public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] tests: Run run-low_high_pc.sh testcase on split dwarf files.
Date: Thu, 31 May 2018 12:16:00 -0000	[thread overview]
Message-ID: <1527769007-8409-1-git-send-email-mark@klomp.org> (raw)

Test that the low high pc attributes can be properly resolved also
in split dwarf setups.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 tests/ChangeLog          |  9 +++++++++
 tests/low_high_pc.c      | 28 ++++++++++++++++++++++++++--
 tests/run-low_high_pc.sh | 15 +++++++++++----
 3 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 521df52..c03db54 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,14 @@
 2018-05-31  Mark Wielaard  <mark@klomp.org>
 
+	* low_high_pc.c (handle_die): Handle NULL name. Print offset and
+	name of die.
+	(main): Check if the cu DIE is a skeleton, then get and handle
+	the split subdie.
+	* run-low-high-pc.sh: Run on testfile-splitdwarf-4 and
+	testfile-splitdwarf-5. Run on all selftest files.
+
+2018-05-31  Mark Wielaard  <mark@klomp.org>
+
 	* get-units-invalid.c (main): Check dwarf_cuoffset and
 	dwarf_dieoffset.
 
diff --git a/tests/low_high_pc.c b/tests/low_high_pc.c
index d0f4302..5c6b343 100644
--- a/tests/low_high_pc.c
+++ b/tests/low_high_pc.c
@@ -1,5 +1,5 @@
 /* Test program for dwarf_lowpc and dwarf_highpc
-   Copyright (C) 2012 Red Hat, Inc.
+   Copyright (C) 2012, 2018 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -55,7 +55,9 @@ handle_die (Dwarf_Die *die, void *arg)
 
   const char *name = dwarf_diename (die);
   if (name == NULL)
-    fail (off, "<no name>", "die without a name");
+    name = "<no name>";
+
+  printf ("[%" PRIx64 "] %s\n", off, name);
 
   Dwarf_Addr lowpc = 0;
   Dwarf_Addr highpc = 0;
@@ -101,9 +103,31 @@ main (int argc, char *argv[])
       a.file = dwarf_diename (a.cu);
       handle_die (a.cu, &a);
       dwarf_getfuncs (a.cu, &handle_die, &a, 0);
+
+      uint8_t unit_type;
+      Dwarf_Die subdie;
+      if (dwarf_cu_info (a.cu->cu, NULL, &unit_type, NULL, &subdie,
+			 NULL, NULL, NULL) != 0)
+	{
+	  Dwarf_Off off = dwarf_dieoffset (a.cu);
+	  fail (off, "dwarf_cu_info", dwarf_errmsg (-1));
+	}
+
+      if (unit_type == DW_UT_skeleton)
+	{
+	  const char *name = dwarf_diename (&subdie) ?: "<unknown>";
+	  printf ("Following split subdie: %s\n", name);
+	  struct args b = a;
+	  b.cu = &subdie;
+	  handle_die (b.cu, &b);
+	  dwarf_getfuncs (b.cu, &handle_die, &b, 0);
+	  printf ("Done subdie: %s\n", name);
+	}
     }
 
   dwfl_end (a.dwfl);
 
+  printf ("\n");
+
   return result;
 }
diff --git a/tests/run-low_high_pc.sh b/tests/run-low_high_pc.sh
index ab5f2c3..41ec420 100755
--- a/tests/run-low_high_pc.sh
+++ b/tests/run-low_high_pc.sh
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2005 Red Hat, Inc.
+# Copyright (C) 2005, 2018 Red Hat, Inc.
 # This file is part of elfutils.
 #
 # This file is free software; you can redistribute it and/or modify
@@ -27,8 +27,15 @@ testfiles testfile_low_high_pc
 
 testrun ${abs_builddir}/low_high_pc -e ./testfile_low_high_pc
 testrun ${abs_builddir}/low_high_pc -e ${abs_builddir}/low_high_pc
-testrun ${abs_builddir}/low_high_pc -e ${abs_top_builddir}/src/strip
-testrun ${abs_builddir}/low_high_pc -e ${abs_top_builddir}/src/strip.o
-testrun ${abs_builddir}/low_high_pc -e ${abs_top_builddir}/libelf/libelf.so
+
+# see tests/testfile-dwarf-45.source
+testfiles testfile-splitdwarf-4 testfile-splitdwarf-5
+testfiles testfile-hello4.dwo testfile-hello5.dwo
+testfiles testfile-world4.dwo testfile-world5.dwo
+
+testrun ${abs_builddir}/low_high_pc -e testfile-splitdwarf-4
+testrun ${abs_builddir}/low_high_pc -e testfile-splitdwarf-5
+
+testrun_on_self ${abs_builddir}/low_high_pc -e
 
 exit 0
-- 
1.8.3.1

             reply	other threads:[~2018-05-31 12:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 12:16 Mark Wielaard [this message]
2018-06-01 11:18 ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1527769007-8409-1-git-send-email-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).