Author Topic: Possible bug in Dwarf debug info for Windows  (Read 6050 times)

Offline SeanRamey

  • Jr. Member
  • *
  • Posts: 2
Possible bug in Dwarf debug info for Windows
« on: September 16, 2016, 09:15:21 PM »
I've been trying to build a simple Hello World program for Windows with DWARF debug information with elf object files. I've posted a question on Stack Overflow, but I haven't got much information yet. Somebody used dwarfdump on a build in Ubuntu (so I don't know how much that relates) , and got an error. Here is the Stack Overflow page: http://stackoverflow.com/questions/39502673/nasm-dwarf-error-bad-offset
Stack Overflow has all the information I can give you, including the source code, the error I get from gdb, the build arguments, and all that stuff. The program debugs and runs fine when I build with STABS. When I build with DWARF, I get an error from gdb, however, the program itself builds and runs without a problem, I just can't debug it.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Possible bug in Dwarf debug info for Windows
« Reply #1 on: September 16, 2016, 11:36:24 PM »
Dwarf debug info is for Linux, not Windows. (as is stabs) I am astonished that it works at all! I'm not familiar with MinGW64 - perhaps it has some unusual features. For Windows (which is what you've got code for), I'd go with:
Code: [Select]
nasm -f win32 -g myprog.asm
That should produce debug info for Codeview 8 - the only format available for either win32 or win64. Your informants at Stack Overflow appear to be using Ubuntu, which is Linux, of course. Completely different OS. A lot of people get hold of Linux code (using int 80h) and try to use it on Windows. At least you've got code that's right for Windows. Good luck!

Best,
Frank


Offline SeanRamey

  • Jr. Member
  • *
  • Posts: 2
Re: Possible bug in Dwarf debug info for Windows
« Reply #2 on: September 17, 2016, 11:06:27 AM »
But Mingw64 uses DWARF debug format on Windows just fine! Gdb can't read codeview8 format can it? If not, then I know for sure that Mingw64 is using either DWARF or STABS.

I can compile a C program with these options: -std=c11 -Wall -gstabs+
Or these options: -std=c11 -Wall -gdwarf-3
Or these options: -std=c11 -Wall -gdwarf-4
And they all work just fine. They run, they can be debugged also. Breakpoints work fine, as well as stepping and reading memory and listing source code.

So, either, Mingw64 is just magical, or you CAN in fact use DWARF debug format on Windows just fine.