RFCv2: debuginfod debian archive support

Frank Ch. Eigler fche@redhat.com
Fri Dec 13 19:25:00 GMT 2019


Hi -

> I see, I missed that both functions are only called after first
> checking the archive type. I think it might be helpful/clearer if both
> methods would be called with the intended archive type then, also
> because that might make it simpler to...

The archive subtype (rpm vs deb) is not stored in the database, as
this would break the current schema, and is really not needed.  In any
case, it's easily recovered for purpose of separate metrics.  Following
sur-patch added to fche/debuginfod-deb branch:


commit 02694cd29672d6912569a4bfe03b703bc134a821
Author: Frank Ch. Eigler <fche@redhat.com>
Date:   Fri Dec 13 14:21:12 2019 -0500

    debuginfod deb support: review responses

diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index f022995f490f..70cb95fecd65 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -868,9 +868,13 @@ handle_buildid_r_match (int64_t b_mtime,
     }
 
   string archive_decoder = "/dev/null";
+  string archive_extension = "";
   for (auto&& arch : scan_archives)
     if (string_endswith(b_source0, arch.first))
-      archive_decoder = arch.second;
+      {
+        archive_extension = arch.first;
+        archive_decoder = arch.second;
+      }
   string popen_cmd = archive_decoder + " " + shell_escape(b_source0);
   FILE* fp = popen (popen_cmd.c_str(), "r"); // "e" O_CLOEXEC?
   if (fp == NULL)
@@ -922,7 +926,7 @@ handle_buildid_r_match (int64_t b_mtime,
           throw archive_exception(a, "cannot extract file");
         }
 
-      inc_metric ("http_responses_total","result","archive");
+      inc_metric ("http_responses_total","result",archive_extension + " archive");
       struct MHD_Response* r = MHD_create_response_from_fd (archive_entry_size(e), fd);
       if (r == 0)
         {
@@ -1881,16 +1885,20 @@ thread_main_scan_source_file_path (void* arg)
 // Analyze given archive file of given age; record buildids / exec/debuginfo-ness of its
 // constituent files with given upsert statements.
 static void
-archive_classify (const string& rps, sqlite_ps& ps_upsert_buildids, sqlite_ps& ps_upsert_files,
-              sqlite_ps& ps_upsert_de, sqlite_ps& ps_upsert_sref, sqlite_ps& ps_upsert_sdef,
-              time_t mtime,
-              unsigned& fts_executable, unsigned& fts_debuginfo, unsigned& fts_sref, unsigned& fts_sdef,
-              bool& fts_sref_complete_p)
+archive_classify (const string& rps, string& archive_extension,
+                  sqlite_ps& ps_upsert_buildids, sqlite_ps& ps_upsert_files,
+                  sqlite_ps& ps_upsert_de, sqlite_ps& ps_upsert_sref, sqlite_ps& ps_upsert_sdef,
+                  time_t mtime,
+                  unsigned& fts_executable, unsigned& fts_debuginfo, unsigned& fts_sref, unsigned& fts_sdef,
+                  bool& fts_sref_complete_p)
 {
   string archive_decoder = "/dev/null";
   for (auto&& arch : scan_archives)
     if (string_endswith(rps, arch.first))
-      archive_decoder = arch.second;
+      {
+        archive_extension = arch.first;
+        archive_decoder = arch.second;
+      }
   string popen_cmd = archive_decoder + " " + shell_escape(rps);
   FILE* fp = popen (popen_cmd.c_str(), "r"); // "e" O_CLOEXEC?
   if (fp == NULL)
@@ -2176,18 +2184,19 @@ scan_source_archive_path (const string& dir)
                 bool my_fts_sref_complete_p = true;
                 try
                   {
-                    archive_classify (rps,
+                    string archive_extension;
+                    archive_classify (rps, archive_extension,
                                   ps_upsert_buildids, ps_upsert_files,
                                   ps_upsert_de, ps_upsert_sref, ps_upsert_sdef, // dalt
                                   f->fts_statp->st_mtime,
                                   my_fts_executable, my_fts_debuginfo, my_fts_sref, my_fts_sdef,
                                   my_fts_sref_complete_p);
-                    inc_metric ("scanned_total","source","archive");
-                    add_metric("found_debuginfo_total","source","archive",
+                    inc_metric ("scanned_total","source",archive_extension + " archive");
+                    add_metric("found_debuginfo_total","source",archive_extension + " archive",
                                my_fts_debuginfo);
-                    add_metric("found_executable_total","source","archive",
+                    add_metric("found_executable_total","source",archive_extension + " archive",
                                my_fts_executable);
-                    add_metric("found_sourcerefs_total","source","archive",
+                    add_metric("found_sourcerefs_total","source",archive_extension + " archive",
                                my_fts_sref);
                   }
                 catch (const reportable_exception& e)
diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh
index cd31e30e0491..01c7e58e5ffc 100755
--- a/tests/run-debuginfod-find.sh
+++ b/tests/run-debuginfod-find.sh
@@ -81,7 +81,8 @@ wait_ready()
   done;
 
   if [ $timeout -eq 0 ]; then
-    echo "metric $what never changed to $value on port $port"
+      echo "metric $what never changed to $value on port $port"
+      curl -s http://127.0.0.1:$port/metrics
     exit 1;
   fi
 }
@@ -166,7 +167,7 @@ cp -rvp ${abs_srcdir}/debuginfod-rpms R
 kill -USR1 $PID1
 # All rpms need to be in the index
 rpms=$(find R -name \*rpm | wc -l)
-wait_ready $PORT1 'scanned_total{source="archive"}' $rpms
+wait_ready $PORT1 'scanned_total{source=".rpm archive"}' $rpms
 
 kill -USR1 $PID1  # two hits of SIGUSR1 may be needed to resolve .debug->dwz->srefs
 # Expect all source files found in the rpms (they are all called hello.c :)
@@ -191,11 +192,11 @@ sourcefiles=$(find -name \*\\.debug \
 cd ..
 rm -rf extracted
 
-wait_ready $PORT1 'found_sourcerefs_total{source="archive"}' $sourcefiles
+wait_ready $PORT1 'found_sourcerefs_total{source=".rpm archive"}' $sourcefiles
 
-# Run a bank of queries against the debuginfod-rpms test cases
+# Run a bank of queries against the debuginfod-rpms / debuginfod-debs test cases
 
-rpm_test() {
+archive_test() {
     __BUILDID=$1
     __SOURCEPATH=$2
     __SOURCESHA1=$3
@@ -221,14 +222,14 @@ rpm_test() {
 # common source file sha1
 SHA=f4a1a8062be998ae93b8f1cd744a398c6de6dbb1
 # fedora30
-rpm_test c36708a78618d597dee15d0dc989f093ca5f9120 /usr/src/debug/hello2-1.0-2.x86_64/hello.c $SHA
-rpm_test 41a236eb667c362a1c4196018cc4581e09722b1b /usr/src/debug/hello2-1.0-2.x86_64/hello.c $SHA
+archive_test c36708a78618d597dee15d0dc989f093ca5f9120 /usr/src/debug/hello2-1.0-2.x86_64/hello.c $SHA
+archive_test 41a236eb667c362a1c4196018cc4581e09722b1b /usr/src/debug/hello2-1.0-2.x86_64/hello.c $SHA
 # rhel7
-rpm_test bc1febfd03ca05e030f0d205f7659db29f8a4b30 /usr/src/debug/hello-1.0/hello.c $SHA
-rpm_test f0aa15b8aba4f3c28cac3c2a73801fefa644a9f2 /usr/src/debug/hello-1.0/hello.c $SHA
+archive_test bc1febfd03ca05e030f0d205f7659db29f8a4b30 /usr/src/debug/hello-1.0/hello.c $SHA
+archive_test f0aa15b8aba4f3c28cac3c2a73801fefa644a9f2 /usr/src/debug/hello-1.0/hello.c $SHA
 # rhel6
-rpm_test bbbf92ebee5228310e398609c23c2d7d53f6e2f9 /usr/src/debug/hello-1.0/hello.c $SHA
-rpm_test d44d42cbd7d915bc938c81333a21e355a6022fb7 /usr/src/debug/hello-1.0/hello.c $SHA
+archive_test bbbf92ebee5228310e398609c23c2d7d53f6e2f9 /usr/src/debug/hello-1.0/hello.c $SHA
+archive_test d44d42cbd7d915bc938c81333a21e355a6022fb7 /usr/src/debug/hello-1.0/hello.c $SHA
 
 RPM_BUILDID=d44d42cbd7d915bc938c81333a21e355a6022fb7 # in rhel6/ subdir, for a later test
 
@@ -276,11 +277,13 @@ if type dpkg-deb 2>/dev/null; then
     cp -rvp ${abs_srcdir}/debuginfod-debs/*deb D
     kill -USR1 $PID2
     # All debs need to be in the index
-    debs=$(find D -name \*deb | wc -l)
-    wait_ready $PORT2 'scanned_total{source="archive"}' `expr $debs`
+    debs=$(find D -name \*.deb | wc -l)
+    wait_ready $PORT2 'scanned_total{source=".deb archive"}' `expr $debs`
+    ddebs=$(find D -name \*.ddeb | wc -l)
+    wait_ready $PORT2 'scanned_total{source=".ddeb archive"}' `expr $ddebs`
 
     # ubuntu
-    rpm_test f17a29b5a25bd4960531d82aa6b07c8abe84fa66 "" ""
+    archive_test f17a29b5a25bd4960531d82aa6b07c8abe84fa66 "" ""
 fi
 
 rm -rf $DEBUGINFOD_CACHE_PATH



More information about the Elfutils-devel mailing list