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;
}
/* -- 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;
}
break;
case Addr_SectKind:
+ VG_(free)(ai->Addr.SectKind.objname);
break;
default:
}
/* 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;
|| (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;
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)(§_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),
/* 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;
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");
}
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");
}
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");
}
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");
}
}
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 */
// 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;
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