Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/cddl/osnet/dist/tools/ctf/cvt Handle assembly code ...



details:   https://anonhg.NetBSD.org/src/rev/3e2bca12389d
branches:  trunk
changeset: 795285:3e2bca12389d
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Apr 05 23:33:15 2014 +0000

description:
Handle assembly code built with -g

diffstat:

 external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c |  32 +++++++++++++++++++------
 1 files changed, 24 insertions(+), 8 deletions(-)

diffs (55 lines):

diff -r 4524aaa5a755 -r 3e2bca12389d external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c
--- a/external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c    Sat Apr 05 22:41:50 2014 +0000
+++ b/external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c    Sat Apr 05 23:33:15 2014 +0000
@@ -1924,7 +1924,6 @@
                        char *name;
 
                        name = elf_strptr(elf, shdr.sh_link, sym.st_name);
-fprintf(stderr, "name = %s\n", name);
 
                        /* Studio emits these local symbols regardless */
                        if ((strcmp(name, "Bbss.bss") != 0) &&
@@ -1995,14 +1994,28 @@
            &addrsz, &offsz, NULL, &nxthdr, &dw.dw_err)) != DW_DLV_OK)
                terminate("rc = %d %s\n", rc, dwarf_errmsg(dw.dw_err));
 
-       if ((cu = die_sibling(&dw, NULL)) == NULL ||
-           (((child = die_child(&dw, cu)) == NULL) &&
-           should_have_dwarf(elf))) {
-               terminate("file does not contain dwarf type data "
-                   "(try compiling with -g)\n");
-       } else if (child == NULL) {
+       if ((cu = die_sibling(&dw, NULL)) == NULL)
+               goto out;
+
+       if ((child = die_child(&dw, cu)) == NULL) {
+               Dwarf_Unsigned lang;
+               if (die_unsigned(&dw, cu, DW_AT_language, &lang, 0)) {
+                       debug(1, "DWARF language: %u\n", lang);
+                       /*
+                        * Assembly languages are typically that.
+                        * They have some dwarf info, but not what
+                        * we expect. They have local symbols for
+                        * example, but they are missing the child info.
+                        */
+                       if (lang >= DW_LANG_lo_user)
+                               return 0;
+               }
+               if (should_have_dwarf(elf))
+                       goto out;
+       }
+
+       if (child == NULL)
                return (0);
-       }
 
        dw.dw_maxoff = nxthdr - 1;
 
@@ -2044,4 +2057,7 @@
        /* leak the dwarf_t */
 
        return (0);
+out:
+       terminate("file does not contain dwarf type data "
+           "(try compiling with -g)\n");
 }



Home | Main Index | Thread Index | Old Index