summaryrefslogtreecommitdiffstats
path: root/src/dviewhelper/dviewhelper.cpp
diff options
context:
space:
mode:
authorsagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8>2012-02-12 16:05:27 (GMT)
committersagitario <sagitario@fc51e93f-b9fe-4711-8d8d-3ae870c5f7d8>2012-02-12 16:05:27 (GMT)
commit96e6e9fa7388b010f55cf8d122ef03a2a8ab87e4 (patch)
tree43bfb85629d0fa32de2d88d04997642a0828c128 /src/dviewhelper/dviewhelper.cpp
parent805aac230223f45acc7db218eb64589a4adb390e (diff)
downloadcv2pdb-96e6e9fa7388b010f55cf8d122ef03a2a8ab87e4.zip
cv2pdb-96e6e9fa7388b010f55cf8d122ef03a2a8ab87e4.tar.gz
cv2pdb-96e6e9fa7388b010f55cf8d122ef03a2a8ab87e4.tar.bz2
* disabled named enumerator for D basic types to avoid debugger troubles displaying arrays
* added command line switch -e to enable using named enumerator for D basic types * added DWARF support * added x64 support
Diffstat (limited to 'src/dviewhelper/dviewhelper.cpp')
-rw-r--r--src/dviewhelper/dviewhelper.cpp53
1 files changed, 44 insertions, 9 deletions
diff --git a/src/dviewhelper/dviewhelper.cpp b/src/dviewhelper/dviewhelper.cpp
index 3cee363..c9d16af 100644
--- a/src/dviewhelper/dviewhelper.cpp
+++ b/src/dviewhelper/dviewhelper.cpp
@@ -25,13 +25,28 @@ extern "C" {
struct DEBUGHELPER
{
DWORD dwVersion;
- BOOL (WINAPI *ReadDebuggeeMemory)(DEBUGHELPER *pThis, DWORD dwAddr, DWORD nWant, VOID* pWhere, DWORD *nGot);
+ HRESULT (WINAPI *ReadDebuggeeMemory)(DEBUGHELPER *pThis, DWORD dwAddr, DWORD nWant, VOID* pWhere, DWORD *nGot);
// from here only when dwVersion >= 0x20000
DWORDLONG (WINAPI *GetRealAddress)(DEBUGHELPER *pThis);
- BOOL (WINAPI *ReadDebuggeeMemoryEx)(DEBUGHELPER *pThis, DWORDLONG qwAddr, DWORD nWant, VOID* pWhere, DWORD *nGot);
+ HRESULT (WINAPI *ReadDebuggeeMemoryEx)(DEBUGHELPER *pThis, DWORDLONG qwAddr, DWORD nWant, VOID* pWhere, DWORD *nGot);
int (WINAPI *GetProcessorType)(DEBUGHELPER *pThis);
};
+// possible processor types
+typedef enum _MPT {
+ mptix86 = 0, // Intel X86
+ mptia64 = 1, // Intel Merced
+ mptamd64 = 2, // AMD64
+ mptUnknown = 3 // Unknown
+} MPT;
+
+HRESULT readMem(DEBUGHELPER *pHelper, DWORDLONG qwAddr, DWORD nWant, VOID* pWhere, DWORD *nGot)
+{
+ if(pHelper->dwVersion < 0x20000)
+ return pHelper->ReadDebuggeeMemory(pHelper, (DWORD)qwAddr, nWant, pWhere, nGot);
+ return pHelper->ReadDebuggeeMemoryEx(pHelper, qwAddr, nWant, pWhere, nGot);
+}
+
struct DString
{
DWORD length;
@@ -43,26 +58,46 @@ struct DString
HRESULT WINAPI StringView(DWORD dwAddress, DEBUGHELPER *pHelper, int nBase, BOOL bUniStrings,
char *pResult, size_t max, DWORD sizePerChar)
{
+ DWORDLONG qwAddress = dwAddress;
+ if(pHelper->dwVersion >= 0x20000)
+ qwAddress = pHelper->GetRealAddress(pHelper);
+
+ int proc = 0;
+ if(pHelper->dwVersion >= 0x20000)
+ proc = pHelper->GetProcessorType(pHelper);
+ int sizeOfPtr = proc == 0 ? 4 : 8;
+
// Get the string struct
- DString dstr;
+ char strdata[16];
DWORD read;
- if (pHelper->ReadDebuggeeMemory(pHelper, dwAddress, sizeof(dstr), &dstr, &read) != S_OK)
+ if (readMem(pHelper, qwAddress, 2*sizeOfPtr, strdata, &read) != S_OK)
{
- strncpy(pResult,"Cannot access struct", max);
- return S_OK;
+ strncpy(pResult,"Cannot access struct", max);
+ return S_OK;
}
- if (dstr.length == 0)
+ DWORDLONG length, data;
+ if(sizeOfPtr > 4)
+ {
+ length = *(DWORDLONG*) strdata;
+ data = *(DWORDLONG*) (strdata + sizeOfPtr);
+ }
+ else
+ {
+ length = *(DWORD*) strdata;
+ data = *(DWORD*) (strdata + sizeOfPtr);
+ }
+ if (length == 0)
{
strncpy(pResult,"\"\"", max);
return S_OK;
}
char* pData = pResult + 1;
- DWORD cnt = (dstr.length < max - 3 ? dstr.length : max - 3);
+ DWORD cnt = (length < max - 3 ? (DWORD)length : max - 3);
if (sizePerChar * cnt > max)
pData = new char[sizePerChar * cnt];
- if (pHelper->ReadDebuggeeMemory(pHelper, dstr.data, sizePerChar * cnt, pData, &read) != S_OK)
+ if (readMem(pHelper, data, sizePerChar * cnt, pData, &read) != S_OK)
{
strncpy(pResult,"Cannot access data", max);
}