Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix broken objdump parser with new versions of objdump
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 20 Dec 2013 10:07:01 +0000 (11:07 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 20 Dec 2013 12:38:14 +0000 (13:38 +0100)
objdump -Wo used to produce this:

     Offset   Begin    End      Expression
     00000000 000000000040149c 000000000040149d (DW_OP_breg7 (rsp): 8)
     00000000 000000000040149d 00000000004014a0 (DW_OP_breg7 (rsp): 16)
     00000000 00000000004014a0 00000000004014ba (DW_OP_breg6 (rbp): 16)
     00000000 00000000004014ba 00000000004014bb (DW_OP_breg7 (rsp): 8)
     00000000 <End of list>
     00000060 00000000004014bb 00000000004014bc (DW_OP_breg7 (rsp): 8)
     00000060 00000000004014bc 00000000004014bf (DW_OP_breg7 (rsp): 16)
     00000060 00000000004014bf 00000000004014c6 (DW_OP_breg6 (rbp): 16)
     00000060 00000000004014c6 00000000004014c7 (DW_OP_breg7 (rsp): 8)
     00000060 <End of list>
     000000c0 00000000004014c7 00000000004014c8 (DW_OP_breg7 (rsp): 8)
     000000c0 00000000004014c8 00000000004014cb (DW_OP_breg7 (rsp): 16)
     000000c0 00000000004014cb 00000000004014d2 (DW_OP_breg6 (rbp): 16)
     000000c0 00000000004014d2 00000000004014d3 (DW_OP_breg7 (rsp): 8)
     000000c0 <End of list>
     00000120 00000000004014d3 00000000004014d4 (DW_OP_breg7 (rsp): 8)
     00000120 00000000004014d4 00000000004014d7 (DW_OP_breg7 (rsp): 16)
     00000120 00000000004014d7 00000000004018c0 (DW_OP_breg6 (rbp): 16)
     00000120 <End of list>

but now we get this:

    Offset   Begin    End      Expression
    00000000 0000000000401252 0000000000401253 (DW_OP_breg7 (rsp): 8)
    00000014 0000000000401253 0000000000401256 (DW_OP_breg7 (rsp): 16)
    00000028 0000000000401256 0000000000401270 (DW_OP_breg6 (rbp): 16)
    0000003c 0000000000401270 0000000000401271 (DW_OP_breg7 (rsp): 8)
    00000050 <End of list>
    00000060 0000000000401271 0000000000401272 (DW_OP_breg7 (rsp): 8)
    00000074 0000000000401272 0000000000401275 (DW_OP_breg7 (rsp): 16)
    00000088 0000000000401275 000000000040127c (DW_OP_breg6 (rbp): 16)
    0000009c 000000000040127c 000000000040127d (DW_OP_breg7 (rsp): 8)
    000000b0 <End of list>
    000000c0 000000000040127d 000000000040127e (DW_OP_breg7 (rsp): 8)
    000000d4 000000000040127e 0000000000401281 (DW_OP_breg7 (rsp): 16)
    000000e8 0000000000401281 0000000000401288 (DW_OP_breg6 (rbp): 16)
    000000fc 0000000000401288 0000000000401289 (DW_OP_breg7 (rsp): 8)
    00000110 <End of list>
    00000120 0000000000401289 000000000040128a (DW_OP_breg7 (rsp): 8)
    00000134 000000000040128a 000000000040128d (DW_OP_breg7 (rsp): 16)
    00000148 000000000040128d 00000000004016a1 (DW_OP_breg6 (rbp): 16)
    0000015c <End of list>
    0000016c 00000000004016a1 00000000004016a2 (DW_OP_breg7 (rsp): 8)
    00000180 00000000004016a2 00000000004016a5 (DW_OP_breg7 (rsp): 16)
    00000194 00000000004016a5 0000000000401bd7 (DW_OP_breg6 (rbp): 16)
    000001a8 <End of list>
    000001b8 0000000000401bd7 0000000000401bd8 (DW_OP_breg7 (rsp): 8)
    000001cc 0000000000401bd8 0000000000401bdb (DW_OP_breg7 (rsp): 16)
    000001e0 0000000000401bdb 0000000000401ced (DW_OP_breg6 (rbp): 16)
    000001f4 0000000000401ced 0000000000401cee (DW_OP_breg7 (rsp): 8)
    00000208 <End of list>

The offset is not stable in a given list.

src/mc/mc_global.c

index 4ae023d..66111e4 100644 (file)
@@ -371,8 +371,14 @@ static xbt_dict_t MC_dwarf_get_location_list(const char *elf_file){
     xbt_str_strip_spaces(line);
     split = xbt_str_split(line, " ");
 
     xbt_str_strip_spaces(line);
     split = xbt_str_split(line, " ");
 
+    char *key = NULL;
     while(read != -1 && strcmp("<End", (char *)xbt_dynar_get_as(split, 1, char *)) != 0){
       
     while(read != -1 && strcmp("<End", (char *)xbt_dynar_get_as(split, 1, char *)) != 0){
       
+      // Take the key from the first line of the list:
+      if(key==NULL){
+        key = bprintf("%d", (int)strtoul((char *)xbt_dynar_get_as(split, 0, char *), NULL, 16));
+      }
+
       dw_location_entry_t new_entry = xbt_new0(s_dw_location_entry_t, 1);
       new_entry->lowpc = strtoul((char *)xbt_dynar_get_as(split, 1, char *), NULL, 16);
       new_entry->highpc = strtoul((char *)xbt_dynar_get_as(split, 2, char *), NULL, 16);
       dw_location_entry_t new_entry = xbt_new0(s_dw_location_entry_t, 1);
       new_entry->lowpc = strtoul((char *)xbt_dynar_get_as(split, 1, char *), NULL, 16);
       new_entry->highpc = strtoul((char *)xbt_dynar_get_as(split, 2, char *), NULL, 16);
@@ -403,7 +409,6 @@ static xbt_dict_t MC_dwarf_get_location_list(const char *elf_file){
     }
 
 
     }
 
 
-    char *key = bprintf("%d", (int)strtoul((char *)xbt_dynar_get_as(split, 0, char *), NULL, 16));
     xbt_dict_set(location_list, key, loclist, NULL);
     xbt_free(key);
     
     xbt_dict_set(location_list, key, loclist, NULL);
     xbt_free(key);