diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2014-05-13 14:26:26 +0400 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2014-05-13 14:26:26 +0400 |
commit | 2915feb81e5178700d070324a9888e8fcf70a7d6 (patch) | |
tree | 89edc13be3741030d9c3c8855c94e4cddd280261 /winsup/utils/minidumper.cc | |
parent | 8f8e7757cffb236383d043d9ef2a5d2b7087feb5 (diff) |
* minidumper.cc (filter_minidump_type): New function.
(minidump): Change default dump type from MiniDumpNormal to
something with more useful information without getting too
big. Use filter_minidump_type() to filter out unsupported dump
types.
Diffstat (limited to 'winsup/utils/minidumper.cc')
-rw-r--r-- | winsup/utils/minidumper.cc | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/winsup/utils/minidumper.cc b/winsup/utils/minidumper.cc index ea1e193c2..04685665e 100644 --- a/winsup/utils/minidumper.cc +++ b/winsup/utils/minidumper.cc @@ -28,9 +28,57 @@ #include <windows.h> #include <dbghelp.h> +DEFINE_ENUM_FLAG_OPERATORS(MINIDUMP_TYPE); + BOOL verbose = FALSE; BOOL nokill = FALSE; +/* Not yet in dbghelp.h */ +#define MiniDumpWithModuleHeaders (static_cast<MINIDUMP_TYPE>(0x00080000)) +#define MiniDumpFilterTriage (static_cast<MINIDUMP_TYPE>(0x00100000)) + +static MINIDUMP_TYPE +filter_minidump_type(MINIDUMP_TYPE dump_type) +{ + API_VERSION build_version = { 6, 0, API_VERSION_NUMBER, 0 }; + API_VERSION *v = ImagehlpApiVersionEx(&build_version); + + if (verbose) + printf ("dbghelp version %d.%d.%d.%d\n", v->MajorVersion, + v->MinorVersion, v->Revision, v->Reserved); + + MINIDUMP_TYPE supported_types = MiniDumpNormal | MiniDumpWithDataSegs + | MiniDumpWithFullMemory | MiniDumpWithHandleData | MiniDumpFilterMemory + | MiniDumpScanMemory; + + /* + This mainly trial and error and guesswork, as the MSDN documentation only + says what version of "Debugging Tools for Windows" added these flags, but + doesn't actually tell us the dbghelp.dll version which was contained in that + (and seems to have errors as well) + */ + + if (v->MajorVersion >= 5) + supported_types |= MiniDumpWithUnloadedModules + | MiniDumpWithIndirectlyReferencedMemory | MiniDumpFilterModulePaths + | MiniDumpWithProcessThreadData | MiniDumpWithPrivateReadWriteMemory; + + if (v->MajorVersion >= 6) + supported_types |= MiniDumpWithoutOptionalData | MiniDumpWithFullMemoryInfo + | MiniDumpWithThreadInfo | MiniDumpWithCodeSegs + | MiniDumpWithoutAuxiliaryState | MiniDumpWithFullAuxiliaryState // seems to be documentation error that these two aren't listed as 'Not supported prior to 6.1' + | MiniDumpWithPrivateWriteCopyMemory | MiniDumpIgnoreInaccessibleMemory + | MiniDumpWithTokenInformation; + + if ((v->MajorVersion*10 + v->MinorVersion) >= 62) + supported_types |= MiniDumpWithModuleHeaders | MiniDumpFilterTriage; // seems to be documentation error that these two are listed as 'Not supported prior to 6.1' + + if (verbose) + printf ("supported MINIDUMP_TYPE flags 0x%x\n", supported_types); + + return (dump_type & supported_types); +} + static void minidump(DWORD pid, MINIDUMP_TYPE dump_type, const char *minidump_file) { @@ -137,6 +185,7 @@ main (int argc, char **argv) int opt; const char *p = ""; DWORD pid; + BOOL default_dump_type = TRUE; MINIDUMP_TYPE dump_type = MiniDumpNormal; while ((opt = getopt_long (argc, argv, opts, longopts, NULL) ) != EOF) @@ -145,6 +194,7 @@ main (int argc, char **argv) case 't': { char *endptr; + default_dump_type = FALSE; dump_type = (MINIDUMP_TYPE)strtoul(optarg, &endptr, 0); if (*endptr != '\0') { @@ -201,6 +251,21 @@ main (int argc, char **argv) } sprintf (minidump_file, "%s.dmp", p); + if (default_dump_type) + { + dump_type = MiniDumpWithHandleData | MiniDumpWithFullMemoryInfo + | MiniDumpWithThreadInfo | MiniDumpWithFullAuxiliaryState + | MiniDumpIgnoreInaccessibleMemory | MiniDumpWithTokenInformation + | MiniDumpWithIndirectlyReferencedMemory; + + /* + Only filter out unsupported dump_type flags if we are using the default + dump type, so that future dump_type flags can be explicitly used even if + we don't know about them + */ + dump_type = filter_minidump_type(dump_type); + } + if (verbose) printf ("dumping process %u to %s using dump type flags 0x%x\n", (unsigned int)pid, minidump_file, (unsigned int)dump_type); |