]> sourceware.org Git - systemtap.git/commitdiff
PR10538: Give a file:line hint for anonymous types
authorJosh Stone <jistone@redhat.com>
Thu, 20 Aug 2009 01:19:53 +0000 (18:19 -0700)
committerJosh Stone <jistone@redhat.com>
Thu, 20 Aug 2009 01:19:53 +0000 (18:19 -0700)
When we list the possible members for an anonymous struct/union, the
user may want to go look at the source for the type.  That's hard
without a type name, so we now list the decl file:line for them.

* dwflpp.cxx (dwflpp::translate_components): List file:line for anon.

dwflpp.cxx

index dce19f21964d5994777df3038ce3a52bb5e949b2..780a3510b141610bdf1f5bb585d9e3c0dcd4bc01 100644 (file)
@@ -1762,15 +1762,26 @@ dwflpp::translate_components(struct obstack *pool,
               vector<Dwarf_Attribute> locs;
               if (!find_struct_member(c, &parentdie, die, locs))
                 {
+                  /* Add a file:line hint for anonymous types */
+                  string source;
+                  if (!dwarf_hasattr_integrate(&parentdie, DW_AT_name))
+                    {
+                      int line;
+                      const char *file = dwarf_decl_file(&parentdie);
+                      if (file && dwarf_decl_line(&parentdie, &line) == 0)
+                        source = " (" + string(file) + ":"
+                                 + lex_cast<string>(line) + ")";
+                    }
+
                   string alternatives;
                   stringstream members;
                   print_members(&parentdie, members);
                   if (members.str().size() != 0)
-                    alternatives = " (alternatives:" + members.str();
+                    alternatives = " (alternatives:" + members.str() + ")";
                   throw semantic_error("unable to find member '" +
                                        c.member + "' for "
                                        + dwarf_type_name(&parentdie)
-                                       + alternatives,
+                                       + source + alternatives,
                                        c.tok);
                 }
 
This page took 0.032353 seconds and 5 git commands to generate.