hi,

 I can't trace kmem_cache_init function with GDB, because gdb jump to wrong 
source line. Is there anyone know how to fix this issue?


[real@name tmp]$ tar -Jxf linux-3.12.6.tar.xz 
[real@name tmp]$ cd linux-3.12.6/
[real@name linux-3.12.6]$ make ARCH=um defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --defconfig arch/x86/um/Kconfig
#
# configuration written to .config
#
[real@name linux-3.12.6]$ make ARCH=um linux 1>log.txt
arch/um/kernel/ptrace.c: In function ‘syscall_trace_enter’:
arch/um/kernel/ptrace.c:178:32: warning: ignoring return value of 
‘tracehook_report_syscall_entry’, declared with attribute warn_unused_result 
[-Wunused-result]
  tracehook_report_syscall_entry(regs);
                                ^


[real@name linux-3.12.6]$ 
[real@name linux-3.12.6]$ cat gdb.txt 
file linux
handle SIGSEGV pass nostop noprint
handle SIGUSR1 pass nostop noprint

b kmem_cache_init
b create_boot_cache

r ubda=/home/real/uml/linux-3.12.6/Fedora20-x86-root_fs mem=256m
[real@name linux-3.12.6]$ 



[real@name linux-3.12.6]$ gdb -q  -x gdb.txt
Breakpoint 1 at 0x8050a57: file mm/slab.c, line 1512.
Breakpoint 2 at 0x804f7c5: file mm/slab_common.c, line 296.
Locating the bottom of the address space ... 0x10000
Locating the top of the address space ... 0xffffd000
Core dump limits :
        soft - 0
        hard - NONE
Checking that ptrace can change system call numbers...Detaching after fork from 
child process 16850.
OK
Checking syscall emulation patch for ptrace...Detaching after fork from child 
process 16851.
OK
Checking advanced syscall emulation patch for ptrace...Detaching after fork 
from child process 16852.
OK
Checking for tmpfs mount on /dev/shm.../dev/shm...nothing mounted on /dev/shm
Checking PROT_EXEC mmap in /tmp/...OK
Detaching after fork from child process 16853.
Checking for the skas3 patch in the host:
  - /proc/mm...not found: No such file or directory
  - PTRACE_FAULTINFO...Detaching after fork from child process 16854.
not found
  - PTRACE_LDT...Detaching after fork from child process 16855.
not found
UML running in SKAS0 mode

Breakpoint 1, kmem_cache_init () at mm/slab.c:1512
1512    {
Missing separate debuginfos, use: debuginfo-install glibc-2.17-20.fc19.i686
(gdb) c
Continuing.

Breakpoint 2, create_boot_cache (s=0x82bdaf8 <kmem_cache_boot>, name=0x82650f5 
"kmem_cache", size=92, 
    flags=8192) at mm/slab_common.c:296
296     {
(gdb) n
299             s->name = name;
(gdb) 
296     {
(gdb) 
299             s->name = name;
(gdb) 
300             s->size = s->object_size = size;
(gdb) 
301             s->align = calculate_alignment(flags, ARCH_KMALLOC_MINALIGN, 
size);
(gdb) 
302             err = __kmem_cache_create(s, flags);
(gdb) s
__kmem_cache_create (cachep=0x82bdaf8 <kmem_cache_boot>, flags=8192) at 
mm/slab.c:2222
2222    {
(gdb) n
2226            size_t size = cachep->size;
(gdb) 
2251            if (size & (BYTES_PER_WORD - 1)) {
(gdb) 
2264            if (flags & SLAB_RED_ZONE) {
(gdb) 
2273            if (ralign < cachep->align) {
(gdb) 
2278                    flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
(gdb) 
2282            cachep->align = ralign;
(gdb) 
2284            if (slab_is_available())
(gdb) p slab_state
$1 = DOWN
(gdb) where
#0  __kmem_cache_create (cachep=0x82bdaf8 <kmem_cache_boot>, flags=8192) at 
mm/slab.c:2284
#1  0x0804f7f6 in create_boot_cache (s=0x82bdaf8 <kmem_cache_boot>, 
name=0x82650f5 "kmem_cache", 
    size=92, flags=8192) at mm/slab_common.c:302
#2  0x08050b1b in kmem_cache_init () at mm/slab.c:1559
#3  0x08049486 in mm_init () at init/main.c:468
#4  start_kernel () at init/main.c:532
#5  0x0804a6d8 in start_kernel_proc (unused=0x0) at 
arch/um/kernel/skas/process.c:46
#6  0x08059323 in new_thread_handler () at arch/um/kernel/process.c:140
#7  0x00000000 in ?? ()
(gdb) l mm/slab.c:2284
2279            /*
2280             * 4) Store it.
2281             */
2282            cachep->align = ralign;
2283    
2284            if (slab_is_available())
2285                    gfp = GFP_KERNEL;
2286            else
2287                    gfp = GFP_NOWAIT;
2288    

(gdb) p slab_state
$2 = DOWN
(gdb) n
2285                    gfp = GFP_KERNEL;
(gdb) n
2289            setup_node_pointer(cachep);
(gdb) n
2285                    gfp = GFP_KERNEL;


Start from 2289, gdb start jump to wrong source line. GDB should jump to 
"2287                   gfp = GFP_NOWAIT;"
But it never hit it. And from here, gdb can't match the execuable UML kernel 
with source.


(gdb) n
2327            if ((size >= (PAGE_SIZE >> 3)) && !slab_early_init &&



And I found that "file" command says the file format is different.
[real@name mm]$ pwd
/tmp/linux-3.12.6/mm
[real@name mm]$ file *.c | sort -k 2
percpu-vm.c:          ASCII text
filemap.c:            assembler source, ASCII text
memcontrol.c:         assembler source, ASCII text
ksm.c:                C source, ASCII text
mmap.c:               C source, ASCII text
rmap.c:               C source, ASCII text
slab.c:               C source, ASCII text
slob.c:               C source, ASCII text
slub.c:               C source, ASCII text

Why percpu-vm.c, filemap.c and memcontrol.c has different format?

thanks

------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user

Reply via email to