[PATCH] Check for existence of mempcpy

2017-02-16 Thread Ulf Hermann
If it doesn't exist, provide a definition based on memcpy.

Signed-off-by: Ulf Hermann 
---
 ChangeLog  | 4 
 configure.ac   | 3 +++
 lib/ChangeLog  | 5 +
 lib/system.h   | 5 +
 lib/xstrndup.c | 2 +-
 libasm/ChangeLog   | 4 
 libasm/disasm_str.c| 2 +-
 libdwfl/ChangeLog  | 4 
 libdwfl/linux-kernel-modules.c | 1 +
 libebl/ChangeLog   | 5 +
 libebl/eblmachineflagname.c| 1 +
 libebl/eblopenbackend.c| 1 +
 tests/ChangeLog| 4 
 tests/elfstrmerge.c| 1 +
 14 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b50f79e..48185c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-02-15  Ulf Hermann  
+
+   * configure.ac: Add check for mempcpy.
+
 2017-02-09  Mark Wielaard  
 
* configure.ac: Add check for adding -D_FORTIFY_SOURCE=2 to CFLAGS.
diff --git a/configure.ac b/configure.ac
index 46055f2..3c35dac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -285,6 +285,9 @@ AC_CHECK_DECLS([memrchr, rawmemchr],[],[],
[#define _GNU_SOURCE
 #include ])
 AC_CHECK_DECLS([powerof2],[],[],[#include ])
+AC_CHECK_DECLS([mempcpy],[],[],
+   [#define _GNU_SOURCE
+#include ])
 
 AC_CHECK_LIB([stdc++], [__cxa_demangle], [dnl
 AC_DEFINE([USE_DEMANGLE], [1], [Defined if demangling is enabled])])
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 6578ddb..fd63e03 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,5 +1,10 @@
 2017-02-15  Ulf Hermann  
 
+   * system.h: Provide mempcpy if it doesn't exist.
+   * xstrndup.c: Include system.h.
+
+2017-02-15  Ulf Hermann  
+
* crc32_file.c: Use _SC_PAGESIZE rather than _SC_PAGE_SIZE.
 
 2017-02-14  Ulf Hermann  
diff --git a/lib/system.h b/lib/system.h
index dde7c4a..429b0c3 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -68,6 +68,11 @@
 #define powerof2(x) (((x) & ((x) - 1)) == 0)
 #endif
 
+#if !HAVE_DECL_MEMPCPY
+#define mempcpy(dest, src, n) \
+((void *) ((char *) memcpy (dest, src, n) + (size_t) n))
+#endif
+
 /* A special gettext function we use if the strings are too short.  */
 #define sgettext(Str) \
   ({ const char *__res = strrchr (gettext (Str), '|');   \
diff --git a/lib/xstrndup.c b/lib/xstrndup.c
index d43e3b9..a257aa9 100644
--- a/lib/xstrndup.c
+++ b/lib/xstrndup.c
@@ -33,7 +33,7 @@
 #include 
 #include 
 #include "libeu.h"
-
+#include "system.h"
 
 /* Return a newly allocated copy of STRING.  */
 char *
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index fe06007..26fc5a9 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,7 @@
+2017-02-15  Ulf Hermann  
+
+   * disasm_str.c: Include system.h.
+
 2015-10-11  Akihiko Odaki  
 
* asm_align.c: Remove sys/param.h include.
diff --git a/libasm/disasm_str.c b/libasm/disasm_str.c
index 5b0bb29..c14e6d5 100644
--- a/libasm/disasm_str.c
+++ b/libasm/disasm_str.c
@@ -31,7 +31,7 @@
 #endif
 
 #include 
-
+#include 
 #include "libasmP.h"
 
 
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 52466cc..4c9f4f6 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,9 @@
 2017-02-15  Ulf Hermann  
 
+   * linux-kernel-modules.c: Include system.h.
+
+2017-02-15  Ulf Hermann  
+
* linux-kernel-modules.c: Use sysconf(_SC_PAGESIZE) to get page size.
* linux-proc-maps.c: Likewise.
 
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index a7ac19d..7345e76 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -34,6 +34,7 @@
 #endif
 
 #include 
+#include 
 
 #include "libdwflP.h"
 #include 
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 0560c6a..719d08d 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-15  Ulf Hermann  
+
+   * eblmachineflagname.c: Include system.h.
+   * eblopenbackend.c: Likewise.
+
 2016-07-08  Mark Wielaard  
 
* Makefile.am (gen_SOURCES): Remove eblstrtab.c.
diff --git a/libebl/eblmachineflagname.c b/libebl/eblmachineflagname.c
index 6079a61..5f44077 100644
--- a/libebl/eblmachineflagname.c
+++ b/libebl/eblmachineflagname.c
@@ -33,6 +33,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index aa75b95..f3a65cf 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 71dba42..4af450c 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2017-02-15  Ulf Hermann  
+
+   * elfstrmerge.c: Include system.h.
+
 2017-02-13  Ulf Hermann  
 
* Makefile.am: Add test for unwinding with frame pointers on aarch64
diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c
index c2c3fb9..8d5b53c 100644

Re: frame unwinding patches

2017-02-16 Thread Ulf Hermann
> I had to hand apply a few things because of whitespace adjustments.
> Hopefully I did it right and this is how Ulf intended the patches.
> If not, my apologies, and please let me know what changes you did
> intend.

Thank you. The patches are correct.

cheers,
Ulf


[PATCH] Move print_version into printversion.{h|c}

2017-02-16 Thread Ulf Hermann
Rename version.c so that the implementation is called after the header
and the header doesn't clash with the toplevel version.h. print_version
depends on argp and is only used in the tools.

Signed-off-by: Ulf Hermann 
---
 lib/ChangeLog  | 13 +
 lib/Makefile.am|  4 ++--
 lib/printversion.c | 45 +
 lib/printversion.h | 49 +
 lib/system.h   | 16 
 lib/version.c  | 47 ---
 po/ChangeLog   |  4 
 po/POTFILES.in |  2 +-
 src/ChangeLog  | 18 ++
 src/addr2line.c|  1 +
 src/ar.c   |  1 +
 src/elfcmp.c   |  2 +-
 src/elfcompress.c  |  2 +-
 src/elflint.c  |  1 +
 src/findtextrel.c  |  2 +-
 src/nm.c   |  1 +
 src/objdump.c  |  1 +
 src/ranlib.c   |  1 +
 src/readelf.c  |  1 +
 src/size.c |  2 +-
 src/stack.c|  1 +
 src/strings.c  |  1 +
 src/strip.c|  1 +
 src/unstrip.c  |  2 +-
 24 files changed, 147 insertions(+), 71 deletions(-)
 create mode 100644 lib/printversion.c
 create mode 100644 lib/printversion.h
 delete mode 100644 lib/version.c

diff --git a/lib/ChangeLog b/lib/ChangeLog
index fd63e03..84290f7 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,16 @@
+2017-02-16  Ulf Hermann  
+
+   * Makefile.am (libeu_a_SOURCES): Remove version.c, add printversion.c
+   (noinst_HEADERS): Add printversion.h
+   * version.c: Moved to printversion.c.
+   * printversion.c: New file, moved from version.c,
+   remove stdio.h, argp.h, system.h includes,
+   add printversion.h include.
+   * printversion.h: New file.
+   * system.h: Remove argp.h include,
+   (ARGP_PROGRAM_VERSION_HOOK_DEF, ARGP_PROGRAM_BUG_ADDRESS_DEF): Remove.
+   (print_version): Remove.
+
 2017-02-15  Ulf Hermann  
 
* system.h: Provide mempcpy if it doesn't exist.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3e0c601..7a65eb9 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -35,10 +35,10 @@ noinst_LIBRARIES = libeu.a
 
 libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c \
  crc32.c crc32_file.c md5.c sha1.c \
- color.c version.c
+ color.c printversion.c
 
 noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \
-md5.h sha1.h eu-config.h color.h
+md5.h sha1.h eu-config.h color.h printversion.h
 EXTRA_DIST = dynamicsizehash.c
 
 if !GPROF
diff --git a/lib/printversion.c b/lib/printversion.c
new file mode 100644
index 000..4056b93
--- /dev/null
+++ b/lib/printversion.c
@@ -0,0 +1,45 @@
+/* Common argp_print_version_hook for all tools.
+   Copyright (C) 2016 Red Hat, Inc.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+   Software Foundation; either version 3 of the License, or (at
+   your option) any later version
+
+   or
+
+ * the GNU General Public License as published by the Free
+   Software Foundation; either version 2 of the License, or (at
+   your option) any later version
+
+   or both in parallel, as here.
+
+   elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see .  */
+
+#ifdef HAVE_CONFIG_H
+# include 
+#endif
+
+#include 
+#include "printversion.h"
+
+void
+print_version (FILE *stream, struct argp_state *state)
+{
+  fprintf (stream, "%s (%s) %s\n", state->name, PACKAGE_NAME, PACKAGE_VERSION);
+  fprintf (stream, gettext ("\
+Copyright (C) %s The elfutils developers <%s>.\n\
+This is free software; see the source for copying conditions.  There is NO\n\
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
+"), "2016", PACKAGE_URL);
+}
diff --git a/lib/printversion.h b/lib/printversion.h
new file mode 100644
index 000..a9e059f
--- /dev/null
+++ b/lib/printversion.h
@@ -0,0 +1,49 @@
+/* Common argp_print_version_hook for all tools.
+   Copyright (C) 2017 The Qt Company Ltd.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+   Software Foundation; either version 3 of the License, or (at
+   your option) any later version
+
+   or
+
+ * the GNU General Public License as published by the Free
+   Software Foundation; either ver

[Fwd: [Dwarf-Discuss] DWARF Version 5 Standard Released]

2017-02-16 Thread Mark Wielaard
For those that actually want to read the standard it is here:
http://dwarfstd.org/doc/DWARF5.pdf

And there now is a public git repository, in case you need to figure out
the changes since the last public draft here:
http://git.dwarfstd.org/?p=dwarf-doc.git;a=summary
git clone http://git.dwarfstd.org/dwarf-doc.git

I have not yet updated my elfutils code/branch for the changes made
since the public draft. GCC7 should be able to emit DWARF5 (except for
split DWARF support) when it is released (current svn versions already
do). I hope to finish my DWARF5 elfutils work before GCC7 is released in
April.
--- Begin Message ---
The DWARF Debugging Information Format Standards Committee is pleased to announce the availability 
of Version 5 of the DWARF Debugging Format Standard.   The DWARF Debugging Format is used to 
communicate debugging information between a compiler and debugger to make it easier for programmers 
to develop, test, and debug programs.


DWARF is used by a wide range of compilers and debuggers, both proprietary and open source, to 
support debugging of Ada, C, C++, Cobol, FORTRAN, Java, and other programming languages. DWARF V5 
adds support for new languages like Rust, Swift, Ocaml, Go, and Haskell, as well as support for new 
features in older languages. DWARF can be used with a wide range of processor architectures, such as 
x86, ARM, PowerPC, from 8-bit to 64-bit.


DWARF is the standard debugging format for Linux and several versions of Unix and is widely used 
with embedded processors. DWARF is designed to be extended easily to support new languages and new 
architectures.


The DWARF Version 5 Standard has been in development for six years. DWARF Committee members include 
representatives from over a dozen major companies with extensive experience in compiler and debugger 
development. Version 5 incorporates improvements in many areas: better data compression, separation 
of debugging data from executable files, improved description of macros and source files, faster 
searching for symbols, improved debugging of optimized code, as well as numerous improvements in 
functionality and performance.


The DWARF Version 5 Standard can be downloaded without charge from the DWARF website (dwarfstd.org). 
Additional information about DWARF, including how to subscribe to the DWARF mailing list, can also 
be found on the website. Questions about the DWARF Debugging Information Format or the DWARF 
Committee can be directed to the DWARF Committee Chair, Michael Eager at i...@dwarfstd.org.


--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077
___
Dwarf-Discuss mailing list
dwarf-disc...@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org
--- End Message ---


[Bug libdw/21174] New: libdw with perf: duplication of entries in callstack

2017-02-16 Thread thommyj at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=21174

Bug ID: 21174
   Summary: libdw with perf: duplication of entries in callstack
   Product: elfutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: libdw
  Assignee: unassigned at sourceware dot org
  Reporter: thommyj at gmail dot com
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Hi,

running perf together with libdw for stack unwinding using dwarf on an
arm64 board. I'm a bit puzzled of the callstack that is unwinded.
Sometimes I get the same entry twice out from libdw

Normal sample:
23_HalInterrupt   462  1087.469883:6802721 cpu-clock:
 6e3628 IBUFDIST_distribute (/usr/local/bin/Application)
 6f33bc endOfFrame (/usr/local/bin/Application)
 6f2fcc interrupt (/usr/local/bin/Application)
 6f8c9c interruptHandler (/usr/local/bin/Application)
 6f7130 taskFunction (/usr/local/bin/Application)
 7fae555df8 [unknown] (/lib/libpthread-2.19-2014.08.so)

Sample with duplicated entries
23_HalInterrupt   462  1028.701041:6802721 cpu-clock:
 6e3628 IBUFDIST_distribute (/usr/local/bin/Application)
 6e3628 IBUFDIST_distribute (/usr/local/bin/Application)
 6f33bc endOfFrame (/usr/local/bin/Application)
 6f2fcc interrupt (/usr/local/bin/Application)
 6f8c9c interruptHandler (/usr/local/bin/Application)
 6f7130 taskFunction (/usr/local/bin/Application)
 7fae555df8 [unknown] (/lib/libpthread-2.19-2014.08.so)

Sometimes it is the same address for the duplicate entry, sometimes
its different addresses but same symbol name. Its not always the first
entry, but seems to be more likely on first.

Is this a known problem?

BR,
Thommy Jakobsson

#record
>>perf record -t 462 -F 147 -g --call-graph dwarf -o halinter2.perf sleep 30
#dump data
>>perf script -i halinter2.perf

linux 4.4
elfutils 0.163
aarch64-linux-gnu-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro
GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)
Copyright (C) 2014 Free Software Found

-- 
You are receiving this mail because:
You are on the CC list for the bug.