gimli-rs / ddbug

Display debugging information
Apache License 2.0
124 stars 15 forks source link

Add a query interface? #37

Open diguasange opened 1 year ago

diguasange commented 1 year ago

Perhaps ddbug can provide a interface to query the given struct/union, such as:

typedef struct xxx{ int aa; int bb; }xxx_tag;

Input the xxx/xxx_tag,ddbug can output struct info like this:

type xxx_tag = struct xxx size: 8 members: 0[4] aa:int 8[4] bb:int

And if there is a struct-nesting, also output nested structs info. Even support multi-threads to query, ddbug can be a great tool for debugging.

philipc commented 1 year ago

For the command line, filtering by name works already:

$ target/release/ddbug.exe target/debug/ddbug.exe -c type -f name=_IMAGE_FILE_HEADER
struct _IMAGE_FILE_HEADER
        size: 20
        members:
                0[2]    Machine: WORD
                2[2]    NumberOfSections: WORD
                4[4]    TimeDateStamp: DWORD
                8[4]    PointerToSymbolTable: DWORD
                12[4]   NumberOfSymbols: DWORD
                16[2]   SizeOfOptionalHeader: WORD
                18[2]   Characteristics: WORD

I can see it would be useful to add the ability to recursively print anything referenced by the selected items though.

The http interface doesn't have a search function, but it still needs a lot of improvements in general anyway. However, if we did add searching to it then you could click through to see the referenced items.

I'm not sure what you mean by supporting multi-threads to query. Do you mean for calling the parser crate from your own program?

diguasange commented 1 year ago

Yeah, I search a structure info by using ddbug executable file in my own program, and return the result. But when there are too many query requests, processing will be slower, especially when there is nesting. So if there is a way to provide .so or dll libraries, I can query the info by using multi-threads to improve query speed.