This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Map Linux asm address with the Source code

Hi Experts,

When the kernel panic occurs the function_name + <offset_addr> will be printed in the terminal.

How to map exactly with the Linux source code with the respective lines of .C file. Is there any tools available ?

  • Hi Lyf,

    In general, either you can use the grep command to find the existence of the function in the files.

    Then use gdb on the *.o and then use the gdb "list" command, (gdb) list *(function+0xoffset)

    something like below:

    [  174.508125]  [<c039ce30>] ? sd_remove+0x20/0x70

    [  174.508235]  [<c0398f22>] ? scsi_bus_remove+0x32/0x40

    [  174.508326]  [<c037deee>] ? __device_release_driver+0x3e/0x70

    [  174.508421]  [<c037dfe0>] ? device_release_driver+0x20/0x40

    #gdb sd.o

    GNU gdb (GDB) 6.8.50.20090628-cvs-debian

    .....

    .......

    This is free software: you are free to change and redistribute it.

    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

    and "show warranty" for details.

    This GDB was configured as "x86_64-linux-gnu".

    ...........

    ............

    (gdb) list *(sd_remove+0x20)

    0x1650 is in sd_remove (/home/manjo/devel/ubuntu/kernel/ubuntu-karmic-397906/drivers/scsi/sd.c:2125).

    2120    static int sd_remove(struct device *dev)

    2121    {

    2122            struct scsi_disk *sdkp;

    2123    

    2124            async_synchronize_full();

    2125            sdkp = dev_get_drvdata(dev);

    2126            blk_queue_prep_rq(sdkp->device->request_queue, scsi_prep_fn);

    2127            device_del(&sdkp->dev);

    2128            del_gendisk(sdkp->disk);

    2129            sd_shutdown(dev);

    (gdb)

    Regards,

    Shankari