gimli-rs/ddbug

Export to other formats?

0ff opened this issue · 3 comments

0ff commented

Hi, I'm using ddbug for reverse-engineering a binary (that, as luck would have it, includes dwarf) - in fact, it's pretty much the only tool I was able to find that can understand (the helplessly outdated) DWARF 2 correctly (without segfaulting (dwarfdump, readelf), hanging (IDA), producing completely wrong output (pyelftools) or simply refusing to load the binary (gdb)).

After playing around with the html export, I began wondering if other exports would make sense to you?
How about JSON (for further processing), C-Style header files (at least for functions, structs, enums) and maybe even idc-Files for use with IDA?
I began implementing JSON export by adding serde to many of the internal data structures, but I was wondering if that would even be something you'd be interested in? It would probably require changes in the way you keep track of data - for instance an EnumerationType currently doesn't know any of it's enumerators without being given the File - this doesn't play too well with serde's way of serializing data ;-)

So this "issue" is pretty much a request for discussion - would you like to see more outputs such as JSON and are you open for changes to the data structures should those be needed?

Hi, I'm glad to hear it's useful!

The requirement for enumerators to be given a file is intentional. This lets us reduce the memory usage. For enumerators this wouldn't be too bad to change, but for functions I definitely don't want to be loading all the inlined functions, variables, and locations up front.

I think adding exports for JSON, C-Style headers and idc-Files would be fine. It may make sense for this to be in another crate, since it wouldn't share much with the existing text/html output. It would be fine for that crate to be kept in this git repo though.

Some changes to the data structures are okay, as long as it doesn't significantly affect performance.

I am just starting to try ddbug, and JSON would be great in order to parse it with other tools (let's say, a Python script) :)

Just a FYI for random people reading this, I made a tool to format the output file to JSON for my own micro controller projects. Only C based projects work at the moment (C++ not supported). Perhaps it may be useful to somebody.