summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <derodat@adacore.com>2017-03-20 17:48:43 (GMT)
committerPierre-Marie de Rodat <derodat@adacore.com>2018-03-21 10:55:50 (GMT)
commit11b6db811820b28ef3abc9465ac708e31f44b5bf (patch)
treeec1ebc5c534373ee37e0da3726d0b6a7edb8da89 /src
parent6c71972b0a5850e4e269f20ce0e2179031ba4f41 (diff)
downloadcv2pdb-11b6db811820b28ef3abc9465ac708e31f44b5bf.zip
cv2pdb-11b6db811820b28ef3abc9465ac708e31f44b5bf.tar.gz
cv2pdb-11b6db811820b28ef3abc9465ac708e31f44b5bf.tar.bz2
CV2PDB::addDWARFProc: turn uncontiguous ranges into smallest cvring one
This is a hack to workaround something that seems to be missing in CodeView: lexical blocks with non-contiguous address ranges.
Diffstat (limited to 'src')
-rw-r--r--src/dwarf2pdb.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/dwarf2pdb.cpp b/src/dwarf2pdb.cpp
index f5ef586..8ba5750 100644
--- a/src/dwarf2pdb.cpp
+++ b/src/dwarf2pdb.cpp
@@ -742,7 +742,32 @@ bool CV2PDB::addDWARFProc(DWARF_InfoData& procid, DWARF_CompilationUnit* cu, DIE
{
if (id.tag == DW_TAG_lexical_block)
{
- if (id.hasChild && id.pchi != id.pclo)
+ // It seems it is not possible to describe blocks with
+ // non-contiguous address ranges in CodeView. Instead,
+ // just create a range that is large enough to cover
+ // all continuous ranges.
+ if (id.hasChild && id.ranges != -1u)
+ {
+ id.pclo = -1u;
+ id.pchi = 0;
+
+ // TODO: handle base address selection
+ byte *r = (byte *)img.debug_ranges + id.ranges;
+ byte *rend = (byte *)img.debug_ranges + img.debug_ranges_length;
+ while (r < rend)
+ {
+ uint32_t pclo = RD4(r);
+ uint32_t pchi = RD4(r);
+ if (pclo == 0 && pchi == 0)
+ break;
+ if (pclo >= pchi)
+ continue;
+ id.pclo = min(id.pclo, pclo + currentBaseAddress);
+ id.pchi = max(id.pchi, pchi + currentBaseAddress);
+ }
+ }
+
+ if (id.hasChild && id.pchi > id.pclo)
{
appendLexicalBlock(id, pclo + codeSegOff);
DIECursor next = cursor;