0

I'm asking this because I've been given a task which I don't yet know how to handle. You see, we're in a situation where we can execute legacy a.out programs on a virtual machine running a really old linux kernel. We would like the native MinGW gdb to debug the program somehow. It's been proposed that we convert the a.out file into a PE file containing debug symbols and send it to GDB to process, while actually running the UNIX a.out file on the virtual machine. The only available debug symbols that comes with the a.out file is STABS, since the version of GCC used on the VM is very old.

I understand that it's possible to add STABS debug information into a PE file. GCC does it, and I've done experiments with objdump and gdb comprehensively enough to come to to the conclusion that STABS works with MinGW GDB. So how do I achieve it? How did GCC approach it?

Thank you.

Einheri
  • 957
  • 1
  • 9
  • 22
  • Why are you trying to do it with a PE if your actual goal is an a.out? – Jonathon Reinhart Jan 03 '14 at 07:44
  • @JonathonReinhart not quite. The a.out file is to be run on linux, within the virtual machine; the version of GDB used is the one that comes with MinGW, which accepts PE files only. – Einheri Jan 03 '14 at 07:47
  • I'm not quite following you, I thought STABS was still supported. Remotely debugging the Linux process running from a virtual machine through a Windows host is certainly possible (albeit fiddly) but you seem to be suggesting trying to use symbolic from a native Windows build for tracing the remote process. That won't work, if nothing else the offsets in the debugging data will be nothing alike and you'll be stepping through garbage. Why can't you simply debug the process natively? – doynax Jan 03 '14 at 08:32
  • @doynax I don't know if I've got the facts straight from my supervisor, but the existing product compiles linux kernel code into an exe file, which is then processed into a bin file to run on the VM. The idea is to debug both the kernel and the application running on the kernel with the same debugger. – Einheri Jan 03 '14 at 08:38
  • @doynax So the idea is that we run the a.out file on linux through the VM, convert the a.out file of the application to a PE file for the windows-based MinGW gdb to debug. the virtual machine program (Bochs) would send GDB information on where a breakpoint is, and GDB, referring to the PE file, returns whatever information it derives from debug symbols. Can this approach ever work out? – Einheri Jan 03 '14 at 08:43
  • Theoretically, if you massage the very same binary as is being run on the VM into a PE executable "frame" I suppose it might work but that's deep voodoo, probably with umpteen gotchas I haven't thought about (how to get the base address across, etc). But why are you attempting to debug with a modern MinGW GDB rather than that of the (cross?) compilation toolchain producing the binary in the first place? – doynax Jan 03 '14 at 09:09
  • It's easy to build a multi-target gdb. I recommend you just build your own gdb and debug the a.out that you are actually running. This will remove many obscure headaches. – Tom Tromey Jan 03 '14 at 19:17

0 Answers0