+2018-05-18 Mark Wielaard <mark@klomp.org>
+
+ * libdw_findcu.c (__libdw_intern_next_unit): Init files to NULL.
+ * dwarf_getsrclines.c (dwarf_getsrclines): Handle split units by
+ taking the line table from the skeleton.
+ * dwarf_getsrcfiles.c (dwarf_getsrcfiles): Handle split units by
+ only taking the files from .debug_line offset zero (if it exists),
+ otherwise fall back to the skeleton.
+
2018-05-17 Mark Wielaard <mark@klomp.org>
* dwarf_begin_elf.c (__libdw_debugdir): New function.
/* Return source file information of CU.
- Copyright (C) 2004, 2005, 2013, 2015 Red Hat, Inc.
+ Copyright (C) 2004, 2005, 2013, 2015, 2018 Red Hat, Inc.
This file is part of elfutils.
- Written by Ulrich Drepper <drepper@redhat.com>, 2004.
This file is free software; you can redistribute it and/or modify
it under the terms of either
/* Get the information if it is not already known. */
struct Dwarf_CU *const cu = cudie->cu;
- if (cu->lines == NULL)
+ if (cu->files == NULL)
{
- Dwarf_Lines *lines;
- size_t nlines;
-
- /* Let the more generic function do the work. It'll create more
- data but that will be needed in an real program anyway. */
- res = INTUSE(dwarf_getsrclines) (cudie, &lines, &nlines);
+ /* For split units there might be a simple file table (without lines).
+ If not, use the one from the skeleton. */
+ if (cu->unit_type == DW_UT_split_compile
+ || cu->unit_type == DW_UT_split_type)
+ {
+ /* We tried, assume we fail... */
+ cu->files = (void *) -1;
+
+ /* See if there is a .debug_line section, for split CUs
+ the table is at offset zero. */
+ if (cu->dbg->sectiondata[IDX_debug_line] != NULL)
+ {
+ /* We are only interested in the files, the lines will
+ always come from the skeleton. */
+ res = __libdw_getsrclines (cu->dbg, 0,
+ __libdw_getcompdir (cudie),
+ cu->address_size, NULL,
+ &cu->files);
+ }
+ else
+ {
+ Dwarf_CU *skel = __libdw_find_split_unit (cu);
+ if (skel != NULL)
+ {
+ Dwarf_Die skeldie = CUDIE (skel);
+ res = INTUSE(dwarf_getsrcfiles) (&skeldie, files, nfiles);
+ cu->files = skel->files;
+ }
+ }
+ }
+ else
+ {
+ Dwarf_Lines *lines;
+ size_t nlines;
+
+ /* Let the more generic function do the work. It'll create more
+ data but that will be needed in an real program anyway. */
+ res = INTUSE(dwarf_getsrclines) (cudie, &lines, &nlines);
+ }
}
else if (cu->files != (void *) -1l)
/* We already have the information. */
struct Dwarf_CU *const cu = cudie->cu;
if (cu->lines == NULL)
{
+ /* For split units always pick the lines from the skeleton. */
+ if (cu->unit_type == DW_UT_split_compile
+ || cu->unit_type == DW_UT_split_type)
+ {
+ /* We tries, assume we fail... */
+ cu->lines = (void *) -1l;
+
+ Dwarf_CU *skel = __libdw_find_split_unit (cu);
+ if (skel != NULL)
+ {
+ Dwarf_Die skeldie = CUDIE (skel);
+ int res = INTUSE(dwarf_getsrclines) (&skeldie, lines, nlines);
+ if (res == 0)
+ {
+ cu->lines = skel->lines;
+ *lines = cu->lines;
+ *nlines = cu->lines->nlines;
+ }
+ return res;
+ }
+
+ __libdw_seterrno (DWARF_E_NO_DEBUG_LINE);
+ return -1;
+ }
+
/* Failsafe mode: no data found. */
cu->lines = (void *) -1l;
cu->files = (void *) -1l;
newp->subdie_offset = subdie_offset;
Dwarf_Abbrev_Hash_init (&newp->abbrev_hash, 41);
newp->orig_abbrev_offset = newp->last_abbrev_offset = abbrev_offset;
+ newp->files = NULL;
newp->lines = NULL;
newp->locs = NULL;
newp->split = (Dwarf_CU *) -1;
+2018-05-18 Mark Wielaard <mark@klomp.org>
+
+ * run-get-files.sh: Add testcases for testfile-splitdwarf-4,
+ testfile-hello4.dwo, testfile-world4.dwo and testfile-splitdwarf-5,
+ testfile-hello5.dwo, testfile-world5.dwo.
+
2018-05-17 Mark Wielaard <mark@klomp.org>
* Makefile.am (check_PROGRAMS): Add attr-integrate-skel.
file[1] = "/shoggoth/drepper/m.c"
EOF
+# see tests/testfile-dwarf-45.source
+testfiles testfile-splitdwarf-4 testfile-hello4.dwo testfile-world4.dwo
+testfiles testfile-splitdwarf-5 testfile-hello5.dwo testfile-world5.dwo
+
+testrun_compare ${abs_builddir}/get-files testfile-splitdwarf-4 testfile-hello4.dwo testfile-world4.dwo <<\EOF
+cuhl = 11, o = 0, asz = 8, osz = 4, ncu = 52
+ dirs[0] = "/home/mark/src/elfutils/tests"
+ dirs[1] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include"
+ file[0] = "???"
+ file[1] = "/home/mark/src/elfutils/tests/hello.c"
+ file[2] = "/home/mark/src/elfutils/tests/hello.h"
+ file[3] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include/stddef.h"
+cuhl = 11, o = 26, asz = 8, osz = 4, ncu = 104
+ dirs[0] = "/home/mark/src/elfutils/tests"
+ dirs[1] = "/usr/include"
+ file[0] = "???"
+ file[1] = "/home/mark/src/elfutils/tests/world.c"
+ file[2] = "/home/mark/src/elfutils/tests/hello.h"
+ file[3] = "/usr/include/stdlib.h"
+cuhl = 11, o = 0, asz = 8, osz = 4, ncu = 414
+ dirs[0] = "/home/mark/src/elfutils/tests"
+ dirs[1] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include"
+ file[0] = "???"
+ file[1] = "/home/mark/src/elfutils/tests/hello.c"
+ file[2] = "/home/mark/src/elfutils/tests/hello.h"
+ file[3] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include/stddef.h"
+cuhl = 11, o = 0, asz = 8, osz = 4, ncu = 331
+ dirs[0] = "/home/mark/src/elfutils/tests"
+ dirs[1] = "/usr/include"
+ file[0] = "???"
+ file[1] = "/home/mark/src/elfutils/tests/world.c"
+ file[2] = "/home/mark/src/elfutils/tests/hello.h"
+ file[3] = "/usr/include/stdlib.h"
+EOF
+
+testrun_compare ${abs_builddir}/get-files testfile-splitdwarf-5 testfile-hello5.dwo testfile-world5.dwo <<\EOF
+cuhl = 20, o = 0, asz = 8, osz = 4, ncu = 53
+ dirs[0] = "/home/mark/src/elfutils/tests"
+ dirs[1] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include"
+ file[0] = "/home/mark/src/elfutils/tests/hello.c"
+ file[1] = "/home/mark/src/elfutils/tests/hello.c"
+ file[2] = "/home/mark/src/elfutils/tests/hello.h"
+ file[3] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include/stddef.h"
+cuhl = 20, o = 21, asz = 8, osz = 4, ncu = 106
+ dirs[0] = "/home/mark/src/elfutils/tests"
+ dirs[1] = "/usr/include"
+ file[0] = "/home/mark/src/elfutils/tests/world.c"
+ file[1] = "/home/mark/src/elfutils/tests/world.c"
+ file[2] = "/home/mark/src/elfutils/tests/hello.h"
+ file[3] = "/usr/include/stdlib.h"
+cuhl = 20, o = 0, asz = 8, osz = 4, ncu = 386
+ dirs[0] = "/home/mark/src/elfutils/tests"
+ dirs[1] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include"
+ file[0] = "/home/mark/src/elfutils/tests/hello.c"
+ file[1] = "/home/mark/src/elfutils/tests/hello.c"
+ file[2] = "/home/mark/src/elfutils/tests/hello.h"
+ file[3] = "/opt/local/install/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/include/stddef.h"
+cuhl = 20, o = 0, asz = 8, osz = 4, ncu = 296
+ dirs[0] = "/home/mark/src/elfutils/tests"
+ dirs[1] = "/usr/include"
+ file[0] = "/home/mark/src/elfutils/tests/world.c"
+ file[1] = "/home/mark/src/elfutils/tests/world.c"
+ file[2] = "/home/mark/src/elfutils/tests/hello.h"
+ file[3] = "/usr/include/stdlib.h"
+EOF
+
exit 0