|
From: <sv...@va...> - 2008-02-14 00:44:29
|
Author: sewardj
Date: 2008-02-14 00:44:17 +0000 (Thu, 14 Feb 2008)
New Revision: 7406
Log:
Primarily, try and free up at least some of the variable type info at
munmap time. Only partially successful. Also, a bit more removal of
duplicated code.
Modified:
branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c
branches/DATASYMS/coregrind/m_debuginfo/misc.c
branches/DATASYMS/coregrind/m_debuginfo/priv_misc.h
branches/DATASYMS/coregrind/m_debuginfo/priv_storage.h
branches/DATASYMS/coregrind/m_debuginfo/priv_tytypes.h
branches/DATASYMS/coregrind/m_debuginfo/readdwarf.c
branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c
branches/DATASYMS/coregrind/m_debuginfo/readelf.c
branches/DATASYMS/coregrind/m_debuginfo/readstabs.c
branches/DATASYMS/coregrind/m_debuginfo/tytypes.c
Modified: branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c 2008-02-13 05:05:58 UTC (rev 7405)
+++ branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c 2008-02-14 00:44:17 UTC (rev 7406)
@@ -204,6 +204,48 @@
next = chunk->next;
ML_(dinfo_free)(chunk);
}
+
+ { TyAdmin *admin1, *admin2;
+ for (admin1 = di->tyadmins; admin1; admin1 = admin2) {
+ admin2 = admin1->next;
+ //ML_(dinfo_free)(admin1);
+ ML_(delete_TyAdmin_and_payload)(admin1);
+ }
+ GExpr *gexpr1, *gexpr2;
+ for (gexpr1 = di->gexprs; gexpr1; gexpr1 = gexpr2) {
+ gexpr2 = gexpr1->next;
+ ML_(dinfo_free)(gexpr1);
+ }
+ }
+
+ Word i, j;
+ if (di->varinfo) {
+ for (i = 0; i < VG_(sizeXA)(di->varinfo); i++) {
+ OSet* scope = *(OSet**)VG_(indexXA)(di->varinfo, i);
+ if (!scope) continue;
+ // iterate over all entries in 'scope'
+ VG_(OSetGen_ResetIter)(scope);
+ while (True) {
+ DiAddrRange* arange = VG_(OSetGen_Next)(scope);
+ if (!arange) break;
+ // for each var in 'arange'
+ vg_assert(arange->vars);
+ for (j = 0; j < VG_(sizeXA)( arange->vars ); j++) {
+ DiVariable* var = (DiVariable*)VG_(indexXA)(arange->vars,j);
+ vg_assert(var);
+ /////////////////////////////
+ //if (var->name && 0xDD != *(var->name))
+ // ML_(dinfo_free)(var->name);
+ // var->name gets used more than once .. can't free it
+ /////////////////////////////
+ }
+ ML_(dinfo_free)(arange->vars);
+ }
+ VG_(OSetGen_Destroy)(scope);
+ }
+ VG_(deleteXA)(di->varinfo);
+ }
+
ML_(dinfo_free)(di);
}
@@ -1531,7 +1573,8 @@
Therefore specify "*" to search all the objects. On TOC-afflicted
platforms, a symbol is deemed to be found only if it has a nonzero
TOC pointer. */
-Bool VG_(lookup_symbol_SLOW)(UChar* sopatt, UChar* name, Addr* pEnt, Addr* pToc)
+Bool VG_(lookup_symbol_SLOW)(UChar* sopatt, UChar* name,
+ Addr* pEnt, Addr* pToc)
{
Bool require_pToc = False;
Int i;
Modified: branches/DATASYMS/coregrind/m_debuginfo/misc.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/misc.c 2008-02-13 05:05:58 UTC (rev 7405)
+++ branches/DATASYMS/coregrind/m_debuginfo/misc.c 2008-02-14 00:44:17 UTC (rev 7406)
@@ -37,6 +37,8 @@
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_mallocfree.h"
+#include "pub_core_xarray.h"
+
#include "priv_misc.h" /* self */
@@ -48,12 +50,15 @@
VG_(memset)(v, 0, szB);
return v;
}
+
void ML_(dinfo_free) ( void* v ) {
VG_(arena_free)( VG_AR_DINFO, v );
}
+
UChar* ML_(dinfo_strdup) ( const UChar* str ) {
return VG_(arena_strdup)( VG_AR_DINFO, str );
}
+
UChar* ML_(dinfo_memdup)( UChar* mem, UWord nbytes ) {
UChar* r = VG_(arena_malloc)( VG_AR_DINFO, nbytes );
if (nbytes > 0)
@@ -61,6 +66,15 @@
return r;
}
+
+void ML_(copy_bytes_into_XA) ( XArray* /* of UChar */ xa,
+ void* bytes, Word nbytes ) {
+ Word i;
+ for (i = 0; i < nbytes; i++)
+ VG_(addToXA)( xa, & ((UChar*)bytes)[i] );
+}
+
+
/*--------------------------------------------------------------------*/
/*--- end misc.c ---*/
/*--------------------------------------------------------------------*/
Modified: branches/DATASYMS/coregrind/m_debuginfo/priv_misc.h
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/priv_misc.h 2008-02-13 05:05:58 UTC (rev 7405)
+++ branches/DATASYMS/coregrind/m_debuginfo/priv_misc.h 2008-02-14 00:44:17 UTC (rev 7406)
@@ -52,6 +52,11 @@
UChar* ML_(dinfo_strdup)( const UChar* str );
UChar* ML_(dinfo_memdup)( UChar* mem, UWord nbytes );
+/* Copy bytes into an XArray of what are assumed to be, well,
+ bytes. */
+void ML_(copy_bytes_into_XA) ( XArray* /* of UChar */ xa,
+ void* bytes, Word nbytes );
+
#endif /* ndef __PRIV_MISC_H */
/*--------------------------------------------------------------------*/
Modified: branches/DATASYMS/coregrind/m_debuginfo/priv_storage.h
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/priv_storage.h 2008-02-13 05:05:58 UTC (rev 7405)
+++ branches/DATASYMS/coregrind/m_debuginfo/priv_storage.h 2008-02-14 00:44:17 UTC (rev 7406)
@@ -351,7 +351,7 @@
UInt cfsi_size;
Addr cfsi_minaddr;
Addr cfsi_maxaddr;
- XArray* cfsi_exprs; /* XArray of CfSiExpr */
+ XArray* cfsi_exprs; /* XArray of CfiExpr */
/* Expandable arrays of characters -- the string table. Pointers
into this are stable (the arrays are not reallocated). */
@@ -383,6 +383,10 @@
range pair, one that covers the entire address space.
*/
XArray* /* of OSet of DiAddrRange */varinfo;
+
+ /* For the purposes of deletion: */
+ TyAdmin* tyadmins;
+ GExpr* gexprs;
};
/* --------------------- functions --------------------- */
Modified: branches/DATASYMS/coregrind/m_debuginfo/priv_tytypes.h
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/priv_tytypes.h 2008-02-13 05:05:58 UTC (rev 7405)
+++ branches/DATASYMS/coregrind/m_debuginfo/priv_tytypes.h 2008-02-14 00:44:17 UTC (rev 7406)
@@ -58,12 +58,12 @@
/* an enumeration value */
struct _TyAtom {
- UChar* name;
+ UChar* name; /* AR_DINFO, unshared */
Long value;
};
struct _TyField {
- UChar* name;
+ UChar* name; /* AR_DINFO, unshared */
Type* typeR;
D3Expr* loc;
Bool isStruct;
@@ -78,7 +78,7 @@
};
struct _D3Expr {
- UChar* bytes;
+ UChar* bytes; /* AR_DINFO, unshared */
UWord nbytes;
};
@@ -87,7 +87,7 @@
Ty_Enum, Ty_Array, Ty_Fn, Ty_Qual, Ty_Void } tag;
union {
struct {
- UChar* name;
+ UChar* name; /* AR_DINFO, unshared */
Int szB;
UChar enc; /* S:signed U:unsigned F:floating */
} Base;
@@ -97,18 +97,18 @@
Bool isPtr;
} PorR;
struct {
- UChar* name;
+ UChar* name; /* AR_DINFO, unshared */
Type* typeR; /* MAY BE NULL, denoting unknown */
} TyDef;
struct {
- UChar* name;
+ UChar* name; /* AR_DINFO, unshared */
UWord szB;
XArray* /* of TyField* */ fields;
Bool complete;
Bool isStruct;
} StOrUn;
struct {
- UChar* name;
+ UChar* name; /* AR_DINFO, unshared */
Int szB;
XArray* /* of TyAtom* */ atomRs;
} Enum;
@@ -135,6 +135,8 @@
Type* ML_(new_Type) ( void );
D3Expr* ML_(new_D3Expr) ( UChar* bytes, UWord nbytes );
+void ML_(delete_TyAdmin_and_payload) ( TyAdmin* ad );
+
void ML_(pp_TyAdmin) ( TyAdmin* admin );
void ML_(pp_TyAtom) ( TyAtom* atom );
void ML_(pp_TyField) ( TyField* field );
Modified: branches/DATASYMS/coregrind/m_debuginfo/readdwarf.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/readdwarf.c 2008-02-13 05:05:58 UTC (rev 7405)
+++ branches/DATASYMS/coregrind/m_debuginfo/readdwarf.c 2008-02-14 00:44:17 UTC (rev 7406)
@@ -40,6 +40,7 @@
#include "pub_core_options.h"
#include "pub_core_xarray.h"
#include "priv_misc.h" /* dinfo_zalloc/free/strdup */
+#include "priv_d3basics.h"
#include "priv_tytypes.h"
#include "priv_storage.h"
#include "priv_readdwarf.h" /* self */
@@ -2444,175 +2445,6 @@
/* ------------ Run/show DWARF3 expressions ---------- */
-/* Taken from binutils-2.17/include/elf/dwarf2.h */
-enum dwarf_location_atom
- {
- DW_OP_addr = 0x03,
- DW_OP_deref = 0x06,
- DW_OP_const1u = 0x08,
- DW_OP_const1s = 0x09,
- DW_OP_const2u = 0x0a,
- DW_OP_const2s = 0x0b,
- DW_OP_const4u = 0x0c,
- DW_OP_const4s = 0x0d,
- DW_OP_const8u = 0x0e,
- DW_OP_const8s = 0x0f,
- DW_OP_constu = 0x10,
- DW_OP_consts = 0x11,
- DW_OP_dup = 0x12,
- DW_OP_drop = 0x13,
- DW_OP_over = 0x14,
- DW_OP_pick = 0x15,
- DW_OP_swap = 0x16,
- DW_OP_rot = 0x17,
- DW_OP_xderef = 0x18,
- DW_OP_abs = 0x19,
- DW_OP_and = 0x1a,
- DW_OP_div = 0x1b,
- DW_OP_minus = 0x1c,
- DW_OP_mod = 0x1d,
- DW_OP_mul = 0x1e,
- DW_OP_neg = 0x1f,
- DW_OP_not = 0x20,
- DW_OP_or = 0x21,
- DW_OP_plus = 0x22,
- DW_OP_plus_uconst = 0x23,
- DW_OP_shl = 0x24,
- DW_OP_shr = 0x25,
- DW_OP_shra = 0x26,
- DW_OP_xor = 0x27,
- DW_OP_bra = 0x28,
- DW_OP_eq = 0x29,
- DW_OP_ge = 0x2a,
- DW_OP_gt = 0x2b,
- DW_OP_le = 0x2c,
- DW_OP_lt = 0x2d,
- DW_OP_ne = 0x2e,
- DW_OP_skip = 0x2f,
- DW_OP_lit0 = 0x30,
- DW_OP_lit1 = 0x31,
- DW_OP_lit2 = 0x32,
- DW_OP_lit3 = 0x33,
- DW_OP_lit4 = 0x34,
- DW_OP_lit5 = 0x35,
- DW_OP_lit6 = 0x36,
- DW_OP_lit7 = 0x37,
- DW_OP_lit8 = 0x38,
- DW_OP_lit9 = 0x39,
- DW_OP_lit10 = 0x3a,
- DW_OP_lit11 = 0x3b,
- DW_OP_lit12 = 0x3c,
- DW_OP_lit13 = 0x3d,
- DW_OP_lit14 = 0x3e,
- DW_OP_lit15 = 0x3f,
- DW_OP_lit16 = 0x40,
- DW_OP_lit17 = 0x41,
- DW_OP_lit18 = 0x42,
- DW_OP_lit19 = 0x43,
- DW_OP_lit20 = 0x44,
- DW_OP_lit21 = 0x45,
- DW_OP_lit22 = 0x46,
- DW_OP_lit23 = 0x47,
- DW_OP_lit24 = 0x48,
- DW_OP_lit25 = 0x49,
- DW_OP_lit26 = 0x4a,
- DW_OP_lit27 = 0x4b,
- DW_OP_lit28 = 0x4c,
- DW_OP_lit29 = 0x4d,
- DW_OP_lit30 = 0x4e,
- DW_OP_lit31 = 0x4f,
- DW_OP_reg0 = 0x50,
- DW_OP_reg1 = 0x51,
- DW_OP_reg2 = 0x52,
- DW_OP_reg3 = 0x53,
- DW_OP_reg4 = 0x54,
- DW_OP_reg5 = 0x55,
- DW_OP_reg6 = 0x56,
- DW_OP_reg7 = 0x57,
- DW_OP_reg8 = 0x58,
- DW_OP_reg9 = 0x59,
- DW_OP_reg10 = 0x5a,
- DW_OP_reg11 = 0x5b,
- DW_OP_reg12 = 0x5c,
- DW_OP_reg13 = 0x5d,
- DW_OP_reg14 = 0x5e,
- DW_OP_reg15 = 0x5f,
- DW_OP_reg16 = 0x60,
- DW_OP_reg17 = 0x61,
- DW_OP_reg18 = 0x62,
- DW_OP_reg19 = 0x63,
- DW_OP_reg20 = 0x64,
- DW_OP_reg21 = 0x65,
- DW_OP_reg22 = 0x66,
- DW_OP_reg23 = 0x67,
- DW_OP_reg24 = 0x68,
- DW_OP_reg25 = 0x69,
- DW_OP_reg26 = 0x6a,
- DW_OP_reg27 = 0x6b,
- DW_OP_reg28 = 0x6c,
- DW_OP_reg29 = 0x6d,
- DW_OP_reg30 = 0x6e,
- DW_OP_reg31 = 0x6f,
- DW_OP_breg0 = 0x70,
- DW_OP_breg1 = 0x71,
- DW_OP_breg2 = 0x72,
- DW_OP_breg3 = 0x73,
- DW_OP_breg4 = 0x74,
- DW_OP_breg5 = 0x75,
- DW_OP_breg6 = 0x76,
- DW_OP_breg7 = 0x77,
- DW_OP_breg8 = 0x78,
- DW_OP_breg9 = 0x79,
- DW_OP_breg10 = 0x7a,
- DW_OP_breg11 = 0x7b,
- DW_OP_breg12 = 0x7c,
- DW_OP_breg13 = 0x7d,
- DW_OP_breg14 = 0x7e,
- DW_OP_breg15 = 0x7f,
- DW_OP_breg16 = 0x80,
- DW_OP_breg17 = 0x81,
- DW_OP_breg18 = 0x82,
- DW_OP_breg19 = 0x83,
- DW_OP_breg20 = 0x84,
- DW_OP_breg21 = 0x85,
- DW_OP_breg22 = 0x86,
- DW_OP_breg23 = 0x87,
- DW_OP_breg24 = 0x88,
- DW_OP_breg25 = 0x89,
- DW_OP_breg26 = 0x8a,
- DW_OP_breg27 = 0x8b,
- DW_OP_breg28 = 0x8c,
- DW_OP_breg29 = 0x8d,
- DW_OP_breg30 = 0x8e,
- DW_OP_breg31 = 0x8f,
- DW_OP_regx = 0x90,
- DW_OP_fbreg = 0x91,
- DW_OP_bregx = 0x92,
- DW_OP_piece = 0x93,
- DW_OP_deref_size = 0x94,
- DW_OP_xderef_size = 0x95,
- DW_OP_nop = 0x96,
- /* DWARF 3 extensions. */
- DW_OP_push_object_address = 0x97,
- DW_OP_call2 = 0x98,
- DW_OP_call4 = 0x99,
- DW_OP_call_ref = 0x9a,
- DW_OP_form_tls_address = 0x9b,
- DW_OP_call_frame_cfa = 0x9c,
- DW_OP_bit_piece = 0x9d,
- /* GNU extensions. */
- DW_OP_GNU_push_tls_address = 0xe0,
- /* HP extensions. */
- DW_OP_HP_unknown = 0xe0, /* Ouch, the same as GNU_push_tls_address. */
- DW_OP_HP_is_value = 0xe1,
- DW_OP_HP_fltconst4 = 0xe2,
- DW_OP_HP_fltconst8 = 0xe3,
- DW_OP_HP_mod_range = 0xe4,
- DW_OP_HP_unmod_range = 0xe5,
- DW_OP_HP_tls = 0xe6
- };
-
-
/* Convert the DWARF3 expression in expr[0 .. exprlen-1] into a dag
(of CfiExprs) stored in ctx->exprs, and return the index in
ctx->exprs of the root node. Or fail in which case return -1. */
Modified: branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c 2008-02-13 05:05:58 UTC (rev 7405)
+++ branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c 2008-02-14 00:44:17 UTC (rev 7406)
@@ -57,8 +57,8 @@
#include "pub_core_xarray.h"
#include "priv_misc.h" /* dinfo_zalloc/free/strdup */
#include "priv_tytypes.h"
+#include "priv_d3basics.h"
#include "priv_storage.h"
-#include "priv_d3basics.h"
#include "priv_readdwarf3.h" /* self */
@@ -387,12 +387,6 @@
location list. Zero length ranges, with aMax == aMin-1, are not
allowed.
*/
-static void copy_bytes_into_XA ( XArray* /* of UChar */ xa,
- void* bytes, Word nbytes ) {
- Word i;
- for (i = 0; i < nbytes; i++)
- VG_(addToXA)( xa, & ((UChar*)bytes)[i] );
-}
void ML_(pp_GX) ( GExpr* gx ) {
Addr aMin, aMax;
UChar uc;
@@ -542,11 +536,11 @@
c = 0; /* !isEnd*/
VG_(addToXA)( xa, &c );
w = w1 + base + svma_of_referencing_CU;
- copy_bytes_into_XA( xa, &w, sizeof(w) );
+ ML_(copy_bytes_into_XA)( xa, &w, sizeof(w) );
w = w2 -1 + base + svma_of_referencing_CU;
- copy_bytes_into_XA( xa, &w, sizeof(w) );
+ ML_(copy_bytes_into_XA)( xa, &w, sizeof(w) );
s = (UShort)len;
- copy_bytes_into_XA( xa, &s, sizeof(s) );
+ ML_(copy_bytes_into_XA)( xa, &s, sizeof(s) );
}
while (len > 0) {
@@ -2750,7 +2744,7 @@
have at least one type entry to refer to. D3_FAKEVOID_CUOFF is
huge and presumably will not occur in any valid DWARF3 file --
it would need to have a .debug_info section 4GB long for that to
- happen. */
+ happen. These type entries end up in the DebugInfo. */
admin = NULL;
{ Type* tVoid = ML_(new_Type)();
tVoid->tag = Ty_Void;
@@ -2760,7 +2754,13 @@
admin->tag = TyA_Type;
}
+ /* List of variables we're accumulating. These don't end up in the
+ DebugInfo; instead their contents are handed to ML_(addVar) and
+ the list elements are then deleted. */
tempvars = NULL;
+
+ /* List of GExprs we're accumulating. These wind up in the
+ DebugInfo. */
gexprs = NULL;
/* We need a D3TypeParser to keep track of partially constructed
@@ -2968,7 +2968,12 @@
}
tempvars = NULL;
- /* FIXME: record adminp in di so it can be freed later */
+ /* record the TyAdmins and the GExprs in di so they can be freed
+ later */
+ vg_assert(!di->tyadmins);
+ di->tyadmins = admin;
+ vg_assert(!di->gexprs);
+ di->gexprs = gexprs;
}
Modified: branches/DATASYMS/coregrind/m_debuginfo/readelf.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/readelf.c 2008-02-13 05:05:58 UTC (rev 7405)
+++ branches/DATASYMS/coregrind/m_debuginfo/readelf.c 2008-02-14 00:44:17 UTC (rev 7406)
@@ -47,6 +47,7 @@
#include "pub_core_tooliface.h" /* VG_(needs) */
#include "pub_core_xarray.h"
#include "priv_misc.h" /* dinfo_zalloc/free/strdup */
+#include "priv_d3basics.h"
#include "priv_tytypes.h"
#include "priv_storage.h"
#include "priv_readelf.h" /* self */
Modified: branches/DATASYMS/coregrind/m_debuginfo/readstabs.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/readstabs.c 2008-02-13 05:05:58 UTC (rev 7405)
+++ branches/DATASYMS/coregrind/m_debuginfo/readstabs.c 2008-02-14 00:44:17 UTC (rev 7406)
@@ -41,6 +41,7 @@
#include "pub_core_xarray.h"
#include "priv_misc.h" /* dinfo_zalloc/free/strdup */
#include "priv_tytypes.h"
+#include "priv_d3basics.h"
#include "priv_storage.h"
#include "priv_readstabs.h" /* self */
Modified: branches/DATASYMS/coregrind/m_debuginfo/tytypes.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/tytypes.c 2008-02-13 05:05:58 UTC (rev 7405)
+++ branches/DATASYMS/coregrind/m_debuginfo/tytypes.c 2008-02-14 00:44:17 UTC (rev 7406)
@@ -80,6 +80,88 @@
return type;
}
+void ML_(delete_TyAtom)( TyAtom* atom ) {
+ if (atom->name)
+ ML_(dinfo_free)(atom->name);
+ ML_(dinfo_free)(atom);
+}
+void ML_(delete_TyField)( TyField* field ) {
+ if (field->name)
+ ML_(dinfo_free)(field->name);
+ /* typeR and loc will be on the admin list; no need to free */
+ ML_(dinfo_free)(field);
+}
+void ML_(delete_TyBounds)( TyBounds* bounds ) {
+ ML_(dinfo_free)(bounds);
+}
+void ML_(delete_D3Expr)( D3Expr* expr ) {
+ if (expr->bytes)
+ ML_(dinfo_free)(expr->bytes);
+ ML_(dinfo_free)(expr);
+}
+void ML_(delete_Type)( Type* ty ) {
+ switch (ty->tag) {
+ case Ty_Base:
+ if (ty->Ty.Base.name)
+ ML_(dinfo_free)(ty->Ty.Base.name);
+ break;
+ case Ty_PorR:
+ /* typeR will be on the admin list */
+ break;
+ case Ty_TyDef:
+ if (ty->Ty.TyDef.name)
+ ML_(dinfo_free)(ty->Ty.TyDef.name);
+ /* typeR will be on the admin list */
+ break;
+ case Ty_StOrUn:
+ if (ty->Ty.StOrUn.name)
+ ML_(dinfo_free)(ty->Ty.StOrUn.name);
+ /* Just dump the containing XArray. The fields themselves
+ will be on the admin list. */
+ if (ty->Ty.StOrUn.fields)
+ VG_(deleteXA)(ty->Ty.StOrUn.fields);
+ break;
+ case Ty_Enum:
+ if (ty->Ty.Enum.name)
+ ML_(dinfo_free)(ty->Ty.Enum.name);
+ if (ty->Ty.Enum.atomRs)
+ VG_(deleteXA)( ty->Ty.Enum.atomRs);
+ /* Just dump the containing XArray. The atoms themselves
+ will be on the admin list. */
+ break;
+ case Ty_Array:
+ if (ty->Ty.Array.bounds)
+ VG_(deleteXA)( ty->Ty.Array.bounds);
+ /* Just dump the containing XArray. The bounds themselves
+ will be on the admin list. */
+ break;
+ case Ty_Fn:
+ break;
+ case Ty_Qual:
+ /* typeR will be on the admin list */
+ break;
+ case Ty_Void:
+ break;
+ default:
+ vg_assert(0);
+ }
+}
+
+void ML_(delete_TyAdmin_and_payload) ( TyAdmin* ad ) {
+ vg_assert(ad->payload);
+ switch (ad->tag) {
+ case TyA_Type: ML_(delete_Type)(ad->payload); break;
+ case TyA_Atom: ML_(delete_TyAtom)(ad->payload); break;
+ case TyA_Expr: ML_(delete_D3Expr)(ad->payload); break;
+ case TyA_Field: ML_(delete_TyField)(ad->payload); break;
+ case TyA_Bounds: ML_(delete_TyBounds)(ad->payload); break;
+ default: vg_assert(0);
+ }
+ ML_(dinfo_free)(ad);
+}
+
+
+
static void pp_XArray_of_pointersOrRefs ( XArray* xa ) {
Word i;
VG_(printf)("{");
@@ -321,21 +403,14 @@
}
-static void copy_bytes_into_XA ( XArray* /* of UChar */ xa,
- void* bytes, Word nbytes ) {
- Word i;
- for (i = 0; i < nbytes; i++)
- VG_(addToXA)( xa, & ((UChar*)bytes)[i] );
-}
static void copy_UWord_into_XA ( XArray* /* of UChar */ xa,
UWord uw ) {
UChar buf[32];
VG_(memset)(buf, 0, sizeof(buf));
VG_(sprintf)(buf, "%lu", uw);
- copy_bytes_into_XA( xa, buf, VG_(strlen)(buf));
+ ML_(copy_bytes_into_XA)( xa, buf, VG_(strlen)(buf));
}
-
/* Describe where in the type 'offset' falls. Caller must
deallocate the resulting XArray. */
XArray* /*UChar*/ ML_(describe_type)( /*OUT*/OffT* residual_offset,
@@ -386,9 +461,9 @@
goto done; /* No. Give up. */
/* Yes. 'field' is it. */
if (!field->name) goto done;
- copy_bytes_into_XA( xa, ".", 1 );
- copy_bytes_into_XA( xa, field->name,
- VG_(strlen)(field->name) );
+ ML_(copy_bytes_into_XA)( xa, ".", 1 );
+ ML_(copy_bytes_into_XA)( xa, field->name,
+ VG_(strlen)(field->name) );
offset -= offMin;
ty = field->typeR;
if (!ty) goto done;
@@ -415,9 +490,9 @@
eszB = ML_(sizeOfType)( ty->Ty.Array.typeR );
if (eszB == 0) goto done;
ix = offset / eszB;
- copy_bytes_into_XA( xa, "[", 1 );
+ ML_(copy_bytes_into_XA)( xa, "[", 1 );
copy_UWord_into_XA( xa, ix );
- copy_bytes_into_XA( xa, "]", 1 );
+ ML_(copy_bytes_into_XA)( xa, "]", 1 );
ty = ty->Ty.Array.typeR;
offset -= ix * eszB;
/* keep going; look inside the array element. */
@@ -447,7 +522,7 @@
done:
*residual_offset = offset;
- copy_bytes_into_XA( xa, "\0", 1 );
+ ML_(copy_bytes_into_XA)( xa, "\0", 1 );
return xa;
}
|