SHA256
1
0
forked from pool/gdb

Accepting request 705251 from home:tomdevries:branches:devel:gcc

Update to 8.3 release

OBS-URL: https://build.opensuse.org/request/show/705251
OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=204
This commit is contained in:
Michael Matz 2019-05-24 13:40:33 +00:00 committed by Git OBS Bridge
parent 15e61520b4
commit 630d3f35be
85 changed files with 2777 additions and 16075 deletions

View File

@ -16,7 +16,7 @@ Subject: gdb-6.3-gstack-20050411.patch
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1735,7 +1735,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
@@ -1749,7 +1749,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
install: all
@$(MAKE) $(FLAGS_TO_PASS) install-only
@ -25,7 +25,7 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e "$$t"` ; \
if test "x$$transformed_name" = x; then \
@@ -1784,7 +1784,25 @@ install-guile:
@@ -1798,7 +1798,25 @@ install-guile:
install-python:
$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
@ -52,7 +52,7 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e $$t` ; \
if test "x$$transformed_name" = x; then \
@@ -1807,6 +1825,18 @@ uninstall: force $(CONFIG_UNINSTALL)
@@ -1821,6 +1839,18 @@ uninstall: force $(CONFIG_UNINSTALL)
fi
@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
@ -171,7 +171,7 @@ diff --git a/gdb/testsuite/gdb.base/gstack.exp b/gdb/testsuite/gdb.base/gstack.e
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gstack.exp
@@ -0,0 +1,66 @@
@@ -0,0 +1,84 @@
+# Copyright (C) 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
@ -202,6 +202,10 @@ new file mode 100644
+ fail $test
+ return
+}
+
+# The spawn id of the test inferior.
+set test_spawn_id $res
+
+set use_gdb_stub 1
+set pid [exp_pid -i $res]
+gdb_expect {
@ -217,7 +221,6 @@ new file mode 100644
+ return
+ }
+}
+gdb_exit
+
+# Testcase uses the most simple notification not to get caught by attach on
+# exiting the function. Still we could retry the gstack command if we fail.
@ -229,12 +232,27 @@ new file mode 100644
+ perror "Spawning $command failed."
+ fail $test
+}
+set pid [exp_pid -i $res]
+
+set gdb_spawn_id $res
+
+gdb_test_multiple "" $test {
+ -re "^#0 +(0x\[0-9a-f\]+ in )?\\.?func \\(\\) at \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in \\.?main \\(\\) at \[^\r\n\]*\r\nGSTACK-END\r\n\$" {
+ pass $test
+ }
+}
+gdb_exit
+
+remote_exec host "kill -9 $pid"
+gdb_test_multiple "" "gstack exits" {
+ eof {
+ set result [wait -i $gdb_spawn_id]
+ verbose $result
+
+ gdb_assert { [lindex $result 2] == 0 } "gstack exits with no error"
+ gdb_assert { [lindex $result 3] == 0 } "gstack's exit status is 0"
+
+ remote_close host
+ clear_gdb_spawn_id
+ }
+}
+
+# Kill the test inferior.
+kill_wait_spawned_process $test_spawn_id

View File

@ -1,32 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andrew Cagney <cagney@gnu.org>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-6.3-ppc64displaysymbol-20041124.patch
;; Include the pc's section when doing a symbol lookup so that the
;; correct symbol is found.
;;=push: Write new testcase.
2004-11-24 Andrew Cagney <cagney@gnu.org>
* printcmd.c (build_address_symbolic): Find a section for the
address.
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -587,6 +587,14 @@ build_address_symbolic (struct gdbarch *gdbarch,
addr = overlay_mapped_address (addr, section);
}
}
+ /* To ensure that the symbol returned belongs to the correct setion
+ (and that the last [random] symbol from the previous section
+ isn't returned) try to find the section containing PC. First try
+ the overlay code (which by default returns NULL); and second try
+ the normal section code (which almost always succeeds). */
+ section = find_pc_overlay (addr);
+ if (section == NULL)
+ section = find_pc_section (addr);
/* First try to find the address in the symbol table, then
in the minsyms. Take the closest one. */

View File

@ -1,118 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andrew Cagney <cagney@gnu.org>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-6.3-ppc64syscall-20040622.patch
;; Better parse 64-bit PPC system call prologues.
;;=push: Write new testcase.
2004-06-22 Andrew Cagney <cagney@gnu.org>
* rs6000-tdep.c (struct rs6000_framedata): Add field "func_start".
(skip_prologue): Delete local variable "orig_pc", use
"func_start". Add local variable "num_skip_linux_syscall_insn",
use to skip over first half of a GNU/Linux syscall and update
"func_start".
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -134,6 +134,7 @@ static const char *powerpc_vector_abi_string = "auto";
struct rs6000_framedata
{
+ CORE_ADDR func_start; /* True function start. */
int offset; /* total size of frame --- the distance
by which we decrement sp to allocate
the frame */
@@ -1426,7 +1427,6 @@ static CORE_ADDR
skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
struct rs6000_framedata *fdata)
{
- CORE_ADDR orig_pc = pc;
CORE_ADDR last_prologue_pc = pc;
CORE_ADDR li_found_pc = 0;
gdb_byte buf[4];
@@ -1445,12 +1445,14 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
int minimal_toc_loaded = 0;
int prev_insn_was_prologue_insn = 1;
int num_skip_non_prologue_insns = 0;
+ int num_skip_ppc64_gnu_linux_syscall_insn = 0;
int r0_contains_arg = 0;
const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
memset (fdata, 0, sizeof (struct rs6000_framedata));
+ fdata->func_start = pc;
fdata->saved_gpr = -1;
fdata->saved_fpr = -1;
fdata->saved_vr = -1;
@@ -1484,6 +1486,55 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
break;
op = extract_unsigned_integer (buf, 4, byte_order);
+ /* A PPC64 GNU/Linux system call function is split into two
+ sub-functions: a non-threaded fast-path (__NAME_nocancel)
+ which does not use a frame; and a threaded slow-path
+ (Lpseudo_cancel) that does create a frame. Ref:
+ nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+
+ *INDENT-OFF*
+ NAME:
+ SINGLE_THREAD_P
+ bne- .Lpseudo_cancel
+ __NAME_nocancel:
+ li r0,162
+ sc
+ bnslr+
+ b 0x7fe014ef64 <.__syscall_error>
+ Lpseudo_cancel:
+ stdu r1,-128(r1)
+ ...
+ *INDENT-ON*
+
+ Unfortunatly, because the latter case uses a local label (not
+ in the symbol table) a PC in "Lpseudo_cancel" appears to be
+ in "__NAME_nocancel". The following code recognizes this,
+ adjusting FUNC_START to point to where "Lpseudo_cancel"
+ should be, and parsing the prologue sequence as if
+ "Lpseudo_cancel" was the entry point. */
+
+ if (((op & 0xffff0000) == 0x38000000 /* li r0,N */
+ && pc == fdata->func_start + 0
+ && num_skip_ppc64_gnu_linux_syscall_insn == 0)
+ || (op == 0x44000002 /* sc */
+ && pc == fdata->func_start + 4
+ && num_skip_ppc64_gnu_linux_syscall_insn == 1)
+ || (op == 0x4ca30020 /* bnslr+ */
+ && pc == fdata->func_start + 8
+ && num_skip_ppc64_gnu_linux_syscall_insn == 2))
+ {
+ num_skip_ppc64_gnu_linux_syscall_insn++;
+ continue;
+ }
+ else if ((op & 0xfc000003) == 0x48000000 /* b __syscall_error */
+ && pc == fdata->func_start + 12
+ && num_skip_ppc64_gnu_linux_syscall_insn == 3)
+ {
+ num_skip_ppc64_gnu_linux_syscall_insn = -1;
+ fdata->func_start = pc;
+ continue;
+ }
+
if ((op & 0xfc1fffff) == 0x7c0802a6)
{ /* mflr Rx */
/* Since shared library / PIC code, which needs to get its
@@ -1673,9 +1724,9 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
we have no line table information or the line info tells
us that the subroutine call is not part of the line
associated with the prologue. */
- if ((pc - orig_pc) > 8)
+ if ((pc - fdata->func_start) > 8)
{
- struct symtab_and_line prologue_sal = find_pc_line (orig_pc, 0);
+ struct symtab_and_line prologue_sal = find_pc_line (fdata->func_start, 0);
struct symtab_and_line this_sal = find_pc_line (pc, 0);
if ((prologue_sal.line == 0)

View File

@ -1,35 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Andrew Cagney <cagney@gnu.org>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-6.3-readnever-20050907.patch
;; Add readnever option
;;=push
2004-11-18 Andrew Cagney <cagney@gnu.org>
* dwarf2read.c: Include "top.c".
(dwarf2_has_info): Check for readnever_symbol_files.
* symfile.c (readnever_symbol_files): Define.
* top.h (readnever_symbol_files): Declare.
* main.c (captured_main): Add --readnever option.
(print_gdb_help): Ditto.
2004-11-18 Andrew Cagney <cagney@gnu.org>
* gdb.texinfo (File Options): Document --readnever.
Pushed upstream: https://sourceware.org/ml/gdb-cvs/2017-12/msg00007.html
diff --git a/gdb/gcore.in b/gdb/gcore.in
--- a/gdb/gcore.in
+++ b/gdb/gcore.in
@@ -97,7 +97,7 @@ for pid in "$@"
do
# `</dev/null' to avoid touching interactive terminal if it is
# available but not accessible as GDB would get stopped on SIGTTIN.
- "$binary_path/@GDB_TRANSFORM_NAME@" </dev/null --nx --batch \
+ "$binary_path/@GDB_TRANSFORM_NAME@" </dev/null --nx --batch --readnever \
-ex "set pagination off" -ex "set height 0" -ex "set width 0" \
"${dump_all_cmds[@]}" \
-ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit

View File

@ -44,7 +44,7 @@ glibc-debuginfo-2.7-2.x86_64: /usr/lib/debug/lib64/libc.so.6.debug:
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1190,6 +1190,10 @@ print_command_1 (const char *exp, int voidprint)
@@ -1183,6 +1183,10 @@ print_command_1 (const char *exp, int voidprint)
if (exp && *exp)
{

View File

@ -1,24 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-6.5-bz203661-emit-relocs.patch
;; Fix debuginfo addresses resolving for --emit-relocs Linux kernels (BZ 203661).
;;=push+jan: There was some mail thread about it, this patch may be a hack.
diff --git a/gdb/symfile.c b/gdb/symfile.c
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3584,6 +3584,12 @@ default_symfile_relocate (struct objfile *objfile, asection *sectp,
DWO file. */
bfd *abfd = sectp->owner;
+ /* Executable files have all the relocations already resolved.
+ Handle files linked with --emit-relocs.
+ http://sources.redhat.com/ml/gdb/2006-08/msg00137.html */
+ if ((abfd->flags & EXEC_P) != 0)
+ return NULL;
+
/* We're only interested in sections with relocation
information. */
if ((sectp->flags & SEC_RELOC) == 0)

View File

@ -127,7 +127,7 @@ diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2595,6 +2595,7 @@ amd64_frame_unwind_stop_reason (struct frame_info *this_frame,
@@ -2601,6 +2601,7 @@ amd64_frame_unwind_stop_reason (struct frame_info *this_frame,
{
struct amd64_frame_cache *cache =
amd64_frame_cache (this_frame, this_cache);
@ -135,7 +135,7 @@ diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
if (!cache->base_p)
return UNWIND_UNAVAILABLE;
@@ -2603,6 +2604,10 @@ amd64_frame_unwind_stop_reason (struct frame_info *this_frame,
@@ -2609,6 +2610,10 @@ amd64_frame_unwind_stop_reason (struct frame_info *this_frame,
if (cache->base == 0)
return UNWIND_OUTERMOST;
@ -146,7 +146,7 @@ diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
return UNWIND_NO_REASON;
}
@@ -2737,6 +2742,7 @@ amd64_sigtramp_frame_this_id (struct frame_info *this_frame,
@@ -2743,6 +2748,7 @@ amd64_sigtramp_frame_this_id (struct frame_info *this_frame,
{
struct amd64_frame_cache *cache =
amd64_sigtramp_frame_cache (this_frame, this_cache);
@ -154,7 +154,7 @@ diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
if (!cache->base_p)
(*this_id) = frame_id_build_unavailable_stack (get_frame_pc (this_frame));
@@ -2745,6 +2751,11 @@ amd64_sigtramp_frame_this_id (struct frame_info *this_frame,
@@ -2751,6 +2757,11 @@ amd64_sigtramp_frame_this_id (struct frame_info *this_frame,
/* This marks the outermost frame. */
return;
}
@ -169,7 +169,7 @@ diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -8406,6 +8406,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
@@ -8407,6 +8407,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
tdep->xsave_xcr0_offset = -1;

View File

@ -11,7 +11,7 @@ https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=218379
diff --git a/gdb/symtab.c b/gdb/symtab.c
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3165,6 +3165,13 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
@@ -3177,6 +3177,13 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
SYMBOL_LINKAGE_NAME (msymbol)); */
;
/* fall through */

View File

@ -12,7 +12,7 @@ diff --git a/gdb/testsuite/gdb.base/readline-overflow.exp b/gdb/testsuite/gdb.ba
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/readline-overflow.exp
@@ -0,0 +1,126 @@
@@ -0,0 +1,104 @@
+# Copyright 2006 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
@ -44,98 +44,76 @@ new file mode 100644
+ strace $tracelevel
+}
+
+# Don't let a .inputrc file or an existing setting of INPUTRC mess up
+# the test results. Even if /dev/null doesn't exist on the particular
+# platform, the readline library will use the default setting just by
+# failing to open the file. OTOH, opening /dev/null successfully will
+# also result in the default settings being used since nothing will be
+# read from this file.
+global env
+if [info exists env(INPUTRC)] {
+ set old_inputrc $env(INPUTRC)
+}
+set env(INPUTRC) "/dev/null"
+
+set oldtimeout1 $timeout
+set timeout 600
+save_vars { env(INPUTRC) env(GDBHISTFILE) env(HISTSIZE) TERM timeout } {
+ # The arrow key test relies on the standard VT100 bindings, so
+ # make sure that an appropriate terminal is selected. The same
+ # bug doesn't show up if we use ^P / ^N instead.
+ setenv TERM vt100
+
+if [info exists env(GDBHISTFILE)] {
+ set old_gdbhistfile $env(GDBHISTFILE)
+}
+if [info exists env(HISTSIZE)] {
+ set old_histsize $env(HISTSIZE)
+}
+set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history"
+set env(HISTSIZE) "10"
+ # Don't let a .inputrc file or an existing setting of INPUTRC mess up
+ # the test results. Even if /dev/null doesn't exist on the particular
+ # platform, the readline library will use the default setting just by
+ # failing to open the file. OTOH, opening /dev/null successfully will
+ # also result in the default settings being used since nothing will be
+ # read from this file.
+ set env(INPUTRC) "/dev/null"
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+ set timeout 600
+
+ set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history"
+ set env(HISTSIZE) "10"
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+
+set width 11
+gdb_test "set width $width" \
+ "" \
+ "Setting width to $width."
+#gdb_test "set height 1" \
+# "" \
+# "Setting height to 1."
+send_gdb "run X"
+set i 0
+# It crashes using `set width 7' on `set total 3560'.
+# Sometimes it corrupts screen on `set width 7'.
+# Bugreport used `set total 130001':
+# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196
+# Check also `timeout' above.
+set total 4200
+gdb_expect {
+ set width 11
+ gdb_test "set width $width" \
+ "" \
+ "Setting width to $width."
+ #gdb_test "set height 1" \
+ # "" \
+ # "Setting height to 1."
+ send_gdb "run X"
+ set i 0
+ # It crashes using `set width 7' on `set total 3560'.
+ # Sometimes it corrupts screen on `set width 7'.
+ # Bugreport used `set total 130001':
+ # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=214196
+ # Check also `timeout' above.
+ set total 4200
+ gdb_expect {
+ -re X {
+ incr i
+ if {$i <= $total} {
+ send_gdb "X"
+ exp_continue
+ }
+ incr i
+ if {$i <= $total} {
+ send_gdb "X"
+ exp_continue
+ }
+ }
+ -re "\[ \b\r\n\]" {
+ exp_continue
+ exp_continue
+ }
+ eof {
+ fail "gdb sending total $total characters"
+ note "Failed after sending $i characters, reason: EOF"
+ gdb_clear_suppressed
+ fail "gdb sending total $total characters"
+ note "Failed after sending $i characters, reason: EOF"
+ gdb_clear_suppressed
+ }
+ timeout {
+ fail "gdb sending total $total characters"
+ note "Failed after sending $i characters (timeout $timeout), reason: TIMEOUT"
+ gdb_clear_suppressed
+ fail "gdb sending total $total characters"
+ note "Failed after sending $i characters (timeout $timeout), reason: TIMEOUT"
+ gdb_clear_suppressed
+ }
+ default {
+ fail "gdb sending total $total characters"
+ note "Failed after sending $i characters, reason: 0=\[$expect_out(0,string)\] buffer=\[$expect_out(buffer)\]"
+ gdb_clear_suppressed
+ fail "gdb sending total $total characters"
+ note "Failed after sending $i characters, reason: 0=\[$expect_out(0,string)\] buffer=\[$expect_out(buffer)\]"
+ gdb_clear_suppressed
+ }
+ }
+ send_gdb "\r"
+ gdb_test "" \
+ "No executable file specified..*" \
+ "All the characters transferred"
+}
+send_gdb "\r"
+gdb_test "" \
+ "No executable file specified..*" \
+ "All the characters transferred"
+
+
+# Restore globals modified in this test...
+if [info exists old_inputrc] {
+ set env(INPUTRC) $old_inputrc
+} else {
+ unset env(INPUTRC)
+}
+if [info exists old_gdbhistfile] {
+ set env(GDBHISTFILE) $old_gdbhistfile
+} else {
+ unset env(GDBHISTFILE)
+}
+if [info exists old_histsize] {
+ set env(HISTSIZE) $old_histsize
+} else {
+ unset env(HISTSIZE)
+}
+set timeout $oldtimeout1
+

View File

@ -85,7 +85,7 @@ diff --git a/gdb/exec.c b/gdb/exec.c
#include <fcntl.h>
#include "readline/readline.h"
@@ -357,12 +358,27 @@ exec_file_attach (const char *filename, int from_tty)
@@ -355,12 +356,27 @@ exec_file_attach (const char *filename, int from_tty)
if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
{
@ -102,7 +102,7 @@ diff --git a/gdb/exec.c b/gdb/exec.c
exec_close ();
- error (_("\"%s\": not in executable format: %s"),
- scratch_pathname,
- gdb_bfd_errmsg (bfd_get_error (), matching));
- gdb_bfd_errmsg (bfd_get_error (), matching).c_str ());
+
+ if (is_core != 0)
+ throw_error (IS_CORE_ERROR,
@ -112,14 +112,14 @@ diff --git a/gdb/exec.c b/gdb/exec.c
+ else
+ error (_("\"%s\": not in executable format: %s"),
+ scratch_pathname,
+ gdb_bfd_errmsg (bfd_get_error (), matching));
+ gdb_bfd_errmsg (bfd_get_error (), matching).c_str ());
}
if (build_section_table (exec_bfd, &sections, &sections_end))
diff --git a/gdb/main.c b/gdb/main.c
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -447,6 +447,37 @@ struct cmdarg
@@ -448,6 +448,35 @@ struct cmdarg
char *string;
};
@ -130,8 +130,6 @@ diff --git a/gdb/main.c b/gdb/main.c
+static void
+exec_or_core_file_attach (const char *filename, int from_tty)
+{
+ volatile struct gdb_exception e;
+
+ gdb_assert (exec_bfd == NULL);
+
+ TRY
@ -157,7 +155,7 @@ diff --git a/gdb/main.c b/gdb/main.c
static void
captured_main_1 (struct captured_main_args *context)
{
@@ -883,6 +914,8 @@ captured_main_1 (struct captured_main_args *context)
@@ -893,6 +922,8 @@ captured_main_1 (struct captured_main_args *context)
{
symarg = argv[optind];
execarg = argv[optind];
@ -166,7 +164,7 @@ diff --git a/gdb/main.c b/gdb/main.c
optind++;
}
@@ -1033,11 +1066,25 @@ captured_main_1 (struct captured_main_args *context)
@@ -1043,12 +1074,25 @@ captured_main_1 (struct captured_main_args *context)
&& symarg != NULL
&& strcmp (execarg, symarg) == 0)
{
@ -185,13 +183,14 @@ diff --git a/gdb/main.c b/gdb/main.c
/* The exec file and the symbol-file are the same. If we can't
open it, better only print one error message.
- catch_command_errors returns non-zero on success! */
- if (catch_command_errors (exec_file_attach, execarg,
- !batch_flag))
- ret = catch_command_errors (exec_file_attach, execarg,
- !batch_flag);
- if (ret != 0)
+ catch_command_errors returns non-zero on success!
+ Do not load EXECARG as a symbol file if it has been already processed
+ as a core file. */
+ if (catch_command_errors (func, execarg, !batch_flag)
+ && core_bfd == NULL)
catch_command_errors (symbol_file_add_main_adapter, symarg,
!batch_flag);
+ ret = catch_command_errors (func, execarg, !batch_flag);
+ if (ret != 0 && core_bfd == NULL)
ret = catch_command_errors (symbol_file_add_main_adapter,
symarg, !batch_flag);
}

View File

@ -25,21 +25,6 @@ Comments by Sergio Durigan Junior <sergiodj@redhat.com>:
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 ...").
diff --git a/gdb/build-id.c b/gdb/build-id.c
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -581,7 +581,10 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id,
do_cleanups (inner);
if (abfd == NULL)
- continue;
+ {
+ filename = NULL;
+ continue;
+ }
if (build_id_verify (abfd.get(), build_id_len, build_id))
break;
diff --git a/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp b/gdb/testsuite/gdb.base/rhbz981154-misleading-yum-install-warning.exp
new file mode 100644
--- /dev/null

View File

@ -9,7 +9,7 @@ Subject: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
diff --git a/gdb/build-id.c b/gdb/build-id.c
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -652,6 +652,19 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return)
@@ -712,6 +712,19 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return)
#include <dlfcn.h>
#endif

View File

@ -12,7 +12,7 @@ https://bugzilla.redhat.com/show_bug.cgi?id=953585
diff --git a/gdb/build-id.c b/gdb/build-id.c
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -689,7 +689,11 @@ static int missing_rpm_list_entries;
@@ -746,7 +746,11 @@ static int missing_rpm_list_entries;
/* Returns the count of newly added rpms. */
static int
@ -24,7 +24,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
{
static int rpm_init_done = 0;
rpmts ts;
@@ -796,7 +800,11 @@ missing_rpm_enlist (const char *filename)
@@ -853,7 +857,11 @@ missing_rpm_enlist (const char *filename)
mi = rpmtsInitIterator_p (ts, RPMTAG_BASENAMES, filename, 0);
if (mi != NULL)
{
@ -36,7 +36,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
{
Header h;
char *debuginfo, **slot, *s, *s2;
@@ -914,6 +922,37 @@ missing_rpm_enlist (const char *filename)
@@ -971,6 +979,37 @@ missing_rpm_enlist (const char *filename)
xfree (debuginfo);
count++;
}
@ -74,7 +74,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
rpmdbFreeIterator_p (mi);
}
@@ -924,6 +963,21 @@ missing_rpm_enlist (const char *filename)
@@ -981,6 +1020,21 @@ missing_rpm_enlist (const char *filename)
}
static int
@ -99,7 +99,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3469,6 +3469,16 @@ read_gdb_index_from_section (struct objfile *objfile,
@@ -3501,6 +3501,16 @@ read_gdb_index_from_buffer (struct objfile *objfile,
"set use-deprecated-index-sections on". */
if (version < 6 && !deprecated_ok)
{
@ -116,7 +116,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
static int warning_printed = 0;
if (!warning_printed)
{
@@ -3480,6 +3490,10 @@ to use the section anyway."),
@@ -3512,6 +3522,10 @@ to use the section anyway."),
warning_printed = 1;
}
return 0;

View File

@ -244,7 +244,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
#define BUILD_ID_VERBOSE_NONE 0
#define BUILD_ID_VERBOSE_FILENAMES 1
@@ -640,8 +642,366 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return)
@@ -700,8 +702,366 @@ build_id_to_filename (const struct bfd_build_id *build_id, char **link_return)
return result;
}
@ -612,7 +612,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
avoidance. */
struct missing_filepair
@@ -695,11 +1055,17 @@ missing_filepair_change (void)
@@ -755,11 +1115,17 @@ missing_filepair_change (void)
/* All their memory came just from missing_filepair_OBSTACK. */
missing_filepair_hash = NULL;
}
@ -630,7 +630,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
missing_filepair_change ();
}
@@ -766,14 +1132,39 @@ debug_print_missing (const char *binary, const char *debug)
@@ -826,14 +1192,39 @@ debug_print_missing (const char *binary, const char *debug)
*slot = missing_filepair;
@ -690,7 +690,7 @@ diff --git a/gdb/config.in b/gdb/config.in
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
@@ -270,6 +273,9 @@
@@ -261,6 +264,9 @@
/* Define if Python 2.7 is being used. */
#undef HAVE_LIBPYTHON2_7
@ -703,7 +703,7 @@ diff --git a/gdb/config.in b/gdb/config.in
diff --git a/gdb/configure b/gdb/configure
--- a/gdb/configure
+++ b/gdb/configure
@@ -749,6 +749,11 @@ CODESIGN_CERT
@@ -751,6 +751,11 @@ CODESIGN_CERT
HAVE_NATIVE_GCORE_TARGET
TARGET_OBS
subdirs
@ -715,15 +715,15 @@ diff --git a/gdb/configure b/gdb/configure
GDB_DATADIR
DEBUGDIR
MAKEINFO_EXTRA_FLAGS
@@ -853,6 +858,7 @@ with_gdb_datadir
@@ -855,6 +860,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
@@ -912,6 +918,11 @@ CCC
enable_gdbmi
@@ -915,6 +921,11 @@ CCC
CPP
MAKEINFO
MAKEINFOFLAGS
@ -735,7 +735,7 @@ diff --git a/gdb/configure b/gdb/configure
YACC
YFLAGS
XMKMF'
@@ -1583,6 +1594,8 @@ Optional Packages:
@@ -1588,6 +1599,8 @@ Optional Packages:
[--with-auto-load-dir]
--without-auto-load-safe-path
do not restrict auto-loaded files locations
@ -744,7 +744,7 @@ diff --git a/gdb/configure b/gdb/configure
--with-libunwind-ia64 use libunwind frame unwinding for ia64 targets
--with-curses use the curses library instead of the termcap
library
@@ -1640,6 +1653,13 @@ Some influential environment variables:
@@ -1645,6 +1658,13 @@ Some influential environment variables:
MAKEINFO Parent configure detects if it is of sufficient version.
MAKEINFOFLAGS
Parameters for MAKEINFO.
@ -758,7 +758,7 @@ diff --git a/gdb/configure b/gdb/configure
YACC The `Yet Another Compiler Compiler' implementation to use.
Defaults to the first program found out of: `bison -y', `byacc',
`yacc'.
@@ -6575,6 +6595,494 @@ _ACEOF
@@ -6626,6 +6646,494 @@ _ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
$as_echo "$with_auto_load_safe_path" >&6; }
@ -1459,7 +1459,7 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac
diff --git a/gdb/corelow.c b/gdb/corelow.c
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -366,7 +366,7 @@ build_id_locate_exec (int from_tty)
@@ -365,7 +365,7 @@ build_id_locate_exec (int from_tty)
symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED;
}
else
@ -1472,7 +1472,7 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -40,6 +40,7 @@
#include "buffer.h"
#include "common/buffer.h"
#include "ser-event.h"
#include "gdb_select.h"
+#include "symfile.h"
@ -1488,7 +1488,7 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c
/* Do not call the python hook on an explicit prompt change as
passed to this function, as this forms a secondary/local prompt,
IE, displayed but not set. */
@@ -774,7 +777,10 @@ command_line_handler (char *rl)
@@ -770,7 +773,10 @@ command_line_handler (gdb::unique_xmalloc_ptr<char> &&rl)
command_handler (cmd);
if (ui->prompt_state != PROMPTED)
@ -1503,7 +1503,7 @@ diff --git a/gdb/event-top.c b/gdb/event-top.c
diff --git a/gdb/symfile.h b/gdb/symfile.h
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -540,6 +540,8 @@ void map_symbol_filenames (symbol_filename_ftype *fun, void *data,
@@ -534,6 +534,8 @@ void map_symbol_filenames (symbol_filename_ftype *fun, void *data,
/* build-id support. */
extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr);
extern void debug_print_missing (const char *binary, const char *debug);

View File

@ -14,7 +14,7 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1339862
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1358,14 +1358,27 @@ svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
@@ -1347,14 +1347,27 @@ svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
}
{
@ -44,7 +44,7 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
if (build_id != NULL)
{
char *name, *build_id_filename;
@@ -1380,23 +1393,7 @@ svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
@@ -1369,23 +1382,7 @@ svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
xfree (name);
}
else

View File

@ -55,13 +55,13 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
+ && namesz == sizeof "GNU"
+ && memcmp (xnp->name, "GNU", sizeof "GNU") == 0)
+ {
+ size_t size = descsz;
+ size_t sz = descsz;
+ gdb_byte *data = (gdb_byte *) descdata;
+ struct bfd_build_id *retval;
+
+ retval = (struct bfd_build_id *) xmalloc (sizeof *retval - 1 + size);
+ retval->size = size;
+ memcpy (retval->data, data, size);
+ retval = (struct bfd_build_id *) xmalloc (sizeof *retval - 1 + sz);
+ retval->size = sz;
+ memcpy (retval->data, data, sz);
+
+ return retval;
+ }
@ -436,7 +436,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
if (found == NULL)
warning (_("File \"%s\" has no build-id, file skipped"),
@@ -65,11 +463,50 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
@@ -65,62 +463,173 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
return retval;
}
@ -474,6 +474,160 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
+ return retval;
+}
+
/* Helper for build_id_to_debug_bfd. LINK is a path to a potential
build-id-based separate debug file, potentially a symlink to the real file.
If the file exists and matches BUILD_ID, return a BFD reference to it. */
static gdb_bfd_ref_ptr
-build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
- const bfd_byte *build_id)
+build_id_to_debug_bfd_1 (const std::string &orig_link, size_t build_id_len,
+ const bfd_byte *build_id, char **link_return,
+ int add_debug_suffix)
{
+ gdb_bfd_ref_ptr ret_bfd = {};
+ std::string ret_link;
+
if (separate_debug_file_debug)
{
- printf_unfiltered (_(" Trying %s..."), link.c_str ());
+ printf_unfiltered (_(" Trying %s..."), orig_link.c_str ());
gdb_flush (gdb_stdout);
}
- /* lrealpath() is expensive even for the usually non-existent files. */
- gdb::unique_xmalloc_ptr<char> filename;
- if (access (link.c_str (), F_OK) == 0)
- filename.reset (lrealpath (link.c_str ()));
-
- if (filename == NULL)
+ for (unsigned seqno = 0;; seqno++)
{
- if (separate_debug_file_debug)
- printf_unfiltered (_(" no, unable to compute real path\n"));
+ std::string link = orig_link;
- return {};
- }
+ if (seqno > 0)
+ {
+ /* There can be multiple build-id symlinks pointing to real files
+ with the same build-id (such as hard links). Some of the real
+ files may not be installed. */
- /* We expect to be silent on the non-existing files. */
- gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget, -1);
+ string_appendf (link, ".%u", seqno);
+ }
- if (debug_bfd == NULL)
- {
- if (separate_debug_file_debug)
- printf_unfiltered (_(" no, unable to open.\n"));
+ if (add_debug_suffix)
+ link += ".debug";
+
+ ret_link = link;
+
+ struct stat statbuf_trash;
+
+ /* `access' automatically dereferences LINK. */
+ if (lstat (link.c_str (), &statbuf_trash) != 0)
+ {
+ /* Stop increasing SEQNO. */
+ break;
+ }
+
+ /* lrealpath() is expensive even for the usually non-existent files. */
+ gdb::unique_xmalloc_ptr<char> filename;
+
+ if (access (link.c_str (), F_OK) == 0)
+ filename.reset (lrealpath (link.c_str ()));
+
+ if (filename == NULL)
+ {
+ if (separate_debug_file_debug)
+ printf_unfiltered (_(" no, unable to compute real path\n"));
+
+ continue;
+ }
+
+ /* We expect to be silent on the non-existing files. */
+ gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget, -1);
+
+ if (debug_bfd == NULL)
+ {
+ if (separate_debug_file_debug)
+ printf_unfiltered (_(" no, unable to open.\n"));
+
+ continue;
+ }
+
+ if (!build_id_verify (debug_bfd.get(), build_id_len, build_id))
+ {
+ if (separate_debug_file_debug)
+ printf_unfiltered (_(" no, build-id does not match.\n"));
+
+ continue;
+ }
- return {};
+ ret_bfd = debug_bfd;
+ break;
}
- if (!build_id_verify (debug_bfd.get(), build_id_len, build_id))
+ std::string link_all;
+
+ if (ret_bfd != NULL)
{
if (separate_debug_file_debug)
- printf_unfiltered (_(" no, build-id does not match.\n"));
+ printf_unfiltered (_(" yes!\n"));
+ }
+ else
+ {
+ /* If none of the real files is found report as missing file
+ always the non-.%u-suffixed file. */
+ std::string link0 = orig_link;
+
+ if (add_debug_suffix)
+ link0 += ".debug";
+
+ /* If the symlink has target request to install the target.
+ BASE-debuginfo.rpm contains the symlink but BASE.rpm may be missing.
+ https://bugzilla.redhat.com/show_bug.cgi?id=981154 */
+ std::string link0_resolved (link_resolve (link0.c_str (), 0));
- return {};
+ if (link_all.empty ())
+ link_all = link0_resolved;
+ else
+ {
+ /* Use whitespace instead of DIRNAME_SEPARATOR to be compatible with
+ its possible use as an argument for installation command. */
+ link_all += " " + link0_resolved;
+ }
}
- if (separate_debug_file_debug)
- printf_unfiltered (_(" yes!\n"));
+ if (link_return != NULL)
+ {
+ if (ret_bfd != NULL)
+ {
+ *link_return = xstrdup (ret_link.c_str ());
+ }
+ else
+ {
+ *link_return = xstrdup (link_all.c_str ());
+ }
+ }
- return debug_bfd;
+ return ret_bfd;
}
/* See build-id.h. */
gdb_bfd_ref_ptr
@ -481,27 +635,9 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
+build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id,
+ char **link_return, int add_debug_suffix)
{
+ char *debugdir;
+ std::string link, link_all;
+ struct cleanup *back_to;
+ int ix;
gdb_bfd_ref_ptr abfd;
/* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
@@ -82,63 +519,296 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
{
const gdb_byte *data = build_id;
size_t size = build_id_len;
+ char *filename = NULL;
+ struct cleanup *inner;
+ unsigned seqno;
+ struct stat statbuf_trash;
+ std::string link0;
- std::string link = debugdir.get ();
+ link = debugdir.get ();
link += "/.build-id/";
cause "/.build-id/..." lookups. */
@@ -143,16 +652,16 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
if (size > 0)
{
size--;
@ -516,105 +652,25 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
- link += ".debug";
-
if (separate_debug_file_debug)
printf_unfiltered (_(" Trying %s\n"), link.c_str ());
gdb_bfd_ref_ptr debug_bfd
- = build_id_to_debug_bfd_1 (link, build_id_len, build_id);
+ = build_id_to_debug_bfd_1 (link, build_id_len, build_id,
+ link_return, add_debug_suffix);
if (debug_bfd != NULL)
return debug_bfd;
- /* lrealpath() is expensive even for the usually non-existent files. */
- gdb::unique_xmalloc_ptr<char> filename;
- if (access (link.c_str (), F_OK) == 0)
- filename.reset (lrealpath (link.c_str ()));
-
- if (filename == NULL)
- continue;
+ for (seqno = 0;; seqno++)
+ {
+ if (seqno)
+ {
+ /* There can be multiple build-id symlinks pointing to real files
+ with the same build-id (such as hard links). Some of the real
+ files may not be installed. */
+
+ string_appendf (link, ".%u", seqno);
+ }
+
+ if (add_debug_suffix)
+ link += ".debug";
+
+ if (!seqno)
+ {
+ /* If none of the real files is found report as missing file
+ always the non-.%u-suffixed file. */
+ link0 = link;
+ }
+
+ /* `access' automatically dereferences LINK. */
+ if (lstat (link.c_str (), &statbuf_trash) != 0)
+ {
+ /* Stop increasing SEQNO. */
+ break;
+ }
+
+ filename = lrealpath (link.c_str ());
+ if (filename == NULL)
+ continue;
+
+ /* We expect to be silent on the non-existing files. */
+ inner = make_cleanup (xfree, filename);
+ abfd = gdb_bfd_open (filename, gnutarget, -1);
+ do_cleanups (inner);
+
+ if (abfd == NULL)
+ continue;
+
+ if (build_id_verify (abfd.get(), build_id_len, build_id))
+ break;
+
+ abfd.release ();
+
+ filename = NULL;
+ }
- /* We expect to be silent on the non-existing files. */
- abfd = gdb_bfd_open (filename.get (), gnutarget, -1);
+ if (filename != NULL)
+ {
+ /* LINK_ALL is not used below in this non-NULL FILENAME case. */
+ break;
+ }
- if (abfd == NULL)
- continue;
+ /* If the symlink has target request to install the target.
+ BASE-debuginfo.rpm contains the symlink but BASE.rpm may be missing.
+ https://bugzilla.redhat.com/show_bug.cgi?id=981154 */
+ std::string link0_resolved (link_resolve (link0.c_str (), 0));
- if (build_id_verify (abfd.get(), build_id_len, build_id))
- break;
+ if (link_all.empty ())
+ link_all = link0_resolved;
+ else
+ {
+ /* Use whitespace instead of DIRNAME_SEPARATOR to be compatible with
+ its possible use as an argument for installation command. */
+ link_all += " " + link0_resolved;
+ }
+ }
- abfd.release ();
+ if (link_return != NULL)
+ {
+ if (abfd != NULL)
+ {
+ *link_return = xstrdup (link.c_str ());
+ }
+ else
+ {
+ *link_return = xstrdup (link_all.c_str ());
+ }
}
return abfd;
@@ -166,7 +675,8 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
if (strcmp (gdb_sysroot, TARGET_SYSROOT_PREFIX) != 0)
{
link = gdb_sysroot + link;
- debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id);
+ debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id,
+ link_return, add_debug_suffix);
if (debug_bfd != NULL)
return debug_bfd;
}
@@ -175,22 +685,190 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
return {};
}
+char *
@ -807,7 +863,7 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
/* Prevent looping on a stripped .debug file. */
if (abfd != NULL
&& filename_cmp (bfd_get_filename (abfd.get ()),
@@ -151,3 +821,21 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
@@ -203,3 +881,21 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
return std::string ();
}
@ -832,9 +888,9 @@ diff --git a/gdb/build-id.c b/gdb/build-id.c
diff --git a/gdb/build-id.h b/gdb/build-id.h
--- a/gdb/build-id.h
+++ b/gdb/build-id.h
@@ -22,9 +22,10 @@
@@ -23,9 +23,10 @@
#include "gdb_bfd.h"
#include "common/rsp-low.h"
-/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
+/* Separate debuginfo files have corrupted PHDR but SHDR is correct there.
@ -845,7 +901,7 @@ diff --git a/gdb/build-id.h b/gdb/build-id.h
/* Return true if ABFD has NT_GNU_BUILD_ID matching the CHECK value.
Otherwise, issue a warning and return false. */
@@ -38,13 +39,18 @@ extern int build_id_verify (bfd *abfd,
@@ -39,14 +40,19 @@ extern int build_id_verify (bfd *abfd,
the caller. */
extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len,
@ -866,11 +922,12 @@ diff --git a/gdb/build-id.h b/gdb/build-id.h
+extern std::string find_separate_debug_file_by_buildid (struct objfile *objfile,
+ gdb::unique_xmalloc_ptr<char> *build_id_filename_return);
#endif /* BUILD_ID_H */
/* Return an hex-string representation of BUILD_ID. */
diff --git a/gdb/coffread.c b/gdb/coffread.c
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -733,7 +733,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
@@ -732,7 +732,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
/* Try to add separate debug file if no symbols table found. */
if (!objfile_has_partial_symbols (objfile))
{
@ -883,10 +940,10 @@ diff --git a/gdb/coffread.c b/gdb/coffread.c
diff --git a/gdb/corelow.c b/gdb/corelow.c
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -45,6 +45,10 @@
@@ -43,6 +43,10 @@
#include "gdb_bfd.h"
#include "completer.h"
#include "filestuff.h"
#include "common/filestuff.h"
+#include "auxv.h"
+#include "elf/common.h"
+#include "gdbcmd.h"
@ -894,7 +951,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
@@ -321,6 +325,54 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
@@ -320,6 +324,54 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
inferior_ptid = ptid; /* Yes, make it current. */
}
@ -905,7 +962,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
+{
+ CORE_ADDR at_entry;
+ struct bfd_build_id *build_id;
+ char *execfilename, *debug_filename;
+ char *execfilename;
+ char *build_id_filename;
+ struct cleanup *back_to;
+
@ -949,7 +1006,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
/* Issue a message saying we have no core to debug, if FROM_TTY. */
static void
@@ -464,6 +516,14 @@ core_target_open (const char *arg, int from_tty)
@@ -455,6 +507,14 @@ core_target_open (const char *arg, int from_tty)
switch_to_thread (thread);
}
@ -964,7 +1021,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
post_create_inferior (target, from_tty);
/* Now go through the target stack looking for threads since there
@@ -1072,4 +1132,11 @@ void
@@ -1063,4 +1123,11 @@ void
_initialize_corelow (void)
{
add_target (core_target_info, core_target_open, filename_completer);
@ -979,7 +1036,7 @@ diff --git a/gdb/corelow.c b/gdb/corelow.c
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -19570,6 +19570,27 @@ information files.
@@ -19949,6 +19949,27 @@ information files.
@end table
@ -1007,10 +1064,22 @@ diff --git a/gdb/doc/gdb.texinfo b/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
diff --git a/gdb/dwarf-index-cache.c b/gdb/dwarf-index-cache.c
--- a/gdb/dwarf-index-cache.c
+++ b/gdb/dwarf-index-cache.c
@@ -93,7 +93,7 @@ index_cache::store (struct dwarf2_per_objfile *dwarf2_per_objfile)
if (!enabled ())
return;
- const bfd_build_id *build_id = build_id_bfd_get (obj->obfd);
+ const bfd_build_id *build_id = build_id_bfd_shdr_get (obj->obfd);
if (build_id == nullptr)
{
if (debug_index_cache)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2683,7 +2683,7 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
@@ -2727,7 +2727,7 @@ dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
}
if (dwz_bfd == NULL)
@ -1019,10 +1088,28 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
if (dwz_bfd == NULL)
error (_("could not find '.gnu_debugaltlink' file for %s"),
@@ -6237,7 +6237,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner)
static gdb::array_view<const gdb_byte>
get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_objfile *dwarf2_obj)
{
- const bfd_build_id *build_id = build_id_bfd_get (obj->obfd);
+ const bfd_build_id *build_id = build_id_bfd_shdr_get (obj->obfd);
if (build_id == nullptr)
return {};
@@ -6250,7 +6250,7 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_objfile *dwarf2_obj)
static gdb::array_view<const gdb_byte>
get_gdb_index_contents_from_cache_dwz (objfile *obj, dwz_file *dwz)
{
- const bfd_build_id *build_id = build_id_bfd_get (dwz->dwz_bfd.get ());
+ const bfd_build_id *build_id = build_id_bfd_shdr_get (dwz->dwz_bfd.get ());
if (build_id == nullptr)
return {};
diff --git a/gdb/elfread.c b/gdb/elfread.c
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1290,7 +1290,9 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
@@ -1287,7 +1287,9 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
&& objfile->separate_debug_objfile == NULL
&& objfile->separate_debug_objfile_backlink == NULL)
{
@ -1033,8 +1120,8 @@ diff --git a/gdb/elfread.c b/gdb/elfread.c
if (debugfile.empty ())
debugfile = find_separate_debug_file_by_debuglink (objfile);
@@ -1302,6 +1304,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
symbol_file_add_separate (abfd.get (), debugfile.c_str (),
@@ -1299,6 +1301,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
symbol_file_add_separate (debug_bfd.get (), debugfile.c_str (),
symfile_flags, objfile);
}
+ /* Check if any separate debug info has been extracted out. */
@ -1047,7 +1134,7 @@ diff --git a/gdb/elfread.c b/gdb/elfread.c
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -470,6 +470,10 @@ struct objfile
@@ -554,6 +554,10 @@ struct objfile
htab_t static_links {};
};
@ -1061,7 +1148,7 @@ diff --git a/gdb/objfiles.h b/gdb/objfiles.h
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -137,7 +137,7 @@ objfpy_get_build_id (PyObject *self, void *closure)
@@ -132,7 +132,7 @@ objfpy_get_build_id (PyObject *self, void *closure)
TRY
{
@ -1070,7 +1157,7 @@ diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
}
CATCH (except, RETURN_MASK_ALL)
{
@@ -544,7 +544,7 @@ objfpy_lookup_objfile_by_build_id (const char *build_id)
@@ -535,7 +535,7 @@ objfpy_lookup_objfile_by_build_id (const char *build_id)
/* Don't return separate debug files. */
if (objfile->separate_debug_objfile_backlink != NULL)
continue;
@ -1090,7 +1177,7 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
static struct link_map_offsets *svr4_fetch_link_map_offsets (void);
static int svr4_have_link_map_offsets (void);
@@ -1356,9 +1357,51 @@ svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
@@ -1345,9 +1346,51 @@ svr4_read_so_list (CORE_ADDR lm, CORE_ADDR prev_lm,
continue;
}
@ -1148,7 +1235,7 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
diff --git a/gdb/symfile.h b/gdb/symfile.h
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -537,6 +537,10 @@ void expand_symtabs_matching
@@ -531,6 +531,10 @@ void expand_symtabs_matching
void map_symbol_filenames (symbol_filename_ftype *fun, void *data,
int need_fullname);
@ -1210,7 +1297,7 @@ diff --git a/gdb/testsuite/gdb.base/new-ui-pending-input.exp b/gdb/testsuite/gdb
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1695,6 +1695,16 @@ proc default_gdb_start { } {
@@ -1716,6 +1716,16 @@ proc default_gdb_start { } {
warning "Couldn't set the width to 0."
}
}

View File

@ -9,7 +9,7 @@ Subject: gdb-6.6-scheduler_locking-step-is-default.patch
diff --git a/gdb/infrun.c b/gdb/infrun.c
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2193,7 +2193,7 @@ static const char *const scheduler_enums[] = {
@@ -2075,7 +2075,7 @@ static const char *const scheduler_enums[] = {
schedlock_replay,
NULL
};

View File

@ -9,7 +9,7 @@ Subject: gdb-6.8-bz436037-reg-no-longer-active.patch
diff --git a/gdb/valops.c b/gdb/valops.c
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1104,6 +1104,8 @@ value_assign (struct value *toval, struct value *fromval)
@@ -1092,6 +1092,8 @@ value_assign (struct value *toval, struct value *fromval)
struct gdbarch *gdbarch;
int value_reg;
@ -18,7 +18,7 @@ diff --git a/gdb/valops.c b/gdb/valops.c
/* Figure out which frame this is in currently.
We use VALUE_FRAME_ID for obtaining the value's frame id instead of
@@ -1113,8 +1115,14 @@ value_assign (struct value *toval, struct value *fromval)
@@ -1101,8 +1103,14 @@ value_assign (struct value *toval, struct value *fromval)
frame. */
frame = frame_find_by_id (VALUE_FRAME_ID (toval));

View File

@ -45,7 +45,7 @@ diff --git a/gdb/extension.c b/gdb/extension.c
diff --git a/gdb/top.c b/gdb/top.c
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1606,7 +1606,13 @@ quit_force (int *exit_arg, int from_tty)
@@ -1626,7 +1626,13 @@ quit_force (int *exit_arg, int from_tty)
qt.from_tty = from_tty;
@ -62,7 +62,7 @@ diff --git a/gdb/top.c b/gdb/top.c
diff --git a/gdb/utils.c b/gdb/utils.c
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -108,6 +108,13 @@ static std::chrono::steady_clock::duration prompt_for_continue_wait_time;
@@ -100,6 +100,13 @@ static std::chrono::steady_clock::duration prompt_for_continue_wait_time;
static int debug_timestamp = 0;

View File

@ -1,19 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-6.8-sparc64-silence-memcpy-check.patch
;; Silence memcpy check which returns false positive (sparc64)
;;=push: But it is just a GCC workaround, look up the existing GCC PR for it.
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1462,6 +1462,7 @@ sparc32_store_return_value (struct type *type, struct regcache *regcache,
if (sparc_floating_p (type) || sparc_complex_floating_p (type))
{
/* Floating return values. */
+ len = (len <= 8) ? len : 8;
memcpy (buf, valbuf, len);
regcache->cooked_write (SPARC_F0_REGNUM, buf);
if (len > 4)

View File

@ -1,90 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-6.8-watchpoint-conditionals-test.patch
;; Test the watchpoints conditionals works.
;;=fedoratest
For:
http://sourceware.org/ml/gdb-patches/2008-04/msg00379.html
http://sourceware.org/ml/gdb-cvs/2008-04/msg00104.html
diff --git a/gdb/testsuite/gdb.base/watchpoint-cond.c b/gdb/testsuite/gdb.base/watchpoint-cond.c
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/watchpoint-cond.c
@@ -0,0 +1,31 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2008 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/>.
+
+ Please email any bugs, comments, and/or additions to this file to:
+ bug-gdb@prep.ai.mit.edu */
+
+int
+main (int argc, char **argv)
+{
+ static int i = 0; /* `static' to start initialized. */
+ int j = 2;
+
+ for (j = 0; j < 30; j++)
+ i = 30 - j;
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/watchpoint-cond.exp b/gdb/testsuite/gdb.base/watchpoint-cond.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/watchpoint-cond.exp
@@ -0,0 +1,37 @@
+# Copyright 2008 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/>.
+
+set testfile watchpoint-cond
+set srcfile ${testfile}.c
+set binfile [standard_output_file ${testfile}]
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested "Couldn't compile test program"
+ return -1
+}
+
+# Get things started.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if { [runto_main] < 0 } {
+ untested watchpoint-cond
+ return -1
+}
+
+gdb_test "watch i if i < 20" "atchpoint \[0-9\]+: i"
+gdb_test "cont" "atchpoint \[0-9\]+: i.*Old value = 20.*New value = 19.*"

View File

@ -1,68 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch
;; Toolchain on sparc is slightly broken and debuginfo files are generated
;; with non 64bit aligned tables/offsets.
;; See for example readelf -S ../Xvnc.debug.
;;
;; As a consenquence calculation of sectp->filepos as used in
;; dwarf2_read_section (gdb/dwarf2read.c:1525) will return a non aligned buffer
;; that cannot be used directly as done with MMAP.
;; Usage will result in a BusError.
;;
;; While we figure out what's wrong in the toolchain and do a full archive
;; rebuild to fix it, we need to be able to use gdb :)
;;=push
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -24,12 +24,14 @@
#include "hashtab.h"
#include "filestuff.h"
#include "vec.h"
+#ifndef __sparc__
#ifdef HAVE_MMAP
#include <sys/mman.h>
#ifndef MAP_FAILED
#define MAP_FAILED ((void *) -1)
#endif
#endif
+#endif
#include "target.h"
#include "gdb/fileio.h"
#include "inferior.h"
@@ -484,6 +486,7 @@ free_one_bfd_section (bfd *abfd, asection *sectp, void *ignore)
if (sect != NULL && sect->data != NULL)
{
+#ifndef __sparc__
#ifdef HAVE_MMAP
if (sect->map_addr != NULL)
{
@@ -493,6 +496,7 @@ free_one_bfd_section (bfd *abfd, asection *sectp, void *ignore)
gdb_assert (res == 0);
}
else
+#endif
#endif
xfree (sect->data);
}
@@ -659,6 +663,7 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size)
if (descriptor->data != NULL)
goto done;
+#ifndef __sparc__
#ifdef HAVE_MMAP
if (!bfd_is_section_compressed (abfd, sectp))
{
@@ -693,6 +698,7 @@ gdb_bfd_map_section (asection *sectp, bfd_size_type *size)
}
}
#endif /* HAVE_MMAP */
+#endif
/* Handle compressed sections, or ordinary uncompressed sections in
the no-mmap case. */

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dee9c5028f1fbe1415556e0f64a79d1f9a261516857af37ed6105f0b53999772
size 29034948

3
gdb-8.3.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e722dd64f86742c5be2da15dea9f8906f44f20dd89f7f98bcad93767ffaf7638
size 29368870

View File

@ -43,7 +43,7 @@ diff --git a/gdb/testsuite/gdb.cp/cxxexec.exp b/gdb/testsuite/gdb.cp/cxxexec.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/cxxexec.exp
@@ -0,0 +1,51 @@
@@ -0,0 +1,42 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
@ -83,15 +83,6 @@ new file mode 100644
+ }
+}
+
+set test continue
+gdb_test_multiple $test $test {
+ -re "Cannot access memory at address 0x\[0-9a-f\]+\r\n$gdb_prompt $" {
+ fail $test
+ }
+ -re "\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
+
+# `info inferiors' can show <null> on older GDBs.
+gdb_test "info threads" "info threads" "program finished"
+# Run to end. The buggy GDB failed instead with:
+# Cannot access memory at address ADDR.
+gdb_continue_to_end "" "continue" 1

View File

@ -8,9 +8,9 @@ Subject: gdb-archer-pie-addons-keep-disabled.patch
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -15522,6 +15522,50 @@ initialize_breakpoint_ops (void)
@@ -15441,6 +15441,50 @@ static struct cmd_list_element *enablebreaklist = NULL;
static struct cmd_list_element *enablebreaklist = NULL;
cmd_list_element *commands_cmd_element = nullptr;
+void
+breakpoints_relocate (struct objfile *objfile, struct section_offsets *delta)
@ -62,7 +62,7 @@ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1679,6 +1679,9 @@ extern const char *ep_parse_optional_if_clause (const char **arg);
@@ -1664,6 +1664,9 @@ extern const char *ep_parse_optional_if_clause (const char **arg);
UIOUT iff debugging multiple threads. */
extern void maybe_print_thread_hit_breakpoint (struct ui_out *uiout);
@ -75,7 +75,7 @@ diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -883,6 +883,11 @@ objfile_relocate1 (struct objfile *objfile,
@@ -875,6 +875,11 @@ objfile_relocate1 (struct objfile *objfile,
obj_section_addr (s));
}

View File

@ -8,7 +8,7 @@ Subject: gdb-archer-pie-addons.patch
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -505,6 +505,7 @@ enum field_loc_kind
@@ -507,6 +507,7 @@ enum field_loc_kind
{
FIELD_LOC_KIND_BITPOS, /**< bitpos */
FIELD_LOC_KIND_ENUMVAL, /**< enumval */
@ -16,7 +16,7 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
FIELD_LOC_KIND_PHYSADDR, /**< physaddr */
FIELD_LOC_KIND_PHYSNAME, /**< physname */
FIELD_LOC_KIND_DWARF_BLOCK /**< dwarf_block */
@@ -556,6 +557,7 @@ union field_location
@@ -558,6 +559,7 @@ union field_location
field. Otherwise, physname is the mangled label of the
static field. */
@ -24,7 +24,7 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
CORE_ADDR physaddr;
const char *physname;
@@ -1438,6 +1440,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
@@ -1436,6 +1438,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define FIELD_ENUMVAL_LVAL(thisfld) ((thisfld).loc.enumval)
#define FIELD_ENUMVAL(thisfld) (FIELD_ENUMVAL_LVAL (thisfld) + 0)
#define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname)
@ -32,7 +32,7 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
#define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
#define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block)
#define SET_FIELD_BITPOS(thisfld, bitpos) \
@@ -1449,6 +1452,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
@@ -1447,6 +1450,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define SET_FIELD_PHYSNAME(thisfld, name) \
(FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME, \
FIELD_STATIC_PHYSNAME (thisfld) = (name))
@ -40,7 +40,7 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
#define SET_FIELD_PHYSADDR(thisfld, addr) \
(FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR, \
FIELD_STATIC_PHYSADDR (thisfld) = (addr))
@@ -1465,6 +1469,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
@@ -1463,6 +1467,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
#define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL (TYPE_FIELD (thistype, n))
#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
@ -51,7 +51,7 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
diff --git a/gdb/value.c b/gdb/value.c
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2829,7 +2829,8 @@ value_static_field (struct type *type, int fieldno)
@@ -2827,7 +2827,8 @@ value_static_field (struct type *type, int fieldno)
{
case FIELD_LOC_KIND_PHYSADDR:
retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno),

View File

@ -17,7 +17,7 @@ tromey/python
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2112,6 +2112,12 @@ stamp-h: $(srcdir)/config.in config.status
@@ -2082,6 +2082,12 @@ stamp-h: $(srcdir)/config.in config.status
CONFIG_LINKS= \
$(SHELL) config.status
@ -53,7 +53,7 @@ diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1245,6 +1245,16 @@ for remote debugging.
@@ -1251,6 +1251,16 @@ for remote debugging.
Run using @var{device} for your program's standard input and output.
@c FIXME: kingdon thinks there is more to -tty. Investigate.
@ -73,7 +73,7 @@ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -88,8 +88,6 @@ containing @code{end}. For example:
@@ -90,8 +90,6 @@ containing @code{end}. For example:
@smallexample
(@value{GDBP}) python
@ -112,7 +112,7 @@ diff --git a/gdb/main.c b/gdb/main.c
#include "source.h"
#include "cli/cli-cmds.h"
#include "objfiles.h"
@@ -479,7 +480,7 @@ exec_or_core_file_attach (const char *filename, int from_tty)
@@ -478,7 +479,7 @@ exec_or_core_file_attach (const char *filename, int from_tty)
}
static void
@ -121,7 +121,7 @@ diff --git a/gdb/main.c b/gdb/main.c
{
int argc = context->argc;
char **argv = context->argv;
@@ -695,10 +696,14 @@ captured_main_1 (struct captured_main_args *context)
@@ -698,10 +699,14 @@ captured_main_1 (struct captured_main_args *context)
{"args", no_argument, &set_args, 1},
{"l", required_argument, 0, 'l'},
{"return-child-result", no_argument, &return_child_result, 1},
@ -137,7 +137,7 @@ diff --git a/gdb/main.c b/gdb/main.c
{
int option_index;
@@ -716,6 +721,9 @@ captured_main_1 (struct captured_main_args *context)
@@ -719,6 +724,9 @@ captured_main_1 (struct captured_main_args *context)
case 0:
/* Long option that just sets a flag. */
break;
@ -147,7 +147,7 @@ diff --git a/gdb/main.c b/gdb/main.c
case OPT_SE:
symarg = optarg;
execarg = optarg;
@@ -890,7 +898,31 @@ captured_main_1 (struct captured_main_args *context)
@@ -898,7 +906,31 @@ captured_main_1 (struct captured_main_args *context)
/* Now that gdb_init has created the initial inferior, we're in
position to set args for that inferior. */
@ -180,7 +180,7 @@ diff --git a/gdb/main.c b/gdb/main.c
{
/* The remaining options are the command-line options for the
inferior. The first one is the sym/exec file, and the rest
@@ -1180,7 +1212,8 @@ captured_main_1 (struct captured_main_args *context)
@@ -1199,7 +1231,8 @@ captured_main_1 (struct captured_main_args *context)
/* Read in the old history after all the command files have been
read. */
@ -190,7 +190,7 @@ diff --git a/gdb/main.c b/gdb/main.c
if (batch_flag)
{
@@ -1193,24 +1226,37 @@ static void
@@ -1215,24 +1248,37 @@ static void
captured_main (void *data)
{
struct captured_main_args *context = (struct captured_main_args *) data;
@ -241,7 +241,7 @@ diff --git a/gdb/main.c b/gdb/main.c
}
/* No exit -- exit is through quit_command. */
}
@@ -1253,6 +1299,12 @@ print_gdb_help (struct ui_file *stream)
@@ -1275,6 +1321,12 @@ print_gdb_help (struct ui_file *stream)
fputs_unfiltered (_("\
This is the GNU debugger. Usage:\n\n\
gdb [options] [executable-file [core-file or process-id]]\n\
@ -254,7 +254,7 @@ diff --git a/gdb/main.c b/gdb/main.c
gdb [options] --args executable-file [inferior-arguments ...]\n\n\
"), stream);
fputs_unfiltered (_("\
@@ -1298,6 +1350,13 @@ Output and user interface control:\n\n\
@@ -1320,6 +1372,13 @@ Output and user interface control:\n\n\
#endif
fputs_unfiltered (_("\
--dbx DBX compatibility mode.\n\
@ -365,8 +365,8 @@ new file mode 100644
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -644,6 +644,9 @@ class gdbpy_enter_varobj : public gdbpy_enter
@@ -709,6 +709,9 @@ private:
PyThreadState *m_save;
};
+struct cleanup *ensure_python_env (struct gdbarch *gdbarch,
@ -378,16 +378,16 @@ diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
diff --git a/gdb/python/python.c b/gdb/python/python.c
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -95,6 +95,8 @@ const struct extension_language_defn extension_language_python =
@@ -94,6 +94,8 @@ const struct extension_language_defn extension_language_python =
#include "linespec.h"
#include "source.h"
#include "version.h"
#include "common/version.h"
+#include "inferior.h"
+#include "gdbthread.h"
#include "target.h"
#include "gdbthread.h"
#include "interps.h"
@@ -237,6 +239,29 @@ gdbpy_enter::~gdbpy_enter ()
@@ -235,6 +237,29 @@ gdbpy_enter::~gdbpy_enter ()
restore_active_ext_lang (m_previous_active);
}
@ -417,10 +417,10 @@ diff --git a/gdb/python/python.c b/gdb/python/python.c
/* Set the quit flag. */
static void
@@ -1367,6 +1392,92 @@ gdbpy_print_stack (void)
@@ -1283,6 +1308,92 @@ gdbpy_print_stack_or_quit ()
/* Return the current Progspace.
There always is one. */
+/* True if 'gdb -P' was used, false otherwise. */
+static int running_python_script;
+
@ -507,10 +507,10 @@ diff --git a/gdb/python/python.c b/gdb/python/python.c
+
+
+
/* Return a sequence holding all the Progspaces. */
static PyObject *
gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2)
@@ -2057,6 +2168,8 @@ PyMethodDef python_GdbMethods[] =
@@ -1937,6 +2048,8 @@ PyMethodDef python_GdbMethods[] =
Evaluate command, a string, as a gdb CLI command. Optionally returns\n\
a Python String containing the output of the command if to_string is\n\
set to True." },
@ -522,13 +522,17 @@ diff --git a/gdb/python/python.c b/gdb/python/python.c
diff --git a/gdb/python/python.h b/gdb/python/python.h
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -25,4 +25,6 @@
@@ -25,7 +25,10 @@
/* This is all that python exports to gdb. */
extern const struct extension_language_defn extension_language_python;
+
/* Command element for the 'python' command. */
extern cmd_list_element *python_cmd_element;
+extern void run_python_script (int argc, char **argv);
+
#endif /* GDB_PYTHON_H */
#endif /* PYTHON_PYTHON_H */
diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp
--- a/gdb/testsuite/gdb.python/py-frame.exp
+++ b/gdb/testsuite/gdb.python/py-frame.exp
@ -544,7 +548,7 @@ diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -384,6 +384,15 @@ proc test_value_after_death {} {
@@ -399,6 +399,15 @@ proc test_value_after_death {} {
"print value's type"
}
@ -560,8 +564,8 @@ diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py
# Regression test for invalid subscript operations. The bug was that
# the type of the value was not being checked before allowing a
# subscript operation to proceed.
@@ -512,6 +521,7 @@ if ![runto_main] then {
test_value_in_inferior
@@ -585,6 +594,7 @@ test_value_in_inferior
test_value_from_buffer
test_inferior_function_call
test_value_after_death
+test_cast_regression
@ -571,7 +575,7 @@ diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py
diff --git a/gdb/varobj.c b/gdb/varobj.c
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -218,6 +218,14 @@ is_root_p (const struct varobj *var)
@@ -217,6 +217,14 @@ is_root_p (const struct varobj *var)
}
#ifdef HAVE_PYTHON

View File

@ -45,7 +45,7 @@ gdb/gdbserver/
diff --git a/gdb/config.in b/gdb/config.in
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -276,6 +276,9 @@
@@ -267,6 +267,9 @@
/* Define if librpm library is being used. */
#undef HAVE_LIBRPM
@ -55,7 +55,7 @@ diff --git a/gdb/config.in b/gdb/config.in
/* Define to 1 if you have the <libunwind-ia64.h> header file. */
#undef HAVE_LIBUNWIND_IA64_H
@@ -399,6 +402,9 @@
@@ -390,6 +393,9 @@
/* Define to 1 if you have the `scm_new_smob' function. */
#undef HAVE_SCM_NEW_SMOB
@ -68,7 +68,7 @@ diff --git a/gdb/config.in b/gdb/config.in
diff --git a/gdb/configure b/gdb/configure
--- a/gdb/configure
+++ b/gdb/configure
@@ -15854,6 +15854,64 @@ cat >>confdefs.h <<_ACEOF
@@ -15898,6 +15898,64 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
@ -136,7 +136,7 @@ diff --git a/gdb/configure b/gdb/configure
diff --git a/gdb/configure.ac b/gdb/configure.ac
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2054,6 +2054,10 @@ case $host_os in
@@ -2051,6 +2051,10 @@ case $host_os in
esac
AC_DEFINE_UNQUOTED(GDBINIT,"$gdbinit",[The .gdbinit filename.])
@ -173,7 +173,7 @@ diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -8535,6 +8535,64 @@ if $want_ipa ; then
@@ -8589,6 +8589,64 @@ if $want_ipa ; then
fi
fi
@ -241,7 +241,7 @@ diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -486,6 +486,10 @@ if $want_ipa ; then
@@ -478,6 +478,10 @@ if $want_ipa ; then
fi
fi
@ -276,9 +276,9 @@ diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1089,7 +1089,17 @@ linux_nat_target::create_inferior (const char *exec_file,
@@ -1099,7 +1099,17 @@ linux_nat_target::create_inferior (const char *exec_file,
/* Make sure we report all signals during startup. */
pass_signals (0, NULL);
pass_signals ({});
- inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty);
+ TRY
@ -318,7 +318,7 @@ diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
return result;
}
@@ -583,6 +589,25 @@ linux_ptrace_init_warnings (void)
@@ -586,6 +592,25 @@ linux_ptrace_init_warnings (void)
linux_ptrace_test_ret_to_nx ();
}

View File

@ -14,7 +14,7 @@ printed, but a default backtrace will occur in this case.
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -1151,6 +1151,7 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
@@ -1139,6 +1139,7 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
htab_eq_pointer,
NULL));
@ -22,22 +22,22 @@ diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
while (true)
{
gdbpy_ref<> item (PyIter_Next (iterable.get ()));
@@ -1159,8 +1160,8 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
@@ -1147,8 +1148,8 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
{
if (PyErr_Occurred ())
{
- throw_quit_or_print_exception ();
- gdbpy_print_stack_or_quit ();
- return EXT_LANG_BT_ERROR;
+ gdbpy_print_stack ();
+ return count_printed > 0 ? EXT_LANG_BT_ERROR : EXT_LANG_BT_NO_FILTERS;
}
break;
}
@@ -1193,7 +1194,8 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
@@ -1181,7 +1182,8 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
/* Do not exit on error printing a single frame. Print the
error and continue with other frames. */
if (success == EXT_LANG_BT_ERROR)
- throw_quit_or_print_exception ();
- gdbpy_print_stack_or_quit ();
+ gdbpy_print_stack ();
+ count_printed++;
}

View File

@ -80,18 +80,18 @@ gdb/testsuite/ChangeLog
diff --git a/gdb/main.c b/gdb/main.c
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1115,7 +1115,10 @@ captured_main_1 (struct captured_main_args *context)
if (isdigit (pid_or_core_arg[0]))
@@ -1129,7 +1129,10 @@ captured_main_1 (struct captured_main_args *context)
{
if (catch_command_errors (attach_command, pid_or_core_arg,
- !batch_flag) == 0)
+ !batch_flag) == 0
ret = catch_command_errors (attach_command, pid_or_core_arg,
!batch_flag);
- if (ret == 0)
+ if (ret == 0
+ /* attach_command could succeed partially and core_file_command
+ would try to kill it. */
+ && !have_inferiors ())
catch_command_errors (core_file_command, pid_or_core_arg,
!batch_flag);
}
ret = catch_command_errors (core_file_command,
pid_or_core_arg,
!batch_flag);
diff --git a/gdb/testsuite/gdb.base/attach-kills.c b/gdb/testsuite/gdb.base/attach-kills.c
new file mode 100644
--- /dev/null

View File

@ -30,7 +30,7 @@ debugging problem of GOMP outside of the scope of this Bug.
diff --git a/gdb/infrun.c b/gdb/infrun.c
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -6695,6 +6695,16 @@ process_event_stop_test (struct execution_control_state *ecs)
@@ -6499,6 +6499,16 @@ process_event_stop_test (struct execution_control_state *ecs)
if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL)
{
@ -47,7 +47,7 @@ diff --git a/gdb/infrun.c b/gdb/infrun.c
/* We're doing a "next".
Normal (forward) execution: set a breakpoint at the
@@ -6728,6 +6738,7 @@ process_event_stop_test (struct execution_control_state *ecs)
@@ -6532,6 +6542,7 @@ process_event_stop_test (struct execution_control_state *ecs)
keep_going (ecs);
return;

View File

@ -10,7 +10,7 @@ Subject: gdb-bz541866-rwatch-before-run.patch
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8807,7 +8807,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
@@ -8773,7 +8773,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
int enabled, int internal, unsigned flags,
int display_canonical)
{
@ -19,7 +19,7 @@ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
if (type == bp_hardware_breakpoint)
{
@@ -14356,7 +14356,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition,
@@ -14271,7 +14271,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition,
if (bpt->type == bp_hardware_breakpoint)
{
@ -97,26 +97,26 @@ new file mode 100644
diff --git a/gdb/configure.nat b/gdb/configure.nat
--- a/gdb/configure.nat
+++ b/gdb/configure.nat
@@ -238,6 +238,7 @@ case ${gdb_host} in
@@ -245,6 +245,7 @@ case ${gdb_host} in
;;
i386)
# Host: Intel 386 running GNU/Linux.
+ NAT_FILE="${srcdir}/config/${gdb_host_cpu}/nm-linux.h"
NATDEPFILES="${NATDEPFILES} x86-nat.o x86-dregs.o \
i386-linux-nat.o x86-linux-nat.o linux-btrace.o \
x86-linux.o x86-linux-dregs.o"
@@ -290,6 +291,7 @@ case ${gdb_host} in
NATDEPFILES="${NATDEPFILES} x86-nat.o nat/x86-dregs.o \
i386-linux-nat.o x86-linux-nat.o nat/linux-btrace.o \
nat/x86-linux.o nat/x86-linux-dregs.o"
@@ -301,6 +302,7 @@ case ${gdb_host} in
case ${gdb_host_cpu} in
i386)
# Host: GNU/Linux x86-64
+ NAT_FILE="${srcdir}/config/${gdb_host_cpu}/nm-linux64.h"
NATDEPFILES="${NATDEPFILES} x86-nat.o x86-dregs.o \
amd64-nat.o amd64-linux-nat.o x86-linux-nat.o linux-btrace.o \
x86-linux.o x86-linux-dregs.o amd64-linux-siginfo.o"
NATDEPFILES="${NATDEPFILES} x86-nat.o nat/x86-dregs.o \
amd64-nat.o amd64-linux-nat.o x86-linux-nat.o \
nat/linux-btrace.o \
diff --git a/gdb/target.h b/gdb/target.h
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1953,9 +1953,11 @@ extern struct thread_info *target_thread_handle_to_thread_info
@@ -1971,9 +1971,11 @@ extern struct thread_info *target_thread_handle_to_thread_info
one. OTHERTYPE is the number of watchpoints of other types than
this one used so far. */

View File

@ -53,7 +53,7 @@ gdb/
diff --git a/gdb/utils.c b/gdb/utils.c
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -746,13 +746,11 @@ malloc_failure (long size)
@@ -721,13 +721,11 @@ malloc_failure (long size)
{
if (size > 0)
{

View File

@ -9,7 +9,7 @@ Subject: gdb-container-rh-pkg.patch
diff --git a/gdb/remote.c b/gdb/remote.c
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -13909,7 +13909,17 @@ remote_target::pid_to_exec_file (int pid)
@@ -13966,7 +13966,17 @@ remote_target::pid_to_exec_file (int pid)
char *annex = NULL;
if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE)

View File

@ -12,7 +12,7 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1270534
diff --git a/gdb/configure b/gdb/configure
--- a/gdb/configure
+++ b/gdb/configure
@@ -9393,6 +9393,7 @@ if test x"$prefer_curses" = xyes; then
@@ -9418,6 +9418,7 @@ if test x"$prefer_curses" = xyes; then
# search /usr/local/include, if ncurses is installed in /usr/local. A
# default installation of ncurses on alpha*-dec-osf* will lead to such
# a situation.
@ -20,7 +20,7 @@ diff --git a/gdb/configure b/gdb/configure
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing waddstr" >&5
$as_echo_n "checking for library containing waddstr... " >&6; }
if ${ac_cv_search_waddstr+:} false; then :
@@ -9417,7 +9418,7 @@ return waddstr ();
@@ -9442,7 +9443,7 @@ return waddstr ();
return 0;
}
_ACEOF
@ -29,7 +29,7 @@ diff --git a/gdb/configure b/gdb/configure
if test -z "$ac_lib"; then
ac_res="none required"
else
@@ -9491,6 +9492,7 @@ case $host_os in
@@ -9516,6 +9517,7 @@ case $host_os in
esac
# These are the libraries checked by Readline.
@ -37,19 +37,19 @@ diff --git a/gdb/configure b/gdb/configure
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
$as_echo_n "checking for library containing tgetent... " >&6; }
if ${ac_cv_search_tgetent+:} false; then :
@@ -9515,7 +9517,7 @@ return tgetent ();
@@ -9540,7 +9542,7 @@ return tgetent ();
return 0;
}
_ACEOF
-for ac_lib in '' termcap tinfo curses ncursesw ncurses; do
+for ac_lib in '' termcap tinfo ncursesw; do
-for ac_lib in '' termcap tinfow tinfo curses ncursesw ncurses; do
+for ac_lib in '' ncursesw; do
if test -z "$ac_lib"; then
ac_res="none required"
else
diff --git a/gdb/configure.ac b/gdb/configure.ac
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -766,7 +766,8 @@ if test x"$prefer_curses" = xyes; then
@@ -743,7 +743,8 @@ if test x"$prefer_curses" = xyes; then
# search /usr/local/include, if ncurses is installed in /usr/local. A
# default installation of ncurses on alpha*-dec-osf* will lead to such
# a situation.
@ -59,13 +59,13 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac
if test "$ac_cv_search_waddstr" != no; then
curses_found=yes
@@ -808,7 +809,8 @@ case $host_os in
@@ -785,7 +786,8 @@ case $host_os in
esac
# These are the libraries checked by Readline.
-AC_SEARCH_LIBS(tgetent, [termcap tinfo curses ncursesw ncurses])
-AC_SEARCH_LIBS(tgetent, [termcap tinfow tinfo curses ncursesw ncurses])
+# Fedora: Force libncursesw over libncurses to match the includes.
+AC_SEARCH_LIBS(tgetent, [termcap tinfo ncursesw])
+AC_SEARCH_LIBS(tgetent, [ncursesw])
if test "$ac_cv_search_tgetent" = no; then
CONFIG_OBS="$CONFIG_OBS stub-termcap.o"

View File

@ -1,220 +0,0 @@
From 31aceee86308321c2ef299e50773d0043e458e7f Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Thu, 1 Nov 2018 09:21:18 +0100
Subject: [PATCH] [gdb] Fix gdb crash when reading core file
Consider the test-case from this patch, compiled with O0.
The executable segfaults, and generates a core dump:
...
$ ./a.out
Segmentation fault (core dumped)
...
When loading the core file, limiting stack size to 4MB, gdb crashes:
...
$ ulimit -s 4096
$ gdb -batch ./a.out core.saved
[New LWP 19379]
Segmentation fault (core dumped)
...
The crash originates here in linux_vsyscall_range_raw, where we call alloca
with phdrs_size == 4194112 (roughly 4MB):
...
phdrs = (Elf_Internal_Phdr *) alloca (phdrs_size);
...
While for this test-case gdb runs fine with the system default stack limit of
8MB, there are cases reported of 12MB phdrs_size where gdb also crashes with
the system default stack limit.
Fix this by using xmalloc instead of alloca, which prevents the crash provided
the stack limit is at least 112kb.
Build and reg-tested on x86_64-linux.
2018-11-06 Tom de Vries <tdevries@suse.de>
* linux-tdep.c (linux_vsyscall_range_raw): Use xmalloc to allocate
program headers.
* gdb.base/many-headers.c: New test.
* gdb.base/many-headers.exp: New file.
---
gdb/ChangeLog | 5 +++
gdb/linux-tdep.c | 12 +++---
gdb/testsuite/ChangeLog | 5 +++
gdb/testsuite/gdb.base/many-headers.c | 50 ++++++++++++++++++++++++
gdb/testsuite/gdb.base/many-headers.exp | 67 +++++++++++++++++++++++++++++++++
5 files changed, 133 insertions(+), 6 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/many-headers.c
create mode 100644 gdb/testsuite/gdb.base/many-headers.exp
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index c958c0dfe9..2c766808f0 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -2269,7 +2269,6 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range)
the vDSO. */
if (!target_has_execution)
{
- Elf_Internal_Phdr *phdrs;
long phdrs_size;
int num_phdrs, i;
@@ -2277,16 +2276,17 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range)
if (phdrs_size == -1)
return 0;
- phdrs = (Elf_Internal_Phdr *) alloca (phdrs_size);
- num_phdrs = bfd_get_elf_phdrs (core_bfd, phdrs);
+ gdb::unique_xmalloc_ptr<Elf_Internal_Phdr>
+ phdrs ((Elf_Internal_Phdr *) xmalloc (phdrs_size));
+ num_phdrs = bfd_get_elf_phdrs (core_bfd, phdrs.get ());
if (num_phdrs == -1)
return 0;
for (i = 0; i < num_phdrs; i++)
- if (phdrs[i].p_type == PT_LOAD
- && phdrs[i].p_vaddr == range->start)
+ if (phdrs.get ()[i].p_type == PT_LOAD
+ && phdrs.get ()[i].p_vaddr == range->start)
{
- range->length = phdrs[i].p_memsz;
+ range->length = phdrs.get ()[i].p_memsz;
return 1;
}
diff --git a/gdb/testsuite/gdb.base/many-headers.c b/gdb/testsuite/gdb.base/many-headers.c
new file mode 100644
index 0000000000..49675b4e40
--- /dev/null
+++ b/gdb/testsuite/gdb.base/many-headers.c
@@ -0,0 +1,50 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2018 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/>. */
+
+#include <stdio.h>
+#include <malloc.h>
+#include <sys/mman.h>
+
+int
+main (void)
+{
+ char *ptr;
+ int ind, cnt;
+
+ cnt = 100000;
+ for (ind = 0; ind < cnt; ind++)
+ {
+ ptr = mmap (NULL, 100, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ if (ptr == NULL)
+ {
+ fprintf (stderr, "Error allocating memory using mmap\n");
+ return -1;
+ }
+
+ ptr = mmap (NULL, 100, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ if (ptr == NULL)
+ {
+ fprintf (stderr, "Error allocating memory using mmap\n");
+ return -1;
+ }
+ }
+
+ ptr = NULL;
+ *ptr = '\0';
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/many-headers.exp b/gdb/testsuite/gdb.base/many-headers.exp
new file mode 100644
index 0000000000..f02b291e36
--- /dev/null
+++ b/gdb/testsuite/gdb.base/many-headers.exp
@@ -0,0 +1,67 @@
+# Copyright 2018 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/>.
+
+# Test if gdb can read a core file with a program header size of 4MB, if the
+# stack size is limited to 4MB.
+
+if { [target_info gdb_protocol] != "" } {
+ # Even though the feature under features being tested are supported by
+ # gdbserver, the way this test is written doesn't make it easy with a
+ # remote target.
+ unsupported "not native"
+ return
+}
+
+standard_testfile
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
+ return -1
+}
+
+# Generate core file.
+set corefile [core_find $binfile]
+if {$corefile == ""} {
+ return 0
+}
+
+# Limit is in kb, so this is 4MB.
+set stack_limit 4096
+
+# Verify if we can set the stack limit.
+catch {
+ system [concat \
+ "(" \
+ "ulimit -s $stack_limit;" \
+ ")"]
+} msg
+if { "$msg" != "" } {
+ untested "Can't set stack limit"
+ return -1
+}
+
+# Run gdb with stack limit
+catch {
+ system [concat \
+ "(" \
+ "ulimit -s $stack_limit;" \
+ "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS -batch -core=$corefile" \
+ ")"]
+} msg
+set test "read core file"
+if { "$msg" == "" } {
+ pass "$test"
+} else {
+ fail "$test"
+}
--
2.16.4

View File

@ -0,0 +1,314 @@
commit 55db11619271cc820adccf35abafe18966ecbf4d
Author: Tom de Vries <tdevries@suse.de>
Date: Thu May 2 17:48:44 2019 +0200
[gdb] Fix heap-use-after-free in typename_concat
When running gdb using AddressSanitizer, and loading a cc1plus binary built
with profiledbootstrap and -flto, we run into a heap-use-after-free error:
...
$ LD_PRELOAD=/usr/lib64/libasan.so.3 ./gdb -batch cc1plus
==26855==ERROR: AddressSanitizer: heap-use-after-free on address \
0x62100ad8a8b0 at pc 0x7f13803cc9e3 bp 0x7ffe55b0d090 sp 0x7ffe55b0c840
READ of size 47 at 0x62100ad8a8b0 thread T0
#0 0x7f13803cc9e2 (/usr/lib64/libasan.so.3+0x3e9e2)
#1 0x5e7a0d in typename_concat gdb/dwarf2read.c:22661
#2 0x5c6437 in partial_die_full_name gdb/dwarf2read.c:8876
#3 0x5c6555 in add_partial_symbol gdb/dwarf2read.c:8893
#4 0x5c6ecf in add_partial_subprogram gdb/dwarf2read.c:9156
#5 0x5c5e90 in scan_partial_symbols gdb/dwarf2read.c:8668
#6 0x5c6c0a in add_partial_namespace gdb/dwarf2read.c:9081
#7 0x5c5f99 in scan_partial_symbols gdb/dwarf2read.c:8702
#8 0x5c48b6 in process_psymtab_comp_unit_reader gdb/dwarf2read.c:8056
#9 0x5c3c1f in init_cutu_and_read_dies gdb/dwarf2read.c:7689
#10 0x5c4c03 in process_psymtab_comp_unit gdb/dwarf2read.c:8140
#11 0x5c58a2 in dwarf2_build_psymtabs_hard gdb/dwarf2read.c:8500
#12 0x5c0d03 in dwarf2_build_psymtabs(objfile*) gdb/dwarf2read.c:6337
#13 0x612359 in read_psyms gdb/elfread.c:1311
#14 0x798a64 in require_partial_symbols(objfile*, int) gdb/psymtab.c:115
#15 0x867d7b in read_symbols gdb/symfile.c:821
#16 0x8683d9 in syms_from_objfile_1 gdb/symfile.c:1000
#17 0x8684a1 in syms_from_objfile gdb/symfile.c:1017
#18 0x868873 in symbol_file_add_with_addrs gdb/symfile.c:1124
#19 0x868b0a in symbol_file_add_from_bfd(bfd*, char const*, \
enum_flags<symfile_add_flag>, std::vector<other_sections, \
std::allocator<other_sections> >*, \
enum_flags<objfile_flag>, objfile*) gdb/symfile.c:1204
#20 0x868b64 in symbol_file_add(char const*, \
enum_flags<symfile_add_flag>, \
std::vector<other_sections, \
std::allocator<other_sections> >*, \
enum_flags<objfile_flag>) gdb/symfile.c:1217
#21 0x868c39 in symbol_file_add_main_1 gdb/symfile.c:1240
#22 0x868bd0 in symbol_file_add_main(char const*, \
enum_flags<symfile_add_flag>) gdb/symfile.c:1231
#23 0x71f1b2 in symbol_file_add_main_adapter gdb/main.c:395
#24 0x71f10e in catch_command_errors gdb/main.c:372
#25 0x71ff5f in captured_main_1 gdb/main.c:1043
#26 0x72045d in captured_main gdb/main.c:1163
#27 0x7204c8 in gdb_main(captured_main_args*) gdb/main.c:1188
#28 0x40fd7d in main gdb/gdb.c:32
#29 0x7f137e300f49 in __libc_start_main (/lib64/libc.so.6+0x20f49)
#30 0x40fc89 in _start (/data/gdb_versions/devel/build/gdb/gdb+0x40fc89)
0x62100ad8a8b0 is located 944 bytes inside of 4064-byte region \
[0x62100ad8a500,0x62100ad8b4e0)
freed by thread T0 here:
#0 0x7f13804523a0 in __interceptor_free (/usr/lib64/libasan.so.3+0xc43a0)
#1 0x435e44 in xfree<void> gdb/common/common-utils.h:60
#2 0xa82c25 in call_freefun libiberty/obstack.c:103
#3 0xa83098 in _obstack_free libiberty/obstack.c:280
#4 0x4367da in auto_obstack::~auto_obstack() gdb/gdb_obstack.h:101
#5 0x5ed72c in dwarf2_cu::~dwarf2_cu() gdb/dwarf2read.c:25341
#6 0x5fb5bb in std::default_delete<dwarf2_cu>::operator()(dwarf2_cu*) const \
/usr/include/c++/7/bits/unique_ptr.h:78
#7 0x5f7334 in std::unique_ptr<dwarf2_cu, \
std::default_delete<dwarf2_cu> >::~unique_ptr() \
/usr/include/c++/7/bits/unique_ptr.h:268
#8 0x5c3ce5 in init_cutu_and_read_dies gdb/dwarf2read.c:7624
#9 0x5c4c03 in process_psymtab_comp_unit gdb/dwarf2read.c:8140
#10 0x5c58a2 in dwarf2_build_psymtabs_hard gdb/dwarf2read.c:8500
#11 0x5c0d03 in dwarf2_build_psymtabs(objfile*) gdb/dwarf2read.c:6337
#12 0x612359 in read_psyms gdb/elfread.c:1311
#13 0x798a64 in require_partial_symbols(objfile*, int) gdb/psymtab.c:115
#14 0x867d7b in read_symbols gdb/symfile.c:821
#15 0x8683d9 in syms_from_objfile_1 gdb/symfile.c:1000
#16 0x8684a1 in syms_from_objfile gdb/symfile.c:1017
#17 0x868873 in symbol_file_add_with_addrs gdb/symfile.c:1124
#18 0x868b0a in symbol_file_add_from_bfd(bfd*, char const*, \
enum_flags<symfile_add_flag>, std::vector<other_sections, \
std::allocator<other_sections> >*, \
enum_flags<objfile_flag>, objfile*) gdb/symfile.c:1204
#19 0x868b64 in symbol_file_add(char const*, \
enum_flags<symfile_add_flag>, std::vector<other_sections, \
std::allocator<other_sections> >*, \
enum_flags<objfile_flag>) gdb/symfile.c:1217
#20 0x868c39 in symbol_file_add_main_1 gdb/symfile.c:1240
#21 0x868bd0 in symbol_file_add_main(char const*, \
enum_flags<symfile_add_flag>) gdb/symfile.c:1231
#22 0x71f1b2 in symbol_file_add_main_adapter gdb/main.c:395
#23 0x71f10e in catch_command_errors gdb/main.c:372
#24 0x71ff5f in captured_main_1 gdb/main.c:1043
#25 0x72045d in captured_main gdb/main.c:1163
#26 0x7204c8 in gdb_main(captured_main_args*) gdb/main.c:1188
#27 0x40fd7d in main gdb/gdb.c:32
#28 0x7f137e300f49 in __libc_start_main (/lib64/libc.so.6+0x20f49)
previously allocated by thread T0 here:
#0 0x7f13804526b8 in __interceptor_malloc (/usr/lib64/libasan.so.3+0xc46b8)
#1 0x5114b5 in xmalloc gdb/common/common-utils.c:44
#2 0xa82bd5 in call_chunkfun libiberty/obstack.c:94
#3 0xa82eda in _obstack_newchunk libiberty/obstack.c:206
#4 0x477310 in allocate_on_obstack::operator new(unsigned long, obstack*) \
gdb/gdb_obstack.h:117
#5 0x5dea8c in load_partial_dies gdb/dwarf2read.c:18571
#6 0x5c487f in process_psymtab_comp_unit_reader gdb/dwarf2read.c:8054
#7 0x5c3c1f in init_cutu_and_read_dies gdb/dwarf2read.c:7689
#8 0x5c4c03 in process_psymtab_comp_unit gdb/dwarf2read.c:8140
#9 0x5c58a2 in dwarf2_build_psymtabs_hard gdb/dwarf2read.c:8500
#10 0x5c0d03 in dwarf2_build_psymtabs(objfile*) gdb/dwarf2read.c:6337
#11 0x612359 in read_psyms gdb/elfread.c:1311
#12 0x798a64 in require_partial_symbols(objfile*, int) gdb/psymtab.c:115
#13 0x867d7b in read_symbols gdb/symfile.c:821
#14 0x8683d9 in syms_from_objfile_1 gdb/symfile.c:1000
#15 0x8684a1 in syms_from_objfile gdb/symfile.c:1017
#16 0x868873 in symbol_file_add_with_addrs gdb/symfile.c:1124
#17 0x868b0a in symbol_file_add_from_bfd(bfd*, char const*, \
enum_flags<symfile_add_flag>, \
std::vector<other_sections, \
std::allocator<other_sections> >*, \
enum_flags<objfile_flag>, objfile*) gdb/symfile.c:1204
#18 0x868b64 in symbol_file_add(char const*, enum_flags<symfile_add_flag>, \
std::vector<other_sections, \
std::allocator<other_sections> >*, \
enum_flags<objfile_flag>) gdb/symfile.c:1217
#19 0x868c39 in symbol_file_add_main_1 gdb/symfile.c:1240
#20 0x868bd0 in symbol_file_add_main(char const*, \
enum_flags<symfile_add_flag>) gdb/symfile.c:1231
#21 0x71f1b2 in symbol_file_add_main_adapter gdb/main.c:395
#22 0x71f10e in catch_command_errors gdb/main.c:372
#23 0x71ff5f in captured_main_1 gdb/main.c:1043
#24 0x72045d in captured_main gdb/main.c:1163
#25 0x7204c8 in gdb_main(captured_main_args*) gdb/main.c:1188
#26 0x40fd7d in main gdb/gdb.c:32
#27 0x7f137e300f49 in __libc_start_main (/lib64/libc.so.6+0x20f49)
...
This error happens as follows.
The function find_partial_die has a cu argument, but returns a pdi which may
or may not be from that cu:
...
/* Find a partial DIE at OFFSET, which may or may not be in CU,
except in the case of .debug_types DIEs which do not reference
outside their CU (they do however referencing other types via
DW_FORM_ref_sig8). */
static struct partial_die_info *
find_partial_die (sect_offset sect_off, int offset_in_dwz, struct dwarf2_cu *cu)
...
So the pdi returned by find_partial_die here in partial_die_parent_scope may
be from another cu:
...
partial_die_parent_scope (struct partial_die_info *pdi,
struct dwarf2_cu *cu)
{
const char *grandparent_scope;
struct partial_die_info *parent, *real_pdi;
/* We need to look at our parent DIE; if we have a DW_AT_specification,
then this means the parent of the specification DIE. */
real_pdi = pdi;
while (real_pdi->has_specification)
real_pdi = find_partial_die (real_pdi->spec_offset,
real_pdi->spec_is_dwz, cu);
parent = real_pdi->die_parent;
...
in which case both real_pdi and parent will be not from cu, but from another
one, say cu2.
Subsequently, cu's comp_unit_obstack is used to set parent->scope:
...
parent->scope = typename_concat (&cu->comp_unit_obstack,
grandparent_scope,
parent->name, 0, cu);
...
So, we use cu->comp_unit_obstack to assign a value to the scope field of
a pdi belonging to cu2, and when cu is deleted, the scope field points to a
freed value.
Fix this by making find_partial_die return the cu corresponding to the
returned pdi, and handling this at the call sites.
Tested on x86_64-linux.
gdb/ChangeLog:
2019-05-03 Tom de Vries <tdevries@suse.de>
PR gdb/24094
* dwarf2read.c (struct cu_partial_die_info): New struct.
(find_partial_die): Return cu_partial_die_info.
(partial_die_parent_scope, guess_partial_die_structure_name)
(partial_die_info::fixup): Handle new return type of find_partial_die.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b0bdecf96f..442b618f6e 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1518,8 +1518,14 @@ static unsigned int peek_abbrev_code (bfd *, const gdb_byte *);
static struct partial_die_info *load_partial_dies
(const struct die_reader_specs *, const gdb_byte *, int);
-static struct partial_die_info *find_partial_die (sect_offset, int,
- struct dwarf2_cu *);
+struct cu_partial_die_info
+{
+ struct dwarf2_cu *cu;
+ struct partial_die_info *pdi;
+};
+
+static struct cu_partial_die_info find_partial_die (sect_offset, int,
+ struct dwarf2_cu *);
static const gdb_byte *read_attribute (const struct die_reader_specs *,
struct attribute *, struct attr_abbrev *,
@@ -8771,14 +8777,19 @@ partial_die_parent_scope (struct partial_die_info *pdi,
{
const char *grandparent_scope;
struct partial_die_info *parent, *real_pdi;
+ struct cu_partial_die_info res;
/* We need to look at our parent DIE; if we have a DW_AT_specification,
then this means the parent of the specification DIE. */
real_pdi = pdi;
while (real_pdi->has_specification)
- real_pdi = find_partial_die (real_pdi->spec_offset,
- real_pdi->spec_is_dwz, cu);
+ {
+ res = find_partial_die (real_pdi->spec_offset,
+ real_pdi->spec_is_dwz, cu);
+ real_pdi = res.pdi;
+ cu = res.cu;
+ }
parent = real_pdi->die_parent;
if (parent == NULL)
@@ -18922,7 +18933,7 @@ dwarf2_cu::find_partial_die (sect_offset sect_off)
outside their CU (they do however referencing other types via
DW_FORM_ref_sig8). */
-static struct partial_die_info *
+static struct cu_partial_die_info
find_partial_die (sect_offset sect_off, int offset_in_dwz, struct dwarf2_cu *cu)
{
struct dwarf2_per_objfile *dwarf2_per_objfile
@@ -18936,7 +18947,12 @@ find_partial_die (sect_offset sect_off, int offset_in_dwz, struct dwarf2_cu *cu)
{
pd = cu->find_partial_die (sect_off);
if (pd != NULL)
- return pd;
+ {
+ struct cu_partial_die_info res;
+ res.pdi = pd;
+ res.cu = cu;
+ return res;
+ }
/* We missed recording what we needed.
Load all dies and try again. */
per_cu = cu->per_cu;
@@ -18984,7 +19000,12 @@ find_partial_die (sect_offset sect_off, int offset_in_dwz, struct dwarf2_cu *cu)
_("could not find partial DIE %s "
"in cache [from module %s]\n"),
sect_offset_str (sect_off), bfd_get_filename (objfile->obfd));
- return pd;
+ {
+ struct cu_partial_die_info res;
+ res.pdi = pd;
+ res.cu = per_cu->cu;
+ return res;
+ }
}
/* See if we can figure out if the class lives in a namespace. We do
@@ -19003,6 +19024,7 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi,
struct partial_die_info *real_pdi;
struct partial_die_info *child_pdi;
+ struct cu_partial_die_info res;
/* If this DIE (this DIE's specification, if any) has a parent, then
we should not do this. We'll prepend the parent's fully qualified
@@ -19010,8 +19032,12 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi,
real_pdi = struct_pdi;
while (real_pdi->has_specification)
- real_pdi = find_partial_die (real_pdi->spec_offset,
- real_pdi->spec_is_dwz, cu);
+ {
+ res = find_partial_die (real_pdi->spec_offset,
+ real_pdi->spec_is_dwz, cu);
+ real_pdi = res.pdi;
+ cu = res.cu;
+ }
if (real_pdi->die_parent != NULL)
return;
@@ -19056,8 +19082,11 @@ partial_die_info::fixup (struct dwarf2_cu *cu)
if (name == NULL && has_specification)
{
struct partial_die_info *spec_die;
+ struct cu_partial_die_info res;
- spec_die = find_partial_die (spec_offset, spec_is_dwz, cu);
+ res = find_partial_die (spec_offset, spec_is_dwz, cu);
+ spec_die = res.pdi;
+ cu = res.cu;
spec_die->fixup (cu);

View File

@ -1,92 +0,0 @@
[gdb] Fix multidictionary.exp for gdb 8.2
---
gdb/testsuite/gdb.dwarf2/multidictionary.exp | 2 +-
gdb/testsuite/lib/gdb.exp | 25 ++++++++++++++++++++-----
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/gdb.dwarf2/multidictionary.exp b/gdb/testsuite/gdb.dwarf2/multidictionary.exp
index 5588ef2144..9b44035aeb 100644
--- a/gdb/testsuite/gdb.dwarf2/multidictionary.exp
+++ b/gdb/testsuite/gdb.dwarf2/multidictionary.exp
@@ -148,7 +148,7 @@ if {[build_executable $testfile.exp $testfile [list $asm_file $srcfile] {}] \
# We force the DIEs above to be read in via "-readnow".
gdb_spawn_with_cmdline_opts "-readnow"
-gdb_load $binfile
+gdb_load_no_done $binfile
# All we need to do is check whether GDB is alive. Without
# multidictionaries, it will either crash, assert, or throw an
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index aef580b04d..f061af3b6c 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1485,7 +1485,7 @@ proc default_gdb_exit {} {
# TODO: gdb.base/sepdebug.exp and gdb.stabs/weird.exp might be able to use
# this if they can get more information set.
-proc gdb_file_cmd { arg } {
+proc gdb_file_cmd_1 { arg done } {
global gdb_prompt
global verbose
global GDB
@@ -1523,17 +1523,17 @@ proc gdb_file_cmd { arg } {
send_gdb "file $arg\n"
gdb_expect 120 {
- -re "Reading symbols from.*LZMA support was disabled.*done.*$gdb_prompt $" {
+ -re "Reading symbols from.*LZMA support was disabled.*$done.*$gdb_prompt $" {
verbose "\t\tLoaded $arg into $GDB; .gnu_debugdata found but no LZMA available"
set gdb_file_cmd_debug_info "lzma"
return 0
}
- -re "Reading symbols from.*no debugging symbols found.*done.*$gdb_prompt $" {
+ -re "Reading symbols from.*no debugging symbols found.*$done.*$gdb_prompt $" {
verbose "\t\tLoaded $arg into $GDB with no debugging symbols"
set gdb_file_cmd_debug_info "nodebug"
return 0
}
- -re "Reading symbols from.*done.*$gdb_prompt $" {
+ -re "Reading symbols from.*$done.*$gdb_prompt $" {
verbose "\t\tLoaded $arg into $GDB"
set gdb_file_cmd_debug_info "debug"
return 0
@@ -1541,7 +1541,7 @@ proc gdb_file_cmd { arg } {
-re "Load new symbol table from \".*\".*y or n. $" {
send_gdb "y\n"
gdb_expect 120 {
- -re "Reading symbols from.*done.*$gdb_prompt $" {
+ -re "Reading symbols from.*$done.*$gdb_prompt $" {
verbose "\t\tLoaded $arg with new symbol table into $GDB"
set gdb_file_cmd_debug_info "debug"
return 0
@@ -1583,6 +1583,14 @@ proc gdb_file_cmd { arg } {
}
}
+proc gdb_file_cmd { arg } {
+ gdb_file_cmd_1 $arg "done"
+}
+
+proc gdb_file_cmd_no_done { arg } {
+ gdb_file_cmd_1 $arg ""
+}
+
# Default gdb_spawn procedure.
proc default_gdb_spawn { } {
@@ -4511,6 +4519,13 @@ proc gdb_load { arg } {
return 0
}
+proc gdb_load_no_done { arg } {
+ if { $arg != "" } {
+ return [gdb_file_cmd_no_done $arg]
+ }
+ return 0
+}
+
# gdb_reload -- load a file into the target. Called before "running",
# either the first time or after already starting the program once,
# for remote targets. Most files that override gdb_load should now

30
gdb-fix-riscv-tdep.patch Normal file
View File

@ -0,0 +1,30 @@
In gdb-rhbz795424-bitpos-20of25.patch, the TYPE_LENGTH is changed from
unsigned to ULONGEST.
This breaks the build on RISC-V:
...
gdb/riscv-tdep.c: In function 'int riscv_type_alignment(type*)':
gdb/riscv-tdep.c:1648:64: error: no matching function for call to \
'min(ULONGEST&, unsigned int)'
return std::min (TYPE_LENGTH (t), (unsigned) BIGGEST_ALIGNMENT);
...
Fix this by backporting a fragment of an unrelated commit on master that
also changes TYPE_LENGTH from unsigned to ULONGEST.
...
$ git show --pretty=%p cc1defb1dc gdb/riscv-tdep.c
...
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 8a996f32d3..ff5f36e762 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -1645,7 +1645,7 @@ riscv_type_alignment (struct type *t)
case TYPE_CODE_ARRAY:
if (TYPE_VECTOR (t))
- return std::min (TYPE_LENGTH (t), (unsigned) BIGGEST_ALIGNMENT);
+ return std::min (TYPE_LENGTH (t), (ULONGEST) BIGGEST_ALIGNMENT);
/* FALLTHROUGH */
case TYPE_CODE_COMPLEX:

View File

@ -24,7 +24,7 @@ unwinders try to access it, breaking:
diff --git a/gdb/infrun.c b/gdb/infrun.c
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -752,6 +752,9 @@ follow_fork (void)
@@ -754,6 +754,9 @@ follow_fork (void)
}
else
{

View File

@ -1,50 +0,0 @@
From 7406a50077773e78282a495cb32ef5b8179f6a33 Mon Sep 17 00:00:00 2001
From: Dimitar Dimitrov <dimitar@dinux.eu>
Date: Mon, 17 Dec 2018 21:30:52 +0200
Subject: [PATCH] Fix build with latest GCC 9.0 tree
A recent patch [1] to fix a GCC PR [2] actually broke the GDB build.
To fix, remove the stack pointer clobber. GCC will ignore the clobber
marker, and will not save or restore the stack pointer.
I ran "make check-gdb" on x86_64 to ensure there are no regressions.
gdb/ChangeLog:
2018-12-17 Dimitar Dimitrov <dimitar@dinux.eu>
* nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Remove sp clobbers.
[1] https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00532.html
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52813
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
---
gdb/ChangeLog | 5 +++++
gdb/nat/linux-ptrace.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index d4c1b8f9fd..187cfeb9bc 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -161,14 +161,14 @@ linux_ptrace_test_ret_to_nx (void)
".globl linux_ptrace_test_ret_to_nx_instr;"
"linux_ptrace_test_ret_to_nx_instr:"
"ret"
- : : "r" (return_address) : "%esp", "memory");
+ : : "r" (return_address) : "memory");
#elif defined __x86_64__
asm volatile ("pushq %0;"
".globl linux_ptrace_test_ret_to_nx_instr;"
"linux_ptrace_test_ret_to_nx_instr:"
"ret"
: : "r" ((uint64_t) (uintptr_t) return_address)
- : "%rsp", "memory");
+ : "memory");
#else
# error "!__i386__ && !__x86_64__"
#endif
--
2.21.0

View File

@ -1,48 +0,0 @@
From 453f8e1e4918171bc12e4d03aab7ee8360dfcfef Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Mon, 21 Jan 2019 15:36:41 -0500
Subject: [PATCH] Fix GCC9 warning on elf32-arm.c:elf32_arm_final_link_relocate
Fedora Rawhide has just switched to GCC9, and now GDB doesn't compile
because of a BFD warning:
BUILDSTDERR: ../../bfd/elf32-arm.c: In function 'elf32_arm_final_link_relocate':
BUILDSTDERR: ../../bfd/elf32-arm.c:10907:10: error: absolute value function 'labs' given an argument of type 'bfd_signed_vma' {aka 'long long int'} but has parameter of type 'long int' which may cause truncation of value [-Werror=absolute-value]
BUILDSTDERR: 10907 | value = labs (relocation);
BUILDSTDERR: | ^~~~
You can take a look at the full build log here:
https://kojipkgs.fedoraproject.org//work/tasks/4828/32174828/build.log
The fix is (apparently) simple: instead of using 'labs', we should use
'llabs', since we're passing a 'bfd_signed_vma' to it, which is at
least a 'long long int', as far as I have checked. This is what this
patch does.
bfd/ChangeLog:
2019-01-25 Sergio Durigan Junior <sergiodj@redhat.com>
* elf32-arm.c (elf32_arm_final_link_relocate): Use 'llabs' instead
of 'labs' (and fix GCC warning).
---
bfd/ChangeLog | 5 +++++
bfd/elf32-arm.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 53baea269b..28ee9d55a8 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -10904,7 +10904,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto,
/* PR 21523: Use an absolute value. The user of this reloc will
have already selected an ADD or SUB insn appropriately. */
- value = labs (relocation);
+ value = llabs (relocation);
if (value >= 0x1000)
return bfd_reloc_overflow;
--
2.21.0

View File

@ -4,43 +4,13 @@ Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-glibc-strstr-workaround.patch
;; Workaround PR libc/14166 for inferior calls of strstr.
;;=fedora: Compatibility with RHELs (unchecked which ones).
;;=fedoratest: Compatibility with RHELs (unchecked which ones).
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -21286,6 +21286,26 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
/* Cache this symbol's name and the name's demangled form (if any). */
SYMBOL_SET_LANGUAGE (sym, cu->language, &objfile->objfile_obstack);
linkagename = dwarf2_physname (name, die, cu);
+
+ /* Workaround for:
+ * invalid IFUNC DW_AT_linkage_name: memmove strstr time
+ * http://sourceware.org/bugzilla/show_bug.cgi?id=14166 */
+ if (strcmp (linkagename, "strstr") == 0
+ && strstr (objfile_name (objfile), "/libc") != NULL)
+ {
+ struct objfile *objfile_msym;
+ struct bound_minimal_symbol bmsym;
+
+ if (objfile->separate_debug_objfile_backlink)
+ objfile_msym = objfile->separate_debug_objfile_backlink;
+ else
+ objfile_msym = objfile;
+ bmsym = lookup_minimal_symbol ("strstr", NULL, objfile_msym);
+ if (bmsym.minsym != NULL
+ && MSYMBOL_TYPE (bmsym.minsym) == mst_text_gnu_ifunc)
+ linkagename = "__strstr";
+ }
+
SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), 0, objfile);
/* Fortran does not have mangling standard and the mangling does differ
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp
@@ -0,0 +1,108 @@
@@ -0,0 +1,115 @@
+# Copyright (C) 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
@ -103,6 +73,10 @@ new file mode 100644
+ set addr $expect_out(1,string)
+ pass "$test (fixed glibc)"
+ }
+ -re " = {<text gnu-indirect-function variable, no debug info>} (0x\[0-9a-f\]+) <__libc_strstr_ifunc>\r\n$gdb_prompt $" {
+ set addr $expect_out(1,string)
+ pass "$test (fixed glibc)"
+ }
+ -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" {
+ untested "$test (gnu-ifunc not in use by glibc)"
+ return 0
@ -142,6 +116,9 @@ new file mode 100644
+ -re " = {<text gnu-indirect-function variable, no debug info>} $addr <__libc_strstr>\r\n$gdb_prompt $" {
+ pass "$test (fixed glibc)"
+ }
+ -re " = {<text gnu-indirect-function variable, no debug info>} $addr <__libc_strstr_ifunc>\r\n$gdb_prompt $" {
+ pass "$test (fixed glibc)"
+ }
+ -re " = {void \\*\\(void\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" {
+ fail $test
+ }

View File

@ -42,7 +42,7 @@ gdb/
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10499,6 +10499,13 @@ private:
@@ -10588,6 +10588,13 @@ private:
static void
process_die (struct die_info *die, struct dwarf2_cu *cu)
{
@ -59,7 +59,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
diff --git a/gdb/infrun.c b/gdb/infrun.c
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -607,6 +607,13 @@ holding the child stopped. Try \"set detach-on-fork\" or \
@@ -609,6 +609,13 @@ holding the child stopped. Try \"set detach-on-fork\" or \
target_pid_to_str (process_ptid));
}
@ -76,7 +76,7 @@ diff --git a/gdb/infrun.c b/gdb/infrun.c
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -191,6 +191,12 @@ struct linux_nat_target *linux_target;
@@ -192,6 +192,12 @@ struct linux_nat_target *linux_target;
/* Does the current host support PTRACE_GETREGSET? */
enum tribool have_ptrace_getregset = TRIBOOL_UNKNOWN;
@ -86,10 +86,10 @@ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
+
+#endif
+
/* The saved to_close method, inherited from inf-ptrace.c.
Called by our to_close. */
static void (*super_close) (struct target_ops *);
@@ -1027,6 +1033,9 @@ linux_nat_post_attach_wait (ptid_t ptid, int *signalled)
static unsigned int debug_linux_nat;
static void
show_debug_linux_nat (struct ui_file *file, int from_tty,
@@ -1037,6 +1043,9 @@ linux_nat_post_attach_wait (ptid_t ptid, int *signalled)
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LNPAW: Attaching to a stopped process\n");
@ -99,7 +99,7 @@ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
/* The process is definitely stopped. It is in a job control
stop, unless the kernel predates the TASK_STOPPED /
@@ -1359,6 +1368,25 @@ get_detach_signal (struct lwp_info *lp)
@@ -1369,6 +1378,25 @@ get_detach_signal (struct lwp_info *lp)
return gdb_signal_to_host (signo);
}
@ -125,7 +125,7 @@ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
return 0;
}
@@ -1507,6 +1535,10 @@ linux_nat_target::detach (inferior *inf, int from_tty)
@@ -1517,6 +1545,10 @@ linux_nat_target::detach (inferior *inf, int from_tty)
detach_one_lwp (main_lwp, &signo);
detach_success (inf);
@ -136,7 +136,7 @@ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
}
}
@@ -1765,6 +1797,16 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
@@ -1775,6 +1807,16 @@ linux_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
return;
}
@ -153,7 +153,7 @@ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
if (resume_many)
iterate_over_lwps (ptid, linux_nat_resume_callback, lp);
@@ -3761,6 +3803,10 @@ linux_nat_target::mourn_inferior ()
@@ -3763,6 +3805,10 @@ linux_nat_target::mourn_inferior ()
/* Let the arch-specific native code know this process is gone. */
linux_target->low_forget_process (pid);

View File

@ -0,0 +1,431 @@
commit b73715df01e6e9b3de5a49cd7bf4170deef48461
Author: Tom de Vries <tdevries@suse.de>
Date: Thu Apr 18 17:05:43 2019 +0100
[gdb] Handle vfork in thread with follow-fork-mode child
When debugging any of the testcases added by this commit, which do a
vfork in a thread with "set follow-fork-mode child" + "set
detach-on-fork on", we run into this assertion:
...
src/gdb/nat/x86-linux-dregs.c:146: internal-error: \
void x86_linux_update_debug_registers(lwp_info*): \
Assertion `lwp_is_stopped (lwp)' failed.
...
The assert is caused by the following: the vfork-child exit or exec
event is handled by handle_vfork_child_exec_or_exit, which calls
target_detach to detach from the vfork parent. During target_detach
we call linux_nat_target::detach, which:
#1 - stops all the threads
#2 - waits for all the threads to be stopped
#3 - detaches all the threads
However, during the second step we run into this code in
stop_wait_callback:
...
/* If this is a vfork parent, bail out, it is not going to report
any SIGSTOP until the vfork is done with. */
if (inf->vfork_child != NULL)
return 0;
...
and we don't wait for the threads to be stopped, which results in this
assert in x86_linux_update_debug_registers triggering during the third
step:
...
gdb_assert (lwp_is_stopped (lwp));
...
The fix is to reset the vfork parent's vfork_child field before
calling target_detach in handle_vfork_child_exec_or_exit. There's
already similar code for the other paths handled by
handle_vfork_child_exec_or_exit, so this commit refactors the code a
bit so that all paths share the same code.
The new tests cover both a vfork child exiting, and a vfork child
execing, since both cases would trigger the assertion.
The new testcases also exercise following the vfork children with "set
detach-on-fork off", since it doesn't seem to be tested anywhere.
Tested on x86_64-linux, using native and native-gdbserver.
gdb/ChangeLog:
2019-04-18 Tom de Vries <tdevries@suse.de>
Pedro Alves <palves@redhat.com>
PR gdb/24454
* infrun.c (handle_vfork_child_exec_or_exit): Reset vfork parent's
vfork_child field before calling target_detach.
gdb/testsuite/ChangeLog:
2019-04-18 Tom de Vries <tdevries@suse.de>
Pedro Alves <palves@redhat.com>
PR gdb/24454
* gdb.threads/vfork-follow-child-exec.c: New file.
* gdb.threads/vfork-follow-child-exec.exp: New file.
* gdb.threads/vfork-follow-child-exit.c: New file.
* gdb.threads/vfork-follow-child-exit.exp: New file.
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 37713b24fe..37df561de0 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -915,10 +915,14 @@ handle_vfork_child_exec_or_exit (int exec)
int resume_parent = -1;
/* This exec or exit marks the end of the shared memory region
- between the parent and the child. If the user wanted to
- detach from the parent, now is the time. */
+ between the parent and the child. Break the bonds. */
+ inferior *vfork_parent = inf->vfork_parent;
+ inf->vfork_parent->vfork_child = NULL;
+ inf->vfork_parent = NULL;
- if (inf->vfork_parent->pending_detach)
+ /* If the user wanted to detach from the parent, now is the
+ time. */
+ if (vfork_parent->pending_detach)
{
struct thread_info *tp;
struct program_space *pspace;
@@ -926,7 +930,7 @@ handle_vfork_child_exec_or_exit (int exec)
/* follow-fork child, detach-on-fork on. */
- inf->vfork_parent->pending_detach = 0;
+ vfork_parent->pending_detach = 0;
gdb::optional<scoped_restore_exited_inferior>
maybe_restore_inferior;
@@ -941,7 +945,7 @@ handle_vfork_child_exec_or_exit (int exec)
maybe_restore_thread.emplace ();
/* We're letting loose of the parent. */
- tp = any_live_thread_of_inferior (inf->vfork_parent);
+ tp = any_live_thread_of_inferior (vfork_parent);
switch_to_thread (tp);
/* We're about to detach from the parent, which implicitly
@@ -964,7 +968,7 @@ handle_vfork_child_exec_or_exit (int exec)
if (print_inferior_events)
{
const char *pidstr
- = target_pid_to_str (ptid_t (inf->vfork_parent->pid));
+ = target_pid_to_str (ptid_t (vfork_parent->pid));
target_terminal::ours_for_output ();
@@ -982,7 +986,7 @@ handle_vfork_child_exec_or_exit (int exec)
}
}
- target_detach (inf->vfork_parent, 0);
+ target_detach (vfork_parent, 0);
/* Put it back. */
inf->pspace = pspace;
@@ -997,10 +1001,7 @@ handle_vfork_child_exec_or_exit (int exec)
inf->removable = 1;
set_current_program_space (inf->pspace);
- resume_parent = inf->vfork_parent->pid;
-
- /* Break the bonds. */
- inf->vfork_parent->vfork_child = NULL;
+ resume_parent = vfork_parent->pid;
}
else
{
@@ -1030,17 +1031,13 @@ handle_vfork_child_exec_or_exit (int exec)
set_current_program_space (pspace);
inf->removable = 1;
inf->symfile_flags = SYMFILE_NO_READ;
- clone_program_space (pspace, inf->vfork_parent->pspace);
+ clone_program_space (pspace, vfork_parent->pspace);
inf->pspace = pspace;
inf->aspace = pspace->aspace;
- resume_parent = inf->vfork_parent->pid;
- /* Break the bonds. */
- inf->vfork_parent->vfork_child = NULL;
+ resume_parent = vfork_parent->pid;
}
- inf->vfork_parent = NULL;
-
gdb_assert (current_program_space == inf->pspace);
if (non_stop && resume_parent != -1)
diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exec.c b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.c
new file mode 100644
index 0000000000..80632d1772
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.c
@@ -0,0 +1,66 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2019 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/>. */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <stdlib.h>
+
+static char *program_name;
+
+static void *
+f (void *arg)
+{
+ int res = vfork ();
+
+ if (res == -1)
+ {
+ perror ("vfork");
+ return NULL;
+ }
+ else if (res == 0)
+ {
+ /* Child. */
+ execl (program_name, program_name, "1", NULL);
+ perror ("exec");
+ abort ();
+ }
+ else
+ {
+ /* Parent. */
+ return NULL;
+ }
+}
+
+int
+main (int argc, char **argv)
+{
+ pthread_t tid;
+
+ if (argc > 1)
+ {
+ /* Getting here via execl. */
+ return 0;
+ }
+
+ program_name = argv[0];
+
+ pthread_create (&tid, NULL, f, NULL);
+ pthread_join (tid, NULL);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp
new file mode 100644
index 0000000000..5a28715fa0
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp
@@ -0,0 +1,64 @@
+# Copyright (C) 2019 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/>. */
+
+# Test following a vfork child that execs, when the vfork parent is a
+# threaded program, and it's a non-main thread that vforks.
+
+standard_testfile
+
+if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} {
+ return -1
+}
+
+# DETACH indicates whether "set detach-on-fork" is enabled. It is
+# either "on" or "off".
+
+proc test_vfork {detach} {
+ global binfile
+
+ clean_restart $binfile
+
+ if ![runto_main] then {
+ fail "can't run to main"
+ return 0
+ }
+
+ delete_breakpoints
+
+ gdb_test_no_output "set follow-fork-mode child"
+ gdb_test_no_output "set detach-on-fork $detach"
+
+ if {$detach == "off"} {
+ gdb_test "continue" \
+ [multi_line \
+ "Attaching after .* vfork to child .*" \
+ ".*New inferior 2 .*" \
+ ".* is executing new program: .*" \
+ ".*Inferior 2 .* exited normally.*"]
+ } else {
+ gdb_test "continue" \
+ [multi_line \
+ "Attaching after .* vfork to child .*" \
+ ".*New inferior 2 .*" \
+ ".*Detaching vfork parent process .* after child exec.*" \
+ ".*Inferior 1 .* detached.*" \
+ ".*is executing new program: .*" \
+ ".*Inferior 2 .*exited normally.*"]
+ }
+}
+
+foreach_with_prefix detach-on-fork {"off" "on"} {
+ test_vfork ${detach-on-fork}
+}
diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exit.c b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.c
new file mode 100644
index 0000000000..6ae254cce9
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.c
@@ -0,0 +1,52 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2019 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/>. */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <pthread.h>
+
+static void *
+f (void *arg)
+{
+ int res = vfork ();
+
+ if (res == -1)
+ {
+ perror ("vfork");
+ return NULL;
+ }
+ else if (res == 0)
+ {
+ /* Child. */
+ _exit (0);
+ }
+ else
+ {
+ /* Parent. */
+ return NULL;
+ }
+}
+
+int
+main (void)
+{
+ pthread_t tid;
+
+ pthread_create (&tid, NULL, f, NULL);
+ pthread_join (tid, NULL);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp
new file mode 100644
index 0000000000..f07215d41c
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp
@@ -0,0 +1,60 @@
+# Copyright (C) 2019 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/>. */
+
+# Test following a vfork child that exits, when the vfork parent is a
+# threaded program, and it's a non-main thread that vforks.
+
+standard_testfile
+
+if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} {
+ return -1
+}
+
+# DETACH indicates whether "set detach-on-fork" is enabled. It is
+# either "on" or "off".
+
+proc test_vfork {detach} {
+ global binfile
+
+ clean_restart $binfile
+
+ if ![runto_main] then {
+ fail "can't run to main"
+ return 0
+ }
+
+ gdb_test_no_output "set follow-fork-mode child"
+ gdb_test_no_output "set detach-on-fork $detach"
+
+ if {$detach == "off"} {
+ gdb_test "continue" \
+ [multi_line \
+ "Attaching after .* vfork to child .*" \
+ ".*New inferior 2 .*" \
+ ".*Inferior 2 .*exited normally.*"]
+ } else {
+ gdb_test "continue" \
+ [multi_line \
+ "Attaching after .* vfork to child .*" \
+ ".*New inferior 2 .*" \
+ ".*Detaching vfork parent process .* after child exit.*" \
+ ".*Inferior 1 .* detached.*" \
+ ".*Inferior 2 .*exited normally.*"]
+ }
+}
+
+foreach_with_prefix detach-on-fork {"off" "on"} {
+ test_vfork ${detach-on-fork}
+}

View File

@ -9,7 +9,7 @@ Subject: gdb-jit-reader-multilib.patch
diff --git a/gdb/configure b/gdb/configure
--- a/gdb/configure
+++ b/gdb/configure
@@ -9680,10 +9680,12 @@ _ACEOF
@@ -9705,10 +9705,12 @@ _ACEOF
@ -28,7 +28,7 @@ diff --git a/gdb/configure b/gdb/configure
diff --git a/gdb/configure.ac b/gdb/configure.ac
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -843,10 +843,12 @@ AC_CHECK_SIZEOF(unsigned long long)
@@ -820,10 +820,12 @@ AC_CHECK_SIZEOF(unsigned long long)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(unsigned __int128)

View File

@ -9,7 +9,7 @@ Subject: gdb-linux_perf-bundle.patch
diff --git a/gdb/configure b/gdb/configure
--- a/gdb/configure
+++ b/gdb/configure
@@ -12059,7 +12059,7 @@ else
@@ -12137,7 +12137,7 @@ else
#include <linux/perf_event.h>
#ifndef PERF_ATTR_SIZE_VER5
@ -21,7 +21,7 @@ diff --git a/gdb/configure b/gdb/configure
diff --git a/gdb/configure.ac b/gdb/configure.ac
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1477,7 +1477,7 @@ else
@@ -1500,7 +1500,7 @@ else
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
#include <linux/perf_event.h>
#ifndef PERF_ATTR_SIZE_VER5

View File

@ -14,7 +14,7 @@ Bug in FSF GDB exploited by the ptrace-on-utrace interaction.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -12016,6 +12016,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
@@ -11929,6 +11929,8 @@ update_global_location_list (enum ugll_insert_mode insert_mode)
traps we can no longer explain. */
old_loc->events_till_retirement = 3 * (thread_count () + 1);
@ -22,4 +22,4 @@ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
+ old_loc->events_till_retirement *= 10;
old_loc->owner = NULL;
VEC_safe_push (bp_location_p, moribund_locations, old_loc);
moribund_locations.push_back (old_loc);

View File

@ -1,241 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-python-gil.patch
;; Fix Python GIL with gdb.execute("continue") (Phil Muldoon, BZ 1116957).
;;=push
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -232,6 +232,14 @@ returned as a string. The default is @code{False}, in which case the
return value is @code{None}. If @var{to_string} is @code{True}, the
@value{GDBN} virtual terminal will be temporarily set to unlimited width
and height, and its pagination will be disabled; @pxref{Screen Size}.
+
+The @var{release_gil} flag specifies whether @value{GDBN} ought to
+release the Python GIL before executing the command. This is useful
+in multi-threaded Python programs where by default the Python
+interpreter will acquire the GIL and lock other threads from
+executing. After the command has completed executing in @value{GDBN}
+the Python GIL is reacquired. This flag must be a boolean value. If
+omitted, it defaults to @code{False}.
@end defun
@findex gdb.breakpoints
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -148,6 +148,8 @@ typedef int Py_ssize_t;
#define PyGILState_Release(ARG) ((void)(ARG))
#define PyEval_InitThreads()
#define PyThreadState_Swap(ARG) ((void)(ARG))
+#define PyEval_SaveThread() ((void)(ARG))
+#define PyEval_RestoreThread(ARG) ((void)(ARG))
#define PyEval_ReleaseLock()
#endif
diff --git a/gdb/python/python.c b/gdb/python/python.c
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -556,12 +556,16 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
{
const char *arg;
PyObject *from_tty_obj = NULL, *to_string_obj = NULL;
- int from_tty, to_string;
- static const char *keywords[] = { "command", "from_tty", "to_string", NULL };
+ int from_tty, to_string, release_gil;
+ static const char *keywords[] = {"command", "from_tty", "to_string", "release_gil", NULL };
+ PyObject *release_gil_obj = NULL;
+ /* Initialize it just to avoid a GCC false warning. */
+ PyThreadState *state = NULL;
- if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!", keywords, &arg,
+ if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|O!O!O!", keywords, &arg,
&PyBool_Type, &from_tty_obj,
- &PyBool_Type, &to_string_obj))
+ &PyBool_Type, &to_string_obj,
+ &PyBool_Type, &release_gil_obj))
return NULL;
from_tty = 0;
@@ -582,6 +586,15 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
to_string = cmp;
}
+ release_gil = 0;
+ if (release_gil_obj)
+ {
+ int cmp = PyObject_IsTrue (release_gil_obj);
+ if (cmp < 0)
+ return NULL;
+ release_gil = cmp;
+ }
+
std::string to_string_res;
TRY
@@ -602,6 +615,13 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
counted_command_line lines = read_command_lines_1 (reader, 1, nullptr);
+ /* In the case of long running GDB commands, allow the user to
+ release the Python GIL acquired by Python. Restore the GIL
+ after the command has completed before handing back to
+ Python. */
+ if (release_gil)
+ state = PyEval_SaveThread();
+
scoped_restore save_async = make_scoped_restore (&current_ui->async, 0);
scoped_restore save_uiout = make_scoped_restore (&current_uiout);
@@ -617,10 +637,22 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
from_tty);
else
execute_control_commands (lines.get (), from_tty);
+
+ /* Reacquire the GIL if it was released earlier. */
+ if (release_gil)
+ PyEval_RestoreThread (state);
}
CATCH (except, RETURN_MASK_ALL)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ if (except.reason < 0)
+ {
+ /* Reacquire the GIL if it was released earlier. */
+ if (release_gil)
+ PyEval_RestoreThread (state);
+
+ gdbpy_convert_exception (except);
+ return NULL;
+ }
}
END_CATCH
diff --git a/gdb/testsuite/gdb.python/py-gil-mthread.c b/gdb/testsuite/gdb.python/py-gil-mthread.c
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-gil-mthread.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <unistd.h>
+
+int
+main (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ sleep (1); /* break-here */
+ printf ("Sleeping %d\n", i);
+ }
+}
diff --git a/gdb/testsuite/gdb.python/py-gil-mthread.exp b/gdb/testsuite/gdb.python/py-gil-mthread.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-gil-mthread.exp
@@ -0,0 +1,69 @@
+# 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 .c .py
+set executable $testfile
+
+if { [prepare_for_testing $testfile.exp $executable $srcfile] } {
+ return -1
+}
+
+# Skip all tests if Python scripting is not enabled.
+if { [skip_python_tests] } { continue }
+
+if ![runto_main] {
+ return -1
+}
+
+gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"] temporary
+gdb_continue_to_breakpoint "break-here" ".* break-here .*"
+
+set test "response"
+set timeout 60
+set sleeping_last -1
+set hello_last 0
+set minimal 5
+gdb_test_multiple "python exec (open ('$srcdir/$subdir/$srcfile2').read ())" $test {
+ -re "Error: unable to start thread\r\n" {
+ fail $test
+ # Not $gdb_prompt-synced!
+ }
+ -re "Sleeping (\[0-9\]+)\r\n" {
+ set n $expect_out(1,string)
+ if { $sleeping_last + 1 != $n } {
+ fail $test
+ } else {
+ set sleeping_last $n
+ if { $sleeping_last >= $minimal && $hello_last >= $minimal } {
+ pass $test
+ } else {
+ exp_continue
+ }
+ }
+ }
+ -re "Hello \\( (\[0-9\]+) \\)\r\n" {
+ set n $expect_out(1,string)
+ if { $hello_last + 1 != $n } {
+ fail $test
+ } else {
+ set hello_last $n
+ if { $sleeping_last >= $minimal && $hello_last >= $minimal } {
+ pass $test
+ } else {
+ exp_continue
+ }
+ }
+ }
+}
diff --git a/gdb/testsuite/gdb.python/py-gil-mthread.py b/gdb/testsuite/gdb.python/py-gil-mthread.py
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-gil-mthread.py
@@ -0,0 +1,28 @@
+try:
+ import thread
+except:
+ import _thread
+import time
+import gdb
+
+# Define a function for the thread
+def print_thread_hello():
+ count = 0
+ while count < 10:
+ time.sleep(1)
+ count += 1
+ print ("Hello ( %d )" % count)
+
+# Create a threads a continue
+try:
+ thread.start_new_thread (print_thread_hello, ())
+ gdb.execute ("continue", release_gil=True)
+except:
+ try:
+ _thread.start_new_thread (print_thread_hello, ())
+ gdb.execute ("continue", release_gil=True)
+ except:
+ print ("Error: unable to start thread")
+
+while 1:
+ pass

View File

@ -9,7 +9,7 @@ Subject: gdb-readline62-ask-more-rh.patch
diff --git a/gdb/event-top.c b/gdb/event-top.c
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -1183,6 +1183,13 @@ gdb_setup_readline (int editing)
@@ -1179,6 +1179,13 @@ gdb_setup_readline (int editing)
{
struct ui *ui = current_ui;

View File

@ -1,65 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Thu, 9 Aug 2018 17:09:48 +0200
Subject: gdb-rhbz1187581-power8-regs-1of7.patch
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
commit 05abfc39c719e740530000059bb963ad33462479
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
Date: Mon Aug 6 16:24:55 2018 -0300
Fix indentation in remote_target::download_tracepoint
gdb/ChangeLog:
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* remote.c (remote_target::download_tracepoint): Fix indentation
in for block.
diff --git a/gdb/remote.c b/gdb/remote.c
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -12912,24 +12912,24 @@ remote_target::download_tracepoint (struct bp_location *loc)
error (_("Error on target while setting tracepoints."));
}
- for (auto action_it = stepping_actions.begin ();
- action_it != stepping_actions.end (); action_it++)
- {
- QUIT; /* Allow user to bail out with ^C. */
-
- bool is_first = action_it == stepping_actions.begin ();
- bool has_more = action_it != stepping_actions.end ();
-
- xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s",
- b->number, addrbuf, /* address */
- is_first ? "S" : "",
- action_it->c_str (),
- has_more ? "-" : "");
- putpkt (buf);
- remote_get_noisy_reply ();
- if (strcmp (rs->buf, "OK"))
- error (_("Error on target while setting tracepoints."));
- }
+ for (auto action_it = stepping_actions.begin ();
+ action_it != stepping_actions.end (); action_it++)
+ {
+ QUIT; /* Allow user to bail out with ^C. */
+
+ bool is_first = action_it == stepping_actions.begin ();
+ bool has_more = action_it != stepping_actions.end ();
+
+ xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s",
+ b->number, addrbuf, /* address */
+ is_first ? "S" : "",
+ action_it->c_str (),
+ has_more ? "-" : "");
+ putpkt (buf);
+ remote_get_noisy_reply ();
+ if (strcmp (rs->buf, "OK"))
+ error (_("Error on target while setting tracepoints."));
+ }
if (packet_support (PACKET_TracepointSource) == PACKET_ENABLE)
{

View File

@ -1,45 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Thu, 9 Aug 2018 17:10:46 +0200
Subject: gdb-rhbz1187581-power8-regs-2of7.patch
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
commit aa6f3694ce867884e43d1c0406c64df08ea24bd3
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
Date: Mon Aug 6 16:24:55 2018 -0300
Remove trailing '-' from the last QTDP action packet
The has_more predicate in remote_target::download_tracepoint always
evaluates to true, so the last action packet will be sent with a
trailing '-'. This patch changes the predicate to remove the last
trailing '-'.
gdb/ChangeLog:
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* remote.c (remote_target::download_tracepoint): Fix the has_more
predicate in the QTDP action list iteration.
diff --git a/gdb/remote.c b/gdb/remote.c
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -12899,7 +12899,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
{
QUIT; /* Allow user to bail out with ^C. */
- bool has_more = (action_it != tdp_actions.end ()
+ bool has_more = ((action_it + 1) != tdp_actions.end ()
|| !stepping_actions.empty ());
xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%c",
@@ -12918,7 +12918,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
QUIT; /* Allow user to bail out with ^C. */
bool is_first = action_it == stepping_actions.begin ();
- bool has_more = action_it != stepping_actions.end ();
+ bool has_more = (action_it + 1) != stepping_actions.end ();
xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s",
b->number, addrbuf, /* address */

View File

@ -1,258 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Thu, 9 Aug 2018 17:11:09 +0200
Subject: gdb-rhbz1187581-power8-regs-3of7.patch
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
commit 3df3a985a475db004706d64f83d9085f99053611
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
Date: Mon Aug 6 16:24:55 2018 -0300
Use get_remote_packet_size in download_tracepoint
This patch changes the remote target to use the remote packet size to
build QTDP packets, and to check if there is enough room for the
packet.
I changed the function to raise an error if the packet is too small,
instead of aborting gdb (through xsnprintf). It isn't clear if gdb
will be in a consistent state with respect to the stub after this,
since it's possible that some packets will be sent but not others, and
there could be an incomplete tracepoint on the stub.
The char array used to build the packets is changed to a
gdb::char_vector and sized with the result from
get_remote_packet_size.
When checking if the buffer is large enough to hold the tracepoint
condition agent expression, the length of the expression is multiplied
by two, since it is encoded with two hex digits per expression
byte. For simplicity, I assume that the result won't overflow, which
can happen for very long condition expressions.
gdb/ChangeLog:
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* remote.c (remote_target::download_tracepoint): Remove BUF_SIZE.
Replace array buf with gdb::char_vector buf, of size
get_remote_packet_size (). Replace references to buf and
BUF_SIZE to buf.data () and buf.size (). Replace strcpy, strcat
and xsnprintf with snprintf. Raise errors if the buffer is too
small.
diff --git a/gdb/remote.c b/gdb/remote.c
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -12799,26 +12799,35 @@ remote_target::remote_download_command_source (int num, ULONGEST addr,
void
remote_target::download_tracepoint (struct bp_location *loc)
{
-#define BUF_SIZE 2048
-
CORE_ADDR tpaddr;
char addrbuf[40];
- char buf[BUF_SIZE];
std::vector<std::string> tdp_actions;
std::vector<std::string> stepping_actions;
char *pkt;
struct breakpoint *b = loc->owner;
struct tracepoint *t = (struct tracepoint *) b;
struct remote_state *rs = get_remote_state ();
+ int ret;
+ char *err_msg = _("Tracepoint packet too large for target.");
+ size_t size_left;
+
+ /* We use a buffer other than rs->buf because we'll build strings
+ across multiple statements, and other statements in between could
+ modify rs->buf. */
+ gdb::char_vector buf (get_remote_packet_size ());
encode_actions_rsp (loc, &tdp_actions, &stepping_actions);
tpaddr = loc->address;
sprintf_vma (addrbuf, tpaddr);
- xsnprintf (buf, BUF_SIZE, "QTDP:%x:%s:%c:%lx:%x", b->number,
- addrbuf, /* address */
- (b->enable_state == bp_enabled ? 'E' : 'D'),
- t->step_count, t->pass_count);
+ ret = snprintf (buf.data (), buf.size (), "QTDP:%x:%s:%c:%lx:%x",
+ b->number, addrbuf, /* address */
+ (b->enable_state == bp_enabled ? 'E' : 'D'),
+ t->step_count, t->pass_count);
+
+ if (ret < 0 || ret >= buf.size ())
+ error (err_msg);
+
/* Fast tracepoints are mostly handled by the target, but we can
tell the target how big of an instruction block should be moved
around. */
@@ -12830,8 +12839,15 @@ remote_target::download_tracepoint (struct bp_location *loc)
{
if (gdbarch_fast_tracepoint_valid_at (loc->gdbarch, tpaddr,
NULL))
- xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":F%x",
- gdb_insn_length (loc->gdbarch, tpaddr));
+ {
+ size_left = buf.size () - strlen (buf.data ());
+ ret = snprintf (buf.data () + strlen (buf.data ()),
+ size_left, ":F%x",
+ gdb_insn_length (loc->gdbarch, tpaddr));
+
+ if (ret < 0 || ret >= size_left)
+ error (err_msg);
+ }
else
/* If it passed validation at definition but fails now,
something is very wrong. */
@@ -12855,7 +12871,14 @@ remote_target::download_tracepoint (struct bp_location *loc)
struct static_tracepoint_marker marker;
if (target_static_tracepoint_marker_at (tpaddr, &marker))
- strcat (buf, ":S");
+ {
+ size_left = buf.size () - strlen (buf.data ());
+ ret = snprintf (buf.data () + strlen (buf.data ()),
+ size_left, ":S");
+
+ if (ret < 0 || ret >= size_left)
+ error (err_msg);
+ }
else
error (_("Static tracepoint not valid during download"));
}
@@ -12873,10 +12896,26 @@ remote_target::download_tracepoint (struct bp_location *loc)
capabilities at definition time. */
if (remote_supports_cond_tracepoints ())
{
- agent_expr_up aexpr = gen_eval_for_expr (tpaddr, loc->cond.get ());
- xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":X%x,",
- aexpr->len);
- pkt = buf + strlen (buf);
+ agent_expr_up aexpr = gen_eval_for_expr (tpaddr,
+ loc->cond.get ());
+
+ size_left = buf.size () - strlen (buf.data ());
+
+ ret = snprintf (buf.data () + strlen (buf.data ()),
+ size_left, ":X%x,", aexpr->len);
+
+ if (ret < 0 || ret >= size_left)
+ error (err_msg);
+
+ size_left = buf.size () - strlen (buf.data ());
+
+ /* Two bytes to encode each aexpr byte, plus the terminating
+ null byte. */
+ if (aexpr->len * 2 + 1 > size_left)
+ error (err_msg);
+
+ pkt = buf.data () + strlen (buf.data ());
+
for (int ndx = 0; ndx < aexpr->len; ++ndx)
pkt = pack_hex_byte (pkt, aexpr->buf[ndx]);
*pkt = '\0';
@@ -12887,8 +12926,17 @@ remote_target::download_tracepoint (struct bp_location *loc)
}
if (b->commands || *default_collect)
- strcat (buf, "-");
- putpkt (buf);
+ {
+ size_left = buf.size () - strlen (buf.data ());
+
+ ret = snprintf (buf.data () + strlen (buf.data ()),
+ size_left, "-");
+
+ if (ret < 0 || ret >= size_left)
+ error (err_msg);
+ }
+
+ putpkt (buf.data ());
remote_get_noisy_reply ();
if (strcmp (rs->buf, "OK"))
error (_("Target does not support tracepoints."));
@@ -12902,11 +12950,15 @@ remote_target::download_tracepoint (struct bp_location *loc)
bool has_more = ((action_it + 1) != tdp_actions.end ()
|| !stepping_actions.empty ());
- xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%c",
- b->number, addrbuf, /* address */
- action_it->c_str (),
- has_more ? '-' : 0);
- putpkt (buf);
+ ret = snprintf (buf.data (), buf.size (), "QTDP:-%x:%s:%s%c",
+ b->number, addrbuf, /* address */
+ action_it->c_str (),
+ has_more ? '-' : 0);
+
+ if (ret < 0 || ret >= buf.size ())
+ error (err_msg);
+
+ putpkt (buf.data ());
remote_get_noisy_reply ();
if (strcmp (rs->buf, "OK"))
error (_("Error on target while setting tracepoints."));
@@ -12920,12 +12972,16 @@ remote_target::download_tracepoint (struct bp_location *loc)
bool is_first = action_it == stepping_actions.begin ();
bool has_more = (action_it + 1) != stepping_actions.end ();
- xsnprintf (buf, BUF_SIZE, "QTDP:-%x:%s:%s%s%s",
- b->number, addrbuf, /* address */
- is_first ? "S" : "",
- action_it->c_str (),
- has_more ? "-" : "");
- putpkt (buf);
+ ret = snprintf (buf.data (), buf.size (), "QTDP:-%x:%s:%s%s%s",
+ b->number, addrbuf, /* address */
+ is_first ? "S" : "",
+ action_it->c_str (),
+ has_more ? "-" : "");
+
+ if (ret < 0 || ret >= buf.size ())
+ error (err_msg);
+
+ putpkt (buf.data ());
remote_get_noisy_reply ();
if (strcmp (rs->buf, "OK"))
error (_("Error on target while setting tracepoints."));
@@ -12935,22 +12991,32 @@ remote_target::download_tracepoint (struct bp_location *loc)
{
if (b->location != NULL)
{
- strcpy (buf, "QTDPsrc:");
+ ret = snprintf (buf.data (), buf.size (), "QTDPsrc:");
+
+ if (ret < 0 || ret >= buf.size ())
+ error (err_msg);
+
encode_source_string (b->number, loc->address, "at",
event_location_to_string (b->location.get ()),
- buf + strlen (buf), 2048 - strlen (buf));
- putpkt (buf);
+ buf.data () + strlen (buf.data ()),
+ buf.size () - strlen (buf.data ()));
+ putpkt (buf.data ());
remote_get_noisy_reply ();
if (strcmp (rs->buf, "OK"))
warning (_("Target does not support source download."));
}
if (b->cond_string)
{
- strcpy (buf, "QTDPsrc:");
+ ret = snprintf (buf.data (), buf.size (), "QTDPsrc:");
+
+ if (ret < 0 || ret >= buf.size ())
+ error (err_msg);
+
encode_source_string (b->number, loc->address,
- "cond", b->cond_string, buf + strlen (buf),
- 2048 - strlen (buf));
- putpkt (buf);
+ "cond", b->cond_string,
+ buf.data () + strlen (buf.data ()),
+ buf.size () - strlen (buf.data ()));
+ putpkt (buf.data ());
remote_get_noisy_reply ();
if (strcmp (rs->buf, "OK"))
warning (_("Target does not support source download."));

View File

@ -1,449 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Thu, 9 Aug 2018 17:17:16 +0200
Subject: gdb-rhbz1187581-power8-regs-4of7.patch
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
commit 4277c4b87addb5354cc47b98d7a73e44cfaf22c2
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
Date: Mon Aug 6 16:24:55 2018 -0300
Use remote register numbers in tracepoint mask
Currently, tracepoint register masks in the QTDP packets include both
internal and remote register numbers, as well as pseudo-register
numbers.
This patch changes this so that the mask only includes remote register
numbers.
Register numbers from agent expressions are already set in the mask
using remote numbers. Other tracepoint actions used internal numbers,
e.g. "collect $regs" or "collect $<pseudoreg>". To handle pseudoreg
numbers, an empty agent expression is created and ax_reg_mask is
called for this expression and the pseudoreg. This will cause the ax
to set its mask with the corresponding remote raw register
numbers (using ax_regs_mask, which calls
gdbarch_ax_pseudo_register_collect).
If ax_regs_mask and gdbarch_ax_pseudo_register_collect also generate
more ax bytecode, the ax is also appended to the collection list. It
isn't clear that this was the original intent for
gdbarch_ax_pseudo_register_collect, and none of the arches seem to do
this, but if this changes in the future, it should work.
The patch also refactors the code used by validate_action line to
validate axs into a function that is now called from every place that
generates axs. Previously, some parts of tracepoint.c that generated
axs didn't check if the ax length was greater than MAX_AGENT_EXPR_LEN.
gdb/ChangeLog:
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* tracepoint.h (class collection_list) <add_register>: Remove.
<add_remote_register, add_ax_registers, add_local_register>:
Declare.
<add_memrange>: Add scope parameter.
* tracepoint.c (encode_actions_1): Likewise.
(collection_list::add_register): Rename to ...
(collection_list::add_remote_register): ... this. Update
comment.
(collection_list::add_ax_registers, add_local_register): New
methods.
(collection_list::add_memrange): Add scope parameter. Call
add_local_register instead of add_register.
(finalize_tracepoint_aexpr): New function.
(collection_list::collect_symbol): Update calls to add_memrange.
Call add_local_register instead of add_register. Call
add_ax_registers. Call finalize_tracepoint_aexpr.
(encode_actions_1): Get remote regnos for $reg action. Call
add_remote_register, add_ax_registers, and add_local_register.
Update call to add_memrange. Call finalize_tracepoint_aexpr.
(validate_actionline): Call finalize_tracepoint_aexpr.
+2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
+
+ * tracepoint.h (class collection_list) <add_register>: Remove.
+ <add_remote_register, add_ax_registers, add_local_register>:
+ Declare.
+ <add_memrange>: Add scope parameter.
+ * tracepoint.c (encode_actions_1): Likewise.
+ (collection_list::add_register): Rename to ...
+ (collection_list::add_remote_register): ... this. Update
+ comment.
+ (collection_list::add_ax_registers, add_local_register): New
+ methods.
+ (collection_list::add_memrange): Add scope parameter. Call
+ add_local_register instead of add_register.
+ (finalize_tracepoint_aexpr): New function.
+ (collection_list::collect_symbol): Update calls to add_memrange.
+ Call add_local_register instead of add_register. Call
+ add_ax_registers. Call finalize_tracepoint_aexpr.
+ (encode_actions_1): Get remote regnos for $reg action. Call
+ add_remote_register, add_ax_registers, and add_local_register.
+ Update call to add_memrange. Call finalize_tracepoint_aexpr.
+ (validate_actionline): Call finalize_tracepoint_aexpr.
+
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* remote.c (remote_target::download_tracepoint): Remove BUF_SIZE.
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -615,6 +615,19 @@ report_agent_reqs_errors (struct agent_expr *aexpr)
error (_("Expression is too complicated."));
}
+/* Call ax_reqs on AEXPR and raise an error if something is wrong. */
+
+static void
+finalize_tracepoint_aexpr (struct agent_expr *aexpr)
+{
+ ax_reqs (aexpr);
+
+ if (aexpr->len > MAX_AGENT_EXPR_LEN)
+ error (_("Expression is too complicated."));
+
+ report_agent_reqs_errors (aexpr);
+}
+
/* worker function */
void
validate_actionline (const char *line, struct breakpoint *b)
@@ -699,12 +712,7 @@ validate_actionline (const char *line, struct breakpoint *b)
exp.get (),
trace_string);
- if (aexpr->len > MAX_AGENT_EXPR_LEN)
- error (_("Expression is too complicated."));
-
- ax_reqs (aexpr.get ());
-
- report_agent_reqs_errors (aexpr.get ());
+ finalize_tracepoint_aexpr (aexpr.get ());
}
}
while (p && *p++ == ',');
@@ -731,11 +739,7 @@ validate_actionline (const char *line, struct breakpoint *b)
long. */
agent_expr_up aexpr = gen_eval_for_expr (loc->address, exp.get ());
- if (aexpr->len > MAX_AGENT_EXPR_LEN)
- error (_("Expression is too complicated."));
-
- ax_reqs (aexpr.get ());
- report_agent_reqs_errors (aexpr.get ());
+ finalize_tracepoint_aexpr (aexpr.get ());
}
}
while (p && *p++ == ',');
@@ -811,10 +815,10 @@ memrange_sortmerge (std::vector<memrange> &memranges)
}
}
-/* Add a register to a collection list. */
+/* Add remote register number REGNO to the collection list mask. */
void
-collection_list::add_register (unsigned int regno)
+collection_list::add_remote_register (unsigned int regno)
{
if (info_verbose)
printf_filtered ("collect register %d\n", regno);
@@ -824,12 +828,74 @@ collection_list::add_register (unsigned int regno)
m_regs_mask[regno / 8] |= 1 << (regno % 8);
}
+/* Add all the registers from the mask in AEXPR to the mask in the
+ collection list. Registers in the AEXPR mask are already remote
+ register numbers. */
+
+void
+collection_list::add_ax_registers (struct agent_expr *aexpr)
+{
+ if (aexpr->reg_mask_len > 0)
+ {
+ for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
+ {
+ QUIT; /* Allow user to bail out with ^C. */
+ if (aexpr->reg_mask[ndx1] != 0)
+ {
+ /* Assume chars have 8 bits. */
+ for (int ndx2 = 0; ndx2 < 8; ndx2++)
+ if (aexpr->reg_mask[ndx1] & (1 << ndx2))
+ /* It's used -- record it. */
+ add_remote_register (ndx1 * 8 + ndx2);
+ }
+ }
+ }
+}
+
+/* If REGNO is raw, add its corresponding remote register number to
+ the mask. If REGNO is a pseudo-register, figure out the necessary
+ registers using a temporary agent expression, and add it to the
+ list if it needs more than just a mask. */
+
+void
+collection_list::add_local_register (struct gdbarch *gdbarch,
+ unsigned int regno,
+ CORE_ADDR scope)
+{
+ if (regno < gdbarch_num_regs (gdbarch))
+ {
+ int remote_regno = gdbarch_remote_register_number (gdbarch, regno);
+
+ if (remote_regno < 0)
+ error (_("Can't collect register %d"), regno);
+
+ add_remote_register (remote_regno);
+ }
+ else
+ {
+ agent_expr_up aexpr (new agent_expr (gdbarch, scope));
+
+ ax_reg_mask (aexpr.get (), regno);
+
+ finalize_tracepoint_aexpr (aexpr.get ());
+
+ add_ax_registers (aexpr.get ());
+
+ /* Usually ax_reg_mask for a pseudo-regiser only sets the
+ corresponding raw registers in the ax mask, but if this isn't
+ the case add the expression that is generated to the
+ collection list. */
+ if (aexpr->len > 0)
+ add_aexpr (std::move (aexpr));
+ }
+}
+
/* Add a memrange to a collection list. */
void
collection_list::add_memrange (struct gdbarch *gdbarch,
int type, bfd_signed_vma base,
- ULONGEST len)
+ ULONGEST len, CORE_ADDR scope)
{
if (info_verbose)
printf_filtered ("(%d,%s,%s)\n", type, paddress (gdbarch, base), pulongest (len));
@@ -840,7 +906,7 @@ collection_list::add_memrange (struct gdbarch *gdbarch,
m_memranges.emplace_back (type, base, base + len);
if (type != memrange_absolute) /* Better collect the base register! */
- add_register (type);
+ add_local_register (gdbarch, type, scope);
}
/* Add a symbol to a collection list. */
@@ -882,19 +948,19 @@ collection_list::collect_symbol (struct symbol *sym,
if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
treat_as_expr = 1;
else
- add_memrange (gdbarch, memrange_absolute, offset, len);
+ add_memrange (gdbarch, memrange_absolute, offset, len, scope);
break;
case LOC_REGISTER:
reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
if (info_verbose)
printf_filtered ("LOC_REG[parm] %s: ",
SYMBOL_PRINT_NAME (sym));
- add_register (reg);
+ add_local_register (gdbarch, reg, scope);
/* Check for doubles stored in two registers. */
/* FIXME: how about larger types stored in 3 or more regs? */
if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FLT &&
len > register_size (gdbarch, reg))
- add_register (reg + 1);
+ add_local_register (gdbarch, reg + 1, scope);
break;
case LOC_REF_ARG:
printf_filtered ("Sorry, don't know how to do LOC_REF_ARG yet.\n");
@@ -911,7 +977,7 @@ collection_list::collect_symbol (struct symbol *sym,
SYMBOL_PRINT_NAME (sym), pulongest (len),
paddress (gdbarch, offset), reg);
}
- add_memrange (gdbarch, reg, offset, len);
+ add_memrange (gdbarch, reg, offset, len, scope);
break;
case LOC_REGPARM_ADDR:
reg = SYMBOL_VALUE (sym);
@@ -923,7 +989,7 @@ collection_list::collect_symbol (struct symbol *sym,
SYMBOL_PRINT_NAME (sym), pulongest (len),
paddress (gdbarch, offset), reg);
}
- add_memrange (gdbarch, reg, offset, len);
+ add_memrange (gdbarch, reg, offset, len, scope);
break;
case LOC_LOCAL:
reg = frame_regno;
@@ -935,7 +1001,7 @@ collection_list::collect_symbol (struct symbol *sym,
SYMBOL_PRINT_NAME (sym), pulongest (len),
paddress (gdbarch, offset), reg);
}
- add_memrange (gdbarch, reg, offset, len);
+ add_memrange (gdbarch, reg, offset, len, scope);
break;
case LOC_UNRESOLVED:
@@ -968,26 +1034,10 @@ collection_list::collect_symbol (struct symbol *sym,
return;
}
- ax_reqs (aexpr.get ());
-
- report_agent_reqs_errors (aexpr.get ());
+ finalize_tracepoint_aexpr (aexpr.get ());
/* Take care of the registers. */
- if (aexpr->reg_mask_len > 0)
- {
- for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
- {
- QUIT; /* Allow user to bail out with ^C. */
- if (aexpr->reg_mask[ndx1] != 0)
- {
- /* Assume chars have 8 bits. */
- for (int ndx2 = 0; ndx2 < 8; ndx2++)
- if (aexpr->reg_mask[ndx1] & (1 << ndx2))
- /* It's used -- record it. */
- add_register (ndx1 * 8 + ndx2);
- }
- }
- }
+ add_ax_registers (aexpr.get ());
add_aexpr (std::move (aexpr));
}
@@ -1257,8 +1307,18 @@ encode_actions_1 (struct command_line *action,
if (0 == strncasecmp ("$reg", action_exp, 4))
{
- for (i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++)
- collect->add_register (i);
+ for (i = 0; i < gdbarch_num_regs (target_gdbarch ());
+ i++)
+ {
+ int remote_regno = (gdbarch_remote_register_number
+ (target_gdbarch (), i));
+
+ /* Ignore arch regnos without a corresponding
+ remote regno. This can happen for regnos not
+ in the tdesc. */
+ if (remote_regno >= 0)
+ collect->add_remote_register (remote_regno);
+ }
action_exp = strchr (action_exp, ','); /* more? */
}
else if (0 == strncasecmp ("$arg", action_exp, 4))
@@ -1288,27 +1348,10 @@ encode_actions_1 (struct command_line *action,
target_gdbarch (),
trace_string);
- ax_reqs (aexpr.get ());
- report_agent_reqs_errors (aexpr.get ());
+ finalize_tracepoint_aexpr (aexpr.get ());
/* take care of the registers */
- if (aexpr->reg_mask_len > 0)
- {
- for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
- {
- QUIT; /* allow user to bail out with ^C */
- if (aexpr->reg_mask[ndx1] != 0)
- {
- /* assume chars have 8 bits */
- for (int ndx2 = 0; ndx2 < 8; ndx2++)
- if (aexpr->reg_mask[ndx1] & (1 << ndx2))
- {
- /* It's used -- record it. */
- collect->add_register (ndx1 * 8 + ndx2);
- }
- }
- }
- }
+ collect->add_ax_registers (aexpr.get ());
collect->add_aexpr (std::move (aexpr));
action_exp = strchr (action_exp, ','); /* more? */
@@ -1340,7 +1383,8 @@ encode_actions_1 (struct command_line *action,
name);
if (info_verbose)
printf_filtered ("OP_REGISTER: ");
- collect->add_register (i);
+ collect->add_local_register (target_gdbarch (),
+ i, tloc->address);
break;
}
@@ -1352,7 +1396,8 @@ encode_actions_1 (struct command_line *action,
check_typedef (exp->elts[1].type);
collect->add_memrange (target_gdbarch (),
memrange_absolute, addr,
- TYPE_LENGTH (exp->elts[1].type));
+ TYPE_LENGTH (exp->elts[1].type),
+ tloc->address);
collect->append_exp (exp.get ());
break;
@@ -1376,28 +1421,10 @@ encode_actions_1 (struct command_line *action,
exp.get (),
trace_string);
- ax_reqs (aexpr.get ());
-
- report_agent_reqs_errors (aexpr.get ());
+ finalize_tracepoint_aexpr (aexpr.get ());
/* Take care of the registers. */
- if (aexpr->reg_mask_len > 0)
- {
- for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
- {
- QUIT; /* Allow user to bail out with ^C. */
- if (aexpr->reg_mask[ndx1] != 0)
- {
- /* Assume chars have 8 bits. */
- for (int ndx2 = 0; ndx2 < 8; ndx2++)
- if (aexpr->reg_mask[ndx1] & (1 << ndx2))
- {
- /* It's used -- record it. */
- collect->add_register (ndx1 * 8 + ndx2);
- }
- }
- }
- }
+ collect->add_ax_registers (aexpr.get ());
collect->add_aexpr (std::move (aexpr));
collect->append_exp (exp.get ());
@@ -1422,8 +1449,7 @@ encode_actions_1 (struct command_line *action,
agent_expr_up aexpr = gen_eval_for_expr (tloc->address,
exp.get ());
- ax_reqs (aexpr.get ());
- report_agent_reqs_errors (aexpr.get ());
+ finalize_tracepoint_aexpr (aexpr.get ());
/* Even though we're not officially collecting, add
to the collect list anyway. */
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -263,9 +263,14 @@ public:
void add_aexpr (agent_expr_up aexpr);
void add_register (unsigned int regno);
+ void add_remote_register (unsigned int regno);
+ void add_ax_registers (struct agent_expr *aexpr);
+ void add_local_register (struct gdbarch *gdbarch,
+ unsigned int regno,
+ CORE_ADDR scope);
void add_memrange (struct gdbarch *gdbarch,
int type, bfd_signed_vma base,
- ULONGEST len);
+ ULONGEST len, CORE_ADDR scope);
void collect_symbol (struct symbol *sym,
struct gdbarch *gdbarch,
long frame_regno, long frame_offset,

View File

@ -1,215 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Thu, 9 Aug 2018 17:17:46 +0200
Subject: gdb-rhbz1187581-power8-regs-5of7.patch
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
commit a04b9d62a234923826e431a209d396a628661548
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
Date: Mon Aug 6 16:24:55 2018 -0300
Variable size for regs mask in collection list
This patch changes collection_list to allow larger register masks.
The mask is changed from an array to a vector and is initialized to
hold the maximum possible remote register number. The stringify
method is updated to resize temp_buf if needed.
gdb/ChangeLog:
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* tracepoint.h (collection_list) <m_regs_mask>: Change type to
std::vector<unsigned char>.
* tracepoint.c (collection_list::collection_list): Remove
m_regs_mask initializer from initializer list. Resize
m_regs_mask using the largest remote register number.
(collection_list::add_remote_register): Remove size check on
m_regs_mask. Use at to access element.
(collection_list::stringify): Change type of temp_buf to
gdb::char_vector. Update uses of temp_buf. Resize if needed to
stringify the register mask. Use pack_hex_byte for the register
mask.
+2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
+
+ * tracepoint.h (collection_list) <m_regs_mask>: Change type to
+ std::vector<unsigned char>.
+ * tracepoint.c (collection_list::collection_list): Remove
+ m_regs_mask initializer from initializer list. Resize
+ m_regs_mask using the largest remote register number.
+ (collection_list::add_remote_register): Remove size check on
+ m_regs_mask. Use at to access element.
+ (collection_list::stringify): Change type of temp_buf to
+ gdb::char_vector. Update uses of temp_buf. Resize if needed to
+ stringify the register mask. Use pack_hex_byte for the register
+ mask.
+
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* tracepoint.h (class collection_list) <add_register>: Remove.
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -822,10 +822,8 @@ collection_list::add_remote_register (unsigned int regno)
{
if (info_verbose)
printf_filtered ("collect register %d\n", regno);
- if (regno >= (8 * sizeof (m_regs_mask)))
- error (_("Internal: register number %d too large for tracepoint"),
- regno);
- m_regs_mask[regno / 8] |= 1 << (regno % 8);
+
+ m_regs_mask.at (regno / 8) |= 1 << (regno % 8);
}
/* Add all the registers from the mask in AEXPR to the mask in the
@@ -1136,9 +1134,20 @@ collection_list::add_static_trace_data ()
}
collection_list::collection_list ()
- : m_regs_mask (),
- m_strace_data (false)
+ : m_strace_data (false)
{
+ int max_remote_regno = 0;
+ for (int i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++)
+ {
+ int remote_regno = (gdbarch_remote_register_number
+ (target_gdbarch (), i));
+
+ if (remote_regno >= 0 && remote_regno > max_remote_regno)
+ max_remote_regno = remote_regno;
+ }
+
+ m_regs_mask.resize ((max_remote_regno / 8) + 1);
+
m_memranges.reserve (128);
m_aexprs.reserve (128);
}
@@ -1148,7 +1157,8 @@ collection_list::collection_list ()
std::vector<std::string>
collection_list::stringify ()
{
- char temp_buf[2048];
+ gdb::char_vector temp_buf (2048);
+
int count;
char *end;
long i;
@@ -1158,35 +1168,45 @@ collection_list::stringify ()
{
if (info_verbose)
printf_filtered ("\nCollecting static trace data\n");
- end = temp_buf;
+ end = temp_buf.data ();
*end++ = 'L';
- str_list.emplace_back (temp_buf, end - temp_buf);
+ str_list.emplace_back (temp_buf.data (), end - temp_buf.data ());
}
- for (i = sizeof (m_regs_mask) - 1; i > 0; i--)
+ for (i = m_regs_mask.size () - 1; i > 0; i--)
if (m_regs_mask[i] != 0) /* Skip leading zeroes in regs_mask. */
break;
if (m_regs_mask[i] != 0) /* Prepare to send regs_mask to the stub. */
{
if (info_verbose)
printf_filtered ("\nCollecting registers (mask): 0x");
- end = temp_buf;
+
+ /* One char for 'R', one for the null terminator and two per
+ mask byte. */
+ std::size_t new_size = (i + 1) * 2 + 2;
+ if (new_size > temp_buf.size ())
+ temp_buf.resize (new_size);
+
+ end = temp_buf.data ();
*end++ = 'R';
for (; i >= 0; i--)
{
QUIT; /* Allow user to bail out with ^C. */
if (info_verbose)
printf_filtered ("%02X", m_regs_mask[i]);
- sprintf (end, "%02X", m_regs_mask[i]);
- end += 2;
+
+ end = pack_hex_byte (end, m_regs_mask[i]);
}
- str_list.emplace_back (temp_buf);
+ *end = '\0';
+
+ str_list.emplace_back (temp_buf.data ());
}
if (info_verbose)
printf_filtered ("\n");
if (!m_memranges.empty () && info_verbose)
printf_filtered ("Collecting memranges: \n");
- for (i = 0, count = 0, end = temp_buf; i < m_memranges.size (); i++)
+ for (i = 0, count = 0, end = temp_buf.data ();
+ i < m_memranges.size (); i++)
{
QUIT; /* Allow user to bail out with ^C. */
if (info_verbose)
@@ -1200,9 +1220,9 @@ collection_list::stringify ()
}
if (count + 27 > MAX_AGENT_EXPR_LEN)
{
- str_list.emplace_back (temp_buf, count);
+ str_list.emplace_back (temp_buf.data (), count);
count = 0;
- end = temp_buf;
+ end = temp_buf.data ();
}
{
@@ -1222,7 +1242,7 @@ collection_list::stringify ()
}
count += strlen (end);
- end = temp_buf + count;
+ end = temp_buf.data () + count;
}
for (i = 0; i < m_aexprs.size (); i++)
@@ -1230,9 +1250,9 @@ collection_list::stringify ()
QUIT; /* Allow user to bail out with ^C. */
if ((count + 10 + 2 * m_aexprs[i]->len) > MAX_AGENT_EXPR_LEN)
{
- str_list.emplace_back (temp_buf, count);
+ str_list.emplace_back (temp_buf.data (), count);
count = 0;
- end = temp_buf;
+ end = temp_buf.data ();
}
sprintf (end, "X%08X,", m_aexprs[i]->len);
end += 10; /* 'X' + 8 hex digits + ',' */
@@ -1244,9 +1264,9 @@ collection_list::stringify ()
if (count != 0)
{
- str_list.emplace_back (temp_buf, count);
+ str_list.emplace_back (temp_buf.data (), count);
count = 0;
- end = temp_buf;
+ end = temp_buf.data ();
}
return str_list;
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -293,8 +293,9 @@ public:
{ return m_computed; }
private:
- /* room for up to 256 regs */
- unsigned char m_regs_mask[32];
+ /* We need the allocator zero-initialize the mask, so we don't use
+ gdb::byte_vector. */
+ std::vector<unsigned char> m_regs_mask;
std::vector<memrange> m_memranges;

View File

@ -1,187 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Thu, 9 Aug 2018 17:18:15 +0200
Subject: gdb-rhbz1187581-power8-regs-6of7.patch
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
commit 296956befef3711ed458c7cba8041fde0dab9c50
Author: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
Date: Mon Aug 6 16:24:55 2018 -0300
Allow larger regblock sizes when saving tracefiles
The tracefile.c:trace_save function assumes trace_regblock_size won't
be larger than the MAX_TRACE_UPLOAD constant, used to size the buffer
which holds trace data. This can cause buffer overruns when this is
not the case. This patch changes this function so that the larger
size is used to size the buffer.
gdb/ChangeLog:
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* tracefile.c: Include common/byte-vector.h.
(trace_save): Change type of buf to gdb::byte_vector. Initialize
with trace_regblock_size if needed. Update uses of buf.
+2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
+
+ * tracefile.c: Include common/byte-vector.h.
+ (trace_save): Change type of buf to gdb::byte_vector. Initialize
+ with trace_regblock_size if needed. Update uses of buf.
+
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* tracepoint.h (collection_list) <m_regs_mask>: Change type to
diff --git a/gdb/tracefile.c b/gdb/tracefile.c
--- a/gdb/tracefile.c
+++ b/gdb/tracefile.c
@@ -22,6 +22,7 @@
#include "ctf.h"
#include "exec.h"
#include "regcache.h"
+#include "common/byte-vector.h"
/* Helper macros. */
@@ -67,7 +68,7 @@ trace_save (const char *filename, struct trace_file_writer *writer,
ULONGEST offset = 0;
#define MAX_TRACE_UPLOAD 2000
- gdb_byte buf[MAX_TRACE_UPLOAD];
+ gdb::byte_vector buf (std::max (MAX_TRACE_UPLOAD, trace_regblock_size));
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
/* If the target is to save the data to a file on its own, then just
@@ -144,7 +145,7 @@ trace_save (const char *filename, struct trace_file_writer *writer,
/* We ask for big blocks, in the hopes of efficiency, but
will take less if the target has packet size limitations
or some such. */
- gotten = target_get_raw_trace_data (buf, offset,
+ gotten = target_get_raw_trace_data (buf.data (), offset,
MAX_TRACE_UPLOAD);
if (gotten < 0)
error (_("Failure to get requested trace buffer data"));
@@ -152,7 +153,7 @@ trace_save (const char *filename, struct trace_file_writer *writer,
if (gotten == 0)
break;
- writer->ops->write_trace_buffer (writer, buf, gotten);
+ writer->ops->write_trace_buffer (writer, buf.data (), gotten);
offset += gotten;
}
@@ -163,7 +164,7 @@ trace_save (const char *filename, struct trace_file_writer *writer,
/* Parse the trace buffers according to how data are stored
in trace buffer in GDBserver. */
- gotten = target_get_raw_trace_data (buf, offset, 6);
+ gotten = target_get_raw_trace_data (buf.data (), offset, 6);
if (gotten == 0)
break;
@@ -171,10 +172,10 @@ trace_save (const char *filename, struct trace_file_writer *writer,
/* Read the first six bytes in, which is the tracepoint
number and trace frame size. */
tp_num = (uint16_t)
- extract_unsigned_integer (&buf[0], 2, byte_order);
+ extract_unsigned_integer (&((buf.data ())[0]), 2, byte_order);
tf_size = (uint32_t)
- extract_unsigned_integer (&buf[2], 4, byte_order);
+ extract_unsigned_integer (&((buf.data ())[2]), 4, byte_order);
writer->ops->frame_ops->start (writer, tp_num);
gotten = 6;
@@ -192,7 +193,8 @@ trace_save (const char *filename, struct trace_file_writer *writer,
/* We'll fetch one block each time, in order to
handle the extremely large 'M' block. We first
fetch one byte to get the type of the block. */
- gotten = target_get_raw_trace_data (buf, offset, 1);
+ gotten = target_get_raw_trace_data (buf.data (),
+ offset, 1);
if (gotten < 1)
error (_("Failure to get requested trace buffer data"));
@@ -205,13 +207,13 @@ trace_save (const char *filename, struct trace_file_writer *writer,
{
case 'R':
gotten
- = target_get_raw_trace_data (buf, offset,
+ = target_get_raw_trace_data (buf.data (), offset,
trace_regblock_size);
if (gotten < trace_regblock_size)
error (_("Failure to get requested trace"
" buffer data"));
- TRACE_WRITE_R_BLOCK (writer, buf,
+ TRACE_WRITE_R_BLOCK (writer, buf.data (),
trace_regblock_size);
break;
case 'M':
@@ -221,7 +223,8 @@ trace_save (const char *filename, struct trace_file_writer *writer,
LONGEST t;
int j;
- t = target_get_raw_trace_data (buf,offset, 10);
+ t = target_get_raw_trace_data (buf.data (),
+ offset, 10);
if (t < 10)
error (_("Failure to get requested trace"
" buffer data"));
@@ -231,10 +234,10 @@ trace_save (const char *filename, struct trace_file_writer *writer,
gotten = 0;
addr = (ULONGEST)
- extract_unsigned_integer (buf, 8,
+ extract_unsigned_integer (buf.data (), 8,
byte_order);
mlen = (unsigned short)
- extract_unsigned_integer (&buf[8], 2,
+ extract_unsigned_integer (&((buf.data ())[8]), 2,
byte_order);
TRACE_WRITE_M_BLOCK_HEADER (writer, addr,
@@ -252,14 +255,15 @@ trace_save (const char *filename, struct trace_file_writer *writer,
else
read_length = mlen - j;
- t = target_get_raw_trace_data (buf,
+ t = target_get_raw_trace_data (buf.data (),
offset + j,
read_length);
if (t < read_length)
error (_("Failure to get requested"
" trace buffer data"));
- TRACE_WRITE_M_BLOCK_MEMORY (writer, buf,
+ TRACE_WRITE_M_BLOCK_MEMORY (writer,
+ buf.data (),
read_length);
j += read_length;
@@ -274,18 +278,18 @@ trace_save (const char *filename, struct trace_file_writer *writer,
LONGEST val;
gotten
- = target_get_raw_trace_data (buf, offset,
- 12);
+ = target_get_raw_trace_data (buf.data (),
+ offset, 12);
if (gotten < 12)
error (_("Failure to get requested"
" trace buffer data"));
- vnum = (int) extract_signed_integer (buf,
+ vnum = (int) extract_signed_integer (buf.data (),
4,
byte_order);
val
- = extract_signed_integer (&buf[4], 8,
- byte_order);
+ = extract_signed_integer (&((buf.data ())[4]),
+ 8, byte_order);
TRACE_WRITE_V_BLOCK (writer, vnum, val);
}

View File

@ -1,129 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Thu, 9 Aug 2018 17:18:49 +0200
Subject: gdb-rhbz1187581-power8-regs-7of7.patch
;; Add GDB support to access/display POWER8 registers (IBM, RH BZ 1187581).
commit a7f25a84f4cc1df5248c46346337f19a2a66af5a
Author: Simon Marchi <simon.marchi@ericsson.com>
Date: Mon Aug 6 16:54:47 2018 -0400
Fix compilation failure in remote.c
A recent patch introduced a few of these:
/home/emaisin/src/binutils-gdb/gdb/remote.c:12862:19: error: format not a string literal and no format arguments [-Werror=format-security]
error (err_msg);
^
Fix them by replacing the call to error with
error ("%s", err_msg);
gdb/ChangeLog:
* remote.c (remote_target::download_tracepoint): Fix format
string errors.
+2018-08-06 Simon Marchi <simon.marchi@ericsson.com>
+
+ * remote.c (remote_target::download_tracepoint): Fix format
+ string errors.
+
2018-08-06 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* tracefile.c: Include common/byte-vector.h.
diff --git a/gdb/remote.c b/gdb/remote.c
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -12826,7 +12826,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
t->step_count, t->pass_count);
if (ret < 0 || ret >= buf.size ())
- error (err_msg);
+ error ("%s", err_msg);
/* Fast tracepoints are mostly handled by the target, but we can
tell the target how big of an instruction block should be moved
@@ -12846,7 +12846,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
gdb_insn_length (loc->gdbarch, tpaddr));
if (ret < 0 || ret >= size_left)
- error (err_msg);
+ error ("%s", err_msg);
}
else
/* If it passed validation at definition but fails now,
@@ -12877,7 +12877,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
size_left, ":S");
if (ret < 0 || ret >= size_left)
- error (err_msg);
+ error ("%s", err_msg);
}
else
error (_("Static tracepoint not valid during download"));
@@ -12905,14 +12905,14 @@ remote_target::download_tracepoint (struct bp_location *loc)
size_left, ":X%x,", aexpr->len);
if (ret < 0 || ret >= size_left)
- error (err_msg);
+ error ("%s", err_msg);
size_left = buf.size () - strlen (buf.data ());
/* Two bytes to encode each aexpr byte, plus the terminating
null byte. */
if (aexpr->len * 2 + 1 > size_left)
- error (err_msg);
+ error ("%s", err_msg);
pkt = buf.data () + strlen (buf.data ());
@@ -12933,7 +12933,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
size_left, "-");
if (ret < 0 || ret >= size_left)
- error (err_msg);
+ error ("%s", err_msg);
}
putpkt (buf.data ());
@@ -12956,7 +12956,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
has_more ? '-' : 0);
if (ret < 0 || ret >= buf.size ())
- error (err_msg);
+ error ("%s", err_msg);
putpkt (buf.data ());
remote_get_noisy_reply ();
@@ -12979,7 +12979,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
has_more ? "-" : "");
if (ret < 0 || ret >= buf.size ())
- error (err_msg);
+ error ("%s", err_msg);
putpkt (buf.data ());
remote_get_noisy_reply ();
@@ -12994,7 +12994,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
ret = snprintf (buf.data (), buf.size (), "QTDPsrc:");
if (ret < 0 || ret >= buf.size ())
- error (err_msg);
+ error ("%s", err_msg);
encode_source_string (b->number, loc->address, "at",
event_location_to_string (b->location.get ()),
@@ -13010,7 +13010,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
ret = snprintf (buf.data (), buf.size (), "QTDPsrc:");
if (ret < 0 || ret >= buf.size ())
- error (err_msg);
+ error ("%s", err_msg);
encode_source_string (b->number, loc->address,
"cond", b->cond_string,

View File

@ -0,0 +1,461 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Tue, 23 Apr 2019 18:17:57 -0400
Subject: gdb-rhbz1371380-gcore-elf-headers.patch
;; Implement dump of mappings with ELF headers by gcore
;; RHBZ 1371380, Sergio Durigan Junior.
Implement dump of mappings with ELF headers by gcore
This patch has a long story, but it all started back in 2015, with
commit df8411da087dc05481926f4c4a82deabc5bc3859 ("Implement support
for checking /proc/PID/coredump_filter"). The purpose of that commit
was to bring GDB's corefile generation closer to what the Linux kernel
does. However, back then, I did not implement the full support for
the dumping of memory mappings containing ELF headers (like mappings
of DSOs or executables). These mappings were being dumped most of
time, though, because the default value of /proc/PID/coredump_filter
is 0x33, which would cause anonymous private mappings (DSOs/executable
code mappings have this type) to be dumped. Well, until something
happened on binutils...
A while ago, I noticed something strange was happening with one of our
local testcases on Fedora GDB: it was failing due to some strange
build-id problem. On Fedora GDB, we (unfortunately) carry a bunch of
"local" patches, and some of these patches actually extend upstream's
build-id support in order to generate more useful information for the
user of a Fedora system (for example, when the user loads a corefile
into GDB, we detect whether the executable that generated that
corefile is present, and if it's not we issue a warning suggesting
that it should be installed, while also providing the build-id of the
executable). A while ago, Fedora GDB stopped printing those warnings.
I wanted to investigate this right away, and spent some time trying to
determine what was going on, but other things happened and I got
sidetracked. Meanwhile, the bug started to be noticed by some of our
users, and its priority started changing. Then, someone on IRC also
mentioned the problem, and when I tried helping him, I noticed he
wasn't running Fedora. Hm... So maybe the bug was *also* present
upstream.
After "some" time investigating, and with a lot of help from Keith and
others, I was finally able to determine that yes, the bug is also
present upstream, and that even though it started with a change in ld,
it is indeed a GDB issue.
So, as I said, the problem started with binutils, more specifically
after the following commit was pushed:
commit f6aec96dce1ddbd8961a3aa8a2925db2021719bb
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Feb 27 11:34:20 2018 -0800
ld: Add --enable-separate-code
This commit makes ld use "-z separate-code" by default on x86-64
machines. What this means is that code pages and data pages are now
separated in the binary, which is confusing GDB when it tries to decide
what to dump.
BTW, Fedora 28 binutils doesn't have this code, which means that
Fedora 28 GDB doesn't have the problem. From Fedora 29 on, binutils
was rebased and incorporated the commit above, which started causing
Fedora GDB to fail.
Anyway, the first thing I tried was to pass "-z max-page-size" and
specify a bigger page size (I saw a patch that did this and was
proposed to Linux, so I thought it might help). Obviously, this
didn't work, because the real "problem" is that ld will always use
separate pages for code and data. So I decided to look into how GDB
dumped the pages, and that's where I found the real issue.
What happens is that, because of "-z separate-code", the first two pages
of the ELF binary are (from /proc/PID/smaps):
00400000-00401000 r--p 00000000 fc:01 799548 /file
Size: 4 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Rss: 4 kB
Pss: 4 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 4 kB
Private_Dirty: 0 kB
Referenced: 4 kB
Anonymous: 0 kB
LazyFree: 0 kB
AnonHugePages: 0 kB
ShmemPmdMapped: 0 kB
Shared_Hugetlb: 0 kB
Private_Hugetlb: 0 kB
Swap: 0 kB
SwapPss: 0 kB
Locked: 0 kB
THPeligible: 0
VmFlags: rd mr mw me dw sd
00401000-00402000 r-xp 00001000 fc:01 799548 /file
Size: 4 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Rss: 4 kB
Pss: 4 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 4 kB
Referenced: 4 kB
Anonymous: 4 kB
LazyFree: 0 kB
AnonHugePages: 0 kB
ShmemPmdMapped: 0 kB
Shared_Hugetlb: 0 kB
Private_Hugetlb: 0 kB
Swap: 0 kB
SwapPss: 0 kB
Locked: 0 kB
THPeligible: 0
VmFlags: rd ex mr mw me dw sd
Whereas before, we had only one:
00400000-00401000 r-xp 00000000 fc:01 798593 /file
Size: 4 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Rss: 4 kB
Pss: 4 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 4 kB
Referenced: 4 kB
Anonymous: 4 kB
LazyFree: 0 kB
AnonHugePages: 0 kB
ShmemPmdMapped: 0 kB
Shared_Hugetlb: 0 kB
Private_Hugetlb: 0 kB
Swap: 0 kB
SwapPss: 0 kB
Locked: 0 kB
THPeligible: 0
VmFlags: rd ex mr mw me dw sd
Notice how we have "Anonymous" data mapped into the page. This will be
important.
So, the way GDB decides which pages it should dump has been revamped
by my patch in 2015, and now it takes the contents of
/proc/PID/coredump_filter into account. The default value for Linux
is 0x33, which means:
Dump anonymous private, anonymous shared, ELF headers and HugeTLB
private pages.
Or:
filter_flags filterflags = (COREFILTER_ANON_PRIVATE
| COREFILTER_ANON_SHARED
| COREFILTER_ELF_HEADERS
| COREFILTER_HUGETLB_PRIVATE);
Now, it is important to keep in mind that GDB doesn't always have *all*
of the necessary information to exactly determine the type of a page, so
the whole algorithm is based on heuristics (you can take a look at
linux-tdep.c:dump_mapping_p and
linux-tdep.c:linux_find_memory_regions_full for more info).
Before the patch to make ld use "-z separate-code", the (single) page
containing data and code was being flagged as an anonymous (due to the
non-zero "Anonymous:" field) private (due to the "r-xp" permission),
which means that it was being dumped into the corefile. That's why it
was working fine.
Now, as you can imagine, when "-z separate-code" is used, the *data*
page (which is where the ELF notes are, including the build-id one) now
doesn't have any "Anonymous:" mapping, so the heuristic is flagging it
as file-backed private, which is *not* dumped by default.
The next question I had to answer was: how come a corefile generated by
the Linux kernel was correct? Well, the answer is that GDB, unlike
Linux, doesn't actually implement the COREFILTER_ELF_HEADERS support.
On Linux, even though the data page is also treated as a file-backed
private mapping, it is also checked to see if there are any ELF headers
in the page, and then, because we *do* have ELF headers there, it is
dumped.
So, after more time trying to think of ways to fix this, I was able to
implement an algorithm that reads the first few bytes of the memory
mapping being processed, and checks to see if the ELF magic code is
present. This is basically what Linux does as well, except that, if
it finds the ELF magic code, it just dumps one page to the corefile,
whereas GDB will dump the whole mapping. But I don't think that's a
big issue, to be honest.
It's also important to explain that we *only* perform the ELF magic
code check if:
- The algorithm has decided *not* to dump the mapping so far, and;
- The mapping is private, and;
- The mapping's offset is zero, and;
- The user has requested us to dump mappings with ELF headers.
IOW, we're not going to blindly check every mapping.
As for the testcase, I struggled even more trying to write it. Since
our build-id support on upstream GDB is not very extensive, it's not
really possible to determine whether a corefile contains build-id
information or not just by using GDB. So, after thinking a lot about
the problem, I decided to rely on an external tool, eu-unstrip, in
order to verify whether the dump was successful. I verified the test
here on my machine, and everything seems to work as expected (i.e., it
fails without the patch, and works with the patch applied). We are
working hard to upstream our "local" Fedora GDB patches, and we intend
to submit our build-id extension patches "soon", so hopefully we'll be
able to use GDB itself to perform this verification.
I built and regtested this on the BuildBot, and no problems were
found.
gdb/ChangeLog:
2019-04-25 Sergio Durigan Junior <sergiodj@redhat.com>
PR corefiles/11608
PR corefiles/18187
* linux-tdep.c (dump_mapping_p): Add new parameters ADDR and
OFFSET. Verify if current mapping contains an ELF header.
(linux_find_memory_regions_full): Adjust call to
dump_mapping_p.
gdb/testsuite/ChangeLog:
2019-04-25 Sergio Durigan Junior <sergiodj@redhat.com>
PR corefiles/11608
PR corefiles/18187
* gdb.base/coredump-filter-build-id.exp: New file.
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -591,8 +591,8 @@ mapping_is_anonymous_p (const char *filename)
}
/* Return 0 if the memory mapping (which is related to FILTERFLAGS, V,
- MAYBE_PRIVATE_P, and MAPPING_ANONYMOUS_P) should not be dumped, or
- greater than 0 if it should.
+ MAYBE_PRIVATE_P, MAPPING_ANONYMOUS_P, ADDR and OFFSET) should not
+ be dumped, or greater than 0 if it should.
In a nutshell, this is the logic that we follow in order to decide
if a mapping should be dumped or not.
@@ -630,12 +630,17 @@ mapping_is_anonymous_p (const char *filename)
see 'p' in the permission flags, then we assume that the mapping
is private, even though the presence of the 's' flag there would
mean VM_MAYSHARE, which means the mapping could still be private.
- This should work OK enough, however. */
+ This should work OK enough, however.
+
+ - Even if, at the end, we decided that we should not dump the
+ mapping, we still have to check if it is something like an ELF
+ header (of a DSO or an executable, for example). If it is, and
+ if the user is interested in dump it, then we should dump it. */
static int
dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v,
int maybe_private_p, int mapping_anon_p, int mapping_file_p,
- const char *filename)
+ const char *filename, ULONGEST addr, ULONGEST offset)
{
/* Initially, we trust in what we received from our caller. This
value may not be very precise (i.e., it was probably gathered
@@ -645,6 +650,7 @@ dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v,
(assuming that the version of the Linux kernel being used
supports it, of course). */
int private_p = maybe_private_p;
+ int dump_p;
/* We always dump vDSO and vsyscall mappings, because it's likely that
there'll be no file to read the contents from at core load time.
@@ -685,13 +691,13 @@ dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v,
/* This is a special situation. It can happen when we see a
mapping that is file-backed, but that contains anonymous
pages. */
- return ((filterflags & COREFILTER_ANON_PRIVATE) != 0
- || (filterflags & COREFILTER_MAPPED_PRIVATE) != 0);
+ dump_p = ((filterflags & COREFILTER_ANON_PRIVATE) != 0
+ || (filterflags & COREFILTER_MAPPED_PRIVATE) != 0);
}
else if (mapping_anon_p)
- return (filterflags & COREFILTER_ANON_PRIVATE) != 0;
+ dump_p = (filterflags & COREFILTER_ANON_PRIVATE) != 0;
else
- return (filterflags & COREFILTER_MAPPED_PRIVATE) != 0;
+ dump_p = (filterflags & COREFILTER_MAPPED_PRIVATE) != 0;
}
else
{
@@ -700,14 +706,55 @@ dump_mapping_p (filter_flags filterflags, const struct smaps_vmflags *v,
/* This is a special situation. It can happen when we see a
mapping that is file-backed, but that contains anonymous
pages. */
- return ((filterflags & COREFILTER_ANON_SHARED) != 0
- || (filterflags & COREFILTER_MAPPED_SHARED) != 0);
+ dump_p = ((filterflags & COREFILTER_ANON_SHARED) != 0
+ || (filterflags & COREFILTER_MAPPED_SHARED) != 0);
}
else if (mapping_anon_p)
- return (filterflags & COREFILTER_ANON_SHARED) != 0;
+ dump_p = (filterflags & COREFILTER_ANON_SHARED) != 0;
else
- return (filterflags & COREFILTER_MAPPED_SHARED) != 0;
+ dump_p = (filterflags & COREFILTER_MAPPED_SHARED) != 0;
}
+
+ /* Even if we decided that we shouldn't dump this mapping, we still
+ have to check whether (a) the user wants us to dump mappings
+ containing an ELF header, and (b) the mapping in question
+ contains an ELF header. If (a) and (b) are true, then we should
+ dump this mapping.
+
+ A mapping contains an ELF header if it is a private mapping, its
+ offset is zero, and its first word is ELFMAG. */
+ if (!dump_p && private_p && offset == 0
+ && (filterflags & COREFILTER_ELF_HEADERS) != 0)
+ {
+ /* Let's check if we have an ELF header. */
+ gdb::unique_xmalloc_ptr<char> header;
+ int errcode;
+
+ /* Useful define specifying the size of the ELF magical
+ header. */
+#ifndef SELFMAG
+#define SELFMAG 4
+#endif
+
+ /* Read the first SELFMAG bytes and check if it is ELFMAG. */
+ if (target_read_string (addr, &header, SELFMAG, &errcode) == SELFMAG
+ && errcode == 0)
+ {
+ const char *h = header.get ();
+
+ /* The EI_MAG* and ELFMAG* constants come from
+ <elf/common.h>. */
+ if (h[EI_MAG0] == ELFMAG0 && h[EI_MAG1] == ELFMAG1
+ && h[EI_MAG2] == ELFMAG2 && h[EI_MAG3] == ELFMAG3)
+ {
+ /* This mapping contains an ELF header, so we
+ should dump it. */
+ dump_p = 1;
+ }
+ }
+ }
+
+ return dump_p;
}
/* Implement the "info proc" command. */
@@ -1311,7 +1358,7 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch,
if (has_anonymous)
should_dump_p = dump_mapping_p (filterflags, &v, priv,
mapping_anon_p, mapping_file_p,
- filename);
+ filename, addr, offset);
else
{
/* Older Linux kernels did not support the "Anonymous:" counter.
diff --git a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
@@ -0,0 +1,69 @@
+# Copyright 2019 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/>.
+
+# Test whether GDB's gcore/generate-core-file command can dump memory
+# mappings with ELF headers, containing a build-id note.
+#
+# Due to the fact that we don't have an easy way to process a corefile
+# and look for specific notes using GDB/dejagnu, we rely on an
+# external tool, eu-unstrip, to verify if the corefile contains
+# build-ids.
+
+standard_testfile "normal.c"
+
+# This test is Linux x86_64 only.
+if { ![istarget *-*-linux*] } {
+ untested "$testfile.exp"
+ return -1
+}
+if { ![istarget "x86_64-*-*"] || ![is_lp64_target] } {
+ untested "$testfile.exp"
+ return -1
+}
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
+ return -1
+}
+
+if { ![runto_main] } {
+ untested "could not run to main"
+ return -1
+}
+
+# First we need to generate a corefile.
+set corefilename "[standard_output_file gcore.test]"
+if { ![gdb_gcore_cmd "$corefilename" "save corefile"] } {
+ verbose -log "Could not save corefile"
+ untested "$testfile.exp"
+ return -1
+}
+
+# Determine if GDB dumped the mapping containing the build-id. This
+# is done by invoking an external program (eu-unstrip).
+if { [catch "exec [gdb_find_eu-unstrip] -n --core $corefilename" output] == 0 } {
+ set line [lindex [split $output "\n"] 0]
+ set test "gcore dumped mapping with build-id"
+
+ verbose -log "First line of eu-unstrip: $line"
+
+ if { [regexp "^${hex}\\+${hex} \[a-f0-9\]+@${hex}.*[string_to_regexp $binfile]$" $line] } {
+ pass "$test"
+ } else {
+ fail "$test"
+ }
+} else {
+ verbose -log "Could not execute eu-unstrip program"
+ untested "$testfile.exp"
+}
diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp
--- a/gdb/testsuite/lib/future.exp
+++ b/gdb/testsuite/lib/future.exp
@@ -162,6 +162,16 @@ proc gdb_find_readelf {} {
return $readelf
}
+proc gdb_find_eu-unstrip {} {
+ global EU_UNSTRIP_FOR_TARGET
+ if [info exists EU_UNSTRIP_FOR_TARGET] {
+ set eu_unstrip $EU_UNSTRIP_FOR_TARGET
+ } else {
+ set eu_unstrip [transform eu-unstrip]
+ }
+ return $eu_unstrip
+}
+
proc gdb_default_target_compile {source destfile type options} {
global target_triplet
global tool_root_dir

View File

@ -1,323 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Gary Benson <gbenson@redhat.com>
Date: Wed, 29 Aug 2018 16:11:50 +0100
Subject: gdb-rhbz1491128-batch-mode-exit-status-1of2.patch
;; Fix for 'gdb in batch mode always exit with status 0' (Gary Benson)
;; RHBZ #1491128
Indicate batch mode failures by exiting with nonzero status
This commit causes GDB in batch mode to exit with nonzero status
if the last command to be executed fails.
gdb/ChangeLog:
PR gdb/13000:
* gdb/main.c (captured_main_1): Exit with nonzero status
in batch mode if the last command to be executed failed.
* NEWS: Mention the above.
gdb/testsuite/ChangeLog:
PR gdb/13000:
* gdb.base/batch-exit-status.exp: New file.
* gdb.base/batch-exit-status.good-commands: Likewise.
* gdb.base/batch-exit-status.bad-commands: Likewise.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2018-08-16 Gary Benson <gbenson@redhat.com>
+
+ PR gdb/13000:
+ * gdb/main.c (captured_main_1): Exit with nonzero status
+ in batch mode if the last command to be executed failed.
+ * NEWS: Mention the above.
+
2018-08-03 Sergio Durigan Junior <sergiodj@redhat.com>
* ser-tcp.c (net_open): Fix thinko when deciding whether to
diff --git a/gdb/NEWS b/gdb/NEWS
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -7,6 +7,9 @@
can be passed using the '[ADDRESS]:PORT' notation, or the regular
'ADDRESS:PORT' method.
+* GDB in batch mode now exits with status 1 if the last command to be
+ executed failed.
+
*** Changes in GDB 8.2
* The 'set disassembler-options' command now supports specifying options
diff --git a/gdb/main.c b/gdb/main.c
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -518,6 +518,7 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
int i;
int save_auto_load;
struct objfile *objfile;
+ int ret = 1;
#ifdef HAVE_SBRK
/* Set this before constructing scoped_command_stats. */
@@ -1051,7 +1052,7 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
processed; it sets global parameters, which are independent of
what file you are debugging or what directory you are in. */
if (system_gdbinit && !inhibit_gdbinit)
- catch_command_errors (source_script, system_gdbinit, 0);
+ ret = catch_command_errors (source_script, system_gdbinit, 0);
/* Read and execute $HOME/.gdbinit file, if it exists. This is done
*before* all the command line arguments are processed; it sets
@@ -1059,7 +1060,7 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
debugging or what directory you are in. */
if (home_gdbinit && !inhibit_gdbinit && !inhibit_home_gdbinit)
- catch_command_errors (source_script, home_gdbinit, 0);
+ ret = catch_command_errors (source_script, home_gdbinit, 0);
/* Process '-ix' and '-iex' options early. */
for (i = 0; i < cmdarg_vec.size (); i++)
@@ -1069,12 +1070,12 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
switch (cmdarg_p.type)
{
case CMDARG_INIT_FILE:
- catch_command_errors (source_script, cmdarg_p.string,
- !batch_flag);
+ ret = catch_command_errors (source_script, cmdarg_p.string,
+ !batch_flag);
break;
case CMDARG_INIT_COMMAND:
- catch_command_errors (execute_command, cmdarg_p.string,
- !batch_flag);
+ ret = catch_command_errors (execute_command, cmdarg_p.string,
+ !batch_flag);
break;
}
}
@@ -1082,11 +1083,11 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
/* Now perform all the actions indicated by the arguments. */
if (cdarg != NULL)
{
- catch_command_errors (cd_command, cdarg, 0);
+ ret = catch_command_errors (cd_command, cdarg, 0);
}
for (i = 0; i < dirarg.size (); i++)
- catch_command_errors (directory_switch, dirarg[i], 0);
+ ret = catch_command_errors (directory_switch, dirarg[i], 0);
/* Skip auto-loading section-specified scripts until we've sourced
local_gdbinit (which is often used to augment the source search
@@ -1115,19 +1116,19 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
catch_command_errors returns non-zero on success!
Do not load EXECARG as a symbol file if it has been already processed
as a core file. */
- if (catch_command_errors (func, execarg, !batch_flag)
- && core_bfd == NULL)
- catch_command_errors (symbol_file_add_main_adapter, symarg,
- !batch_flag);
+ ret = catch_command_errors (func, execarg, !batch_flag);
+ if (ret != 0 && core_bfd == NULL)
+ ret = catch_command_errors (symbol_file_add_main_adapter,
+ symarg, !batch_flag);
}
else
{
if (execarg != NULL)
- catch_command_errors (exec_file_attach, execarg,
- !batch_flag);
+ ret = catch_command_errors (exec_file_attach, execarg,
+ !batch_flag);
if (symarg != NULL)
- catch_command_errors (symbol_file_add_main_adapter, symarg,
- !batch_flag);
+ ret = catch_command_errors (symbol_file_add_main_adapter,
+ symarg, !batch_flag);
}
if (corearg && pidarg)
@@ -1135,9 +1136,14 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
"a core file at the same time."));
if (corearg != NULL)
- catch_command_errors (core_file_command, corearg, !batch_flag);
+ {
+ ret = catch_command_errors (core_file_command, corearg,
+ !batch_flag);
+ }
else if (pidarg != NULL)
- catch_command_errors (attach_command, pidarg, !batch_flag);
+ {
+ ret = catch_command_errors (attach_command, pidarg, !batch_flag);
+ }
else if (pid_or_core_arg)
{
/* The user specified 'gdb program pid' or gdb program core'.
@@ -1146,17 +1152,23 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
if (isdigit (pid_or_core_arg[0]))
{
- if (catch_command_errors (attach_command, pid_or_core_arg,
- !batch_flag) == 0
+ ret = catch_command_errors (attach_command, pid_or_core_arg,
+ !batch_flag);
+ if (ret == 0
/* attach_command could succeed partially and core_file_command
would try to kill it. */
&& !have_inferiors ())
- catch_command_errors (core_file_command, pid_or_core_arg,
- !batch_flag);
+ ret = catch_command_errors (core_file_command,
+ pid_or_core_arg,
+ !batch_flag);
+ }
+ else
+ {
+ /* Can't be a pid, better be a corefile. */
+ ret = catch_command_errors (core_file_command,
+ pid_or_core_arg,
+ !batch_flag);
}
- else /* Can't be a pid, better be a corefile. */
- catch_command_errors (core_file_command, pid_or_core_arg,
- !batch_flag);
}
if (ttyarg != NULL)
@@ -1180,7 +1192,7 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
{
auto_load_local_gdbinit_loaded = 1;
- catch_command_errors (source_script, local_gdbinit, 0);
+ ret = catch_command_errors (source_script, local_gdbinit, 0);
}
}
@@ -1200,12 +1212,12 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
switch (cmdarg_p.type)
{
case CMDARG_FILE:
- catch_command_errors (source_script, cmdarg_p.string,
- !batch_flag);
+ ret = catch_command_errors (source_script, cmdarg_p.string,
+ !batch_flag);
break;
case CMDARG_COMMAND:
- catch_command_errors (execute_command, cmdarg_p.string,
- !batch_flag);
+ ret = catch_command_errors (execute_command, cmdarg_p.string,
+ !batch_flag);
break;
}
}
@@ -1217,8 +1229,11 @@ captured_main_1 (struct captured_main_args *context, int &python_script)
if (batch_flag)
{
+ int error_status = EXIT_FAILURE;
+ int *exit_arg = ret == 0 ? &error_status : NULL;
+
/* We have hit the end of the batch file. */
- quit_force (NULL, 0);
+ quit_force (exit_arg, 0);
}
}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2018-08-16 Gary Benson <gbenson@redhat.com>
+
+ PR gdb/13000:
+ * gdb.base/batch-exit-status.exp: New file.
+ * gdb.base/batch-exit-status.good-commands: Likewise.
+ * gdb.base/batch-exit-status.bad-commands: Likewise.
+
2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
Paul Fertser <fercerpav@gmail.com>
diff --git a/gdb/testsuite/gdb.base/batch-exit-status.bad-commands b/gdb/testsuite/gdb.base/batch-exit-status.bad-commands
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/batch-exit-status.bad-commands
@@ -0,0 +1 @@
+bork
diff --git a/gdb/testsuite/gdb.base/batch-exit-status.exp b/gdb/testsuite/gdb.base/batch-exit-status.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/batch-exit-status.exp
@@ -0,0 +1,63 @@
+# Copyright (C) 2018 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/>.
+
+# Check that "gdb -batch" exits with appropriate status.
+
+standard_testfile
+
+set good_commands "$srcdir/$subdir/batch-exit-status.good-commands"
+set bad_commands "$srcdir/$subdir/batch-exit-status.bad-commands"
+
+proc _test_exit_status {expect_status cmdline_opts} {
+ global gdb_spawn_id
+
+ gdb_exit
+ if {[gdb_spawn_with_cmdline_opts $cmdline_opts] != 0} {
+ fail "spawn"
+ return
+ }
+
+ set result [wait -i $gdb_spawn_id]
+ verbose $result
+ gdb_assert { [lindex $result 2] == 0 }
+ set actual_status [lindex $result 3]
+ gdb_assert { $actual_status == $expect_status }
+}
+
+proc test_exit_status {expect_status cmdline_opts} {
+ with_test_prefix $cmdline_opts {
+ _test_exit_status $expect_status $cmdline_opts
+ }
+}
+
+# gdb -batch with nothing to do should exit 0.
+test_exit_status 0 "-batch"
+
+# Bad command-line options should cause exit 1.
+test_exit_status 1 "-batch -jslkflsdjlkfjlksdjf"
+
+# gdb -batch with good commands should exit 0.
+test_exit_status 0 "-batch -ex \"info source\""
+test_exit_status 0 "-batch -x $good_commands"
+
+# gdb -batch with bad commands should exit 1.
+test_exit_status 1 "-batch -ex \"set not-a-thing 4\""
+test_exit_status 1 "-batch -x $bad_commands"
+
+# Success or failure of the last thing determines the exit code.
+test_exit_status 0 "-batch -ex \"set not-a-thing 4\" -x $good_commands"
+test_exit_status 0 "-batch -x $bad_commands -ex \"info source\""
+test_exit_status 1 "-batch -x $good_commands -x $bad_commands"
+test_exit_status 1 "-batch -x $good_commands -ex \"set not-a-thing 4\""
diff --git a/gdb/testsuite/gdb.base/batch-exit-status.good-commands b/gdb/testsuite/gdb.base/batch-exit-status.good-commands
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/batch-exit-status.good-commands
@@ -0,0 +1 @@
+info mem

View File

@ -1,65 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Gary Benson <gbenson@redhat.com>
Date: Mon, 3 Sep 2018 16:14:55 +0100
Subject: gdb-rhbz1491128-batch-mode-exit-status-2of2.patch
;; Fix for 'gdb in batch mode always exit with status 0' (Gary Benson)
;; RHBZ #1491128
Fix batch exit status test failure on Fedora 28
This commit adds calls to remote_close and clear_gdb_spawn_id to
gdb.base/batch-exit-status.exp, fixing failures reported by buildbot
on Fedora 28 where gdb_spawn_id not being reset by the previous test
caused default_gdb_spawn to return without spawning.
This commit also changes the test to use detect GDB's exit using
gdb_test_multiple expecting 'eof', rather than using 'wait -i' alone.
This means the testcase won't hang forever on failure as fixed in
gdb.base/quit.exp by commit 15763a09d4ae ("Fix 'gdb.base/quit.exp
hangs forever' if the test fails").
gdb/testsuite/ChangeLog:
* gdb.base/batch-exit-status.exp: Use gdb_test_multiple and expect
'eof' before 'wait -i'. Use remote_close and clear_gdb_spawn_id.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-09-04 Gary Benson <gbenson@redhat.com>
+
+ * gdb.base/batch-exit-status.exp: Use gdb_test_multiple and expect
+ 'eof' before 'wait -i'. Use remote_close and clear_gdb_spawn_id.
+
2018-08-16 Gary Benson <gbenson@redhat.com>
PR gdb/13000:
diff --git a/gdb/testsuite/gdb.base/batch-exit-status.exp b/gdb/testsuite/gdb.base/batch-exit-status.exp
--- a/gdb/testsuite/gdb.base/batch-exit-status.exp
+++ b/gdb/testsuite/gdb.base/batch-exit-status.exp
@@ -29,11 +29,18 @@ proc _test_exit_status {expect_status cmdline_opts} {
return
}
- set result [wait -i $gdb_spawn_id]
- verbose $result
- gdb_assert { [lindex $result 2] == 0 }
- set actual_status [lindex $result 3]
- gdb_assert { $actual_status == $expect_status }
+ gdb_test_multiple "" "run til exit" {
+ eof {
+ set result [wait -i $gdb_spawn_id]
+ verbose $result
+
+ gdb_assert { [lindex $result 2] == 0 }
+ gdb_assert { [lindex $result 3] == $expect_status }
+
+ remote_close host
+ clear_gdb_spawn_id
+ }
+ }
}
proc test_exit_status {expect_status cmdline_opts} {

View File

@ -1,746 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Fri, 11 Jan 2019 10:52:17 -0500
Subject:
gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-1of5.patch
;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.'
;; Keith Seitz, RHBZ#1560010.
gdb/23712: Introduce multidictionary's
gdb/23712 is a new manifestation of the now-infamous (at least to me)
symtab/23010 assertion failure (DICT_LANGUAGE == SYMBOL_LANGAUGE).
An example of the problem (using test case from symtab/23010):
Reading symbols from /home/rdiez/rdiez/arduino/JtagDue/BuildOutput/JtagDue-obj-release/firmware.elf...done.
(gdb) p SysTick_Handler
dwarf2read.c:9715: internal-error: void dw2_add_symbol_to_list(symbol*, pending**): Assertion `(*listhead) == NULL || (SYMBOL_LANGUAGE ((*listhead)->symbol[0]) == SYMBOL_LANGUAGE (symbol))' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
This assertion was added specifically to catch this condition (of adding
symbols of different languages to a single pending list).
The problems we're now seeing on systems utilizing DWARF debugging seem to
be caused by the use of LTO, which adds a CU with an artificial DIE of
language C99 which references DIEs in other CUs of language C++.
Thus, we create a dictionary containing symbols of C99 but end up
stuffing C++ symbols into it, and the dw2_add_symbol_to_list triggers.
The approach taken here to fix this is to introduce multi-language
dictionaries to "replace" the standard, single-language dictionaries
used today.
Note to reviewers: This patch introduces some temporary functions to
aide with review. This and other artifacts (such as "See dictionary.h"
which appear incorrect) will all be valid at the end of the series.
This first patch introduces the new multidictionary and its API (which
is, by design, identical to the old dictionary interface). It also
mutates dict_create_hashed and dict_create_linear so that they take
a std::vector instead of the usual struct pending linked list. This will
be needed later on.
This patch does /not/ actually enable multidictionary's. That is left
for a subsequent patch in the series.
I've done exhaustive performance testing with this approach, and I've
attempted to minimize the overhead for the (overwhelmingly) most common
one-language scenario.
On average, a -g3 -O0 GDB (the one we developers use) will see
approximately a 4% slowdown when initially reading symbols. [I've
tested only GDB and firefox with -readnow.] When using -O2, this
difference shrinks to ~0.5%. Since a number of runs with these
patches actually run /faster/ than unpatched GDB, I conclude that
these tests have at least a 0.5% error margin.
On our own gdb.perf test suite, again, results appear to be pretty
negligible. Differences to unpatched GDB range from -7.8% (yes,
patched version is again faster than unpatched) to 27%. All tests
lying outside "negligible," such as the 27% slowdown, involve a total
run time of 0.0007 (or less) with smaller numbers of CUs/DSOs (usually 10
or 100). In all cases, the follow-up tests with more CUs/DSOs is never
more than 3% difference to the baseline, unpatched GDB.
In my opinion, these results are satisfactory.
gdb/ChangeLog:
PR gdb/23712
PR symtab/23010
* dictionary.c: Include unordered_map.
(pending_to_vector): New function.
(dict_create_hashed_1, dict_create_linear_1, dict_add_pending_1):
Rewrite the non-"_1" functions to take vector instead
of linked list.
(dict_create_hashed, dict_create_linear, dict_add_pending): Use the
"new" _1 versions of the same name.
(multidictionary): Define.
(std::hash<enum language): New definition.
(collate_pending_symbols_by_language, mdict_create_hashed)
(mdict_create_hashed_expandable, mdict_create_linear)
(mdict_create_linear_expandable, mdict_free)
(find_language_dictionary, create_new_language_dictionary)
(mdict_add_symbol, mdict_add_pending, mdict_iterator_first)
(mdict_iterator_next, mdict_iter_match_first, mdict_iter_match_next)
(mdict_size, mdict_empty): New functions.
* dictionary.h (mdict_iterator): Define.
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -27,6 +27,7 @@
#include "buildsym.h"
#include "dictionary.h"
#include "safe-ctype.h"
+#include <unordered_map>
/* This file implements dictionaries, which are tables that associate
symbols to names. They are represented by an opaque type 'struct
@@ -341,53 +342,66 @@ static void insert_symbol_hashed (struct dictionary *dict,
static void expand_hashtable (struct dictionary *dict);
+/* A function to convert a linked list into a vector. */
+
+static std::vector<symbol *>
+pending_to_vector (const struct pending *symbol_list)
+{
+ std::vector<symbol *> symlist;
+
+ for (const struct pending *list_counter = symbol_list;
+ list_counter != nullptr; list_counter = list_counter->next)
+ {
+ for (int i = list_counter->nsyms - 1; i >= 0; --i)
+ symlist.push_back (list_counter->symbol[i]);
+ }
+
+ return symlist;
+}
+
/* The creation functions. */
-/* See dictionary.h. */
+/* A function to transition dict_create_hashed to new API. */
-struct dictionary *
-dict_create_hashed (struct obstack *obstack,
- enum language language,
- const struct pending *symbol_list)
+static struct dictionary *
+dict_create_hashed_1 (struct obstack *obstack,
+ enum language language,
+ const std::vector<symbol *> &symbol_list)
{
- struct dictionary *retval;
- int nsyms = 0, nbuckets, i;
- struct symbol **buckets;
- const struct pending *list_counter;
-
- retval = XOBNEW (obstack, struct dictionary);
+ /* Allocate the dictionary. */
+ struct dictionary *retval = XOBNEW (obstack, struct dictionary);
DICT_VECTOR (retval) = &dict_hashed_vector;
DICT_LANGUAGE (retval) = language_def (language);
- /* Calculate the number of symbols, and allocate space for them. */
- for (list_counter = symbol_list;
- list_counter != NULL;
- list_counter = list_counter->next)
- {
- nsyms += list_counter->nsyms;
- }
- nbuckets = DICT_HASHTABLE_SIZE (nsyms);
+ /* Allocate space for symbols. */
+ int nsyms = symbol_list.size ();
+ int nbuckets = DICT_HASHTABLE_SIZE (nsyms);
DICT_HASHED_NBUCKETS (retval) = nbuckets;
- buckets = XOBNEWVEC (obstack, struct symbol *, nbuckets);
+ struct symbol **buckets = XOBNEWVEC (obstack, struct symbol *, nbuckets);
memset (buckets, 0, nbuckets * sizeof (struct symbol *));
DICT_HASHED_BUCKETS (retval) = buckets;
/* Now fill the buckets. */
- for (list_counter = symbol_list;
- list_counter != NULL;
- list_counter = list_counter->next)
- {
- for (i = list_counter->nsyms - 1; i >= 0; --i)
- {
- insert_symbol_hashed (retval, list_counter->symbol[i]);
- }
- }
+ for (const auto &sym : symbol_list)
+ insert_symbol_hashed (retval, sym);
return retval;
}
/* See dictionary.h. */
+struct dictionary *
+dict_create_hashed (struct obstack *obstack,
+ enum language language,
+ const struct pending *symbol_list)
+{
+ std::vector<symbol *> symlist = pending_to_vector (symbol_list);
+
+ return dict_create_hashed_1 (obstack, language, symlist);
+}
+
+/* See dictionary.h. */
+
extern struct dictionary *
dict_create_hashed_expandable (enum language language)
{
@@ -403,52 +417,45 @@ dict_create_hashed_expandable (enum language language)
return retval;
}
-/* See dictionary.h. */
+/* A function to transition dict_create_linear to new API. */
-struct dictionary *
-dict_create_linear (struct obstack *obstack,
- enum language language,
- const struct pending *symbol_list)
+static struct dictionary *
+dict_create_linear_1 (struct obstack *obstack,
+ enum language language,
+ const std::vector<symbol *> &symbol_list)
{
- struct dictionary *retval;
- int nsyms = 0, i, j;
- struct symbol **syms;
- const struct pending *list_counter;
-
- retval = XOBNEW (obstack, struct dictionary);
+ struct dictionary *retval = XOBNEW (obstack, struct dictionary);
DICT_VECTOR (retval) = &dict_linear_vector;
DICT_LANGUAGE (retval) = language_def (language);
- /* Calculate the number of symbols, and allocate space for them. */
- for (list_counter = symbol_list;
- list_counter != NULL;
- list_counter = list_counter->next)
- {
- nsyms += list_counter->nsyms;
- }
+ /* Allocate space for symbols. */
+ int nsyms = symbol_list.size ();
DICT_LINEAR_NSYMS (retval) = nsyms;
- syms = XOBNEWVEC (obstack, struct symbol *, nsyms );
+ struct symbol **syms = XOBNEWVEC (obstack, struct symbol *, nsyms);
DICT_LINEAR_SYMS (retval) = syms;
- /* Now fill in the symbols. Start filling in from the back, so as
- to preserve the original order of the symbols. */
- for (list_counter = symbol_list, j = nsyms - 1;
- list_counter != NULL;
- list_counter = list_counter->next)
- {
- for (i = list_counter->nsyms - 1;
- i >= 0;
- --i, --j)
- {
- syms[j] = list_counter->symbol[i];
- }
- }
+ /* Now fill in the symbols. */
+ int idx = nsyms - 1;
+ for (const auto &sym : symbol_list)
+ syms[idx--] = sym;
return retval;
}
/* See dictionary.h. */
+struct dictionary *
+dict_create_linear (struct obstack *obstack,
+ enum language language,
+ const struct pending *symbol_list)
+{
+ std::vector<symbol *> symlist = pending_to_vector (symbol_list);
+
+ return dict_create_linear_1 (obstack, language, symlist);
+}
+
+/* See dictionary.h. */
+
struct dictionary *
dict_create_linear_expandable (enum language language)
{
@@ -483,20 +490,26 @@ dict_add_symbol (struct dictionary *dict, struct symbol *sym)
(DICT_VECTOR (dict))->add_symbol (dict, sym);
}
+/* A function to transition dict_add_pending to new API. */
+
+static void
+dict_add_pending_1 (struct dictionary *dict,
+ const std::vector<symbol *> &symbol_list)
+{
+ /* Preserve ordering by reversing the list. */
+ for (auto sym = symbol_list.rbegin (); sym != symbol_list.rend (); ++sym)
+ dict_add_symbol (dict, *sym);
+}
+
/* Utility to add a list of symbols to a dictionary.
DICT must be an expandable dictionary. */
void
dict_add_pending (struct dictionary *dict, const struct pending *symbol_list)
{
- const struct pending *list;
- int i;
+ std::vector<symbol *> symlist = pending_to_vector (symbol_list);
- for (list = symbol_list; list != NULL; list = list->next)
- {
- for (i = 0; i < list->nsyms; ++i)
- dict_add_symbol (dict, list->symbol[i]);
- }
+ dict_add_pending_1 (dict, symlist);
}
/* Initialize ITERATOR to point at the first symbol in DICT, and
@@ -929,3 +942,408 @@ add_symbol_linear_expandable (struct dictionary *dict,
DICT_LINEAR_SYM (dict, nsyms - 1) = sym;
}
+
+/* Multi-language dictionary support. */
+
+/* The structure describing a multi-language dictionary. */
+
+struct multidictionary
+{
+ /* An array of dictionaries, one per language. All dictionaries
+ must be of the same type. This should be free'd for expandable
+ dictionary types. */
+ struct dictionary **dictionaries;
+
+ /* The number of language dictionaries currently allocated.
+ Only used for expandable dictionaries. */
+ unsigned short n_allocated_dictionaries;
+};
+
+/* A hasher for enum language. Injecting this into std is a convenience
+ when using unordered_map with C++11. */
+
+namespace std
+{
+ template<> struct hash<enum language>
+ {
+ typedef enum language argument_type;
+ typedef std::size_t result_type;
+
+ result_type operator() (const argument_type &l) const noexcept
+ {
+ return static_cast<result_type> (l);
+ }
+ };
+} /* namespace std */
+
+/* A helper function to collate symbols on the pending list by language. */
+
+static std::unordered_map<enum language, std::vector<symbol *>>
+collate_pending_symbols_by_language (const struct pending *symbol_list)
+{
+ std::unordered_map<enum language, std::vector<symbol *>> nsyms;
+
+ for (const struct pending *list_counter = symbol_list;
+ list_counter != nullptr; list_counter = list_counter->next)
+ {
+ for (int i = list_counter->nsyms - 1; i >= 0; --i)
+ {
+ enum language language = SYMBOL_LANGUAGE (list_counter->symbol[i]);
+ nsyms[language].push_back (list_counter->symbol[i]);
+ }
+ }
+
+ return nsyms;
+}
+
+/* See dictionary.h. */
+
+struct multidictionary *
+mdict_create_hashed (struct obstack *obstack,
+ const struct pending *symbol_list)
+{
+ struct multidictionary *retval
+ = XOBNEW (obstack, struct multidictionary);
+ std::unordered_map<enum language, std::vector<symbol *>> nsyms
+ = collate_pending_symbols_by_language (symbol_list);
+
+ /* Loop over all languages and create/populate dictionaries. */
+ retval->dictionaries
+ = XOBNEWVEC (obstack, struct dictionary *, nsyms.size ());
+ retval->n_allocated_dictionaries = nsyms.size ();
+
+ int idx = 0;
+ for (const auto &pair : nsyms)
+ {
+ enum language language = pair.first;
+ std::vector<symbol *> symlist = pair.second;
+
+ retval->dictionaries[idx++]
+ = dict_create_hashed_1 (obstack, language, symlist);
+ }
+
+ return retval;
+}
+
+/* See dictionary.h. */
+
+struct multidictionary *
+mdict_create_hashed_expandable (enum language language)
+{
+ struct multidictionary *retval = XNEW (struct multidictionary);
+
+ /* We have no symbol list to populate, but we create an empty
+ dictionary of the requested language to populate later. */
+ retval->n_allocated_dictionaries = 1;
+ retval->dictionaries = XNEW (struct dictionary *);
+ retval->dictionaries[0] = dict_create_hashed_expandable (language);
+
+ return retval;
+}
+
+/* See dictionary.h. */
+
+struct multidictionary *
+mdict_create_linear (struct obstack *obstack,
+ const struct pending *symbol_list)
+{
+ struct multidictionary *retval
+ = XOBNEW (obstack, struct multidictionary);
+ std::unordered_map<enum language, std::vector<symbol *>> nsyms
+ = collate_pending_symbols_by_language (symbol_list);
+
+ /* Loop over all languages and create/populate dictionaries. */
+ retval->dictionaries
+ = XOBNEWVEC (obstack, struct dictionary *, nsyms.size ());
+ retval->n_allocated_dictionaries = nsyms.size ();
+
+ int idx = 0;
+ for (const auto &pair : nsyms)
+ {
+ enum language language = pair.first;
+ std::vector<symbol *> symlist = pair.second;
+
+ retval->dictionaries[idx++]
+ = dict_create_linear_1 (obstack, language, symlist);
+ }
+
+ return retval;
+}
+
+/* See dictionary.h. */
+
+struct multidictionary *
+mdict_create_linear_expandable (enum language language)
+{
+ struct multidictionary *retval = XNEW (struct multidictionary);
+
+ /* We have no symbol list to populate, but we create an empty
+ dictionary to populate later. */
+ retval->n_allocated_dictionaries = 1;
+ retval->dictionaries = XNEW (struct dictionary *);
+ retval->dictionaries[0] = dict_create_linear_expandable (language);
+
+ return retval;
+}
+
+/* See dictionary.h. */
+
+void
+mdict_free (struct multidictionary *mdict)
+{
+ /* Grab the type of dictionary being used. */
+ enum dict_type type = mdict->dictionaries[0]->vector->type;
+
+ /* Loop over all dictionaries and free them. */
+ for (unsigned short idx = 0; idx < mdict->n_allocated_dictionaries; ++idx)
+ dict_free (mdict->dictionaries[idx]);
+
+ /* Free the dictionary list, if needed. */
+ switch (type)
+ {
+ case DICT_HASHED:
+ case DICT_LINEAR:
+ /* Memory was allocated on an obstack when created. */
+ break;
+
+ case DICT_HASHED_EXPANDABLE:
+ case DICT_LINEAR_EXPANDABLE:
+ xfree (mdict->dictionaries);
+ break;
+ }
+}
+
+/* Helper function to find the dictionary associated with LANGUAGE
+ or NULL if there is no dictionary of that language. */
+
+static struct dictionary *
+find_language_dictionary (const struct multidictionary *mdict,
+ enum language language)
+{
+ for (unsigned short idx = 0; idx < mdict->n_allocated_dictionaries; ++idx)
+ {
+ if (DICT_LANGUAGE (mdict->dictionaries[idx])->la_language == language)
+ return mdict->dictionaries[idx];
+ }
+
+ return nullptr;
+}
+
+/* Create a new language dictionary for LANGUAGE and add it to the
+ multidictionary MDICT's list of dictionaries. If MDICT is not
+ based on expandable dictionaries, this function throws an
+ internal error. */
+
+static struct dictionary *
+create_new_language_dictionary (struct multidictionary *mdict,
+ enum language language)
+{
+ struct dictionary *retval = nullptr;
+
+ /* We use the first dictionary entry to decide what create function
+ to call. Not optimal but sufficient. */
+ gdb_assert (mdict->dictionaries[0] != nullptr);
+ switch (mdict->dictionaries[0]->vector->type)
+ {
+ case DICT_HASHED:
+ case DICT_LINEAR:
+ internal_error (__FILE__, __LINE__,
+ _("create_new_language_dictionary: attempted to expand "
+ "non-expandable multidictionary"));
+
+ case DICT_HASHED_EXPANDABLE:
+ retval = dict_create_hashed_expandable (language);
+ break;
+
+ case DICT_LINEAR_EXPANDABLE:
+ retval = dict_create_linear_expandable (language);
+ break;
+ }
+
+ /* Grow the dictionary vector and save the new dictionary. */
+ mdict->dictionaries
+ = (struct dictionary **) xrealloc (mdict->dictionaries,
+ (++mdict->n_allocated_dictionaries
+ * sizeof (struct dictionary *)));
+ mdict->dictionaries[mdict->n_allocated_dictionaries - 1] = retval;
+
+ return retval;
+}
+
+/* See dictionary.h. */
+
+void
+mdict_add_symbol (struct multidictionary *mdict, struct symbol *sym)
+{
+ struct dictionary *dict
+ = find_language_dictionary (mdict, SYMBOL_LANGUAGE (sym));
+
+ if (dict == nullptr)
+ {
+ /* SYM is of a new language that we haven't previously seen.
+ Create a new dictionary for it. */
+ dict = create_new_language_dictionary (mdict, SYMBOL_LANGUAGE (sym));
+ }
+
+ dict_add_symbol (dict, sym);
+}
+
+/* See dictionary.h. */
+
+void
+mdict_add_pending (struct multidictionary *mdict,
+ const struct pending *symbol_list)
+{
+ std::unordered_map<enum language, std::vector<symbol *>> nsyms
+ = collate_pending_symbols_by_language (symbol_list);
+
+ for (const auto &pair : nsyms)
+ {
+ enum language language = pair.first;
+ std::vector<symbol *> symlist = pair.second;
+ struct dictionary *dict = find_language_dictionary (mdict, language);
+
+ if (dict == nullptr)
+ {
+ /* The language was not previously seen. Create a new dictionary
+ for it. */
+ dict = create_new_language_dictionary (mdict, language);
+ }
+
+ dict_add_pending_1 (dict, symlist);
+ }
+}
+
+/* See dictionary.h. */
+
+struct symbol *
+mdict_iterator_first (const multidictionary *mdict,
+ struct mdict_iterator *miterator)
+{
+ miterator->mdict = mdict;
+ miterator->current_idx = 0;
+
+ for (unsigned short idx = miterator->current_idx;
+ idx < mdict->n_allocated_dictionaries; ++idx)
+ {
+ struct symbol *result
+ = dict_iterator_first (mdict->dictionaries[idx], &miterator->iterator);
+
+ if (result != nullptr)
+ {
+ miterator->current_idx = idx;
+ return result;
+ }
+ }
+
+ return nullptr;
+}
+
+/* See dictionary.h. */
+
+struct symbol *
+mdict_iterator_next (struct mdict_iterator *miterator)
+{
+ struct symbol *result = dict_iterator_next (&miterator->iterator);
+
+ if (result != nullptr)
+ return result;
+
+ /* The current dictionary had no matches -- move to the next
+ dictionary, if any. */
+ for (unsigned short idx = ++miterator->current_idx;
+ idx < miterator->mdict->n_allocated_dictionaries; ++idx)
+ {
+ result
+ = dict_iterator_first (miterator->mdict->dictionaries[idx],
+ &miterator->iterator);
+ if (result != nullptr)
+ {
+ miterator->current_idx = idx;
+ return result;
+ }
+ }
+
+ return nullptr;
+}
+
+/* See dictionary.h. */
+
+struct symbol *
+mdict_iter_match_first (const struct multidictionary *mdict,
+ const lookup_name_info &name,
+ struct mdict_iterator *miterator)
+{
+ miterator->mdict = mdict;
+ miterator->current_idx = 0;
+
+ for (unsigned short idx = miterator->current_idx;
+ idx < mdict->n_allocated_dictionaries; ++idx)
+ {
+ struct symbol *result
+ = dict_iter_match_first (mdict->dictionaries[idx], name,
+ &miterator->iterator);
+
+ if (result != nullptr)
+ return result;
+ }
+
+ return nullptr;
+}
+
+/* See dictionary.h. */
+
+struct symbol *
+mdict_iter_match_next (const lookup_name_info &name,
+ struct mdict_iterator *miterator)
+{
+ /* Search the current dictionary. */
+ struct symbol *result = dict_iter_match_next (name, &miterator->iterator);
+
+ if (result != nullptr)
+ return result;
+
+ /* The current dictionary had no matches -- move to the next
+ dictionary, if any. */
+ for (unsigned short idx = ++miterator->current_idx;
+ idx < miterator->mdict->n_allocated_dictionaries; ++idx)
+ {
+ result
+ = dict_iter_match_first (miterator->mdict->dictionaries[idx],
+ name, &miterator->iterator);
+ if (result != nullptr)
+ {
+ miterator->current_idx = idx;
+ return result;
+ }
+ }
+
+ return nullptr;
+}
+
+/* See dictionary.h. */
+
+int
+mdict_size (const struct multidictionary *mdict)
+{
+ int size = 0;
+
+ for (unsigned short idx = 0; idx < mdict->n_allocated_dictionaries; ++idx)
+ size += dict_size (mdict->dictionaries[idx]);
+
+ return size;
+}
+
+/* See dictionary.h. */
+
+bool
+mdict_empty (const struct multidictionary *mdict)
+{
+ for (unsigned short idx = 0; idx < mdict->n_allocated_dictionaries; ++idx)
+ {
+ if (!dict_empty (mdict->dictionaries[idx]))
+ return false;
+ }
+
+ return true;
+}
diff --git a/gdb/dictionary.h b/gdb/dictionary.h
--- a/gdb/dictionary.h
+++ b/gdb/dictionary.h
@@ -113,6 +113,21 @@ struct dict_iterator
struct symbol *current;
};
+/* The multi-language dictionary iterator. Like dict_iterator above,
+ these contents should be considered private. */
+
+struct mdict_iterator
+{
+ /* The multidictionary with whcih this iterator is associated. */
+ const struct multidictionary *mdict;
+
+ /* The iterator used to iterate through individual dictionaries. */
+ struct dict_iterator iterator;
+
+ /* The current index of the dictionary being iterated over. */
+ unsigned short current_idx;
+};
+
/* Initialize ITERATOR to point at the first symbol in DICT, and
return that first symbol, or NULL if DICT is empty. */

View File

@ -1,644 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Fri, 11 Jan 2019 11:25:11 -0500
Subject:
gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-2of5.patch
;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.'
;; Keith Seitz, RHBZ#1560010.
gdb/23712: Use new multidictionary API
This patch builds on the previous by enabling the `new' multidictionary
API. A lot of the hunks are simply textual replacements of "dict_"
with "mdict_" and similar transformations.
A word of warning, even with the use of multidictionaries, the code
still does not satisfactorily fix the reported problems with gdb/23712
(or gdb/23010). We still have additional changes to make before that
happens.
gdb/ChangeLog:
PR gdb/23712
PR symtab/23010
* dictionary.h (struct dictionary): Replace declaration with
multidictionary.
(dict_create_hashed, dict_create_hashed_expandable)
(dict_create_linear, dict_create_linear_expandable)
(dict_free, dict_add_symbol, dict_add_pending, dict_empty)
(dict_iterator_first, dict_iterator_next, dict_iter_match_first)
(dict_iter_match_next, dict_size): Rename to "mdict_" versions
taking multidictionary argument.
[ALL_DICT_SYMBOLS]: Update for multidictionary.
* block.h (struct block) <dict>: Change to multidictionary
and rename `multidict'.
* block.c, buildsym.c, jit.c, mdebugread.c, objfiles.c,
symmisc.c: Update all dictionary references to multidictionary.
diff --git a/gdb/block.c b/gdb/block.c
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -387,9 +387,9 @@ block_global_block (const struct block *block)
zero/NULL. This is useful for creating "dummy" blocks that don't
correspond to actual source files.
- Warning: it sets the block's BLOCK_DICT to NULL, which isn't a
+ Warning: it sets the block's BLOCK_MULTIDICT to NULL, which isn't a
valid value. If you really don't want the block to have a
- dictionary, then you should subsequently set its BLOCK_DICT to
+ dictionary, then you should subsequently set its BLOCK_MULTIDICT to
dict_create_linear (obstack, NULL). */
struct block *
@@ -544,10 +544,11 @@ block_iterator_step (struct block_iterator *iterator, int first)
block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
iterator->which);
- sym = dict_iterator_first (BLOCK_DICT (block), &iterator->dict_iter);
+ sym = mdict_iterator_first (BLOCK_MULTIDICT (block),
+ &iterator->mdict_iter);
}
else
- sym = dict_iterator_next (&iterator->dict_iter);
+ sym = mdict_iterator_next (&iterator->mdict_iter);
if (sym != NULL)
return sym;
@@ -569,7 +570,7 @@ block_iterator_first (const struct block *block,
initialize_block_iterator (block, iterator);
if (iterator->which == FIRST_LOCAL_BLOCK)
- return dict_iterator_first (block->dict, &iterator->dict_iter);
+ return mdict_iterator_first (block->multidict, &iterator->mdict_iter);
return block_iterator_step (iterator, 1);
}
@@ -580,7 +581,7 @@ struct symbol *
block_iterator_next (struct block_iterator *iterator)
{
if (iterator->which == FIRST_LOCAL_BLOCK)
- return dict_iterator_next (&iterator->dict_iter);
+ return mdict_iterator_next (&iterator->mdict_iter);
return block_iterator_step (iterator, 0);
}
@@ -612,11 +613,11 @@ block_iter_match_step (struct block_iterator *iterator,
block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
iterator->which);
- sym = dict_iter_match_first (BLOCK_DICT (block), name,
- &iterator->dict_iter);
+ sym = mdict_iter_match_first (BLOCK_MULTIDICT (block), name,
+ &iterator->mdict_iter);
}
else
- sym = dict_iter_match_next (name, &iterator->dict_iter);
+ sym = mdict_iter_match_next (name, &iterator->mdict_iter);
if (sym != NULL)
return sym;
@@ -639,7 +640,8 @@ block_iter_match_first (const struct block *block,
initialize_block_iterator (block, iterator);
if (iterator->which == FIRST_LOCAL_BLOCK)
- return dict_iter_match_first (block->dict, name, &iterator->dict_iter);
+ return mdict_iter_match_first (block->multidict, name,
+ &iterator->mdict_iter);
return block_iter_match_step (iterator, name, 1);
}
@@ -651,7 +653,7 @@ block_iter_match_next (const lookup_name_info &name,
struct block_iterator *iterator)
{
if (iterator->which == FIRST_LOCAL_BLOCK)
- return dict_iter_match_next (name, &iterator->dict_iter);
+ return mdict_iter_match_next (name, &iterator->mdict_iter);
return block_iter_match_step (iterator, name, 0);
}
@@ -731,7 +733,7 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
const domain_enum domain)
{
struct symbol *sym, *other;
- struct dict_iterator dict_iter;
+ struct mdict_iterator mdict_iter;
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
@@ -740,9 +742,10 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
|| BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
other = NULL;
- for (sym = dict_iter_match_first (block->dict, lookup_name, &dict_iter);
+ for (sym
+ = mdict_iter_match_first (block->multidict, lookup_name, &mdict_iter);
sym != NULL;
- sym = dict_iter_match_next (lookup_name, &dict_iter))
+ sym = mdict_iter_match_next (lookup_name, &mdict_iter))
{
if (SYMBOL_DOMAIN (sym) == domain)
return sym;
diff --git a/gdb/block.h b/gdb/block.h
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -111,7 +111,7 @@ struct block
/* This is used to store the symbols in the block. */
- struct dictionary *dict;
+ struct multidictionary *multidict;
/* Contains information about namespace-related info relevant to this block:
using directives and the current namespace scope. */
@@ -143,7 +143,7 @@ struct global_block
#define BLOCK_END(bl) (bl)->endaddr
#define BLOCK_FUNCTION(bl) (bl)->function
#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
-#define BLOCK_DICT(bl) (bl)->dict
+#define BLOCK_MULTIDICT(bl) (bl)->multidict
#define BLOCK_NAMESPACE(bl) (bl)->namespace_info
/* Accessor for ranges field within block BL. */
@@ -298,9 +298,9 @@ struct block_iterator
enum block_enum which;
- /* The underlying dictionary iterator. */
+ /* The underlying multidictionary iterator. */
- struct dict_iterator dict_iter;
+ struct mdict_iterator mdict_iter;
};
/* Initialize ITERATOR to point at the first symbol in BLOCK, and
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -349,23 +349,21 @@ finish_block_internal (struct symbol *symbol,
if (symbol)
{
- BLOCK_DICT (block)
- = dict_create_linear (&objfile->objfile_obstack,
- buildsym_compunit->language, *listhead);
+ BLOCK_MULTIDICT (block)
+ = mdict_create_linear (&objfile->objfile_obstack, *listhead);
}
else
{
if (expandable)
{
- BLOCK_DICT (block)
- = dict_create_hashed_expandable (buildsym_compunit->language);
- dict_add_pending (BLOCK_DICT (block), *listhead);
+ BLOCK_MULTIDICT (block)
+ = mdict_create_hashed_expandable (buildsym_compunit->language);
+ mdict_add_pending (BLOCK_MULTIDICT (block), *listhead);
}
else
{
- BLOCK_DICT (block) =
- dict_create_hashed (&objfile->objfile_obstack,
- buildsym_compunit->language, *listhead);
+ BLOCK_MULTIDICT (block) =
+ mdict_create_hashed (&objfile->objfile_obstack, *listhead);
}
}
@@ -377,7 +375,7 @@ finish_block_internal (struct symbol *symbol,
if (symbol)
{
struct type *ftype = SYMBOL_TYPE (symbol);
- struct dict_iterator iter;
+ struct mdict_iterator miter;
SYMBOL_BLOCK_VALUE (symbol) = block;
BLOCK_FUNCTION (block) = symbol;
@@ -391,7 +389,7 @@ finish_block_internal (struct symbol *symbol,
/* Here we want to directly access the dictionary, because
we haven't fully initialized the block yet. */
- ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
+ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym)
{
if (SYMBOL_IS_ARGUMENT (sym))
nparams++;
@@ -405,7 +403,7 @@ finish_block_internal (struct symbol *symbol,
iparams = 0;
/* Here we want to directly access the dictionary, because
we haven't fully initialized the block yet. */
- ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
+ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym)
{
if (iparams == nparams)
break;
@@ -1448,7 +1446,7 @@ end_symtab_with_blockvector (struct block *static_block,
{
struct block *block = BLOCKVECTOR_BLOCK (blockvector, block_i);
struct symbol *sym;
- struct dict_iterator iter;
+ struct mdict_iterator miter;
/* Inlined functions may have symbols not in the global or
static symbol lists. */
@@ -1459,7 +1457,7 @@ end_symtab_with_blockvector (struct block *static_block,
/* Note that we only want to fix up symbols from the local
blocks, not blocks coming from included symtabs. That is why
we use ALL_DICT_SYMBOLS here and not ALL_BLOCK_SYMBOLS. */
- ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
+ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym)
if (symbol_symtab (sym) == NULL)
symbol_set_symtab (sym, symtab);
}
@@ -1598,7 +1596,7 @@ augment_type_symtab (void)
to the primary symtab. */
set_missing_symtab (file_symbols, cust);
- dict_add_pending (BLOCK_DICT (block), file_symbols);
+ mdict_add_pending (BLOCK_MULTIDICT (block), file_symbols);
}
if (global_symbols != NULL)
@@ -1609,7 +1607,7 @@ augment_type_symtab (void)
to the primary symtab. */
set_missing_symtab (global_symbols, cust);
- dict_add_pending (BLOCK_DICT (block), global_symbols);
+ mdict_add_pending (BLOCK_MULTIDICT (block), global_symbols);
}
reset_symtab_globals ();
diff --git a/gdb/dictionary.h b/gdb/dictionary.h
--- a/gdb/dictionary.h
+++ b/gdb/dictionary.h
@@ -25,10 +25,10 @@
#include "symfile.h"
-/* An opaque type for dictionaries; only dictionary.c should know
- about its innards. */
+/* An opaque type for multi-language dictionaries; only dictionary.c should
+ know about its innards. */
-struct dictionary;
+struct multidictionary;
/* Other types needed for declarations. */
@@ -38,65 +38,64 @@ struct pending;
struct language_defn;
/* The creation functions for various implementations of
- dictionaries. */
+ multi-language dictionaries. */
-/* Create a dictionary of symbols of language LANGUAGE implemented via
+/* Create a multi-language dictionary of symbols implemented via
a fixed-size hashtable. All memory it uses is allocated on
OBSTACK; the environment is initialized from SYMBOL_LIST. */
-extern struct dictionary *dict_create_hashed (struct obstack *obstack,
- enum language language,
- const struct pending
- *symbol_list);
+extern struct multidictionary *
+ mdict_create_hashed (struct obstack *obstack,
+ const struct pending *symbol_list);
-/* Create a dictionary of symbols of language LANGUAGE, implemented
- via a hashtable that grows as necessary. The dictionary is
- initially empty; to add symbols to it, call dict_add_symbol().
- Call dict_free() when you're done with it. */
+/* Create a multi-language dictionary of symbols, implemented
+ via a hashtable that grows as necessary. The initial dictionary of
+ LANGUAGE is empty; to add symbols to it, call mdict_add_symbol().
+ Call mdict_free() when you're done with it. */
-extern struct dictionary *
- dict_create_hashed_expandable (enum language language);
+extern struct multidictionary *
+ mdict_create_hashed_expandable (enum language language);
-/* Create a dictionary of symbols of language LANGUAGE, implemented
+/* Create a multi-language dictionary of symbols, implemented
via a fixed-size array. All memory it uses is allocated on
OBSTACK; the environment is initialized from the SYMBOL_LIST. The
symbols are ordered in the same order that they're found in
SYMBOL_LIST. */
-extern struct dictionary *dict_create_linear (struct obstack *obstack,
- enum language language,
- const struct pending
- *symbol_list);
+extern struct multidictionary *
+ mdict_create_linear (struct obstack *obstack,
+ const struct pending *symbol_list);
-/* Create a dictionary of symbols of language LANGUAGE, implemented
- via an array that grows as necessary. The dictionary is initially
- empty; to add symbols to it, call dict_add_symbol(). Call
- dict_free() when you're done with it. */
+/* Create a multi-language dictionary of symbols, implemented
+ via an array that grows as necessary. The multidictionary initially
+ contains a single empty dictionary of LANGUAGE; to add symbols to it,
+ call mdict_add_symbol(). Call mdict_free() when you're done with it. */
-extern struct dictionary *
- dict_create_linear_expandable (enum language language);
+extern struct multidictionary *
+ mdict_create_linear_expandable (enum language language);
-/* The functions providing the interface to dictionaries. Note that
- the most common parts of the interface, namely symbol lookup, are
- only provided via iterator functions. */
+/* The functions providing the interface to multi-language dictionaries.
+ Note that the most common parts of the interface, namely symbol lookup,
+ are only provided via iterator functions. */
-/* Free the memory used by a dictionary that's not on an obstack. (If
+/* Free the memory used by a multidictionary that's not on an obstack. (If
any.) */
-extern void dict_free (struct dictionary *dict);
+extern void mdict_free (struct multidictionary *mdict);
-/* Add a symbol to an expandable dictionary. */
+/* Add a symbol to an expandable multidictionary. */
-extern void dict_add_symbol (struct dictionary *dict, struct symbol *sym);
+extern void mdict_add_symbol (struct multidictionary *mdict,
+ struct symbol *sym);
-/* Utility to add a list of symbols to a dictionary. */
+/* Utility to add a list of symbols to a multidictionary. */
-extern void dict_add_pending (struct dictionary *dict,
- const struct pending *symbol_list);
+extern void mdict_add_pending (struct multidictionary *mdict,
+ const struct pending *symbol_list);
-/* Is the dictionary empty? */
+/* Is the multidictionary empty? */
-extern int dict_empty (struct dictionary *dict);
+extern int mdict_empty (struct multidictionary *mdict);
/* A type containing data that is used when iterating over all symbols
in a dictionary. Don't ever look at its innards; this type would
@@ -128,44 +127,46 @@ struct mdict_iterator
unsigned short current_idx;
};
-/* Initialize ITERATOR to point at the first symbol in DICT, and
- return that first symbol, or NULL if DICT is empty. */
+/* Initialize ITERATOR to point at the first symbol in MDICT, and
+ return that first symbol, or NULL if MDICT is empty. */
-extern struct symbol *dict_iterator_first (const struct dictionary *dict,
- struct dict_iterator *iterator);
+extern struct symbol *
+ mdict_iterator_first (const struct multidictionary *mdict,
+ struct mdict_iterator *miterator);
-/* Advance ITERATOR, and return the next symbol, or NULL if there are
+/* Advance MITERATOR, and return the next symbol, or NULL if there are
no more symbols. Don't call this if you've previously received
- NULL from dict_iterator_first or dict_iterator_next on this
+ NULL from mdict_iterator_first or mdict_iterator_next on this
iteration. */
-extern struct symbol *dict_iterator_next (struct dict_iterator *iterator);
+extern struct symbol *mdict_iterator_next (struct mdict_iterator *miterator);
-/* Initialize ITERATOR to point at the first symbol in DICT whose
+/* Initialize MITERATOR to point at the first symbol in MDICT whose
SYMBOL_SEARCH_NAME is NAME, as tested using COMPARE (which must use
the same conventions as strcmp_iw and be compatible with any
dictionary hashing function), and return that first symbol, or NULL
if there are no such symbols. */
-extern struct symbol *dict_iter_match_first (const struct dictionary *dict,
- const lookup_name_info &name,
- struct dict_iterator *iterator);
+extern struct symbol *
+ mdict_iter_match_first (const struct multidictionary *mdict,
+ const lookup_name_info &name,
+ struct mdict_iterator *miterator);
-/* Advance ITERATOR to point at the next symbol in DICT whose
+/* Advance MITERATOR to point at the next symbol in MDICT whose
SYMBOL_SEARCH_NAME is NAME, as tested using COMPARE (see
dict_iter_match_first), or NULL if there are no more such symbols.
Don't call this if you've previously received NULL from
- dict_iterator_match_first or dict_iterator_match_next on this
- iteration. And don't call it unless ITERATOR was created by a
- previous call to dict_iter_match_first with the same NAME and COMPARE. */
+ mdict_iterator_match_first or mdict_iterator_match_next on this
+ iteration. And don't call it unless MITERATOR was created by a
+ previous call to mdict_iter_match_first with the same NAME and COMPARE. */
-extern struct symbol *dict_iter_match_next (const lookup_name_info &name,
- struct dict_iterator *iterator);
+extern struct symbol *mdict_iter_match_next (const lookup_name_info &name,
+ struct mdict_iterator *miterator);
-/* Return some notion of the size of the dictionary: the number of
+/* Return some notion of the size of the multidictionary: the number of
symbols if we have that, the number of hash buckets otherwise. */
-extern int dict_size (const struct dictionary *dict);
+extern int mdict_size (const struct multidictionary *mdict);
/* Macro to loop through all symbols in a dictionary DICT, in no
particular order. ITER is a struct dict_iterator (NOTE: __not__ a
@@ -175,8 +176,8 @@ extern int dict_size (const struct dictionary *dict);
early by a break if you desire. */
#define ALL_DICT_SYMBOLS(dict, iter, sym) \
- for ((sym) = dict_iterator_first ((dict), &(iter)); \
+ for ((sym) = mdict_iterator_first ((dict), &(iter)); \
(sym); \
- (sym) = dict_iterator_next (&(iter)))
+ (sym) = mdict_iterator_next (&(iter)))
#endif /* DICTIONARY_H */
diff --git a/gdb/jit.c b/gdb/jit.c
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -651,14 +651,12 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
size_t blockvector_size;
CORE_ADDR begin, end;
struct blockvector *bv;
- enum language language;
actual_nblocks = FIRST_LOCAL_BLOCK + stab->nblocks;
cust = allocate_compunit_symtab (objfile, stab->file_name);
allocate_symtab (cust, stab->file_name);
add_compunit_symtab_to_objfile (cust);
- language = compunit_language (cust);
/* JIT compilers compile in memory. */
COMPUNIT_DIRNAME (cust) = NULL;
@@ -702,8 +700,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
TARGET_CHAR_BIT,
"void");
- BLOCK_DICT (new_block) = dict_create_linear (&objfile->objfile_obstack,
- language, NULL);
+ BLOCK_MULTIDICT (new_block)
+ = mdict_create_linear (&objfile->objfile_obstack, NULL);
/* The address range. */
BLOCK_START (new_block) = (CORE_ADDR) gdb_block_iter->begin;
BLOCK_END (new_block) = (CORE_ADDR) gdb_block_iter->end;
@@ -740,8 +738,8 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
new_block = (i == GLOBAL_BLOCK
? allocate_global_block (&objfile->objfile_obstack)
: allocate_block (&objfile->objfile_obstack));
- BLOCK_DICT (new_block) = dict_create_linear (&objfile->objfile_obstack,
- language, NULL);
+ BLOCK_MULTIDICT (new_block)
+ = mdict_create_linear (&objfile->objfile_obstack, NULL);
BLOCK_SUPERBLOCK (new_block) = block_iter;
block_iter = new_block;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4534,7 +4534,7 @@ static void
add_symbol (struct symbol *s, struct symtab *symtab, struct block *b)
{
symbol_set_symtab (s, symtab);
- dict_add_symbol (BLOCK_DICT (b), s);
+ mdict_add_symbol (BLOCK_MULTIDICT (b), s);
}
/* Add a new block B to a symtab S. */
@@ -4762,7 +4762,7 @@ new_bvect (int nblocks)
}
/* Allocate and zero a new block of language LANGUAGE, and set its
- BLOCK_DICT. If function is non-zero, assume the block is
+ BLOCK_MULTIDICT. If function is non-zero, assume the block is
associated to a function, and make sure that the symbols are stored
linearly; otherwise, store them hashed. */
@@ -4775,9 +4775,9 @@ new_block (enum block_type type, enum language language)
struct block *retval = XCNEW (struct block);
if (type == FUNCTION_BLOCK)
- BLOCK_DICT (retval) = dict_create_linear_expandable (language);
+ BLOCK_MULTIDICT (retval) = mdict_create_linear_expandable (language);
else
- BLOCK_DICT (retval) = dict_create_hashed_expandable (language);
+ BLOCK_MULTIDICT (retval) = mdict_create_hashed_expandable (language);
return retval;
}
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -813,40 +813,40 @@ objfile_relocate1 (struct objfile *objfile,
}
ALL_OBJFILE_COMPUNITS (objfile, cust)
- {
- const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
- int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
-
- if (BLOCKVECTOR_MAP (bv))
- addrmap_relocate (BLOCKVECTOR_MAP (bv),
- ANOFFSET (delta, block_line_section));
-
- for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
- {
- struct block *b;
- struct symbol *sym;
- struct dict_iterator iter;
-
- b = BLOCKVECTOR_BLOCK (bv, i);
- BLOCK_START (b) += ANOFFSET (delta, block_line_section);
- BLOCK_END (b) += ANOFFSET (delta, block_line_section);
-
- if (BLOCK_RANGES (b) != nullptr)
- for (int j = 0; j < BLOCK_NRANGES (b); j++)
+ {
+ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
+ int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
+
+ if (BLOCKVECTOR_MAP (bv))
+ addrmap_relocate (BLOCKVECTOR_MAP (bv),
+ ANOFFSET (delta, block_line_section));
+
+ for (int i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
+ {
+ struct block *b;
+ struct symbol *sym;
+ struct mdict_iterator miter;
+
+ b = BLOCKVECTOR_BLOCK (bv, i);
+ BLOCK_START (b) += ANOFFSET (delta, block_line_section);
+ BLOCK_END (b) += ANOFFSET (delta, block_line_section);
+
+ if (BLOCK_RANGES (b) != nullptr)
+ for (int j = 0; j < BLOCK_NRANGES (b); j++)
+ {
+ BLOCK_RANGE_START (b, j)
+ += ANOFFSET (delta, block_line_section);
+ BLOCK_RANGE_END (b, j) += ANOFFSET (delta, block_line_section);
+ }
+
+ /* We only want to iterate over the local symbols, not any
+ symbols in included symtabs. */
+ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (b), miter, sym)
{
- BLOCK_RANGE_START (b, j)
- += ANOFFSET (delta, block_line_section);
- BLOCK_RANGE_END (b, j) += ANOFFSET (delta, block_line_section);
+ relocate_one_symbol (sym, objfile, delta);
}
-
- /* We only want to iterate over the local symbols, not any
- symbols in included symtabs. */
- ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
- {
- relocate_one_symbol (sym, objfile, delta);
- }
- }
- }
+ }
+ }
}
/* Relocate isolated symbols. */
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -275,7 +275,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
struct objfile *objfile = SYMTAB_OBJFILE (symtab);
struct gdbarch *gdbarch = get_objfile_arch (objfile);
int i;
- struct dict_iterator iter;
+ struct mdict_iterator miter;
int len;
struct linetable *l;
const struct blockvector *bv;
@@ -331,7 +331,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
even if we're using a hashtable, but nothing else but this message
wants it. */
fprintf_filtered (outfile, ", %d syms/buckets in ",
- dict_size (BLOCK_DICT (b)));
+ mdict_size (BLOCK_MULTIDICT (b)));
fputs_filtered (paddress (gdbarch, BLOCK_START (b)), outfile);
fprintf_filtered (outfile, "..");
fputs_filtered (paddress (gdbarch, BLOCK_END (b)), outfile);
@@ -349,7 +349,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
/* Now print each symbol in this block (in no particular order, if
we're using a hashtable). Note that we only want this
block, not any blocks from included symtabs. */
- ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
+ ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (b), miter, sym)
{
TRY
{

View File

@ -1,232 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Fri, 11 Jan 2019 11:26:59 -0500
Subject:
gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-3of5.patch
;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.'
;; Keith Seitz, RHBZ#1560010.
gdb/23712: Cleanup/Remove temporary dictionary functions
Now that multidictionary's are being used, there is no longer any need
to retain the four temporary functions introduced in the beginning of
this series.
This patch removes them.
As an additional cleanup, since the single-language dictionaries are
no longer used outside dictionary.c, make all of those functions
static.
gdb/ChangeLog:
PR gdb/23712
PR symtab/23010
* dictionary.c (pending_to_vector): Remove.
(dict_create_hashed_1, dict_create_linear_1, dict_add_pending_1):
Remove _1 suffix, replacing functions of the same name. Update
all callers.
(dict_create_hashed, dict_create_hashed_expandable)
(dict_create_linear, dict_create_linear_expandable, dict_free)
(dict_add_symbol, dict_add_pending, dict_size, dict_empty):
Make functions static.
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -342,31 +342,14 @@ static void insert_symbol_hashed (struct dictionary *dict,
static void expand_hashtable (struct dictionary *dict);
-/* A function to convert a linked list into a vector. */
-
-static std::vector<symbol *>
-pending_to_vector (const struct pending *symbol_list)
-{
- std::vector<symbol *> symlist;
-
- for (const struct pending *list_counter = symbol_list;
- list_counter != nullptr; list_counter = list_counter->next)
- {
- for (int i = list_counter->nsyms - 1; i >= 0; --i)
- symlist.push_back (list_counter->symbol[i]);
- }
-
- return symlist;
-}
-
/* The creation functions. */
-/* A function to transition dict_create_hashed to new API. */
+/* Create a hashed dictionary of a given language. */
static struct dictionary *
-dict_create_hashed_1 (struct obstack *obstack,
- enum language language,
- const std::vector<symbol *> &symbol_list)
+dict_create_hashed (struct obstack *obstack,
+ enum language language,
+ const std::vector<symbol *> &symbol_list)
{
/* Allocate the dictionary. */
struct dictionary *retval = XOBNEW (obstack, struct dictionary);
@@ -388,21 +371,9 @@ dict_create_hashed_1 (struct obstack *obstack,
return retval;
}
-/* See dictionary.h. */
-
-struct dictionary *
-dict_create_hashed (struct obstack *obstack,
- enum language language,
- const struct pending *symbol_list)
-{
- std::vector<symbol *> symlist = pending_to_vector (symbol_list);
-
- return dict_create_hashed_1 (obstack, language, symlist);
-}
+/* Create an expandable hashed dictionary of a given language. */
-/* See dictionary.h. */
-
-extern struct dictionary *
+static struct dictionary *
dict_create_hashed_expandable (enum language language)
{
struct dictionary *retval = XNEW (struct dictionary);
@@ -417,12 +388,12 @@ dict_create_hashed_expandable (enum language language)
return retval;
}
-/* A function to transition dict_create_linear to new API. */
+/* Create a linear dictionary of a given language. */
static struct dictionary *
-dict_create_linear_1 (struct obstack *obstack,
- enum language language,
- const std::vector<symbol *> &symbol_list)
+dict_create_linear (struct obstack *obstack,
+ enum language language,
+ const std::vector<symbol *> &symbol_list)
{
struct dictionary *retval = XOBNEW (obstack, struct dictionary);
DICT_VECTOR (retval) = &dict_linear_vector;
@@ -442,21 +413,9 @@ dict_create_linear_1 (struct obstack *obstack,
return retval;
}
-/* See dictionary.h. */
-
-struct dictionary *
-dict_create_linear (struct obstack *obstack,
- enum language language,
- const struct pending *symbol_list)
-{
- std::vector<symbol *> symlist = pending_to_vector (symbol_list);
-
- return dict_create_linear_1 (obstack, language, symlist);
-}
-
-/* See dictionary.h. */
+/* Create an expandable linear dictionary of a given language. */
-struct dictionary *
+static struct dictionary *
dict_create_linear_expandable (enum language language)
{
struct dictionary *retval = XNEW (struct dictionary);
@@ -476,7 +435,7 @@ dict_create_linear_expandable (enum language language)
/* Free the memory used by a dictionary that's not on an obstack. (If
any.) */
-void
+static void
dict_free (struct dictionary *dict)
{
(DICT_VECTOR (dict))->free (dict);
@@ -484,34 +443,24 @@ dict_free (struct dictionary *dict)
/* Add SYM to DICT. DICT had better be expandable. */
-void
+static void
dict_add_symbol (struct dictionary *dict, struct symbol *sym)
{
(DICT_VECTOR (dict))->add_symbol (dict, sym);
}
-/* A function to transition dict_add_pending to new API. */
+/* Utility to add a list of symbols to a dictionary.
+ DICT must be an expandable dictionary. */
static void
-dict_add_pending_1 (struct dictionary *dict,
- const std::vector<symbol *> &symbol_list)
+dict_add_pending (struct dictionary *dict,
+ const std::vector<symbol *> &symbol_list)
{
/* Preserve ordering by reversing the list. */
for (auto sym = symbol_list.rbegin (); sym != symbol_list.rend (); ++sym)
dict_add_symbol (dict, *sym);
}
-/* Utility to add a list of symbols to a dictionary.
- DICT must be an expandable dictionary. */
-
-void
-dict_add_pending (struct dictionary *dict, const struct pending *symbol_list)
-{
- std::vector<symbol *> symlist = pending_to_vector (symbol_list);
-
- dict_add_pending_1 (dict, symlist);
-}
-
/* Initialize ITERATOR to point at the first symbol in DICT, and
return that first symbol, or NULL if DICT is empty. */
@@ -548,7 +497,7 @@ dict_iter_match_next (const lookup_name_info &name,
->iter_match_next (name, iterator);
}
-int
+static int
dict_size (const struct dictionary *dict)
{
return (DICT_VECTOR (dict))->size (dict);
@@ -560,7 +509,7 @@ dict_size (const struct dictionary *dict)
/* Test to see if DICT is empty. */
-int
+static int
dict_empty (struct dictionary *dict)
{
struct dict_iterator iter;
@@ -1019,7 +968,7 @@ mdict_create_hashed (struct obstack *obstack,
std::vector<symbol *> symlist = pair.second;
retval->dictionaries[idx++]
- = dict_create_hashed_1 (obstack, language, symlist);
+ = dict_create_hashed (obstack, language, symlist);
}
return retval;
@@ -1064,7 +1013,7 @@ mdict_create_linear (struct obstack *obstack,
std::vector<symbol *> symlist = pair.second;
retval->dictionaries[idx++]
- = dict_create_linear_1 (obstack, language, symlist);
+ = dict_create_linear (obstack, language, symlist);
}
return retval;
@@ -1210,7 +1159,7 @@ mdict_add_pending (struct multidictionary *mdict,
dict = create_new_language_dictionary (mdict, language);
}
- dict_add_pending_1 (dict, symlist);
+ dict_add_pending (dict, symlist);
}
}

View File

@ -1,90 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Fri, 11 Jan 2019 11:29:25 -0500
Subject:
gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-4of5.patch
;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.'
;; Keith Seitz, RHBZ#1560010.
gdb/23712: Remove dw2_add_symbol_to_list
Finally, we can remove dw2_add_symbol_to_list since the wrapper function
originally introduced to catch this multi-language scenario is no longer
needed. With multi-language dictionaries, we can now support adding
symbols of multiple languages, negating the need for the assertion
entirely.
This patch should now fix gdb/23712 (and symtab/23010). At least it will
if the NULL buildsym_compunit problem doesn't strike first (see gdb/23773).
gdb/ChangeLog:
PR gdb/23712
PR symtab/23010
* dwarf2read.c (dw2_add_symbol_to_list): Remove.
(fixup_go_packaging, new_symbol): Use add_symbol_to_list.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9715,23 +9715,6 @@ compute_delayed_physnames (struct dwarf2_cu *cu)
cu->method_list.clear ();
}
-/* A wrapper for add_symbol_to_list to ensure that SYMBOL's language is
- the same as all other symbols in LISTHEAD. If a new symbol is added
- with a different language, this function asserts. */
-
-static inline void
-dw2_add_symbol_to_list (struct symbol *symbol, struct pending **listhead)
-{
- /* Only assert if LISTHEAD already contains symbols of a different
- language (dict_create_hashed/insert_symbol_hashed requires that all
- symbols in this list are of the same language). */
- gdb_assert ((*listhead) == NULL
- || (SYMBOL_LANGUAGE ((*listhead)->symbol[0])
- == SYMBOL_LANGUAGE (symbol)));
-
- add_symbol_to_list (symbol, listhead);
-}
-
/* Go objects should be embedded in a DW_TAG_module DIE,
and it's not clear if/how imported objects will appear.
To keep Go support simple until that's worked out,
@@ -9803,7 +9786,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
SYMBOL_TYPE (sym) = type;
- dw2_add_symbol_to_list (sym, &global_symbols);
+ add_symbol_to_list (sym, &global_symbols);
xfree (package_name);
}
@@ -21387,7 +21370,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_core_addr;
SYMBOL_DOMAIN (sym) = LABEL_DOMAIN;
SYMBOL_ACLASS_INDEX (sym) = LOC_LABEL;
- dw2_add_symbol_to_list (sym, cu->list_in_scope);
+ add_symbol_to_list (sym, cu->list_in_scope);
break;
case DW_TAG_subprogram:
/* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
@@ -21645,7 +21628,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
case DW_TAG_common_block:
SYMBOL_ACLASS_INDEX (sym) = LOC_COMMON_BLOCK;
SYMBOL_DOMAIN (sym) = COMMON_BLOCK_DOMAIN;
- dw2_add_symbol_to_list (sym, cu->list_in_scope);
+ add_symbol_to_list (sym, cu->list_in_scope);
break;
default:
/* Not a tag we recognize. Hopefully we aren't processing
@@ -21665,7 +21648,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
}
if (list_to_add != NULL)
- dw2_add_symbol_to_list (sym, list_to_add);
+ add_symbol_to_list (sym, list_to_add);
/* For the benefit of old versions of GCC, check for anonymous
namespaces based on the demangled name. */

View File

@ -1,183 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Fri, 11 Jan 2019 11:31:59 -0500
Subject:
gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-5of5.patch
;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.'
;; Keith Seitz, RHBZ#1560010.
gdb/23712: Test case for multidictionary
This is a test derived from one of the reproducers in symtab/23010.
The DIE tree used here is typical of compilations with LTO, where an
artificial parent DIE of language C99 imports DIEs of other languages.
gdb/testsuite/ChangeLog:
PR gdb/23712
PR symtab/23010
* gdb.dwarf2/multidictionary.exp: New file.
diff --git a/gdb/testsuite/gdb.dwarf2/multidictionary.exp b/gdb/testsuite/gdb.dwarf2/multidictionary.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/multidictionary.exp
@@ -0,0 +1,157 @@
+# Copyright 2019 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/>.
+
+# A test of multi-language dictionaries, a solution to symtab/23010 et al.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF.
+if {![dwarf2_support]} {
+ return 0
+}
+
+standard_testfile main.c .S
+
+# Create the DWARF. This is derived from the reproducer in the bug
+# mentioned above. This DIE tree is typical of compilations wtih
+# LTO enabled.
+
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+ declare_labels D45d9 D5079 D5080 D50a9 D50af D5ab2 D5ac2 D5ace D5acf
+ declare_labels D2135f D2216a D22171 D226c4 D226ca D244ca \
+ D245da D245e6
+ declare_labels D41c21 D42025 D42045 D42038 D42045 D420b5
+
+ cu {} {
+ D45d9: compile_unit {
+ {language @DW_LANG_C_plus_plus}
+ {name "SerialPortUtils.cpp"}
+ } {
+ D5079: base_type {
+ {byte_size 1 sdata}
+ {encoding @DW_ATE_unsigned}
+ {name "char"}
+ }
+
+ D5080: const_type {
+ {type :$D5079}
+ }
+
+ D50a9: pointer_type {
+ {byte_size 4 sdata}
+ {type :$D5080}
+ }
+
+ D50af: const_type {
+ {type :$D50a9}
+ }
+
+ D5ab2: subprogram {
+ {external 1 flag}
+ {linkage_name "_Z18SerialSyncWriteStrPKc"}
+ } {
+ D5ac2: formal_parameter {
+ {name "msg"}
+ {type :$D50af}
+ }
+ D5ace: lexical_block {} {
+ D5acf: DW_TAG_variable {
+ {name "p"}
+ {type :$D50a9}
+ }
+ }
+ }
+ }
+ }
+
+ cu {} {
+ D2135f: compile_unit {
+ {language @DW_LANG_C_plus_plus}
+ {name "Main.cpp"}
+ } {
+ D2216a: base_type {
+ {byte_size 1 sdata}
+ {encoding @DW_ATE_unsigned_char}
+ {name "char"}
+ }
+
+ D22171: const_type {
+ {type :$D2216a}
+ }
+
+ D226c4: pointer_type {
+ {byte_size 4 sdata}
+ {type :$D22171}
+ }
+
+ D226ca: const_type {
+ {type :$D226c4}
+ }
+
+ D245da: subprogram {
+ {name "PrintPanicMsg"}
+ } {
+ D245e6: formal_parameter {
+ {name "msg"}
+ {type :$D226ca}
+ }
+ }
+ }
+ }
+
+ cu {} {
+ D41c21: compile_unit {
+ {language @DW_LANG_C99}
+ {name "<artificial>"}
+ } {
+ D42025: subprogram {
+ {abstract_origin %$D245da}
+ {low_pc 0x80b60 addr}
+ {high_pc 0x6c data4}
+ } {
+ D42038: formal_parameter {
+ {abstract_origin %$D245e6}
+ }
+
+ D42045: inlined_subroutine {
+ {abstract_origin %$D5ab2}
+ {low_pc 0x8060 addr}
+ {high_pc 0xc data4}
+ } {
+ D420b5: formal_parameter {
+ {abstract_origin %$D5ac2}
+ }
+ }
+ }
+ }
+ }
+}
+
+# Build the test executable.
+if {[build_executable $testfile.exp $testfile [list $asm_file $srcfile] {}] \
+ == -1} {
+ return -1
+}
+
+# We force the DIEs above to be read in via "-readnow".
+gdb_spawn_with_cmdline_opts "-readnow"
+gdb_load $binfile
+
+# All we need to do is check whether GDB is alive. Without
+# multidictionaries, it will either crash, assert, or throw an
+# internal_error.
+gdb_test "p 1" "= 1" "GDB is alive"
+

File diff suppressed because it is too large Load Diff

View File

@ -62,7 +62,7 @@ Content-Disposition: attachment; filename=bitpos-ensure-size_t.patch
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -413,6 +413,13 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -414,6 +414,13 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
accumulate_size = 0;
else
accumulate_size -= sizeof(arg_reg_buffer);
@ -90,7 +90,7 @@ diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
diff --git a/gdb/defs.h b/gdb/defs.h
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -665,4 +665,6 @@ DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
@@ -669,4 +669,6 @@ DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
#include "utils.h"
@ -100,7 +100,7 @@ diff --git a/gdb/defs.h b/gdb/defs.h
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -773,6 +773,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
@@ -775,6 +775,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
if (boffset < 0 || boffset >= TYPE_LENGTH (type))
{
@ -111,7 +111,7 @@ diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
diff --git a/gdb/utils.c b/gdb/utils.c
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2834,6 +2834,17 @@ string_to_core_addr (const char *my_string)
@@ -2957,6 +2957,17 @@ string_to_core_addr (const char *my_string)
return addr;
}
@ -132,7 +132,7 @@ diff --git a/gdb/utils.c b/gdb/utils.c
diff --git a/gdb/valops.c b/gdb/valops.c
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -2088,6 +2088,7 @@ search_struct_method (const char *name, struct value **arg1p,
@@ -2064,6 +2064,7 @@ search_struct_method (const char *name, struct value **arg1p,
{
CORE_ADDR address;
@ -160,7 +160,7 @@ diff --git a/gdb/value.c b/gdb/value.c
if (!val->contents)
{
check_type_length_before_alloc (val->enclosing_type);
@@ -2876,6 +2879,7 @@ set_value_enclosing_type (struct value *val, struct type *new_encl_type)
@@ -2874,6 +2877,7 @@ set_value_enclosing_type (struct value *val, struct type *new_encl_type)
if (TYPE_LENGTH (new_encl_type) > TYPE_LENGTH (value_enclosing_type (val)))
{
check_type_length_before_alloc (new_encl_type);
@ -171,7 +171,7 @@ diff --git a/gdb/value.c b/gdb/value.c
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
--- a/gdb/vax-tdep.c
+++ b/gdb/vax-tdep.c
@@ -218,6 +218,7 @@ vax_return_value (struct gdbarch *gdbarch, struct value *function,
@@ -219,6 +219,7 @@ vax_return_value (struct gdbarch *gdbarch, struct value *function,
ULONGEST addr;
regcache_raw_read_unsigned (regcache, VAX_R0_REGNUM, &addr);

View File

@ -154,7 +154,7 @@ diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
const struct target_desc *read_description () override;
@@ -1207,7 +1207,7 @@ arm_linux_nat_target::stopped_by_watchpoint ()
@@ -1203,7 +1203,7 @@ arm_linux_nat_target::stopped_by_watchpoint ()
bool
arm_linux_nat_target::watchpoint_addr_within_range (CORE_ADDR addr,
CORE_ADDR start,
@ -221,7 +221,7 @@ diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c
struct aarch64_debug_reg_state *state)
{
if (aarch64_point_is_aligned (1 /* is_watchpoint */ , addr, len))
@@ -722,14 +723,14 @@ aarch64_linux_set_debug_regs (struct aarch64_debug_reg_state *state,
@@ -742,14 +743,14 @@ aarch64_linux_any_set_debug_regs_state (aarch64_debug_reg_state *state,
void
aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state,
const char *func, CORE_ADDR addr,
@ -239,7 +239,7 @@ diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c
type == hw_write ? "hw-write-watchpoint"
: (type == hw_read ? "hw-read-watchpoint"
: (type == hw_access ? "hw-access-watchpoint"
@@ -812,7 +813,7 @@ aarch64_linux_get_debug_reg_capacity (int tid)
@@ -832,7 +833,7 @@ aarch64_linux_get_debug_reg_capacity (int tid)
ADDR and whose length is LEN in bytes. */
int
@ -260,7 +260,7 @@ diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h
struct aarch64_debug_reg_state *state);
void aarch64_linux_set_debug_regs (struct aarch64_debug_reg_state *state,
@@ -184,12 +184,12 @@ void aarch64_linux_set_debug_regs (struct aarch64_debug_reg_state *state,
@@ -189,12 +189,12 @@ bool aarch64_linux_any_set_debug_regs_state (aarch64_debug_reg_state *state,
void aarch64_show_debug_reg_state (struct aarch64_debug_reg_state *state,
const char *func, CORE_ADDR addr,
@ -274,11 +274,11 @@ diff --git a/gdb/nat/aarch64-linux-hw-point.h b/gdb/nat/aarch64-linux-hw-point.h
-int aarch64_linux_region_ok_for_watchpoint (CORE_ADDR addr, int len);
+int aarch64_linux_region_ok_for_watchpoint (CORE_ADDR addr, LONGEST len);
#endif /* AARCH64_LINUX_HW_POINT_H */
#endif /* NAT_AARCH64_LINUX_HW_POINT_H */
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -282,7 +282,7 @@ struct ppc_linux_nat_target final : public linux_nat_target
@@ -284,7 +284,7 @@ struct ppc_linux_nat_target final : public linux_nat_target
int remove_hw_breakpoint (struct gdbarch *, struct bp_target_info *)
override;
@ -287,7 +287,7 @@ diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
int insert_watchpoint (CORE_ADDR, int, enum target_hw_bp_type,
struct expression *) override;
@@ -300,9 +300,9 @@ struct ppc_linux_nat_target final : public linux_nat_target
@@ -302,9 +302,9 @@ struct ppc_linux_nat_target final : public linux_nat_target
bool stopped_data_address (CORE_ADDR *) override;
@ -299,7 +299,7 @@ diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
override;
int masked_watch_num_registers (CORE_ADDR, CORE_ADDR) override;
@@ -1659,11 +1659,11 @@ can_use_watchpoint_cond_accel (void)
@@ -2065,11 +2065,11 @@ can_use_watchpoint_cond_accel (void)
CONDITION_VALUE will hold the value which should be put in the
DVC register. */
static void
@ -314,7 +314,7 @@ diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
CORE_ADDR addr_end_data, addr_end_dvc;
/* The DVC register compares bytes within fixed-length windows which
@@ -1751,7 +1751,7 @@ num_memory_accesses (const std::vector<value_ref_ptr> &chain)
@@ -2157,7 +2157,7 @@ num_memory_accesses (const std::vector<value_ref_ptr> &chain)
of the constant. */
static int
check_condition (CORE_ADDR watch_addr, struct expression *cond,
@ -323,7 +323,7 @@ diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
{
int pc = 1, num_accesses_left, num_accesses_right;
struct value *left_val, *right_val;
@@ -1802,7 +1802,8 @@ check_condition (CORE_ADDR watch_addr, struct expression *cond,
@@ -2208,7 +2208,8 @@ check_condition (CORE_ADDR watch_addr, struct expression *cond,
the condition expression, thus only triggering the watchpoint when it is
true. */
bool
@ -333,7 +333,7 @@ diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
int rw,
struct expression *cond)
{
@@ -1820,7 +1821,7 @@ ppc_linux_nat_target::can_accel_watchpoint_condition (CORE_ADDR addr, int len,
@@ -2226,7 +2227,7 @@ ppc_linux_nat_target::can_accel_watchpoint_condition (CORE_ADDR addr, int len,
static void
create_watchpoint_request (struct ppc_hw_breakpoint *p, CORE_ADDR addr,
@ -342,7 +342,7 @@ diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
struct expression *cond, int insert)
{
if (len == 1
@@ -2086,7 +2087,7 @@ ppc_linux_nat_target::stopped_by_watchpoint ()
@@ -2492,7 +2493,7 @@ ppc_linux_nat_target::stopped_by_watchpoint ()
bool
ppc_linux_nat_target::watchpoint_addr_within_range (CORE_ADDR addr,
CORE_ADDR start,
@ -354,7 +354,7 @@ diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
diff --git a/gdb/procfs.c b/gdb/procfs.c
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -1561,7 +1561,7 @@ procfs_address_to_host_pointer (CORE_ADDR addr)
@@ -1546,7 +1546,7 @@ procfs_address_to_host_pointer (CORE_ADDR addr)
}
static int
@ -363,7 +363,7 @@ diff --git a/gdb/procfs.c b/gdb/procfs.c
{
struct {
procfs_ctl_t cmd;
@@ -3214,7 +3214,7 @@ procfs_target::pid_to_str (ptid_t ptid)
@@ -3238,7 +3238,7 @@ procfs_target::pid_to_exec_file (int pid)
/* Insert a watchpoint. */
static int
@ -375,7 +375,7 @@ diff --git a/gdb/procfs.c b/gdb/procfs.c
diff --git a/gdb/remote.c b/gdb/remote.c
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -454,7 +454,7 @@ public:
@@ -450,7 +450,7 @@ public:
bool stopped_data_address (CORE_ADDR *) override;
@ -384,16 +384,16 @@ diff --git a/gdb/remote.c b/gdb/remote.c
int can_use_hw_breakpoint (enum bptype, int, int) override;
@@ -10342,7 +10342,7 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
p = strchr (rs->buf, '\0');
@@ -10335,7 +10335,7 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
p = strchr (rs->buf.data (), '\0');
addr = remote_address_masked (addr);
p += hexnumstr (p, (ULONGEST) addr);
- xsnprintf (p, endbuf - p, ",%x", len);
+ xsnprintf (p, endbuf - p, ",%s", phex_nz (len, sizeof (len)));
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
@@ -10362,7 +10362,7 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
getpkt (&rs->buf, 0);
@@ -10355,7 +10355,7 @@ remote_target::insert_watchpoint (CORE_ADDR addr, int len,
bool
remote_target::watchpoint_addr_within_range (CORE_ADDR addr,
@ -402,14 +402,14 @@ diff --git a/gdb/remote.c b/gdb/remote.c
{
CORE_ADDR diff = remote_address_masked (addr - start);
@@ -10391,7 +10391,7 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len,
p = strchr (rs->buf, '\0');
@@ -10384,7 +10384,7 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len,
p = strchr (rs->buf.data (), '\0');
addr = remote_address_masked (addr);
p += hexnumstr (p, (ULONGEST) addr);
- xsnprintf (p, endbuf - p, ",%x", len);
+ xsnprintf (p, endbuf - p, ",%s", phex_nz (len, sizeof (len)));
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
getpkt (&rs->buf, 0);
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
--- a/gdb/s390-linux-nat.c
@ -420,15 +420,15 @@ diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
override;
- int region_ok_for_hw_watchpoint (CORE_ADDR, int) override;
+ int region_ok_for_hw_watchpoint (CORE_ADDR, LONGEST) override;
bool have_continuable_watchpoint () override { return true; }
bool stopped_by_watchpoint () override;
int insert_watchpoint (CORE_ADDR, int, enum target_hw_bp_type,
struct expression *) override;
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -38,9 +38,9 @@ struct dummy_target : public target_ops
int have_steppable_watchpoint () override;
bool have_continuable_watchpoint () override;
@@ -37,9 +37,9 @@ struct dummy_target : public target_ops
bool stopped_by_watchpoint () override;
bool have_steppable_watchpoint () override;
bool stopped_data_address (CORE_ADDR *arg0) override;
- bool watchpoint_addr_within_range (CORE_ADDR arg0, CORE_ADDR arg1, int arg2) override;
+ bool watchpoint_addr_within_range (CORE_ADDR arg0, CORE_ADDR arg1, LONGEST arg2) override;
@ -438,9 +438,9 @@ diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
int masked_watch_num_registers (CORE_ADDR arg0, CORE_ADDR arg1) override;
int can_do_single_step () override;
bool supports_terminal_ours () override;
@@ -206,9 +206,9 @@ struct debug_target : public target_ops
int have_steppable_watchpoint () override;
bool have_continuable_watchpoint () override;
@@ -204,9 +204,9 @@ struct debug_target : public target_ops
bool stopped_by_watchpoint () override;
bool have_steppable_watchpoint () override;
bool stopped_data_address (CORE_ADDR *arg0) override;
- bool watchpoint_addr_within_range (CORE_ADDR arg0, CORE_ADDR arg1, int arg2) override;
+ bool watchpoint_addr_within_range (CORE_ADDR arg0, CORE_ADDR arg1, LONGEST arg2) override;
@ -450,7 +450,7 @@ diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
int masked_watch_num_registers (CORE_ADDR arg0, CORE_ADDR arg1) override;
int can_do_single_step () override;
bool supports_terminal_ours () override;
@@ -1068,19 +1068,19 @@ debug_target::stopped_data_address (CORE_ADDR *arg0)
@@ -1041,19 +1041,19 @@ debug_target::stopped_data_address (CORE_ADDR *arg0)
}
bool
@ -473,7 +473,7 @@ diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
{
bool result;
fprintf_unfiltered (gdb_stdlog, "-> %s->watchpoint_addr_within_range (...)\n", this->beneath ()->shortname ());
@@ -1090,7 +1090,7 @@ debug_target::watchpoint_addr_within_range (CORE_ADDR arg0, CORE_ADDR arg1, int
@@ -1063,7 +1063,7 @@ debug_target::watchpoint_addr_within_range (CORE_ADDR arg0, CORE_ADDR arg1, int
fputs_unfiltered (", ", gdb_stdlog);
target_debug_print_CORE_ADDR (arg1);
fputs_unfiltered (", ", gdb_stdlog);
@ -482,7 +482,7 @@ diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
fputs_unfiltered (") = ", gdb_stdlog);
target_debug_print_bool (result);
fputs_unfiltered ("\n", gdb_stdlog);
@@ -1126,19 +1126,19 @@ debug_target::region_ok_for_hw_watchpoint (CORE_ADDR arg0, LONGEST arg1)
@@ -1099,19 +1099,19 @@ debug_target::region_ok_for_hw_watchpoint (CORE_ADDR arg0, LONGEST arg1)
}
bool
@ -505,7 +505,7 @@ diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
{
bool result;
fprintf_unfiltered (gdb_stdlog, "-> %s->can_accel_watchpoint_condition (...)\n", this->beneath ()->shortname ());
@@ -1146,7 +1146,7 @@ debug_target::can_accel_watchpoint_condition (CORE_ADDR arg0, int arg1, int arg2
@@ -1119,7 +1119,7 @@ debug_target::can_accel_watchpoint_condition (CORE_ADDR arg0, int arg1, int arg2
fprintf_unfiltered (gdb_stdlog, "<- %s->can_accel_watchpoint_condition (", this->beneath ()->shortname ());
target_debug_print_CORE_ADDR (arg0);
fputs_unfiltered (", ", gdb_stdlog);
@ -517,7 +517,7 @@ diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
diff --git a/gdb/target.c b/gdb/target.c
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -56,7 +56,7 @@ static void generic_tls_error (void) ATTRIBUTE_NORETURN;
@@ -55,7 +55,7 @@ static void generic_tls_error (void) ATTRIBUTE_NORETURN;
static void default_terminal_info (struct target_ops *, const char *, int);
static int default_watchpoint_addr_within_range (struct target_ops *,
@ -526,7 +526,7 @@ diff --git a/gdb/target.c b/gdb/target.c
static int default_region_ok_for_hw_watchpoint (struct target_ops *,
CORE_ADDR, LONGEST);
@@ -3189,7 +3189,7 @@ default_region_ok_for_hw_watchpoint (struct target_ops *self,
@@ -3111,7 +3111,7 @@ default_region_ok_for_hw_watchpoint (struct target_ops *self,
static int
default_watchpoint_addr_within_range (struct target_ops *target,
CORE_ADDR addr,
@ -538,7 +538,7 @@ diff --git a/gdb/target.c b/gdb/target.c
diff --git a/gdb/target.h b/gdb/target.h
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -557,7 +557,7 @@ struct target_ops
@@ -561,7 +561,7 @@ struct target_ops
TARGET_DEFAULT_RETURN (false);
virtual bool stopped_data_address (CORE_ADDR *)
TARGET_DEFAULT_RETURN (false);
@ -547,7 +547,7 @@ diff --git a/gdb/target.h b/gdb/target.h
TARGET_DEFAULT_FUNC (default_watchpoint_addr_within_range);
/* Documentation of this routine is provided with the corresponding
@@ -565,7 +565,7 @@ struct target_ops
@@ -569,7 +569,7 @@ struct target_ops
virtual int region_ok_for_hw_watchpoint (CORE_ADDR, LONGEST)
TARGET_DEFAULT_FUNC (default_region_ok_for_hw_watchpoint);

View File

@ -147,12 +147,12 @@ Content-Disposition: attachment; filename=bitpos-tdep.patch
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -299,17 +299,17 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -300,17 +300,17 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
- int accumulate_size = struct_return ? 8 : 0;
+ ssize_t accumulate_size = struct_return ? 8 : 0;
- int accumulate_size = (return_method == return_method_struct) ? 8 : 0;
+ ssize_t accumulate_size = (return_method == return_method_struct) ? 8 : 0;
struct alpha_arg
{
const gdb_byte *contents;
@ -169,7 +169,7 @@ diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
CORE_ADDR func_addr = find_function_addr (function, NULL);
/* The ABI places the address of the called function in T12. */
@@ -429,8 +429,8 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -430,8 +430,8 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (i = nargs; m_arg--, --i >= 0;)
{
const gdb_byte *contents = m_arg->contents;
@ -180,7 +180,7 @@ diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
/* Copy the bytes destined for registers into arg_reg_buffer. */
if (offset < sizeof(arg_reg_buffer))
@@ -442,7 +442,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -443,7 +443,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
else
{
@ -192,7 +192,7 @@ diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -878,8 +878,8 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
@@ -883,8 +883,8 @@ amd64_push_arguments (struct regcache *regcache, int nargs, struct value **args,
};
struct value **stack_args = XALLOCAVEC (struct value *, nargs);
int num_stack_args = 0;
@ -203,7 +203,7 @@ diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
int integer_reg = 0;
int sse_reg = 0;
int i;
@@ -891,7 +891,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
@@ -896,7 +896,7 @@ if (return_method == return_method_struct)
for (i = 0; i < nargs; i++)
{
struct type *type = value_type (args[i]);
@ -212,7 +212,7 @@ diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
enum amd64_reg_class theclass[2];
int needed_integer_regs = 0;
int needed_sse_regs = 0;
@@ -955,7 +955,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
@@ -960,7 +960,7 @@ if (return_method == return_method_struct)
gdb_assert (regnum != -1);
memset (buf, 0, sizeof buf);
@ -236,7 +236,7 @@ diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3468,7 +3468,7 @@ arm_vfp_cprc_reg_char (enum arm_vfp_cprc_base_type b)
@@ -3472,7 +3472,7 @@ arm_vfp_cprc_reg_char (enum arm_vfp_cprc_base_type b)
array). Vector types are not currently supported, matching the
generic AAPCS support. */
@ -245,7 +245,7 @@ diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
arm_vfp_cprc_sub_candidate (struct type *t,
enum arm_vfp_cprc_base_type *base_type)
{
@@ -3551,7 +3551,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
@@ -3555,7 +3555,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
}
else
{
@ -254,7 +254,7 @@ diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
unsigned unitlen;
count = arm_vfp_cprc_sub_candidate (TYPE_TARGET_TYPE (t),
@@ -3574,12 +3574,12 @@ arm_vfp_cprc_sub_candidate (struct type *t,
@@ -3578,12 +3578,12 @@ arm_vfp_cprc_sub_candidate (struct type *t,
case TYPE_CODE_STRUCT:
{
@ -269,7 +269,7 @@ diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
if (!field_is_static (&TYPE_FIELD (t, i)))
sub_count = arm_vfp_cprc_sub_candidate (TYPE_FIELD_TYPE (t, i),
@@ -3603,13 +3603,15 @@ arm_vfp_cprc_sub_candidate (struct type *t,
@@ -3607,13 +3607,15 @@ arm_vfp_cprc_sub_candidate (struct type *t,
case TYPE_CODE_UNION:
{
@ -288,7 +288,7 @@ diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
if (sub_count == -1)
return -1;
count = (count > sub_count ? count : sub_count);
@@ -3645,7 +3647,7 @@ arm_vfp_call_candidate (struct type *t, enum arm_vfp_cprc_base_type *base_type,
@@ -3649,7 +3651,7 @@ arm_vfp_call_candidate (struct type *t, enum arm_vfp_cprc_base_type *base_type,
int *count)
{
enum arm_vfp_cprc_base_type b = VFP_CPRC_UNKNOWN;
@ -297,7 +297,7 @@ diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
if (c <= 0 || c > 4)
return 0;
*base_type = b;
@@ -3726,7 +3728,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -3731,7 +3733,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (argnum = 0; argnum < nargs; argnum++)
{
@ -325,7 +325,7 @@ diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
{
struct stack_item *si;
si = XNEW (struct stack_item);
@@ -1286,12 +1286,12 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -1287,12 +1287,12 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (i = 0; i < nargs; i++)
{
@ -357,8 +357,8 @@ diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
{
struct type *value_type = value_enclosing_type (args[i]);
struct type *arg_type = check_typedef (value_type);
- int container_len = (TYPE_LENGTH (value_type) + 3) & ~3;
+ ssize_t container_len = (TYPE_LENGTH (value_type) + 3) & ~3;
- int container_len = (TYPE_LENGTH (arg_type) + 3) & ~3;
+ ssize_t container_len = (TYPE_LENGTH (arg_type) + 3) & ~3;
sp -= container_len;
write_memory (sp, value_contents (args[i]), container_len);
@ -381,7 +381,7 @@ diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
{
struct stack_item *si = XNEW (struct stack_item);
si->data = (gdb_byte *) xmalloc (len);
@@ -833,13 +833,13 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -832,13 +832,13 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (argnum = 0; argnum < nargs; argnum++)
{
@ -402,8 +402,8 @@ diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -637,7 +637,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int struct_return, CORE_ADDR struct_addr)
@@ -638,7 +638,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
CORE_ADDR struct_addr)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- int stack_alloc = 0, stack_offset = 0;
@ -411,7 +411,7 @@ diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
int wordsize = BINWORD (gdbarch);
int reg = E_ARG0_REGNUM;
int argument;
@@ -663,11 +663,11 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -664,11 +664,11 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (argument = 0; argument < nargs; argument++)
{
struct type *type = value_type (args[argument]);
@ -425,7 +425,7 @@ diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
/* Use std::vector here to get zero initialization. */
std::vector<gdb_byte> padded (padded_len);
@@ -696,7 +696,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -697,7 +697,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* Heavens to Betsy --- it's really going in registers!
Note that on the h8/300s, there are gaps between the
registers in the register file. */
@ -437,7 +437,7 @@ diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -984,7 +984,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -985,7 +985,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
struct value *arg = args[i];
struct type *type = value_type (arg);
@ -446,7 +446,7 @@ diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
const bfd_byte *valbuf;
bfd_byte fptrbuf[8];
int regnum;
@@ -1177,7 +1177,7 @@ hppa64_return_value (struct gdbarch *gdbarch, struct value *function,
@@ -1178,7 +1178,7 @@ hppa64_return_value (struct gdbarch *gdbarch, struct value *function,
struct type *type, struct regcache *regcache,
gdb_byte *readbuf, const gdb_byte *writebuf)
{
@ -458,7 +458,7 @@ diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
--- a/gdb/i386-darwin-tdep.c
+++ b/gdb/i386-darwin-tdep.c
@@ -166,7 +166,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -167,7 +167,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (write_pass = 0; write_pass < 2; write_pass++)
{
@ -466,11 +466,11 @@ diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
+ LONGEST args_space = 0;
int num_m128 = 0;
if (struct_return)
if (return_method == return_method_struct)
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -2678,7 +2678,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -2679,7 +2679,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
gdb_byte buf[4];
int i;
int write_pass;
@ -479,16 +479,16 @@ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
/* BND registers can be in arbitrary values at the moment of the
inferior call. This can cause boundary violations that are not
@@ -2693,7 +2693,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -2694,7 +2694,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (write_pass = 0; write_pass < 2; write_pass++)
{
- int args_space_used = 0;
+ LONGEST args_space_used = 0;
if (struct_return)
if (return_method == return_method_struct)
{
@@ -2710,7 +2710,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -2711,7 +2711,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (i = 0; i < nargs; i++)
{
@ -497,7 +497,7 @@ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
if (write_pass)
{
@@ -2917,7 +2917,7 @@ i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
@@ -2918,7 +2918,7 @@ i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
enum type_code code = TYPE_CODE (type);
@ -506,7 +506,7 @@ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
gdb_assert (code == TYPE_CODE_STRUCT
|| code == TYPE_CODE_UNION
@@ -3703,7 +3703,7 @@ static int
@@ -3704,7 +3704,7 @@ static int
i386_convert_register_p (struct gdbarch *gdbarch,
int regnum, struct type *type)
{
@ -515,7 +515,7 @@ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
/* Values may be spread across multiple registers. Most debugging
formats aren't expressive enough to specify the locations, so
@@ -3736,7 +3736,7 @@ i386_register_to_value (struct frame_info *frame, int regnum,
@@ -3737,7 +3737,7 @@ i386_register_to_value (struct frame_info *frame, int regnum,
int *optimizedp, int *unavailablep)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
@ -524,7 +524,7 @@ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
if (i386_fp_regnum_p (gdbarch, regnum))
return i387_register_to_value (frame, regnum, type, to,
@@ -3772,7 +3772,7 @@ static void
@@ -3773,7 +3773,7 @@ static void
i386_value_to_register (struct frame_info *frame, int regnum,
struct type *type, const gdb_byte *from)
{
@ -536,7 +536,7 @@ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
--- a/gdb/iq2000-tdep.c
+++ b/gdb/iq2000-tdep.c
@@ -651,8 +651,9 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -652,8 +652,9 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
const bfd_byte *val;
bfd_byte buf[4];
struct type *type;
@ -572,7 +572,7 @@ diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
|| code == TYPE_CODE_COMPLEX);
@@ -504,9 +504,9 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -505,9 +505,9 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (i = nargs - 1; i >= 0; i--)
{
struct type *value_type = value_enclosing_type (args[i]);
@ -588,7 +588,7 @@ diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -2239,7 +2239,7 @@ push_large_arguments (CORE_ADDR sp, int argc, struct value **argv,
@@ -2238,7 +2238,7 @@ push_large_arguments (CORE_ADDR sp, int argc, struct value **argv,
for (i = 0; i < argc; i++)
{
@ -620,7 +620,7 @@ diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
if (mips_debug && out != NULL)
{
int i;
@@ -4543,13 +4543,13 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -4563,13 +4563,13 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
gdb_byte ref_valbuf[MAX_MIPS_ABI_REGSIZE];
struct value *arg = args[argnum];
struct type *arg_type = check_typedef (value_type (arg));
@ -637,7 +637,7 @@ diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
/* The EABI passes structures that do not fit in a register by
reference. */
@@ -4819,7 +4819,7 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct value *function,
@@ -4839,7 +4839,7 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct value *function,
static int
mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type,
@ -646,7 +646,7 @@ diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
{
int i;
@@ -4834,7 +4834,7 @@ mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type,
@@ -4854,7 +4854,7 @@ mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type,
for (i = 0; i < TYPE_NFIELDS (arg_type); i++)
{
@ -655,16 +655,29 @@ diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
struct type *field_type;
/* We're only looking at normal fields. */
@@ -4876,7 +4876,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -4897,7 +4897,8 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int argreg;
int float_argreg;
int argnum;
- int len = 0;
- int arg_space = 0;
+ ULONGEST arg_space = 0;
+ LONGEST len = 0;
int stack_offset = 0;
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr = find_function_addr (function, NULL);
@@ -5227,11 +5227,11 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
@@ -4926,9 +4927,9 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
if (mips_debug)
fprintf_unfiltered (gdb_stdlog,
- "mips_n32n64_push_dummy_call: sp=%s allocated %ld\n",
+ "mips_n32n64_push_dummy_call: sp=%s allocated %s\n",
paddress (gdbarch, sp),
- (long) align_up (arg_space, 16));
+ pulongest (align_up (arg_space, 16)));
/* Initialize the integer and float register pointers. */
argreg = MIPS_A0_REGNUM;
@@ -5249,11 +5250,11 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
: MIPS_V0_REGNUM);
field < TYPE_NFIELDS (type); field++, regnum += 2)
{
@ -680,7 +693,7 @@ diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
if (TYPE_LENGTH (TYPE_FIELD_TYPE (type, field)) == 16)
{
/* A 16-byte long double field goes in two consecutive
@@ -5273,8 +5273,8 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
@@ -5295,8 +5296,8 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
if (offset + xfer > TYPE_LENGTH (type))
xfer = TYPE_LENGTH (type) - offset;
if (mips_debug)
@ -691,16 +704,29 @@ diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
mips_xfer_register (gdbarch, regcache,
gdbarch_num_regs (gdbarch) + regnum,
xfer, BFD_ENDIAN_UNKNOWN, readbuf, writebuf,
@@ -5332,7 +5332,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -5355,7 +5356,8 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int argreg;
int float_argreg;
int argnum;
- int len = 0;
- int arg_space = 0;
+ ULONGEST arg_space = 0;
+ LONGEST len = 0;
int stack_offset = 0;
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr = find_function_addr (function, NULL);
@@ -5396,13 +5396,13 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -5392,9 +5394,9 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
if (mips_debug)
fprintf_unfiltered (gdb_stdlog,
- "mips_o32_push_dummy_call: sp=%s allocated %ld\n",
+ "mips_o32_push_dummy_call: sp=%s allocated %s\n",
paddress (gdbarch, sp),
- (long) align_up (arg_space, 16));
+ pulongest (align_up (arg_space, 16)));
/* Initialize the integer and float register pointers. */
argreg = MIPS_A0_REGNUM;
@@ -5420,13 +5422,13 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
const gdb_byte *val;
struct value *arg = args[argnum];
struct type *arg_type = check_typedef (value_type (arg));
@ -717,18 +743,30 @@ diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
val = value_contents (arg);
@@ -5856,8 +5856,8 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -5880,8 +5882,8 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int argreg;
int float_argreg;
int argnum;
- int len = 0;
- int arg_space = 0;
- int stack_offset = 0;
+ LONGEST len = 0;
+ ULONGEST arg_space = 0;
+ LONGEST stack_offset = 0;
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr = find_function_addr (function, NULL);
@@ -5917,13 +5917,13 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -5914,9 +5916,9 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
if (mips_debug)
fprintf_unfiltered (gdb_stdlog,
- "mips_o64_push_dummy_call: sp=%s allocated %ld\n",
+ "mips_o64_push_dummy_call: sp=%s allocated %s\n",
paddress (gdbarch, sp),
- (long) align_up (arg_space, 16));
+ pulongest (align_up (arg_space, 16)));
/* Initialize the integer and float register pointers. */
argreg = MIPS_A0_REGNUM;
@@ -5942,13 +5944,13 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
const gdb_byte *val;
struct value *arg = args[argnum];
struct type *arg_type = check_typedef (value_type (arg));
@ -760,7 +798,7 @@ diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -68,7 +68,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -69,7 +69,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int opencl_abi = ppc_sysv_use_opencl_abi (value_type (function));
ULONGEST saved_sp;
@ -769,7 +807,7 @@ diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
int write_pass;
gdb_assert (tdep->wordsize == 4);
@@ -99,9 +99,9 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -100,9 +100,9 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* Next available vector register for vector arguments. */
int vreg = 2;
/* Arguments start above the "LR save word" and "Back chain". */
@ -781,7 +819,7 @@ diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
/* If the function is returning a `struct', then the first word
(which will be passed in r3) is used for struct return
@@ -120,7 +120,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -121,7 +121,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
struct value *arg = args[argno];
struct type *type = check_typedef (value_type (arg));
@ -790,7 +828,7 @@ diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
const bfd_byte *val = value_contents (arg);
if (TYPE_CODE (type) == TYPE_CODE_FLT && len <= 8
@@ -1246,11 +1246,11 @@ struct ppc64_sysv_argpos
@@ -1247,11 +1247,11 @@ struct ppc64_sysv_argpos
static void
ppc64_sysv_abi_push_val (struct gdbarch *gdbarch,
@ -804,7 +842,7 @@ diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
/* Enforce alignment of stack location, if requested. */
if (align > tdep->wordsize)
@@ -1287,7 +1287,7 @@ ppc64_sysv_abi_push_val (struct gdbarch *gdbarch,
@@ -1288,7 +1288,7 @@ ppc64_sysv_abi_push_val (struct gdbarch *gdbarch,
{
if (argpos->regcache && argpos->greg <= 10)
argpos->regcache->cooked_write_part
@ -813,7 +851,7 @@ diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
argpos->greg++;
}
}
@@ -1346,7 +1346,7 @@ ppc64_sysv_abi_push_freg (struct gdbarch *gdbarch,
@@ -1347,7 +1347,7 @@ ppc64_sysv_abi_push_freg (struct gdbarch *gdbarch,
if (argpos->regcache && argpos->freg <= 13)
{
int regnum = tdep->ppc_fp0_regnum + argpos->freg;
@ -822,7 +860,7 @@ diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
offset = 8 - TYPE_LENGTH (type);
@@ -1795,7 +1795,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype,
@@ -1797,7 +1797,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype,
&& TYPE_CODE (valtype) == TYPE_CODE_DECFLOAT)
{
int regnum = tdep->ppc_fp0_regnum + 1 + index;
@ -831,7 +869,7 @@ diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
offset = 8 - TYPE_LENGTH (valtype);
@@ -1871,7 +1871,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype,
@@ -1873,7 +1873,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype,
&& TYPE_CODE (valtype) == TYPE_CODE_ARRAY && TYPE_VECTOR (valtype))
{
int regnum = tdep->ppc_gp0_regnum + 3 + index;
@ -840,7 +878,7 @@ diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
offset = 8 - TYPE_LENGTH (valtype);
@@ -1979,7 +1979,8 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
@@ -1981,7 +1981,8 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
&& TYPE_LENGTH (TYPE_TARGET_TYPE (valtype)) == 1)
{
int regnum = tdep->ppc_gp0_regnum + 3;
@ -853,7 +891,7 @@ diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -1346,8 +1346,8 @@ rl78_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -1347,8 +1347,8 @@ rl78_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (i = nargs - 1; i >= 0; i--)
{
struct type *value_type = value_enclosing_type (args[i]);
@ -867,7 +905,7 @@ diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -177,9 +177,9 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -291,9 +291,9 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int ii;
@ -879,7 +917,7 @@ diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
gdb_byte tmp_buffer[50];
int f_argno = 0; /* current floating point argno */
int wordsize = gdbarch_tdep (gdbarch)->wordsize;
@@ -307,7 +307,7 @@ ran_out_of_registers_for_arguments:
@@ -421,7 +421,7 @@ ran_out_of_registers_for_arguments:
if ((argno < nargs) || argbytes)
{
@ -891,7 +929,7 @@ diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -516,7 +516,7 @@ score_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -517,7 +517,7 @@ score_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argnum;
int argreg;
@ -931,7 +969,7 @@ diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
int pass_on_stack = 0;
int treat_as_flt;
int last_reg_arg = INT_MAX;
@@ -1215,7 +1216,8 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
@@ -1216,7 +1217,8 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
struct type *type;
CORE_ADDR regval;
const gdb_byte *val;
@ -944,7 +982,7 @@ diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -1205,7 +1205,7 @@ sparc64_16_byte_align_p (struct type *type)
@@ -1206,7 +1206,7 @@ sparc64_16_byte_align_p (struct type *type)
static void
sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
@ -953,7 +991,7 @@ diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
{
struct gdbarch *gdbarch = regcache->arch ();
int len = TYPE_LENGTH (type);
@@ -1265,7 +1265,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
@@ -1266,7 +1266,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
for (i = 0; i < TYPE_NFIELDS (type); i++)
{
struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
@ -962,7 +1000,7 @@ diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
sparc64_store_floating_fields (regcache, subtype, valbuf,
element, subpos);
@@ -1297,7 +1297,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
@@ -1298,7 +1298,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
static void
sparc64_extract_floating_fields (struct regcache *regcache, struct type *type,
@ -971,7 +1009,7 @@ diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
{
struct gdbarch *gdbarch = regcache->arch ();
@@ -1353,7 +1353,7 @@ sparc64_extract_floating_fields (struct regcache *regcache, struct type *type,
@@ -1354,7 +1354,7 @@ sparc64_extract_floating_fields (struct regcache *regcache, struct type *type,
for (i = 0; i < TYPE_NFIELDS (type); i++)
{
struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
@ -980,7 +1018,7 @@ diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
sparc64_extract_floating_fields (regcache, subtype, valbuf, subpos);
}
@@ -1386,7 +1386,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
@@ -1388,7 +1388,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
for (i = 0; i < nargs; i++)
{
struct type *type = value_type (args[i]);
@ -989,7 +1027,7 @@ diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
if (sparc64_structure_or_union_p (type)
|| (sparc64_complex_floating_p (type) && len == 32))
@@ -1486,7 +1486,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
@@ -1488,7 +1488,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
{
const gdb_byte *valbuf = value_contents (args[i]);
struct type *type = value_type (args[i]);
@ -1001,7 +1039,7 @@ diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -1431,7 +1431,7 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -1432,7 +1432,7 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
struct value *arg = args[i];
struct type *type = check_typedef (value_type (arg));
const gdb_byte *contents = value_contents (arg);
@ -1010,7 +1048,7 @@ diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
/* If the argument doesn't wholly fit into registers, it and
all subsequent arguments go to the stack. */
@@ -1463,7 +1463,7 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -1464,7 +1464,7 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
struct value *arg = args[i];
struct type *type = check_typedef (value_type (arg));
@ -1028,10 +1066,10 @@ diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
int stack_offset = 4;
- int references_offset = 4;
+ LONGEST references_offset = 4;
CORE_ADDR func_addr = find_function_addr (function, NULL);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct type *func_type = value_type (function);
@@ -915,7 +915,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* The first arg passed on stack. Mostly the first 10 args are passed by
@@ -914,7 +914,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* Now make space on the stack for the args. */
for (argnum = 0; argnum < nargs; argnum++)
{
@ -1040,7 +1078,7 @@ diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
if (argnum >= 10 - argreg)
references_offset += len;
stack_offset += len;
@@ -934,7 +934,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -933,7 +933,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
const gdb_byte *val;
struct value *arg = args[argnum];
struct type *arg_type = check_typedef (value_type (arg));
@ -1049,7 +1087,7 @@ diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
enum type_code typecode = TYPE_CODE (arg_type);
val = value_contents (arg);
@@ -1090,7 +1090,8 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
@@ -1088,7 +1088,8 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
else
internal_error (__FILE__, __LINE__,
@ -1074,16 +1112,17 @@ diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -1019,7 +1019,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
@@ -1019,7 +1019,8 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argreg;
int argnum;
- int len = 0;
- int arg_space = 0;
+ ULONGEST arg_space = 0;
+ LONGEST len = 0;
int stack_offset;
if (gdbarch_tdep (gdbarch)->abi == V850_ABI_RH850)
@@ -1047,7 +1047,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
@@ -1047,7 +1048,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
in four registers available. Loop thru args from first to last. */
for (argnum = 0; argnum < nargs; argnum++)
{
@ -1116,7 +1155,7 @@ diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -232,8 +232,9 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
@@ -233,8 +233,10 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR stack_dest = sp;
int argreg = E_1ST_ARG_REGNUM;
@ -1125,13 +1164,14 @@ diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
+ int i, slacklen;
+ LONGEST j;
+ LONGEST typelen;
const gdb_byte *val;
+ const gdb_byte *val;
gdb_byte buf[xstormy16_pc_size];
/* If returning a struct using target ABI method, then the struct return
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -1626,8 +1626,7 @@ xtensa_store_return_value (struct type *type,
@@ -1615,8 +1615,7 @@ xtensa_store_return_value (struct type *type,
if (len > (callsize > 8 ? 8 : 16))
internal_error (__FILE__, __LINE__,
@ -1141,11 +1181,12 @@ diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
areg = arreg_number (gdbarch,
gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
@@ -1701,18 +1700,18 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
@@ -1689,18 +1688,19 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
CORE_ADDR struct_addr)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
- int size, onstack_size;
+ int i;
+ LONGEST size, onstack_size;
gdb_byte *buf = (gdb_byte *) alloca (16);
CORE_ADDR ra, ps;
@ -1163,7 +1204,7 @@ diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
int regno; /* regno if in register. */
} u;
};
@@ -1736,9 +1735,10 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
@@ -1723,9 +1723,10 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
{
struct value *arg = args[i];
struct type *arg_type = check_typedef (value_type (arg));
@ -1177,7 +1218,7 @@ diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
switch (TYPE_CODE (arg_type))
{
case TYPE_CODE_INT:
@@ -1808,8 +1808,8 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
@@ -1794,8 +1795,8 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
info->align = TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
break;
}
@ -1187,7 +1228,7 @@ diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
/* Align size and onstack_size. */
size = (size + info->align - 1) & ~(info->align - 1);
@@ -1854,7 +1854,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
@@ -1840,7 +1841,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
if (info->onstack)
{
@ -1196,7 +1237,7 @@ diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
CORE_ADDR offset = sp + info->u.offset;
/* Odd-sized structs are aligned to the lower side of a memory
@@ -1870,7 +1870,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
@@ -1856,7 +1857,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
}
else
{

View File

@ -57,7 +57,7 @@ Content-Disposition: attachment; filename=f77-bounds.patch
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -47,9 +47,9 @@ struct common_block
@@ -50,9 +50,9 @@ struct common_block
struct symbol *contents[1];
};

View File

@ -0,0 +1,60 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Wed, 12 Sep 2018 00:02:17 -0400
Subject: gdb-rhbz795424-bitpos-arrayview.patch
;; This patch is needed to compile GDB after -Werror=narrowing has
;; been enabled by default.
;; Author: Sergio Durigan Junior.
diff --git a/gdb/common/array-view.h b/gdb/common/array-view.h
--- a/gdb/common/array-view.h
+++ b/gdb/common/array-view.h
@@ -85,7 +85,7 @@ public:
using value_type = T;
using reference = T &;
using const_reference = const T &;
- using size_type = size_t;
+ using size_type = ULONGEST;
/* Default construction creates an empty view. */
constexpr array_view () noexcept
@@ -114,7 +114,7 @@ public:
count. */
template<typename U,
typename = Requires<DecayedConvertible<U>>>
- constexpr array_view (U *array, size_t size) noexcept
+ constexpr array_view (U *array, ULONGEST size) noexcept
: m_array (array), m_size (size)
{}
@@ -128,7 +128,7 @@ public:
{}
/* Create an array view from an array. */
- template<typename U, size_t Size,
+ template<typename U, ULONGEST Size,
typename = Requires<DecayedConvertible<U>>>
constexpr array_view (U (&array)[Size]) noexcept
: m_array (array), m_size (Size)
@@ -161,9 +161,9 @@ public:
/*constexpr14*/ T *end () noexcept { return m_array + m_size; }
constexpr const T *end () const noexcept { return m_array + m_size; }
- /*constexpr14*/ reference operator[] (size_t index) noexcept
+ /*constexpr14*/ reference operator[] (ULONGEST index) noexcept
{ return m_array[index]; }
- constexpr const_reference operator[] (size_t index) const noexcept
+ constexpr const_reference operator[] (ULONGEST index) const noexcept
{ return m_array[index]; }
constexpr size_type size () const noexcept { return m_size; }
@@ -196,7 +196,7 @@ operator== (const gdb::array_view<T> &lhs, const gdb::array_view<T> &rhs)
if (lhs.size () != rhs.size ())
return false;
- for (size_t i = 0; i < lhs.size (); i++)
+ for (ULONGEST i = 0; i < lhs.size (); i++)
if (!(lhs[i] == rhs[i]))
return false;

File diff suppressed because it is too large Load Diff

View File

@ -1,54 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Mon, 30 Jul 2018 15:23:27 -0400
Subject: gdb-rhbz881849-ipv6-2of3.patch
Match any kind of error after "cannot resolve name" on lib/gdbserver-support.exp:gdbserver_start
On commit:
commit 7f1f7e23939adc7d71036a17fc6081e3af7ca585
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Fri Jul 13 16:20:34 2018 -0400
Expect for another variant of error message when gdbserver cannot resolve hostname
I extended the regular expression being used to identify whether
gdbserver could not resolve a (host)name. This was needed because the
error message being printed had a different variation across some
systems. However, as it turns out, I've just noticed that the message
has yet another variation:
target remote tcp8:123:2353
tcp8:123:2353: cannot resolve name: System error
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tcp8:123:2353: No such file or directory.
(gdb) FAIL: gdb.server/server-connect.exp: tcp8: connect to gdbserver using tcp8:123
which is causing FAILs on some systems (namely, Fedora-i686 on
BuildBot).
So instead of trying to predict everything that can be printed, I
decided to just match anything after the "cannot resolve name: " part.
This patch implements that.
Regression tested on the BuildBot.
gdb/testsuite/ChangeLog:
2018-07-30 Sergio Durigan Junior <sergiodj@redhat.com>
* lib/gdbserver-support.exp (gdbserver_start): Match any kind of
error after "cannot resolve name" string.
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -326,7 +326,7 @@ proc gdbserver_start { options arguments } {
continue
}
}
- -re ".*: cannot resolve name: Name or service not known\r\n" {
+ -re ".*: cannot resolve name: .*\r\n" {
error "gdbserver cannot resolve name."
}
timeout {

View File

@ -1,72 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Fri, 3 Aug 2018 18:04:38 -0400
Subject: gdb-rhbz881849-ipv6-3of3.patch
Fix thinko when deciding whether to disable TCP's Nagle algorithm
This patch fixes a thinko that happened when I was implementing the
IPv6 support on GDB/gdbserver. On certain situations, it is necessary
to disable TCP's Nagle algorithm (NODELAY). For obvious reasons, this
only applies when we are dealing with a TCP connection.
While implementing the IPv6 patch, I noticed that the net_open
function (on gdb/ser-tcp.c) kept a flag indicating whether the
connection type was UDP or TCP. I eliminated that flag, and started
using the 'struct addrinfo *' related to the successful connection
directly. However, I made a mistake:
if (success_ainfo->ai_socktype == IPPROTO_TCP)
^^^^^^^^^^^
{
/* Disable Nagle algorithm. Needed in some cases. */
int tmp = 1;
setsockopt (scb->fd, IPPROTO_TCP, TCP_NODELAY,
(char *) &tmp, sizeof (tmp));
}
The 'ai_socktype' field specifies the socket type (SOCK_STREAM or
SOCK_DGRAM), and not the protocol. This test was always failing, and
the Nagle algorithm was never being disabled.
The obvious fix is to use the 'ai_protocol' field. This is what this
patch does.
Huge "thank you" to Joel Brobecker who reported the regression (he was
experiencing an unusual delay while debugging a bare-metal program
running under QEMU) and helped me set up a proper reproducer for the
bug.
gdb/ChangeLog:
2018-08-03 Sergio Durigan Junior <sergiodj@redhat.com>
* ser-tcp.c (net_open): Fix thinko when deciding whether to
disable TCP's Nagle algorithm (use "ai_protocol" instead of
"ai_socktype").
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2018-08-03 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ * ser-tcp.c (net_open): Fix thinko when deciding whether to
+ disable TCP's Nagle algorithm (use "ai_protocol" instead of
+ "ai_socktype").
+
2018-09-05 Joel Brobecker <brobecker@adacore.com>
* version.in: Set GDB version number to 8.2.
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -367,7 +367,7 @@ net_open (struct serial *scb, const char *name)
ioctl (scb->fd, FIONBIO, &ioarg);
- if (success_ainfo->ai_socktype == IPPROTO_TCP)
+ if (success_ainfo->ai_protocol == IPPROTO_TCP)
{
/* Disable Nagle algorithm. Needed in some cases. */
int tmp = 1;

View File

@ -0,0 +1,97 @@
commit ed483764bd189d61714aa6b07104abe35469175a
Author: Tom de Vries <tdevries@suse.de>
Date: Fri May 10 18:46:28 2019 +0200
[gdb/symtab] Fix symbol loading performance regression
The commit "[gdb/symtab] Fix language of duplicate static minimal symbol"
introduces a performance regression, when loading a cc1 executable build with
-O0 -g and gcc 7.4.0. The performance regression, measured in 'real' time is
about 175%.
The slower execution comes from the fact that the fix in symbol_set_names
makes the call to symbol_find_demangled_name unconditional.
Fix this by reverting the commit, and redoing the fix as follows.
Recapturing the original problem, the first time symbol_set_names is called
with gsymbol.language == lang_auto and linkage_name == "_ZL3foov", the name is
not present in the per_bfd->demangled_names_hash hash table, so
symbol_find_demangled_name is called to demangle the name, after which the
mangled/demangled pair is added to the hashtable. The call to
symbol_find_demangled_name also sets gsymbol.language to lang_cplus.
The second time symbol_set_names is called with gsymbol.language == lang_auto
and linkage_name == "_ZL3foov", the name is present in the hash table, so the
demangled name from the hash table is used. However, the language of the
symbol remains lang_auto.
Fix this by adding a field language in struct demangled_name_entry, and using
the field in symbol_set_names to set the language of gsymbol, if necessary.
Tested on x86_64-linux.
gdb/ChangeLog:
2019-05-11 Tom de Vries <tdevries@suse.de>
PR symtab/24545
* symtab.c (struct demangled_name_entry): Add language field.
(symbol_set_names): Revert "[gdb/symtab] Fix language of duplicate
static minimal symbol". Set and use language field.
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 130d5cd48f..44964533ee 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -713,6 +713,7 @@ symbol_set_language (struct general_symbol_info *gsymbol,
struct demangled_name_entry
{
const char *mangled;
+ ENUM_BITFIELD(language) language : LANGUAGE_BITS;
char demangled[1];
};
@@ -853,11 +854,6 @@ symbol_set_names (struct general_symbol_info *gsymbol,
else
linkage_name_copy = linkage_name;
- /* Set the symbol language. */
- char *demangled_name_ptr
- = symbol_find_demangled_name (gsymbol, linkage_name_copy);
- gdb::unique_xmalloc_ptr<char> demangled_name (demangled_name_ptr);
-
entry.mangled = linkage_name_copy;
slot = ((struct demangled_name_entry **)
htab_find_slot (per_bfd->demangled_names_hash,
@@ -870,7 +866,9 @@ symbol_set_names (struct general_symbol_info *gsymbol,
|| (gsymbol->language == language_go
&& (*slot)->demangled[0] == '\0'))
{
- int demangled_len = demangled_name ? strlen (demangled_name.get ()) : 0;
+ char *demangled_name = symbol_find_demangled_name (gsymbol,
+ linkage_name_copy);
+ int demangled_len = demangled_name ? strlen (demangled_name) : 0;
/* Suppose we have demangled_name==NULL, copy_name==0, and
linkage_name_copy==linkage_name. In this case, we already have the
@@ -906,12 +904,19 @@ symbol_set_names (struct general_symbol_info *gsymbol,
strcpy (mangled_ptr, linkage_name_copy);
(*slot)->mangled = mangled_ptr;
}
+ (*slot)->language = gsymbol->language;
if (demangled_name != NULL)
- strcpy ((*slot)->demangled, demangled_name.get());
+ {
+ strcpy ((*slot)->demangled, demangled_name);
+ xfree (demangled_name);
+ }
else
(*slot)->demangled[0] = '\0';
}
+ else if (gsymbol->language == language_unknown
+ || gsymbol->language == language_auto)
+ gsymbol->language = (*slot)->language;
gsymbol->name = (*slot)->mangled;
if ((*slot)->demangled[0] != '\0')

View File

@ -1,44 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Thu, 6 Sep 2018 00:22:18 -0400
Subject: gdb-use-pulongest-aarch64-linux-tdep.patch
;; Use pulongest in aarch64-linux-tdep.c.
;; This patch was forgotten during the 8.2 release process, and is
;; needed to unbreak GDB when compiling on 32-bit arches.
Use pulongest in aarch64-linux-tdep.c
While testing a patch on the buildbot, I got this error:
../../binutils-gdb/gdb/aarch64-linux-tdep.c: In function uint64_t aarch64_linux_core_read_vq(gdbarch*, bfd*):
../../binutils-gdb/gdb/aarch64-linux-tdep.c:285:29: error: format %ld expects argument of type long int, but argument 2 has type uint64_t {aka long long unsigned int} [-Werror=format=]
This patch avoids the problem by using pulongest rather than %ld.
This seems safe to me because, if aarch64-linux-tdep.c is included in
the build, then ULONGEST must be a 64-bit type.
gdb/ChangeLog
2018-08-15 Tom Tromey <tom@tromey.com>
* aarch64-linux-tdep.c (aarch64_linux_core_read_vq): Use pulongest.
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -282,12 +282,13 @@ aarch64_linux_core_read_vq (struct gdbarch *gdbarch, bfd *abfd)
if (vq > AARCH64_MAX_SVE_VQ)
{
warning (_("SVE Vector length in core file not supported by this version"
- " of GDB. (VQ=%ld)"), vq);
+ " of GDB. (VQ=%s)"), pulongest (vq));
return 0;
}
else if (vq == 0)
{
- warning (_("SVE Vector length in core file is invalid. (VQ=%ld"), vq);
+ warning (_("SVE Vector length in core file is invalid. (VQ=%s"),
+ pulongest (vq));
return 0;
}

View File

@ -37,7 +37,7 @@ dbfd7140bf4c0500d1f5d192be781f83f78f7922
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -2600,11 +2600,14 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
@@ -2429,11 +2429,14 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
/* See dwarf2loc.h. */
int
@ -54,7 +54,7 @@ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
if (prop == NULL)
return 0;
@@ -2628,7 +2631,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
@@ -2457,7 +2460,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
*value = value_as_address (val);
}
@ -63,7 +63,7 @@ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
}
}
break;
@@ -2650,7 +2653,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
@@ -2479,7 +2482,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
if (!value_optimized_out (val))
{
*value = value_as_address (val);
@ -72,7 +72,7 @@ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
}
}
}
@@ -2658,8 +2661,8 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
@@ -2487,8 +2490,8 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
case PROP_CONST:
*value = prop->data.const_val;
@ -83,7 +83,7 @@ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
case PROP_ADDR_OFFSET:
{
struct dwarf2_property_baton *baton
@@ -2680,11 +2683,38 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
@@ -2509,11 +2512,38 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
val = value_at (baton->offset_info.type,
pinfo->addr + baton->offset_info.offset);
*value = value_as_address (val);
@ -143,7 +143,7 @@ diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -17566,7 +17566,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
@@ -17773,7 +17773,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
struct type *base_type, *orig_base_type;
struct type *range_type;
struct attribute *attr;
@ -152,7 +152,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
int low_default_is_valid;
int high_bound_is_count = 0;
const char *name;
@@ -17586,7 +17586,9 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
@@ -17793,7 +17793,9 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
low.kind = PROP_CONST;
high.kind = PROP_CONST;
@ -162,7 +162,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
/* Set LOW_DEFAULT_IS_VALID if current language and DWARF version allow
omitting DW_AT_lower_bound. */
@@ -17619,6 +17621,14 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
@@ -17826,6 +17828,14 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
break;
}
@ -177,7 +177,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
if (attr)
attr_to_dynamic_prop (attr, die, cu, &low);
@@ -17696,7 +17706,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
@@ -17918,7 +17928,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
&& !TYPE_UNSIGNED (base_type) && (high.data.const_val & negative_mask))
high.data.const_val |= negative_mask;
@ -189,7 +189,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
diff --git a/gdb/eval.c b/gdb/eval.c
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -377,29 +377,325 @@ init_array_element (struct value *array, struct value *element,
@@ -377,29 +377,324 @@ init_array_element (struct value *array, struct value *element,
return index;
}
@ -207,8 +207,7 @@ diff --git a/gdb/eval.c b/gdb/eval.c
+ int *pos, int nargs, enum noside noside)
{
- int pc = (*pos) + 1;
+ int i, dim_count = 0;
LONGEST low_bound, high_bound;
- LONGEST low_bound, high_bound;
- struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array)));
- enum range_type range_type
- = (enum range_type) longest_to_int (exp->elts[pc].longconst);
@ -219,11 +218,12 @@ diff --git a/gdb/eval.c b/gdb/eval.c
- low_bound = TYPE_LOW_BOUND (range);
- else
- low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+ int i, dim_count = 0;
+ struct value *new_array = array;
+ struct type *array_type = check_typedef (value_type (new_array));
+ struct type *elt_type;
+
+ typedef struct subscript_range
+ typedef struct
+ {
+ enum range_type f90_range_type;
+ LONGEST low, high, stride;
@ -272,11 +272,7 @@ diff --git a/gdb/eval.c b/gdb/eval.c
+ for (i = 0; i < nargs; i++)
+ {
+ struct subscript_store *index = &subscript_array[i];
- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
- high_bound = TYPE_HIGH_BOUND (range);
- else
- high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+
+ /* The user input is a range, with or without lower and upper bound.
+ E.g.: "p arry(2:5)", "p arry( :5)", "p arry( : )", etc. */
+ if (exp->elts[*pos].opcode == OP_RANGE)
@ -310,7 +306,11 @@ diff --git a/gdb/eval.c b/gdb/eval.c
+ /* Assign the default stride value '1'. */
+ else
+ range->stride = 1;
+
- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
- high_bound = TYPE_HIGH_BOUND (range);
- else
- high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
+ /* Check the provided stride value is illegal, aka '0'. */
+ if (range->stride == 0)
+ error (_("Stride must not be 0"));
@ -480,7 +480,8 @@ diff --git a/gdb/eval.c b/gdb/eval.c
+ struct value *v = NULL;
+
+ elt_type = TYPE_TARGET_TYPE (value_type (new_array));
+
- return value_slice (array, low_bound, high_bound - low_bound + 1);
+ /* Every SUBSCRIPT_RANGE in the user input signifies an actual range in
+ the output array. So we traverse the SUBSCRIPT_ARRAY again, looking
+ for a range entry. When we find one, we use the range info to create
@ -497,8 +498,7 @@ diff --git a/gdb/eval.c b/gdb/eval.c
+ struct type *range_type, *interim_array_type;
+
+ int new_length;
- return value_slice (array, low_bound, high_bound - low_bound + 1);
+
+ /* The length of a sub-dimension with all elements between the
+ bounds plus the start element itself. It may be modified by
+ a user provided stride value. */
@ -533,20 +533,54 @@ diff --git a/gdb/eval.c b/gdb/eval.c
}
@@ -1926,19 +2222,8 @@ evaluate_subexp_standard (struct type *expect_type,
@@ -1242,19 +1537,6 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos,
return eval_call (exp, noside, nargs, argvec, var_func_name, expect_type);
}
-/* Helper for skipping all the arguments in an undetermined argument list.
- This function was designed for use in the OP_F77_UNDETERMINED_ARGLIST
- case of evaluate_subexp_standard as multiple, but not all, code paths
- require a generic skip. */
-
-static void
-skip_undetermined_arglist (int nargs, struct expression *exp, int *pos,
- enum noside noside)
-{
- for (int i = 0; i < nargs; ++i)
- evaluate_subexp (NULL_TYPE, exp, pos, noside);
-}
-
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -1949,33 +2231,8 @@ evaluate_subexp_standard (struct type *expect_type,
switch (code)
{
case TYPE_CODE_ARRAY:
- if (exp->elts[*pos].opcode == OP_RANGE)
- return value_f90_subarray (arg1, exp, pos, noside);
- else
- goto multi_f77_subscript;
- {
- if (noside == EVAL_SKIP)
- {
- skip_undetermined_arglist (nargs, exp, pos, noside);
- /* Return the dummy value with the correct type. */
- return arg1;
- }
- goto multi_f77_subscript;
- }
-
case TYPE_CODE_STRING:
- if (exp->elts[*pos].opcode == OP_RANGE)
- return value_f90_subarray (arg1, exp, pos, noside);
- else
- {
- if (noside == EVAL_SKIP)
- {
- skip_undetermined_arglist (nargs, exp, pos, noside);
- /* Return the dummy value with the correct type. */
- return arg1;
- }
- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
- return value_subscript (arg1, value_as_long (arg2));
- }
@ -554,7 +588,7 @@ diff --git a/gdb/eval.c b/gdb/eval.c
case TYPE_CODE_PTR:
case TYPE_CODE_FUNC:
@@ -2334,49 +2619,6 @@ evaluate_subexp_standard (struct type *expect_type,
@@ -2372,49 +2629,6 @@ evaluate_subexp_standard (struct type *expect_type,
}
return (arg1);
@ -604,7 +638,7 @@ diff --git a/gdb/eval.c b/gdb/eval.c
case BINOP_LOGICAL_AND:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
@@ -3293,6 +3535,9 @@ calc_f77_array_dims (struct type *array_type)
@@ -3334,6 +3548,9 @@ calc_f77_array_dims (struct type *array_type)
int ndimen = 1;
struct type *tmp_type;
@ -639,7 +673,7 @@ diff --git a/gdb/expprint.c b/gdb/expprint.c
print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
fputs_filtered (")", stream);
return;
@@ -1098,22 +1095,24 @@ dump_subexp_body_standard (struct expression *exp,
@@ -1105,22 +1102,24 @@ dump_subexp_body_standard (struct expression *exp,
switch (range_type)
{
@ -672,7 +706,7 @@ diff --git a/gdb/expprint.c b/gdb/expprint.c
fputs_filtered ("ExclusiveRange 'EXP..EXP'", stream);
break;
default:
@@ -1121,11 +1120,9 @@ dump_subexp_body_standard (struct expression *exp,
@@ -1128,11 +1127,9 @@ dump_subexp_body_standard (struct expression *exp,
break;
}
@ -689,7 +723,7 @@ diff --git a/gdb/expprint.c b/gdb/expprint.c
diff --git a/gdb/expression.h b/gdb/expression.h
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -148,28 +148,27 @@ extern void dump_raw_expression (struct expression *,
@@ -150,28 +150,27 @@ extern void dump_raw_expression (struct expression *,
struct ui_file *, const char *);
extern void dump_prefix_expression (struct expression *, struct ui_file *);
@ -832,7 +866,7 @@ diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -902,7 +902,8 @@ operator== (const range_bounds &l, const range_bounds &r)
@@ -911,7 +911,8 @@ operator== (const range_bounds &l, const range_bounds &r)
struct type *
create_range_type (struct type *result_type, struct type *index_type,
const struct dynamic_prop *low_bound,
@ -842,7 +876,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
{
if (result_type == NULL)
result_type = alloc_type_copy (index_type);
@@ -917,6 +918,7 @@ create_range_type (struct type *result_type, struct type *index_type,
@@ -926,6 +927,7 @@ create_range_type (struct type *result_type, struct type *index_type,
TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
TYPE_RANGE_DATA (result_type)->low = *low_bound;
TYPE_RANGE_DATA (result_type)->high = *high_bound;
@ -850,7 +884,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
if (low_bound->kind == PROP_CONST && low_bound->data.const_val >= 0)
TYPE_UNSIGNED (result_type) = 1;
@@ -945,7 +947,7 @@ struct type *
@@ -954,7 +956,7 @@ struct type *
create_static_range_type (struct type *result_type, struct type *index_type,
LONGEST low_bound, LONGEST high_bound)
{
@ -859,7 +893,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
low.kind = PROP_CONST;
low.data.const_val = low_bound;
@@ -953,7 +955,11 @@ create_static_range_type (struct type *result_type, struct type *index_type,
@@ -962,7 +964,11 @@ create_static_range_type (struct type *result_type, struct type *index_type,
high.kind = PROP_CONST;
high.data.const_val = high_bound;
@ -872,7 +906,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
return result_type;
}
@@ -1171,16 +1177,20 @@ create_array_type_with_stride (struct type *result_type,
@@ -1180,16 +1186,20 @@ create_array_type_with_stride (struct type *result_type,
&& (!type_not_associated (result_type)
&& !type_not_allocated (result_type)))
{
@ -894,7 +928,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
else if (bit_stride > 0)
TYPE_LENGTH (result_type) =
(bit_stride * (high_bound - low_bound + 1) + 7) / 8;
@@ -1981,12 +1991,12 @@ resolve_dynamic_range (struct type *dyn_range_type,
@@ -1990,12 +2000,12 @@ resolve_dynamic_range (struct type *dyn_range_type,
CORE_ADDR value;
struct type *static_range_type, *static_target_type;
const struct dynamic_prop *prop;
@ -909,7 +943,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
{
low_bound.kind = PROP_CONST;
low_bound.data.const_val = value;
@@ -1998,7 +2008,7 @@ resolve_dynamic_range (struct type *dyn_range_type,
@@ -2007,7 +2017,7 @@ resolve_dynamic_range (struct type *dyn_range_type,
}
prop = &TYPE_RANGE_DATA (dyn_range_type)->high;
@ -918,7 +952,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
{
high_bound.kind = PROP_CONST;
high_bound.data.const_val = value;
@@ -2013,12 +2023,20 @@ resolve_dynamic_range (struct type *dyn_range_type,
@@ -2022,12 +2032,20 @@ resolve_dynamic_range (struct type *dyn_range_type,
high_bound.data.const_val = 0;
}
@ -943,7 +977,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -612,6 +612,10 @@ struct range_bounds
@@ -614,6 +614,10 @@ struct range_bounds
struct dynamic_prop high;
@ -954,7 +988,7 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
/* True if HIGH range bound contains the number of elements in the
subrange. This affects how the final hight bound is computed. */
@@ -776,7 +780,6 @@ struct main_type
@@ -778,7 +782,6 @@ struct main_type
/* * Union member used for range types. */
struct range_bounds *bounds;
@ -962,7 +996,7 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
} flds_bnds;
/* * Slot to point to additional language-specific fields of this
@@ -1329,6 +1332,15 @@ extern bool set_type_align (struct type *, ULONGEST);
@@ -1327,6 +1330,15 @@ extern bool set_type_align (struct type *, ULONGEST);
TYPE_RANGE_DATA(range_type)->high.kind
#define TYPE_LOW_BOUND_KIND(range_type) \
TYPE_RANGE_DATA(range_type)->low.kind
@ -978,7 +1012,7 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
/* Property accessors for the type data location. */
#define TYPE_DATA_LOCATION(thistype) \
@@ -1363,6 +1375,9 @@ extern bool set_type_align (struct type *, ULONGEST);
@@ -1361,6 +1373,9 @@ extern bool set_type_align (struct type *, ULONGEST);
TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
#define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
@ -988,7 +1022,7 @@ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
(TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
@@ -1892,6 +1907,7 @@ extern struct type *create_array_type_with_stride
@@ -1896,6 +1911,7 @@ extern struct type *create_array_type_with_stride
struct dynamic_prop *, unsigned int);
extern struct type *create_range_type (struct type *, struct type *,
@ -1038,7 +1072,7 @@ diff --git a/gdb/parse.c b/gdb/parse.c
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -2478,24 +2478,28 @@ convert_ast_to_expression (struct parser_state *state,
@@ -2475,24 +2475,28 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
case OP_RANGE:
{
@ -1047,13 +1081,13 @@ diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
if (operation->left.op != NULL)
{
convert_ast_to_expression (state, operation->left.op, top);
convert_ast_to_expression (operation->left.op, top);
- kind = HIGH_BOUND_DEFAULT;
+ kind = SUBARRAY_LOW_BOUND;
}
if (operation->right.op != NULL)
{
convert_ast_to_expression (state, operation->right.op, top);
convert_ast_to_expression (operation->right.op, top);
- if (kind == BOTH_BOUND_DEFAULT)
- kind = (operation->inclusive
- ? LOW_BOUND_DEFAULT : LOW_BOUND_DEFAULT_EXCLUSIVE);
@ -1078,7 +1112,7 @@ diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1149,13 +1149,11 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
@@ -1193,13 +1193,11 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst);
*pos += 3;
@ -1095,7 +1129,7 @@ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
if (noside == EVAL_SKIP)
return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
@@ -1244,7 +1242,7 @@ rust_compute_range (struct type *type, struct value *range,
@@ -1288,7 +1286,7 @@ rust_compute_range (struct type *type, struct value *range,
*low = 0;
*high = 0;
@ -1104,7 +1138,7 @@ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
if (TYPE_NFIELDS (type) == 0)
return;
@@ -1252,15 +1250,14 @@ rust_compute_range (struct type *type, struct value *range,
@@ -1296,15 +1294,14 @@ rust_compute_range (struct type *type, struct value *range,
i = 0;
if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0)
{
@ -1122,7 +1156,7 @@ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
*high = value_as_long (value_field (range, i));
if (rust_inclusive_range_type_p (type))
@@ -1278,7 +1275,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
@@ -1322,7 +1319,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
struct type *rhstype;
LONGEST low, high_bound;
/* Initialized to appease the compiler. */
@ -1131,7 +1165,7 @@ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
LONGEST high = 0;
int want_slice = 0;
@@ -1376,7 +1373,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
@@ -1420,7 +1417,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
error (_("Cannot subscript non-array type"));
if (want_slice
@ -1140,7 +1174,7 @@ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
low = low_bound;
if (low < 0)
error (_("Index less than zero"));
@@ -1394,7 +1391,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
@@ -1438,7 +1435,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
CORE_ADDR addr;
struct value *addrval, *tem;
@ -1761,7 +1795,7 @@ diff --git a/gdb/testsuite/gdb.fortran/vla.f90 b/gdb/testsuite/gdb.fortran/vla.f
diff --git a/gdb/valarith.c b/gdb/valarith.c
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -187,10 +187,16 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
@@ -187,11 +187,17 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
struct type *array_type = check_typedef (value_type (array));
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
ULONGEST elt_size = type_length_units (elt_type);
@ -1774,16 +1808,17 @@ diff --git a/gdb/valarith.c b/gdb/valarith.c
+ else
+ elt_offs *= elt_size;
if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
- && elt_offs >= type_length_units (array_type)))
+ && abs (elt_offs) >= type_length_units (array_type)))
if (index < lowerbound
|| (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
- && elt_offs >= type_length_units (array_type))
+ && abs (elt_offs) >= type_length_units (array_type))
|| (VALUE_LVAL (array) != lval_memory
&& TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)))
{
if (type_not_associated (array_type))
error (_("no such vector element (vector not associated)"));
diff --git a/gdb/valops.c b/gdb/valops.c
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3808,56 +3808,195 @@ value_of_this_silent (const struct language_defn *lang)
@@ -3792,56 +3792,195 @@ value_of_this_silent (const struct language_defn *lang)
struct value *
value_slice (struct value *array, int lowbound, int length)

View File

@ -33,7 +33,7 @@ git diff --stat -p gdb/master...gdb/users/bheckel/fortran-vla-strings
diff --git a/gdb/NEWS b/gdb/NEWS
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -109,6 +109,8 @@ SH-5/SH64 running OpenBSD SH-5/SH64 support in sh*-*-openbsd*
@@ -336,6 +336,8 @@ SH-5/SH64 running OpenBSD SH-5/SH64 support in sh*-*-openbsd*
*** Changes in GDB 8.1
@ -77,7 +77,7 @@ diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1789,7 +1789,8 @@ static void read_signatured_type (struct signatured_type *);
@@ -1833,7 +1833,8 @@ static void read_signatured_type (struct signatured_type *);
static int attr_to_dynamic_prop (const struct attribute *attr,
struct die_info *die, struct dwarf2_cu *cu,
@ -87,7 +87,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
/* memory allocation interface */
@@ -13648,7 +13649,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
@@ -13757,7 +13758,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
{
newobj->static_link
= XOBNEW (&objfile->objfile_obstack, struct dynamic_prop);
@ -95,8 +95,8 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
+ attr_to_dynamic_prop (attr, die, cu, newobj->static_link, NULL, 0);
}
cu->list_in_scope = &local_symbols;
@@ -16329,7 +16330,8 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
cu->list_in_scope = cu->get_builder ()->get_local_symbols ();
@@ -16516,7 +16517,8 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
byte_stride_prop
= (struct dynamic_prop *) alloca (sizeof (struct dynamic_prop));
@ -106,7 +106,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
if (!stride_ok)
{
complaint (_("unable to read array DW_AT_byte_stride "
@@ -17090,29 +17092,90 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
@@ -17277,29 +17279,90 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct type *type, *range_type, *index_type, *char_type;
struct attribute *attr;
@ -150,7 +150,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
+ operand. */
+ DW_OP_deref_size,
+ /* Operand for DW_OP_deref_size. */
+ DW_UNSND(byte_size) };
+ (gdb_byte) DW_UNSND(byte_size) };
+
+ if (!attr_to_dynamic_prop (attr, die, cu, &high, append_ops,
+ ARRAY_SIZE(append_ops)))
@ -208,7 +208,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
char_type = language_string_char_type (cu->language_defn, gdbarch);
type = create_string_type (NULL, char_type, range_type);
@@ -17460,7 +17523,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
@@ -17667,7 +17730,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
static int
attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
@ -218,7 +218,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
{
struct dwarf2_property_baton *baton;
struct obstack *obstack
@@ -17471,14 +17535,33 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
@@ -17678,14 +17742,33 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
if (attr_form_is_block (attr))
{
@ -256,7 +256,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
}
else if (attr_form_is_ref (attr))
{
@@ -17511,8 +17594,28 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
@@ -17718,8 +17801,28 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
baton = XOBNEW (obstack, struct dwarf2_property_baton);
baton->referenced_type = die_type (target_die, target_cu);
baton->locexpr.per_cu = cu->per_cu;
@ -287,7 +287,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
prop->data.baton = baton;
prop->kind = PROP_LOCEXPR;
gdb_assert (prop->data.baton != NULL);
@@ -17623,7 +17726,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
@@ -17830,7 +17933,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
if (attr)
@ -296,7 +296,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
complaint (_("Missing DW_AT_byte_stride "
"- DIE at 0x%s [in module %s]"),
sect_offset_str (die->sect_off),
@@ -17631,7 +17734,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
@@ -17838,7 +17941,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
if (attr)
@ -305,20 +305,20 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
else if (!low_default_is_valid)
complaint (_("Missing DW_AT_lower_bound "
"- DIE at %s [in module %s]"),
@@ -17639,10 +17742,10 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
objfile_name (cu->per_cu->dwarf2_per_objfile->objfile));
@@ -17847,10 +17950,10 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
struct attribute *attr_ub, *attr_count;
attr = attr_ub = dwarf2_attr (die, DW_AT_upper_bound, cu);
- if (!attr_to_dynamic_prop (attr, die, cu, &high))
+ if (!attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
{
attr = dwarf2_attr (die, DW_AT_count, cu);
attr = attr_count = dwarf2_attr (die, DW_AT_count, cu);
- if (attr_to_dynamic_prop (attr, die, cu, &high))
+ if (attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
{
/* If bounds are constant do the final calculation here. */
if (low.kind == PROP_CONST && high.kind == PROP_CONST)
@@ -25143,7 +25246,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
@@ -25417,7 +25520,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_allocated, cu);
if (attr_form_is_block (attr))
{
@ -327,7 +327,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
add_dyn_prop (DYN_PROP_ALLOCATED, prop, type);
}
else if (attr != NULL)
@@ -25157,7 +25260,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
@@ -25431,7 +25534,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_associated, cu);
if (attr_form_is_block (attr))
{
@ -336,7 +336,7 @@ diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
add_dyn_prop (DYN_PROP_ASSOCIATED, prop, type);
}
else if (attr != NULL)
@@ -25169,7 +25272,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
@@ -25443,7 +25546,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
/* Read DW_AT_data_location and set in type. */
attr = dwarf2_attr (die, DW_AT_data_location, cu);
@ -500,7 +500,7 @@ diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1904,7 +1904,8 @@ is_dynamic_type_internal (struct type *type, int top_level)
@@ -1913,7 +1913,8 @@ is_dynamic_type_internal (struct type *type, int top_level)
type = check_typedef (type);
/* We only want to recognize references at the outermost level. */
@ -510,7 +510,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
type = check_typedef (TYPE_TARGET_TYPE (type));
/* Types that have a dynamic TYPE_DATA_LOCATION are considered
@@ -1938,6 +1939,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
@@ -1947,6 +1948,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
}
case TYPE_CODE_ARRAY:
@ -518,7 +518,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
{
gdb_assert (TYPE_NFIELDS (type) == 1);
@@ -2056,7 +2058,8 @@ resolve_dynamic_array (struct type *type,
@@ -2065,7 +2067,8 @@ resolve_dynamic_array (struct type *type,
struct dynamic_prop *prop;
unsigned int bit_stride = 0;
@ -528,7 +528,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
type = copy_type (type);
@@ -2081,11 +2084,15 @@ resolve_dynamic_array (struct type *type,
@@ -2090,11 +2093,15 @@ resolve_dynamic_array (struct type *type,
ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
@ -545,7 +545,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
prop = get_dyn_prop (DYN_PROP_BYTE_STRIDE, type);
if (prop != NULL)
{
@@ -2240,6 +2247,28 @@ resolve_dynamic_struct (struct type *type,
@@ -2249,6 +2256,28 @@ resolve_dynamic_struct (struct type *type,
return resolved_type;
}
@ -574,7 +574,7 @@ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
/* Worker for resolved_dynamic_type. */
static struct type *
@@ -2288,7 +2317,12 @@ resolve_dynamic_type_internal (struct type *type,
@@ -2297,7 +2326,12 @@ resolve_dynamic_type_internal (struct type *type,
break;
}
@ -1306,7 +1306,7 @@ diff --git a/gdb/typeprint.c b/gdb/typeprint.c
diff --git a/gdb/valops.c b/gdb/valops.c
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1565,6 +1565,19 @@ value_ind (struct value *arg1)
@@ -1553,6 +1553,19 @@ value_ind (struct value *arg1)
if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
{
struct type *enc_type;
@ -1326,7 +1326,7 @@ diff --git a/gdb/valops.c b/gdb/valops.c
/* We may be pointing to something embedded in a larger object.
Get the real type of the enclosing object. */
@@ -1580,8 +1593,7 @@ value_ind (struct value *arg1)
@@ -1568,8 +1581,7 @@ value_ind (struct value *arg1)
else
/* Retrieve the enclosing object pointed to. */
arg2 = value_at_lazy (enc_type,

View File

@ -38,7 +38,7 @@ diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
#include "common/underlying.h"
#include "common/byte-vector.h"
@@ -2348,6 +2349,20 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
@@ -2158,6 +2159,20 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
ctx.per_cu = per_cu;
ctx.obj_address = 0;

View File

@ -0,0 +1,212 @@
commit 3f52fdbcb599f76b4838020721ca6c9f1cc28f84
Author: Kevin Buettner <kevinb@redhat.com>
Date: Sat Mar 16 12:40:01 2019 -0700
Fix amd64->i386 linux syscall restart problem
This commit fixes some failures in gdb.base/interrupt.exp
when debugging a 32-bit i386 linux inferior from an amd64 host.
When running the following test...
make check RUNTESTFLAGS="--target_board unix/-m32 interrupt.exp"
... without this commit, I see the following output:
FAIL: gdb.base/interrupt.exp: continue (the program exited)
FAIL: gdb.base/interrupt.exp: echo data
FAIL: gdb.base/interrupt.exp: Send Control-C, second time
FAIL: gdb.base/interrupt.exp: signal SIGINT (the program is no longer running)
ERROR: Undefined command "".
ERROR: GDB process no longer exists
=== gdb Summary ===
When the test is run with this commit in place, we see 12 passes
instead. This is the desired behavior.
Analysis:
On Linux, when a syscall is interrupted by a signal, the syscall
may return -ERESTARTSYS when a signal occurs. Doing so indicates that
the syscall is restartable. Then, depending on settings associated
with the signal handler, and after the signal handler is called, the
kernel can then either return -EINTR or can cause the syscall to be
restarted. In this discussion, we are concerned with the latter
case.
On i386, the kernel returns this status via the EAX register.
When debugging a 32-bit (i386) process from a 64-bit (amd64)
GDB, the debugger fetches 64-bit registers even though the
process being debugged is 32-bit. Since we're debugging a 32-bit
target, only 32 bits are being saved in the register cache.
Now, ideally, GDB would save all 64-bits in the regcache and
then would be able to restore those same values when it comes
time to continue the target. I've looked into doing this, but
it's not easy and I don't see many benefits to doing so. One
benefit, however, would be that EAX would appear as a negative
value for doing syscall restarts.
At the moment, GDB is setting the high 32 bits of RAX (and other
registers too) to 0. So, when GDB restores EAX just prior to
a syscall restart, the high 32 bits of RAX are zeroed, thus making
it look like a positive value. For this particular purpose, we
need to sign extend EAX so that RAX will appear as a negative
value when EAX is set to -ERESTARTSYS. This in turn will cause
the signal handling code in the kernel to recognize -ERESTARTSYS
which will in turn cause the syscall to be restarted.
This commit is based on work by Jan Kratochvil from 2009:
https://sourceware.org/ml/gdb-patches/2009-11/msg00592.html
Jan's patch had the sign extension code in amd64-nat.c. Several
other native targets make use of this code, so it seemed better
to move the sign extension code to a linux specific file. I
also added similar code to gdbserver.
Another approach is to fix the problem in the kernel. Hui Zhu
tried to get a fix into the kernel back in 2014, but it was not
accepted. Discussion regarding this approach may be found here:
https://lore.kernel.org/patchwork/patch/457841/
Even if a fix were to be put into the kernel, we'd still need
some kind of fix in GDB in order to support older kernels.
Finally, I'll note that Fedora has been carrying a similar patch for
at least nine years. Other distributions, including RHEL and CentOS
have picked up this change and have been using it too.
gdb/ChangeLog:
* amd64-linux-nat.c (amd64_linux_collect_native_gregset): New
function.
(fill_gregset): Call amd64_linux_collect_native_gregset instead
of amd64_collect_native_gregset.
(amd64_linux_nat_target::store_registers): Likewise.
gdb/gdbserver/ChangeLog:
* linux-x86-low.c (x86_fill_gregset): Sign extend EAX value
when using a 64-bit gdbserver.
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index a0bb105f5a..8d0e8eb35c 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -92,6 +92,71 @@ static int amd64_linux_gregset32_reg_offset[] =
/* Transfering the general-purpose registers between GDB, inferiors
and core files. */
+/* See amd64_collect_native_gregset. This linux specific version handles
+ issues with negative EAX values not being restored correctly upon syscall
+ return when debugging 32-bit targets. It has no effect on 64-bit
+ targets. */
+
+static void
+amd64_linux_collect_native_gregset (const struct regcache *regcache,
+ void *gregs, int regnum)
+{
+ amd64_collect_native_gregset (regcache, gregs, regnum);
+
+ struct gdbarch *gdbarch = regcache->arch ();
+ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
+ {
+ /* Sign extend EAX value to avoid potential syscall restart
+ problems.
+
+ On Linux, when a syscall is interrupted by a signal, the
+ (kernel function implementing the) syscall may return
+ -ERESTARTSYS when a signal occurs. Doing so indicates that
+ the syscall is restartable. Then, depending on settings
+ associated with the signal handler, and after the signal
+ handler is called, the kernel can then either return -EINTR
+ or it can cause the syscall to be restarted. We are
+ concerned with the latter case here.
+
+ On (32-bit) i386, the status (-ERESTARTSYS) is placed in the
+ EAX register. When debugging a 32-bit process from a 64-bit
+ (amd64) GDB, the debugger fetches 64-bit registers even
+ though the process being debugged is only 32-bit. The
+ register cache is only 32 bits wide though; GDB discards the
+ high 32 bits when placing 64-bit values in the 32-bit
+ regcache. Normally, this is not a problem since the 32-bit
+ process should only care about the lower 32-bit portions of
+ these registers. That said, it can happen that the 64-bit
+ value being restored will be different from the 64-bit value
+ that was originally retrieved from the kernel. The one place
+ (that we know of) where it does matter is in the kernel's
+ syscall restart code. The kernel's code for restarting a
+ syscall after a signal expects to see a negative value
+ (specifically -ERESTARTSYS) in the 64-bit RAX register in
+ order to correctly cause a syscall to be restarted.
+
+ The call to amd64_collect_native_gregset, above, is setting
+ the high 32 bits of RAX (and other registers too) to 0. For
+ syscall restart, we need to sign extend EAX so that RAX will
+ appear as a negative value when EAX is set to -ERESTARTSYS.
+ This in turn will cause the signal handling code in the
+ kernel to recognize -ERESTARTSYS which will in turn cause the
+ syscall to be restarted.
+
+ The test case gdb.base/interrupt.exp tests for this problem.
+ Without this sign extension code in place, it'll show
+ a number of failures when testing against unix/-m32. */
+
+ if (regnum == -1 || regnum == I386_EAX_REGNUM)
+ {
+ void *ptr = ((gdb_byte *) gregs
+ + amd64_linux_gregset32_reg_offset[I386_EAX_REGNUM]);
+
+ *(int64_t *) ptr = *(int32_t *) ptr;
+ }
+ }
+}
+
/* Fill GDB's register cache with the general-purpose register values
in *GREGSETP. */
@@ -109,7 +174,7 @@ void
fill_gregset (const struct regcache *regcache,
elf_gregset_t *gregsetp, int regnum)
{
- amd64_collect_native_gregset (regcache, gregsetp, regnum);
+ amd64_linux_collect_native_gregset (regcache, gregsetp, regnum);
}
/* Transfering floating-point registers between GDB, inferiors and cores. */
@@ -237,7 +302,7 @@ amd64_linux_nat_target::store_registers (struct regcache *regcache, int regnum)
if (ptrace (PTRACE_GETREGS, tid, 0, (long) &regs) < 0)
perror_with_name (_("Couldn't get registers"));
- amd64_collect_native_gregset (regcache, &regs, regnum);
+ amd64_linux_collect_native_gregset (regcache, &regs, regnum);
if (ptrace (PTRACE_SETREGS, tid, 0, (long) &regs) < 0)
perror_with_name (_("Couldn't write registers"));
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 029796e361..dd7673126e 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -338,6 +338,19 @@ x86_fill_gregset (struct regcache *regcache, void *buf)
collect_register_by_name (regcache, "orig_eax",
((char *) buf) + ORIG_EAX * REGSIZE);
+
+ /* Sign extend EAX value to avoid potential syscall restart
+ problems.
+
+ See amd64_linux_collect_native_gregset() in gdb/amd64-linux-nat.c
+ for a detailed explanation. */
+ if (register_size (regcache->tdesc, 0) == 4)
+ {
+ void *ptr = ((gdb_byte *) buf
+ + i386_regmap[find_regno (regcache->tdesc, "eax")]);
+
+ *(int64_t *) ptr = *(int32_t *) ptr;
+ }
}
static void

View File

@ -1,123 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-x86_64-i386-syscall-restart.patch
;; Fix syscall restarts for amd64->i386 biarch.
;;=push+jan
http://sourceware.org/ml/gdb-patches/2009-11/msg00592.html
Subject: [patch] Fix syscall restarts for amd64->i386 biarch
Hi,
tested only on recent Linux kernels, it should apply also on vanilla ones.
There were various changes of the kernels behavior in the past.
FSF GDB HEAD state:
kernel debugger inferior state
x86_64 x86_64 x86_64 PASS
x86_64 x86_64 i386 FAIL without this patch, PASS with this patch
x86_64 i386 i386 PASS on recent kernels
(FAIL: kernel-2.6.31.5-127.fc12.x86_64 - Fedora 12)
(PASS: kernel-2.6.32-0.55.rc8.git1.fc13.x86_64)
i386 i386 i386 PASS
Currently gdb.base/interrupt.exp fails on amd64 host running under
--target_board unix/-m32 with:
continue
Continuing.
Unknown error 512
<linux/errno.h>:
/*
* These should never be seen by user programs. To return one of ERESTART*
* codes, signal_pending() MUST be set. Note that ptrace can observe these
* at syscall exit tracing, but they will never be left for the debugged user
* process to see.
*/
"Unknown error 512" printed above is printed by the inferior itself, not by GDB.
It is because GDB reads it as 0xfffffffffffffe00 but writes it back as
0xfffffe00.
+ /* Sign-extend %eax as during return from a syscall it is being checked
+ for -ERESTART* values -512 being above 0xfffffffffffffe00; tested by
+ interrupt.exp. */
Quote of Roland McGrath from IRC:
roland: in the user_regset model, there are 64-bit user_regset flavors and
32-bit user_regset flavors, so at the kabi level the (kernel) caller can say
what it means: calls on the 32-bit user_regset flavor will behave as if on
a 32-bit kernel/userland. in ptrace, there is no way for x86_64 ptrace calls
to say "i think of the inferior as being 32 bits, so act accordingly" (tho ppc
and/or sparc have ptr
roland: ace requests that do that iirc)
roland: ergo 64-bit ptrace callers must either save/restore full 64-bits so
the kernel's sign-extension choices are preserved, or else grok magic ways to
expand stored 32-bit register contents to 64-bit values to stuff via 64-bit
ptrace
[...]
roland: there is a "32-bit-flavored task", but it's not really true that it
has 32-bit registers. there is no 32-bit-only userland condition. any task
can always ljmp to the 64-bit code segment and run 64-bit insns including
a 64-bit syscall
roland: so a 64-bit debugger should see and be able to fiddle the full
registers. it can even change cs via ptrace to force the inferior into
running 32 or 64 bit code.
Saving whole 64bits for i386 targets on x86_64 hosts does not much match the
GDB architecture as `struct type' for these registers still should be 32bit
etc. Therefore provided just this exception.
The problem is reproducible only if one does an inferior call during the
interruption to do full inferior save/restore from GDB regcache.
Regression tested on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
Thanks,
Jan
gdb/
2009-11-29 Jan Kratochvil <jan.kratochvil@redhat.com>
* amd64-nat.c (amd64_collect_native_gregset): Do not pre-clear %eax.
Sign extend it afterwards.
diff --git a/gdb/amd64-nat.c b/gdb/amd64-nat.c
--- a/gdb/amd64-nat.c
+++ b/gdb/amd64-nat.c
@@ -135,9 +135,9 @@ amd64_collect_native_gregset (const struct regcache *regcache,
{
num_regs = amd64_native_gregset32_num_regs;
- /* Make sure %eax, %ebx, %ecx, %edx, %esi, %edi, %ebp, %esp and
+ /* Make sure %ebx, %ecx, %edx, %esi, %edi, %ebp, %esp and
%eip get zero-extended to 64 bits. */
- for (i = 0; i <= I386_EIP_REGNUM; i++)
+ for (i = I386_ECX_REGNUM; i <= I386_EIP_REGNUM; i++)
{
if (regnum == -1 || regnum == i)
memset (regs + amd64_native_gregset_reg_offset (gdbarch, i), 0, 8);
@@ -163,4 +163,20 @@ amd64_collect_native_gregset (const struct regcache *regcache,
regcache->raw_collect (i, regs + offset);
}
}
+
+ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
+ {
+ /* Sign-extend %eax as during return from a syscall it is being checked
+ for -ERESTART* values -512 being above 0xfffffffffffffe00; tested by
+ interrupt.exp. */
+
+ int i = I386_EAX_REGNUM;
+
+ if (regnum == -1 || regnum == i)
+ {
+ void *ptr = regs + amd64_native_gregset_reg_offset (gdbarch, i);
+
+ *(int64_t *) ptr = *(int32_t *) ptr;
+ }
+ }
}

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Fri May 24 13:16:38 UTC 2019 - Tom de Vries <tdevries@suse.de>
- Update gdb.changes to mention fedora patches dropped and added
-------------------------------------------------------------------
Wed May 22 16:01:13 UTC 2019 - Tom de Vries <tdevries@suse.de>
- Remove gdb-gcc9-fix-build-with-latest-GCC-9.0-tree.patch and
gdb-gcc9-warning-on-elf32-arm.c-elf32_arm_final_link.patch, which are
already present in 8.3.
-------------------------------------------------------------------
Wed May 22 08:44:01 UTC 2019 - Martin Liška <mliska@suse.cz>
@ -5,6 +17,88 @@ Wed May 22 08:44:01 UTC 2019 - Martin Liška <mliska@suse.cz>
gdb-gcc9-warning-on-elf32-arm.c-elf32_arm_final_link.patch
in order to fix build with GCC9.
-------------------------------------------------------------------
Tue May 21 13:32:17 UTC 2019 - Tom de Vries <tdevries@suse.de>
- Replace fedora patch gdb-x86_64-i386-syscall-restart.patch with
master backport gdb-x86_64-i386-syscall-restart-master.patch
-------------------------------------------------------------------
Fri May 17 16:04:43 UTC 2019 - Tom de Vries <tdevries@suse.de>
- Work around riscv64 build error: gdbserver.1 is installed, but not
packaged
-------------------------------------------------------------------
Thu May 16 15:12:24 UTC 2019 - Tom de Vries <tdevries@suse.de>
- Don't expect gdbserver for riscv64
-------------------------------------------------------------------
Thu May 16 13:00:08 UTC 2019 - Tom de Vries <tdevries@suse.de>
- Add gdb-fix-riscv-tdep.patch to fix RISC-V build breaker
-------------------------------------------------------------------
Thu May 16 10:42:34 UTC 2019 - Tom de Vries <tdevries@suse.de>
- Rebase to 8.3 release (as in fedora 30 @ 1e222a3).
* DWARF index cache: GDB can now automatically save indices of DWARF
symbols on disk to speed up further loading of the same binaries.
* Ada task switching is now supported on aarch64-elf targets when
debugging a program using the Ravenscar Profile.
* Terminal styling is now available for the CLI and the TUI.
* Removed support for old demangling styles arm, edg, gnu, hp and
lucid.
* Support for new native configuration RISC-V GNU/Linux (riscv*-*-linux*).
- Obsoleted fedora patches dropped:
* gdb-6.3-ppc64syscall-20040622.patch
* gdb-6.3-ppc64displaysymbol-20041124.patch
* gdb-6.3-readnever-20050907.patch
* gdb-6.5-bz203661-emit-relocs.patch
* gdb-6.8-sparc64-silence-memcpy-check.patch
* gdb-6.8-watchpoint-conditionals-test.patch
* gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch
* gdb-python-gil.patch
* gdb-rhbz881849-ipv6-1of3.patch
* gdb-rhbz881849-ipv6-2of3.patch
* gdb-rhbz881849-ipv6-3of3.patch
* gdb-rhbz1187581-power8-regs-1of7.patch
* gdb-rhbz1187581-power8-regs-2of7.patch
* gdb-rhbz1187581-power8-regs-3of7.patch
* gdb-rhbz1187581-power8-regs-4of7.patch
* gdb-rhbz1187581-power8-regs-5of7.patch
* gdb-rhbz1187581-power8-regs-6of7.patch
* gdb-rhbz1187581-power8-regs-7of7.patch
* gdb-rhbz1491128-batch-mode-exit-status-1of2.patch
* gdb-rhbz1491128-batch-mode-exit-status-2of2.patch
* gdb-use-pulongest-aarch64-linux-tdep.patch
* gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-1of5.patch
* gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-2of5.patch
* gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-3of5.patch
* gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-4of5.patch
* gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-5of5.patch
- Fedora patches added:
* gdb-rhbz795424-bitpos-arrayview.patch
* gdb-rhbz1371380-gcore-elf-headers.patch
- Obsoleted patched dropped:
* gdb-fix-crash-when-reading-core.patch
* power8-registers.diff
* gdb-fix-multidictionary.exp-for-gdb-8.2.patch
- Backport from master:
* gdb-handle-vfork-in-thread-with-follow-fork-mode-child.patch
[swo#gdb/24454]
- Added patches proposed for master:
* gdb-fix-heap-use-after-free-in-typename-concat.patch
[swo#24094]
* gdb-symtab-fix-symbol-loading-performance-regression.patch
[swo#24545]
-------------------------------------------------------------------
Wed May 15 07:34:51 UTC 2019 - Tom de Vries <tdevries@suse.de>
- Add BuildRequires mpfr-devel
-------------------------------------------------------------------
Thu Jan 24 10:13:33 UTC 2019 - tdevries@suse.com

316
gdb.spec
View File

@ -27,7 +27,7 @@ License: GPL-3.0-or-later AND GPL-3.0-with-GCC-exception AND LGPL-2.1-or-
Group: Development/Tools/Debuggers
Name: gdb
Version: 8.2
Version: 8.3
Release: 0
# The release always contains a leading reserved number, start it at 1.
@ -35,7 +35,7 @@ Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# Do not provide URL for snapshots as the file lasts there only for 2 days.
# ftp://sourceware.org/pub/gdb/releases/gdb-%{version}.tar.gz
# ftp://sourceware.org/pub/gdb/releases/gdb-%%{version}.tar.gz
Source: gdb-%{version}.tar.bz2
Url: http://gnu.org/software/gdb/
@ -102,141 +102,116 @@ Patch1: gdb-6.3-rh-testversion-20041202.patch
Patch2: gdb-vla-intel-fortran-strides.patch
Patch3: gdb-vla-intel-fortran-vla-strings.patch
Patch4: gdb-vla-intel-stringbt-fix.patch
Patch5: gdb-6.3-ppc64syscall-20040622.patch
Patch6: gdb-6.3-ppc64displaysymbol-20041124.patch
Patch7: gdb-6.3-gstack-20050411.patch
Patch8: gdb-6.3-test-pie-20050107.patch
Patch9: gdb-6.3-test-self-20050110.patch
Patch10: gdb-6.3-test-dtorfix-20050121.patch
Patch11: gdb-6.3-test-movedir-20050125.patch
Patch12: gdb-6.3-threaded-watchpoints2-20050225.patch
Patch13: gdb-6.3-inferior-notification-20050721.patch
Patch14: gdb-6.3-inheritancetest-20050726.patch
Patch15: gdb-6.3-readnever-20050907.patch
Patch16: gdb-6.5-bz203661-emit-relocs.patch
Patch17: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
Patch18: gdb-6.5-sharedlibrary-path.patch
Patch19: gdb-6.5-BEA-testsuite.patch
Patch20: gdb-6.5-last-address-space-byte-test.patch
Patch21: gdb-6.5-readline-long-line-crash-test.patch
Patch22: gdb-6.5-bz216711-clone-is-outermost.patch
Patch23: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
Patch24: gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch
Patch25: gdb-6.5-bz109921-DW_AT_decl_file-test.patch
Patch26: gdb-6.3-bz140532-ppc-unwinding-test.patch
Patch27: gdb-6.3-bz202689-exec-from-pthread-test.patch
Patch28: gdb-6.6-bz230000-power6-disassembly-test.patch
Patch29: gdb-6.6-bz229517-gcore-without-terminal.patch
Patch30: gdb-6.6-testsuite-timeouts.patch
Patch31: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
Patch32: gdb-6.6-scheduler_locking-step-is-default.patch
Patch33: gdb-6.3-attach-see-vdso-test.patch
Patch34: gdb-6.5-bz243845-stale-testing-zombie-test.patch
Patch35: gdb-6.6-buildid-locate.patch
Patch36: gdb-6.6-buildid-locate-solib-missing-ids.patch
Patch37: gdb-6.6-buildid-locate-rpm.patch
Patch38: gdb-6.7-charsign-test.patch
Patch39: gdb-6.7-ppc-clobbered-registers-O2-test.patch
Patch40: gdb-6.7-testsuite-stable-results.patch
Patch41: gdb-6.5-ia64-libunwind-leak-test.patch
Patch42: gdb-6.5-missed-trap-on-step-test.patch
Patch43: gdb-6.5-gcore-buffer-limit-test.patch
Patch44: gdb-6.3-mapping-zero-inode-test.patch
Patch45: gdb-6.3-focus-cmd-prev-test.patch
Patch46: gdb-6.8-bz442765-threaded-exec-test.patch
Patch47: gdb-6.8-sparc64-silence-memcpy-check.patch
Patch48: gdb-6.5-section-num-fixup-test.patch
Patch49: gdb-6.8-bz436037-reg-no-longer-active.patch
Patch50: gdb-6.8-watchpoint-conditionals-test.patch
Patch51: gdb-6.8-bz466901-backtrace-full-prelinked.patch
Patch52: gdb-simultaneous-step-resume-breakpoint-test.patch
Patch53: gdb-core-open-vdso-warning.patch
Patch54: gdb-x86_64-i386-syscall-restart.patch
Patch55: gdb-bz533176-fortran-omp-step.patch
Patch56: gdb-follow-child-stale-parent.patch
Patch57: gdb-ccache-workaround.patch
Patch58: gdb-archer-pie-addons.patch
Patch59: gdb-archer-pie-addons-keep-disabled.patch
Patch60: gdb-lineno-makeup-test.patch
Patch61: gdb-ppc-power7-test.patch
Patch62: gdb-bz541866-rwatch-before-run.patch
Patch63: gdb-moribund-utrace-workaround.patch
Patch64: gdb-archer-next-over-throw-cxx-exec.patch
Patch65: gdb-bz601887-dwarf4-rh-test.patch
Patch66: gdb-6.6-buildid-locate-core-as-arg.patch
Patch67: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
Patch68: gdb-test-bt-cfi-without-die.patch
Patch69: gdb-bz568248-oom-is-error.patch
Patch70: gdb-bz634108-solib_address.patch
Patch71: gdb-test-pid0-core.patch
Patch72: gdb-test-dw2-aranges.patch
Patch73: gdb-test-expr-cumulative-archer.patch
Patch74: gdb-physname-pr11734-test.patch
Patch75: gdb-physname-pr12273-test.patch
Patch76: gdb-7.2.50-sparc-add-workaround-to-broken-debug-files.patch
Patch77: gdb-test-ivy-bridge.patch
Patch78: gdb-runtest-pie-override.patch
Patch79: gdb-attach-fail-reasons-5of5.patch
Patch80: gdb-glibc-strstr-workaround.patch
Patch81: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch
Patch82: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch
Patch83: gdb-rhbz795424-bitpos-20of25.patch
Patch84: gdb-rhbz795424-bitpos-21of25.patch
Patch85: gdb-rhbz795424-bitpos-22of25.patch
Patch86: gdb-rhbz795424-bitpos-23of25.patch
Patch87: gdb-rhbz795424-bitpos-25of25.patch
Patch88: gdb-rhbz795424-bitpos-25of25-test.patch
Patch89: gdb-rhbz795424-bitpos-lazyvalue.patch
Patch90: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch
Patch91: gdb-gnat-dwarf-crash-3of3.patch
Patch92: gdb-rhbz1007614-memleak-infpy_read_memory-test.patch
Patch93: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
Patch94: gdb-archer-vla-tests.patch
Patch95: gdb-vla-intel-tests.patch
Patch96: gdb-btrobust.patch
Patch97: gdb-fortran-frame-string.patch
Patch98: gdb-python-gil.patch
Patch99: gdb-rhbz1156192-recursive-dlopen-test.patch
Patch100: gdb-jit-reader-multilib.patch
Patch101: gdb-rhbz1149205-catch-syscall-after-fork-test.patch
Patch102: gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch
Patch103: gdb-rhbz1350436-type-printers-error.patch
Patch104: gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch
Patch105: gdb-bz1219747-attach-kills.patch
Patch106: gdb-fedora-libncursesw.patch
Patch107: gdb-opcodes-clflushopt-test.patch
Patch108: gdb-dts-rhel6-python-compat.patch
Patch109: gdb-6.6-buildid-locate-rpm-scl.patch
Patch110: gdb-readline62-ask-more-rh.patch
Patch111: gdb-6.8-quit-never-aborts.patch
Patch112: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
Patch113: gdb-container-rh-pkg.patch
Patch114: gdb-rhbz1325795-framefilters-test.patch
Patch115: gdb-linux_perf-bundle.patch
Patch116: gdb-libexec-add-index.patch
Patch117: gdb-rhbz1398387-tab-crash-test.patch
Patch118: gdb-testsuite-readline63-sigint.patch
Patch119: gdb-archer.patch
Patch120: gdb-vla-intel-fix-print-char-array.patch
Patch121: gdb-rhbz1553104-s390x-arch12-test.patch
Patch122: gdb-rhbz881849-ipv6-1of3.patch
Patch123: gdb-rhbz881849-ipv6-2of3.patch
Patch124: gdb-rhbz881849-ipv6-3of3.patch
Patch125: gdb-rhbz1187581-power8-regs-1of7.patch
Patch126: gdb-rhbz1187581-power8-regs-2of7.patch
Patch127: gdb-rhbz1187581-power8-regs-3of7.patch
Patch128: gdb-rhbz1187581-power8-regs-4of7.patch
Patch129: gdb-rhbz1187581-power8-regs-5of7.patch
Patch130: gdb-rhbz1187581-power8-regs-6of7.patch
Patch131: gdb-rhbz1187581-power8-regs-7of7.patch
Patch132: gdb-rhbz1491128-batch-mode-exit-status-1of2.patch
Patch133: gdb-rhbz1491128-batch-mode-exit-status-2of2.patch
Patch134: gdb-use-pulongest-aarch64-linux-tdep.patch
Patch137: gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-1of5.patch
Patch138: gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-2of5.patch
Patch139: gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-3of5.patch
Patch140: gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-4of5.patch
Patch141: gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-5of5.patch
Patch5: gdb-6.3-gstack-20050411.patch
Patch6: gdb-6.3-test-pie-20050107.patch
Patch7: gdb-6.3-test-self-20050110.patch
Patch8: gdb-6.3-test-dtorfix-20050121.patch
Patch9: gdb-6.3-test-movedir-20050125.patch
Patch10: gdb-6.3-threaded-watchpoints2-20050225.patch
Patch11: gdb-6.3-inferior-notification-20050721.patch
Patch12: gdb-6.3-inheritancetest-20050726.patch
Patch13: gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch
Patch14: gdb-6.5-sharedlibrary-path.patch
Patch15: gdb-6.5-BEA-testsuite.patch
Patch16: gdb-6.5-last-address-space-byte-test.patch
Patch17: gdb-6.5-readline-long-line-crash-test.patch
Patch18: gdb-6.5-bz216711-clone-is-outermost.patch
Patch19: gdb-6.5-bz218379-ppc-solib-trampoline-test.patch
Patch20: gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch
Patch21: gdb-6.5-bz109921-DW_AT_decl_file-test.patch
Patch22: gdb-6.3-bz140532-ppc-unwinding-test.patch
Patch23: gdb-6.3-bz202689-exec-from-pthread-test.patch
Patch24: gdb-6.6-bz230000-power6-disassembly-test.patch
Patch25: gdb-6.6-bz229517-gcore-without-terminal.patch
Patch26: gdb-6.6-testsuite-timeouts.patch
Patch27: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
Patch28: gdb-6.6-scheduler_locking-step-is-default.patch
Patch29: gdb-6.3-attach-see-vdso-test.patch
Patch30: gdb-6.5-bz243845-stale-testing-zombie-test.patch
Patch31: gdb-6.6-buildid-locate.patch
Patch32: gdb-6.6-buildid-locate-solib-missing-ids.patch
Patch33: gdb-6.6-buildid-locate-rpm.patch
Patch34: gdb-6.7-charsign-test.patch
Patch35: gdb-6.7-ppc-clobbered-registers-O2-test.patch
Patch36: gdb-6.7-testsuite-stable-results.patch
Patch37: gdb-6.5-ia64-libunwind-leak-test.patch
Patch38: gdb-6.5-missed-trap-on-step-test.patch
Patch39: gdb-6.5-gcore-buffer-limit-test.patch
Patch40: gdb-6.3-mapping-zero-inode-test.patch
Patch41: gdb-6.3-focus-cmd-prev-test.patch
Patch42: gdb-6.8-bz442765-threaded-exec-test.patch
Patch43: gdb-6.5-section-num-fixup-test.patch
Patch44: gdb-6.8-bz436037-reg-no-longer-active.patch
Patch45: gdb-6.8-bz466901-backtrace-full-prelinked.patch
Patch46: gdb-simultaneous-step-resume-breakpoint-test.patch
Patch47: gdb-core-open-vdso-warning.patch
Patch49: gdb-bz533176-fortran-omp-step.patch
Patch50: gdb-follow-child-stale-parent.patch
Patch51: gdb-ccache-workaround.patch
Patch52: gdb-archer-pie-addons.patch
Patch53: gdb-archer-pie-addons-keep-disabled.patch
Patch54: gdb-lineno-makeup-test.patch
Patch55: gdb-ppc-power7-test.patch
Patch56: gdb-bz541866-rwatch-before-run.patch
Patch57: gdb-moribund-utrace-workaround.patch
Patch58: gdb-archer-next-over-throw-cxx-exec.patch
Patch59: gdb-bz601887-dwarf4-rh-test.patch
Patch60: gdb-6.6-buildid-locate-core-as-arg.patch
Patch61: gdb-6.6-buildid-locate-rpm-librpm-workaround.patch
Patch62: gdb-test-bt-cfi-without-die.patch
Patch63: gdb-bz568248-oom-is-error.patch
Patch64: gdb-bz634108-solib_address.patch
Patch65: gdb-test-pid0-core.patch
Patch66: gdb-test-dw2-aranges.patch
Patch67: gdb-test-expr-cumulative-archer.patch
Patch68: gdb-physname-pr11734-test.patch
Patch69: gdb-physname-pr12273-test.patch
Patch70: gdb-test-ivy-bridge.patch
Patch71: gdb-runtest-pie-override.patch
Patch72: gdb-attach-fail-reasons-5of5.patch
Patch73: gdb-glibc-strstr-workaround.patch
Patch74: gdb-rhel5.9-testcase-xlf-var-inside-mod.patch
Patch75: gdb-rhbz-818343-set-solib-absolute-prefix-testcase.patch
Patch76: gdb-rhbz795424-bitpos-20of25.patch
Patch77: gdb-rhbz795424-bitpos-21of25.patch
Patch78: gdb-rhbz795424-bitpos-22of25.patch
Patch79: gdb-rhbz795424-bitpos-23of25.patch
Patch80: gdb-rhbz795424-bitpos-25of25.patch
Patch81: gdb-rhbz795424-bitpos-25of25-test.patch
Patch82: gdb-rhbz795424-bitpos-lazyvalue.patch
Patch83: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch
Patch84: gdb-gnat-dwarf-crash-3of3.patch
Patch85: gdb-rhbz1007614-memleak-infpy_read_memory-test.patch
Patch86: gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
Patch87: gdb-archer-vla-tests.patch
Patch88: gdb-vla-intel-tests.patch
Patch89: gdb-btrobust.patch
Patch90: gdb-fortran-frame-string.patch
Patch91: gdb-rhbz1156192-recursive-dlopen-test.patch
Patch92: gdb-jit-reader-multilib.patch
Patch93: gdb-rhbz1149205-catch-syscall-after-fork-test.patch
Patch94: gdb-rhbz1186476-internal-error-unqualified-name-re-set-test.patch
Patch95: gdb-rhbz1350436-type-printers-error.patch
Patch96: gdb-rhbz1084404-ppc64-s390x-wrong-prologue-skip-O2-g-3of3.patch
Patch97: gdb-bz1219747-attach-kills.patch
Patch98: gdb-fedora-libncursesw.patch
Patch99: gdb-opcodes-clflushopt-test.patch
Patch100: gdb-dts-rhel6-python-compat.patch
Patch101: gdb-6.6-buildid-locate-rpm-scl.patch
Patch102: gdb-readline62-ask-more-rh.patch
Patch103: gdb-6.8-quit-never-aborts.patch
Patch104: gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
Patch105: gdb-container-rh-pkg.patch
Patch106: gdb-rhbz1325795-framefilters-test.patch
Patch107: gdb-linux_perf-bundle.patch
Patch108: gdb-libexec-add-index.patch
Patch109: gdb-rhbz1398387-tab-crash-test.patch
Patch110: gdb-testsuite-readline63-sigint.patch
Patch111: gdb-archer.patch
Patch112: gdb-vla-intel-fix-print-char-array.patch
Patch113: gdb-rhbz1553104-s390x-arch12-test.patch
Patch114: gdb-rhbz795424-bitpos-arrayview.patch
Patch115: gdb-rhbz1371380-gcore-elf-headers.patch
#Fedora Packages end
# Upstream patch to fix gcc -Werror
@ -244,19 +219,21 @@ Patch1002: gdb-6.6-buildid-locate-rpm-suse.patch
Patch1004: gdb-fix-buf-overflow.diff
Patch1005: gdb-7.10-swo18929.patch
Patch1007: gdb-fix-s390-build.diff
Patch1008: gdb-gcc9-fix-build-with-latest-GCC-9.0-tree.patch
Patch1009: gdb-gcc9-warning-on-elf32-arm.c-elf32_arm_final_link.patch
# Backports from master
Patch2000: gdb-fix-crash-when-reading-core.patch
Patch2001: power8-registers.diff
Patch2000: gdb-handle-vfork-in-thread-with-follow-fork-mode-child.patch
Patch2001: gdb-fix-riscv-tdep.patch
Patch2002: gdb-x86_64-i386-syscall-restart-master.patch
# Submitted for master
Patch2500: gdb-fix-heap-use-after-free-in-typename-concat.patch
Patch2501: gdb-symtab-fix-symbol-loading-performance-regression.patch
# libipt support
Patch3000: v1.5-libipt-static.patch
# Testsuite fixes
Patch4000: gdb-fix-multidictionary.exp-for-gdb-8.2.patch
BuildRequires: bison
BuildRequires: flex
%if 0%{suse_version} > 1110
@ -282,6 +259,7 @@ BuildRequires: pkg-config
BuildRequires: readline-devel
BuildRequires: rpm-devel
BuildRequires: zlib-devel
BuildRequires: mpfr-devel
%if 0%{!?_without_python:1}
%if 0%{suse_version} > 1000
Requires: %{python}-base
@ -370,6 +348,18 @@ GDB, the GNU debugger, allows you to debug programs written in C, C++,
Java, and other languages, by executing them in a controlled fashion
and printing their data.
%ifarch riscv64
# Work around RPM build error:
# ...
# Installed (but unpackaged) file(s) found:
# /usr/share/man/man1/gdbserver.1.gz
# ...
# Filed at PR24575 - "gdbserver.1 should only be installed if gdbserver was
# build" ( https://sourceware.org/bugzilla/show_bug.cgi?id=24575 ).
%define _unpackaged_files_terminate_build 0
%endif
%ifnarch riscv64
%if %{suse_version} > 1010
%package -n gdbserver
Summary: A standalone server for GDB (the GNU source-level debugger)
@ -384,6 +374,7 @@ and printing their data.
This package provides a program that allows you to run GDB on a different
machine than the one which is running the program being debugged.
%endif
%endif
%package doc
Summary: Documentation for GDB (the GNU source-level debugger)
@ -474,7 +465,6 @@ find -name "*.info*"|xargs rm -f
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1
%patch51 -p1
@ -542,41 +532,19 @@ find -name "*.info*"|xargs rm -f
%patch113 -p1
%patch114 -p1
%patch115 -p1
%patch116 -p1
%patch117 -p1
%patch118 -p1
%patch119 -p1
%patch120 -p1
%patch121 -p1
%patch122 -p1
%patch123 -p1
%patch124 -p1
%patch125 -p1
%patch126 -p1
%patch127 -p1
%patch128 -p1
%patch129 -p1
%patch130 -p1
%patch131 -p1
%patch132 -p1
%patch133 -p1
%patch134 -p1
%patch137 -p1
%patch138 -p1
%patch139 -p1
%patch140 -p1
%patch141 -p1
#Fedora patching end
%patch1002 -p1
%patch1004 -p1
%patch1005 -p1
%patch1007 -p1
%patch1008 -p1
%patch1009 -p1
%patch2000 -p1
%patch2001 -p1
%patch2002 -p1
%patch2500 -p1
%patch2501 -p1
#unpack libipt
%if 0%{have_libipt}
@ -587,8 +555,6 @@ tar xzf %{SOURCE7}
)
%endif
%patch4000 -p1
find -name "*.orig" | xargs rm -f
! find -name "*.rej" # Should not happen.
@ -1098,6 +1064,7 @@ fi
%{_datadir}/gdb
%{_infodir}/annotate.info*
%{_infodir}/gdb.info*
%ifnarch riscv64
# In SLE10 gdbserver is not in a separate package
%if %{suse_version} <= 1010
%{_bindir}/gdbserver
@ -1106,6 +1073,7 @@ fi
%{_libdir}/libinproctrace.so
%endif
%endif
%endif
%if %{with testsuite}
%files testresults
@ -1116,6 +1084,7 @@ fi
# don't include the files in include, they are part of binutils
%ifnarch riscv64
%if %{suse_version} > 1010
%ifnarch sparcv9 hppa
%files -n gdbserver
@ -1127,6 +1096,7 @@ fi
%endif # %{have_inproctrace}
%endif
%endif
%endif
%post doc
# This step is part of the installation of the RPM. Not to be confused

File diff suppressed because it is too large Load Diff