summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-18 19:01:03 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-18 19:01:03 +0100
commita8c6f96eed97ac484343ecf731d4e0859049a2c4 (patch)
treeada0c02dfbcb4239e7823d7480f0fe6722a8538a
parent8bb4a3e25654fdfef7b9a378a0177ed26114e83a (diff)
downloadabrt-a8c6f96eed97ac484343ecf731d4e0859049a2c4.tar.gz
abrt-a8c6f96eed97ac484343ecf731d4e0859049a2c4.tar.xz
abrt-a8c6f96eed97ac484343ecf731d4e0859049a2c4.zip
ccpp: deal with const string& params; fix a bug in GetIndependentBuildIdPC
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--lib/Plugins/CCpp.cpp56
1 files changed, 26 insertions, 30 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index 73334958..83b0e9a3 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -50,7 +50,7 @@ CAnalyzerCCpp::CAnalyzerCCpp() :
m_nDebugInfoCacheMB(4000)
{}
-static string CreateHash(const string& pInput)
+static string CreateHash(const char *pInput)
{
string ret;
HASHContext* hc;
@@ -63,7 +63,7 @@ static string CreateHash(const string& pInput)
error_msg_and_die("HASH_Create(HASH_AlgSHA1) failed"); /* paranoia */
}
HASH_Begin(hc);
- HASH_Update(hc, reinterpret_cast<const unsigned char*>(pInput.c_str()), pInput.length());
+ HASH_Update(hc, (const unsigned char*)pInput, strlen(pInput));
HASH_End(hc, hash, &len, sizeof(hash));
HASH_Destroy(hc);
@@ -312,7 +312,7 @@ static void GetBacktrace(const char *pDebugDumpDir, const char *pDebugInfoDirs,
ExecVP(args, atoi(UID.c_str()), pBacktrace);
}
-static string GetIndependentBacktrace(const string& pBacktrace)
+static string GetIndependentBacktrace(const char *pBacktrace)
{
string header;
bool in_bracket = false;
@@ -345,7 +345,7 @@ static string GetIndependentBacktrace(const string& pBacktrace)
seconds = 1260
ok = true
*/
- const char *bk = pBacktrace.c_str();
+ const char *bk = pBacktrace;
while (*bk)
{
if (bk[0] == '#'
@@ -433,33 +433,29 @@ static string GetIndependentBacktrace(const string& pBacktrace)
return pIndependentBacktrace;
}
-static void GetIndependentBuildIdPC(const string& pBuildIdPC, string& pIndependentBuildIdPC)
+static void GetIndependentBuildIdPC(const char *unstrip_n_output, string& pIndependentBuildIdPC)
{
- int ii = 0;
- while (ii < pBuildIdPC.length())
+ // lines look like this:
+ // 0x400000+0x209000 23c77451cf6adff77fc1f5ee2a01d75de6511dda@0x40024c - - [exe]
+ // 0x400000+0x209000 ab3c8286aac6c043fd1bb1cc2a0b88ec29517d3e@0x40024c /bin/sleep /usr/lib/debug/bin/sleep.debug [exe]
+ // 0x7fff313ff000+0x1000 389c7475e3d5401c55953a425a2042ef62c4c7df@0x7fff313ff2f8 . - linux-vdso.so.1
+ const char *line = unstrip_n_output;
+ while (*line)
{
- string line;
- int jj = 0;
-
- while (pBuildIdPC[ii] != '\n' && ii < pBuildIdPC.length())
+ const char *eol = strchrnul(line, '\n');
+ const char *plus = (char*)memchr(line, '+', eol - line);
+ if (plus)
{
- line += pBuildIdPC[ii];
- ii++;
- }
- while (line[jj] != '+' && jj < line.length())
- {
- jj++;
- }
- jj++;
- while (line[jj] != '@' && jj < line.length())
- {
- if (!isspace(line[jj]))
+ while (++plus < eol && *plus != '@')
{
- pIndependentBuildIdPC += line[jj];
+ if (!isspace(*plus))
+ {
+ pIndependentBuildIdPC += *plus;
+ }
}
- jj++;
}
- ii++;
+ if (*eol != '\n') break;
+ line = eol + 1;
}
}
@@ -843,10 +839,10 @@ string CAnalyzerCCpp::GetLocalUUID(const char *pDebugDumpDir)
dd.LoadText(FILENAME_PACKAGE, package);
}
- string buildIdPC = run_unstrip_n(pDebugDumpDir);
+ string unstrip_n_output = run_unstrip_n(pDebugDumpDir);
string independentBuildIdPC;
- GetIndependentBuildIdPC(buildIdPC, independentBuildIdPC);
- return CreateHash(package + executable + independentBuildIdPC);
+ GetIndependentBuildIdPC(unstrip_n_output.c_str(), independentBuildIdPC);
+ return CreateHash((package + executable + independentBuildIdPC).c_str());
}
string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir)
@@ -863,8 +859,8 @@ string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir)
dd.LoadText(FILENAME_EXECUTABLE, executable);
dd.LoadText(FILENAME_PACKAGE, package);
}
- string independentBacktrace = GetIndependentBacktrace(backtrace);
- return CreateHash(package + executable + independentBacktrace);
+ string independentBacktrace = GetIndependentBacktrace(backtrace.c_str());
+ return CreateHash((package + executable + independentBacktrace).c_str());
}
static bool DebuginfoCheckPolkit(int uid)