Search code examples
linuxlinux-kernelgdbddd-debugger

In ddd (display debugger), the source windows doesn't show the original assembly source code for linux debug


I was debugging a linux assembly code but in the assembly source code window, the current line is at the top of the window and all the future lines are display below. I want to see some lines that I have already passed. How can I do that? Please see the photo below. enter image description here


Solution

  • I have done this before but I had forgotten how to do it this time.
    I figured out, the correct method is, when readelf -S vmlinux shows this,

    Section Headers:
      [Nr] Name              Type             Address           Offset
           Size              EntSize          Flags  Link  Info  Align
      [ 0]                   NULL             0000000000000000  00000000
           0000000000000000  0000000000000000           0     0     0
      [ 1] .head.text        PROGBITS         ffffffc008000000  00010000
           0000000000000040  0000000000000000  AX       0     0     4
      [ 2] .text             PROGBITS         ffffffc008010000  00020000
           0000000000389c18  0000000000000008  AX       0     0     65536
      [ 3] .got.plt          PROGBITS         ffffffc008399c18  003a9c18
           0000000000000018  0000000000000008  WA       0     0     8
      [ 4] .rodata           PROGBITS         ffffffc0083a0000  003b0000
           00000000000cc852  0000000000000000  WA       0     0     4096
       .... 
    

    in the debugger command window,

    add-symbol-file ../../LinuxDevDrv/linux-5.15.68/vmlinux -s .text 0x80210000

    In my case, the physical load address of linux 'Image' was 0x80200000. Since the address of .text is 0x10000 from the start of .head.txt(comparing the virtual addresses), I gave 0x80210000 as the physical address of section .text.
    When you do this, the original assembly code appears on the source code window.
    enter image description here