As we require c++11, GDB fails to build if bison is not new enough.
I see the following error on the system (fedora 19) that bison is
2.6.4,
g++ -std=gnu++11 .... \
-c -o ada-exp.o -MT ada-exp.o -MMD -MP -MF .deps/ada-exp.Tpo 'if test -f ada-exp.c; then echo ada-exp.c; else echo ../../binutils-gdb/gdb/ada-exp.c; fi`
In file included from ../../binutils-gdb/gdb/ada-exp.y:731:0:
ada-lex.c:113:0: error: "YY_NULL" redefined [-Werror]
#define YY_NULL 0
^
ada-exp.c:158:0: note: this is the location of the previous definition
# define YY_NULL nullptr
^
cc1plus: all warnings being treated as errors
make: *** [ada-exp.o] Error 1
Both ada-exp.c and ada-lex.c has macro YY_NULL, like this,
$ cat 1.c
# ifndef YY_NULL
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULL nullptr
# else
# define YY_NULL 0
# endif
# endif
#define YY_NULL 0
as we can see, YY_NULL is defined differently (nullptr vs 0)
$ g++ -std=c++11 -Wall 1.c -c
1.c:9:0: warning: "YY_NULL" redefined
#define YY_NULL 0
^
1.c:3:0: note: this is the location of the previous definition
# define YY_NULL nullptr
^
$ g++ -Wall 1.c -c
bison renames YY_NULL to YY_NULLPTR in 2013 Nov,
https://lists.gnu.org/archive/html/bison-patches/2013-11/msg00002.html
and bison released later than 2013 Nov have this patch. Bison 3.0.2,
released on 2013 Dec, is OK.
The fix is to replace YY_NULL with YY_NULLPTR via sed. With old bison,
YY_NULL becomes YY_NULLPTR; with new bison, YY_NULLPTR becomes
YY_NULLPTRPTR,
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* Makefile.in (.y.c): Replace YY_NULL with YY_NULLPTR.
The REG_82 entry in x86 disassembler is for opcode 0x83, not opcode
0x82.
* i386-dis.c (REG_82): Renamed to ...
(REG_83): This.
(dis386): Updated.
(reg_table): Likewise.
Both of them are used in conversion. We can remove them since the
conversion is done.
There are many architectures only have one breakpoint instruction,
so their gdbarch methods breakpoint_kind_from_pc and
sw_breakpoint_from_kind look very similar. Instead of macro, we
use template "template <size_t, const gdb_byte *> struct bp_manipulation"
for these architectures. In order to use template, I also change
breakpoint instruction of type "static const gdb_byte[]" to
"constexpr gdb_byte[]", and rename them to ARCH_break_insn.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
Pedro Alves <palves@redhat.com>
* aarch64-tdep.c (aarch64_default_breakpoint): Change it to
constexpr. Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(aarch64_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* alpha-tdep.c (break_insn): Rename to alpha_break_insn.
Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(alpha_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* arc-tdep.c (arc_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Remove.
(struct bp_manipulation): New.
(SET_GDBARCH_BREAKPOINT_MANIPULATION): Remove.
(struct bp_manipulation_endian): New.
(BP_MANIPULATION): New.
(BP_MANIPULATION_ENDIAN): New.
* arm-tdep.c (arm_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* avr-tdep.c (avr_break_insn): Change it constexpr.
(avr_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* bfin-tdep.c (bfin_gdbarch_init): Likewise.
* cris-tdep.c (cris_gdbarch_init): Likewise.
* frv-tdep.c (breakpoint): Rename it to frv_break_insn, and
change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(frv_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* ft32-tdep.c (breakpoint): Rename it to ft32_break_insn and
change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(ft32_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* h8300-tdep.c (breakpoint): Rename it to h8300_break_insn.
Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(h8300_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* hppa-tdep.c (breakpoint): Rename it to h8300_break_insn.
Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(hppa_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* i386-tdep.c (break_insn): Rename it to i386_break_insn.
Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(i386_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* iq2000-tdep.c (iq2000_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* lm32-tdep.c (breakpoint): Rename it to lm32_break_insn and
change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(lm32_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* m32c-tdep.c (break_insn): Rename it to m32c_break_insn and change
its type to constexpr. Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(m32c_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* m32r-tdep.c (m32r_gdbarch_init): Likewise.
* m68hc11-tdep.c (breakpoint): Rename it to m68hc11_break_insn and
change its type to constexpr. Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(m68hc11_gdbarch_init): Don't use SET_GDBARCH_BREAKPOINT_MANIPULATION.
* m68k-tdep.c (break_insn): Rename it to m68k_break_insn and change
its type to constexpr. Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(m68k_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* m88k-tdep.c (break_insn): Rename it to m88k_break_insn and change
its type to constexpr. Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(m88k_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* mep-tdep.c (breakpoint): Rename it to mep_break_insn and change
its type to constexpr. Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(mep_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* microblaze-tdep.c (break_insn): Rename it to
microblaze_break_insn and change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(microblaze_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* mn10300-tdep.c (breakpoint): Rename it to mn10300_break_insn and
change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(mn10300_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* moxie-tdep.c (breakpoint): Rename it to moxie_break_insn and
change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(moxie_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* msp430-tdep.c (breakpoint): Rename it to msp430_break_insn
and change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(msp430_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* mt-tdep.c (mt_gdbarch_init): Likewise.
* nds32-tdep.c (break_insn): Rename it to nds32_break_insn
and change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(nds32_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* nios2-tdep.c (nios2_gdbarch_init): Likewise.
* rl78-tdep.c (breakpoint): Rename it to rl78_break_ins
and change its type to rl78_break_insn. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(rl78_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* rs6000-tdep.c (big_breakpoint): Change its type to
constexpr.
(little_breakpoint): Likewise.
Don't use GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN.
(rs6000_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* rx-tdep.c (breakpoint): Rename it to rx_break_insn and
change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(rx_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* s390-linux-tdep.c (breakpoint): Rename it to s390_break_insn
and change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION
(s390_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* score-tdep.c (score_gdbarch_init): Likewise.
* sh-tdep.c (sh_gdbarch_init): Likewise.
* sh64-tdep.c (sh64_gdbarch_init): Likewise.
* sparc-tdep.c (break_insn): Rename it to sparc_break_insn
and change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(sparc32_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* spu-tdep.c (breakpoint): Rename it to spu_break_insn and change
its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(spu_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
* tilegx-tdep.c (breakpoint): Rename it to tilegx_break_insn
and change its type to constexpr. Don't use
GDBARCH_BREAKPOINT_MANIPULATION.
(tilegx_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* v850-tdep.c (v850_gdbarch_init): Likewise.
* vax-tdep.c (break_insn): Rename it to vax_break_insn and
change its type to constexpr.
Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(vax_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* xstormy16-tdep.c (breakpoint): Rename it to
xstormy16_break_insn and change its type to constexpr.
Don't use GDBARCH_BREAKPOINT_MANIPULATION.
(xstormy16_gdbarch_init): Don't use
SET_GDBARCH_BREAKPOINT_MANIPULATION.
* xtensa-tdep.c (xtensa_gdbarch_init): Likewise.
GDB can determine the kind of single step breakpoint by gdbarch
breakpoint_kind_from_current_state, so global variable
arm_override_mode is no longer needed. This patch removes it.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* arm-tdep.c (arm_override_mode): Remove.
(arm_pc_is_thumb): Update.
(arm_insert_single_step_breakpoint): Update.
This patch adds a new gdbarch method breakpoint_kind_from_current_state
for single step breakpoint, and uses it in breakpoint_kind.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* arch-utils.c (default_breakpoint_kind_from_current_state):
New function.
* arch-utils.h (default_breakpoint_kind_from_current_state):
Declare.
* arm-tdep.c (arm_breakpoint_kind_from_current_state): New
function.
(arm_gdbarch_init): Call
set_gdbarch_breakpoint_kind_from_current_state.
* breakpoint.c (breakpoint_kind): Call
gdbarch_breakpoint_kind_from_current_state for single step
breakpoint. Update comments.
* gdbarch.sh (breakpoint_kind_from_current_state): New.
* gdbarch.c, gdbarch.h: Regenerate.
This patch renames placed_size to kind.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* breakpoint.h (struct bp_target_info) <placed_size>: Remove.
<kind>: New field.
Update all users.
This patch adds two gdbarch methods breakpoint_kind_from_pc and
sw_breakpoint_from_kind, and uses target_info.placed_size as "kind"
of the breakpoint. This patch updates the usages of
target_info.placed_size.
The "kind" of a breakpoint is determined by gdbarch rather than
target, so we have gdbarch method breakpoint_kind_from_pc, and we
should set target_info.placed_size out of each implementation of
target to_insert_breakpoint. In this way, each target doesn't have
to set target_info.placed_size any more.
This patch also sets target_info.placed_address before
target_insert_breakpoint too, so that target to_insert_breakpoint
can use it, see record_full_insert_breakpoint.
Before we call target_insert_breakpoint, we set
target_info.placed_address and target_info.placed_size like this,
CORE_ADDR addr = bl->target_info.reqstd_address;
bl->target_info.placed_size = gdbarch_breakpoint_kind_from_pc (bl->gdbarch, &addr);
bl->target_info.placed_address = addr;
return target_insert_breakpoint (bl->gdbarch, &bl->target_info);
target_insert_breakpoint may fail, but it doesn't matter to the "kind"
and "placed_address" of a breakpoint. They should be determined by
gdbarch.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Define
breakpoint_kind_from_pc and sw_breakpoint_from_kind.
(GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): Likewise.
(SET_GDBARCH_BREAKPOINT_MANIPULATION): Call
set_gdbarch_breakpoint_kind_from_pc and
set_gdbarch_sw_breakpoint_from_kind.
* arm-tdep.c: Add comments.
* bfin-tdep.c: Likewise.
* breakpoint.c (breakpoint_kind): New function.
(insert_bp_location): Set target_info.placed_size and
target_info.placed_address.
(bkpt_insert_location): Likewise.
* cris-tdep.c: Add comments.
* gdbarch.sh (breakpoint_kind_from_pc): New.
(sw_breakpoint_from_kind): New.
* gdbarch.c, gdbarch.h: Regenerated.
* ia64-tdep.c (ia64_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
(ia64_memory_remove_breakpoint): Don't assert
bp_tgt->placed_size.
(ia64_breakpoint_kind_from_pc): New function.
(ia64_gdbarch_init): Install ia64_breakpoint_kind_from_pc.
* m32r-tdep.c (m32r_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
* mem-break.c (default_memory_insert_breakpoint): Don't set
bp_tgt->placed_size. Call gdbarch_sw_breakpoint_from_kind.
(default_memory_remove_breakpoint): Call
gdbarch_sw_breakpoint_from_kind.
(memory_validate_breakpoint): Don't check bp_tgt->placed_size.
* mips-tdep.c: Add comments.
* mt-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* record-full.c (record_full_insert_breakpoint): Don't call
gdbarch_breakpoint_from_pc. Don't set bp_tgt->placed_address
and bp_tgt->placed_size.
* remote.c (remote_insert_breakpoint): Don't call
gdbarch_remote_breakpoint_from_pc. Use bp_tgt->placed_size.
Don't set bp_tgt->placed_address and bp_tgt->placed_size.
(remote_insert_hw_breakpoint): Likewise.
* score-tdep.c: Likewise.
* sh-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* v850-tdep.c: Likewise.
* xtensa-tdep.c: Likewise.
This patch adds an enum mips_breakpoint_kind to avoid using magic
numbers as much as possible.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* mips-tdep.c (mips_breakpoint_kind): New enum.
(mips_breakpoint_from_pc): Use it.
(mips_remote_breakpoint_from_pc): Likewise.
gdbarch_breakpoint_from_pc doesn't return NULL except for
ia64_breakpoint_from_pc, and we checked its return value in three
places. In microblaze_linux_memory_remove_breakpoint and
ppc_linux_memory_remove_breakpoint, gdbarch_breakpoint_from_pc never
returns NULL, so we can remove the NULL checking. In
default_memory_insert_breakpoint, gdbarch_breakpoint_from_pc can't
returns NULL too because ia64 defines its own memory_insert_breakpoint.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* mem-break.c (default_memory_insert_breakpoint): Don't check
'bp' against NULL.
* microblaze-linux-tdep.c (microblaze_linux_memory_remove_breakpoint):
Likewise.
* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise.
This fixes some regressions found in the patch to convert
dwarf_expr_context to use methods. Specifically:
* get_base_type could erroneously throw; this was rewritten to move
the size checks into the only spot needing them.
* Previously the "symbol needs frame" implementation reused th
"cfa" function for the get_frame_pc slot; this reimplements
it under the correct name.
* Not enough members were saved and restored in one implementation
of push_dwarf_reg_entry_value; this patch fixes this oversight
and also takes the opportunity to remove an extraneous structure
definition.
2016-11-02 Tom Tromey <tom@tromey.com>
* dwarf2loc.c (dwarf_evaluate_loc_desc::get_base_type): Rename
from impl_get_base_type. Rewrite.
(struct dwarf_expr_baton): Remove.
(dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value): Save and
restore more fields.
(symbol_needs_eval_context::get_frame_pc): New method.
* dwarf2expr.h (dwarf_expr_context::get_base_type): Now public,
virtual.
(dwarf_expr_context::impl_get_base_type): Remove.
* dwarf2expr.c (dwarf_expr_context::get_base_type): Remove.
Break out of the outer switch statement once the inner switch for the
BFD_RELOC_CTOR relocation has been processed, preventing double BFD_FAIL
calls from being made, once from the inner switch and then again from
the default case of the outer switch.
Noticed with a `-Wimplicit-fallthrough' build error reported by a recent
GCC version:
In file included from .../bfd/reloc.c:52:0:
.../bfd/reloc.c: In function 'bfd_default_reloc_type_lookup':
.../bfd/libbfd.h:779:8: error: this statement may fall through [-Werror=implicit-fallthrough=]
do { bfd_assert(__FILE__,__LINE__); } while (0)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../bfd/reloc.c:7780:4: note: in expansion of macro 'BFD_FAIL'
BFD_FAIL ();
^~~~~~~~
.../bfd/reloc.c:7782:5: note: here
default:
^~~~~~~
cc1: all warnings being treated as errors
make[4]: *** [reloc.lo] Error 1
bfd/
* reloc.c (bfd_default_reloc_type_lookup) <BFD_RELOC_CTOR>: Do
not fall through to the default case.
Complement commit f7c382926d ("Remove support for "target m32rsdi" and
"target mips/pmon/ddb/rockhopper/lsi"") and remove dead MIPS target code
which used to support these legacy remote targets.
gdb/
* mips-tdep.c (mips_r3041_reg_names): Remove.
(mips_breakpoint_from_pc): Remove IDT and PMON breakpoint
encodings.
2016-10-31 Thomas Preud'homme <thomas.preudhomme@arm.com>
ld/
* ldmain.c (add_archive_element): Initialize input->header.type.
* plugin.c (plugin_maybe_claim): Assert the statement is an input
statement.
gdb/ChangeLog
2016-10-29 Eli Zaretskii <eliz@gnu.org>
* NEWS: Mention support for redirection on MS-Windows.
* windows-nat.c (redir_open, redir_set_redirection)
(redirect_inferior_handles) [!__CYGWIN__]: New functions.
(windows_create_inferior) [!__CYGWIN__]: Use
'redirect_inferior_handles' to redirect standard handles of the
debuggee if the command line requests that.
Discussion with qemu folks suggests that the vCont description could
be even simpler and clearer. Given we now say:
For each inferior thread, the leftmost action with a matching
thread-id is applied.
There's really no need to even talk about "default" actions, which
raises doubts about whether "default" is special in some way (it's
not).
See <https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg06944.html>.
gdb/doc/ChangeLog:
2016-10-29 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Packets) <vCont>: Remove mention of default
actions.
Use AX_CXX_COMPILE_STDCXX to detect if the compiler supports C++11,
and if -std=xxx switches are necessary to enable C++11.
We need to tweak AX_CXX_COMPILE_STDCXX a bit though. Pristine
upstream AX_CXX_COMPILE_STDCXX appends -std=gnu++11 to CXX directly.
That doesn't work for us, because the top level Makefile passes CXX
down to subdirs, and that overrides whatever gdb/Makefile may set CXX
to. The result would be that a make invocation from the build/gdb/
directory would use "g++ -std=gnu++11" as expected, while a make
invocation at the top level would not.
So instead of having AX_CXX_COMPILE_STDCXX set CXX directly, tweak it
to AC_SUBST a separate variable -- CXX_DIALECT -- and use '$(CXX)
(CXX_DIALECT)' to compile/link.
Confirmed that this enables C++11 starting with gcc 4.8, the first gcc
release with full C++11 support.
Also confirmed that configure errors out gracefully with older GCC
releases:
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features by default... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=gnu++11... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=gnu++0x... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=c++11... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=c++0x... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with +std=c++11... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -h std=c++11... no
configure: error: *** A compiler with support for C++11 language features is required.
Makefile:9451: recipe for target 'configure-gdb' failed
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory '/home/pedro/brno/pedro/gdb/mygit/cxx-convertion/build-gcc-4.7'
If we need to revert back to making C++11 optional, all that's
necessary is to change the "mandatory" to "optional" in configure.ac
and regenerate configure (both gdb and gdbserver).
gdb/ChangeLog:
2016-10-28 Pedro Alves <palves@redhat.com>
* Makefile.in (CXX_DIALECT): Get from configure.
(COMPILE.pre, CC_LD): Append $(CXX_DIALECT).
(FLAGS_TO_PASS): Pass CXX_DIALECT.
* acinclude.m4: Include ax_cxx_compile_stdcxx.m4.
* ax_cxx_compile_stdcxx.m4: Add FSF copyright header. Set and
AC_SUBST CXX_DIALECT instead of changing CXX/CXXCPP.
* configure.ac: Call AX_CXX_COMPILE_STDCXX.
* config.in: Regenerate.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
2016-10-28 Pedro Alves <palves@redhat.com>
* Makefile.in (CXX_DIALECT): Get from configure.
(COMPILE.pre, CC_LD): Append $(CXX_DIALECT).
* acinclude.m4: Include ../ax_cxx_compile_stdcxx.m4.
* configure.ac: Call AX_CXX_COMPILE_STDCXX.
* config.in: Regenerate.
* configure: Regenerate.
This macro throws C++11 code at the compiler in order to check whether
it supports C++11. final/override, rvalue references, static_assert,
decltype, auto, constexpr, etc., and adds -std=gnu++11 to CXX if
necessary.
Nothing uses the macro yet. Simply adding it as separate preliminary
step because we'll need local changes.
gdb/ChangeLog
2016-10-28 Pedro Alves <palves@redhat.com>
* ax_cxx_compile_stdcxx.m4: New file.
Fixes:
PASS: gdb.base/maint.exp: maint w/o args
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/maint.exp: maint info line-table w/o a file name
The problem is just many symtabs and long line tables, enough to
overflow the expect buffer. Fix this by matching input incrementally.
gdb/testsuite/ChangeLog:
2016-10-28 Pedro Alves <palves@redhat.com>
* gdb.base/maint.exp <maint info line-table w/o a file name>: Use
gdb_test_multiple, tighten regexps and match symtabs and line
tables incrementally.
Testing a powerpc toolchain running gdbserver on the other end i noticed a
failure in gdb.base/foll-exec.exp. Turns out gdb is outputting a slightly
different pattern due to the presence of debug information.
--
foll-exec is about to execlp(execd-prog)...^M
Continuing.^M
process 21222 is executing new program: gdb.d/outputs/gdb.base/foll-exec/execd-prog^M
^M
Catchpoint 2 (exec'd gdb.d/outputs/gdb.base/foll-exec/execd-prog), _start () at ../sysdeps/powerpc/powerpc32/dl-start.S:32^M
--
Notice the presence of source file information.
Now, on my local machine, i get this:
--
foll-exec is about to execlp(execd-prog)...^M
Continuing.^M
process 9285 is executing new program: gdb/testsuite/outputs/gdb.base/foll-exec/execd-prog^M
^M
Catchpoint 2 (exec'd gdb/testsuite/outputs/gdb.base/foll-exec/execd-prog), 0x00007ffff7dd7cc0 in ?? () from /lib64/ld-linux-x86-64.so.2^M
--
So the output differs slightly and the testcase is actually expecting only
the second form with the "in" anchor.
This patch removes the "in" pattern and lets the test match both kinds of
output.
gdb/testsuite/ChangeLog:
2016-10-28 Luis Machado <lgustavo@codesourcery.com>
* gdb.base/foll-exec.exp (do_exec_tests): Make test pattern more
general.
This commit fixes these regressions:
FAIL: gdb.base/maint.exp: mt set per on for expand-symtabs
FAIL: gdb.base/maint.exp: maint set per-command on
caused by commit 1e3b796d58 ("Change command stats reporting to use
class").
gdb.log shows that the command stats are now printing garbage:
(gdb) mt set per on
Command execution time: -6.-419590 (cpu), 1467139648.-7706296840 (wall)
Space used: 9809920 (-33276528 for this command)
(gdb) FAIL: gdb.base/maint.exp: mt set per on for expand-symtabs
while there should have been no output at all.
The stats printing is done from within the scoped_command_stats's
destructor, depending on whether some flags in the object are set.
The problem is simply that scoped_command_stats's ctor misses clearing
those flags on some paths.
Since scoped_command_stats objects are allocated on the stack, whether
you'll see the regression simply depends on whatever happens to
already be on the stack space the object occupies.
gdb/ChangeLog:
2016-10-28 Pedro Alves <palves@redhat.com>
* maint.c (scoped_command_stats::scoped_command_stats): Clear
m_space_enabled, m_time_enabled and m_symtab_enabled.
Most of the time, the trace should be in one piece. This case is handled fine
by GDB. In some cases, however, there may be gaps in the trace. They result
from trace decode errors or from overflows.
A gap in the trace means we lost an unknown amount of trace. Gaps can be very
small, such as a few instructions in the same function, or they can be rather
big. We may, for example, lose a few function calls or returns. The trace may
continue in a different function and we likely don't know how we got there.
Even though we can't say how the program executed across a gap, higher levels
may not be impacted too much by it. Let's assume we have functions a-e and a
trace that looks roughly like this:
a
\
b b
\ /
c <gap> c
/
d d
\ /
e
Even though we can't say for sure, it is likely that b and c are the same
function instance before and after the gap. This patch is trying to connect
the c and b function segments across the gap.
This will add a to the back trace of b on the right hand side. The changes are
reflected in GDB's internal representation of the trace and will improve:
- the output of "record function-call-history /c"
- the output of "backtrace" in replay mode
- source stepping in replay mode
will be improved indirectly via the improved back trace
I don't have an automated test for this patch; decode errors will be fixed and
overflows occur sporadically and are quite rare. I tested it by hacking GDB to
provoke a decode error and on the expected gap in the gdb.btrace/dlopen.exp
test.
The issue is that we can't predict where we will be able to re-sync in case of
errors. For the expected decode error in gdb.btrace/dlopen.exp, for example, we
may be able to re-sync somewhere in dlclose, in test, in main, or not at all.
Here's one example run of gdb.btrace/dlopen.exp with and without this patch.
(gdb) info record
Active record target: record-btrace
Recording format: Intel Processor Trace.
Buffer size: 16kB.
warning: Non-contiguous trace at instruction 66608 (offset = 0xa83, pc = 0xb7fdcc31).
warning: Non-contiguous trace at instruction 66652 (offset = 0xa9b, pc = 0xb7fdcc31).
warning: Non-contiguous trace at instruction 66770 (offset = 0xacb, pc = 0xb7fdcc31).
warning: Non-contiguous trace at instruction 66966 (offset = 0xb60, pc = 0xb7ff5ee4).
warning: Non-contiguous trace at instruction 66994 (offset = 0xb74, pc = 0xb7ff5f24).
warning: Non-contiguous trace at instruction 67334 (offset = 0xbac, pc = 0xb7ff5e6d).
warning: Non-contiguous trace at instruction 69022 (offset = 0xc04, pc = 0xb7ff60b3).
warning: Non-contiguous trace at instruction 69116 (offset = 0xc1c, pc = 0xb7ff60b3).
warning: Non-contiguous trace at instruction 69504 (offset = 0xc74, pc = 0xb7ff605d).
warning: Non-contiguous trace at instruction 83648 (offset = 0xecc, pc = 0xb7ff6134).
warning: Decode error (-13) at instruction 83876 (offset = 0xf48, pc = 0xb7fd6380): no memory mapped at this address.
warning: Non-contiguous trace at instruction 83876 (offset = 0x11b7, pc = 0xb7ff1c70).
Recorded 83948 instructions in 912 functions (12 gaps) for thread 1 (process 12996).
(gdb) record instruction-history 83876, +2
83876 => 0xb7fec46f <call_init.part.0+95>: call *%eax
[decode error (-13): no memory mapped at this address]
[disabled]
83877 0xb7ff1c70 <_dl_close_worker.part.0+1584>: nop
Without the patch, the trace is disconnected and the backtrace is short:
(gdb) record goto 83876
#0 0xb7fec46f in call_init.part () from /lib/ld-linux.so.2
(gdb) backtrace
#0 0xb7fec46f in call_init.part () from /lib/ld-linux.so.2
#1 0xb7fec5d0 in _dl_init () from /lib/ld-linux.so.2
#2 0xb7ff0fe3 in dl_open_worker () from /lib/ld-linux.so.2
Backtrace stopped: not enough registers or memory available to unwind further
(gdb) record goto 83877
#0 0xb7ff1c70 in _dl_close_worker.part.0 () from /lib/ld-linux.so.2
(gdb) backtrace
#0 0xb7ff1c70 in _dl_close_worker.part.0 () from /lib/ld-linux.so.2
#1 0xb7ff287a in _dl_close () from /lib/ld-linux.so.2
#2 0xb7fc3d5d in dlclose_doit () from /lib/libdl.so.2
#3 0xb7fec354 in _dl_catch_error () from /lib/ld-linux.so.2
#4 0xb7fc43dd in _dlerror_run () from /lib/libdl.so.2
#5 0xb7fc3d98 in dlclose () from /lib/libdl.so.2
#6 0x0804860a in test ()
#7 0x08048628 in main ()
With the patch, GDB is able to connect the trace pieces and we get a full
backtrace.
(gdb) record goto 83876
#0 0xb7fec46f in call_init.part () from /lib/ld-linux.so.2
(gdb) backtrace
#0 0xb7fec46f in call_init.part () from /lib/ld-linux.so.2
#1 0xb7fec5d0 in _dl_init () from /lib/ld-linux.so.2
#2 0xb7ff0fe3 in dl_open_worker () from /lib/ld-linux.so.2
#3 0xb7fec354 in _dl_catch_error () from /lib/ld-linux.so.2
#4 0xb7ff02e2 in _dl_open () from /lib/ld-linux.so.2
#5 0xb7fc3c65 in dlopen_doit () from /lib/libdl.so.2
#6 0xb7fec354 in _dl_catch_error () from /lib/ld-linux.so.2
#7 0xb7fc43dd in _dlerror_run () from /lib/libdl.so.2
#8 0xb7fc3d0e in dlopen@@GLIBC_2.1 () from /lib/libdl.so.2
#9 0xb7ff28ee in _dl_runtime_resolve () from /lib/ld-linux.so.2
#10 0x0804841c in ?? ()
#11 0x08048470 in dlopen@plt ()
#12 0x080485a3 in test ()
#13 0x08048628 in main ()
(gdb) record goto 83877
#0 0xb7ff1c70 in _dl_close_worker.part.0 () from /lib/ld-linux.so.2
(gdb) backtrace
#0 0xb7ff1c70 in _dl_close_worker.part.0 () from /lib/ld-linux.so.2
#1 0xb7ff287a in _dl_close () from /lib/ld-linux.so.2
#2 0xb7fc3d5d in dlclose_doit () from /lib/libdl.so.2
#3 0xb7fec354 in _dl_catch_error () from /lib/ld-linux.so.2
#4 0xb7fc43dd in _dlerror_run () from /lib/libdl.so.2
#5 0xb7fc3d98 in dlclose () from /lib/libdl.so.2
#6 0x0804860a in test ()
#7 0x08048628 in main ()
It worked nicely in this case but it may, of course, also lead to weird
connections; it is a heuristic, after all.
It works best when the gap is small and the trace pieces are long.
gdb/
* btrace.c (bfun_s): New typedef.
(ftrace_update_caller): Print caller in debug dump.
(ftrace_get_caller, ftrace_match_backtrace, ftrace_fixup_level)
(ftrace_compute_global_level_offset, ftrace_connect_bfun)
(ftrace_connect_backtrace, ftrace_bridge_gap, btrace_bridge_gaps): New.
(btrace_compute_ftrace_bts): Pass vector of gaps. Collect gaps.
(btrace_compute_ftrace_pt): Likewise.
(btrace_compute_ftrace): Split into this, ...
(btrace_compute_ftrace_1): ... this, and ...
(btrace_finalize_ftrace): ... this. Call btrace_bridge_gaps.
When encountering a return for which we have not seen a corresponding call, GDB
starts a new back trace from level -1, i.e. from the level of the first function
in the trace.
In the presence of trace gaps, this may cause some rather big jump.
(gdb) record function-call-history /c 192, +8
192 sbrk
193 brk
194 __x86.get_pc_thunk.bx
195 brk
196 __kernel_vsyscall
197 [disabled]
198 __kernel_vsyscall
199 brk
200 sbrk
This doesn't help to make things more clear. Let's remain on the same level
instead.
(gdb) record function-call-history /c 192, +8
192 sbrk
193 brk
194 __x86.get_pc_thunk.bx
195 brk
196 __kernel_vsyscall
197 [disabled]
198 __kernel_vsyscall
199 brk
200 sbrk
In this case it will look like we were able to connect the trace parts across
the disabled gap. We were not. More work is required to achieve this.
In the general case, the function-call history for the two trace parts won't
match. They may be off by a few levels or they may be entirely different. All
this patch does is to preserve the indentation level of the record
function-call-history command.
The disabled gap is caused by a sysenter not returning to the next instruction.
(gdb) record function-call-history /i 196, +1
196 __kernel_vsyscall inst 66515,66519
(gdb) record instruction-history 66515
66515 0xb7fdcbf8 <__kernel_vsyscall+0>: push %ecx
66516 0xb7fdcbf9 <__kernel_vsyscall+1>: push %edx
66517 0xb7fdcbfa <__kernel_vsyscall+2>: push %ebp
66518 0xb7fdcbfb <__kernel_vsyscall+3>: mov %esp,%ebp
66519 0xb7fdcbfd <__kernel_vsyscall+5>: sysenter
[disabled]
66520 0xb7fdcc08 <__kernel_vsyscall+16>: pop %ebp
66521 0xb7fdcc09 <__kernel_vsyscall+17>: pop %edx
66522 0xb7fdcc0a <__kernel_vsyscall+18>: pop %ecx
66523 0xb7fdcc0b <__kernel_vsyscall+19>: ret
66524 0xb7e8e09e <brk+30>: xchg %ecx,%ebx
(gdb) disassemble 0xb7fdcbf8, 0xb7fdcc0c
Dump of assembler code from 0xb7fdcbf8 to 0xb7fdcc0c:
0xb7fdcbf8 <__kernel_vsyscall+0>: push %ecx
0xb7fdcbf9 <__kernel_vsyscall+1>: push %edx
0xb7fdcbfa <__kernel_vsyscall+2>: push %ebp
0xb7fdcbfb <__kernel_vsyscall+3>: mov %esp,%ebp
0xb7fdcbfd <__kernel_vsyscall+5>: sysenter
0xb7fdcbff <__kernel_vsyscall+7>: nop
0xb7fdcc00 <__kernel_vsyscall+8>: nop
0xb7fdcc01 <__kernel_vsyscall+9>: nop
0xb7fdcc02 <__kernel_vsyscall+10>: nop
0xb7fdcc03 <__kernel_vsyscall+11>: nop
0xb7fdcc04 <__kernel_vsyscall+12>: nop
0xb7fdcc05 <__kernel_vsyscall+13>: nop
0xb7fdcc06 <__kernel_vsyscall+14>: int $0x80
0xb7fdcc08 <__kernel_vsyscall+16>: pop %ebp
0xb7fdcc09 <__kernel_vsyscall+17>: pop %edx
0xb7fdcc0a <__kernel_vsyscall+18>: pop %ecx
0xb7fdcc0b <__kernel_vsyscall+19>: ret
End of assembler dump.
I've seen this on 32-bit Fedora 23. I have not investigated what causes this
and whether we can avoid the gap in the first place. Let's first try to make
GDB handle such gaps more gracefully.
gdb/
* btrace.c (ftrace_new_return): Start from the previous function's level
if we can't find a matching call for a return.
An unconditional jump to the start of a function typically indicates a tail
call.
If we can't determine the start of the function at the destination address, we
used to treat it as a tail call, as well. This results in lots of tail calls
for code for which we don't have symbol information.
Restrict the heuristic to only consider jumps as tail calls that switch
functions in the case where we can't determine the start of a function. This
effectively disables tail call detection for code without symbol information.
gdb/
* btrace.c (ftrace_update_function): Update tail call heuristic.
GDB ignores trace gaps from decode errors or overflows at the beginning of the
trace. There isn't really a gap in the trace; the trace just starts a bit
later than expected.
In cases where there is no trace at all or where the trace is smaller than
expected, this may hide the reason for the missing trace.
Allow leading trace gaps. They will be shown as decode warnings and by the
record function-call-history command.
(gdb) info record
Active record target: record-btrace
Recording format: Intel Processor Trace.
Buffer size: 16kB.
warning: Decode error (-6) at instruction 0 (offset = 0x58, pc = 0x0): unexpected packet context.
warning: Decode error (-6) at instruction 0 (offset = 0xb0, pc = 0x0): unexpected packet context.
warning: Decode error (-6) at instruction 0 (offset = 0x168, pc = 0x0): unexpected packet context.
warning: Decode error (-6) at instruction 54205 (offset = 0xe08, pc = 0x0): unexpected packet context.
warning: Decode error (-6) at instruction 54205 (offset = 0xe60, pc = 0x0): unexpected packet context.
warning: Decode error (-6) at instruction 54205 (offset = 0xed8, pc = 0x0): unexpected packet context.
Recorded 91582 instructions in 1111 functions (6 gaps) for thread 1 (process 15710).
(gdb) record function-call-history /c 1
1 [decode error (-6): unexpected packet context]
2 [decode error (-6): unexpected packet context]
3 [decode error (-6): unexpected packet context]
4 _dl_addr
5 ??
6 _dl_addr
7 ??
8 ??
9 ??
10 ??
Leading trace gaps will not be shown by the record instruction-history command
without further changes.
gdb/
* btrace.c (btrace_compute_ftrace_bts, ftrace_add_pt): Allow leading gaps.
* record-btrace.c (record_btrace_single_step_forward)
(record_btrace_single_step_backward): Jump back to last instruction if
step ends at a gap.
(record_btrace_goto_begin): Skip gaps.
Trace gaps due to overflows or non-contiguous trace are ignored in the 'info
record' command. Fix that.
Also add a warning when decoding the trace and print the instruction number
preceding the trace gap in that warning message. It looks like this:
(gdb) info record
Active record target: record-btrace
Recording format: Intel Processor Trace.
Buffer size: 16kB.
warning: Decode error (-13) at instruction 101044 (offset = 0x29f0, pc = 0x7ffff728a642): no memory mapped at this address.
Recorded 101044 instructions in 2093 functions (1 gaps) for thread 1 (process 5360).
(gdb) record instruction-history 101044
101044 0x00007ffff728a640: pop %r13
[decode error (-13): no memory mapped at this address]
Remove the dead code that was supposed to print a gaps warning at the end of
trace decode. This isn't really needed since we now print a warning for each
gap.
gdb/
* btrace.c (ftrace_add_pt): Fix gap indication. Add warning for non-
contiguous trace and overflow. Rephrase trace decode warning and print
instruction number. Remove dead gaps warning.
(btrace_compute_ftrace_bts): Rephrase warnings and print instruction
number.
If the target can do software single step, it can do range
stepping.
gdb/gdbserver:
2016-10-27 Yao Qi <yao.qi@linaro.org>
* linux-low.c (linux_supports_agent): Return true if
can_software_single_step return true.