Skip to content

Commit 51c8f8f

Browse files
committed
Code cleanups
1 parent 6a96d39 commit 51c8f8f

File tree

3 files changed

+39
-27
lines changed

3 files changed

+39
-27
lines changed

substratevm/DEBUGINFO.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Using the ptototype debug info feature
2-
--------------------------------------
1+
Using the debug info feature
2+
----------------------------
33

44
To add debug info to a generated native image add flag
55
-H:GenerateDebugInfo=<N> to the native image command line (where N is
@@ -10,8 +10,8 @@ debug info). For example,
1010
$ mx native-image -H:GenerateDebugInfo=1 Hello
1111

1212
The resulting image should contain code (method) debug records in a
13-
format gdb understands (VS support is still under development). At
14-
present it makes no difference which positive value is supplied as
13+
format gdb understands (Windows support is still under development).
14+
At present it makes no difference which positive value is supplied as
1515
argument to the GenerateDebugInfo option.
1616

1717
The GenerateDebugInfo option also enables caching of sources for any
@@ -30,7 +30,7 @@ uses the current JAVA_HOME to locate the JDK src.zip when searching
3030
for JDK runtime sources. It also uses entries in the classpath to
3131
suggest locations for GraalVM source files and application source
3232
files (see below for precise details of the scheme used to identify
33-
source locations). However, source layouts do vary and it may no tbe
33+
source locations). However, source layouts do vary and it may not be
3434
possible to find all sources. Hence, users can specify the location of
3535
source files explicitly on the command line using option
3636
DebugInfoSourceSearchPath:
@@ -61,7 +61,7 @@ Note that in both the examples above the DebugInfoSourceSearchPath
6161
options are actually redundant. In the first case the classpath
6262
entries for apps/hello/classes and apps/greeter/classes will be used
6363
to derive the default search roots apps/hello/src and
64-
apps/greeter/src. In the second case classpath entires
64+
apps/greeter/src. In the second case classpath entries
6565
apps/target/hello.jar and apps/target/greeter.jar will be used to
6666
derive the default search roots apps/target/hello-sources.jar and
6767
apps/target/greeter-sources.jar.
@@ -90,7 +90,7 @@ achieve this by accumulating the relevant sources in a suitably
9090
structured file cache.
9191

9292
The native image generator uses different strategies to locate source
93-
files for JDK runtime classes, GraalVM classses and application source
93+
files for JDK runtime classes, GraalVM classes and application source
9494
classes for inclusion in the local sources cache. It identifies which
9595
strategy to use based on the package name of the class. So, for
9696
example, packages starting with java.* or jdk.* are JDK classes;
@@ -180,7 +180,7 @@ sources are being included.
180180
You can also add extra directories to the search path. Note that gdb
181181
does not understand zip format file systems so any extra entries you
182182
add must identify a directory tree containing the relevant
183-
sources. Once again. top leel entries in the directory added to the
183+
sources. Once again. top level entries in the directory added to the
184184
search path must correspond to the top level package for the classes
185185
whose sources are being included.
186186

@@ -193,13 +193,13 @@ Checking debug info on Linux
193193
----------------------------
194194

195195
n.b. this is only of interest to those who want to understand how the
196-
debug info implemetation works or want to trouble shoot problems
196+
debug info implementation works or want to trouble shoot problems
197197
encountered during debugging that might relate to the debug info
198198
encoding.
199199

200-
The objdump command can be used to display the dbeug info embedded
200+
The objdump command can be used to display the debug info embedded
201201
into a native image. The following commands (which all assume the
202-
target binary is called hello) can be used to display all currentyl
202+
target binary is called hello) can be used to display all currently
203203
generated content:
204204

205205
$ objdump --dwarf=info hello > info
@@ -212,7 +212,7 @@ generated content:
212212

213213
The *info* section includes details of all compiled Java methods.
214214

215-
The *abbrev* sectio defines the layout of records in the info section
215+
The *abbrev* section defines the layout of records in the info section
216216
that describe Java files (compilation units) and methods.
217217

218218
The *ranges* section details the start and end addresses of method
@@ -222,8 +222,8 @@ The *decodedline* section maps subsegments of method code range
222222
segments to files and line numbers. This mapping includes entries
223223
for files and line numbers for inlined methods.
224224

225-
The *rawline* segment provides deatails of how the line table is
226-
generated using DWARF state machine instuctions that encode file,
225+
The *rawline* segment provides details of how the line table is
226+
generated using DWARF state machine instructions that encode file,
227227
line and address transitions.
228228

229229
The *str* section provides a lookup table for strings referenced
@@ -244,7 +244,7 @@ Currently supported targets
244244

245245
The prototype is currently implemented only for gdb on Linux.
246246

247-
- Linux/x86_64 suppoort has been tested and should work
247+
- Linux/x86_64 support has been tested and should work
248248
correctly.
249249

250250
- Linux/AArch64 support is present but has not yet been fully

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
import java.util.LinkedList;
3636
import java.util.List;
3737
import java.util.Map;
38+
3839
/**
39-
* An abstract class which indexes the information presented by the DebugInfoProvider
40-
* in an organization suitable for use by subclasses targeting a specific binary format.
40+
* An abstract class which indexes the information presented by the DebugInfoProvider in an
41+
* organization suitable for use by subclasses targeting a specific binary format.
4142
*/
4243
public abstract class DebugInfoBase {
4344
protected ByteOrder byteOrder;
@@ -102,6 +103,7 @@ public abstract class DebugInfoBase {
102103
public DebugInfoBase(ByteOrder byteOrder) {
103104
this.byteOrder = byteOrder;
104105
}
106+
105107
/**
106108
* Entry point allowing ELFObjectFile to pass on information about types, code and heap data.
107109
*
@@ -167,6 +169,7 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
167169
* String name = debugDataInfo.toString(); }
168170
*/
169171
}
172+
170173
private ClassEntry ensureClassEntry(Range range) {
171174
String className = range.getClassName();
172175
/*
@@ -185,6 +188,7 @@ private ClassEntry ensureClassEntry(Range range) {
185188
assert classEntry.getClassName().equals(className);
186189
return classEntry;
187190
}
191+
188192
private FileEntry ensureFileEntry(Range range) {
189193
String fileName = range.getFileName();
190194
if (fileName == null) {
@@ -213,25 +217,29 @@ private FileEntry ensureFileEntry(Range range) {
213217
}
214218
return fileEntry;
215219
}
220+
216221
private void addRange(Range primaryRange, List<DebugInfoProvider.DebugFrameSizeChange> frameSizeInfos, int frameSize) {
217222
assert primaryRange.isPrimary();
218223
ClassEntry classEntry = ensureClassEntry(primaryRange);
219224
classEntry.addPrimary(primaryRange, frameSizeInfos, frameSize);
220225
}
226+
221227
private void addSubRange(Range primaryRange, Range subrange) {
222228
assert primaryRange.isPrimary();
223229
assert !subrange.isPrimary();
224230
String className = primaryRange.getClassName();
225231
ClassEntry classEntry = primaryClassesIndex.get(className);
226232
FileEntry subrangeFileEntry = ensureFileEntry(subrange);
227233
/*
228-
* The primary range should already have been seen and associated with a primary class entry.
234+
* The primary range should already have been seen and associated with a primary class
235+
* entry.
229236
*/
230237
assert classEntry.primaryIndexFor(primaryRange) != null;
231238
if (subrangeFileEntry != null) {
232239
classEntry.addSubRange(subrange, subrangeFileEntry);
233240
}
234241
}
242+
235243
private DirEntry ensureDirEntry(Path filePath) {
236244
if (filePath == null) {
237245
return null;
@@ -243,24 +251,30 @@ private DirEntry ensureDirEntry(Path filePath) {
243251
}
244252
return dirEntry;
245253
}
254+
246255
/* Accessors to query the debug info model. */
247256
public ByteOrder getByteOrder() {
248257
return byteOrder;
249258
}
259+
250260
public LinkedList<ClassEntry> getPrimaryClasses() {
251261
return primaryClasses;
252262
}
263+
253264
@SuppressWarnings("unused")
254265
public LinkedList<FileEntry> getFiles() {
255266
return files;
256267
}
268+
257269
@SuppressWarnings("unused")
258270
public FileEntry findFile(Path fullFileName) {
259271
return filesIndex.get(fullFileName);
260272
}
273+
261274
public StringTable getStringTable() {
262275
return stringTable;
263276
}
277+
264278
/**
265279
* Indirects this call to the string table.
266280
*

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/ELFObjectFile.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,15 +1183,13 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
11831183
newUserDefinedSection(elfARangesSectionImpl.getSectionName(), elfARangesSectionImpl);
11841184
newUserDefinedSection(elfLineSectionImpl.getSectionName(), elfLineSectionImpl);
11851185
/*
1186-
* The byte[] for each implementation's content are created and
1187-
* written under getOrDecideContent. Doing that ensures that all
1188-
* dependent sections are filled in and then sized according to the
1189-
* declared dependencies. However, if we leave it at that then
1190-
* associated reloc sections only get created when the first reloc
1191-
* is inserted during content write that's too late for them to have
1192-
* layout constraints included in the layout decision set and causes
1193-
* an NPE during reloc section write. So we need to create the relevant
1194-
* reloc sections here in advance.
1186+
* The byte[] for each implementation's content are created and written under
1187+
* getOrDecideContent. Doing that ensures that all dependent sections are filled in and then
1188+
* sized according to the declared dependencies. However, if we leave it at that then
1189+
* associated reloc sections only get created when the first reloc is inserted during
1190+
* content write that's too late for them to have layout constraints included in the layout
1191+
* decision set and causes an NPE during reloc section write. So we need to create the
1192+
* relevant reloc sections here in advance.
11951193
*/
11961194
elfStrSectionImpl.getOrCreateRelocationElement(false);
11971195
elfAbbrevSectionImpl.getOrCreateRelocationElement(false);

0 commit comments

Comments
 (0)