mirror of https://github.com/buggins/dlangide.git
debugger support, continue
This commit is contained in:
parent
baa1656de3
commit
6dd80be82d
|
@ -64,7 +64,7 @@
|
||||||
<doXGeneration>1</doXGeneration>
|
<doXGeneration>1</doXGeneration>
|
||||||
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
|
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids>DebugInfo</debugids>
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>Unicode USE_FREETYPE</versionids>
|
<versionids>Unicode USE_FREETYPE</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
module ddebug.windows.debuginfo;
|
module ddebug.windows.debuginfo;
|
||||||
|
|
||||||
|
version(Windows):
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.algorithm;
|
import std.algorithm;
|
||||||
|
@ -49,13 +50,47 @@ struct Buffer {
|
||||||
ubyte[] sectionAt(uint pos) {
|
ubyte[] sectionAt(uint pos) {
|
||||||
uint rva = uintAt(pos);
|
uint rva = uintAt(pos);
|
||||||
uint sz = uintAt(pos + 4);
|
uint sz = uintAt(pos + 4);
|
||||||
|
Log.d("section rva=", rva, " sz=", sz);
|
||||||
|
if (!sz)
|
||||||
|
return null;
|
||||||
enforce(pos + sz <= buf.length, new FileFormatException("sectionAt: index is outside file range"));
|
enforce(pos + sz <= buf.length, new FileFormatException("sectionAt: index is outside file range"));
|
||||||
return buf[rva .. rva + sz];
|
return buf[rva .. rva + sz];
|
||||||
}
|
}
|
||||||
|
string stringzAt(uint pos, uint maxSize) {
|
||||||
|
char[] res;
|
||||||
|
for (uint p = pos; maxSize == 0 || p < pos + maxSize; p++) {
|
||||||
|
ubyte ch = ubyteAt(p);
|
||||||
|
if (!ch)
|
||||||
|
break;
|
||||||
|
res ~= ch;
|
||||||
|
}
|
||||||
|
return cast(string)res;
|
||||||
|
}
|
||||||
|
ubyte[] rangeAt(uint pos, uint size) {
|
||||||
|
Log.d("rangeAt: pos=", pos, " size=", size, " pos+size=", pos+size, " buf.len=", buf.length);
|
||||||
|
uint endp = pos + size;
|
||||||
|
//if (endp > buf.length)
|
||||||
|
// endp = cast(uint)buf.length;
|
||||||
|
enforce(pos <= endp, new FileFormatException("rangeAt: index is outside file range"));
|
||||||
|
return buf[pos .. endp];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Section {
|
struct Section {
|
||||||
|
string name;
|
||||||
|
uint vsize;
|
||||||
|
uint rva;
|
||||||
|
uint sz;
|
||||||
|
uint offset;
|
||||||
|
uint flags;
|
||||||
|
this(ref Buffer buf, uint pos) {
|
||||||
|
name = buf.stringzAt(pos, 8);
|
||||||
|
vsize = buf.uintAt(pos + 0x08);
|
||||||
|
rva = buf.uintAt(pos + 0x0C);
|
||||||
|
sz = buf.uintAt(pos + 0x10);
|
||||||
|
offset = buf.uintAt(pos + 0x14);
|
||||||
|
flags = buf.uintAt(pos + 0x28);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class OMFDebugInfo {
|
class OMFDebugInfo {
|
||||||
|
@ -66,11 +101,40 @@ class OMFDebugInfo {
|
||||||
data.buf = cast(ubyte[])std.file.read(filename);
|
data.buf = cast(ubyte[])std.file.read(filename);
|
||||||
data.check(0, ['M', 'Z']);
|
data.check(0, ['M', 'Z']);
|
||||||
peoffset = data.uintAt(0x3c);
|
peoffset = data.uintAt(0x3c);
|
||||||
data.skip(peoffset);
|
Buffer pe;
|
||||||
data.check(0, ['P', 'E', 0, 0]);
|
pe.buf = data.buf[peoffset .. $];
|
||||||
ushort objectCount = data.ushortAt(0x06);
|
//data.skip(peoffset);
|
||||||
ushort flags = data.ushortAt(0x16);
|
pe.check(0, ['P', 'E', 0, 0]);
|
||||||
ushort subsystem = data.ushortAt(0x5c);
|
ushort objectCount = pe.ushortAt(0x06);
|
||||||
|
ushort flags = pe.ushortAt(0x16);
|
||||||
|
ushort subsystem = pe.ushortAt(0x5c);
|
||||||
|
uint coffRva = pe.uintAt(0x0c);
|
||||||
|
uint coffSize = pe.uintAt(0x10);
|
||||||
|
Log.d("subsystem: ", subsystem, " flags: ", flags, " coffRva:", coffRva, " coffSize:", coffSize);
|
||||||
|
//ubyte[] debugInfo = data.sectionAt(peoffset + 0xA8);
|
||||||
|
//ubyte[] exportInfo = data.sectionAt(peoffset + 0x78);
|
||||||
|
//ubyte[] importInfo = data.sectionAt(peoffset + 0x7c);
|
||||||
|
//ubyte[] resInfo = data.sectionAt(peoffset + 0x88);
|
||||||
|
//Buffer debugHeader;
|
||||||
|
//debugHeader.buf = debugInfo;
|
||||||
|
//uint debugType = debugHeader.uintAt(0x0C);
|
||||||
|
//uint debugSize = debugHeader.uintAt(0x10);
|
||||||
|
//uint debugRva = debugHeader.uintAt(0x14);
|
||||||
|
//uint debugSeek = debugHeader.uintAt(0x18);
|
||||||
|
//Log.d("debugInfo[", debugInfo.length, "] type=", debugType, " debugSize=", debugSize, " rva=", debugRva, " seek=", debugSeek, " seek-rva=");
|
||||||
|
//ubyte[] debugRaw = data.rangeAt(debugSeek, debugSize);
|
||||||
|
//Log.d("debugRaw: ", debugRaw);
|
||||||
|
ubyte[] debugData;
|
||||||
|
for (int i = 0; i < objectCount; i++) {
|
||||||
|
Section section = Section(data, peoffset + 0xF8 + i * 0x28);
|
||||||
|
Log.d("section ", section.name, " rva=", section.rva, " sz=", section.sz, " offset=", section.offset);
|
||||||
|
if (section.name.equal(".debug"))
|
||||||
|
debugData = data.rangeAt(section.offset, section.sz);
|
||||||
|
}
|
||||||
|
if (debugData) {
|
||||||
|
string debugName = cast(string)debugData[1.. debugData[0] + 1];
|
||||||
|
Log.d("Found debug data: name=", debugName, " sz=", debugData.length);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new FileFormatException(e);
|
throw new FileFormatException(e);
|
||||||
|
|
|
@ -43,10 +43,12 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
//import ddc.lexer.tokenizer;
|
//import ddc.lexer.tokenizer;
|
||||||
//runTokenizerTest();
|
//runTokenizerTest();
|
||||||
debug(DebugInfo) {
|
debug(DebugInfo) {
|
||||||
|
version(Windows) {
|
||||||
import ddebug.windows.debuginfo;
|
import ddebug.windows.debuginfo;
|
||||||
import std.file;
|
import std.file;
|
||||||
debugInfoTest(thisExePath);
|
debugInfoTest(thisExePath);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create window
|
// create window
|
||||||
Window window = Platform.instance.createWindow("Dlang IDE", null, WindowFlag.Resizable, 900, 700);
|
Window window = Platform.instance.createWindow("Dlang IDE", null, WindowFlag.Resizable, 900, 700);
|
||||||
|
|
Loading…
Reference in New Issue