Re: Interleaving assembler & C code for kernel modules ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/17/07, Curran, Dominic <dcurran@xxxxxx> wrote:

I used to write kernel modules for the 2.4 series kernel.

When my driver Oops'ed it would print out the eip line
e.g.
    EIP is at my_func+0xf9/0x3ee [mod_abc]

I could then use objdump to output the assembler interleaved with the C
src code. e.g.
$ objdump -DS mod_abc.o > mod_abc.txt

I could then search through mod_abc.txt to find the start address of
my_func() and add on the offset (0xf9) to find the address of the fault.

Because the C source was interleaved with the assembler then I could
easily pinpoint the offending line of C code.
This made 80% of my kernel debugging much simpler !  :)


PROBLEM:
When I try this with modules built for the 2.6 kernel, objdump doesn't
interleave the C source with the assembler.

$ objdump -DS mod_abc.ko > mod_abc.txt

This makes it MUCH more difficult to relate the offending assembler line
back to C code.  ><

Is there anyway to get an interleaved output of assembler and C code for
a 2.6 kernel module ?

I'm using kernel 2.6.18. I tried the same command ($ objdump -DS
mod_abc.ko > mod_abc.txt) and am getting intermixed C code and
assembly as output:

static inline int list_empty(const struct list_head *head)
{
       return head->next == head;
    474:       8b 4c 24 04             mov    0x4(%esp),%ecx

       if (!list_empty(&active_list)) {
    478:       8d 44 24 04             lea    0x4(%esp),%eax
    47c:       39 c1                   cmp    %eax,%ecx
    47e:       74 4b                   je     4cb <scsi_device_cancel+0xdb>
               list_for_each_safe(lh, lh_sf, &active_list) {
    480:       8b 31                   mov    (%ecx),%esi
* @entry: the element to delete from the list.
*/
static inline void list_del_init(struct list_head *entry)
{
       __list_del(entry->prev, entry->next);
    482:       8b 11                   mov    (%ecx),%edx
    484:       8b 41 04                mov    0x4(%ecx),%eax
    487:       89 42 04                mov    %eax,0x4(%edx)
    48a:       89 10                   mov    %edx,(%eax)
    48c:       89 49 04                mov    %ecx,0x4(%ecx)
    48f:       89 09                   mov    %ecx,(%ecx)
                       scmd = list_entry(lh, struct scsi_cmnd, eh_entry);


Perhaps you forgot to add debug information to the kernel (-g)? You
can also try to turn off all optimizations (-O0) while compiling the
kernel.

Regards,

Rajat

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux