}
static int
-read_srclines (Dwarf *dbg,
+read_srclines (Dwarf_Die *cudie, Dwarf *dbg,
const unsigned char *linep, const unsigned char *lineendp,
const char *comp_dir, unsigned address_size,
Dwarf_Lines **linesp, Dwarf_Files **filesp)
{
int res = -1;
+ /* Get the information if it is not already known. */
+ struct Dwarf_CU *const cu = cudie->cu;
+
size_t nfilelist = 0;
unsigned int ndirlist = 0;
if (filesp != NULL)
*filesp = files;
+ /* Remember the referring CU. */
+ files->cu = cu;
+
+ /* Make the file data structure available through the CU. */
+ cu->files = files;
+
size_t buf_size = (sizeof (Dwarf_Lines)
+ (sizeof (Dwarf_Line) * state.nlinelist));
void *buf = libdw_alloc (dbg, Dwarf_Lines, buf_size, 1);
int
internal_function
-__libdw_getsrclines (Dwarf *dbg, Dwarf_Off debug_line_offset,
+__libdw_getsrclines (Dwarf_Die *cudie, Dwarf *dbg, Dwarf_Off debug_line_offset,
const char *comp_dir, unsigned address_size,
Dwarf_Lines **linesp, Dwarf_Files **filesp)
{
struct files_lines_s *node = libdw_alloc (dbg, struct files_lines_s,
sizeof *node, 1);
- if (read_srclines (dbg, linep, lineendp, comp_dir, address_size,
+ if (read_srclines (cudie, dbg, linep, lineendp, comp_dir, address_size,
&node->lines, &node->files) != 0)
return -1;
NULL, &debug_line_offset) == NULL)
return -1;
- if (__libdw_getsrclines (cu->dbg, debug_line_offset,
+ if (__libdw_getsrclines (cudie, cu->dbg, debug_line_offset,
__libdw_getcompdir (cudie),
cu->address_size, &cu->lines, &cu->files) < 0)
return -1;
#include "libdwP.h"
int
-dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
+dwarf_macro_getsrcfiles (Dwarf_Die *cudie, Dwarf *dbg, Dwarf_Macro *macro,
Dwarf_Files **files, size_t *nfiles)
{
/* macro is declared NN */
the same unit through dwarf_getsrcfiles, and the file names
will be broken. */
- if (__libdw_getsrclines (dbg, line_offset, table->comp_dir,
+ if (__libdw_getsrclines (cudie, dbg, line_offset, table->comp_dir,
table->is_64bit ? 8 : 4,
NULL, &table->files) < 0)
table->files = (void *) -1;
invalid. (Which is to say it's only valid within the
dwarf_getmacros* callback.) Returns 0 for success or a negative
value in case of an error. */
-extern int dwarf_macro_getsrcfiles (Dwarf *dbg, Dwarf_Macro *macro,
- Dwarf_Files **files, size_t *nfiles)
+extern int dwarf_macro_getsrcfiles (Dwarf_Die *cudie, Dwarf *dbg,
+ Dwarf_Macro *macro, Dwarf_Files **files, size_t *nfiles)
__nonnull_attribute__ (2, 3, 4);
/* Return macro opcode. That's a constant that can be either from
the loaded unit and optionally set *LINESP and/or *FILESP (if not
NULL) with loaded information. Returns 0 for success or a negative
value for failure. */
-int __libdw_getsrclines (Dwarf *dbg, Dwarf_Off debug_line_offset,
+int __libdw_getsrclines (Dwarf_Die *cudie, Dwarf *dbg, Dwarf_Off debug_line_offset,
const char *comp_dir, unsigned address_size,
Dwarf_Lines **linesp, Dwarf_Files **filesp)
internal_function
{
Dwarf_Files *files;
size_t nfiles;
- if (dwarf_macro_getsrcfiles (dbg, macro, &files, &nfiles) < 0)
+ Dwarf_Die cudie_mem, *cudie = dwarf_offdie (dbg, 0, &cudie_mem);
+
+ if (dwarf_macro_getsrcfiles (cudie, dbg, macro, &files, &nfiles) < 0)
printf ("dwarf_macro_getsrcfiles: %s\n",
dwarf_errmsg (dwarf_errno ()));