Print offset relative to function when using DWARF
authorAntoine Busque <abusque@efficios.com>
Tue, 19 Apr 2016 17:43:10 +0000 (13:43 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 3 May 2016 19:42:42 +0000 (15:42 -0400)
Signed-off-by: Antoine Busque <abusque@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/so-info.c

index 88106f39daccb8d3285e3698a9d82ccc69a8faf1..eca53cfbd79694898becae3bff00f953205eb33e 100644 (file)
@@ -745,7 +745,10 @@ int so_info_lookup_cu_function_name(struct bt_dwarf_cu *cu, uint64_t addr,
                char **func_name)
 {
        int ret = 0, found = 0;
+       uint64_t low_addr = 0;
+       char *die_name = NULL;
        char *_func_name = NULL;
+       char offset_str[ADDR_STR_LEN];
        struct bt_dwarf_die *die = NULL;
 
        if (!cu || !func_name) {
@@ -778,11 +781,26 @@ int so_info_lookup_cu_function_name(struct bt_dwarf_cu *cu, uint64_t addr,
        }
 
        if (found) {
-               ret = bt_dwarf_die_get_name(die, &_func_name);
+               ret = bt_dwarf_die_get_name(die, &die_name);
+               if (ret) {
+                       goto error;
+               }
+
+               ret = dwarf_lowpc(die->dwarf_die, &low_addr);
                if (ret) {
                        goto error;
                }
 
+               snprintf(offset_str, ADDR_STR_LEN, "+%#0" PRIx64,
+                               addr - low_addr);
+               _func_name = malloc(strlen(die_name) + ADDR_STR_LEN);
+               if (!_func_name) {
+                       goto error;
+               }
+
+               strcpy(_func_name, die_name);
+               strcat(_func_name, offset_str);
+
                *func_name = _func_name;
        }
 
This page took 0.034959 seconds and 4 git commands to generate.