summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Schuetze <r.sagitario@gmx.de>2015-06-09 19:29:54 (GMT)
committerRainer Schuetze <r.sagitario@gmx.de>2015-06-09 19:29:54 (GMT)
commit068e1d5f36fa784e7fc56fe8966cf403de57905d (patch)
treefdeebb491df27c07741231ec557f43ab25157e89
parent31af08b9e88552b8329d7956d862a578bfb19aa6 (diff)
downloadcv2pdb-068e1d5f36fa784e7fc56fe8966cf403de57905d.zip
cv2pdb-068e1d5f36fa784e7fc56fe8966cf403de57905d.tar.gz
cv2pdb-068e1d5f36fa784e7fc56fe8966cf403de57905d.tar.bz2
DWARF: fix struct/class conversion, array limits, replace '.' with '@' in names
-rw-r--r--src/dwarf2pdb.cpp24
-rw-r--r--src/readDwarf.cpp4
-rw-r--r--src/readDwarf.h2
-rw-r--r--src/symutil.cpp5
4 files changed, 21 insertions, 14 deletions
diff --git a/src/dwarf2pdb.cpp b/src/dwarf2pdb.cpp
index beabddd..a8f9043 100644
--- a/src/dwarf2pdb.cpp
+++ b/src/dwarf2pdb.cpp
@@ -297,20 +297,18 @@ bool CV2PDB::addDWARFProc(DWARF_InfoData& procid, DWARF_CompilationUnit* cu, DIE
cursor = lexicalBlocks.back();
lexicalBlocks.pop_back();
- L_nextBlock:
- if (cursor.readNext(id))
+ while (cursor.readNext(id))
{
- L_nextSibling:
if (id.tag == DW_TAG_lexical_block)
{
if (id.hasChild && id.pchi != id.pclo)
{
appendLexicalBlock(id, pclo + codeSegOff);
- DIECursor next = cursor;
- next.gotoSibling();
+ DIECursor next = cursor;
+ next.gotoSibling();
lexicalBlocks.push_back(next);
cursor = cursor.getSubtreeCursor();
- goto L_nextBlock;
+ continue;
}
}
else if (id.tag == DW_TAG_variable)
@@ -322,8 +320,7 @@ bool CV2PDB::addDWARFProc(DWARF_InfoData& procid, DWARF_CompilationUnit* cu, DIE
appendStackVar(id.name, getTypeByDWARFPtr(cu, id.type), loc);
}
}
- if (cursor.readSibling(id))
- goto L_nextSibling;
+ cursor.gotoSibling();
}
appendEnd();
}
@@ -366,9 +363,10 @@ int CV2PDB::addDWARFStructure(DWARF_InfoData& structid, DWARF_CompilationUnit* c
nfields++;
}
#endif
+ // cursor points to the first member
DWARF_InfoData id;
int len = 0;
- while (cursor.readSibling(id))
+ while (cursor.readNext(id, true))
{
int cvid = -1;
if (id.tag == DW_TAG_member && id.name)
@@ -377,7 +375,7 @@ int CV2PDB::addDWARFStructure(DWARF_InfoData& structid, DWARF_CompilationUnit* c
int off = 0;
if (!isunion)
{
- Location loc = decodeLocation(id.member_location);
+ Location loc = decodeLocation(id.member_location, 0, DW_AT_data_member_location);
if (loc.is_abs())
{
off = loc.off;
@@ -396,7 +394,7 @@ int CV2PDB::addDWARFStructure(DWARF_InfoData& structid, DWARF_CompilationUnit* c
else if(id.tag == DW_TAG_inheritance)
{
int off;
- Location loc = decodeLocation(id.member_location);
+ Location loc = decodeLocation(id.member_location, 0, DW_AT_data_member_location);
if (loc.is_abs())
{
cvid = S_CONSTANT_V2;
@@ -415,6 +413,7 @@ int CV2PDB::addDWARFStructure(DWARF_InfoData& structid, DWARF_CompilationUnit* c
nfields++;
}
}
+ cursor.gotoSibling();
}
fl = (codeview_reftype*) (dwarfTypes + flbegin);
fl->fieldlist.len = cbDwarfTypes - flbegin - 2;
@@ -443,7 +442,7 @@ int CV2PDB::getDWARFArrayBounds(DWARF_InfoData& arrayid, DWARF_CompilationUnit*
if (cu)
{
DWARF_InfoData id;
- while (cursor.readSibling(id))
+ while (cursor.readNext(id, true))
{
int cvid = -1;
if (id.tag == DW_TAG_subrange_type)
@@ -451,6 +450,7 @@ int CV2PDB::getDWARFArrayBounds(DWARF_InfoData& arrayid, DWARF_CompilationUnit*
lowerBound = id.lower_bound;
upperBound = id.upper_bound;
}
+ cursor.gotoSibling();
}
}
return lowerBound;
diff --git a/src/readDwarf.cpp b/src/readDwarf.cpp
index 46be7b6..85668a3 100644
--- a/src/readDwarf.cpp
+++ b/src/readDwarf.cpp
@@ -36,7 +36,7 @@ static Location mkRegRel(int reg, int off)
return l;
}
-Location decodeLocation(const DWARF_Attribute& attr, const Location* frameBase)
+Location decodeLocation(const DWARF_Attribute& attr, const Location* frameBase, int at)
{
static Location invalid = { Location::Invalid };
@@ -49,6 +49,8 @@ Location decodeLocation(const DWARF_Attribute& attr, const Location* frameBase)
byte* p = attr.expr.ptr;
Location stack[256];
int stackDepth = 0;
+ if (at == DW_AT_data_member_location)
+ stack[stackDepth++] = Location { Location::Abs, 0, 0 };
for (;;)
{
diff --git a/src/readDwarf.h b/src/readDwarf.h
index 71b43a2..0f5f258 100644
--- a/src/readDwarf.h
+++ b/src/readDwarf.h
@@ -333,7 +333,7 @@ struct Location
// Attemots to partially evaluate DWARF location expressions.
// The only supported expressions are those, whose result may be represented
// as either an absolute value, a register, or a register-relative address.
-Location decodeLocation(const DWARF_Attribute& attr, const Location* frameBase = 0);
+Location decodeLocation(const DWARF_Attribute& attr, const Location* frameBase = 0, int at = 0);
class PEImage;
diff --git a/src/symutil.cpp b/src/symutil.cpp
index 7c92c0c..3b4c1c6 100644
--- a/src/symutil.cpp
+++ b/src/symutil.cpp
@@ -268,6 +268,11 @@ int cstrcpy_v(bool v3, BYTE* d, const char* s)
}
memcpy(d, s, len + 1);
+
+ for(int i = 0; i < len; i++)
+ if (d[i] == '.')
+ d[i] = dotReplacementChar;
+
return len + 1;
}