summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorNeeraj Singh <neerajsi@microsoft.com>2021-11-29 20:44:16 (GMT)
committerNeeraj Singh <neerajsi@microsoft.com>2021-12-02 05:49:07 (GMT)
commit28d3fad41817310b8fc2fd6d9e46137249d65fad (patch)
treea6180d64820de4a9eea1f9b69a0c3ab3630814ea /src/main.cpp
parent9e0795af0123ea890c43805d956ada5eae8b30d8 (diff)
downloadcv2pdb-28d3fad41817310b8fc2fd6d9e46137249d65fad.zip
cv2pdb-28d3fad41817310b8fc2fd6d9e46137249d65fad.tar.gz
cv2pdb-28d3fad41817310b8fc2fd6d9e46137249d65fad.tar.bz2
Refactor PE image section handling. Add debug logging.
Encapsulate dwarf-related PE sections into the PESection class. Remove some unused sections. Add helpers for common section operations. Move the context set via DIECursor::setContext to be static members of the class and add a debug context there. Add a standard method of enabling debug logging across the dwarf and PDB code.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index ced7aac..91b300a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -21,6 +21,8 @@ double
#define T_strcpy wcscpy
#define T_strcat wcscat
#define T_strstr wcsstr
+#define T_strncmp wcsncmp
+#define T_strtoul wcstoul
#define T_strtod wcstod
#define T_strrchr wcsrchr
#define T_unlink _wremove
@@ -34,6 +36,8 @@ double
#define T_strcpy strcpy
#define T_strcat strcat
#define T_strstr strstr
+#define T_strncmp strncmp
+#define T_strtoul strtoul
#define T_strtod strtod
#define T_strrchr strrchr
#define T_unlink unlink
@@ -120,7 +124,7 @@ int T_main(int argc, TCHAR* argv[])
{
double Dversion = 2.072;
const TCHAR* pdbref = 0;
- bool debug = false;
+ DebugLevel debug = DebugLevel{};
CoInitialize(nullptr);
@@ -138,8 +142,15 @@ int T_main(int argc, TCHAR* argv[])
demangleSymbols = false;
else if (argv[0][1] == 'e')
useTypedefEnum = true;
- else if (argv[0][1] == 'd' && argv[0][2] == 'e' && argv[0][3] == 'b') // deb[ug]
- debug = true;
+ else if (!T_strncmp(&argv[0][1], TEXT("debug"), 5)) // debug[level]
+ {
+ debug = (DebugLevel)T_strtoul(&argv[0][6], 0, 0);
+ if (!debug) {
+ debug = DbgBasic;
+ }
+
+ fprintf(stderr, "Debug set to %x\n", debug);
+ }
else if (argv[0][1] == 's' && argv[0][2])
dotReplacementChar = (char)argv[0][2];
else if (argv[0][1] == 'p' && argv[0][2])
@@ -182,9 +193,8 @@ int T_main(int argc, TCHAR* argv[])
img = &dbg;
}
- CV2PDB cv2pdb(*img);
+ CV2PDB cv2pdb(*img, debug);
cv2pdb.Dversion = Dversion;
- cv2pdb.debug = debug;
cv2pdb.initLibraries();
TCHAR* outname = argv[1];