1

I would like to create a program in C under Windows using the libdwarf library that is able to extract information about a variable given as input. The program should output the size in bytes of the variable and the type (unsigned, signed, float).

So far I was able to compile the library under Windows, but I'm having a hard time figuring out all the library functions. What I need is a function that takes a string (name of the variable) and outputs a DIE offset. After that I can use other functions to extract the type attribute at the given DIE offset.

Does such a function exist?

1 Answer 1

0

Windows uses the PE format, not ELF, for executables so it seems odd that you are doing this under windows.

Using libdwarf it should be possible to figure out the size and type of a variable, but there is no function in the library that operates at that high level. I believe what you need to do is roughly 1. iterate over compilation units with dwarf_next_cu_header 2. Get the first DIE in the CU with dwarf_siblingof 3. Walk the DIE tree to find the DIE you need 4. Get information about that DIE

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.