Bug 17959 - Something (broken DWARF?) causes Systemtap to generate C code with uint0_t types
Summary: Something (broken DWARF?) causes Systemtap to generate C code with uint0_t types
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-11 15:35 UTC by Aram Hăvărneanu
Modified: 2015-04-09 14:56 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Generated src.c. (6.26 KB, text/plain)
2015-02-11 20:32 UTC, Aram Hăvărneanu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aram Hăvărneanu 2015-02-11 15:35:58 UTC
When using systemtap on Go binaries that work around issue 17957 and 17958, systemtap will fail to create the kernel module because the generated C code uses uint0_t types:

/tmp/stapUOqJjk/stap_ea1e3b08acea61492ed2615b6f549cbe_535512_src.c: In function ‘function__dwarf_tvar_get__p__261’:
/tmp/stapUOqJjk/stap_ea1e3b08acea61492ed2615b6f549cbe_535512_src.c:12640:7: error: unknown type name ‘uint0_t’
     { uint0_t value = deref (sizeof addr, addr); addr = value; }
       ^
/tmp/stapUOqJjk/stap_ea1e3b08acea61492ed2615b6f549cbe_535512_src.c: In function ‘function__dwarf_tvar_get__p__585’:
/tmp/stapUOqJjk/stap_ea1e3b08acea61492ed2615b6f549cbe_535512_src.c:12712:7: error: unknown type name ‘uint0_t’
     { uint0_t value = deref (sizeof addr, addr); addr = value; }
       ^
/tmp/stapUOqJjk/stap_ea1e3b08acea61492ed2615b6f549cbe_535512_src.c: In function ‘function__dwarf_tvar_get_addr_647’:
/tmp/stapUOqJjk/stap_ea1e3b08acea61492ed2615b6f549cbe_535512_src.c:13060:7: error: unknown type name ‘uint0_t’
     { uint0_t value = deref (sizeof addr, addr); addr = value; }
       ^
Comment 1 Aram Hăvărneanu 2015-02-11 20:32:55 UTC
Created attachment 8122 [details]
Generated src.c.
Comment 2 Aram Hăvărneanu 2015-02-11 20:33:12 UTC
Added generated src.c.
Comment 3 Mark Wielaard 2015-02-11 21:18:29 UTC
This seems to be caused by a "sizeless" pointer type.

The following quick hack seems to solve the issue:

diff --git a/loc2c.c b/loc2c.c
index aef999c..b179240 100644
--- a/loc2c.c
+++ b/loc2c.c
@@ -2132,7 +2132,7 @@ c_translate_pointer (struct obstack *pool, int indent,
   Dwarf_Attribute attr_mem;
   Dwarf_Word byte_size;
   if (dwarf_attr_integrate (typedie, DW_AT_byte_size, &attr_mem) == NULL)
-    byte_size = 0;
+    byte_size = max_fetch_size (*input, typedie);
   else if (dwarf_formudata (&attr_mem, &byte_size) != 0)
     FAIL (*input,
          N_("cannot get byte_size attribute for type %s: %s"),
Comment 4 Mark Wielaard 2015-04-09 14:56:21 UTC
commit 4bfa7779843bda6f74c547a42a092a2974d07b9e
Author: Mark Wielaard <mjw@redhat.com>
Date:   Thu Apr 9 16:51:56 2015 +0200

    PR17959 Allow size-less pointer types.
    
    golang might produce a DW_TAG_pointer_type without any size. Assume
    the size of the pointer is equal to the address size of the DWARF CU
    in that case. Otherwise we might try to create values of type uint0_t.