summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorAmy Yu <amycmyu@gmail.com>2018-06-14 17:34:47 -0700
committerAmy Yu <amycmyu@gmail.com>2018-06-14 17:34:47 -0700
commita1c04b25428b2c800f281ad2a4b7241199612bac (patch)
treec5ebc181d0554ea3f1776e787b20a504d7175bad /src/tools
parent80809ca2890fb3d952521db69573da2b9a0d1231 (diff)
downloadcoreclr-a1c04b25428b2c800f281ad2a4b7241199612bac.tar.gz
coreclr-a1c04b25428b2c800f281ad2a4b7241199612bac.tar.bz2
coreclr-a1c04b25428b2c800f281ad2a4b7241199612bac.zip
Fixed some bugs with gc transitions
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/r2rdump/GCInfo.cs15
-rw-r--r--src/tools/r2rdump/GCSlotTable.cs4
-rw-r--r--src/tools/r2rdump/NativeReader.cs2
3 files changed, 15 insertions, 6 deletions
diff --git a/src/tools/r2rdump/GCInfo.cs b/src/tools/r2rdump/GCInfo.cs
index 2b8c1f1465..a39a85a11c 100644
--- a/src/tools/r2rdump/GCInfo.cs
+++ b/src/tools/r2rdump/GCInfo.cs
@@ -385,12 +385,21 @@ namespace R2RDump
{
chunkPointers[i] = NativeReader.ReadBits(image, numBitsPerPointer, ref bitOffset);
}
- bitOffset = (int)Math.Ceiling(bitOffset / 8.0) * 8;
+ int info2Offset = (int)Math.Ceiling(bitOffset / 8.0) * 8;
List<GcTransition> transitions = new List<GcTransition>();
bool[] liveAtEnd = new bool[slots.Count];
for (int currentChunk = 0; currentChunk < numChunks; currentChunk++)
{
+ if (chunkPointers[currentChunk] == 0)
+ {
+ continue;
+ }
+ else
+ {
+ bitOffset = info2Offset + chunkPointers[currentChunk] - 1;
+ }
+
int couldBeLiveOffset = bitOffset;
int slotId = 0;
bool fSimple = (NativeReader.ReadBits(image, 1, ref couldBeLiveOffset) == 0);
@@ -410,7 +419,7 @@ namespace R2RDump
int normChunkBaseCodeOffset = currentChunk * gcInfoTypes.NUM_NORM_CODE_OFFSETS_PER_CHUNK;
for (int i = 0; i < numCouldBeLiveSlots; i++)
{
- slotId = GetSlotId(image, gcInfoTypes, fSimple, fSkipFirst, slotId, ref couldBeLiveCnt, ref couldBeLiveOffset);
+ slotId = GetNextSlotId(image, gcInfoTypes, fSimple, fSkipFirst, slotId, ref couldBeLiveCnt, ref couldBeLiveOffset);
bool isLive = !liveAtEnd[slotId];
liveAtEnd[slotId] = (NativeReader.ReadBits(image, 1, ref finalStateOffset) != 0);
@@ -469,7 +478,7 @@ namespace R2RDump
return numCouldBeLiveSlots;
}
- private int GetSlotId(byte[] image, GcInfoTypes gcInfoTypes, bool fSimple, bool fSkipFirst, int slotId, ref int couldBeLiveCnt, ref int couldBeLiveOffset)
+ private int GetNextSlotId(byte[] image, GcInfoTypes gcInfoTypes, bool fSimple, bool fSkipFirst, int slotId, ref int couldBeLiveCnt, ref int couldBeLiveOffset)
{
if (fSimple)
{
diff --git a/src/tools/r2rdump/GCSlotTable.cs b/src/tools/r2rdump/GCSlotTable.cs
index 5828b95418..750c65d7e1 100644
--- a/src/tools/r2rdump/GCSlotTable.cs
+++ b/src/tools/r2rdump/GCSlotTable.cs
@@ -103,7 +103,7 @@ namespace R2RDump
GcSlotFlags flags = (GcSlotFlags)NativeReader.ReadBits(image, 2, ref bitOffset);
GcSlots.Add(new GcSlot((int)regNum, null, flags));
- for (int i = 1; i < NumRegisters && i < gcInfoTypes.MAX_PREDECODED_SLOTS; i++)
+ for (int i = 1; i < NumRegisters; i++)
{
if ((uint)flags != 0)
{
@@ -128,7 +128,7 @@ namespace R2RDump
GcSlotFlags flags = (GcSlotFlags)NativeReader.ReadBits(image, 2, ref bitOffset);
GcSlots.Add(new GcSlot(-1, new GcStackSlot(spOffset, spBase), flags));
- for (int i = 1; i < nSlots && GcSlots.Count < gcInfoTypes.MAX_PREDECODED_SLOTS; i++)
+ for (int i = 1; i < nSlots; i++)
{
spBase = (GcStackSlotBase)NativeReader.ReadBits(image, 2, ref bitOffset);
if ((uint)flags != 0)
diff --git a/src/tools/r2rdump/NativeReader.cs b/src/tools/r2rdump/NativeReader.cs
index cfc9a68107..9871c2eb3d 100644
--- a/src/tools/r2rdump/NativeReader.cs
+++ b/src/tools/r2rdump/NativeReader.cs
@@ -107,7 +107,7 @@ namespace R2RDump
int bits = bitOffset % BITS_PER_BYTE;
int val = image[start] >> bits;
bits += numBits;
- if (bits > BITS_PER_BYTE)
+ while (bits > BITS_PER_BYTE)
{
start++;
bits -= BITS_PER_BYTE;