diff options
Diffstat (limited to 'src/plugins/CCpp.cpp')
| -rw-r--r-- | src/plugins/CCpp.cpp | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/src/plugins/CCpp.cpp b/src/plugins/CCpp.cpp index d88a593d..df2c4482 100644 --- a/src/plugins/CCpp.cpp +++ b/src/plugins/CCpp.cpp @@ -26,16 +26,28 @@ using namespace std; #define CORE_PATTERN_IFACE "/proc/sys/kernel/core_pattern" -#define CORE_PATTERN "|"CCPP_HOOK_PATH" "DEBUG_DUMPS_DIR" %p %s %u %c" +/* + * %s - signal number + * %c - ulimit -c value + * %p - pid + * %u - uid + * %g - gid + * %t - UNIX time of dump + * %h - hostname + * %e - executable filename + * %% - output one "%" + */ +#define CORE_PATTERN "|"CCPP_HOOK_PATH" "DEBUG_DUMPS_DIR" %s %c %p %u %g %t %h %e" + #define CORE_PIPE_LIMIT_IFACE "/proc/sys/kernel/core_pipe_limit" /* core_pipe_limit specifies how many dump_helpers might run at the same time * 0 - means unlimited, but it's not guaranteed that /proc/<pid> of crashing - * process will be available for dump_helper + * process will be available for dump_helper. * 4 - means that 4 dump_helpers can run at the same time (the rest will also - * run, but they will fail to read /proc/<pid>) - * This should be enough for ABRT, we can miss some crashes, but what are - * the odds that more processes crash at the same time? - * The value of 4 has been recommended by nhorman. + * run, but they will fail to read /proc/<pid>). + * This should be enough for ABRT, we can miss some crashes, but what are + * the odds that more processes crash at the same time? + * The value of 4 has been recommended by nhorman. */ #define CORE_PIPE_LIMIT "4" @@ -133,7 +145,7 @@ void CAnalyzerCCpp::Init() } if (m_sOldCorePattern[0] == '|') { - if (m_sOldCorePattern == CORE_PATTERN) + if (strncmp(m_sOldCorePattern.c_str(), CORE_PATTERN, strlen(CORE_PATTERN)) == 0) { log("warning: %s already contains %s, " "did abrt daemon crash recently?", @@ -157,14 +169,35 @@ void CAnalyzerCCpp::Init() fp = fopen(CORE_PATTERN_IFACE, "w"); if (fp) { - fputs(CORE_PATTERN, fp); + if (m_sOldCorePattern[0] != '|') + { + const char *old = m_sOldCorePattern.c_str(); + unsigned len = strchrnul(old, '\n') - old; + char *hex_old = (char*)xmalloc(len * 2 + 1); + bin2hex(hex_old, old, len)[0] = '\0'; + /* Trailing 00 is a sentinel. Decoder in the hook will check it. + * If it won't see it, then kernel has truncated the argument: + */ + char *pattern = xasprintf("%s %s00", CORE_PATTERN, hex_old); + //log("old:'%s'->'%s'", old, hex_old); + //log("pattern:'%s'", pattern); + + fputs(pattern, fp); + + free(pattern); + free(hex_old); + } + else + { + fputs(CORE_PATTERN, fp); + } fclose(fp); } /* read the core_pipe_limit and change it if it's == 0 - otherwise the abrt-hook-ccpp won't be able to read /proc/<pid> - of the crashing process - */ + * otherwise the abrt-hook-ccpp won't be able to read /proc/<pid> + * of the crashing process + */ fp = fopen(CORE_PIPE_LIMIT_IFACE, "r"); if (fp) { |
