Bug 15014

Summary: DDB can't find symbol for address in kernel loadable modules.
Product: Base System Reporter: Vladimir N.Silyaev <vns>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-CURRENT   
Hardware: Any   
OS: Any   

Description Vladimir N.Silyaev 1999-11-21 06:20:00 UTC
	DDB can't locate names to stack frame, when frames include pointer
        from kernel loadable module

Fix: Apply the following patch.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


After applying this patch, in the same circumstance, trace will be printing:
db> trace
linux_open(c4324280,c45f3f80,28051dc6,3,28054a10) at linux_open
syscall(2f,2f,2f,28054a10,3) at syscall+0x119
Xint0x80_syscall() at Xint0x80_syscall+0x26


P.S. It's looks like that the /sys/kern/link_aout.c have the same kind
of problem.--DwhcW3yPVfRLJaH6h0lqgbR6Je9Lx6w7LJR4CBVZJdmweEAU
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- /sys/kern/link_elf.c.orig	Fri Oct 29 18:12:02 1999
+++ /sys/kern/link_elf.c	Sat Nov 20 17:51:16 1999
@@ -958,17 +958,19 @@
 	const Elf_Sym* es;
 	const Elf_Sym* best = 0;
 	int i;
+	u_long st_value;
 
 	for (i = 0, es = ef->ddbsymtab; i < ef->ddbsymcnt; i++, es++) {
 		if (es->st_name == 0)
 			continue;
-		if (off >= es->st_value) {
-			if (off - es->st_value < diff) {
-				diff = off - es->st_value;
+		st_value = es->st_value + (u_long)ef->address;
+		if (off >= st_value) {
+			if (off - st_value < diff) {
+				diff = off - st_value;
 				best = es;
 				if (diff == 0)
 					break;
-			} else if (off - es->st_value == diff) {
+			} else if (off - st_value == diff) {
 				best = es;
 			}
 		}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
How-To-Repeat: 
- Build kernel with DDB support.
- Load linux KLD (launch linux command).

Throw to DDB, then 
db> b linux_open
db> c

Run any linux command, for example:
> /compat/linux/bin/bash

Breakpoint at   linux_open:     pushl   %ebp
db> trace
_end(c4324280,c45f3f80,28051dc6,3,28054a10) at 0xc06ef344
syscall(2f,2f,2f,28054a10,3) at syscall+0x119
Xint0x80_syscall() at Xint0x80_syscall+0x26
db> c
Comment 1 Peter Wemm freebsd_committer freebsd_triage 1999-11-28 14:51:41 UTC
State Changed
From-To: open->closed

Suggested changes applied and adapted for the link_aout.c code, revs: 
1.22      +7 -5      src/sys/kern/link_elf.c 
1.23      +7 -5      src/sys/kern/link_aout.c 
1.17.2.2  +7 -5      src/sys/kern/link_aout.c 
1.11.2.2  +7 -5      src/sys/kern/link_elf.c 
(The last two being -stable).  Thanks! 
Comment 2 Philip M. Gollucci freebsd_committer freebsd_triage 2010-09-09 07:32:47 UTC
Responsible Changed
From-To: freebsd-bugs->pgollucci

I will take it
Comment 3 Philip M. Gollucci freebsd_committer freebsd_triage 2010-09-09 07:34:13 UTC
Responsible Changed
From-To: pgollucci->freebsd-bugs

fat fingered the pr #