On Monday 08 Mar 2004 4:19 pm, Amit S. Kale wrote: > On Monday 08 Mar 2004 3:56 pm, Andrew Morton wrote: > > "Amit S. Kale" wrote: > > > Here are features that are present only in full kgdb: > > > 1. Thread support (aka info threads) > > > > argh, disaster. I discussed this with Tom a week or so ago when it > > looked like this it was being chopped out and I recall being told that > > the discussion was referring to something else. > > > > Ho-hum, sorry. Can we please put this back in? > > Err., well this is one of the particularly dirty parts of kgdb. That's why > it's been kept away. It takes care of correct thread backtraces in some > rare cases. > > If you consider it an absolutely must, we can do something so that the > dirty part is kept away and info threads almost always works. I attempted it and found that it works better than my expectation! I am attaching revised core-lite.patch with this email and sending i386-lite.patch as a reply. Here is the code that extract registers of a sleeping thread: /* * Extracts ebp, esp and eip values understandable by gdb from the values * saved by switch_to. * thread.esp points to ebp. flags and ebp are pushed in switch_to hence esp * prior to entering switch_to is 8 greater then the value that is saved. * If switch_to changes, change following code appropriately. */ void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) { gdb_regs[_EAX] = 0; gdb_regs[_EBX] = 0; gdb_regs[_ECX] = 0; gdb_regs[_EDX] = 0; gdb_regs[_ESI] = 0; gdb_regs[_EDI] = 0; gdb_regs[_EBP] = *(unsigned long *)p->thread.esp; gdb_regs[_DS] = __KERNEL_DS; gdb_regs[_ES] = __KERNEL_DS; gdb_regs[_PS] = 0; gdb_regs[_CS] = __KERNEL_CS; gdb_regs[_PC] = p->thread.eip; gdb_regs[_ESP] = p->thread.esp + 8; gdb_regs[_SS] = __KERNEL_DS; gdb_regs[_FS] = 0xFFFF; gdb_regs[_GS] = 0xFFFF; } Here is the prologue for schedule 0xc0119f70 : push %ebp 0xc0119f71 : mov %esp,%ebp 0xc0119f73 : mov $0xffffe000,%edx 0xc0119f78 : push %edi 0xc0119f79 : push %esi 0xc0119f7a : push %ebx 0xc0119f7b : sub $0x3c,%esp gdb is capable of parsing this prolog and figure out saved registers even in absence of dwarf debugging information. edi, esi, ebx and ebp are saved in standard pattern. eax, ecx and edx are call clobbered, hence not used to store locals in a function calling schedule. Hence gdb can print correct backtraces with _all_ locals even in callers of schedule!! -Amit