Skip to content

Commit b7f9fdc

Browse files
committed
make lo/hi ranges long instead of int to allow 8-byte values (as allowed per DWARF specs)
1 parent 214d509 commit b7f9fdc

File tree

13 files changed

+50
-50
lines changed

13 files changed

+50
-50
lines changed

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public boolean hasCompiledEntries() {
317317
return compiledEntryCount() != 0;
318318
}
319319

320-
public int compiledEntriesBase() {
320+
public long compiledEntriesBase() {
321321
assert hasCompiledEntries();
322322
return compiledEntries.get(0).getPrimary().getLo();
323323
}
@@ -352,7 +352,7 @@ public List<MethodEntry> getMethods() {
352352
*
353353
* @return the lowest code section offset for compiled method code belonging to this class
354354
*/
355-
public int lowpc() {
355+
public long lowpc() {
356356
assert hasCompiledEntries();
357357
return compiledEntries.get(0).getPrimary().getLo();
358358
}
@@ -364,7 +364,7 @@ public int lowpc() {
364364
*
365365
* @return the highest code section offset for compiled method code belonging to this class
366366
*/
367-
public int hipc() {
367+
public long hipc() {
368368
assert hasCompiledEntries();
369369
return compiledEntries.get(compiledEntries.size() - 1).getPrimary().getHi();
370370
}

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/DebugInfoBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,8 @@ private Range addSubrange(DebugLocationInfo locationInfo, PrimaryRange primaryRa
515515
final String methodName = locationInfo.name();
516516
final int loOff = locationInfo.addressLo();
517517
final int hiOff = locationInfo.addressHi() - 1;
518-
final int lo = primaryRange.getLo() + locationInfo.addressLo();
519-
final int hi = primaryRange.getLo() + locationInfo.addressHi();
518+
final long lo = primaryRange.getLo() + locationInfo.addressLo();
519+
final long hi = primaryRange.getLo() + locationInfo.addressHi();
520520
final int line = locationInfo.line();
521521
ClassEntry subRangeClassEntry = lookupClassEntry(ownerType);
522522
MethodEntry subRangeMethodEntry = subRangeClassEntry.ensureMethodEntryForDebugRangeInfo(locationInfo, this, debugContext);

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/range/CallRange.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2022, 2022, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -39,7 +39,7 @@ class CallRange extends SubRange {
3939
*/
4040
protected SubRange lastCallee;
4141

42-
protected CallRange(MethodEntry methodEntry, int lo, int hi, int line, PrimaryRange primary, Range caller) {
42+
protected CallRange(MethodEntry methodEntry, long lo, long hi, int line, PrimaryRange primary, Range caller) {
4343
super(methodEntry, lo, hi, line, primary, caller);
4444
this.firstCallee = null;
4545
this.lastCallee = null;

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/range/LeafRange.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2022, 2022, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -29,7 +29,7 @@
2929
import com.oracle.objectfile.debugentry.MethodEntry;
3030

3131
class LeafRange extends SubRange {
32-
protected LeafRange(MethodEntry methodEntry, int lo, int hi, int line, PrimaryRange primary, Range caller) {
32+
protected LeafRange(MethodEntry methodEntry, long lo, long hi, int line, PrimaryRange primary, Range caller) {
3333
super(methodEntry, lo, hi, line, primary, caller);
3434
}
3535

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/range/PrimaryRange.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2022, 2022, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -39,7 +39,7 @@ public class PrimaryRange extends Range {
3939
*/
4040
protected SubRange lastCallee;
4141

42-
protected PrimaryRange(MethodEntry methodEntry, int lo, int hi, int line) {
42+
protected PrimaryRange(MethodEntry methodEntry, long lo, long hi, int line) {
4343
super(methodEntry, lo, hi, line, -1);
4444
this.firstCallee = null;
4545
this.lastCallee = null;

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/range/Range.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -72,29 +72,29 @@
7272
public abstract class Range {
7373
private static final String CLASS_DELIMITER = ".";
7474
protected final MethodEntry methodEntry;
75-
protected final int lo;
76-
protected int hi;
75+
protected final long lo;
76+
protected long hi;
7777
protected final int line;
7878
protected final int depth;
7979

8080
/**
8181
* Create a primary range representing the root of the subrange tree for a top level compiled
8282
* method.
83-
*
83+
*
8484
* @param methodEntry the top level compiled method for this primary range.
8585
* @param lo the lowest address included in the range.
8686
* @param hi the first address above the highest address in the range.
8787
* @param line the line number associated with the range
8888
* @return a new primary range to serve as the root of the subrange tree.
8989
*/
90-
public static PrimaryRange createPrimary(MethodEntry methodEntry, int lo, int hi, int line) {
90+
public static PrimaryRange createPrimary(MethodEntry methodEntry, long lo, long hi, int line) {
9191
return new PrimaryRange(methodEntry, lo, hi, line);
9292
}
9393

9494
/**
9595
* Create a subrange representing a segment of the address range for code of a top level or
9696
* inlined compiled method. The result will either be a call or a leaf range.
97-
*
97+
*
9898
* @param methodEntry the method from which code in the subrange is derived.
9999
* @param lo the lowest address included in the range.
100100
* @param hi the first address above the highest address in the range.
@@ -105,7 +105,7 @@ public static PrimaryRange createPrimary(MethodEntry methodEntry, int lo, int hi
105105
* @param isLeaf true if this is a leaf range with no subranges
106106
* @return a new subrange to be linked into the range tree below the primary range.
107107
*/
108-
public static SubRange createSubrange(MethodEntry methodEntry, int lo, int hi, int line, PrimaryRange primary, Range caller, boolean isLeaf) {
108+
public static SubRange createSubrange(MethodEntry methodEntry, long lo, long hi, int line, PrimaryRange primary, Range caller, boolean isLeaf) {
109109
assert primary != null;
110110
assert primary.isPrimary();
111111
if (isLeaf) {
@@ -115,7 +115,7 @@ public static SubRange createSubrange(MethodEntry methodEntry, int lo, int hi, i
115115
}
116116
}
117117

118-
protected Range(MethodEntry methodEntry, int lo, int hi, int line, int depth) {
118+
protected Range(MethodEntry methodEntry, long lo, long hi, int line, int depth) {
119119
assert methodEntry != null;
120120
this.methodEntry = methodEntry;
121121
this.lo = lo;
@@ -144,11 +144,11 @@ public String getSymbolName() {
144144
return methodEntry.getSymbolName();
145145
}
146146

147-
public int getHi() {
147+
public long getHi() {
148148
return hi;
149149
}
150150

151-
public int getLo() {
151+
public long getLo() {
152152
return lo;
153153
}
154154

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/range/SubRange.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2022, 2022, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -60,7 +60,7 @@ public abstract class SubRange extends Range {
6060
private DebugInfoProvider.DebugLocalInfo[] localInfos;
6161

6262
@SuppressWarnings("this-escape")
63-
protected SubRange(MethodEntry methodEntry, int lo, int hi, int line, PrimaryRange primary, Range caller) {
63+
protected SubRange(MethodEntry methodEntry, long lo, long hi, int line, PrimaryRange primary, Range caller) {
6464
super(methodEntry, lo, hi, line, (caller == null ? 0 : caller.depth + 1));
6565
this.caller = caller;
6666
if (caller != null) {

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debuginfo/dwarf/DwarfInfoSectionImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -409,7 +409,7 @@ private int writeInstanceClassInfo(DebugContext context, ClassEntry classEntry,
409409
log(context, " [0x%08x] ranges 0x%x", pos, codeRangesIndex);
410410
pos = writeRangesSectionOffset(codeRangesIndex, buffer, pos);
411411
// write low_pc as well as ranges so that lcoation lists can default the base address
412-
int lo = classEntry.lowpc();
412+
long lo = classEntry.lowpc();
413413
log(context, " [0x%08x] low_pc 0x%x", pos, codeRangesIndex);
414414
pos = writeAttrAddress(lo, buffer, pos);
415415
int lineIndex = getLineIndex(classEntry);

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debuginfo/dwarf/DwarfLocSectionImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2022, 2022, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -151,7 +151,7 @@ private int writeCompiledMethodLocations(DebugContext context, CompiledMethodEnt
151151
* more up-front cross-referencing of CUs when it needs to resolve code addresses e.g. to
152152
* set a breakpoint, leading to a very slow response for the user.
153153
*/
154-
int base = primary.getLo();
154+
long base = primary.getLo();
155155
log(context, " [0x%08x] top level locations [0x%x, 0x%x] method %s", pos, primary.getLo(), primary.getHi(), primary.getFullMethodNameWithParams());
156156
pos = writeTopLevelLocations(context, compiledEntry, base, buffer, pos);
157157
if (!primary.isLeaf()) {
@@ -161,7 +161,7 @@ private int writeCompiledMethodLocations(DebugContext context, CompiledMethodEnt
161161
return pos;
162162
}
163163

164-
private int writeTopLevelLocations(DebugContext context, CompiledMethodEntry compiledEntry, int base, byte[] buffer, int p) {
164+
private int writeTopLevelLocations(DebugContext context, CompiledMethodEntry compiledEntry, long base, byte[] buffer, int p) {
165165
int pos = p;
166166
Range primary = compiledEntry.getPrimary();
167167
HashMap<DebugLocalInfo, List<SubRange>> varRangeMap = primary.getVarRangeMap();
@@ -175,7 +175,7 @@ private int writeTopLevelLocations(DebugContext context, CompiledMethodEntry com
175175
return pos;
176176
}
177177

178-
private int writeInlineLocations(DebugContext context, CompiledMethodEntry compiledEntry, int base, byte[] buffer, int p) {
178+
private int writeInlineLocations(DebugContext context, CompiledMethodEntry compiledEntry, long base, byte[] buffer, int p) {
179179
int pos = p;
180180
Range primary = compiledEntry.getPrimary();
181181
assert !primary.isLeaf();
@@ -197,7 +197,7 @@ private int writeInlineLocations(DebugContext context, CompiledMethodEntry compi
197197
return pos;
198198
}
199199

200-
private int writeVarLocations(DebugContext context, DebugLocalInfo local, int base, List<SubRange> rangeList, byte[] buffer, int p) {
200+
private int writeVarLocations(DebugContext context, DebugLocalInfo local, long base, List<SubRange> rangeList, byte[] buffer, int p) {
201201
assert !rangeList.isEmpty();
202202
int pos = p;
203203
// collect ranges and values, merging adjacent ranges that have equal value
@@ -362,15 +362,15 @@ static class LocalValueExtent {
362362
}
363363

364364
@SuppressWarnings("unused")
365-
boolean shouldMerge(int otherLo, int otherHi, DebugLocalValueInfo otherValue) {
365+
boolean shouldMerge(long otherLo, long otherHi, DebugLocalValueInfo otherValue) {
366366
// ranges need to be contiguous to merge
367367
if (hi != otherLo) {
368368
return false;
369369
}
370370
return value.equals(otherValue);
371371
}
372372

373-
private LocalValueExtent maybeMerge(int otherLo, int otherHi, DebugLocalValueInfo otherValue) {
373+
private LocalValueExtent maybeMerge(long otherLo, long otherHi, DebugLocalValueInfo otherValue) {
374374
if (shouldMerge(otherLo, otherHi, otherValue)) {
375375
// We can extend the current extent to cover the next one.
376376
this.hi = otherHi;

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debuginfo/dwarf/DwarfRangesSectionImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ public void writeContent(DebugContext context) {
9090
int start = pos;
9191
setCodeRangesIndex(classEntry, pos);
9292
log(context, " [0x%08x] ranges start for class %s", pos, classEntry.getTypeName());
93-
int base = classEntry.compiledEntriesBase();
93+
long base = classEntry.compiledEntriesBase();
9494
log(context, " [0x%08x] base 0x%x", pos, base);
9595
pos = writeLong(-1L, buffer, pos);
9696
pos = writeRelocatableCodeOffset(base, buffer, pos);
9797
cursor.set(pos);
9898
classEntry.compiledEntries().forEach(compiledMethodEntry -> {
99-
int lo = compiledMethodEntry.getPrimary().getLo();
100-
int hi = compiledMethodEntry.getPrimary().getHi();
99+
long lo = compiledMethodEntry.getPrimary().getLo();
100+
long hi = compiledMethodEntry.getPrimary().getHi();
101101
log(context, " [0x%08x] lo 0x%x (%s)", cursor.get(), lo - base, compiledMethodEntry.getPrimary().getFullMethodNameWithParams());
102102
cursor.set(writeLong(lo - base, buffer, cursor.get()));
103103
log(context, " [0x%08x] hi 0x%x", cursor.get(), hi - base);

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecord.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -55,7 +55,7 @@ void addNewFile(int fileId) {
5555
fileBlocks.add(new FileBlock(fileId));
5656
}
5757

58-
void addNewLine(int addr, int line) {
58+
void addNewLine(long addr, int line) {
5959
fileBlocks.get(fileBlocks.size() - 1).addEntry(new LineEntry(addr, line));
6060
}
6161

@@ -97,8 +97,8 @@ private int computeHeader(byte[] buffer, int initialPos) {
9797

9898
/* Length of this chunk in object file (= highAddr since it's zero based. */
9999
assert !fileBlocks.isEmpty();
100-
int length = fileBlocks.get(fileBlocks.size() - 1).getHighAddr();
101-
pos = CVUtil.putInt(length, buffer, pos);
100+
long length = fileBlocks.get(fileBlocks.size() - 1).getHighAddr();
101+
pos = CVUtil.putLong(length, buffer, pos);
102102
return pos;
103103
}
104104

@@ -161,7 +161,7 @@ int computeSize(int initialPos) {
161161
return initialPos + FILE_BLOCK_HEADER_SIZE + LineEntry.LINE_ENTRY_SIZE * lineEntries.size();
162162
}
163163

164-
int getHighAddr() {
164+
long getHighAddr() {
165165
assert !lineEntries.isEmpty();
166166
return lineEntries.get(lineEntries.size() - 1).addr;
167167
}
@@ -176,10 +176,10 @@ private static class LineEntry {
176176
/* Entry: address(4 bytes) line number+flags (4 bytes) */
177177
static final int LINE_ENTRY_SIZE = 2 * Integer.BYTES;
178178

179-
int addr;
179+
long addr;
180180
int lineAndFlags;
181181

182-
LineEntry(int addr, int line, int deltaEnd, boolean isStatement) {
182+
LineEntry(long addr, int line, int deltaEnd, boolean isStatement) {
183183
this.addr = addr;
184184
assert line <= 0xffffff;
185185
assert line >= 0;
@@ -188,13 +188,13 @@ private static class LineEntry {
188188
lineAndFlags = line | (deltaEnd << 24) | (isStatement ? 0x80000000 : 0);
189189
}
190190

191-
LineEntry(int addr, int line) {
191+
LineEntry(long addr, int line) {
192192
this(addr, line, 0, false);
193193
}
194194

195195
int computeContents(byte[] buffer, int initialPos) {
196196
int pos = initialPos;
197-
pos = CVUtil.putInt(addr, buffer, pos);
197+
pos = CVUtil.putLong(addr, buffer, pos);
198198
pos = CVUtil.putInt(lineAndFlags, buffer, pos);
199199
return pos;
200200
}

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVLineRecordBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -102,7 +102,7 @@ private void processRange(Range range) {
102102
}
103103

104104
/* Add line record. */
105-
int lineLoAddr = range.getLo() - compiledEntry.getPrimary().getLo();
105+
long lineLoAddr = range.getLo() - compiledEntry.getPrimary().getLo();
106106
int line = Math.max(range.getLine(), 1);
107107
debug(" processRange: addNewLine: 0x%05x-0x%05x %s", lineLoAddr, range.getHi() - compiledEntry.getPrimary().getLo(), line);
108108
lineRecord.addNewLine(lineLoAddr, line);

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2020, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -340,7 +340,7 @@ public static class CVSymbolGProc32Record extends CVSymbolSubrecord {
340340
private final int pparent;
341341
private final int pend;
342342
private final int pnext;
343-
private final int proclen;
343+
private final long proclen;
344344
private final int debugStart;
345345
private final int debugEnd;
346346
private final int typeIndex;
@@ -349,7 +349,7 @@ public static class CVSymbolGProc32Record extends CVSymbolSubrecord {
349349
private final String symbolName;
350350
private final String displayName;
351351

352-
CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, int proclen, int debugStart, int debugEnd, int typeIndex,
352+
CVSymbolGProc32Record(CVDebugInfo cvDebugInfo, String symbolName, String displayName, int pparent, int pend, int pnext, long proclen, int debugStart, int debugEnd, int typeIndex,
353353
short segment, byte flags) {
354354
super(cvDebugInfo, CVDebugConstants.S_GPROC32);
355355
this.symbolName = symbolName;
@@ -370,7 +370,7 @@ protected int computeContents(byte[] buffer, int initialPos) {
370370
int pos = CVUtil.putInt(pparent, buffer, initialPos);
371371
pos = CVUtil.putInt(pend, buffer, pos);
372372
pos = CVUtil.putInt(pnext, buffer, pos);
373-
pos = CVUtil.putInt(proclen, buffer, pos);
373+
pos = CVUtil.putLong(proclen, buffer, pos);
374374
pos = CVUtil.putInt(debugStart, buffer, pos);
375375
pos = CVUtil.putInt(debugEnd, buffer, pos);
376376
pos = CVUtil.putInt(typeIndex, buffer, pos);

0 commit comments

Comments
 (0)