summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-10-19 01:40:28 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-19 01:40:28 +0200
commita0ad2aada47afdc78d6b807e7c51c854d50accda (patch)
tree94a2fefdfa1e21b79ca1b4b5c359f1dd8becc105
parentd61b353da2093a6dba08e11d08f786f407f8588d (diff)
downloadabrt-a0ad2aada47afdc78d6b807e7c51c854d50accda.tar.gz
abrt-a0ad2aada47afdc78d6b807e7c51c854d50accda.tar.xz
abrt-a0ad2aada47afdc78d6b807e7c51c854d50accda.zip
wire up abrt-debuginfo-install to lib/Plugins/CCpp.cpp
Tested. Seems to work better than what we had before. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--lib/Plugins/CCpp.cpp154
-rwxr-xr-xsrc/Daemon/abrt-debuginfo-install62
2 files changed, 72 insertions, 144 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index 0718323..40aadd2 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -172,10 +172,10 @@ static void GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktra
char* args[9];
args[0] = (char*)"gdb";
args[1] = (char*)"-batch";
- // when/if we'll add support for networked debuginfos
+ // when/if gdb supports it:
// (https://bugzilla.redhat.com/show_bug.cgi?id=528668):
- //args[] = (char*)"-ex";
- //args[] = xasprintf("set debug-file-directory %s", dir);
+ //args[2] = (char*)"-ex";
+ //args[3] = "set debug-file-directory /usr/lib/debug/.build-id:/var/cache/abrt-di/usr/lib/debug/.build-id";
/*
* Unfortunately, "file BINARY_FILE" doesn't work well if BINARY_FILE
* was deleted (as often happens during system updates):
@@ -373,75 +373,9 @@ static std::string run_unstrip_n(const std::string& pDebugDumpDir)
static void InstallDebugInfos(const std::string& pDebugDumpDir, std::string& build_ids)
{
- log("Getting module names, file names, build IDs from core file");
- std::string unstrip_list = run_unstrip_n(pDebugDumpDir);
-
- log("Building list of missing debuginfos");
- // lines look like this:
- // 0x400000+0x209000 23c77451cf6adff77fc1f5ee2a01d75de6511dda@0x40024c - - [exe]
- // or
- // 0x400000+0x209000 ab3c8286aac6c043fd1bb1cc2a0b88ec29517d3e@0x40024c /bin/sleep /usr/lib/debug/bin/sleep.debug [exe]
- // 0x7fff313ff000+0x1000 389c7475e3d5401c55953a425a2042ef62c4c7df@0x7fff313ff2f8 . - linux-vdso.so.1
- vector_string_t missing;
- char *dup = xstrdup(unstrip_list.c_str());
- char *p = dup;
- char c;
- do {
- char* end = strchrnul(p, '\n');
- c = *end;
- *end = '\0';
- char* word2 = strchr(p, ' ');
- p = end + 1;
- if (!word2)
- continue;
- word2++;
- char* endsp = strchr(word2, ' ');
- if (!endsp)
- continue;
- /* endsp points to 2nd space in the line now*/
-
- /* This filters out linux-vdso.so, among others */
- if (strstr(endsp, "[exe]") == NULL && endsp[1] != '/')
- continue;
- *endsp = '\0';
- char* at = strchrnul(word2, '@');
- *at = '\0';
-
- bool file_exists = 1;
- if (word2[0] && word2[1] && is_hexstr(word2))
- {
- struct stat sb;
- char *fn = xasprintf("/usr/lib/debug/.build-id/%.2s/%s.debug", word2, word2 + 2);
- /* Not lstat: this is a symlink and we want link's TARGET to exist */
- file_exists = stat(fn, &sb) == 0 && S_ISREG(sb.st_mode);
- free(fn);
- build_ids += "build-id ";
- build_ids += word2;
- build_ids += file_exists ? " (debuginfo present)\n" : " (debuginfo absent)\n";
- }
- log("build_id:%s exists:%d", word2, (int)file_exists);
- if (!file_exists)
- missing.push_back(word2);
- } while (c);
- free(dup);
-
- if (missing.size() == 0)
- {
- log("All debuginfos are present, not installing debuginfo packages");
- return;
- }
- //missing vector is unused for now, but TODO: use it to install only needed debuginfos
-
- std::string package;
- {
- CDebugDump dd;
- dd.Open(pDebugDumpDir);
- dd.LoadText(FILENAME_PACKAGE, package);
- }
-
update_client(_("Searching for debug-info packages..."));
- int pipein[2], pipeout[2];
+ int pipein[2], pipeout[2]; //TODO: get rid of pipein
xpipe(pipein);
xpipe(pipeout);
@@ -462,45 +396,18 @@ static void InstallDebugInfos(const std::string& pDebugDumpDir, std::string& bui
/*close(STDERR_FILENO);*/
setsid();
-/* Honestly, I do not know what is worse, pk-debuginfo-install or debuginfo-install:
-
-# pk-debuginfo-install -y -- coreutils-7.2-4.fc11
-1. Getting sources list...OK. Found 16 enabled and 23 disabled sources.
-2. Finding debugging sources...OK. Found 0 disabled debuginfo repos.
-3. Enabling debugging sources...OK. Enabled 0 debugging sources.
-4. Finding debugging packages...Failed to find the package : more than one package found for
-Failed to find the package : more than one package found for
-FAILED. Found no packages to install.
-5. Disabling sources previously enabled...OK. Disabled 0 debugging sources.
-
-:( FAIL!
-
-# debuginfo-install -y -- coreutils-7.2-4.fc11
-Loaded plugins: refresh-packagekit
-Another application is holding the yum lock, cannot continue
-
-:( FAIL!
-
-# debuginfo-install -y -- coreutils-7.2-4.fc11
-(second time in a row - it worked)
-*/
+ char *coredump = xasprintf("%s/"FILENAME_COREDUMP, pDebugDumpDir.c_str());
+ char *tempdir = xasprintf("/tmp/abrt-%u-%lu", (int)getpid(), (long)time(NULL));
/* log() goes to stderr/syslog, it's ok to use it here */
- VERB1 log("Executing: %s %s %s %s", "pk-debuginfo-install", "-y", "--", package.c_str());
- execlp("pk-debuginfo-install", "pk-debuginfo-install", "-y", "--", package.c_str(), NULL);
- /* fall back */
- VERB1 log("Executing: %s %s %s %s", "debuginfo-install", "-y", "--", package.c_str());
- execlp("debuginfo-install", "debuginfo-install", "-y", "--", package.c_str(), NULL);
+ VERB1 log("Executing: %s %s %s %s", "abrt-debuginfo-install", coredump, tempdir, "/"); // "/var/cache/abrt-di"
+ execlp("abrt-debuginfo-install", "abrt-debuginfo-install", coredump, tempdir, "/", NULL);
exit(1);
}
close(pipein[0]);
close(pipeout[1]);
- /* Should not be needed (we use -y option), but just in case: */
- safe_write(pipein[1], "y\n", sizeof("y\n")-1);
- close(pipein[1]);
-
update_client(_("Downloading and installing debug-info packages..."));
FILE *pipeout_fp = fdopen(pipeout[0], "r");
@@ -511,50 +418,30 @@ Another application is holding the yum lock, cannot continue
return;
}
-/* glx-utils, for example, do not have glx-utils-debuginfo package.
- * Disabled code was causing failures in backtrace decoding.
- * This does not seem to be useful.
- */
-#ifdef COMPLAIN_IF_NO_DEBUGINFO
- bool already_installed = false;
-#endif
char buff[1024];
- std::string packageName = package.substr(0, package.rfind("-", package.rfind("-")-1));
while (fgets(buff, sizeof(buff), pipeout_fp))
{
int last = strlen(buff) - 1;
if (last >= 0 && buff[last] == '\n')
buff[last] = '\0';
- /* log(buff); - update_client logs it too */
- update_client(buff); /* maybe only if buff != ""? */
-
-#ifdef COMPLAIN_IF_NO_DEBUGINFO
- if (already_installed == false)
+ if (strncmp(buff, "MISSING:", 8) == 0)
{
- /* "Package foo-debuginfo-1.2-5.ARCH already installed and latest version" */
- char* pn = strstr(buff, packageName.c_str());
- if (pn)
- {
- char* already_str = strstr(pn, "already installed and latest version");
- if (already_str)
- {
- already_installed = true;
- }
- }
+ build_ids += "Debuginfo absent: ";
+ build_ids += buff + 8;
+ build_ids += "\n";
}
- if (already_installed == false &&
- (strstr(buff, "No debuginfo packages available to install") != NULL ||
- strstr(buff, "Could not find debuginfo for main pkg") != NULL ||
- strstr(buff, "Could not find debuginfo pkg for dependency package") != NULL))
+ const char *p = buff;
+ while (*p == ' ' || *p == '\t')
+ {
+ p++;
+ }
+ if (*p)
{
- fclose(pipeout_fp);
- kill(child, SIGTERM);
- wait(NULL);
- throw CABRTException(EXCEP_PLUGIN, std::string(__func__) + ": cannot install debuginfos for " + pPackage);
+ /* log(buff); - update_client logs it too */
+ update_client(buff);
}
-#endif
}
fclose(pipeout_fp);
@@ -665,6 +552,7 @@ void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir, int force)
dd.Open(pDebugDumpDir);
dd.SaveText(FILENAME_BACKTRACE, build_ids + backtrace);
+log("BACKTRACE:'%s'", (build_ids + backtrace).c_str());
if (m_bMemoryMap)
{
dd.SaveText(FILENAME_MEMORYMAP, "memory map of the crashed C/C++ application, not implemented yet");
diff --git a/src/Daemon/abrt-debuginfo-install b/src/Daemon/abrt-debuginfo-install
index d8d306a..fe55250 100755
--- a/src/Daemon/abrt-debuginfo-install
+++ b/src/Daemon/abrt-debuginfo-install
@@ -5,19 +5,28 @@ tempdir=$2
cachedir=$3
debug=false
+count_words() {
+ echo $#
+}
+
+exec 2>&1
+
+# Output goes to GUI as debigunfo install log.
+# "MISSING:xxxx" messages result in xxxx being prepended to backtrace
+
# Exitcodes:
# 0 - all debuginfos are installed
# 1 - not all debuginfos are installed
# 2+ - serious problem
test -f "$core" || exit 2
-# cahcedir is optional
+# cachedir is optional
test x"$cachedir" = x"" || test -d "$cachedir" || exit 2
# tempdir must not exist
-test -d "$tempdir" && exit 2
+test -e "$tempdir" && exit 2
+
mkdir "$tempdir" || exit 2
cd "$tempdir" || exit 2
-
$debug && echo "Installing rpms to $tempdir"
# eu-unstrip output example:
@@ -27,6 +36,7 @@ $debug && echo "Installing rpms to $tempdir"
# 0x7fff5cdff000+0x1000 0d3eb4326fd7489fcf9b598269f1edc420e2c560@0x7fff5cdff2f8 . - linux-vdso.so.1
# 0x3d15600000+0x208000 20196628d1bc062279622615cc9955554e5bb227@0x3d156001a0 /usr/lib64/libnotify.so.1.1.3 /usr/lib/debug/usr/lib64/libnotify.so.1.1.3.debug libnotify.so.1
# 0x7fd8ae931000+0x62d000 dd49f44f958b5a11a1635523b2f09cb2e45c1734@0x7fd8ae9311a0 /usr/lib64/libgtk-x11-2.0.so.0.1600.6 /usr/lib/debug/usr/lib64/libgtk-x11-2.0.so.0.1600.6.debug
+echo "Getting list of build IDs"
eu_unstrip_OUT=`eu-unstrip "--core=$core" -n 2>&1`
err=$?
printf "%s\nexitcode:%s\n" "$eu_unstrip_OUT" $err >eu_unstrip.OUT
@@ -53,9 +63,19 @@ $debug && echo "build_ids:$build_ids"
missing_debuginfo_files=`for build_id in $build_ids; do
build_id1=${build_id:0:2}
build_id2=${build_id:2}
+
file="usr/lib/debug/.build-id/$build_id1/$build_id2.debug"
+ if test x"$cachedir" != x"" && test x"$cachedir" != x"/" ; then
+ test -f "$cachedir/$file" && continue
+ if test -f "/$file"; then
+ mkdir -p "$cachedir/usr/lib/debug/.build-id/$build_id1"
+ # Note: this does not preserve symlinks. This is intentional
+ $debug && echo Copying "$file" to "$cachedir/$file" >&2
+ cp "$file" "$cachedir/$file"
+ continue
+ fi
+ fi
test -f "/$file" && continue
- test x"$cachedir" != x"" && test -f "$cachedir/$file" && continue
echo -n "/$file "
done`
$debug && echo "missing_debuginfo_files:$missing_debuginfo_files"
@@ -66,6 +86,7 @@ test x"$missing_debuginfo_files" = x"" && exit 0
# yum --enablerepo='*debuginfo*' --quiet provides \
# /usr/lib/debug/.build-id/bb/11528d59940983f495e9cb099cafb0cb206051.debug \
# /usr/lib/debug/.build-id/c5/b84c0ad3676509dc30bfa7d42191574dac5b06.debug ...
+echo "Determining list of packages for `count_words $missing_debuginfo_files` missing debuginfos"
yum_provides_OUT=`yum --enablerepo='*debuginfo*' --quiet provides $missing_debuginfo_files 2>&1`
err=$?
printf "%s\nexitcode:%s\n" "$yum_provides_OUT" $err >yum_provides.OUT
@@ -95,6 +116,7 @@ $debug && echo "packages:$packages"
test x"$packages" = x"" && exit 1
# Redirecting, since progress bar stuff only messes up our output
+echo "Downloading `count_words $packages` packages"
yumdownloader --enablerepo='*debuginfo*' --quiet $packages >yumdownloader.OUT 2>&1
err=$?
echo "exitcode:$err" >>yumdownloader.OUT
@@ -104,32 +126,50 @@ for f in *.rpm; do
# Happens if no .rpm's were downloaded (yumdownloader problem)
# In this case, $f is the literal "*.rpm" string
test -f "$f" || exit 2
- $debug && echo "Processing: $f"
+ echo "Unpacking: $f"
echo "Processing: $f" >>unpack.OUT
rpm2cpio <"$f" 2>>unpack.OUT | cpio -id >>unpack.OUT 2>&1
done
# Which debuginfo files are still missing, including those we just unpacked?
-missing_debuginfo_files2=`for build_id in $build_ids; do
+missing_build_ids=`for build_id in $build_ids; do
build_id1=${build_id:0:2}
build_id2=${build_id:2}
+
file="usr/lib/debug/.build-id/$build_id1/$build_id2.debug"
+
test -f "/$file" && continue
- test x"$cachedir" != x"" && test -f "$cachedir/$file" && continue
+ test x"$cachedir" != x"" \
+ && test x"$cachedir" != x"/" \
+ && test -f "$cachedir/$file" && continue
+
if test -f "$file"; then
# file is one of those we just installed.
# Cache it if cachedir is specified.
if test x"$cachedir" != x"" && test -d "$cachedir"; then
mkdir -p "$cachedir/usr/lib/debug/.build-id/$build_id1"
# Note: this does not preserve symlinks. This is intentional
- cp "$file" "$cachedir/$file"
+ $debug && echo Copying "$file" to "$cachedir/$file" >&2
+ cp --remove-destination "$file" "$cachedir/$file"
fi
continue
fi
- echo -n "/$file "
+ echo -n "$build_id "
done`
-$debug && echo "missing_debuginfo_files2:$missing_debuginfo_files2"
+$debug && echo "missing_build_ids:$missing_build_ids"
+
+# If cachedir is specified, tempdir is just a staging area. Delete it
+if test x"$cachedir" != x""; then
+ $debug && echo "Removing $tempdir"
+ rm -rf "$tempdir"
+fi
+
+test x"$missing_build_ids" = x"" && exit 0
+
+for missing in $missing_build_ids; do
+ echo "MISSING:$missing"
+done
-test x"$missing_debuginfo_files2" = x"" && exit 0
+echo "`count_words $missing_build_ids` debuginfos can't be found"
exit 1