On Fri, Jun 14, 2002 at 06:58:38PM -0700, Micah Cowan wrote: > Peter Jay Salzman writes: > > hey there, > > > > every tutorial on gdb says "compile with -g" within the first few lines. > > but what if you don't? or rather, what if you can't compile with -g? > > > > but how do you inspect arguments, local variables, etc. in a given frame > > if you don't know the address of these variables because the symbol > > table is unavailable? > > Well, without compiling with -g, you obviously don't have the > convenience of debugging symbols and whatnot - but you should still be > able to examine the program as raw assembly (hey, it's better than raw > machine code). > > I just tried it on /bin/echo (stripped). > > You can set the initial breakpoint with: b main > > after beginning the run, you'll be in main, and you can use: disas > to disassemble the current function. You'll get the whole > function. You can set breakpoints at specific addresses, and move on > that way. > > It's a mess, but it's something. > > I'm no gdb expert, so I'm sure someone can offer better advice than > this...? > > Micah
What you're looking for is a decompiler, such as the one described in Cifuentes, but they're scarce as hen's teeth: http://www.sable.mcgill.ca/publications/papers/2002-2/sable-paper-2002-2.ps.gz Your next option is studying up on your CPU's instruction set and application binary interface (ABI) specification, and reading the code. If you've got a typical Elf object file, the binary exposes some symbols to the linker (man objdump -- and it has a built-in disassembler). At least you'll have the entry point (as Micah pointed out), the exit call, and anyplace a library function is called. You've got to be seriously motivated to go this route: I've had decades of practice yet it remains a major undertaking to debug without a symbol table. > what if you can't compile with -g? Can you explain why not (or is that hypothetical) ? Maybe you can generate a map file and use that for your landmarks. Is hyperthetical the opposite of hypothetical, and does it have anything to do with coffee? -- The US Constitution isn't perfect. But it's better than what we have now. _______________________________________________ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech