[packages/gdb] updated to 7.7.1 updated build-id patches from fedora
bszx
bszx at pld-linux.org
Thu Jun 5 20:43:35 CEST 2014
commit 321e94d61aceab20eb50bc5296671301ab33cc26
Author: Bartek Szady <bszx at bszx.eu>
Date: Thu Jun 5 20:38:03 2014 +0200
updated to 7.7.1
updated build-id patches from fedora
buildid-locate-rpm-pld.patch | 6 +-
floatformat_ibm_long_double.patch | 152 --
gdb-6.6-buildid-locate-core-as-arg.patch | 38 +-
...ding-warning-missing-debuginfo-rhbz981154.patch | 131 ++
gdb-6.6-buildid-locate-rpm-librpm-workaround.patch | 32 +-
gdb-6.6-buildid-locate-rpm.patch | 2479 ++++++++++----------
gdb-6.6-buildid-locate.patch | 540 +++--
gdb-gdb-add-index-script.patch | 18 +-
gdb-info.patch | 24 +-
gdb-pretty-print-by-default.patch | 16 +-
gdb.spec | 21 +-
11 files changed, 1779 insertions(+), 1678 deletions(-)
---
diff --git a/gdb.spec b/gdb.spec
index 77d8433..101b813 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -19,12 +19,12 @@ Summary(zh_CN.UTF-8): [开发]C和其他语言的调试器
Summary(zh_TW.UTF-8): [.-A開發]C和.$)B其.-A他語.$)B言的調試器
%define snap 20120926
Name: gdb
-Version: 7.6.2
-Release: 1
+Version: 7.7.1
+Release: 0.1
License: GPL v3+
Group: Development/Debuggers
Source0: http://ftp.gnu.org/gnu/gdb/%{name}-%{version}.tar.bz2
-# Source0-md5: 496399e96654fc0f899a5c964bc1f0f8
+# Source0-md5: 77b20b515e7c25f032cb9732a66620fe
Source1: http://www.mif.pg.gda.pl/homepages/ankry/man-PLD/%{name}-non-english-man-pages.tar.bz2
# Source1-md5: 2e8a48939ae282c12bbacdd54e398247
Source3: %{name}-gstack.man
@@ -33,9 +33,9 @@ Patch101: gdb-6.6-buildid-locate-solib-missing-ids.patch
Patch102: gdb-6.6-buildid-locate-rpm.patch
Patch103: gdb-6.6-buildid-locate-core-as-arg.patch
Patch104: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
-Patch105: gdb-6.3-gstack-20050411.patch
-Patch106: gdb-gdb-add-index-script.patch
-Patch107: floatformat_ibm_long_double.patch
+Patch105: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
+Patch110: gdb-6.3-gstack-20050411.patch
+Patch111: gdb-gdb-add-index-script.patch
Patch1000: %{name}-readline.patch
Patch1001: %{name}-info.patch
Patch1002: %{name}-passflags.patch
@@ -175,8 +175,8 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch103 -p1
%patch104 -p1
%patch105 -p1
-%patch106 -p1
-%patch107 -p1
+%patch110 -p1
+%patch111 -p1
%patch1000 -p1
%patch1001 -p1
@@ -282,7 +282,7 @@ install libdecnumber/libdecnumber.a $RPM_BUILD_ROOT%{_libdir}
%{__rm} $RPM_BUILD_ROOT%{_infodir}/{bfd,configure,standards}.info*
%{__rm} $RPM_BUILD_ROOT%{_includedir}/{ansidecl,bfd,bfdlink,dis-asm,symcat}.h
%{__rm} $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.la
-%{__rm} $RPM_BUILD_ROOT%{_libdir}/lib{bfd,iberty,opcodes}.a
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.a
%clean
rm -rf $RPM_BUILD_ROOT
@@ -300,6 +300,7 @@ rm -rf $RPM_BUILD_ROOT
%attr(755,root,root) %{_bindir}/gdbtui
%attr(755,root,root) %{_bindir}/gdb-add-index
%attr(755,root,root) %{_bindir}/gstack
+%attr(755,root,root) %{_bindir}/gcore
%dir %{_datadir}/gdb
%dir %{_datadir}/gdb/auto-load
%dir %{_datadir}/gdb/auto-load%{_prefix}
@@ -312,6 +313,7 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/gdb.1*
%{_mandir}/man1/gdbtui.1*
%{_mandir}/man1/gstack.1*
+%{_mandir}/man1/gcore.1*
%lang(es) %{_mandir}/es/man1/*
%lang(fr) %{_mandir}/fr/man1/*
%lang(hu) %{_mandir}/hu/man1/*
@@ -319,7 +321,6 @@ rm -rf $RPM_BUILD_ROOT
%lang(pl) %{_mandir}/pl/man1/*
%{_infodir}/annotate.info*
%{_infodir}/gdb.info*
-%{_infodir}/gdbint.info*
%{_infodir}/stabs.info*
%files gdbserver
diff --git a/buildid-locate-rpm-pld.patch b/buildid-locate-rpm-pld.patch
index aa146d6..5bef82d 100644
--- a/buildid-locate-rpm-pld.patch
+++ b/buildid-locate-rpm-pld.patch
@@ -1,6 +1,6 @@
---- gdb-7.5.0.20120926/gdb/elfread.c.orig 2012-11-18 20:50:42.844619396 +0100
-+++ gdb-7.5.0.20120926/gdb/elfread.c 2012-11-18 20:52:37.756554669 +0100
-@@ -2237,8 +2237,8 @@
+--- gdb-7.7.1/gdb/build-id.c.old 2014-06-05 14:31:11.000000000 +0200
++++ gdb-7.7.1/gdb/build-id.c 2014-06-05 14:33:12.248235380 +0200
+@@ -1190,8 +1190,8 @@
fprintf_unfiltered (gdb_stdlog,
_("Missing separate debuginfo for %s\n"), binary);
if (debug != NULL)
diff --git a/floatformat_ibm_long_double.patch b/floatformat_ibm_long_double.patch
deleted file mode 100644
index e803e30..0000000
--- a/floatformat_ibm_long_double.patch
+++ /dev/null
@@ -1,152 +0,0 @@
-https://sourceware.org/ml/gdb-patches/2013-08/msg00483.html
-
-diff --git a/include/floatformat.h b/include/floatformat.h
-index b595164..04db61a 100644
---- a/include/floatformat.h
-+++ b/include/floatformat.h
-@@ -128,7 +128,8 @@ extern const struct floatformat floatformat_ia64_spill_little;
- extern const struct floatformat floatformat_ia64_quad_big;
- extern const struct floatformat floatformat_ia64_quad_little;
- /* IBM long double (double+double). */
--extern const struct floatformat floatformat_ibm_long_double;
-+extern const struct floatformat floatformat_ibm_long_double_big;
-+extern const struct floatformat floatformat_ibm_long_double_little;
-
- /* Convert from FMT to a double.
- FROM is the address of the extended float.
-diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
-index c58ab01..789fa05 100644
---- a/libiberty/floatformat.c
-+++ b/libiberty/floatformat.c
-@@ -371,14 +371,23 @@ floatformat_ibm_long_double_is_valid (const struct floatformat *fmt,
- }
- }
-
--const struct floatformat floatformat_ibm_long_double =
-+const struct floatformat floatformat_ibm_long_double_big =
- {
- floatformat_big, 128, 0, 1, 11, 1023, 2047, 12, 52,
- floatformat_intbit_no,
-- "floatformat_ibm_long_double",
-+ "floatformat_ibm_long_double_big",
- floatformat_ibm_long_double_is_valid,
- &floatformat_ieee_double_big
- };
-+
-+const struct floatformat floatformat_ibm_long_double_little =
-+{
-+ floatformat_little, 128, 0, 1, 11, 1023, 2047, 12, 52,
-+ floatformat_intbit_no,
-+ "floatformat_ibm_long_double_little",
-+ floatformat_ibm_long_double_is_valid,
-+ &floatformat_ieee_double_little
-+};
-
-
- #ifndef min
---
-1.7.1
-
-diff --git a/gdb/doublest.c b/gdb/doublest.c
-index 2e4c87e..85890b1 100644
---- a/gdb/doublest.c
-+++ b/gdb/doublest.c
-@@ -190,7 +190,8 @@ convert_floatformat_to_doublest (const struct floatformat *fmt,
- {
- double dto;
-
-- floatformat_to_double (fmt, from, &dto);
-+ floatformat_to_double (fmt->split_half ? fmt->split_half : fmt,
-+ from, &dto);
- *to = (DOUBLEST) dto;
- return;
- }
-@@ -514,6 +515,11 @@ floatformat_is_negative (const struct floatformat *fmt,
- gdb_assert (fmt->totalsize
- <= FLOATFORMAT_LARGEST_BYTES * FLOATFORMAT_CHAR_BIT);
-
-+ /* An IBM long double (a two element array of double) always takes the
-+ sign of the first double. */
-+ if (fmt->split_half)
-+ fmt = fmt->split_half;
-+
- order = floatformat_normalize_byteorder (fmt, uval, newfrom);
-
- if (order != fmt->byteorder)
-@@ -540,6 +546,13 @@ floatformat_classify (const struct floatformat *fmt,
- gdb_assert (fmt->totalsize
- <= FLOATFORMAT_LARGEST_BYTES * FLOATFORMAT_CHAR_BIT);
-
-+ /* An IBM long double (a two element array of double) can be classified
-+ by looking at the first double. inf and nan are specified as
-+ ignoring the second double. zero and subnormal will always have
-+ the second double 0.0 if the long double is correctly rounded. */
-+ if (fmt->split_half)
-+ fmt = fmt->split_half;
-+
- order = floatformat_normalize_byteorder (fmt, uval, newfrom);
-
- if (order != fmt->byteorder)
-@@ -622,6 +635,16 @@ floatformat_mantissa (const struct floatformat *fmt,
- gdb_assert (fmt->totalsize
- <= FLOATFORMAT_LARGEST_BYTES * FLOATFORMAT_CHAR_BIT);
-
-+ /* For IBM long double (a two element array of double), return the
-+ mantissa of the first double. The problem with returning the
-+ actual mantissa from both doubles is that there can be an
-+ arbitrary number of implied 0's or 1's between the mantissas
-+ of the first and second double. In any case, this function
-+ is only used for dumping out nans, and a nan is specified to
-+ ignore the value in the second double. */
-+ if (fmt->split_half)
-+ fmt = fmt->split_half;
-+
- order = floatformat_normalize_byteorder (fmt, uval, newfrom);
-
- if (order != fmt->byteorder)
-@@ -879,27 +902,3 @@ convert_typed_floating (const void *from, const struct type *from_type,
- floatformat_from_doublest (to_fmt, &d, to);
- }
- }
--
--const struct floatformat *floatformat_ieee_single[BFD_ENDIAN_UNKNOWN];
--const struct floatformat *floatformat_ieee_double[BFD_ENDIAN_UNKNOWN];
--const struct floatformat *floatformat_ieee_quad[BFD_ENDIAN_UNKNOWN];
--const struct floatformat *floatformat_arm_ext[BFD_ENDIAN_UNKNOWN];
--const struct floatformat *floatformat_ia64_spill[BFD_ENDIAN_UNKNOWN];
--
--extern void _initialize_doublest (void);
--
--extern void
--_initialize_doublest (void)
--{
-- floatformat_ieee_single[BFD_ENDIAN_LITTLE] = &floatformat_ieee_single_little;
-- floatformat_ieee_single[BFD_ENDIAN_BIG] = &floatformat_ieee_single_big;
-- floatformat_ieee_double[BFD_ENDIAN_LITTLE] = &floatformat_ieee_double_little;
-- floatformat_ieee_double[BFD_ENDIAN_BIG] = &floatformat_ieee_double_big;
-- floatformat_arm_ext[BFD_ENDIAN_LITTLE]
-- = &floatformat_arm_ext_littlebyte_bigword;
-- floatformat_arm_ext[BFD_ENDIAN_BIG] = &floatformat_arm_ext_big;
-- floatformat_ia64_spill[BFD_ENDIAN_LITTLE] = &floatformat_ia64_spill_little;
-- floatformat_ia64_spill[BFD_ENDIAN_BIG] = &floatformat_ia64_spill_big;
-- floatformat_ieee_quad[BFD_ENDIAN_LITTLE] = &floatformat_ia64_quad_little;
-- floatformat_ieee_quad[BFD_ENDIAN_BIG] = &floatformat_ia64_quad_big;
--}
-diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
-index d19c593..dd2ef96 100644
---- a/gdb/gdbtypes.c
-+++ b/gdb/gdbtypes.c
-@@ -108,8 +108,8 @@ const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN] = {
- &floatformat_vax_d
- };
- const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN] = {
-- &floatformat_ibm_long_double,
-- &floatformat_ibm_long_double
-+ &floatformat_ibm_long_double_big,
-+ &floatformat_ibm_long_double_little
- };
-
- /* Should opaque types be resolved? */
---
-1.7.1
-
diff --git a/gdb-6.6-buildid-locate-core-as-arg.patch b/gdb-6.6-buildid-locate-core-as-arg.patch
index efacab5..ffe0b40 100644
--- a/gdb-6.6-buildid-locate-core-as-arg.patch
+++ b/gdb-6.6-buildid-locate-core-as-arg.patch
@@ -58,13 +58,13 @@ Http://sourceware.org/ml/gdb-patches/2010-01/msg00517.html
* exec.c (exec_file_attach): Print a more useful error message if the
user did "gdb core".
-Index: gdb-7.5.91.20130323/gdb/exceptions.h
+Index: gdb-7.6.90.20140127/gdb/exceptions.h
===================================================================
---- gdb-7.5.91.20130323.orig/gdb/exceptions.h 2013-03-22 21:41:45.000000000 +0100
-+++ gdb-7.5.91.20130323/gdb/exceptions.h 2013-03-23 19:49:05.738459185 +0100
-@@ -90,6 +90,9 @@ enum errors {
- aborted as the inferior state is no longer valid. */
- TARGET_CLOSE_ERROR,
+--- gdb-7.6.90.20140127.orig/gdb/exceptions.h 2014-02-06 17:31:00.148529736 +0100
++++ gdb-7.6.90.20140127/gdb/exceptions.h 2014-02-06 17:31:17.560548525 +0100
+@@ -97,6 +97,9 @@ enum errors {
+ /* An undefined command was executed. */
+ UNDEFINED_COMMAND_ERROR,
+ /* Attempt to load a core file as executable. */
+ IS_CORE_ERROR,
@@ -72,10 +72,10 @@ Index: gdb-7.5.91.20130323/gdb/exceptions.h
/* Add more errors here. */
NR_ERRORS
};
-Index: gdb-7.5.91.20130323/gdb/exec.c
+Index: gdb-7.6.90.20140127/gdb/exec.c
===================================================================
---- gdb-7.5.91.20130323.orig/gdb/exec.c 2013-01-31 19:37:37.000000000 +0100
-+++ gdb-7.5.91.20130323/gdb/exec.c 2013-03-23 19:48:53.284575912 +0100
+--- gdb-7.6.90.20140127.orig/gdb/exec.c 2014-02-06 17:30:58.266527708 +0100
++++ gdb-7.6.90.20140127/gdb/exec.c 2014-02-06 17:31:00.149529737 +0100
@@ -34,6 +34,7 @@
#include "gdbthread.h"
#include "progspace.h"
@@ -84,7 +84,7 @@ Index: gdb-7.5.91.20130323/gdb/exec.c
#include <fcntl.h>
#include "readline/readline.h"
-@@ -240,12 +241,27 @@ exec_file_attach (char *filename, int fr
+@@ -228,12 +229,27 @@ exec_file_attach (char *filename, int fr
if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
{
@@ -114,12 +114,12 @@ Index: gdb-7.5.91.20130323/gdb/exec.c
+ gdb_bfd_errmsg (bfd_get_error (), matching));
}
- /* FIXME - This should only be run for RS6000, but the ifdef is a poor
-Index: gdb-7.5.91.20130323/gdb/main.c
+ if (build_section_table (exec_bfd, §ions, §ions_end))
+Index: gdb-7.6.90.20140127/gdb/main.c
===================================================================
---- gdb-7.5.91.20130323.orig/gdb/main.c 2013-03-23 19:48:18.000000000 +0100
-+++ gdb-7.5.91.20130323/gdb/main.c 2013-03-23 19:48:53.285575901 +0100
-@@ -296,6 +296,36 @@ typedef struct cmdarg {
+--- gdb-7.6.90.20140127.orig/gdb/main.c 2014-02-06 17:30:58.267527709 +0100
++++ gdb-7.6.90.20140127/gdb/main.c 2014-02-06 17:32:32.232629052 +0100
+@@ -307,6 +307,36 @@ typedef struct cmdarg {
/* Define type VEC (cmdarg_s). */
DEF_VEC_O (cmdarg_s);
@@ -156,7 +156,7 @@ Index: gdb-7.5.91.20130323/gdb/main.c
static int
captured_main (void *data)
{
-@@ -796,6 +826,8 @@ captured_main (void *data)
+@@ -824,6 +854,8 @@ captured_main (void *data)
{
symarg = argv[optind];
execarg = argv[optind];
@@ -165,7 +165,7 @@ Index: gdb-7.5.91.20130323/gdb/main.c
optind++;
}
-@@ -951,11 +983,25 @@ captured_main (void *data)
+@@ -987,11 +1019,25 @@ captured_main (void *data)
&& symarg != NULL
&& strcmp (execarg, symarg) == 0)
{
@@ -191,6 +191,6 @@ Index: gdb-7.5.91.20130323/gdb/main.c
+ as a core file. */
+ if (catch_command_errors (func, execarg, !batch_flag, RETURN_MASK_ALL)
+ && core_bfd == NULL)
- catch_command_errors (symbol_file_add_main, symarg,
- !batch_flag, RETURN_MASK_ALL);
+ catch_command_errors_const (symbol_file_add_main, symarg,
+ !batch_flag, RETURN_MASK_ALL);
}
diff --git a/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch b/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
new file mode 100644
index 0000000..044a408
--- /dev/null
+++ b/gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
@@ -0,0 +1,131 @@
+Comments by Sergio Durigan Junior <sergiodj at redhat.com>:
+
+ This is the fix for RH BZ #981154
+
+ It is mainly a testcase addition, but a minor fix in the gdb/build-id.c
+ file was also needed.
+
+ gdb/build-id.c was added by:
+
+ commit dc294be54c96414035eed7d53dafdea0a6f31a72
+ Author: Tom Tromey <tromey at redhat.com>
+ Date: Tue Oct 8 19:56:15 2013 +0000
+
+ and had a little thinko there. The variable 'filename' needs to be set to
+ NULL after it is free'd, otherwise the code below thinks that it is still
+ valid and doesn't print the necessary warning ("Try: yum install ...").
+
+Index: gdb-7.7/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
+===================================================================
+--- /dev/null
++++ gdb-7.7/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
+@@ -0,0 +1,97 @@
++# Copyright (C) 2014 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program 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 a copy of the GNU General Public License
++# along with this program. If not, see <http://www.gnu.org/licenses/>.
++
++standard_testfile "normal.c"
++
++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
++ return -1
++}
++
++# Get the build-id of the file
++set build_id_debug_file [build_id_debug_filename_get $binfile]
++regsub -all ".debug$" $build_id_debug_file "" build_id_without_debug
++
++# Run to main
++if { ![runto_main] } {
++ return -1
++}
++
++# We first need to generate a corefile
++set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
++set core_supported 0
++gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \
++ "save a corefile" \
++{
++ -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
++ pass "save a corefile"
++ global core_supported
++ set core_supported 1
++ }
++ -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
++ unsupported "save a corefile"
++ global core_supported
++ set core_supported 0
++ }
++}
++
++if {!$core_supported} {
++ return -1
++}
++
++# Move the binfile to a temporary name
++remote_exec build "mv $binfile ${binfile}.old"
++
++# Reinitialize GDB and see if we get a yum warning
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++
++with_test_prefix "first run:" {
++ gdb_test "set build-id-verbose 1" "" \
++ "set build-id-verbose"
++
++ gdb_test "set debug-file-directory ${objdir}/${subdir}" "" \
++ "set debug-file-directory"
++
++ gdb_test "core-file ${objdir}/${subdir}/gcore.test" \
++ "Missing separate debuginfo for the main executable file\r\nTry: yum --enablerepo='\\*debug\\*' install $objdir/$subdir/$build_id_without_debug\r\n.*" \
++ "test first yum warning"
++}
++
++# Now we define and create our .build-id
++file mkdir [file dirname ${objdir}/${subdir}/${build_id_without_debug}]
++# Cannot use "file link" (from TCL) because it requires the target file to
++# exist.
++remote_exec build "ln -s $binfile ${objdir}/${subdir}/${build_id_without_debug}"
++
++# Reinitialize GDB to get the second yum warning
++gdb_exit
++gdb_start
++gdb_reinitialize_dir $srcdir/$subdir
++
++with_test_prefix "second run:" {
++ gdb_test "set build-id-verbose 1" "" \
++ "set build-id-verbose"
++
++ gdb_test "set debug-file-directory ${objdir}/${subdir}" "" \
++ "set debug-file-directory"
++
++ gdb_test "core-file ${objdir}/${subdir}/gcore.test" \
++ "Missing separate debuginfo for the main executable file\r\nTry: yum --enablerepo='\\*debug\\*' install $binfile\r\n.*" \
++ "test second yum warning"
++}
++
++# Leaving the link there will cause breakage in the next run.
++remote_exec build "rm -f ${objdir}/${subdir}/${build_id_without_debug}"
+Index: gdb-7.7/gdb/build-id.c
+===================================================================
+--- gdb-7.7.orig/gdb/build-id.c
++++ gdb-7.7/gdb/build-id.c
+@@ -588,6 +588,7 @@ build_id_to_debug_bfd (size_t build_id_l
+ if (abfd == NULL)
+ {
+ xfree (filename);
++ filename = NULL;
+ continue;
+ }
+
diff --git a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
index 617bef9..3378717 100644
--- a/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
+++ b/gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
@@ -1,8 +1,20 @@
-Index: gdb-7.4.50.20120602/gdb/elfread.c
+Index: gdb-7.6.90.20140127/gdb/proc-service.list
===================================================================
---- gdb-7.4.50.20120602.orig/gdb/elfread.c 2012-06-02 21:35:09.669510757 +0200
-+++ gdb-7.4.50.20120602/gdb/elfread.c 2012-06-02 21:35:31.106502660 +0200
-@@ -1658,6 +1658,19 @@ build_id_to_filename (struct build_id *b
+--- gdb-7.6.90.20140127.orig/gdb/proc-service.list 2014-02-06 17:32:42.810640320 +0100
++++ gdb-7.6.90.20140127/gdb/proc-service.list 2014-02-06 17:33:35.406696964 +0100
+@@ -37,4 +37,7 @@
+ ps_pstop;
+ ps_ptread;
+ ps_ptwrite;
++
++ /* gdb-6.6-buildid-locate-rpm.patch */
++ rpmsqEnable;
+ };
+Index: gdb-7.6.90.20140127/gdb/build-id.c
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/build-id.c 2014-02-06 17:30:14.230480264 +0100
++++ gdb-7.6.90.20140127/gdb/build-id.c 2014-02-06 17:34:28.846754283 +0100
+@@ -677,6 +677,19 @@ build_id_to_filename (const struct elf_b
#include <dlfcn.h>
#endif
@@ -22,15 +34,3 @@ Index: gdb-7.4.50.20120602/gdb/elfread.c
/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
and avoid their duplicities during a single inferior run. */
-Index: gdb-7.4.50.20120602/gdb/proc-service.list
-===================================================================
---- gdb-7.4.50.20120602.orig/gdb/proc-service.list 2012-06-02 21:35:09.669510757 +0200
-+++ gdb-7.4.50.20120602/gdb/proc-service.list 2012-06-02 21:35:14.296508989 +0200
-@@ -37,4 +37,7 @@
- ps_pstop;
- ps_ptread;
- ps_ptwrite;
-+
-+ /* gdb-6.6-buildid-locate-rpm.patch */
-+ rpmsqEnable;
- };
diff --git a/gdb-6.6-buildid-locate-rpm.patch b/gdb-6.6-buildid-locate-rpm.patch
index 8289bae..77b2ca4 100644
--- a/gdb-6.6-buildid-locate-rpm.patch
+++ b/gdb-6.6-buildid-locate-rpm.patch
@@ -1,25 +1,25 @@
-Index: gdb-7.6/gdb/event-top.c
+Index: gdb-7.6.90.20140127/gdb/event-top.c
===================================================================
---- gdb-7.6.orig/gdb/event-top.c 2013-01-31 19:37:37.000000000 +0100
-+++ gdb-7.6/gdb/event-top.c 2013-07-17 19:51:02.679357656 +0200
-@@ -36,6 +36,7 @@
- #include "continuations.h"
+--- gdb-7.6.90.20140127.orig/gdb/event-top.c 2014-02-06 17:18:26.965717210 +0100
++++ gdb-7.6.90.20140127/gdb/event-top.c 2014-02-06 16:59:23.174474404 +0100
+@@ -37,6 +37,7 @@
#include "gdbcmd.h" /* for dont_repeat() */
#include "annotate.h"
+ #include "maint.h"
+#include "symfile.h"
/* readline include files. */
#include "readline/readline.h"
-@@ -170,6 +171,8 @@ rl_callback_read_char_wrapper (gdb_clien
+@@ -173,6 +174,8 @@ rl_callback_read_char_wrapper (gdb_clien
void
- cli_command_loop (void)
+ cli_command_loop (void *data)
{
+ debug_flush_missing ();
+
display_gdb_prompt (0);
/* Now it's time to start the event loop. */
-@@ -237,6 +240,8 @@ display_gdb_prompt (char *new_prompt)
+@@ -240,6 +243,8 @@ display_gdb_prompt (char *new_prompt)
/* Reset the nesting depth used when trace-commands is set. */
reset_command_nest_depth ();
@@ -28,813 +28,914 @@ Index: gdb-7.6/gdb/event-top.c
/* Each interpreter has its own rules on displaying the command
prompt. */
if (!current_interp_display_prompt_p ())
-Index: gdb-7.6/gdb/elfread.c
+Index: gdb-7.6.90.20140127/gdb/symfile.h
===================================================================
---- gdb-7.6.orig/gdb/elfread.c 2013-07-17 19:51:02.639357629 +0200
-+++ gdb-7.6/gdb/elfread.c 2013-07-17 19:51:50.738390068 +0200
-@@ -49,6 +49,7 @@
- #include "gdbcore.h"
- #include "gdbcmd.h"
- #include "observer.h"
-+#include "elf/external.h"
- #include <sys/stat.h>
+--- gdb-7.6.90.20140127.orig/gdb/symfile.h 2014-02-06 17:18:33.865724666 +0100
++++ gdb-7.6.90.20140127/gdb/symfile.h 2014-02-06 17:08:56.282099150 +0100
+@@ -557,6 +557,8 @@ extern struct cleanup *increment_reading
+ /* build-id support. */
+ extern struct elf_build_id *build_id_addr_get (CORE_ADDR addr);
+ extern void debug_print_missing (const char *binary, const char *debug);
++extern void debug_flush_missing (void);
++#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
- extern void _initialize_elfread (void);
-@@ -1682,8 +1683,360 @@ build_id_to_filename (const struct elf_b
- return retval;
- }
+ /* From dwarf2read.c */
-+#ifdef HAVE_LIBRPM
+Index: gdb-7.6.90.20140127/gdb/testsuite/lib/gdb.exp
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/testsuite/lib/gdb.exp 2014-02-06 17:18:26.969717214 +0100
++++ gdb-7.6.90.20140127/gdb/testsuite/lib/gdb.exp 2014-02-06 17:18:33.866724667 +0100
+@@ -1504,7 +1504,7 @@ proc default_gdb_start { } {
+ warning "Couldn't set the width to 0."
+ }
+ }
+- # Turn off the missing warnings as the testsuite does not expect it.
++ # Turn off the missing RPMs warnings as the testsuite does not expect it.
+ send_gdb "set build-id-verbose 0\n"
+ gdb_expect 10 {
+ -re "$gdb_prompt $" {
+Index: gdb-7.6.90.20140127/gdb/testsuite/lib/mi-support.exp
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/testsuite/lib/mi-support.exp 2014-02-06 17:18:26.970717215 +0100
++++ gdb-7.6.90.20140127/gdb/testsuite/lib/mi-support.exp 2014-02-06 17:18:33.867724668 +0100
+@@ -212,7 +212,7 @@ proc default_mi_gdb_start { args } {
+ warning "Couldn't set the width to 0."
+ }
+ }
+- # Turn off the missing warnings as the testsuite does not expect it.
++ # Turn off the missing RPMs warnings as the testsuite does not expect it.
+ send_gdb "190-gdb-set build-id-verbose 0\n"
+ gdb_expect 10 {
+ -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
+Index: gdb-7.6.90.20140127/gdb/tui/tui-interp.c
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/tui/tui-interp.c 2014-02-06 17:18:26.970717215 +0100
++++ gdb-7.6.90.20140127/gdb/tui/tui-interp.c 2014-02-06 17:18:33.867724668 +0100
+@@ -30,6 +30,7 @@
+ #include "tui/tui.h"
+ #include "tui/tui-io.h"
+ #include "exceptions.h"
++#include "symfile.h"
+
+ /* Set to 1 when the TUI mode must be activated when we first start
+ gdb. */
+Index: gdb-7.6.90.20140127/gdb/aclocal.m4
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/aclocal.m4 2014-02-06 17:18:33.868724669 +0100
++++ gdb-7.6.90.20140127/gdb/aclocal.m4 2014-02-06 17:09:49.877157405 +0100
+@@ -11,6 +11,221 @@
+ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ # PARTICULAR PURPOSE.
+
++# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
++# serial 1 (pkg-config-0.24)
++#
++# Copyright © 2004 Scott James Remnant <scott at netsplit.com>.
++#
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of 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.
++#
++# This program 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 a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
++#
++# As a special exception to the GNU General Public License, if you
++# distribute this file as part of a program that contains a
++# configuration script generated by Autoconf, you may include it under
++# the same distribution terms that you use for the rest of that program.
+
-+#include <rpm/rpmlib.h>
-+#include <rpm/rpmts.h>
-+#include <rpm/rpmdb.h>
-+#include <rpm/header.h>
-+#ifdef DLOPEN_LIBRPM
-+#include <dlfcn.h>
-+#endif
++# PKG_PROG_PKG_CONFIG([MIN-VERSION])
++# ----------------------------------
++AC_DEFUN([PKG_PROG_PKG_CONFIG],
++[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
++m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
++m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
++AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
++AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
++AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
-+/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
-+ and avoid their duplicities during a single inferior run. */
++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
++ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
++fi
++if test -n "$PKG_CONFIG"; then
++ _pkg_min_version=m4_default([$1], [0.9.0])
++ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
++ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
++ AC_MSG_RESULT([yes])
++ else
++ AC_MSG_RESULT([no])
++ PKG_CONFIG=""
++ fi
++fi[]dnl
++])# PKG_PROG_PKG_CONFIG
+
-+static struct htab *missing_rpm_hash;
++# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
++#
++# Check to see whether a particular set of modules exists. Similar
++# to PKG_CHECK_MODULES(), but does not set variables or print errors.
++#
++# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
++# only at the first occurence in configure.ac, so if the first place
++# it's called might be skipped (such as if it is within an "if", you
++# have to call PKG_CHECK_EXISTS manually
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_EXISTS],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++if test -n "$PKG_CONFIG" && \
++ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
++ m4_default([$2], [:])
++m4_ifvaln([$3], [else
++ $3])dnl
++fi])
+
-+/* This MISSING_RPM_LIST tracker is used to collect and print as a single line
-+ all the rpms right before the nearest GDB prompt. It gets cleared after
-+ each such print (it is questionable if we should clear it after the print).
-+ */
++# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
++# ---------------------------------------------
++m4_define([_PKG_CONFIG],
++[if test -n "$$1"; then
++ pkg_cv_[]$1="$$1"
++ elif test -n "$PKG_CONFIG"; then
++ PKG_CHECK_EXISTS([$3],
++ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
++ test "x$?" != "x0" && pkg_failed=yes ],
++ [pkg_failed=yes])
++ else
++ pkg_failed=untried
++fi[]dnl
++])# _PKG_CONFIG
+
-+struct missing_rpm
-+ {
-+ struct missing_rpm *next;
-+ char rpm[1];
-+ };
-+static struct missing_rpm *missing_rpm_list;
-+static int missing_rpm_list_entries;
++# _PKG_SHORT_ERRORS_SUPPORTED
++# -----------------------------
++AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
++ _pkg_short_errors_supported=yes
++else
++ _pkg_short_errors_supported=no
++fi[]dnl
++])# _PKG_SHORT_ERRORS_SUPPORTED
+
-+/* Returns the count of newly added rpms. */
+
-+static int
-+missing_rpm_enlist (const char *filename)
-+{
-+ static int rpm_init_done = 0;
-+ rpmts ts;
-+ rpmdbMatchIterator mi;
-+ int count = 0;
++# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
++# [ACTION-IF-NOT-FOUND])
++#
++#
++# Note that if there is a possibility the first call to
++# PKG_CHECK_MODULES might not happen, you should be sure to include an
++# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
++#
++#
++# --------------------------------------------------------------
++AC_DEFUN([PKG_CHECK_MODULES],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
++AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
-+#ifdef DLOPEN_LIBRPM
-+ /* Duplicate here the declarations to verify they match. The same sanity
-+ check is present also in `configure.ac'. */
-+ extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
-+ static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg);
-+ extern int rpmReadConfigFiles(const char * file, const char * target);
-+ static int (*rpmReadConfigFiles_p) (const char * file, const char * target);
-+ extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
-+ static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi);
-+ extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
-+ static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi);
-+ extern rpmts rpmtsCreate(void);
-+ static rpmts (*rpmtsCreate_p) (void);
-+ extern rpmts rpmtsFree(rpmts ts);
-+ static rpmts (*rpmtsFree_p) (rpmts ts);
-+ extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
-+ const void * keyp, size_t keylen);
-+ static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
-+ rpmTag rpmtag,
-+ const void *keyp,
-+ size_t keylen);
-+#else /* !DLOPEN_LIBRPM */
-+# define headerFormat_p headerFormat
-+# define rpmReadConfigFiles_p rpmReadConfigFiles
-+# define rpmdbFreeIterator_p rpmdbFreeIterator
-+# define rpmdbNextIterator_p rpmdbNextIterator
-+# define rpmtsCreate_p rpmtsCreate
-+# define rpmtsFree_p rpmtsFree
-+# define rpmtsInitIterator_p rpmtsInitIterator
-+#endif /* !DLOPEN_LIBRPM */
++pkg_failed=no
++AC_MSG_CHECKING([for $1])
+
-+ gdb_assert (filename != NULL);
++_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
++_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
-+ if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0)
-+ return 0;
++m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
++and $1[]_LIBS to avoid the need to call pkg-config.
++See the pkg-config man page for more details.])
+
-+ if (filename[0] != '/')
-+ {
-+ warning (_("Ignoring non-absolute filename: <%s>"), filename);
-+ return 0;
-+ }
++if test $pkg_failed = yes; then
++ AC_MSG_RESULT([no])
++ _PKG_SHORT_ERRORS_SUPPORTED
++ if test $_pkg_short_errors_supported = yes; then
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
++ else
++ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
++ fi
++ # Put the nasty error message in config.log where it belongs
++ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
-+ if (!rpm_init_done)
-+ {
-+ static int init_tried;
++ m4_default([$4], [AC_MSG_ERROR(
++[Package requirements ($2) were not met:
+
-+ /* Already failed the initialization before? */
-+ if (init_tried)
-+ return 0;
-+ init_tried = 1;
++$$1_PKG_ERRORS
+
-+#ifdef DLOPEN_LIBRPM
-+ {
-+ void *h;
++Consider adjusting the PKG_CONFIG_PATH environment variable if you
++installed software in a non-standard prefix.
+
-+ h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY);
-+ if (!h)
-+ {
-+ warning (_("Unable to open \"%s\" (%s), "
-+ "missing debuginfos notifications will not be displayed"),
-+ DLOPEN_LIBRPM, dlerror ());
-+ return 0;
-+ }
++_PKG_TEXT])[]dnl
++ ])
++elif test $pkg_failed = untried; then
++ AC_MSG_RESULT([no])
++ m4_default([$4], [AC_MSG_FAILURE(
++[The pkg-config script could not be found or is too old. Make sure it
++is in your PATH or set the PKG_CONFIG environment variable to the full
++path to pkg-config.
+
-+ if (!((headerFormat_p = dlsym (h, "headerFormat"))
-+ && (rpmReadConfigFiles_p = dlsym (h, "rpmReadConfigFiles"))
-+ && (rpmdbFreeIterator_p = dlsym (h, "rpmdbFreeIterator"))
-+ && (rpmdbNextIterator_p = dlsym (h, "rpmdbNextIterator"))
-+ && (rpmtsCreate_p = dlsym (h, "rpmtsCreate"))
-+ && (rpmtsFree_p = dlsym (h, "rpmtsFree"))
-+ && (rpmtsInitIterator_p = dlsym (h, "rpmtsInitIterator"))))
-+ {
-+ warning (_("Opened library \"%s\" is incompatible (%s), "
-+ "missing debuginfos notifications will not be displayed"),
-+ DLOPEN_LIBRPM, dlerror ());
-+ if (dlclose (h))
-+ warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM,
-+ dlerror ());
-+ return 0;
-+ }
-+ }
-+#endif /* DLOPEN_LIBRPM */
-+
-+ if (rpmReadConfigFiles_p (NULL, NULL) != 0)
-+ {
-+ warning (_("Error reading the rpm configuration files"));
-+ return 0;
-+ }
++_PKG_TEXT
+
-+ rpm_init_done = 1;
-+ }
++To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
++ ])
++else
++ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
++ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
++ AC_MSG_RESULT([yes])
++ $3
++fi[]dnl
++])# PKG_CHECK_MODULES
+
-+ ts = rpmtsCreate_p ();
+
-+ mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
-+ if (mi != NULL)
-+ {
-+ for (;;)
-+ {
-+ Header h;
-+ char *debuginfo, **slot, *s, *s2;
-+ errmsg_t err;
-+ size_t srcrpmlen = sizeof (".src.rpm") - 1;
-+ size_t debuginfolen = sizeof ("-debuginfo") - 1;
-+ rpmdbMatchIterator mi_debuginfo;
++# PKG_INSTALLDIR(DIRECTORY)
++# -------------------------
++# Substitutes the variable pkgconfigdir as the location where a module
++# should install pkg-config .pc files. By default the directory is
++# $libdir/pkgconfig, but the default can be changed by passing
++# DIRECTORY. The user can override through the --with-pkgconfigdir
++# parameter.
++AC_DEFUN([PKG_INSTALLDIR],
++[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
++m4_pushdef([pkg_description],
++ [pkg-config installation directory @<:@]pkg_default[@:>@])
++AC_ARG_WITH([pkgconfigdir],
++ [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
++ [with_pkgconfigdir=]pkg_default)
++AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
++m4_popdef([pkg_default])
++m4_popdef([pkg_description])
++]) dnl PKG_INSTALLDIR
++
++
++# PKG_NOARCH_INSTALLDIR(DIRECTORY)
++# -------------------------
++# Substitutes the variable noarch_pkgconfigdir as the location where a
++# module should install arch-independent pkg-config .pc files. By
++# default the directory is $datadir/pkgconfig, but the default can be
++# changed by passing DIRECTORY. The user can override through the
++# --with-noarch-pkgconfigdir parameter.
++AC_DEFUN([PKG_NOARCH_INSTALLDIR],
++[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
++m4_pushdef([pkg_description],
++ [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
++AC_ARG_WITH([noarch-pkgconfigdir],
++ [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
++ [with_noarch_pkgconfigdir=]pkg_default)
++AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
++m4_popdef([pkg_default])
++m4_popdef([pkg_description])
++]) dnl PKG_NOARCH_INSTALLDIR
++
++
++# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
++# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
++# -------------------------------------------
++# Retrieves the value of the pkg-config variable for the given module.
++AC_DEFUN([PKG_CHECK_VAR],
++[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
++AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
-+ h = rpmdbNextIterator_p (mi);
-+ if (h == NULL)
-+ break;
++_PKG_CONFIG([$1], [variable="][$3]["], [$2])
++AS_VAR_COPY([$1], [pkg_cv_][$1])
+
-+ /* Verify the debuginfo file is not already installed. */
++AS_VAR_IF([$1], [""], [$5], [$4])dnl
++])# PKG_CHECK_VAR
+
-+ debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}",
-+ &err);
-+ if (!debuginfo)
-+ {
-+ warning (_("Error querying the rpm file `%s': %s"), filename,
-+ err);
-+ continue;
-+ }
-+ /* s = `.src.rpm-debuginfo.%{arch}' */
-+ s = strrchr (debuginfo, '-') - srcrpmlen;
-+ s2 = NULL;
-+ if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0)
-+ {
-+ /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */
-+ s2 = memrchr (debuginfo, '-', s - debuginfo);
-+ }
-+ if (s2)
-+ {
-+ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
-+ s2 = memrchr (debuginfo, '-', s2 - debuginfo);
-+ }
-+ if (!s2)
-+ {
-+ warning (_("Error querying the rpm file `%s': %s"), filename,
-+ debuginfo);
-+ xfree (debuginfo);
-+ continue;
-+ }
-+ /* s = `.src.rpm-debuginfo.%{arch}' */
-+ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
-+ memmove (s2 + debuginfolen, s2, s - s2);
-+ memcpy (s2, "-debuginfo", debuginfolen);
-+ /* s = `XXXX.%{arch}' */
-+ /* strlen ("XXXX") == srcrpmlen + debuginfolen */
-+ /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */
-+ /* strlen ("XX") == srcrpmlen */
-+ memmove (s + debuginfolen, s + srcrpmlen + debuginfolen,
-+ strlen (s + srcrpmlen + debuginfolen) + 1);
-+ /* s = `-debuginfo-%{version}-%{release}.%{arch}' */
+ # AM_AUX_DIR_EXPAND -*- Autoconf -*-
+
+ # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
+Index: gdb-7.6.90.20140127/gdb/config.in
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/config.in 2014-02-06 17:18:26.971717216 +0100
++++ gdb-7.6.90.20140127/gdb/config.in 2014-02-06 17:18:33.868724669 +0100
+@@ -33,6 +33,9 @@
+ /* Define to BFD's default target vector. */
+ #undef DEFAULT_BFD_VEC
+
++/* librpm version specific library name to dlopen. */
++#undef DLOPEN_LIBRPM
+
-+ /* RPMDBI_PACKAGES requires keylen == sizeof (int). */
-+ /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */
-+ mi_debuginfo = rpmtsInitIterator_p (ts, RPMDBI_LABEL, debuginfo, 0);
-+ xfree (debuginfo);
-+ if (mi_debuginfo)
-+ {
-+ rpmdbFreeIterator_p (mi_debuginfo);
-+ count = 0;
-+ break;
-+ }
+ /* Define to 1 if translation of program messages to the user's native
+ language is requested. */
+ #undef ENABLE_NLS
+@@ -207,6 +210,9 @@
+ /* Define if Python 2.7 is being used. */
+ #undef HAVE_LIBPYTHON2_7
+
++/* Define if librpm library is being used. */
++#undef HAVE_LIBRPM
+
-+ /* The allocated memory gets utilized below for MISSING_RPM_HASH. */
-+ debuginfo = headerFormat_p (h,
-+ "%{name}-%{version}-%{release}.%{arch}",
-+ &err);
-+ if (!debuginfo)
-+ {
-+ warning (_("Error querying the rpm file `%s': %s"), filename,
-+ err);
-+ continue;
-+ }
+ /* Define to 1 if you have the <libunwind-ia64.h> header file. */
+ #undef HAVE_LIBUNWIND_IA64_H
+
+Index: gdb-7.6.90.20140127/gdb/configure
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/configure 2014-02-06 17:18:26.976717221 +0100
++++ gdb-7.6.90.20140127/gdb/configure 2014-02-06 17:18:33.872724673 +0100
+@@ -689,6 +689,11 @@ PKGVERSION
+ HAVE_NATIVE_GCORE_TARGET
+ TARGET_OBS
+ subdirs
++RPM_LIBS
++RPM_CFLAGS
++PKG_CONFIG_LIBDIR
++PKG_CONFIG_PATH
++PKG_CONFIG
+ GDB_DATADIR
+ DEBUGDIR
+ MAKEINFO_EXTRA_FLAGS
+@@ -792,6 +797,7 @@ with_gdb_datadir
+ with_relocated_sources
+ with_auto_load_dir
+ with_auto_load_safe_path
++with_rpm
+ enable_targets
+ enable_64_bit_bfd
+ enable_gdbcli
+@@ -842,6 +848,11 @@ CPPFLAGS
+ CPP
+ MAKEINFO
+ MAKEINFOFLAGS
++PKG_CONFIG
++PKG_CONFIG_PATH
++PKG_CONFIG_LIBDIR
++RPM_CFLAGS
++RPM_LIBS
+ YACC
+ YFLAGS
+ XMKMF'
+@@ -1512,6 +1523,8 @@ Optional Packages:
+ [--with-auto-load-dir]
+ --without-auto-load-safe-path
+ do not restrict auto-loaded files locations
++ --with-rpm query rpm database for missing debuginfos (yes/no,
++ def. auto=librpm.so)
+ --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets
+ --with-curses use the curses library instead of the termcap
+ library
+@@ -1559,6 +1572,13 @@ Some influential environment variables:
+ MAKEINFO Parent configure detects if it is of sufficient version.
+ MAKEINFOFLAGS
+ Parameters for MAKEINFO.
++ PKG_CONFIG path to pkg-config utility
++ PKG_CONFIG_PATH
++ directories to add to pkg-config's search path
++ PKG_CONFIG_LIBDIR
++ path overriding pkg-config's built-in search path
++ RPM_CFLAGS C compiler flags for RPM, overriding pkg-config
++ RPM_LIBS linker flags for RPM, overriding pkg-config
+ YACC The `Yet Another C Compiler' implementation to use. Defaults to
+ the first program found out of: `bison -y', `byacc', `yacc'.
+ YFLAGS The list of arguments that will be passed by default to $YACC.
+@@ -5154,6 +5174,491 @@ _ACEOF
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
+ $as_echo "$with_auto_load_safe_path" >&6; }
+
++# Integration with rpm library to support missing debuginfo suggestions.
++# --without-rpm: Disable any rpm support.
++# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
++# Even with runtime missing `libname.so' GDB will still other run correctly.
++# Missing `libname.so' during ./configure will abort the configuration.
++# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
++# minor version first such as `librpm-4.6.so' as minor version differences
++# mean API+ABI incompatibility. If the specific match versioned library name
++# could not be found still open dynamically at least `librpm.so'.
++# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
++# to find librpm for compilation-time linking by pkg-config. GDB binary will
++# be probably linked with the version specific library (as `librpm-4.6.so').
++# Failure to find librpm by pkg-config will abort the configuration.
++# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
++# cannot find librpm use to the rpmless compilation (like `--without-rpm').
+
-+ /* Base package name for `debuginfo-install'. We do not use the
-+ `yum' command directly as the line
-+ yum --enablerepo='*debug*' install NAME-debuginfo.ARCH
-+ would be more complicated than just:
-+ debuginfo-install NAME-VERSION-RELEASE.ARCH
-+ Do not supply the rpm base name (derived from .src.rpm name) as
-+ debuginfo-install is unable to install the debuginfo package if
-+ the base name PKG binary rpm is not installed while for example
-+ PKG-libs would be installed (RH Bug 467901).
-+ FUTURE: After multiple debuginfo versions simultaneously installed
-+ get supported the support for the VERSION-RELEASE tags handling
-+ may need an update. */
+
-+ if (missing_rpm_hash == NULL)
-+ {
-+ /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE
-+ should not deallocate the entries. */
++# Check whether --with-rpm was given.
++if test "${with_rpm+set}" = set; then :
++ withval=$with_rpm;
++else
++ with_rpm="auto"
++fi
+
-+ missing_rpm_hash = htab_create_alloc (64, htab_hash_string,
-+ (int (*) (const void *, const void *)) streq,
-+ NULL, xcalloc, xfree);
-+ }
-+ slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT);
-+ /* XCALLOC never returns NULL. */
-+ gdb_assert (slot != NULL);
-+ if (*slot == NULL)
-+ {
-+ struct missing_rpm *missing_rpm;
+
-+ *slot = debuginfo;
+
-+ missing_rpm = xmalloc (sizeof (*missing_rpm) + strlen (debuginfo));
-+ strcpy (missing_rpm->rpm, debuginfo);
-+ missing_rpm->next = missing_rpm_list;
-+ missing_rpm_list = missing_rpm;
-+ missing_rpm_list_entries++;
-+ }
-+ else
-+ xfree (debuginfo);
-+ count++;
-+ }
+
-+ rpmdbFreeIterator_p (mi);
-+ }
++if test "x$with_rpm" != "xno"; then
++ if test "x$with_rpm" = "xyes"; then
++ LIBRPM="librpm.so"
++ RPM_REQUIRE=true
++ DLOPEN_REQUIRE=false
++ elif test "x$with_rpm" = "xauto"; then
++ LIBRPM="librpm.so"
++ RPM_REQUIRE=false
++ DLOPEN_REQUIRE=false
++ else
++ LIBRPM="$with_rpm"
++ RPM_REQUIRE=true
++ DLOPEN_REQUIRE=true
++ fi
++ LIBRPM_STRING='"'"$LIBRPM"'"'
+
-+ rpmtsFree_p (ts);
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5
++$as_echo_n "checking specific librpm version... " >&6; }
++ HAVE_DLOPEN_LIBRPM=false
++ save_LIBS="$LIBS"
++ LIBS="$LIBS -ldl"
++ if test "$cross_compiling" = yes; then :
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
++as_fn_error "cannot run test program while cross compiling
++See \`config.log' for more details." "$LINENO" 5; }
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
+
-+ return count;
-+}
++#include <rpm/rpmlib.h>
++#include <dlfcn.h>
++#include <errno.h>
+
-+static int
-+missing_rpm_list_compar (const char *const *ap, const char *const *bp)
++int
++main ()
+{
-+ return strcoll (*ap, *bp);
-+}
+
-+/* It returns a NULL-terminated array of strings needing to be FREEd. It may
-+ also return only NULL. */
++ void *h;
++ const char *const *rpmverp;
++ FILE *f;
+
-+static void
-+missing_rpm_list_print (void)
-+{
-+ char **array, **array_iter;
-+ struct missing_rpm *list_iter;
-+ struct cleanup *cleanups;
++ f = fopen ("conftest.out", "w");
++ if (!f)
++ {
++ fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
++ strerror (errno));
++ return 1;
++ }
++ h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
++ if (!h)
++ {
++ fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
++ return 1;
++ }
++ rpmverp = dlsym (h, "RPMVERSION");
++ if (!rpmverp)
++ {
++ fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
++ return 1;
++ }
++ fprintf (stderr, "RPMVERSION is: \"");
++ fprintf (stderr, "%s\"\n", *rpmverp);
+
-+ if (missing_rpm_list_entries == 0)
-+ return;
++ /* Try to find the specific librpm version only for "librpm.so" as we do
++ not know how to assemble the version string otherwise. */
+
-+ array = xmalloc (sizeof (*array) * missing_rpm_list_entries);
-+ cleanups = make_cleanup (xfree, array);
++ if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
++ {
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ else
++ {
++ char *h2_name;
++ void *h2;
++ int major, minor;
+
-+ array_iter = array;
-+ for (list_iter = missing_rpm_list; list_iter != NULL;
-+ list_iter = list_iter->next)
-+ {
-+ *array_iter++ = list_iter->rpm;
-+ }
-+ gdb_assert (array_iter == array + missing_rpm_list_entries);
++ if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
++ {
++ fprintf (stderr, "Unable to parse RPMVERSION.\n");
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ /* Avoid the square brackets by malloc. */
++ h2_name = malloc (64);
++ sprintf (h2_name, "librpm-%d.%d.so", major, minor);
++ h2 = dlopen (h2_name, RTLD_LAZY);
++ if (!h2)
++ {
++ fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ if (h2 != h)
++ {
++ fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
++ $LIBRPM_STRING, h2_name);
++ fprintf (f, "%s\n", $LIBRPM_STRING);
++ return 0;
++ }
++ /* Found the valid .so name with a specific version. */
++ fprintf (f, "%s\n", h2_name);
++ return 0;
++ }
+
-+ qsort (array, missing_rpm_list_entries, sizeof (*array),
-+ (int (*) (const void *, const void *)) missing_rpm_list_compar);
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
+
-+ printf_unfiltered (_("Missing separate debuginfos, use: %s"),
-+ "debuginfo-install");
-+ for (array_iter = array; array_iter < array + missing_rpm_list_entries;
-+ array_iter++)
-+ {
-+ putchar_unfiltered (' ');
-+ puts_unfiltered (*array_iter);
-+ }
-+ putchar_unfiltered ('\n');
++ DLOPEN_LIBRPM="`cat conftest.out`"
++ if test "x$DLOPEN_LIBRPM" != "x"; then
++ HAVE_DLOPEN_LIBRPM=true
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5
++$as_echo "$DLOPEN_LIBRPM" >&6; }
++ fi
+
-+ while (missing_rpm_list != NULL)
-+ {
-+ list_iter = missing_rpm_list;
-+ missing_rpm_list = list_iter->next;
-+ xfree (list_iter);
-+ }
-+ missing_rpm_list_entries = 0;
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
+
-+ do_cleanups (cleanups);
-+}
++ rm -f conftest.out
+
-+static void
-+missing_rpm_change (void)
-+{
-+ debug_flush_missing ();
+
-+ gdb_assert (missing_rpm_list == NULL);
-+ if (missing_rpm_hash != NULL)
-+ {
-+ htab_delete (missing_rpm_hash);
-+ missing_rpm_hash = NULL;
-+ }
-+}
+
-+enum missing_exec
-+ {
-+ /* Init state. EXEC_BFD also still could be NULL. */
-+ MISSING_EXEC_NOT_TRIED,
-+ /* We saw a non-NULL EXEC_BFD but RPM has no info about it. */
-+ MISSING_EXEC_NOT_FOUND,
-+ /* We found EXEC_BFD by RPM and we either have its symbols (either embedded
-+ or separate) or the main executable's RPM is now contained in
-+ MISSING_RPM_HASH. */
-+ MISSING_EXEC_ENLISTED
-+ };
-+static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED;
++ if $HAVE_DLOPEN_LIBRPM; then
+
-+#endif /* HAVE_LIBRPM */
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
++$as_echo_n "checking rpm library API compatibility... " >&6; }
++ # The compilation requires -Werror to verify anything.
++ save_CFLAGS="$CFLAGS"
++ CFLAGS="$CFLAGS -Werror"
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
+
-+void
-+debug_flush_missing (void)
++/* Duplicate here the declarations to verify they match "elfread.c". */
++#include <rpm/rpmlib.h>
++#include <rpm/rpmts.h>
++#include <rpm/rpmdb.h>
++#include <rpm/header.h>
++extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
++extern int rpmReadConfigFiles(const char * file, const char * target);
++extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
++extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
++extern rpmts rpmtsCreate(void);
++extern rpmts rpmtsFree(rpmts ts);
++extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
++ const void * keyp, size_t keylen);
++
++int
++main ()
+{
-+#ifdef HAVE_LIBRPM
-+ missing_rpm_list_print ();
-+#endif
++
++ ;
++ return 0;
+}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
+
- /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
-- Try to install the hash file ...
-+ yum --enablerepo='*debug*' install ...
- avoidance. */
-
- struct missing_filepair
-@@ -1737,11 +2090,17 @@ missing_filepair_change (void)
- /* All their memory came just from missing_filepair_OBSTACK. */
- missing_filepair_hash = NULL;
- }
-+#ifdef HAVE_LIBRPM
-+ missing_exec = MISSING_EXEC_NOT_TRIED;
-+#endif
- }
-
- static void
- debug_print_executable_changed (void)
- {
-+#ifdef HAVE_LIBRPM
-+ missing_rpm_change ();
-+#endif
- missing_filepair_change ();
- }
-
-@@ -1808,14 +2167,34 @@ debug_print_missing (const char *binary,
-
- *slot = missing_filepair;
-
-- /* We do not collect and flush these messages as each such message
-- already requires its own separate lines. */
-+#ifdef HAVE_LIBRPM
-+ if (missing_exec == MISSING_EXEC_NOT_TRIED)
-+ {
-+ char *exec_filename;
-
-- fprintf_unfiltered (gdb_stdlog,
-- _("Missing separate debuginfo for %s\n"), binary);
-- if (debug != NULL)
-- fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
-- debug);
-+ exec_filename = get_exec_file (0);
-+ if (exec_filename != NULL)
-+ {
-+ if (missing_rpm_enlist (exec_filename) == 0)
-+ missing_exec = MISSING_EXEC_NOT_FOUND;
-+ else
-+ missing_exec = MISSING_EXEC_ENLISTED;
-+ }
-+ }
-+ if (missing_exec != MISSING_EXEC_ENLISTED)
-+ if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0)
-+ && (debug == NULL || missing_rpm_enlist (debug) == 0))
-+#endif /* HAVE_LIBRPM */
-+ {
-+ /* We do not collect and flush these messages as each such message
-+ already requires its own separate lines. */
++ LIBRPM_COMPAT=true
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
+
-+ fprintf_unfiltered (gdb_stdlog,
-+ _("Missing separate debuginfo for %s\n"), binary);
-+ if (debug != NULL)
-+ fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"),
-+ "yum --enablerepo='*debug*' install", debug);
-+ }
- }
-
- static char *
-Index: gdb-7.6/gdb/symfile.h
-===================================================================
---- gdb-7.6.orig/gdb/symfile.h 2013-07-17 19:51:02.639357629 +0200
-+++ gdb-7.6/gdb/symfile.h 2013-07-17 19:51:02.687357661 +0200
-@@ -598,6 +598,8 @@ extern struct elf_build_id *build_id_add
- extern char *build_id_to_filename (const struct elf_build_id *build_id,
- char **link_return, int add_debug_suffix);
- extern void debug_print_missing (const char *binary, const char *debug);
-+extern void debug_flush_missing (void);
-+#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file")
-
- /* From dwarf2read.c */
-
-Index: gdb-7.6/gdb/testsuite/lib/gdb.exp
-===================================================================
---- gdb-7.6.orig/gdb/testsuite/lib/gdb.exp 2013-07-17 19:51:02.640357629 +0200
-+++ gdb-7.6/gdb/testsuite/lib/gdb.exp 2013-07-17 19:51:02.688357662 +0200
-@@ -1482,7 +1482,7 @@ proc default_gdb_start { } {
- warning "Couldn't set the width to 0."
- }
- }
-- # Turn off the missing warnings as the testsuite does not expect it.
-+ # Turn off the missing RPMs warnings as the testsuite does not expect it.
- send_gdb "set build-id-verbose 0\n"
- gdb_expect 10 {
- -re "$gdb_prompt $" {
-Index: gdb-7.6/gdb/testsuite/lib/mi-support.exp
-===================================================================
---- gdb-7.6.orig/gdb/testsuite/lib/mi-support.exp 2013-07-17 19:51:02.656357640 +0200
-+++ gdb-7.6/gdb/testsuite/lib/mi-support.exp 2013-07-17 19:51:02.689357663 +0200
-@@ -212,7 +212,7 @@ proc default_mi_gdb_start { args } {
- warning "Couldn't set the width to 0."
- }
- }
-- # Turn off the missing warnings as the testsuite does not expect it.
-+ # Turn off the missing RPMs warnings as the testsuite does not expect it.
- send_gdb "190-gdb-set build-id-verbose 0\n"
- gdb_expect 10 {
- -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
-Index: gdb-7.6/gdb/tui/tui-interp.c
-===================================================================
---- gdb-7.6.orig/gdb/tui/tui-interp.c 2013-01-01 07:41:30.000000000 +0100
-+++ gdb-7.6/gdb/tui/tui-interp.c 2013-07-17 19:51:02.689357663 +0200
-@@ -30,6 +30,7 @@
- #include "tui/tui.h"
- #include "tui/tui-io.h"
- #include "exceptions.h"
-+#include "symfile.h"
-
- /* Set to 1 when the TUI mode must be activated when we first start
- gdb. */
-Index: gdb-7.6/gdb/aclocal.m4
-===================================================================
---- gdb-7.6.orig/gdb/aclocal.m4 2013-01-17 12:06:26.000000000 +0100
-+++ gdb-7.6/gdb/aclocal.m4 2013-07-17 19:51:02.689357663 +0200
-@@ -11,6 +11,164 @@
- # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- # PARTICULAR PURPOSE.
-
-+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
-+# serial 1 (pkg-config-0.24)
-+#
-+# Copyright © 2004 Scott James Remnant <scott at netsplit.com>.
-+#
-+# This program is free software; you can redistribute it and/or modify
-+# it under the terms of 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.
-+#
-+# This program 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 a copy of the GNU General Public License
-+# along with this program; if not, write to the Free Software
-+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+#
-+# As a special exception to the GNU General Public License, if you
-+# distribute this file as part of a program that contains a
-+# configuration script generated by Autoconf, you may include it under
-+# the same distribution terms that you use for the rest of that program.
++else
+
-+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
-+# ----------------------------------
-+AC_DEFUN([PKG_PROG_PKG_CONFIG],
-+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
-+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
-+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
-+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
-+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
++ LIBRPM_COMPAT=false
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
+
-+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
-+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
-+if test -n "$PKG_CONFIG"; then
-+ _pkg_min_version=m4_default([$1], [0.9.0])
-+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
-+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
-+ AC_MSG_RESULT([yes])
-+ else
-+ AC_MSG_RESULT([no])
-+ PKG_CONFIG=""
-+ fi
-+fi[]dnl
-+])# PKG_PROG_PKG_CONFIG
-+
-+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-+#
-+# Check to see whether a particular set of modules exists. Similar
-+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
-+#
-+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-+# only at the first occurence in configure.ac, so if the first place
-+# it's called might be skipped (such as if it is within an "if", you
-+# have to call PKG_CHECK_EXISTS manually
-+# --------------------------------------------------------------
-+AC_DEFUN([PKG_CHECK_EXISTS],
-+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-+if test -n "$PKG_CONFIG" && \
-+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
-+ m4_default([$2], [:])
-+m4_ifvaln([$3], [else
-+ $3])dnl
-+fi])
-+
-+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
-+# ---------------------------------------------
-+m4_define([_PKG_CONFIG],
-+[if test -n "$$1"; then
-+ pkg_cv_[]$1="$$1"
-+ elif test -n "$PKG_CONFIG"; then
-+ PKG_CHECK_EXISTS([$3],
-+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
-+ [pkg_failed=yes])
-+ else
-+ pkg_failed=untried
-+fi[]dnl
-+])# _PKG_CONFIG
-+
-+# _PKG_SHORT_ERRORS_SUPPORTED
-+# -----------------------------
-+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
-+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-+ _pkg_short_errors_supported=yes
-+else
-+ _pkg_short_errors_supported=no
-+fi[]dnl
-+])# _PKG_SHORT_ERRORS_SUPPORTED
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ CFLAGS="$save_CFLAGS"
+
++ if ! $LIBRPM_COMPAT; then
++ HAVE_DLOPEN_LIBRPM=false
++ fi
++ fi
+
-+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-+# [ACTION-IF-NOT-FOUND])
-+#
-+#
-+# Note that if there is a possibility the first call to
-+# PKG_CHECK_MODULES might not happen, you should be sure to include an
-+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
-+#
-+#
-+# --------------------------------------------------------------
-+AC_DEFUN([PKG_CHECK_MODULES],
-+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
-+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
-+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
++ if $HAVE_DLOPEN_LIBRPM; then
++ DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
+
-+pkg_failed=no
-+AC_MSG_CHECKING([for $1])
++cat >>confdefs.h <<_ACEOF
++#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING
++_ACEOF
+
-+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
-+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
-+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
-+and $1[]_LIBS to avoid the need to call pkg-config.
-+See the pkg-config man page for more details.])
++$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
+
-+if test $pkg_failed = yes; then
-+ AC_MSG_RESULT([no])
-+ _PKG_SHORT_ERRORS_SUPPORTED
-+ if test $_pkg_short_errors_supported = yes; then
-+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
-+ else
-+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
-+ fi
-+ # Put the nasty error message in config.log where it belongs
-+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
++ else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++ LIBS="$save_LIBS"
++ if $DLOPEN_REQUIRE; then
++ as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
++ fi
+
-+ m4_default([$4], [AC_MSG_ERROR(
-+[Package requirements ($2) were not met:
+
-+$$1_PKG_ERRORS
+
-+Consider adjusting the PKG_CONFIG_PATH environment variable if you
-+installed software in a non-standard prefix.
+
-+_PKG_TEXT])
-+ ])
-+elif test $pkg_failed = untried; then
-+ AC_MSG_RESULT([no])
-+ m4_default([$4], [AC_MSG_FAILURE(
-+[The pkg-config script could not be found or is too old. Make sure it
-+is in your PATH or set the PKG_CONFIG environment variable to the full
-+path to pkg-config.
+
-+_PKG_TEXT
+
-+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])
-+ ])
++if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
++ if test -n "$ac_tool_prefix"; then
++ # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
++set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
++ $as_echo_n "(cached) " >&6
+else
-+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
-+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
-+ AC_MSG_RESULT([yes])
-+ $3
-+fi[]dnl
-+])# PKG_CHECK_MODULES
++ case $PKG_CONFIG in
++ [\\/]* | ?:[\\/]*)
++ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
++ ;;
++ *)
++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++ done
++IFS=$as_save_IFS
+
- # AM_CONDITIONAL -*- Autoconf -*-
-
- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
-Index: gdb-7.6/gdb/config.in
-===================================================================
---- gdb-7.6.orig/gdb/config.in 2012-12-09 19:39:58.000000000 +0100
-+++ gdb-7.6/gdb/config.in 2013-07-17 19:51:02.689357663 +0200
-@@ -33,6 +33,9 @@
- /* Define to BFD's default target vector. */
- #undef DEFAULT_BFD_VEC
-
-+/* librpm version specific library name to dlopen. */
-+#undef DLOPEN_LIBRPM
++ ;;
++esac
++fi
++PKG_CONFIG=$ac_cv_path_PKG_CONFIG
++if test -n "$PKG_CONFIG"; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
++$as_echo "$PKG_CONFIG" >&6; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
+
- /* Define to 1 if translation of program messages to the user's native
- language is requested. */
- #undef ENABLE_NLS
-@@ -210,6 +213,9 @@
- /* Define if Python 2.7 is being used. */
- #undef HAVE_LIBPYTHON2_7
-
-+/* Define if librpm library is being used. */
-+#undef HAVE_LIBRPM
+
- /* Define to 1 if you have the <libunwind-ia64.h> header file. */
- #undef HAVE_LIBUNWIND_IA64_H
-
-Index: gdb-7.6/gdb/configure
-===================================================================
---- gdb-7.6.orig/gdb/configure 2013-07-17 19:51:01.665356963 +0200
-+++ gdb-7.6/gdb/configure 2013-07-17 19:51:02.691357664 +0200
-@@ -686,6 +686,11 @@ PKGVERSION
- HAVE_NATIVE_GCORE_TARGET
- TARGET_OBS
- subdirs
-+RPM_LIBS
-+RPM_CFLAGS
-+PKG_CONFIG_LIBDIR
-+PKG_CONFIG_PATH
-+PKG_CONFIG
- GDB_DATADIR
- DEBUGDIR
- MAKEINFO_EXTRA_FLAGS
-@@ -786,6 +791,7 @@ with_gdb_datadir
- with_relocated_sources
- with_auto_load_dir
- with_auto_load_safe_path
-+with_rpm
- enable_targets
- enable_64_bit_bfd
- enable_gdbcli
-@@ -834,6 +840,11 @@ CPPFLAGS
- CPP
- MAKEINFO
- MAKEINFOFLAGS
-+PKG_CONFIG
-+PKG_CONFIG_PATH
-+PKG_CONFIG_LIBDIR
-+RPM_CFLAGS
-+RPM_LIBS
- YACC
- YFLAGS
- XMKMF'
-@@ -1504,6 +1515,8 @@ Optional Packages:
- [--with-auto-load-dir]
- --without-auto-load-safe-path
- do not restrict auto-loaded files locations
-+ --with-rpm query rpm database for missing debuginfos (yes/no,
-+ def. auto=librpm.so)
- --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets
- --with-curses use the curses library instead of the termcap
- library
-@@ -1548,6 +1561,13 @@ Some influential environment variables:
- MAKEINFO Parent configure detects if it is of sufficient version.
- MAKEINFOFLAGS
- Parameters for MAKEINFO.
-+ PKG_CONFIG path to pkg-config utility
-+ PKG_CONFIG_PATH
-+ directories to add to pkg-config's search path
-+ PKG_CONFIG_LIBDIR
-+ path overriding pkg-config's built-in search path
-+ RPM_CFLAGS C compiler flags for RPM, overriding pkg-config
-+ RPM_LIBS linker flags for RPM, overriding pkg-config
- YACC The `Yet Another C Compiler' implementation to use. Defaults to
- the first program found out of: `bison -y', `byacc', `yacc'.
- YFLAGS The list of arguments that will be passed by default to $YACC.
-@@ -5033,6 +5053,491 @@ _ACEOF
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
- $as_echo "$with_auto_load_safe_path" >&6; }
-
-+# Integration with rpm library to support missing debuginfo suggestions.
-+# --without-rpm: Disable any rpm support.
-+# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
-+# Even with runtime missing `libname.so' GDB will still other run correctly.
-+# Missing `libname.so' during ./configure will abort the configuration.
-+# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
-+# minor version first such as `librpm-4.6.so' as minor version differences
-+# mean API+ABI incompatibility. If the specific match versioned library name
-+# could not be found still open dynamically at least `librpm.so'.
-+# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
-+# to find librpm for compilation-time linking by pkg-config. GDB binary will
-+# be probably linked with the version specific library (as `librpm-4.6.so').
-+# Failure to find librpm by pkg-config will abort the configuration.
-+# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
-+# cannot find librpm use to the rpmless compilation (like `--without-rpm').
++fi
++if test -z "$ac_cv_path_PKG_CONFIG"; then
++ ac_pt_PKG_CONFIG=$PKG_CONFIG
++ # Extract the first word of "pkg-config", so it can be a program name with args.
++set dummy pkg-config; ac_word=$2
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
++$as_echo_n "checking for $ac_word... " >&6; }
++if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ case $ac_pt_PKG_CONFIG in
++ [\\/]* | ?:[\\/]*)
++ ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
++ ;;
++ *)
++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
++for as_dir in $PATH
++do
++ IFS=$as_save_IFS
++ test -z "$as_dir" && as_dir=.
++ for ac_exec_ext in '' $ac_executable_extensions; do
++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
++ ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
++ break 2
++ fi
++done
++ done
++IFS=$as_save_IFS
+
++ ;;
++esac
++fi
++ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
++if test -n "$ac_pt_PKG_CONFIG"; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
++$as_echo "$ac_pt_PKG_CONFIG" >&6; }
++else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++fi
+
-+# Check whether --with-rpm was given.
-+if test "${with_rpm+set}" = set; then :
-+ withval=$with_rpm;
++ if test "x$ac_pt_PKG_CONFIG" = x; then
++ PKG_CONFIG=""
++ else
++ case $cross_compiling:$ac_tool_warned in
++yes:)
++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
++ac_tool_warned=yes ;;
++esac
++ PKG_CONFIG=$ac_pt_PKG_CONFIG
++ fi
+else
-+ with_rpm="auto"
++ PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
++fi
++if test -n "$PKG_CONFIG"; then
++ _pkg_min_version=0.9.0
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
++$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
++ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++ else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++ PKG_CONFIG=""
++ fi
++fi
+
++pkg_failed=no
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
++$as_echo_n "checking for RPM... " >&6; }
+
++if test -n "$RPM_CFLAGS"; then
++ pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
++ elif test -n "$PKG_CONFIG"; then
++ if test -n "$PKG_CONFIG" && \
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
++ ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
++ ac_status=$?
++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++ test $ac_status = 0; }; then
++ pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null`
++else
++ pkg_failed=yes
++fi
++ else
++ pkg_failed=untried
++fi
++if test -n "$RPM_LIBS"; then
++ pkg_cv_RPM_LIBS="$RPM_LIBS"
++ elif test -n "$PKG_CONFIG"; then
++ if test -n "$PKG_CONFIG" && \
++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
++ ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
++ ac_status=$?
++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++ test $ac_status = 0; }; then
++ pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null`
++else
++ pkg_failed=yes
++fi
++ else
++ pkg_failed=untried
++fi
+
-+if test "x$with_rpm" != "xno"; then
-+ if test "x$with_rpm" = "xyes"; then
-+ LIBRPM="librpm.so"
-+ RPM_REQUIRE=true
-+ DLOPEN_REQUIRE=false
-+ elif test "x$with_rpm" = "xauto"; then
-+ LIBRPM="librpm.so"
-+ RPM_REQUIRE=false
-+ DLOPEN_REQUIRE=false
-+ else
-+ LIBRPM="$with_rpm"
-+ RPM_REQUIRE=true
-+ DLOPEN_REQUIRE=true
-+ fi
-+ LIBRPM_STRING='"'"$LIBRPM"'"'
+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking specific librpm version" >&5
-+$as_echo_n "checking specific librpm version... " >&6; }
-+ HAVE_DLOPEN_LIBRPM=false
-+ save_LIBS="$LIBS"
-+ LIBS="$LIBS -ldl"
-+ if test "$cross_compiling" = yes; then :
-+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-+as_fn_error "cannot run test program while cross compiling
-+See \`config.log' for more details." "$LINENO" 5; }
++
++if test $pkg_failed = yes; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++
++if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
++ _pkg_short_errors_supported=yes
+else
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++ _pkg_short_errors_supported=no
++fi
++ if test $_pkg_short_errors_supported = yes; then
++ RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "rpm" 2>&1`
++ else
++ RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors "rpm" 2>&1`
++ fi
++ # Put the nasty error message in config.log where it belongs
++ echo "$RPM_PKG_ERRORS" >&5
++
++ HAVE_LIBRPM=false
++elif test $pkg_failed = untried; then
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++ HAVE_LIBRPM=false
++else
++ RPM_CFLAGS=$pkg_cv_RPM_CFLAGS
++ RPM_LIBS=$pkg_cv_RPM_LIBS
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++ HAVE_LIBRPM=true
++fi
++
++ if $HAVE_LIBRPM; then
++
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
++$as_echo_n "checking rpm library API compatibility... " >&6; }
++ # The compilation requires -Werror to verify anything.
++ save_CFLAGS="$CFLAGS"
++ CFLAGS="$CFLAGS -Werror"
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
++/* Duplicate here the declarations to verify they match "elfread.c". */
+#include <rpm/rpmlib.h>
-+#include <dlfcn.h>
-+#include <errno.h>
++#include <rpm/rpmts.h>
++#include <rpm/rpmdb.h>
++#include <rpm/header.h>
++extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
++extern int rpmReadConfigFiles(const char * file, const char * target);
++extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
++extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
++extern rpmts rpmtsCreate(void);
++extern rpmts rpmtsFree(rpmts ts);
++extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
++ const void * keyp, size_t keylen);
+
+int
+main ()
+{
+
-+ void *h;
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_compile "$LINENO"; then :
++
++ LIBRPM_COMPAT=true
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
++$as_echo "yes" >&6; }
++
++else
++
++ LIBRPM_COMPAT=false
++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
++$as_echo "no" >&6; }
++
++fi
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ CFLAGS="$save_CFLAGS"
++
++ if ! $LIBRPM_COMPAT; then
++ HAVE_LIBRPM=false
++ RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
++ fi
++ fi
++
++ if $HAVE_LIBRPM; then
++
++$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
++
++ CFLAGS="$CFLAGS $RPM_CFLAGS"
++ LIBS="$LIBS $RPM_LIBS"
++ else
++ if $RPM_REQUIRE; then
++ as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
++ else
++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
++$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
++ fi
++ fi
++ fi
++fi
++
+
+
+ subdirs="$subdirs testsuite"
+Index: gdb-7.6.90.20140127/gdb/configure.ac
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/configure.ac 2014-02-06 17:18:26.977717223 +0100
++++ gdb-7.6.90.20140127/gdb/configure.ac 2014-02-06 17:18:33.873724674 +0100
+@@ -165,6 +165,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escap
+ [Directories safe to hold auto-loaded files.])
+ AC_MSG_RESULT([$with_auto_load_safe_path])
+
++# Integration with rpm library to support missing debuginfo suggestions.
++# --without-rpm: Disable any rpm support.
++# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
++# Even with runtime missing `libname.so' GDB will still other run correctly.
++# Missing `libname.so' during ./configure will abort the configuration.
++# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
++# minor version first such as `librpm-4.6.so' as minor version differences
++# mean API+ABI incompatibility. If the specific match versioned library name
++# could not be found still open dynamically at least `librpm.so'.
++# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
++# to find librpm for compilation-time linking by pkg-config. GDB binary will
++# be probably linked with the version specific library (as `librpm-4.6.so').
++# Failure to find librpm by pkg-config will abort the configuration.
++# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
++# cannot find librpm use to the rpmless compilation (like `--without-rpm').
++
++AC_ARG_WITH([rpm],
++ [AS_HELP_STRING([--with-rpm],
++ [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"])
++
++m4_pattern_allow([^AC_MSG_ERROR$])
++m4_pattern_allow([^AC_MSG_WARN$])
++if test "x$with_rpm" != "xno"; then
++ if test "x$with_rpm" = "xyes"; then
++ LIBRPM="librpm.so"
++ RPM_REQUIRE=true
++ DLOPEN_REQUIRE=false
++ elif test "x$with_rpm" = "xauto"; then
++ LIBRPM="librpm.so"
++ RPM_REQUIRE=false
++ DLOPEN_REQUIRE=false
++ else
++ LIBRPM="$with_rpm"
++ RPM_REQUIRE=true
++ DLOPEN_REQUIRE=true
++ fi
++ LIBRPM_STRING='"'"$LIBRPM"'"'
++
++ AC_MSG_CHECKING([specific librpm version])
++ HAVE_DLOPEN_LIBRPM=false
++ save_LIBS="$LIBS"
++ LIBS="$LIBS -ldl"
++ AC_RUN_IFELSE(AC_LANG_PROGRAM([[
++#include <rpm/rpmlib.h>
++#include <dlfcn.h>
++#include <errno.h>
++ ]], [[
++ void *h;
+ const char *const *rpmverp;
+ FILE *f;
+
@@ -901,39 +1002,21 @@ Index: gdb-7.6/gdb/configure
+ fprintf (f, "%s\n", h2_name);
+ return 0;
+ }
-+
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_run "$LINENO"; then :
-+
++ ]]), [
+ DLOPEN_LIBRPM="`cat conftest.out`"
+ if test "x$DLOPEN_LIBRPM" != "x"; then
+ HAVE_DLOPEN_LIBRPM=true
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLOPEN_LIBRPM" >&5
-+$as_echo "$DLOPEN_LIBRPM" >&6; }
++ AC_MSG_RESULT($DLOPEN_LIBRPM)
+ fi
-+
-+fi
-+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-+ conftest.$ac_objext conftest.beam conftest.$ac_ext
-+fi
-+
++ ])
+ rm -f conftest.out
+
-+
-+
-+ if $HAVE_DLOPEN_LIBRPM; then
-+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
-+$as_echo_n "checking rpm library API compatibility... " >&6; }
++ m4_define([CHECK_LIBRPM_COMPAT], [
++ AC_MSG_CHECKING([rpm library API compatibility])
+ # The compilation requires -Werror to verify anything.
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror"
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h. */
-+
++ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
+/* Duplicate here the declarations to verify they match "elfread.c". */
+#include <rpm/rpmlib.h>
+#include <rpm/rpmts.h>
@@ -947,31 +1030,18 @@ Index: gdb-7.6/gdb/configure
+extern rpmts rpmtsFree(rpmts ts);
+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
+ const void * keyp, size_t keylen);
-+
-+int
-+main ()
-+{
-+
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_compile "$LINENO"; then :
-+
++ ]]), [
+ LIBRPM_COMPAT=true
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+$as_echo "yes" >&6; }
-+
-+else
-+
++ AC_MSG_RESULT(yes)
++ ], [
+ LIBRPM_COMPAT=false
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+
-+fi
-+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++ AC_MSG_RESULT(no)
++ ])
+ CFLAGS="$save_CFLAGS"
++ ])
+
++ if $HAVE_DLOPEN_LIBRPM; then
++ CHECK_LIBRPM_COMPAT
+ if ! $LIBRPM_COMPAT; then
+ HAVE_DLOPEN_LIBRPM=false
+ fi
@@ -979,498 +1049,485 @@ Index: gdb-7.6/gdb/configure
+
+ if $HAVE_DLOPEN_LIBRPM; then
+ DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
-+
-+cat >>confdefs.h <<_ACEOF
-+#define DLOPEN_LIBRPM $DLOPEN_LIBRPM_STRING
-+_ACEOF
-+
-+
-+$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
-+
++ AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.])
++ AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
+ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
++ AC_MSG_RESULT(no)
+ LIBS="$save_LIBS"
+ if $DLOPEN_REQUIRE; then
-+ as_fn_error "Specific name $LIBRPM was requested but it could not be opened." "$LINENO" 5
++ AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.])
+ fi
++ PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false])
+
++ if $HAVE_LIBRPM; then
++ CHECK_LIBRPM_COMPAT
++ if ! $LIBRPM_COMPAT; then
++ HAVE_LIBRPM=false
++ RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
++ fi
++ fi
+
++ if $HAVE_LIBRPM; then
++ AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
++ CFLAGS="$CFLAGS $RPM_CFLAGS"
++ LIBS="$LIBS $RPM_LIBS"
++ else
++ if $RPM_REQUIRE; then
++ AC_MSG_ERROR($RPM_PKG_ERRORS)
++ else
++ AC_MSG_WARN($RPM_PKG_ERRORS)
++ fi
++ fi
++ fi
++fi
++
+ AC_CONFIG_SUBDIRS(testsuite)
+
+ # Check whether to support alternative target configurations
+Index: gdb-7.6.90.20140127/gdb/corelow.c
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/corelow.c 2014-02-06 17:18:26.978717224 +0100
++++ gdb-7.6.90.20140127/gdb/corelow.c 2014-02-06 17:18:33.873724674 +0100
+@@ -315,7 +315,7 @@ build_id_locate_exec (int from_tty)
+ symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
+ }
+ else
+- debug_print_missing (_("the main executable file"), build_id_filename);
++ debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename);
+
+ do_cleanups (back_to);
+
+Index: gdb-7.6.90.20140127/gdb/build-id.c
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/build-id.c 2014-02-06 17:18:26.842717077 +0100
++++ gdb-7.6.90.20140127/gdb/build-id.c 2014-02-06 17:08:18.341060295 +0100
+@@ -32,6 +32,7 @@
+ #include "gdbcmd.h"
+ #include "observer.h"
+ #include <sys/stat.h>
++#include "elf/external.h"
+
+ #define BUILD_ID_VERBOSE_NONE 0
+ #define BUILD_ID_VERBOSE_FILENAMES 1
+@@ -666,8 +667,360 @@ build_id_to_filename (const struct elf_b
+ return result;
+ }
+
++#ifdef HAVE_LIBRPM
+
++#include <rpm/rpmlib.h>
++#include <rpm/rpmts.h>
++#include <rpm/rpmdb.h>
++#include <rpm/header.h>
++#ifdef DLOPEN_LIBRPM
++#include <dlfcn.h>
++#endif
+
++/* This MISSING_RPM_HASH tracker is used to collect all the missing rpm files
++ and avoid their duplicities during a single inferior run. */
+
++static struct htab *missing_rpm_hash;
+
-+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
-+ if test -n "$ac_tool_prefix"; then
-+ # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
-+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+$as_echo_n "checking for $ac_word... " >&6; }
-+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
-+ $as_echo_n "(cached) " >&6
-+else
-+ case $PKG_CONFIG in
-+ [\\/]* | ?:[\\/]*)
-+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
-+ ;;
-+ *)
-+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+for as_dir in $PATH
-+do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+ fi
-+done
-+ done
-+IFS=$as_save_IFS
-+
-+ ;;
-+esac
-+fi
-+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
-+if test -n "$PKG_CONFIG"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
-+$as_echo "$PKG_CONFIG" >&6; }
-+else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+fi
++/* This MISSING_RPM_LIST tracker is used to collect and print as a single line
++ all the rpms right before the nearest GDB prompt. It gets cleared after
++ each such print (it is questionable if we should clear it after the print).
++ */
+
++struct missing_rpm
++ {
++ struct missing_rpm *next;
++ char rpm[1];
++ };
++static struct missing_rpm *missing_rpm_list;
++static int missing_rpm_list_entries;
+
-+fi
-+if test -z "$ac_cv_path_PKG_CONFIG"; then
-+ ac_pt_PKG_CONFIG=$PKG_CONFIG
-+ # Extract the first word of "pkg-config", so it can be a program name with args.
-+set dummy pkg-config; ac_word=$2
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-+$as_echo_n "checking for $ac_word... " >&6; }
-+if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
-+ $as_echo_n "(cached) " >&6
-+else
-+ case $ac_pt_PKG_CONFIG in
-+ [\\/]* | ?:[\\/]*)
-+ ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
-+ ;;
-+ *)
-+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-+for as_dir in $PATH
-+do
-+ IFS=$as_save_IFS
-+ test -z "$as_dir" && as_dir=.
-+ for ac_exec_ext in '' $ac_executable_extensions; do
-+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-+ ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-+ break 2
-+ fi
-+done
-+ done
-+IFS=$as_save_IFS
++/* Returns the count of newly added rpms. */
+
-+ ;;
-+esac
-+fi
-+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
-+if test -n "$ac_pt_PKG_CONFIG"; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
-+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
-+else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+fi
++static int
++missing_rpm_enlist (const char *filename)
++{
++ static int rpm_init_done = 0;
++ rpmts ts;
++ rpmdbMatchIterator mi;
++ int count = 0;
+
-+ if test "x$ac_pt_PKG_CONFIG" = x; then
-+ PKG_CONFIG=""
-+ else
-+ case $cross_compiling:$ac_tool_warned in
-+yes:)
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-+ac_tool_warned=yes ;;
-+esac
-+ PKG_CONFIG=$ac_pt_PKG_CONFIG
-+ fi
-+else
-+ PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
-+fi
++#ifdef DLOPEN_LIBRPM
++ /* Duplicate here the declarations to verify they match. The same sanity
++ check is present also in `configure.ac'. */
++ extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
++ static char *(*headerFormat_p) (Header h, const char * fmt, errmsg_t *errmsg);
++ extern int rpmReadConfigFiles(const char * file, const char * target);
++ static int (*rpmReadConfigFiles_p) (const char * file, const char * target);
++ extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
++ static rpmdbMatchIterator (*rpmdbFreeIterator_p) (rpmdbMatchIterator mi);
++ extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
++ static Header (*rpmdbNextIterator_p) (rpmdbMatchIterator mi);
++ extern rpmts rpmtsCreate(void);
++ static rpmts (*rpmtsCreate_p) (void);
++ extern rpmts rpmtsFree(rpmts ts);
++ static rpmts (*rpmtsFree_p) (rpmts ts);
++ extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
++ const void * keyp, size_t keylen);
++ static rpmdbMatchIterator (*rpmtsInitIterator_p) (const rpmts ts,
++ rpmTag rpmtag,
++ const void *keyp,
++ size_t keylen);
++#else /* !DLOPEN_LIBRPM */
++# define headerFormat_p headerFormat
++# define rpmReadConfigFiles_p rpmReadConfigFiles
++# define rpmdbFreeIterator_p rpmdbFreeIterator
++# define rpmdbNextIterator_p rpmdbNextIterator
++# define rpmtsCreate_p rpmtsCreate
++# define rpmtsFree_p rpmtsFree
++# define rpmtsInitIterator_p rpmtsInitIterator
++#endif /* !DLOPEN_LIBRPM */
+
-+fi
-+if test -n "$PKG_CONFIG"; then
-+ _pkg_min_version=0.9.0
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
-+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
-+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+$as_echo "yes" >&6; }
-+ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+ PKG_CONFIG=""
-+ fi
-+fi
++ gdb_assert (filename != NULL);
+
-+pkg_failed=no
-+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPM" >&5
-+$as_echo_n "checking for RPM... " >&6; }
++ if (strcmp (filename, BUILD_ID_MAIN_EXECUTABLE_FILENAME) == 0)
++ return 0;
+
-+if test -n "$RPM_CFLAGS"; then
-+ pkg_cv_RPM_CFLAGS="$RPM_CFLAGS"
-+ elif test -n "$PKG_CONFIG"; then
-+ if test -n "$PKG_CONFIG" && \
-+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
-+ ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
-+ ac_status=$?
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; }; then
-+ pkg_cv_RPM_CFLAGS=`$PKG_CONFIG --cflags "rpm" 2>/dev/null`
-+else
-+ pkg_failed=yes
-+fi
-+ else
-+ pkg_failed=untried
-+fi
-+if test -n "$RPM_LIBS"; then
-+ pkg_cv_RPM_LIBS="$RPM_LIBS"
-+ elif test -n "$PKG_CONFIG"; then
-+ if test -n "$PKG_CONFIG" && \
-+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"rpm\""; } >&5
-+ ($PKG_CONFIG --exists --print-errors "rpm") 2>&5
-+ ac_status=$?
-+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-+ test $ac_status = 0; }; then
-+ pkg_cv_RPM_LIBS=`$PKG_CONFIG --libs "rpm" 2>/dev/null`
-+else
-+ pkg_failed=yes
-+fi
-+ else
-+ pkg_failed=untried
-+fi
++ if (filename[0] != '/')
++ {
++ warning (_("Ignoring non-absolute filename: <%s>"), filename);
++ return 0;
++ }
+
++ if (!rpm_init_done)
++ {
++ static int init_tried;
+
++ /* Already failed the initialization before? */
++ if (init_tried)
++ return 0;
++ init_tried = 1;
+
-+if test $pkg_failed = yes; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
++#ifdef DLOPEN_LIBRPM
++ {
++ void *h;
+
-+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
-+ _pkg_short_errors_supported=yes
-+else
-+ _pkg_short_errors_supported=no
-+fi
-+ if test $_pkg_short_errors_supported = yes; then
-+ RPM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "rpm" 2>&1`
-+ else
-+ RPM_PKG_ERRORS=`$PKG_CONFIG --print-errors "rpm" 2>&1`
-+ fi
-+ # Put the nasty error message in config.log where it belongs
-+ echo "$RPM_PKG_ERRORS" >&5
++ h = dlopen (DLOPEN_LIBRPM, RTLD_LAZY);
++ if (!h)
++ {
++ warning (_("Unable to open \"%s\" (%s), "
++ "missing debuginfos notifications will not be displayed"),
++ DLOPEN_LIBRPM, dlerror ());
++ return 0;
++ }
+
-+ HAVE_LIBRPM=false
-+elif test $pkg_failed = untried; then
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
-+ HAVE_LIBRPM=false
-+else
-+ RPM_CFLAGS=$pkg_cv_RPM_CFLAGS
-+ RPM_LIBS=$pkg_cv_RPM_LIBS
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+$as_echo "yes" >&6; }
-+ HAVE_LIBRPM=true
-+fi
++ if (!((headerFormat_p = dlsym (h, "headerFormat"))
++ && (rpmReadConfigFiles_p = dlsym (h, "rpmReadConfigFiles"))
++ && (rpmdbFreeIterator_p = dlsym (h, "rpmdbFreeIterator"))
++ && (rpmdbNextIterator_p = dlsym (h, "rpmdbNextIterator"))
++ && (rpmtsCreate_p = dlsym (h, "rpmtsCreate"))
++ && (rpmtsFree_p = dlsym (h, "rpmtsFree"))
++ && (rpmtsInitIterator_p = dlsym (h, "rpmtsInitIterator"))))
++ {
++ warning (_("Opened library \"%s\" is incompatible (%s), "
++ "missing debuginfos notifications will not be displayed"),
++ DLOPEN_LIBRPM, dlerror ());
++ if (dlclose (h))
++ warning (_("Error closing library \"%s\": %s\n"), DLOPEN_LIBRPM,
++ dlerror ());
++ return 0;
++ }
++ }
++#endif /* DLOPEN_LIBRPM */
+
-+ if $HAVE_LIBRPM; then
++ if (rpmReadConfigFiles_p (NULL, NULL) != 0)
++ {
++ warning (_("Error reading the rpm configuration files"));
++ return 0;
++ }
+
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking rpm library API compatibility" >&5
-+$as_echo_n "checking rpm library API compatibility... " >&6; }
-+ # The compilation requires -Werror to verify anything.
-+ save_CFLAGS="$CFLAGS"
-+ CFLAGS="$CFLAGS -Werror"
-+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-+/* end confdefs.h. */
++ rpm_init_done = 1;
++ }
+
-+/* Duplicate here the declarations to verify they match "elfread.c". */
-+#include <rpm/rpmlib.h>
-+#include <rpm/rpmts.h>
-+#include <rpm/rpmdb.h>
-+#include <rpm/header.h>
-+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
-+extern int rpmReadConfigFiles(const char * file, const char * target);
-+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
-+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
-+extern rpmts rpmtsCreate(void);
-+extern rpmts rpmtsFree(rpmts ts);
-+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
-+ const void * keyp, size_t keylen);
++ ts = rpmtsCreate_p ();
+
-+int
-+main ()
-+{
++ mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
++ if (mi != NULL)
++ {
++ for (;;)
++ {
++ Header h;
++ char *debuginfo, **slot, *s, *s2;
++ errmsg_t err;
++ size_t srcrpmlen = sizeof (".src.rpm") - 1;
++ size_t debuginfolen = sizeof ("-debuginfo") - 1;
++ rpmdbMatchIterator mi_debuginfo;
+
-+ ;
-+ return 0;
-+}
-+_ACEOF
-+if ac_fn_c_try_compile "$LINENO"; then :
++ h = rpmdbNextIterator_p (mi);
++ if (h == NULL)
++ break;
+
-+ LIBRPM_COMPAT=true
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-+$as_echo "yes" >&6; }
++ /* Verify the debuginfo file is not already installed. */
+
-+else
++ debuginfo = headerFormat_p (h, "%{sourcerpm}-debuginfo.%{arch}",
++ &err);
++ if (!debuginfo)
++ {
++ warning (_("Error querying the rpm file `%s': %s"), filename,
++ err);
++ continue;
++ }
++ /* s = `.src.rpm-debuginfo.%{arch}' */
++ s = strrchr (debuginfo, '-') - srcrpmlen;
++ s2 = NULL;
++ if (s > debuginfo && memcmp (s, ".src.rpm", srcrpmlen) == 0)
++ {
++ /* s2 = `-%{release}.src.rpm-debuginfo.%{arch}' */
++ s2 = memrchr (debuginfo, '-', s - debuginfo);
++ }
++ if (s2)
++ {
++ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
++ s2 = memrchr (debuginfo, '-', s2 - debuginfo);
++ }
++ if (!s2)
++ {
++ warning (_("Error querying the rpm file `%s': %s"), filename,
++ debuginfo);
++ xfree (debuginfo);
++ continue;
++ }
++ /* s = `.src.rpm-debuginfo.%{arch}' */
++ /* s2 = `-%{version}-%{release}.src.rpm-debuginfo.%{arch}' */
++ memmove (s2 + debuginfolen, s2, s - s2);
++ memcpy (s2, "-debuginfo", debuginfolen);
++ /* s = `XXXX.%{arch}' */
++ /* strlen ("XXXX") == srcrpmlen + debuginfolen */
++ /* s2 = `-debuginfo-%{version}-%{release}XX.%{arch}' */
++ /* strlen ("XX") == srcrpmlen */
++ memmove (s + debuginfolen, s + srcrpmlen + debuginfolen,
++ strlen (s + srcrpmlen + debuginfolen) + 1);
++ /* s = `-debuginfo-%{version}-%{release}.%{arch}' */
+
-+ LIBRPM_COMPAT=false
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-+$as_echo "no" >&6; }
++ /* RPMDBI_PACKAGES requires keylen == sizeof (int). */
++ /* RPMDBI_LABEL is an interface for NVR-based dbiFindByLabel(). */
++ mi_debuginfo = rpmtsInitIterator_p (ts, RPMDBI_LABEL, debuginfo, 0);
++ xfree (debuginfo);
++ if (mi_debuginfo)
++ {
++ rpmdbFreeIterator_p (mi_debuginfo);
++ count = 0;
++ break;
++ }
+
-+fi
-+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-+ CFLAGS="$save_CFLAGS"
++ /* The allocated memory gets utilized below for MISSING_RPM_HASH. */
++ debuginfo = headerFormat_p (h,
++ "%{name}-%{version}-%{release}.%{arch}",
++ &err);
++ if (!debuginfo)
++ {
++ warning (_("Error querying the rpm file `%s': %s"), filename,
++ err);
++ continue;
++ }
+
-+ if ! $LIBRPM_COMPAT; then
-+ HAVE_LIBRPM=false
-+ RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
-+ fi
-+ fi
++ /* Base package name for `debuginfo-install'. We do not use the
++ `yum' command directly as the line
++ yum --enablerepo='*debug*' install NAME-debuginfo.ARCH
++ would be more complicated than just:
++ debuginfo-install NAME-VERSION-RELEASE.ARCH
++ Do not supply the rpm base name (derived from .src.rpm name) as
++ debuginfo-install is unable to install the debuginfo package if
++ the base name PKG binary rpm is not installed while for example
++ PKG-libs would be installed (RH Bug 467901).
++ FUTURE: After multiple debuginfo versions simultaneously installed
++ get supported the support for the VERSION-RELEASE tags handling
++ may need an update. */
+
-+ if $HAVE_LIBRPM; then
++ if (missing_rpm_hash == NULL)
++ {
++ /* DEL_F is passed NULL as MISSING_RPM_LIST's HTAB_DELETE
++ should not deallocate the entries. */
+
-+$as_echo "#define HAVE_LIBRPM 1" >>confdefs.h
++ missing_rpm_hash = htab_create_alloc (64, htab_hash_string,
++ (int (*) (const void *, const void *)) streq,
++ NULL, xcalloc, xfree);
++ }
++ slot = (char **) htab_find_slot (missing_rpm_hash, debuginfo, INSERT);
++ /* XCALLOC never returns NULL. */
++ gdb_assert (slot != NULL);
++ if (*slot == NULL)
++ {
++ struct missing_rpm *missing_rpm;
+
-+ CFLAGS="$CFLAGS $RPM_CFLAGS"
-+ LIBS="$LIBS $RPM_LIBS"
-+ else
-+ if $RPM_REQUIRE; then
-+ as_fn_error "$RPM_PKG_ERRORS" "$LINENO" 5
-+ else
-+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $RPM_PKG_ERRORS" >&5
-+$as_echo "$as_me: WARNING: $RPM_PKG_ERRORS" >&2;}
-+ fi
-+ fi
-+ fi
-+fi
++ *slot = debuginfo;
+
-
-
- subdirs="$subdirs testsuite"
-Index: gdb-7.6/gdb/configure.ac
-===================================================================
---- gdb-7.6.orig/gdb/configure.ac 2013-07-17 19:51:01.666356964 +0200
-+++ gdb-7.6/gdb/configure.ac 2013-07-17 19:51:02.692357665 +0200
-@@ -166,6 +166,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escap
- [Directories safe to hold auto-loaded files.])
- AC_MSG_RESULT([$with_auto_load_safe_path])
-
-+# Integration with rpm library to support missing debuginfo suggestions.
-+# --without-rpm: Disable any rpm support.
-+# --with-rpm=libname.so: Try to dynamically open `libname.so' during runtime.
-+# Even with runtime missing `libname.so' GDB will still other run correctly.
-+# Missing `libname.so' during ./configure will abort the configuration.
-+# --with-rpm=librpm.so: Like `--with-rpm=libname.so' but try to find specific
-+# minor version first such as `librpm-4.6.so' as minor version differences
-+# mean API+ABI incompatibility. If the specific match versioned library name
-+# could not be found still open dynamically at least `librpm.so'.
-+# --with-rpm: Like `--with-rpm=librpm.so' but if any of its detection fails try
-+# to find librpm for compilation-time linking by pkg-config. GDB binary will
-+# be probably linked with the version specific library (as `librpm-4.6.so').
-+# Failure to find librpm by pkg-config will abort the configuration.
-+# (default) --with-rpm=auto: Like `--with-rpm=librpm.so' but if even pkg-config
-+# cannot find librpm use to the rpmless compilation (like `--without-rpm').
++ missing_rpm = xmalloc (sizeof (*missing_rpm) + strlen (debuginfo));
++ strcpy (missing_rpm->rpm, debuginfo);
++ missing_rpm->next = missing_rpm_list;
++ missing_rpm_list = missing_rpm;
++ missing_rpm_list_entries++;
++ }
++ else
++ xfree (debuginfo);
++ count++;
++ }
+
-+AC_ARG_WITH([rpm],
-+ [AS_HELP_STRING([--with-rpm],
-+ [query rpm database for missing debuginfos (yes/no, def. auto=librpm.so)])], [], [with_rpm="auto"])
++ rpmdbFreeIterator_p (mi);
++ }
+
-+m4_pattern_allow([^AC_MSG_ERROR$])
-+m4_pattern_allow([^AC_MSG_WARN$])
-+if test "x$with_rpm" != "xno"; then
-+ if test "x$with_rpm" = "xyes"; then
-+ LIBRPM="librpm.so"
-+ RPM_REQUIRE=true
-+ DLOPEN_REQUIRE=false
-+ elif test "x$with_rpm" = "xauto"; then
-+ LIBRPM="librpm.so"
-+ RPM_REQUIRE=false
-+ DLOPEN_REQUIRE=false
-+ else
-+ LIBRPM="$with_rpm"
-+ RPM_REQUIRE=true
-+ DLOPEN_REQUIRE=true
-+ fi
-+ LIBRPM_STRING='"'"$LIBRPM"'"'
++ rpmtsFree_p (ts);
+
-+ AC_MSG_CHECKING([specific librpm version])
-+ HAVE_DLOPEN_LIBRPM=false
-+ save_LIBS="$LIBS"
-+ LIBS="$LIBS -ldl"
-+ AC_RUN_IFELSE(AC_LANG_PROGRAM([[
-+#include <rpm/rpmlib.h>
-+#include <dlfcn.h>
-+#include <errno.h>
-+ ]], [[
-+ void *h;
-+ const char *const *rpmverp;
-+ FILE *f;
++ return count;
++}
+
-+ f = fopen ("conftest.out", "w");
-+ if (!f)
-+ {
-+ fprintf (stderr, "Cannot write \"%s\": %s\n", "conftest.out",
-+ strerror (errno));
-+ return 1;
-+ }
-+ h = dlopen ($LIBRPM_STRING, RTLD_LAZY);
-+ if (!h)
-+ {
-+ fprintf (stderr, "dlopen (\"%s\"): %s\n", $LIBRPM_STRING, dlerror ());
-+ return 1;
-+ }
-+ rpmverp = dlsym (h, "RPMVERSION");
-+ if (!rpmverp)
-+ {
-+ fprintf (stderr, "dlsym (\"RPMVERSION\"): %s\n", dlerror ());
-+ return 1;
-+ }
-+ fprintf (stderr, "RPMVERSION is: \"");
-+ fprintf (stderr, "%s\"\n", *rpmverp);
++static int
++missing_rpm_list_compar (const char *const *ap, const char *const *bp)
++{
++ return strcoll (*ap, *bp);
++}
+
-+ /* Try to find the specific librpm version only for "librpm.so" as we do
-+ not know how to assemble the version string otherwise. */
++/* It returns a NULL-terminated array of strings needing to be FREEd. It may
++ also return only NULL. */
+
-+ if (strcmp ("librpm.so", $LIBRPM_STRING) != 0)
-+ {
-+ fprintf (f, "%s\n", $LIBRPM_STRING);
-+ return 0;
-+ }
-+ else
-+ {
-+ char *h2_name;
-+ void *h2;
-+ int major, minor;
++static void
++missing_rpm_list_print (void)
++{
++ char **array, **array_iter;
++ struct missing_rpm *list_iter;
++ struct cleanup *cleanups;
+
-+ if (sscanf (*rpmverp, "%d.%d", &major, &minor) != 2)
-+ {
-+ fprintf (stderr, "Unable to parse RPMVERSION.\n");
-+ fprintf (f, "%s\n", $LIBRPM_STRING);
-+ return 0;
-+ }
-+ /* Avoid the square brackets by malloc. */
-+ h2_name = malloc (64);
-+ sprintf (h2_name, "librpm-%d.%d.so", major, minor);
-+ h2 = dlopen (h2_name, RTLD_LAZY);
-+ if (!h2)
-+ {
-+ fprintf (stderr, "dlopen (\"%s\"): %s\n", h2_name, dlerror ());
-+ fprintf (f, "%s\n", $LIBRPM_STRING);
-+ return 0;
-+ }
-+ if (h2 != h)
-+ {
-+ fprintf (stderr, "dlopen of \"%s\" and \"%s\" are different.\n",
-+ $LIBRPM_STRING, h2_name);
-+ fprintf (f, "%s\n", $LIBRPM_STRING);
-+ return 0;
-+ }
-+ /* Found the valid .so name with a specific version. */
-+ fprintf (f, "%s\n", h2_name);
-+ return 0;
-+ }
-+ ]]), [
-+ DLOPEN_LIBRPM="`cat conftest.out`"
-+ if test "x$DLOPEN_LIBRPM" != "x"; then
-+ HAVE_DLOPEN_LIBRPM=true
-+ AC_MSG_RESULT($DLOPEN_LIBRPM)
-+ fi
-+ ])
-+ rm -f conftest.out
++ if (missing_rpm_list_entries == 0)
++ return;
+
-+ m4_define([CHECK_LIBRPM_COMPAT], [
-+ AC_MSG_CHECKING([rpm library API compatibility])
-+ # The compilation requires -Werror to verify anything.
-+ save_CFLAGS="$CFLAGS"
-+ CFLAGS="$CFLAGS -Werror"
-+ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[
-+/* Duplicate here the declarations to verify they match "elfread.c". */
-+#include <rpm/rpmlib.h>
-+#include <rpm/rpmts.h>
-+#include <rpm/rpmdb.h>
-+#include <rpm/header.h>
-+extern char * headerFormat(Header h, const char * fmt, errmsg_t * errmsg);
-+extern int rpmReadConfigFiles(const char * file, const char * target);
-+extern rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi);
-+extern Header rpmdbNextIterator(rpmdbMatchIterator mi);
-+extern rpmts rpmtsCreate(void);
-+extern rpmts rpmtsFree(rpmts ts);
-+extern rpmdbMatchIterator rpmtsInitIterator(const rpmts ts, rpmTag rpmtag,
-+ const void * keyp, size_t keylen);
-+ ]]), [
-+ LIBRPM_COMPAT=true
-+ AC_MSG_RESULT(yes)
-+ ], [
-+ LIBRPM_COMPAT=false
-+ AC_MSG_RESULT(no)
-+ ])
-+ CFLAGS="$save_CFLAGS"
-+ ])
++ array = xmalloc (sizeof (*array) * missing_rpm_list_entries);
++ cleanups = make_cleanup (xfree, array);
+
-+ if $HAVE_DLOPEN_LIBRPM; then
-+ CHECK_LIBRPM_COMPAT
-+ if ! $LIBRPM_COMPAT; then
-+ HAVE_DLOPEN_LIBRPM=false
-+ fi
-+ fi
++ array_iter = array;
++ for (list_iter = missing_rpm_list; list_iter != NULL;
++ list_iter = list_iter->next)
++ {
++ *array_iter++ = list_iter->rpm;
++ }
++ gdb_assert (array_iter == array + missing_rpm_list_entries);
+
-+ if $HAVE_DLOPEN_LIBRPM; then
-+ DLOPEN_LIBRPM_STRING='"'"$DLOPEN_LIBRPM"'"'
-+ AC_DEFINE_UNQUOTED(DLOPEN_LIBRPM, $DLOPEN_LIBRPM_STRING, [librpm version specific library name to dlopen.])
-+ AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
-+ else
-+ AC_MSG_RESULT(no)
-+ LIBS="$save_LIBS"
-+ if $DLOPEN_REQUIRE; then
-+ AC_MSG_ERROR([Specific name $LIBRPM was requested but it could not be opened.])
-+ fi
-+ PKG_CHECK_MODULES(RPM, rpm, [HAVE_LIBRPM=true], [HAVE_LIBRPM=false])
++ qsort (array, missing_rpm_list_entries, sizeof (*array),
++ (int (*) (const void *, const void *)) missing_rpm_list_compar);
+
-+ if $HAVE_LIBRPM; then
-+ CHECK_LIBRPM_COMPAT
-+ if ! $LIBRPM_COMPAT; then
-+ HAVE_LIBRPM=false
-+ RPM_PKG_ERRORS="Found $LIBRPM API is incompatibile with this GDB"
-+ fi
-+ fi
++ printf_unfiltered (_("Missing separate debuginfos, use: %s"),
++ "debuginfo-install");
++ for (array_iter = array; array_iter < array + missing_rpm_list_entries;
++ array_iter++)
++ {
++ putchar_unfiltered (' ');
++ puts_unfiltered (*array_iter);
++ }
++ putchar_unfiltered ('\n');
+
-+ if $HAVE_LIBRPM; then
-+ AC_DEFINE(HAVE_LIBRPM, 1, [Define if librpm library is being used.])
-+ CFLAGS="$CFLAGS $RPM_CFLAGS"
-+ LIBS="$LIBS $RPM_LIBS"
-+ else
-+ if $RPM_REQUIRE; then
-+ AC_MSG_ERROR($RPM_PKG_ERRORS)
-+ else
-+ AC_MSG_WARN($RPM_PKG_ERRORS)
-+ fi
-+ fi
-+ fi
-+fi
-+
- AC_CONFIG_SUBDIRS(testsuite)
++ while (missing_rpm_list != NULL)
++ {
++ list_iter = missing_rpm_list;
++ missing_rpm_list = list_iter->next;
++ xfree (list_iter);
++ }
++ missing_rpm_list_entries = 0;
++
++ do_cleanups (cleanups);
++}
++
++static void
++missing_rpm_change (void)
++{
++ debug_flush_missing ();
++
++ gdb_assert (missing_rpm_list == NULL);
++ if (missing_rpm_hash != NULL)
++ {
++ htab_delete (missing_rpm_hash);
++ missing_rpm_hash = NULL;
++ }
++}
++
++enum missing_exec
++ {
++ /* Init state. EXEC_BFD also still could be NULL. */
++ MISSING_EXEC_NOT_TRIED,
++ /* We saw a non-NULL EXEC_BFD but RPM has no info about it. */
++ MISSING_EXEC_NOT_FOUND,
++ /* We found EXEC_BFD by RPM and we either have its symbols (either embedded
++ or separate) or the main executable's RPM is now contained in
++ MISSING_RPM_HASH. */
++ MISSING_EXEC_ENLISTED
++ };
++static enum missing_exec missing_exec = MISSING_EXEC_NOT_TRIED;
++
++#endif /* HAVE_LIBRPM */
++
++void
++debug_flush_missing (void)
++{
++#ifdef HAVE_LIBRPM
++ missing_rpm_list_print ();
++#endif
++}
++
+ /* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
+- Try to install the hash file ...
++ yum --enablerepo='*debug*' install ...
+ avoidance. */
- # Check whether to support alternative target configurations
-Index: gdb-7.6/gdb/corelow.c
-===================================================================
---- gdb-7.6.orig/gdb/corelow.c 2013-07-17 19:51:02.608357607 +0200
-+++ gdb-7.6/gdb/corelow.c 2013-07-17 19:51:02.692357665 +0200
-@@ -314,7 +314,7 @@ build_id_locate_exec (int from_tty)
- symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
+ struct missing_filepair
+@@ -721,11 +1074,17 @@ missing_filepair_change (void)
+ /* All their memory came just from missing_filepair_OBSTACK. */
+ missing_filepair_hash = NULL;
}
- else
-- debug_print_missing (_("the main executable file"), build_id_filename);
-+ debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename);
++#ifdef HAVE_LIBRPM
++ missing_exec = MISSING_EXEC_NOT_TRIED;
++#endif
+ }
- do_cleanups (back_to);
+ static void
+ debug_print_executable_changed (void)
+ {
++#ifdef HAVE_LIBRPM
++ missing_rpm_change ();
++#endif
+ missing_filepair_change ();
+ }
+
+@@ -792,14 +1151,34 @@ debug_print_missing (const char *binary,
+
+ *slot = missing_filepair;
+
+- /* We do not collect and flush these messages as each such message
+- already requires its own separate lines. */
++#ifdef HAVE_LIBRPM
++ if (missing_exec == MISSING_EXEC_NOT_TRIED)
++ {
++ char *execfilename;
+
+- fprintf_unfiltered (gdb_stdlog,
+- _("Missing separate debuginfo for %s\n"), binary);
+- if (debug != NULL)
+- fprintf_unfiltered (gdb_stdlog, _("Try to install the hash file %s\n"),
+- debug);
++ execfilename = get_exec_file (0);
++ if (execfilename != NULL)
++ {
++ if (missing_rpm_enlist (execfilename) == 0)
++ missing_exec = MISSING_EXEC_NOT_FOUND;
++ else
++ missing_exec = MISSING_EXEC_ENLISTED;
++ }
++ }
++ if (missing_exec != MISSING_EXEC_ENLISTED)
++ if ((binary[0] == 0 || missing_rpm_enlist (binary) == 0)
++ && (debug == NULL || missing_rpm_enlist (debug) == 0))
++#endif /* HAVE_LIBRPM */
++ {
++ /* We do not collect and flush these messages as each such message
++ already requires its own separate lines. */
++
++ fprintf_unfiltered (gdb_stdlog,
++ _("Missing separate debuginfo for %s\n"), binary);
++ if (debug != NULL)
++ fprintf_unfiltered (gdb_stdlog, _("Try: %s %s\n"),
++ "yum --enablerepo='*debug*' install", debug);
++ }
+ }
+ /* See build-id.h. */
diff --git a/gdb-6.6-buildid-locate.patch b/gdb-6.6-buildid-locate.patch
index 7a473c7..d3bc4a5 100644
--- a/gdb-6.6-buildid-locate.patch
+++ b/gdb-6.6-buildid-locate.patch
@@ -1,18 +1,19 @@
-Index: gdb-7.6/gdb/corelow.c
+Index: gdb-7.6.90.20140127/gdb/corelow.c
===================================================================
---- gdb-7.6.orig/gdb/corelow.c 2013-01-31 19:37:37.000000000 +0100
-+++ gdb-7.6/gdb/corelow.c 2013-07-17 05:28:49.277203536 +0200
-@@ -46,6 +46,9 @@
- #include "progspace.h"
- #include "objfiles.h"
+--- gdb-7.6.90.20140127.orig/gdb/corelow.c 2014-01-27 02:57:53.000000000 +0100
++++ gdb-7.6.90.20140127/gdb/corelow.c 2014-02-06 16:46:52.261646499 +0100
+@@ -48,6 +48,10 @@
#include "gdb_bfd.h"
+ #include "completer.h"
+ #include "filestuff.h"
+#include "auxv.h"
+#include "elf/common.h"
+#include "gdbcmd.h"
++#include "build-id.h"
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
-@@ -271,6 +274,53 @@ add_to_thread_list (bfd *abfd, asection
+@@ -271,6 +275,53 @@ add_to_thread_list (bfd *abfd, asection
inferior_ptid = ptid; /* Yes, make it current. */
}
@@ -44,7 +45,7 @@ Index: gdb-7.6/gdb/corelow.c
+ file - such .eh_frame would not be found if SYMFILE_OBJFILE would refer
+ directly to the separate debug info file. */
+
-+ execfilename = build_id_to_filename (build_id, &build_id_filename, 0);
++ execfilename = build_id_to_filename (build_id, &build_id_filename);
+ make_cleanup (xfree, build_id_filename);
+
+ if (execfilename != NULL)
@@ -66,7 +67,7 @@ Index: gdb-7.6/gdb/corelow.c
/* This routine opens and sets up the core file bfd. */
static void
-@@ -409,6 +459,14 @@ core_open (char *filename, int from_tty)
+@@ -409,6 +460,14 @@ core_open (char *filename, int from_tty)
switch_to_thread (thread->ptid);
}
@@ -81,10 +82,10 @@ Index: gdb-7.6/gdb/corelow.c
post_create_inferior (&core_ops, from_tty);
/* Now go through the target stack looking for threads since there
-@@ -978,4 +1036,11 @@ _initialize_corelow (void)
+@@ -980,4 +1039,11 @@ _initialize_corelow (void)
init_core_ops ();
- add_target (&core_ops);
+ add_target_with_completer (&core_ops, filename_completer);
+
+ add_setshow_boolean_cmd ("build-id-core-loads", class_files,
+ &build_id_core_loads, _("\
@@ -93,11 +94,11 @@ Index: gdb-7.6/gdb/corelow.c
+ NULL, NULL, NULL,
+ &setlist, &showlist);
}
-Index: gdb-7.6/gdb/doc/gdb.texinfo
+Index: gdb-7.6.90.20140127/gdb/doc/gdb.texinfo
===================================================================
---- gdb-7.6.orig/gdb/doc/gdb.texinfo 2013-07-17 05:28:48.882203384 +0200
-+++ gdb-7.6/gdb/doc/gdb.texinfo 2013-07-17 05:28:49.286203539 +0200
-@@ -16831,6 +16831,27 @@ information files.
+--- gdb-7.6.90.20140127.orig/gdb/doc/gdb.texinfo 2014-02-06 16:46:51.804645989 +0100
++++ gdb-7.6.90.20140127/gdb/doc/gdb.texinfo 2014-02-06 16:46:52.110646331 +0100
+@@ -17413,6 +17413,27 @@ information files.
@end table
@@ -125,11 +126,19 @@ Index: gdb-7.6/gdb/doc/gdb.texinfo
@cindex @code{.gnu_debuglink} sections
@cindex debug link sections
A debug link is a special section of the executable file named
-Index: gdb-7.6/gdb/solib-svr4.c
+Index: gdb-7.6.90.20140127/gdb/solib-svr4.c
===================================================================
---- gdb-7.6.orig/gdb/solib-svr4.c 2013-01-31 14:52:52.000000000 +0100
-+++ gdb-7.6/gdb/solib-svr4.c 2013-07-17 05:28:49.287203539 +0200
-@@ -1224,9 +1224,52 @@ svr4_read_so_list (CORE_ADDR lm, struct
+--- gdb-7.6.90.20140127.orig/gdb/solib-svr4.c 2014-01-27 02:57:53.000000000 +0100
++++ gdb-7.6.90.20140127/gdb/solib-svr4.c 2014-02-06 16:49:27.508819174 +0100
+@@ -47,6 +47,7 @@
+ #include "exceptions.h"
+ #include "gdb_bfd.h"
+ #include "probe.h"
++#include "build-id.h"
+
+ static struct link_map_offsets *svr4_fetch_link_map_offsets (void);
+ static int svr4_have_link_map_offsets (void);
+@@ -1369,9 +1370,52 @@ svr4_read_so_list (CORE_ADDR lm, CORE_AD
continue;
}
@@ -151,7 +160,7 @@ Index: gdb-7.6/gdb/solib-svr4.c
+
+ /* Missing the build-id matching separate debug info file
+ would be handled while SO_NAME gets loaded. */
-+ name = build_id_to_filename (build_id, &build_id_filename, 0);
++ name = build_id_to_filename (build_id, &build_id_filename);
+ if (name != NULL)
+ {
+ strncpy (new->so_name, name, SO_NAME_MAX_PATH_SIZE - 1);
@@ -185,27 +194,160 @@ Index: gdb-7.6/gdb/solib-svr4.c
xfree (buffer);
/* If this entry has no name, or its name matches the name
-Index: gdb-7.6/gdb/elfread.c
+Index: gdb-7.6.90.20140127/gdb/elfread.c
===================================================================
---- gdb-7.6.orig/gdb/elfread.c 2013-03-18 10:20:02.000000000 +0100
-+++ gdb-7.6/gdb/elfread.c 2013-07-17 05:31:21.242256141 +0200
-@@ -45,6 +45,11 @@
- #include "regcache.h"
- #include "bcache.h"
- #include "gdb_bfd.h"
+--- gdb-7.6.90.20140127.orig/gdb/elfread.c 2014-01-27 02:57:53.000000000 +0100
++++ gdb-7.6.90.20140127/gdb/elfread.c 2014-02-06 16:46:52.249646486 +0100
+@@ -1316,9 +1316,10 @@ elf_symfile_read (struct objfile *objfil
+ && objfile->separate_debug_objfile == NULL
+ && objfile->separate_debug_objfile_backlink == NULL)
+ {
+- char *debugfile;
++ char *debugfile, *build_id_filename;
+
+- debugfile = find_separate_debug_file_by_buildid (objfile);
++ debugfile = find_separate_debug_file_by_buildid (objfile,
++ &build_id_filename);
+
+ if (debugfile == NULL)
+ debugfile = find_separate_debug_file_by_debuglink (objfile);
+@@ -1332,6 +1333,12 @@ elf_symfile_read (struct objfile *objfil
+ symbol_file_add_separate (abfd, debugfile, symfile_flags, objfile);
+ do_cleanups (cleanup);
+ }
++ /* Check if any separate debug info has been extracted out. */
++ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink")
++ != NULL)
++ debug_print_missing (objfile_name (objfile), build_id_filename);
++
++ xfree (build_id_filename);
+ }
+ }
+
+Index: gdb-7.6.90.20140127/gdb/symfile.h
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/symfile.h 2014-01-27 02:57:53.000000000 +0100
++++ gdb-7.6.90.20140127/gdb/symfile.h 2014-02-06 16:46:52.250646487 +0100
+@@ -554,6 +554,10 @@ void free_symfile_segment_data (struct s
+
+ extern struct cleanup *increment_reading_symtab (void);
+
++/* build-id support. */
++extern struct elf_build_id *build_id_addr_get (CORE_ADDR addr);
++extern void debug_print_missing (const char *binary, const char *debug);
++
+ /* From dwarf2read.c */
+
+ /* Names for a dwarf2 debugging section. The field NORMAL is the normal
+Index: gdb-7.6.90.20140127/gdb/testsuite/lib/gdb.exp
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/testsuite/lib/gdb.exp 2014-02-06 16:46:51.643645810 +0100
++++ gdb-7.6.90.20140127/gdb/testsuite/lib/gdb.exp 2014-02-06 16:46:52.251646488 +0100
+@@ -1504,6 +1504,16 @@ proc default_gdb_start { } {
+ warning "Couldn't set the width to 0."
+ }
+ }
++ # Turn off the missing warnings as the testsuite does not expect it.
++ send_gdb "set build-id-verbose 0\n"
++ gdb_expect 10 {
++ -re "$gdb_prompt $" {
++ verbose "Disabled the missing debug infos warnings." 2
++ }
++ timeout {
++ warning "Could not disable the missing debug infos warnings.."
++ }
++ }
+ return 0
+ }
+
+Index: gdb-7.6.90.20140127/gdb/testsuite/lib/mi-support.exp
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/testsuite/lib/mi-support.exp 2014-01-27 02:57:54.000000000 +0100
++++ gdb-7.6.90.20140127/gdb/testsuite/lib/mi-support.exp 2014-02-06 16:46:52.252646489 +0100
+@@ -212,6 +212,16 @@ proc default_mi_gdb_start { args } {
+ warning "Couldn't set the width to 0."
+ }
+ }
++ # Turn off the missing warnings as the testsuite does not expect it.
++ send_gdb "190-gdb-set build-id-verbose 0\n"
++ gdb_expect 10 {
++ -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
++ verbose "Disabled the missing debug infos warnings." 2
++ }
++ timeout {
++ warning "Could not disable the missing debug infos warnings.."
++ }
++ }
+ # If allowing the inferior to have its own PTY then assign the inferior
+ # its own terminal device here.
+ if { $separate_inferior_pty } {
+Index: gdb-7.6.90.20140127/gdb/objfiles.h
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/objfiles.h 2014-01-27 02:57:53.000000000 +0100
++++ gdb-7.6.90.20140127/gdb/objfiles.h 2014-02-06 16:46:52.113646334 +0100
+@@ -436,6 +436,10 @@ struct objfile
+
+ #define OBJF_NOT_FILENAME (1 << 6)
+
++/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */
++
++#define OBJF_BUILD_ID_CORE_LOADED (1 << 12)
++
+ /* Declarations for functions defined in objfiles.c */
+
+ extern struct objfile *allocate_objfile (bfd *, const char *name, int);
+Index: gdb-7.6.90.20140127/gdb/testsuite/gdb.base/corefile.exp
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/testsuite/gdb.base/corefile.exp 2014-01-27 02:57:54.000000000 +0100
++++ gdb-7.6.90.20140127/gdb/testsuite/gdb.base/corefile.exp 2014-02-06 16:46:52.113646334 +0100
+@@ -281,3 +281,33 @@ gdb_test_multiple "core-file $corefile"
+ pass $test
+ }
+ }
++
++
++# Test auto-loading of binary files through build-id from the core file.
++set buildid [build_id_debug_filename_get $binfile]
++set wholetest "binfile found by build-id"
++if {$buildid == ""} {
++ untested "$wholetest (binary has no build-id)"
++} else {
++ gdb_exit
++ gdb_start
++
++ regsub {\.debug$} $buildid {} buildid
++ set debugdir ${objdir}/${subdir}/${testfile}-debugdir
++ file delete -force -- $debugdir
++ file mkdir $debugdir/[file dirname $buildid]
++ file copy $binfile $debugdir/$buildid
++
++ set test "show debug-file-directory"
++ gdb_test_multiple $test $test {
++ -re "The directory where separate debug symbols are searched for is \"(.*)\"\\.\r\n$gdb_prompt $" {
++ set debugdir_orig $expect_out(1,string)
++ pass $test
++ }
++ }
++ gdb_test_no_output "set debug-file-directory $debugdir:$debugdir_orig" "set debug-file-directory"
++ gdb_test "show build-id-core-loads" {Whether CORE-FILE loads the build-id associated files automatically is on\.}
++ gdb_test "core-file $corefile" "\r\nProgram terminated with .*" "core-file without executable"
++ gdb_test "info files" "Local exec file:\r\n\[ \t\]*`[string_to_regexp $debugdir/$buildid]', file type .*"
++ pass $wholetest
++}
+Index: gdb-7.6.90.20140127/gdb/build-id.c
+===================================================================
+--- gdb-7.6.90.20140127.orig/gdb/build-id.c 2014-01-27 02:57:53.000000000 +0100
++++ gdb-7.6.90.20140127/gdb/build-id.c 2014-02-06 16:46:52.113646334 +0100
+@@ -27,11 +27,65 @@
+ #include "symfile.h"
+ #include "objfiles.h"
+ #include "filenames.h"
+#include "libbfd.h"
+#include "gdbcore.h"
+#include "gdbcmd.h"
+#include "observer.h"
+#include <sys/stat.h>
-
- extern void _initialize_elfread (void);
-
-@@ -1068,10 +1073,59 @@ elf_gnu_ifunc_resolver_return_stop (stru
- update_breakpoint_locations (b, sals, sals_end);
- }
-
--/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
++
+#define BUILD_ID_VERBOSE_NONE 0
+#define BUILD_ID_VERBOSE_FILENAMES 1
+#define BUILD_ID_VERBOSE_BINARY_PARSE 2
@@ -220,7 +362,8 @@ Index: gdb-7.6/gdb/elfread.c
+
+/* Locate NT_GNU_BUILD_ID and return its matching debug filename.
+ FIXME: NOTE decoding should be unified with the BFD core notes decoding. */
-+
+
+-/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
+static struct elf_build_id *
+build_id_buf_get (bfd *templ, gdb_byte *buf, bfd_size_type size)
+{
@@ -233,7 +376,7 @@ Index: gdb-7.6/gdb/elfread.c
+ Elf_External_Note *xnp = (Elf_External_Note *) p;
+ size_t namesz = H_GET_32 (templ, xnp->namesz);
+ size_t descsz = H_GET_32 (templ, xnp->descsz);
-+ bfd_byte *descdata = xnp->name + BFD_ALIGN (namesz, 4);
++ bfd_byte *descdata = (gdb_byte *) xnp->name + BFD_ALIGN (namesz, 4);
+
+ if (H_GET_32 (templ, xnp->type) == NT_GNU_BUILD_ID
+ && namesz == sizeof "GNU"
@@ -253,17 +396,17 @@ Index: gdb-7.6/gdb/elfread.c
+ }
+ return NULL;
+}
-+
+
+/* Separate debuginfo files have corrupted PHDR but SHDR is correct there.
+ Locate NT_GNU_BUILD_ID from ABFD and return its content. */
-
++
static const struct elf_build_id *
-build_id_bfd_get (bfd *abfd)
+build_id_bfd_shdr_get (bfd *abfd)
{
if (!bfd_check_format (abfd, bfd_object)
|| bfd_get_flavour (abfd) != bfd_target_elf_flavour
-@@ -1081,6 +1135,348 @@ build_id_bfd_get (bfd *abfd)
+@@ -45,6 +99,348 @@ build_id_bfd_get (bfd *abfd)
return elf_tdata (abfd)->build_id;
}
@@ -609,23 +752,23 @@ Index: gdb-7.6/gdb/elfread.c
+ return retval;
+}
+
- /* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */
+ /* See build-id.h. */
- static int
-@@ -1095,7 +1491,7 @@ build_id_verify (const char *filename, c
- if (abfd == NULL)
- return 0;
+ int
+@@ -53,7 +449,7 @@ build_id_verify (bfd *abfd, size_t check
+ const struct elf_build_id *found;
+ int retval = 0;
- found = build_id_bfd_get (abfd);
+ found = build_id_bfd_shdr_get (abfd);
if (found == NULL)
- warning (_("File \"%s\" has no build-id, file skipped"), filename);
-@@ -1112,16 +1508,53 @@ build_id_verify (const char *filename, c
+ warning (_("File \"%s\" has no build-id, file skipped"),
+@@ -68,20 +464,56 @@ build_id_verify (bfd *abfd, size_t check
+ return retval;
}
- static char *
--build_id_to_debug_filename (const struct elf_build_id *build_id)
++static char *
+link_resolve (const char *symlink, int level)
+{
+ char buf[PATH_MAX + 1], *target, *retval;
@@ -661,28 +804,33 @@ Index: gdb-7.6/gdb/elfread.c
+ return retval;
+}
+
-+char *
-+build_id_to_filename (const struct elf_build_id *build_id, char **link_return,
-+ int add_debug_suffix)
+ /* See build-id.h. */
+
+ bfd *
+-build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
++build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id,
++ char **link_return, int add_debug_suffix)
{
- char *link, *debugdir, *retval = NULL;
-+ char *link_all = NULL;
+- char *link, *debugdir;
++ char *link, *debugdir, *link_all = NULL;
VEC (char_ptr) *debugdir_vec;
struct cleanup *back_to;
int ix;
+ bfd *abfd = NULL;
/* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */
- link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
-- + 2 * build_id->size + (sizeof ".debug" - 1) + 1);
-+ link = xmalloc (strlen (debug_file_directory) + 2 * build_id->size + 50);
+- + 2 * build_id_len + (sizeof ".debug" - 1) + 1);
++ link = xmalloc (strlen (debug_file_directory) + 2 * build_id_len + 50);
/* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
cause "/.build-id/..." lookups. */
-@@ -1134,7 +1567,10 @@ build_id_to_debug_filename (const struct
+@@ -94,8 +526,11 @@ build_id_to_debug_bfd (size_t build_id_l
size_t debugdir_len = strlen (debugdir);
- const gdb_byte *data = build_id->data;
- size_t size = build_id->size;
+ const gdb_byte *data = build_id;
+ size_t size = build_id_len;
- char *s;
+ char *filename = NULL;
+ unsigned seqno;
+ struct stat statbuf_trash;
+ /* Initialize it just to avoid a GCC false warning. */
@@ -690,19 +838,18 @@ Index: gdb-7.6/gdb/elfread.c
memcpy (link, debugdir, debugdir_len);
s = &link[debugdir_len];
-@@ -1148,37 +1584,256 @@ build_id_to_debug_filename (const struct
+@@ -109,44 +544,282 @@ build_id_to_debug_bfd (size_t build_id_l
*s++ = '/';
while (size-- > 0)
s += sprintf (s, "%02x", (unsigned) *data++);
- strcpy (s, ".debug");
-
-- /* lrealpath() is expensive even for the usually non-existent files. */
-- if (access (link, F_OK) == 0)
-- retval = lrealpath (link);
+ for (seqno = 0;; seqno++)
+ {
+ char *s2;
-+
+
+- /* lrealpath() is expensive even for the usually non-existent files. */
+- if (access (link, F_OK) == 0)
+- filename = lrealpath (link);
+ if (seqno)
+ {
+ /* There can be multiple build-id symlinks pointing to real files
@@ -733,21 +880,39 @@ Index: gdb-7.6/gdb/elfread.c
+ break;
+ }
+
-+ retval = lrealpath (link);
++ filename = lrealpath (link);
++ if (filename == NULL)
++ continue;
+
-+ if (retval != NULL && !build_id_verify (retval, build_id))
++ /* We expect to be silent on the non-existing files. */
++ abfd = gdb_bfd_open_maybe_remote (filename);
++ if (abfd == NULL)
+ {
-+ xfree (retval);
-+ retval = NULL;
++ xfree (filename);
++ continue;
+ }
-+
-+ if (retval)
+
+- if (filename == NULL)
+- continue;
++ if (build_id_verify (abfd, build_id_len, build_id))
+ break;
+
+- /* We expect to be silent on the non-existing files. */
+- abfd = gdb_bfd_open_maybe_remote (filename);
+- if (abfd == NULL)
+- continue;
++ gdb_bfd_unref (abfd);
++ abfd = NULL;
+
+- if (build_id_verify (abfd, build_id_len, build_id))
+- break;
++ xfree (filename);
++ filename = NULL;
+ }
+
-+ if (retval != NULL)
++ if (filename != NULL)
+ {
-+ /* LINK_ALL is not used below in this non-NULL RETVAL case. */
++ /* LINK_ALL is not used below in this non-NULL FILENAME case. */
+ xfree (link0);
+ break;
+ }
@@ -757,14 +922,11 @@ Index: gdb-7.6/gdb/elfread.c
+ https://bugzilla.redhat.com/show_bug.cgi?id=981154 */
+ link0_resolved = link_resolve (link0, 0);
+ xfree (link0);
-
-- if (retval != NULL && !build_id_verify (retval, build_id))
++
+ if (link_all == NULL)
-+ link_all = xstrdup (link0_resolved);
++ link_all = link0_resolved;
+ else
- {
-- xfree (retval);
-- retval = NULL;
++ {
+ size_t len_orig = strlen (link_all);
+
+ link_all = xrealloc (link_all,
@@ -773,16 +935,17 @@ Index: gdb-7.6/gdb/elfread.c
+ /* Use whitespace instead of DIRNAME_SEPARATOR to be compatible with
+ its possible use as an argument for installation command. */
+ link_all[len_orig] = ' ';
-+
+
+- gdb_bfd_unref (abfd);
+- abfd = NULL;
+ strcpy (&link_all[len_orig + 1], link0_resolved);
- }
-+ xfree (link0_resolved);
++ xfree (link0_resolved);
++ }
+ }
-
++
+ if (link_return != NULL)
+ {
- if (retval != NULL)
-- break;
++ if (abfd != NULL)
+ {
+ *link_return = link;
+ link = NULL;
@@ -797,9 +960,24 @@ Index: gdb-7.6/gdb/elfread.c
+ xfree (link_all);
do_cleanups (back_to);
- return retval;
+ return abfd;
}
++char *
++build_id_to_filename (const struct elf_build_id *build_id, char **link_return)
++{
++ bfd *abfd;
++ char *result;
++
++ abfd = build_id_to_debug_bfd (build_id->size, build_id->data, link_return, 0);
++ if (abfd == NULL)
++ return NULL;
++
++ result = xstrdup (bfd_get_filename (abfd));
++ gdb_bfd_unref (abfd);
++ return result;
++}
++
+/* This MISSING_FILEPAIR_HASH tracker is used only for the duplicite messages
+ Try to install the hash file ...
+ avoidance. */
@@ -936,7 +1114,9 @@ Index: gdb-7.6/gdb/elfread.c
+ debug);
+}
+
- static char *
+ /* See build-id.h. */
+
+ char *
-find_separate_debug_file_by_buildid (struct objfile *objfile)
+find_separate_debug_file_by_buildid (struct objfile *objfile,
+ char **build_id_filename_return)
@@ -950,54 +1130,24 @@ Index: gdb-7.6/gdb/elfread.c
+ build_id = build_id_bfd_shdr_get (objfile->obfd);
if (build_id != NULL)
{
- char *build_id_name;
+ bfd *abfd;
-- build_id_name = build_id_to_debug_filename (build_id);
-+ build_id_name = build_id_to_filename (build_id, build_id_filename_return,
-+ 1);
+- abfd = build_id_to_debug_bfd (build_id->size, build_id->data);
++ abfd = build_id_to_debug_bfd (build_id->size, build_id->data,
++ build_id_filename_return, 1);
/* Prevent looping on a stripped .debug file. */
- if (build_id_name != NULL
- && filename_cmp (build_id_name, objfile->name) == 0)
-@@ -1188,7 +1843,7 @@ find_separate_debug_file_by_buildid (str
- xfree (build_id_name);
- }
- else if (build_id_name != NULL)
-- return build_id_name;
-+ return build_id_name;
+ if (abfd != NULL
+ && filename_cmp (bfd_get_filename (abfd),
+@@ -166,3 +839,21 @@ find_separate_debug_file_by_buildid (str
}
return NULL;
}
-@@ -1426,9 +2081,10 @@ elf_symfile_read (struct objfile *objfil
- && objfile->separate_debug_objfile == NULL
- && objfile->separate_debug_objfile_backlink == NULL)
- {
-- char *debugfile;
-+ char *debugfile, *build_id_filename;
-
-- debugfile = find_separate_debug_file_by_buildid (objfile);
-+ debugfile = find_separate_debug_file_by_buildid (objfile,
-+ &build_id_filename);
-
- if (debugfile == NULL)
- debugfile = find_separate_debug_file_by_debuglink (objfile);
-@@ -1442,6 +2098,12 @@ elf_symfile_read (struct objfile *objfil
- symbol_file_add_separate (abfd, symfile_flags, objfile);
- do_cleanups (cleanup);
- }
-+ /* Check if any separate debug info has been extracted out. */
-+ else if (bfd_get_section_by_name (objfile->obfd, ".gnu_debuglink")
-+ != NULL)
-+ debug_print_missing (objfile->name, build_id_filename);
+
-+ xfree (build_id_filename);
- }
- }
-
-@@ -1761,4 +2423,16 @@ _initialize_elfread (void)
-
- elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
- gnu_ifunc_fns_p = &elf_gnu_ifunc_fns;
++extern void _initialize_build_id (void);
+
++void
++_initialize_build_id (void)
++{
+ add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose,
+ _("\
+Set debugging level of the build-id locator."), _("\
@@ -1009,116 +1159,42 @@ Index: gdb-7.6/gdb/elfread.c
+ &setlist, &showlist);
+
+ observer_attach_executable_changed (debug_print_executable_changed);
- }
-Index: gdb-7.6/gdb/symfile.h
++}
+Index: gdb-7.6.90.20140127/gdb/build-id.h
===================================================================
---- gdb-7.6.orig/gdb/symfile.h 2013-02-03 17:20:18.000000000 +0100
-+++ gdb-7.6/gdb/symfile.h 2013-07-17 05:28:49.291203541 +0200
-@@ -593,6 +593,12 @@ void free_symfile_segment_data (struct s
-
- extern struct cleanup *increment_reading_symtab (void);
+--- gdb-7.6.90.20140127.orig/gdb/build-id.h 2014-01-27 02:57:53.000000000 +0100
++++ gdb-7.6.90.20140127/gdb/build-id.h 2014-02-06 16:46:52.114646335 +0100
+@@ -32,13 +32,18 @@ extern int build_id_verify (bfd *abfd,
+ the caller. */
-+/* build-id support. */
-+extern struct elf_build_id *build_id_addr_get (CORE_ADDR addr);
-+extern char *build_id_to_filename (const struct elf_build_id *build_id,
-+ char **link_return, int add_debug_suffix);
-+extern void debug_print_missing (const char *binary, const char *debug);
+ extern bfd *build_id_to_debug_bfd (size_t build_id_len,
+- const bfd_byte *build_id);
++ const bfd_byte *build_id, char **link_return,
++ int add_debug_suffix);
+
- /* From dwarf2read.c */
++extern char *build_id_to_filename (const struct elf_build_id *build_id,
++ char **link_return);
- /* Names for a dwarf2 debugging section. The field NORMAL is the normal
-Index: gdb-7.6/gdb/testsuite/lib/gdb.exp
-===================================================================
---- gdb-7.6.orig/gdb/testsuite/lib/gdb.exp 2013-07-17 05:28:48.334203172 +0200
-+++ gdb-7.6/gdb/testsuite/lib/gdb.exp 2013-07-17 05:28:49.292203541 +0200
-@@ -1482,6 +1482,16 @@ proc default_gdb_start { } {
- warning "Couldn't set the width to 0."
- }
- }
-+ # Turn off the missing warnings as the testsuite does not expect it.
-+ send_gdb "set build-id-verbose 0\n"
-+ gdb_expect 10 {
-+ -re "$gdb_prompt $" {
-+ verbose "Disabled the missing debug infos warnings." 2
-+ }
-+ timeout {
-+ warning "Could not disable the missing debug infos warnings.."
-+ }
-+ }
- return 0;
- }
+ /* Find the separate debug file for OBJFILE, by using the build-id
+ associated with OBJFILE's BFD. If successful, returns a malloc'd
+ file name for the separate debug file. The caller must free this.
+ Otherwise, returns NULL. */
+
+-extern char *find_separate_debug_file_by_buildid (struct objfile *objfile);
++extern char *find_separate_debug_file_by_buildid (struct objfile *objfile,
++ char **build_id_filename_return);
-Index: gdb-7.6/gdb/testsuite/lib/mi-support.exp
+ #endif /* BUILD_ID_H */
+Index: gdb-7.6.90.20140127/gdb/dwarf2read.c
===================================================================
---- gdb-7.6.orig/gdb/testsuite/lib/mi-support.exp 2013-01-22 00:57:59.000000000 +0100
-+++ gdb-7.6/gdb/testsuite/lib/mi-support.exp 2013-07-17 05:28:49.292203541 +0200
-@@ -212,6 +212,16 @@ proc default_mi_gdb_start { args } {
- warning "Couldn't set the width to 0."
- }
+--- gdb-7.6.90.20140127.orig/gdb/dwarf2read.c 2014-02-06 16:46:51.809645995 +0100
++++ gdb-7.6.90.20140127/gdb/dwarf2read.c 2014-02-06 16:49:55.679850414 +0100
+@@ -2429,7 +2429,7 @@ dwarf2_get_dwz_file (void)
}
-+ # Turn off the missing warnings as the testsuite does not expect it.
-+ send_gdb "190-gdb-set build-id-verbose 0\n"
-+ gdb_expect 10 {
-+ -re ".*190-gdb-set build-id-verbose 0\r\n190\\\^done\r\n$mi_gdb_prompt$" {
-+ verbose "Disabled the missing debug infos warnings." 2
-+ }
-+ timeout {
-+ warning "Could not disable the missing debug infos warnings.."
-+ }
-+ }
- # If allowing the inferior to have its own PTY then assign the inferior
- # its own terminal device here.
- if { $separate_inferior_pty } {
-Index: gdb-7.6/gdb/objfiles.h
-===================================================================
---- gdb-7.6.orig/gdb/objfiles.h 2013-02-28 20:00:31.000000000 +0100
-+++ gdb-7.6/gdb/objfiles.h 2013-07-17 05:28:49.293203542 +0200
-@@ -432,6 +432,10 @@ struct objfile
-
- #define OBJF_MAINLINE (1 << 5)
-
-+/* This file was loaded according to the BUILD_ID_CORE_LOADS rules. */
-+
-+#define OBJF_BUILD_ID_CORE_LOADED (1 << 12)
-+
- /* The object file that contains the runtime common minimal symbols
- for SunOS4. Note that this objfile has no associated BFD. */
-Index: gdb-7.6/gdb/testsuite/gdb.base/corefile.exp
-===================================================================
---- gdb-7.6.orig/gdb/testsuite/gdb.base/corefile.exp 2013-01-01 07:33:25.000000000 +0100
-+++ gdb-7.6/gdb/testsuite/gdb.base/corefile.exp 2013-07-17 05:28:49.293203542 +0200
-@@ -256,3 +256,33 @@ if ![is_remote target] {
+ if (dwz_bfd == NULL)
+- dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid);
++ dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid, NULL, 1);
- gdb_exit
- }
-+
-+
-+# Test auto-loading of binary files through build-id from the core file.
-+set buildid [build_id_debug_filename_get $binfile]
-+set wholetest "binfile found by build-id"
-+if {$buildid == ""} {
-+ untested "$wholetest (binary has no build-id)"
-+} else {
-+ gdb_exit
-+ gdb_start
-+
-+ regsub {\.debug$} $buildid {} buildid
-+ set debugdir ${objdir}/${subdir}/${testfile}-debugdir
-+ file delete -force -- $debugdir
-+ file mkdir $debugdir/[file dirname $buildid]
-+ file copy $binfile $debugdir/$buildid
-+
-+ set test "show debug-file-directory"
-+ gdb_test_multiple $test $test {
-+ -re "The directory where separate debug symbols are searched for is \"(.*)\"\\.\r\n$gdb_prompt $" {
-+ set debugdir_orig $expect_out(1,string)
<Skipped 118 lines>
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/gdb.git/commitdiff/321e94d61aceab20eb50bc5296671301ab33cc26
More information about the pld-cvs-commit
mailing list