]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge revisions 14445 and 14446 from the BUF_REMOVAL branch to trunk.
authorFlorian Krohm <florian@eich-krohm.de>
Thu, 13 Nov 2014 21:41:28 +0000 (21:41 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Thu, 13 Nov 2014 21:41:28 +0000 (21:41 +0000)
Two things:
- remove the buffer argument from VG_(DebugInfo_sect_kind)
- allocate AddrInfo::SectKind::objname dynamically

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14719

callgrind/bb.c
coregrind/m_addrinfo.c
coregrind/m_debuginfo/debuginfo.c
drd/drd_error.c
drd/drd_load_store.c
drd/drd_main.c
helgrind/hg_errors.c
include/pub_tool_addrinfo.h
include/pub_tool_debuginfo.h

index 0dd1d3358945199e34cbe1f7bab422f444d5f2e6..b9b3812ebfc0c252c481c2ee157358cb9e7edc2d 100644 (file)
@@ -141,7 +141,7 @@ static BB* new_bb(obj_node* obj, PtrdiffT offset,
    bb->jmp         = (CJmpInfo*) &(bb->instr[instr_count]);
    bb->instr_len   = 0;
    bb->cost_count  = 0;
-   bb->sect_kind   = VG_(DebugInfo_sect_kind)(NULL, 0, offset + obj->offset);
+   bb->sect_kind   = VG_(DebugInfo_sect_kind)(NULL, offset + obj->offset);
    bb->fn          = 0;
    bb->line        = 0;
    bb->is_entry    = 0;
index 0cc29efb9423ca569ad796f2ba1388d1e42f50d4..8b364e2c70cf75e4687c85f3fe512e672d578d3a 100644 (file)
@@ -203,17 +203,12 @@ void VG_(describe_addr) ( Addr a, /*OUT*/AddrInfo* ai )
    }
 
    /* -- last ditch attempt at classification -- */
-   vg_assert( sizeof(ai->Addr.SectKind.objname) > 4 );
-   VG_(memset)( &ai->Addr.SectKind.objname, 
-                0, sizeof(ai->Addr.SectKind.objname));
-   VG_(strcpy)( ai->Addr.SectKind.objname, "???" );
-   sect = VG_(DebugInfo_sect_kind)( &ai->Addr.SectKind.objname[0],
-                                    sizeof(ai->Addr.SectKind.objname)-1, a);
+   sect = VG_(DebugInfo_sect_kind)( &name, a);
+   ai->Addr.SectKind.objname = VG_(strdup)("mc.da.dsname", name);
+
    if (sect != Vg_SectUnknown) {
       ai->tag = Addr_SectKind;
       ai->Addr.SectKind.kind = sect;
-      vg_assert( ai->Addr.SectKind.objname
-                    [ sizeof(ai->Addr.SectKind.objname)-1 ] == 0);
       return;
    }
 
@@ -305,6 +300,7 @@ void VG_(clear_addrinfo) ( AddrInfo* ai)
          break;
 
       case Addr_SectKind:
+         VG_(free)(ai->Addr.SectKind.objname);
          break;
 
       default:
index 11e2037ec53c927acfaaca8b7bfd963dfb5d2658..217f1d1be923b9cbb03a50112a392f31c41afc8e 100644 (file)
@@ -4274,12 +4274,11 @@ const HChar* VG_(pp_SectKind)( VgSectKind kind )
 }
 
 /* Given an address 'a', make a guess of which section of which object
-   it comes from.  If name is non-NULL, then the last n_name-1
-   characters of the object's name is put in name[0 .. n_name-2], and
-   name[n_name-1] is set to zero (guaranteed zero terminated). */
-
-VgSectKind VG_(DebugInfo_sect_kind)( /*OUT*/HChar* name, SizeT n_name, 
-                                     Addr a)
+   it comes from.  If name is non-NULL, then the object's name is put
+   in *name. The returned name, if any, should be saved away, if there is
+   a chance that a debug-info will be discarded and the name is being
+   used later on. */
+VgSectKind VG_(DebugInfo_sect_kind)( /*OUT*/const HChar** name, Addr a)
 {
    DebugInfo* di;
    VgSectKind res = Vg_SectUnknown;
@@ -4357,29 +4356,11 @@ VgSectKind VG_(DebugInfo_sect_kind)( /*OUT*/HChar* name, SizeT n_name,
               || (di != NULL && res != Vg_SectUnknown) );
 
    if (name) {
-
-      vg_assert(n_name >= 8);
-
       if (di && di->fsm.filename) {
-         Int i, j;
-         Int fnlen = VG_(strlen)(di->fsm.filename);
-         Int start_at = 1 + fnlen - n_name;
-         if (start_at < 0) start_at = 0;
-         vg_assert(start_at < fnlen);
-         i = start_at; j = 0;
-         while (True) {
-            vg_assert(j >= 0 && j < n_name);
-            vg_assert(i >= 0 && i <= fnlen);
-            name[j] = di->fsm.filename[i];
-            if (di->fsm.filename[i] == 0) break;
-            i++; j++;
-         }
-         vg_assert(i == fnlen);
+         *name = di->fsm.filename;
       } else {
-         VG_(snprintf)(name, n_name, "%s", "???");
+         *name = "???";
       }
-
-      name[n_name-1] = 0;
    }
 
    return res;
index e3df0b59a56d29294a65b89dd22d43f96de34bba..c510b8820d67fee14e851b210a393de37f2bf747 100644 (file)
@@ -221,11 +221,10 @@ void drd_report_data_race(const Error* const err,
       if (xml)
          print_err_detail("  </allocation_context>\n");
    } else {
-      HChar sect_name[64];
+      const HChar *sect_name;
       VgSectKind sect_kind;
 
-      sect_kind = VG_(DebugInfo_sect_kind)(sect_name, sizeof(sect_name),
-                                           dri->addr);
+      sect_kind = VG_(DebugInfo_sect_kind)(&sect_name, dri->addr);
       if (sect_kind != Vg_SectUnknown) {
          print_err_detail("%sAllocation context: %ps section of %ps%s\n",
                           auxwhat_prefix, VG_(pp_SectKind)(sect_kind),
index a7928d5571e76b67bf98b2e988f732da93327015..95e9f42ae2fd876543d4b7cceac2343dea140230 100644 (file)
@@ -624,7 +624,7 @@ IRSB* DRD_(instrument)(VgCallbackClosure* const closure,
          /* relocated in another way than by later binutils versions. The  */
          /* linker e.g. does not generate .got.plt sections on CentOS 3.0. */
       case Ist_IMark:
-         instrument = VG_(DebugInfo_sect_kind)(NULL, 0, st->Ist.IMark.addr)
+         instrument = VG_(DebugInfo_sect_kind)(NULL, st->Ist.IMark.addr)
             != Vg_SectPLT;
          addStmtToIRSB(bb, st);
          break;
index a24588be446be25b32371373c6105276b92b1f49..0960fe5ded79344fa4bdbb44cb1e01be1183c1fe 100644 (file)
@@ -447,7 +447,7 @@ static void DRD_(suppress_relocation_conflicts)(const Addr a, const SizeT len)
           VG_(strcmp)(VG_(DebugInfo_get_soname)(di), "libpthread.so.0") == 0) {
         if (trace_sectsuppr)
            VG_(dmsg)("Suppressing .bss @ 0x%lx size %ld\n", avma, size);
-         tl_assert(VG_(DebugInfo_sect_kind)(NULL, 0, avma) == Vg_SectBSS);
+         tl_assert(VG_(DebugInfo_sect_kind)(NULL, avma) == Vg_SectBSS);
          DRD_(start_suppression)(avma, avma + size, ".bss");
       }
 
@@ -457,7 +457,7 @@ static void DRD_(suppress_relocation_conflicts)(const Addr a, const SizeT len)
       if (size > 0) {
         if (trace_sectsuppr)
            VG_(dmsg)("Suppressing .plt @ 0x%lx size %ld\n", avma, size);
-         tl_assert(VG_(DebugInfo_sect_kind)(NULL, 0, avma) == Vg_SectPLT);
+         tl_assert(VG_(DebugInfo_sect_kind)(NULL, avma) == Vg_SectPLT);
          DRD_(start_suppression)(avma, avma + size, ".plt");
       }
 
@@ -467,7 +467,7 @@ static void DRD_(suppress_relocation_conflicts)(const Addr a, const SizeT len)
       if (size > 0) {
         if (trace_sectsuppr)
            VG_(dmsg)("Suppressing .got.plt @ 0x%lx size %ld\n", avma, size);
-         tl_assert(VG_(DebugInfo_sect_kind)(NULL, 0, avma) == Vg_SectGOTPLT);
+         tl_assert(VG_(DebugInfo_sect_kind)(NULL, avma) == Vg_SectGOTPLT);
          DRD_(start_suppression)(avma, avma + size, ".gotplt");
       }
 
@@ -477,7 +477,7 @@ static void DRD_(suppress_relocation_conflicts)(const Addr a, const SizeT len)
       if (size > 0) {
         if (trace_sectsuppr)
            VG_(dmsg)("Suppressing .got @ 0x%lx size %ld\n", avma, size);
-         tl_assert(VG_(DebugInfo_sect_kind)(NULL, 0, avma) == Vg_SectGOT);
+         tl_assert(VG_(DebugInfo_sect_kind)(NULL, avma) == Vg_SectGOT);
          DRD_(start_suppression)(avma, avma + size, ".got");
       }
    }
index 0e96d7e76317f26b31afbd98ae81ab82a4244a4a..65703e687951614286c56aca9478f944147491f2 100644 (file)
@@ -464,7 +464,7 @@ void HG_(record_error_Race) ( Thread* thr,
       linked routine, into the table (or whatever) when it is called
       for the first time. */
    {
-     VgSectKind sect = VG_(DebugInfo_sect_kind)( NULL, 0, data_addr );
+     VgSectKind sect = VG_(DebugInfo_sect_kind)( NULL, data_addr );
      if (0) VG_(printf)("XXXXXXXXX RACE on %#lx %s\n",
                         data_addr, VG_(pp_SectKind)(sect));
      /* SectPLT is required on ???-linux */
index 84afdde69668ebcee68d3f898e6d4676c2e66269..6e089e794d03dbd3d6a19876b5679fedb115162a 100644 (file)
@@ -169,7 +169,7 @@ struct _AddrInfo {
       // Could only narrow it down to be the PLT/GOT/etc of a given
       // object.  Better than nothing, perhaps.
       struct {
-         HChar      objname[128];
+         HChar      *objname;
          VgSectKind kind;
       } SectKind;
 
index 2c0f8150364e13d9689de45636f404aacc278a71..95b203acdb0cea4f78bc9b57443cd279658137cf 100644 (file)
@@ -262,11 +262,10 @@ typedef
 const HChar* VG_(pp_SectKind)( VgSectKind kind );
 
 /* Given an address 'a', make a guess of which section of which object
-   it comes from.  If name is non-NULL, then the last n_name-1
-   characters of the object's name is put in name[0 .. n_name-2], and
-   name[n_name-1] is set to zero (guaranteed zero terminated). */
-VgSectKind VG_(DebugInfo_sect_kind)( /*OUT*/HChar* name, SizeT n_name, 
-                                     Addr a);
+   it comes from.  If name is non-NULL, then the object's name is put
+   into *name. The returned name is persistent as long as the debuginfo
+   it belongs to isn't discarded. */
+VgSectKind VG_(DebugInfo_sect_kind)( /*OUT*/const HChar** name, Addr a);
 
 
 #endif   // __PUB_TOOL_DEBUGINFO_H