libdwarf
Attaching a tied dbg

Example attaching base dbg to a split-DWARF object.

See DWARF5 Appendix F on Split-DWARF.

By libdwarf convention, open the split Dwarf_Debug using a dwarf_init call. Then open the executable as the tied object. Then call dwarf_set_tied_dbg() so the library can look for relevant data in the tied-dbg (the executable).

With split dwarf your libdwarf calls after the the initial open are done against the split Dwarf_Dbg and libdwarf automatically looks in the tied dbg when and as appropriate. the tied_dbg can be detached too, see example3 link, though you must call dwarf_finish() on the detached dw_tied_dbg, the library will not do that for you.

Parameters
split_dbg
tied_dbg
error
Returns
Returns DW_DLV_OK or DW_DLV_ERROR or DW_DLV_NO_ENTRY to the caller.
*/
int example2(Dwarf_Debug split_dbg, Dwarf_Debug tied_dbg, Dwarf_Error *error)
{
int res = 0;
/* The caller should have opened dbg
on the split-dwarf object/dwp,
an object with DWARF, but no executable
code.
And it should have opened tieddbg on the
runnable shared object or executable. */
res = dwarf_set_tied_dbg(split_dbg,tied_dbg,error);
/* Let the caller (who initialized the dbg
values) deal with doing dwarf_finish()
*/
return res;
}
struct Dwarf_Debug_s * Dwarf_Debug
Definition: libdwarf.h:586
struct Dwarf_Error_s * Dwarf_Error
Definition: libdwarf.h:580
int dwarf_set_tied_dbg(Dwarf_Debug dw_split_dbg, Dwarf_Debug dw_tied_dbg, Dwarf_Error *dw_error)
Use with split dwarf.