Author: florian
Date: Wed Sep 3 21:01:05 2014
New Revision: 14445
Log:
Change VG_(DebugInfo_sect_kind) to return a pointer to the name
via its first parameter instead of copying into a fixed size buffer.
The so returned name should be saved away if needed sometime later.
Where "sometime later" means that a debuginfo could be discarded in
the meantime. This is currently not the case. But the subtlety is
commented on.
Modified:
branches/BUF_REMOVAL/callgrind/bb.c
branches/BUF_REMOVAL/coregrind/m_addrinfo.c
branches/BUF_REMOVAL/coregrind/m_debuginfo/debuginfo.c
branches/BUF_REMOVAL/drd/drd_error.c
branches/BUF_REMOVAL/drd/drd_load_store.c
branches/BUF_REMOVAL/drd/drd_main.c
branches/BUF_REMOVAL/helgrind/hg_errors.c
branches/BUF_REMOVAL/include/pub_tool_debuginfo.h
Modified: branches/BUF_REMOVAL/callgrind/bb.c
==============================================================================
--- branches/BUF_REMOVAL/callgrind/bb.c (original)
+++ branches/BUF_REMOVAL/callgrind/bb.c Wed Sep 3 21:01:05 2014
@@ -143,7 +143,7 @@
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;
Modified: branches/BUF_REMOVAL/coregrind/m_addrinfo.c
==============================================================================
--- branches/BUF_REMOVAL/coregrind/m_addrinfo.c (original)
+++ branches/BUF_REMOVAL/coregrind/m_addrinfo.c Wed Sep 3 21:01:05 2014
@@ -162,8 +162,11 @@
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);
+ HChar *temp_name;
+ sect = VG_(DebugInfo_sect_kind)( &temp_name, a);
+ VG_(strncpy)(ai->Addr.SectKind.objname, temp_name,
+ sizeof(ai->Addr.SectKind.objname)-1);
+
if (sect != Vg_SectUnknown) {
ai->tag = Addr_SectKind;
ai->Addr.SectKind.kind = sect;
Modified: branches/BUF_REMOVAL/coregrind/m_debuginfo/debuginfo.c
==============================================================================
--- branches/BUF_REMOVAL/coregrind/m_debuginfo/debuginfo.c (original)
+++ branches/BUF_REMOVAL/coregrind/m_debuginfo/debuginfo.c Wed Sep 3 21:01:05 2014
@@ -4174,12 +4174,11 @@
}
/* 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*/HChar** name, Addr a)
{
DebugInfo* di;
VgSectKind res = Vg_SectUnknown;
@@ -4257,29 +4256,11 @@
|| (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 = (HChar *)"???"; // FIXME: constification
}
-
- name[n_name-1] = 0;
}
return res;
Modified: branches/BUF_REMOVAL/drd/drd_error.c
==============================================================================
--- branches/BUF_REMOVAL/drd/drd_error.c (original)
+++ branches/BUF_REMOVAL/drd/drd_error.c Wed Sep 3 21:01:05 2014
@@ -222,11 +222,10 @@
if (xml)
print_err_detail(" </allocation_context>\n");
} else {
- HChar sect_name[64];
+ 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),
Modified: branches/BUF_REMOVAL/drd/drd_load_store.c
==============================================================================
--- branches/BUF_REMOVAL/drd/drd_load_store.c (original)
+++ branches/BUF_REMOVAL/drd/drd_load_store.c Wed Sep 3 21:01:05 2014
@@ -624,7 +624,7 @@
/* 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;
Modified: branches/BUF_REMOVAL/drd/drd_main.c
==============================================================================
--- branches/BUF_REMOVAL/drd/drd_main.c (original)
+++ branches/BUF_REMOVAL/drd/drd_main.c Wed Sep 3 21:01:05 2014
@@ -447,7 +447,7 @@
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 @@
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 @@
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 @@
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");
}
}
Modified: branches/BUF_REMOVAL/helgrind/hg_errors.c
==============================================================================
--- branches/BUF_REMOVAL/helgrind/hg_errors.c (original)
+++ branches/BUF_REMOVAL/helgrind/hg_errors.c Wed Sep 3 21:01:05 2014
@@ -468,7 +468,7 @@
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 */
Modified: branches/BUF_REMOVAL/include/pub_tool_debuginfo.h
==============================================================================
--- branches/BUF_REMOVAL/include/pub_tool_debuginfo.h (original)
+++ branches/BUF_REMOVAL/include/pub_tool_debuginfo.h Wed Sep 3 21:01:05 2014
@@ -262,11 +262,9 @@
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. */
+VgSectKind VG_(DebugInfo_sect_kind)( /*OUT*/HChar** name, Addr a);
#endif // __PUB_TOOL_DEBUGINFO_H
|