In Java: C / C ++ variable address determination when executing COFF / ELF / DWARF executable

This is the situation I am facing now:

For an embedded system that does not use virtual addressing, I have an executable that was compiled with C or C ++ code with debugging information enabled. Usually it is COFF or ELF / DWARF (I get these two mixed) formats.

At run time, on a PC, I would like to determine the address of a variable with its name. (for example, "foo.bar [7] .baz") This allows me to read / write the value of a variable into the embedded system (given the debugging protocol that goes beyond the scope of this question). Obviously, any stack-based or heap-based variables are missing, since they do not have static addresses.

I did this in front of me in C ++ to parse the COFF files from the TI compiler for my 2800 series DSP systems, and it was kind of a pain. I was wondering if there is a Java library there that already does such things, since I am faced with the same as the executable files of one or two other processors.


Update: (11/18/2009) A promising clue!

Has anyone out there used the Eclipse CDT ELF parser?

(see http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.cdt.doc.isv/reference/api/org/eclipse/cdt/core/model/IBinary.html for one of javadoc pgs)

TI Code Composer 4 (based on Eclipse) seems to be using this, so it seems that if I can figure out where the documentation is, maybe I can use this to solve my problem.

+5
2

gdb ?

, , , GDB Remote Serial Protocol TCP socket gdb .

-

gdb < - gdb protocol → java-prog < - → target

, ,

  • java-prog
  • gdb your-executable java-prog

    (gdb) target remote 127.0.0.1:port

  • gdb

    (gdb) p foo.bar [7].baz

gdb, java-prog TCP. java-prog gdb .

+2

JNI- GNU binutils, . , GPL , .

+1

All Articles