Author Topic: gdb and debug symbols  (Read 13310 times)

Offline decuser

  • Jr. Member
  • *
  • Posts: 11
  • Country: us
gdb and debug symbols
« on: February 03, 2024, 10:25:11 PM »
nasm newb here...

I have started using nasm and I am trying to debug my program. I did nasm -g and ld -g and when I open gdb, or ddd, it shows my listing and will let me step through the code and whatnot, yay! However, when I try to display a variable's address using 'info address bVar1' it says:
Symbol "bVar1" is at 0x402000 in a file compiled without debugging.

What it means, as I understand it, is that the file was not compiled with gnu debugging symbols. Obviously, there are debugging symbols present, but they're in whatever the default format is for nasm. Should I be worried, or just ignore it?

FWIW, stuff like:

(gdb) x/db &bVar1

seems to work:

0x402000 <bVar1>:       17


Thx!

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: gdb and debug symbols
« Reply #1 on: February 04, 2024, 12:13:20 AM »
It may help to tell Nasm  "-F dwar"
Start your cide wuth a singke byte opcode  I like
"nop

st,
BeFrank


Offline decuser

  • Jr. Member
  • *
  • Posts: 11
  • Country: us
Re: gdb and debug symbols
« Reply #2 on: March 02, 2024, 02:46:18 PM »
Ok. I've since learned a lot more about what I'm doing with this stuff (assembly on Linux). I still have the same issue though.

I've tried adding nop as the first executable instruction:

Code: [Select]
section .data
EOLs: db 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10

section .text

global _start
_start:
    nop

When I fire up gdb, I'm able to debug fine. I can set breakpoints at my labels, step through code, display memory contents with x/, etc. But, if I try to use:

Code: [Select]
info address EOLs
I get

Code: [Select]
Symbol "EOLs" is at 0x402000 in a file compiled without debugging.
Sure enough EOLs is at 0x402000:

Code: [Select]
(gdb) x/16bx &EOLs
0x402000 <EOLs>:        0x0a    0x0a    0x0a    0x0a    0x0a    0x0a    0x0a    0x0a
0x402008:       0x0a    0x0a    0x0a    0x0a    0x0a    0x0a    0x0a    0x0a
(gdb) x/16bx 0x402000
0x402000 <EOLs>:        0x0a    0x0a    0x0a    0x0a    0x0a    0x0a    0x0a    0x0a
0x402008:       0x0a    0x0a    0x0a    0x0a    0x0a    0x0a    0x0a    0x0a

Why does it report that it's in a file compiled without debugging?

Offline decuser

  • Jr. Member
  • *
  • Posts: 11
  • Country: us
Re: gdb and debug symbols
« Reply #3 on: March 02, 2024, 02:47:47 PM »
and I've tried it with no -F, -F stabs, and -Fdwarf, same result.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: gdb and debug symbols
« Reply #4 on: March 02, 2024, 09:22:38 PM »

""Code" is not a "known  section name". Try changing it to .text
Best,
Frank


Offline decuser

  • Jr. Member
  • *
  • Posts: 11
  • Country: us
Re: gdb and debug symbols
« Reply #5 on: March 02, 2024, 09:51:33 PM »
I don't have "Code" anywhere. I have a .text section.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: gdb and debug symbols
« Reply #6 on: March 02, 2024, 10:24:19 PM »
My poor exeszight.

Sorry
Frank

Offline decuser

  • Jr. Member
  • *
  • Posts: 11
  • Country: us
Re: gdb and debug symbols
« Reply #7 on: March 03, 2024, 03:56:36 PM »
You and me, both! Screen’s aren’t big enough. Somebody oughtta...