From: Florian Krohm Date: Thu, 13 Nov 2014 21:41:28 +0000 (+0000) Subject: Merge revisions 14445 and 14446 from the BUF_REMOVAL branch to trunk. X-Git-Tag: svn/VALGRIND_3_11_0~829 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac3b22e6af354921b32162f0ccae8ad54ee1de5f;p=thirdparty%2Fvalgrind.git Merge revisions 14445 and 14446 from the BUF_REMOVAL branch to trunk. 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 --- diff --git a/callgrind/bb.c b/callgrind/bb.c index 0dd1d33589..b9b3812ebf 100644 --- a/callgrind/bb.c +++ b/callgrind/bb.c @@ -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; diff --git a/coregrind/m_addrinfo.c b/coregrind/m_addrinfo.c index 0cc29efb94..8b364e2c70 100644 --- a/coregrind/m_addrinfo.c +++ b/coregrind/m_addrinfo.c @@ -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: diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c index 11e2037ec5..217f1d1be9 100644 --- a/coregrind/m_debuginfo/debuginfo.c +++ b/coregrind/m_debuginfo/debuginfo.c @@ -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; diff --git a/drd/drd_error.c b/drd/drd_error.c index e3df0b59a5..c510b8820d 100644 --- a/drd/drd_error.c +++ b/drd/drd_error.c @@ -221,11 +221,10 @@ void drd_report_data_race(const Error* const err, if (xml) print_err_detail(" \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)(§_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), diff --git a/drd/drd_load_store.c b/drd/drd_load_store.c index a7928d5571..95e9f42ae2 100644 --- a/drd/drd_load_store.c +++ b/drd/drd_load_store.c @@ -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; diff --git a/drd/drd_main.c b/drd/drd_main.c index a24588be44..0960fe5ded 100644 --- a/drd/drd_main.c +++ b/drd/drd_main.c @@ -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"); } } diff --git a/helgrind/hg_errors.c b/helgrind/hg_errors.c index 0e96d7e763..65703e6879 100644 --- a/helgrind/hg_errors.c +++ b/helgrind/hg_errors.c @@ -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 */ diff --git a/include/pub_tool_addrinfo.h b/include/pub_tool_addrinfo.h index 84afdde696..6e089e794d 100644 --- a/include/pub_tool_addrinfo.h +++ b/include/pub_tool_addrinfo.h @@ -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; diff --git a/include/pub_tool_debuginfo.h b/include/pub_tool_debuginfo.h index 2c0f815036..95b203acdb 100644 --- a/include/pub_tool_debuginfo.h +++ b/include/pub_tool_debuginfo.h @@ -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