Module API - #12
Module API#12oltolm wants to merge 3 commits into
Conversation
|
I think there is some misunderstanding what Looking at And even In my opinion this calls for specialized functions for both of these cases, and not extending the callback with unrelated functionality. That being said, the first 2 patches are fine in principle, but probably not very useful on its own. |
Split dwstOfFileExt() into dwstModuleOpen(), which builds the CU table, dwstOfModuleExt(), which resolves addresses with it, and dwstModuleClose(). Applications which already have a Dwarf_Debug of a module (e.g. drmingw) can build the CU table once and reuse it. The Dwarf_Debug is passed as void* so dwarfstack.h doesn't depend on libdwarf.h, and it is owned by the caller.
Resolve addresses with a module created by dwstModuleOpen(), without reading the debug information and the CU table again for every call.
I don't quite understand. A source location is a file name + line numer. Do you mean that it doesn't work when there are inlined functions? The last callback wins, which is the outermost function, which is correct for
The last callback wins, which is also correct for
It does not care about inlined functions, that's right. The displacements are also mostly correctly calculated, with the exception of line addresses because DWARF does not have all the information, but I also don't really care about displacements. But having said that, I am not insisting on this API. If you have a better proposal then that's even better. |
dwstOfModule() and dwstOfModuleW() now call the callback with DWST_FUNC_ADDR and DWST_LINE_ADDR before each resolved frame, with the start address of the function and of the source line. This allows callers to compute the displacement of an address inside a function or line. For an address inside inlined code, e.g. inner() inlined into outer(), the callback is called for inner() and then for outer(), each preceded by its own DWST_FUNC_ADDR and DWST_LINE_ADDR. As with dwstOfFile(), addr is 0 for outer(), so callers compute the displacement from the address they looked up. DWST_LINE_ADDR is 0 for outer() here, since DWARF doesn't store where the code of the line calling inner() starts. dwstOfFile() and dwstOfProcess() don't report them, since existing callbacks don't expect a NULL filename.
I mean it doesn't work for variable symbols, only functions.
You're right, if you only care about the last callback, this works.
If the displacement doesn't matter, then what is the DWST_LINE_ADDR callback for?
That would be easier if I knew what these functions will be later used for. |
It is for displacement, I just meant that DWARF only has the line address for the innermost inlined function and I am not going to try to fix it.
I only know of two users, drmingw and my fork of VerySleepy. Both use In the future I plan to also implement |
drmingw is now using dwarfstack, but it's using a fork because it needs an API that dwarfstack does not provide. So I have come up with a new API.
This is needed to calculate the displacement for
SymGetLineFromAddr64.This is needed to calculate the displacement for
SymGetSymFromAddr64.These functions are needed for opening and closing modules. drmingw needs to be able to cache the module information. Opening and closing the module each time is too expensive.