Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
393b17b
define interfaces used to communicate debug info to object file and p…
adinn Jan 21, 2020
cab2bc9
implement generation of basic DWARF sections in ELF object files
adinn Jan 21, 2020
c447f4d
drive native image debug info generation when -H:+TrackNodeSourcePosi…
adinn Jan 21, 2020
f38669e
script that writes a 'set directories' command into file .gdbsourcepa…
adinn Jan 21, 2020
476b909
instructions for using debug info prototype
adinn Jan 22, 2020
55ab5bd
fix check-style errors
adinn Jan 22, 2020
dd09c00
fixed eclipseformat style issues
adinn Jan 22, 2020
bfe928f
fixed eclipseformat style issues
adinn Jan 22, 2020
0b2bbc4
more style whackamole
adinn Jan 22, 2020
441b64f
death to style dragons
adinn Jan 22, 2020
0d5308c
sigh ... still more style issues
adinn Jan 22, 2020
7138edc
another style domino topples
adinn Jan 23, 2020
b4a83df
converted lots of comments to javadcoc, added new ones and edited con…
adinn Jan 23, 2020
fc310cf
fix missing javadoc return and remove unused imports
adinn Jan 23, 2020
65e1aa3
fix punctuation issues and remove redudant declaration
adinn Jan 23, 2020
a394251
remove debug trace
adinn Jan 24, 2020
cb8be8e
fix reloc code to ensure content of elf section depends on content of…
adinn Jan 24, 2020
df8f5bd
add correct VADDR dependency so that debug sections can use vaddr of …
adinn Jan 24, 2020
b2c884f
fix some bugs turned up by enabling asserts
adinn Jan 28, 2020
69af9d1
remove redudant local declarations
adinn Feb 6, 2020
6b3f95c
removed redundant list of primary entries since iteration always happ…
adinn Feb 6, 2020
24c17a4
relocate dwarf section implementations to separate files as outer cla…
adinn Feb 6, 2020
80d4c19
added option GenertaeDebugInfo=<level> and made it force TrackNodeSou…
adinn Feb 6, 2020
7d74c91
deleted another remaining redundant local var
adinn Feb 6, 2020
da14ccd
fixed style issues and made code aware of target byte order
adinn Feb 7, 2020
8366f51
start using Path expressions for directories and file names
adinn Feb 11, 2020
a0bae1e
ensure dir path for module classes include module name at start
adinn Feb 12, 2020
392b580
fix problem with non-null return for empty package on jdk11
adinn Feb 12, 2020
94512bf
avoid addition ofmodule prefix to file paths for Graal classes
adinn Feb 12, 2020
396b552
lookup source files via classpath or local dir and cache copies in lo…
adinn Feb 24, 2020
0700ec6
correct use File and Path APIs
adinn Feb 25, 2020
61eeb39
remove redundant imports
adinn Feb 25, 2020
99fb818
modified debug info API to use streams instead of iterators
adinn Feb 25, 2020
93dbfe5
updated DEBUGINFO readme to match latest version
adinn Feb 26, 2020
db7ec66
fixed typos and small format/wording errors and rmeoved smeredudant code
adinn Feb 26, 2020
2d0a7e7
Add Windows SECTION and SECREL relocations types
stooke Feb 26, 2020
63ee7cd
initial PECoff CodeView support
stooke Feb 26, 2020
0c323d7
added -H:DebugInfoSourceSearchPath option, tweaked SourceCacheType en…
adinn Feb 27, 2020
ceeefa3
update readme to describe DebugInfoSourceSearchPath option
adinn Feb 27, 2020
0e14d50
added some debug behviour switches, null source cache implementation
stooke Feb 27, 2020
7a70ada
address some checkstyle errors
stooke Feb 27, 2020
6c38153
use string,replace() to avoid backslash error in regex on Windows
stooke Feb 27, 2020
17cd324
Merge pull request #2 from stooke/debug_info_prototype
adinn Feb 27, 2020
fd36ad9
obtain classpath from image classloader, clean up source searches, en…
adinn Feb 28, 2020
9579a99
Move ClassEntry and siblings to package com.oracle.objectfile.debugentry
stooke Mar 3, 2020
842fb01
Merge remote-tracking branch 'adinn/debug_info_prototype' into pr_deb…
stooke Mar 3, 2020
e1868ea
fix merge issues
stooke Mar 3, 2020
79cd412
if generating debug info, don't strip local symbols
stooke Mar 3, 2020
38b1974
refctor codeview code to use existing Range/ClassEntry classes
stooke Mar 3, 2020
56f5458
fix issues caused by refactoring
stooke Mar 5, 2020
a965b47
merge latest from Andrew Dinn ([email protected])
stooke Mar 6, 2020
2117e6a
CodeView debug fixes after latest merge
stooke Mar 6, 2020
587e41a
cleanup, add toString for Range and FileEntry
stooke Mar 10, 2020
a9ff44a
fix line numbers
stooke Mar 10, 2020
c53dd34
fix line numbers - add some usage info, get rid of debug line
stooke Mar 10, 2020
9195a9c
define interfaces used to communicate debug info to object file and p…
adinn Jan 21, 2020
8fddfd3
implement generation of basic DWARF sections in ELF object files
adinn Jan 21, 2020
9e590de
drive native image debug info generation when -H:+TrackNodeSourcePosi…
adinn Jan 21, 2020
5849bf0
script that writes a 'set directories' command into file .gdbsourcepa…
adinn Jan 21, 2020
434d234
instructions for using debug info prototype
adinn Jan 22, 2020
c1ab03a
fix check-style errors
adinn Jan 22, 2020
0e6e8dc
fixed eclipseformat style issues
adinn Jan 22, 2020
bb6a891
fixed eclipseformat style issues
adinn Jan 22, 2020
ec06068
more style whackamole
adinn Jan 22, 2020
44ad637
death to style dragons
adinn Jan 22, 2020
b8ba230
sigh ... still more style issues
adinn Jan 22, 2020
8deb6a1
another style domino topples
adinn Jan 23, 2020
638656e
converted lots of comments to javadcoc, added new ones and edited con…
adinn Jan 23, 2020
ff76233
fix missing javadoc return and remove unused imports
adinn Jan 23, 2020
84060e0
fix punctuation issues and remove redudant declaration
adinn Jan 23, 2020
0d974dc
remove debug trace
adinn Jan 24, 2020
9151adf
fix reloc code to ensure content of elf section depends on content of…
adinn Jan 24, 2020
614c3e9
add correct VADDR dependency so that debug sections can use vaddr of …
adinn Jan 24, 2020
d95c771
fix some bugs turned up by enabling asserts
adinn Jan 28, 2020
624e4ca
remove redudant local declarations
adinn Feb 6, 2020
26ff905
removed redundant list of primary entries since iteration always happ…
adinn Feb 6, 2020
1d129cd
relocate dwarf section implementations to separate files as outer cla…
adinn Feb 6, 2020
46a42db
added option GenertaeDebugInfo=<level> and made it force TrackNodeSou…
adinn Feb 6, 2020
05eb983
deleted another remaining redundant local var
adinn Feb 6, 2020
a13a3f5
fixed style issues and made code aware of target byte order
adinn Feb 7, 2020
a6ca2e2
start using Path expressions for directories and file names
adinn Feb 11, 2020
40d10c0
ensure dir path for module classes include module name at start
adinn Feb 12, 2020
49b603c
fix problem with non-null return for empty package on jdk11
adinn Feb 12, 2020
0a184e1
avoid addition ofmodule prefix to file paths for Graal classes
adinn Feb 12, 2020
0348fa7
lookup source files via classpath or local dir and cache copies in lo…
adinn Feb 24, 2020
9f04d5e
correct use File and Path APIs
adinn Feb 25, 2020
b10ad74
remove redundant imports
adinn Feb 25, 2020
c73f835
modified debug info API to use streams instead of iterators
adinn Feb 25, 2020
09e006b
updated DEBUGINFO readme to match latest version
adinn Feb 26, 2020
9a8b65f
fixed typos and small format/wording errors and rmeoved smeredudant code
adinn Feb 26, 2020
6774391
added -H:DebugInfoSourceSearchPath option, tweaked SourceCacheType en…
adinn Feb 27, 2020
26af82e
update readme to describe DebugInfoSourceSearchPath option
adinn Feb 27, 2020
783d30e
use string,replace() to avoid backslash error in regex on Windows
stooke Feb 27, 2020
8dbf126
obtain classpath from image classloader, clean up source searches, en…
adinn Feb 28, 2020
7309dc6
Move ClassEntry and siblings to package com.oracle.objectfile.debugentry
stooke Mar 3, 2020
4f21b65
fixed problem with wrong path for graalvm sources and allowed for nul…
adinn Mar 6, 2020
e8ade41
remove unused field
adinn Mar 6, 2020
1ae0ff1
code cleanups
adinn Mar 9, 2020
5d0ab6b
comment out currently unused DWARF opcodes
adinn Mar 9, 2020
45e3416
formatting
adinn Mar 9, 2020
0732355
more format changes and fix some small errors in graal cache
adinn Mar 10, 2020
356d5d6
Demonstrate how to implement hierarchical logging
olpaw Mar 11, 2020
3aa6840
support tracing of DWARF debug info modelling and generation to file …
adinn Mar 17, 2020
b8b1ccf
modify suite to ensured ObjectFile can acess class DebugContext on jdk8
adinn Mar 20, 2020
36caf2b
remove dud import pulled in at merge
adinn Mar 20, 2020
c6f6af7
simplify withDebugContext to just use a Runnable
adinn Mar 20, 2020
05e8e89
use dwarf prefix plus section name to label context subscope when gen…
adinn Mar 20, 2020
597acaa
Checkstyle adjustments for copyright header
adinn Mar 20, 2020
536baf5
avoid repeated dot in scope name
adinn Mar 20, 2020
233efff
fix checkstyle issues
adinn Mar 20, 2020
46b2fa7
eclipse style check issues
adinn Mar 20, 2020
e68a81a
fix many travis-ci errors
stooke Mar 23, 2020
7f92cd5
add latest from adinn
stooke Mar 26, 2020
a19d77b
more code cleanups
adinn Mar 26, 2020
0605bd8
merge with adinn
stooke Mar 26, 2020
3ffe099
latest from adinn
stooke Mar 26, 2020
4410852
clean up errors from travis-ci build
stooke Mar 27, 2020
06ef217
Merge remote-tracking branch 'adinngithub/debug_info_prototype' into …
stooke Apr 6, 2020
aee9b5d
Merge branch 'master' of https://github.com/oracle/graal into pr_debu…
stooke Apr 7, 2020
88715e2
delete obsolete file
stooke Apr 7, 2020
1e4d3c8
use adinns debugInfoBase, rfactor constant interfaces to classes
stooke Apr 7, 2020
9bbddfd
more cleanup, slight refactor
stooke Apr 7, 2020
44b8696
slight refactor to use standard debugcontext-based logging
stooke Apr 8, 2020
c7e3471
emit graal intrinsic information
stooke Apr 8, 2020
52171ac
fix for travis-ci build tests
stooke Apr 9, 2020
650bc6f
Merge branch 'master' of https://github.com/oracle/graal into pr_debu…
stooke Apr 9, 2020
ddf9bfe
incorporate eclipse formatting changes
stooke Apr 14, 2020
8f1ffd6
fix syntax error from merge
stooke Apr 14, 2020
c5c82d9
fix syntax error from merge
stooke Apr 14, 2020
7729194
remove unused logging code
stooke Apr 14, 2020
971f396
latest travis fixes
stooke Apr 14, 2020
ea3d68d
latest travice checkstyle fixes
stooke Apr 14, 2020
253587e
Merge https://github.com/oracle/graal into pr_debug_pecoff_prototype
stooke Apr 14, 2020
4406cf4
fix issue while linking with windows debug info on
stooke Apr 16, 2020
1521a75
Merge branch 'master' of https://github.com/oracle/graal into pr_debu…
stooke Apr 16, 2020
acb9292
fix comment alignment
stooke Apr 17, 2020
145f973
correctly assign base pointer flags to SP
stooke Apr 17, 2020
3ed90c8
Merge remote-tracking branch 'oraclegithub/master' into pr_debug_peco…
stooke Apr 17, 2020
489345f
make travis happy again
stooke Apr 17, 2020
84ff0ab
make travis really happy again
stooke Apr 17, 2020
35776ca
Merge branch 'master' of https://github.com/oracle/graal into pr_debu…
stooke Apr 21, 2020
180cfb1
Merge remote-tracking branch 'upstream/master' into pr_debug_pecoff_p…
stooke Apr 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions substratevm/DEBUGINFO_WINDOWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Using the prototype debug info feature on windows.
--------------------------------------

To add debug info to a generated native image add flag
-H:GenerateDebugInfo=<N> to the native image command line (where N is
a positive integer value -- the default value 0 means generate no
debug info). For example,

$ javac Hello.java
$ mx native-image -H:GenerateDebugInfo=1 Hello

The resulting image should contain CodeView4 debug records in a
format Visual Studio understands.

Please read the standard DEBUGINFO file; this file only documents differences.

Because of limitations in the linker, function names are mangled into the equivalent of
_package.class.Function_999_, where '999' is a hash of the function arguments. The exception is the first main() function encountered,
which is mangled to _package.class.main_, with no argument hash.

As an experimental feature, the Windows debug info ignores inlined Graal code.
This is currently a Graal compile-time flag in CVConstants.java: _skipGraalIntrinsics_.

To enable Visual Studio to access the cached sources, right click on the solution
in the "Solution Explorer", and select "Properties", then "Debug Source Files".
in the Debug Source Files plane, add the cache directories to the source directory list.

___Unimplemented functionality___

- Currently stack frames are not properly expressed in the debug info.
The stack frame display may have extraneous information in it, and "Step Out", may work incorrectly.

- Currently there is no type information in the debug info.

- Currently variables and members do not appear in the type information.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ public enum RelocationKind {
* The relocation's symbol provides high fixup bytes.
*/
DIRECT_HI,
/**
* The index of the object file section containing the relocation's symbol supplies the
* fixup bytes. (used in CodeView debug information)
*/
SECTION,
/**
* The address of the object file section containing the relocation's symbol (+addend(
* supplies the fixup bytes. (used in CodeView debug information)
*/
SECREL,
/**
* The relocation's symbol provides low fixup bytes.
*/
Expand Down Expand Up @@ -1092,7 +1102,7 @@ protected boolean elementsCanSharePage(Element s1, Element s2, int offset1, int
/**
* API method provided to allow a native image generator to provide details of types, code and
* heap data inserted into a native image.
*
*
* @param debugInfoProvider an implementation of the provider interface that communicates
* details of the relevant types, code and heap data.
*/
Expand Down Expand Up @@ -1750,7 +1760,7 @@ public final SymbolTable getOrCreateSymbolTable() {
* Allows a task to be executed with a debug context in a named subscope bound to the object
* file and accessible to code executed during the lifetime of the task. Invoked code may obtain
* access to the debug context using method {@link #debugContext}.
*
*
* @param context a context to be bound to the object file for the duration of the task
* execution.
* @param scopeName a name to be used to define a subscope current while the task is being
Expand All @@ -1772,7 +1782,7 @@ public void withDebugContext(DebugContext context, String scopeName, Runnable ta
/**
* Allows a consumer to retrieve the debug context currently bound to this object file. This
* method must only called underneath an invocation of method {@link #withDebugContext}.
*
*
* @param scopeName a name to be used to define a subscope current while the consumer is active.
* @param action an action parameterised by the debug context.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@ public String getFormatDependentName(Format f) {
public static final SectionName APPLE_NAMESPACE = new ProgbitsSectionName("apple_namespac");
public static final SectionName APPLE_OBJC = new ProgbitsSectionName("apple_objc");
public static final SectionName LLVM_STACKMAPS = new ProgbitsSectionName("llvm_stackmaps");
// Windows PECOFF CodeView 4 debug sections
public static final SectionName CV4_DEBUG_SYMBOLS = new ProgbitsSectionName("debug$S");
public static final SectionName CV4_DEBUG_TYPES = new ProgbitsSectionName("debug$T");

private static final SectionName[] myValues;

static {
myValues = new SectionName[]{DATA, RODATA, TEXT, BSS, APPLE_NAMES, APPLE_TYPES, APPLE_NAMESPACE, APPLE_OBJC, LLVM_STACKMAPS};
myValues = new SectionName[]{DATA, RODATA, TEXT, BSS, APPLE_NAMES, APPLE_TYPES, APPLE_NAMESPACE, APPLE_OBJC, LLVM_STACKMAPS, CV4_DEBUG_SYMBOLS, CV4_DEBUG_TYPES};
}

private static String getFormatPrefix(ObjectFile.Format f) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,14 @@ public String getFullName() {
public DirEntry getDirEntry() {
return dirEntry;
}

@Override
public String toString() {
if (getDirEntry() == null) {
return getFileName() == null ? "-" : getFileName();
} else if (getFileName() == null) {
return "--";
}
return String.format("FileEntry(%s)", getFullName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
*/

public class Range {

/* Use '.' for PECOFF files */
private static final String CLASS_DELIMITER = System.getProperty("os.name").toLowerCase().contains("windows") ? "." : "::";

private String fileName;
private Path filePath;
private String className;
Expand Down Expand Up @@ -79,6 +83,25 @@ public Range(String fileName, Path filePath, String className, String methodName
this.primary = primary;
}

/*
* Create a slightly different copy of a previously constructed range. Because the previous
* range was constructed by one of the other constructors, a valid assumption is that all the
* strings have previously been inserted int he stringTable, and we can avoid doing that again.
*/
public Range(Range other, int lo, int hi) {
this.fileName = other.fileName;
this.filePath = other.filePath;
this.className = other.className;
this.methodName = other.methodName;
this.paramNames = other.paramNames;
this.returnTypeName = other.returnTypeName;
this.fullMethodName = other.fullMethodName;
this.lo = lo;
this.hi = hi;
this.line = other.line;
this.primary = other.primary;
}

public boolean contains(Range other) {
return (lo <= other.lo && hi >= other.hi);
}
Expand Down Expand Up @@ -133,6 +156,19 @@ public String getFullMethodName() {
return fullMethodName;
}

public String getParamNames() {
return paramNames;
}

public String getClassAndMethodName() {
StringBuilder builder = new StringBuilder();
if (className != null) {
builder.append(className).append(CLASS_DELIMITER);
}
builder.append(methodName);
return builder.toString();
}

private String getExtendedMethodName(boolean includeParams, boolean includeReturnType) {
StringBuilder builder = new StringBuilder();
if (includeReturnType && returnTypeName.length() > 0) {
Expand All @@ -141,7 +177,7 @@ private String getExtendedMethodName(boolean includeParams, boolean includeRetur
}
if (className != null) {
builder.append(className);
builder.append("::");
builder.append(CLASS_DELIMITER);
}
builder.append(methodName);
if (includeParams && !paramNames.isEmpty()) {
Expand All @@ -155,4 +191,9 @@ private String getExtendedMethodName(boolean includeParams, boolean includeRetur
private String constructClassAndMethodNameWithParams() {
return getExtendedMethodName(true, false);
}

@Override
public String toString() {
return String.format("Range(lo=0x%05x hi=0x%05x %s %s:%d)", lo, hi, constructClassAndMethodNameWithParams(), getFileAsPath(), line);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public StringTable() {
* Ensures a unique instance of a string exists in the table, inserting the supplied String if
* no equivalent String is already present. This should only be called before the string section
* has been written.
*
*
* @param string the string to be included in the table
* @return the unique instance of the String
*/
Expand All @@ -58,7 +58,7 @@ public String uniqueString(String string) {
* Ensures a unique instance of a string exists in the table and is marked for inclusion in the
* debug_str section, inserting the supplied String if no equivalent String is already present.
* This should only be called before the string section has been written.
*
*
* @param string the string to be included in the table and marked for inclusion in the
* debug_str section
* @return the unique instance of the String
Expand All @@ -82,7 +82,7 @@ private String ensureString(String string, boolean addToStrSection) {
/**
* Retrieves the offset at which a given string was written into the debug_str section. This
* should only be called after the string section has been written.
*
*
* @param string the strng whose offset is to be retrieved
* @return the offset or -1 if the string does not define an entry or the entry has not been
* written to the debug_str section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ enum IMAGE_SECTION_HEADER {

static final int IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000;

static final int IMAGE_SCN_MEM_DISCARDABLE = 0x02000000;
static final int IMAGE_SCN_MEM_SHARED = 0x10000000;
static final int IMAGE_SCN_MEM_EXECUTE = 0x20000000;
static final int IMAGE_SCN_MEM_READ = 0x40000000;
Expand Down Expand Up @@ -202,7 +203,8 @@ enum IMAGE_RELOCATION {
static final int IMAGE_REL_AMD64_REL32_3 = 0x7;
static final int IMAGE_REL_AMD64_REL32_4 = 0x8;
static final int IMAGE_REL_AMD64_REL32_5 = 0x9;

static final int IMAGE_REL_AMD64_SECTION = 0xa;
static final int IMAGE_REL_AMD64_SECREL = 0xb;
}
//@formatter:on
// Checkstyle: resume
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public static PECoffRelocationMethod getRelocation(PECoffMachine m, RelocationKi
switch (k) {
case DIRECT:
switch (sizeInBytes) {
case 4:
return PECoffX86_64Relocation.ADDR32;
case 8:
return PECoffX86_64Relocation.ADDR64;
default:
Expand All @@ -68,6 +70,20 @@ public static PECoffRelocationMethod getRelocation(PECoffMachine m, RelocationKi
default:
throw new IllegalArgumentException("unsupported relocation type: " + k + " size: " + sizeInBytes);
}
case SECTION:
switch (sizeInBytes) {
case 2:
return PECoffX86_64Relocation.SECTION;
default:
throw new IllegalArgumentException("unsupported relocation type: " + k + " size: " + sizeInBytes);
}
case SECREL:
switch (sizeInBytes) {
case 4:
return PECoffX86_64Relocation.SECREL;
default:
throw new IllegalArgumentException("unsupported relocation type: " + k + " size: " + sizeInBytes);
}
default:
case UNKNOWN:
throw new IllegalArgumentException("cannot map unknown relocation kind to an PECoff x86-64 relocation type");
Expand Down Expand Up @@ -176,6 +192,54 @@ public long toLong() {
return IMAGE_RELOCATION.IMAGE_REL_AMD64_ADDR64;
}
},
ADDR32 {
@Override
public RelocationKind getKind() {
return RelocationKind.DIRECT;
}

@Override
public int getRelocatedByteSize() {
return 4;
}

@Override
public long toLong() {
return IMAGE_RELOCATION.IMAGE_REL_AMD64_ADDR32;
}
},
SECREL {
@Override
public RelocationKind getKind() {
return RelocationKind.DIRECT;
}

@Override
public int getRelocatedByteSize() {
return 4;
}

@Override
public long toLong() {
return IMAGE_RELOCATION.IMAGE_REL_AMD64_SECREL;
}
},
SECTION {
@Override
public RelocationKind getKind() {
return RelocationKind.DIRECT;
}

@Override
public int getRelocatedByteSize() {
return 2;
}

@Override
public long toLong() {
return IMAGE_RELOCATION.IMAGE_REL_AMD64_SECTION;
}
},
REL32 {
@Override
public RelocationKind getKind() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@
import com.oracle.objectfile.LayoutDecisionMap;
import com.oracle.objectfile.ObjectFile;
import com.oracle.objectfile.SymbolTable;
import com.oracle.objectfile.debuginfo.DebugInfoProvider;
import com.oracle.objectfile.io.AssemblyBuffer;
import com.oracle.objectfile.io.OutputAssembler;
import com.oracle.objectfile.pecoff.PECoff.IMAGE_FILE_HEADER;
import com.oracle.objectfile.pecoff.PECoff.IMAGE_SECTION_HEADER;
import com.oracle.objectfile.pecoff.cv.CVDebugInfo;
import com.oracle.objectfile.pecoff.cv.CVSymbolSectionImpl;
import com.oracle.objectfile.pecoff.cv.CVTypeSectionImpl;

/**
* Represents a PECoff object file.
Expand Down Expand Up @@ -379,6 +383,7 @@ public enum PECoffSectionFlag implements ValueEnum {
READ(IMAGE_SECTION_HEADER.IMAGE_SCN_MEM_READ),
WRITE(IMAGE_SECTION_HEADER.IMAGE_SCN_MEM_WRITE),
EXECUTE(IMAGE_SECTION_HEADER.IMAGE_SCN_MEM_EXECUTE),
DISCARDABLE(IMAGE_SECTION_HEADER.IMAGE_SCN_MEM_DISCARDABLE),
LINKER(IMAGE_SECTION_HEADER.IMAGE_SCN_LNK_INFO | IMAGE_SECTION_HEADER.IMAGE_SCN_LNK_REMOVE);

private final int value;
Expand Down Expand Up @@ -683,4 +688,42 @@ public PECoffRelocationTable getRelocationTable() {
protected int getMinimumFileSize() {
return 0;
}

@Override
public Section newDebugSection(String name, ElementImpl impl) {
PECoffSection coffSection = (PECoffSection) super.newDebugSection(name, impl);
coffSection.getFlags().add(PECoffSectionFlag.DISCARDABLE);
coffSection.getFlags().add(PECoffSectionFlag.READ);
coffSection.getFlags().add(PECoffSectionFlag.INITIALIZED_DATA);
impl.setElement(coffSection);
return coffSection;
}

@Override
public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
CVDebugInfo cvDebugInfo = new CVDebugInfo(getMachine(), getByteOrder());

// we need an implementation for each section
CVSymbolSectionImpl cvSymbolSectionImpl = cvDebugInfo.getCVSymbolSection();
CVTypeSectionImpl cvTypeSectionImpl = cvDebugInfo.getCVTypeSection();

// now we can create the section elements with empty content
newDebugSection(cvSymbolSectionImpl.getSectionName(), cvSymbolSectionImpl);
newDebugSection(cvTypeSectionImpl.getSectionName(), cvTypeSectionImpl);

// the byte[] for each implementation's content are created and
// written under getOrDecideContent. doing that ensures that all
// dependent sections are filled in and then sized according to the
// declared dependencies. however, if we leave it at that then
// associated reloc sections only get created when the first reloc
// is inserted during content write that's too late for them to have
// layout constraints included in the layout decision set and causes
// an NPE during reloc section write. so we need to create the relevant
// reloc sections here in advance
cvSymbolSectionImpl.getOrCreateRelocationElement(false);
cvTypeSectionImpl.getOrCreateRelocationElement(false);

// ok now we can populate the implementations
cvDebugInfo.installDebugInfo(debugInfoProvider);
}
}
Loading