public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [committed] If .debug_info section not present, exit with 0
@ 2019-01-01  0:00 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2019-01-01  0:00 UTC (permalink / raw)
  To: dwz, jakub; +Cc: Matthias Klose

Hi,

There are two errors switched off by --quiet (provided we don't run with -o):
- DWARF compression not beneficial
- .debug_info section not present
If we run into the first error, we exit with '0', but if we run into the
second error, we exit with '1'.

It seems that if the error is unimportant enough to not print with --quiet,
it's not worth exiting with '1' either.  Fix this.

Committed to trunk.

Thanks,
- Tom

If .debug_info section not present, exit with 0

2019-07-11  Tom de Vries  <tdevries@suse.de>

	PR dwz/24766
	* dwz.c (read_dwarf): Return 3 if .debug_info not present.
	(dwz): If read_dwarf returned 3, exit with 0.
	* testsuite/dwz.tests/objcopy-strip-debug.sh: Update.

---
 dwz.c                                      |  7 ++++++-
 testsuite/dwz.tests/objcopy-strip-debug.sh | 14 +++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/dwz.c b/dwz.c
index cd382b9..e5de164 100644
--- a/dwz.c
+++ b/dwz.c
@@ -10276,7 +10276,7 @@ read_dwarf (DSO *dso, bool quieter)
       if (!quieter)
 	error (0, 0, "%s: .debug_info section not present",
 	       dso->filename);
-      return 1;
+      return 3;
     }
 
   if (debug_sections[GNU_DEBUGALTLINK].data != NULL)
@@ -11815,6 +11815,11 @@ dwz (const char *file, const char *outfile, struct file_result *res,
   free (dso);
   if (ret == 0 && !low_mem)
     res->res = 0;
+  if (ret == 3)
+    {
+      ret = (outfile != NULL) ? 1 : 0;
+      res->res = -1;
+    }
   return ret;
 }
 
diff --git a/testsuite/dwz.tests/objcopy-strip-debug.sh b/testsuite/dwz.tests/objcopy-strip-debug.sh
index 043563b..a22ba3a 100644
--- a/testsuite/dwz.tests/objcopy-strip-debug.sh
+++ b/testsuite/dwz.tests/objcopy-strip-debug.sh
@@ -11,8 +11,20 @@ if ! grep -q "\.debug_info section not present" dwz.err; then
     exit 1
 fi
 
-[ $status -eq 1 ]
+[ $status -eq 0 ]
 
 cmp 1 1.saved
 
+if dwz 1 -o 2 2>dwz.err; status=$?; then
+    true
+fi
+
+if ! grep -q "\.debug_info section not present" dwz.err; then
+    cat dwz.err
+    exit 1
+fi
+
+[ $status -eq 1 ]
+[ ! -f 2 ]
+
 rm -f 1 1.saved dwz.err

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-07-11 10:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-01  0:00 [committed] If .debug_info section not present, exit with 0 Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).