aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2016-11-08cli-script.c: Simplify using std::string, eliminate cleanupsPedro Alves2-76/+41
gdb/ChangeLog: 2016-11-08 Pedro Alves <palves@redhat.com> * cli/cli-script.c (execute_control_command): Use std::string instead of cleanups. (locate_arg): Constify return type. (insert_args): Constify paremeter. Simplify using std::string. Return a std::string.
2016-11-08breakpoint.c:commands_command_1 constification and cleanupPedro Alves3-26/+28
This is constification needed for next patch. Adjust commands_command_1 to use std::string too because the "arg" parameter is currently overwritten and then passed to make_cleanup. The constification alone would trigger a compile error in the make_cleanup call otherwise (passing const char * to void * parameter). Using std::string gets rid of the cleanup in the first place, resulting in simpler code. gdb/ChangeLog: 2016-11-08 Pedro Alves <palves@redhat.com> * breakpoint.c (struct commands_info) <arg>: Constify. (commands_command_1): Constify 'arg' parameter. Use std::string and string_printf. (commands_from_control_command): Constify 'arg' parameter. (map_breakpoint_numbers): Constify 'args' parameter. * breakpoint.h (commands_from_control_command): Constify 'arg' parameter.
2016-11-08cli/cli-script.c: Remove some dead NULL checksPedro Alves2-11/+6
gdb/ChangeLog: 2016-11-08 Pedro Alves <palves@redhat.com> * cli/cli-script.c (execute_control_command): Assume insert_args never returns NULL. (insert_args): Assume xmalloc never returns NULL.
2016-11-08Introduce string_printfPedro Alves5-1/+98
This introduces the string_printf function. Like asprintf, but returns a std::string. gdb/ChangeLog: 2016-11-08 Pedro Alves <palves@redhat.com> * Makefile.in (COMMON_OBS): Add utils-selftests.o. * common/common-utils.c (string_printf): New function. * common/common-utils.h: Include <string>. (string_printf): Declare. * utils-selftests.c: New file.
2016-11-08gdbarch software_single_step returns VEC (CORE_ADDR) *Yao Qi26-173/+225
This patch changes gdbarch method software_single_step to return a vector of addresses on which GDB should insert breakpoints, and don't insert breakpoints. Instead, the caller of gdbarch_software_single_step inserts breakpoints if the returned vector is not NULL. gdb: 2016-11-08 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (aarch64_software_single_step): Return VEC (CORE_ADDR) *. Return NULL instead of 0. Don't call insert_single_step_breakpoint. * alpha-tdep.c (alpha_deal_with_atomic_sequence): Likewise. (alpha_software_single_step): Likewise. * alpha-tdep.h (alpha_software_single_step): Update declaration. * arm-linux-tdep.c (arm_linux_software_single_step): Return VEC (CORE_ADDR) *. Return NULL instead of 0. * arm-tdep.c (arm_software_single_step): Return NULL instead of 0. * arm-tdep.h (arm_software_single_step): Update declaration. * breakpoint.c (insert_single_step_breakpoints): New function. * breakpoint.h (insert_single_step_breakpoints): Declare. * cris-tdep.c (cris_software_single_step): Return VEC (CORE_ADDR) *. Don't call insert_single_step_breakpoint. * gdbarch.sh (software_single_step): Change it to return VEC (CORE_ADDR) *. * gdbarch.c, gdbarch.h: Regenerated. * infrun.c (maybe_software_singlestep): Adjust. * mips-tdep.c (mips_deal_with_atomic_sequence): Return VEC (CORE_ADDR) *. Don't call insert_single_step_breakpoint. (micromips_deal_with_atomic_sequence): Likewise. (deal_with_atomic_sequence): Likewise. (mips_software_single_step): Likewise. * mips-tdep.h (mips_software_single_step): Update declaration. * moxie-tdep.c (moxie_software_single_step): Likewise. * nios2-tdep.c (nios2_software_single_step): Likewise. * ppc-tdep.h (ppc_deal_with_atomic_sequence): Update declaration. * record-full.c (record_full_resume): Adjust. (record_full_wait_1): Likewise. * rs6000-aix-tdep.c (rs6000_software_single_step): Return VEC (CORE_ADDR) *. Don't call insert_single_step_breakpoint. * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Return VEC (CORE_ADDR) *. Don't call insert_single_step_breakpoint. * s390-linux-tdep.c (s390_software_single_step): Likewise. * sparc-tdep.c (sparc_software_single_step): Likewise. * spu-tdep.c (spu_software_single_step): Likewise. * tic6x-tdep.c (tic6x_software_single_step): Likewise.
2016-11-08Clear addr bit in next_pcs vectorYao Qi3-2/+15
This patch is to split the loop of calling gdbarch_addr_bits_remove and insert_single_step_breakpoint into two loops. gdb: 2016-11-08 Yao Qi <yao.qi@linaro.org> * arm-linux-tdep.c (arm_linux_software_single_step): Write adjusted address back to vector. Call insert_single_step_breakpoint in a new loop. * arm-tdep.c (arm_software_single_step): Likewise.
2016-11-08Remove arm_insert_single_step_breakpointYao Qi4-18/+20
This patch is to remove arm_insert_single_step_breakpoint. gdb: 2016-11-08 Yao Qi <yao.qi@linaro.org> * arm-linux-tdep.c (arm_linux_software_single_step): Don't call arm_insert_single_step_breakpoint, call insert_single_step_breakpoint instead. * arm-tdep.c (arm_insert_single_step_breakpoint): Remove. (arm_software_single_step): Don't call arm_insert_single_step_breakpoint, call insert_single_step_breakpoint instead. * arm-tdep.h (arm_insert_single_step_breakpoint): Remove declaration.
2016-11-08Fix PR breakpoints/20739: Badly formatted adress string in error messageCordian A. Daniluk2-1/+7
Remove duplicate `0x'-prefix for the hex address printed. `paddress' already prepends this, so no need to do it manually. gdb/ChangeLog: 2016-11-08 Cordian A. Daniluk <th3c0r1uk@gmail.com> PR breakpoints/20739 * breakpoint.c (check_fast_tracepoint_sals): Don't print duplicate 0x prefix.
2016-11-08Fix indentationYao Qi2-3/+7
gdb: 2016-11-08 Yao Qi <yao.qi@linaro.org> * rust-lang.c (val_print_struct): Fix indentation.
2016-11-08Check for truncated registers in process_g_packetLionel Flandrin2-3/+22
While investigating an unrelated issue in remote.c I noticed that the bound checking for 'g' packets was bogus: The previous code would only check that the first byte of the register was within bounds before passing the buffer to regcache_raw_supply. If it turned out that the register in the 'g' packet was incomplete then regcache_raw_supply would proceed to memcpy out-of-bounds. Since the buffer is allocated with alloca it's relatively unlikely to crash (you just end up dumping gdb's stack into the cache) but it's still a bit messy. I changed this logic to check for truncated registers and raise an error if one is encountered. Hopefully it should make debugging remote stubs a bit easier. gdb/ChangeLog: 2016-11-08 Lionel Flandrin <lionel@svkt.org> * remote.c (process_g_packet): Detect truncated registers in 'g' packets and raise an error.
2016-11-07Fix ext lang calls to value_struct_elt.Doug Evans3-2/+9
gdb/ChangeLog: * guile/scm-value.c (gdbscm_value_field): Fix call to value_struct_elt. * python/py-value.c (valpy_getitem): Ditto.
2016-11-07i386-tdep.c (i386_gdbarch_init): Add comments.Doug Evans2-2/+10
gdb/ChangeLog: * i386-tdep.c (i386_gdbarch_init): Add comments.
2016-11-07python/py-unwind.c (unwind_infopy_str): Fix use of VEC_iterate.Doug Evans2-3/+5
gdb/ChangeLog: * python/py-unwind.c (unwind_infopy_str): Fix use of VEC_iterate.
2016-11-07configure.tgt (x86_64-*-elf*): Remove i386bsd-tdep.o.Doug Evans2-3/+10
gdb/ChangeLog: * configure.tgt (x86_64-*-elf*): Remove i386bsd-tdep.o.
2016-11-04Fix a few typosSimon Marchi8-8/+19
gdb/ChangeLog: * maint.c (scoped_command_stats::scoped_command_stats): Fix typo. * ppcnbsd-tdep.c (_initialize_ppcnbsd_tdep): Likewise. * ppcobsd-tdep.c (_initialize_ppcobsd_tdep): Likewise. * ui-out.c (ui_out_new): Likewise. * utils.c (init_page_info): Likewise. (reset_prompt_for_continue_wait_time): Likewise. * windows-nat.c (windows_init_thread_list): Likewise. * xtensa-tdep.c (call0_analyze_prologue): Likewise.
2016-11-03Add support for the sizeof function in RustManish Goregaokar4-3/+17
2016-10-29 Manish Goregaokar <manish@mozilla.com> gdb/ChangeLog: * rust-exp.y: Parse `sizeof(exp)` as `UNOP_SIZEOF` gdb/testsuite/ChangeLog: * gdb.rust/simple.exp: Add tests for `sizeof(expr)`
2016-11-03Add support for untagged unions in RustManish Goregaokar2-118/+201
2016-10-28 Manish Goregaokar <manish@mozilla.com> gdb/ChangeLog: * rust-lang.c (rust_union_is_untagged): Add function to check if a union is an untagged unioni (rust_val_print): Handle printing of untagged union values (rust_print_type): Handle printing of untagged union types (rust_evaluate_subexp): Handle evaluating field access on untagged unions
2016-11-03Fix handling of discriminantless univariant enums in Rust; fix bug with ↵Manish Goregaokar5-1/+70
encoded enums 2016-10-27 Manish Goregaokar <manish@mozilla.com> gdb/ChangeLog: * rust-lang.c (rust_get_disr_info): Treat univariant enums without discriminants as encoded enums with a real field * rust-lang.c (rust_evaluate_subexp): Handle field access on encoded struct-like enums gdb/testsuite/ChangeLog: * simple.rs: Add test for univariant enums without discriminants and for encoded struct-like enums * simple.exp: Add test expectations
2016-11-03Replace YY_NULL with YY_NULLPTR in LANG-exp.cYao Qi2-0/+5
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.
2016-11-03Remove GDBARCH_BREAKPOINT_MANIPULATION and SET_GDBARCH_BREAKPOINT_MANIPULATIONYao Qi45-141/+384
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.
2016-11-03Remove arm_override_modeYao Qi2-14/+6
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.
2016-11-03Determine the kind of single step breakpointYao Qi8-2/+135
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.
2016-11-03Add default_breakpoint_from_pcYao Qi20-82/+35
This patch adds the default implementation of gdbarch breakpoint_from_pc, which is, const gdb_byte * default_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr) { int kind = gdbarch_breakpoint_kind_from_pc (gdbarch, pcptr); return gdbarch_sw_breakpoint_from_kind (gdbarch, kind, lenptr); } so gdbarch can only defines sw_breakpoint_from_kind and breakpoint_kind_from_pc. gdb: 2016-11-03 Yao Qi <yao.qi@linaro.org> * arch-utils.c (default_breakpoint_from_pc): New function. * arch-utils.h (GDBARCH_BREAKPOINT_FROM_PC): Remove. (GDBARCH_BREAKPOINT_MANIPULATION): Don't use GDBARCH_BREAKPOINT_FROM_PC. (SET_GDBARCH_BREAKPOINT_MANIPULATION): Don't call set_gdbarch_breakpoint_from_pc. (default_breakpoint_from_pc): Remove declaration. * gdbarch.sh (breakpoint_from_pc): Add its default implementation. * gdbarch.c, gdbarch.h: Regenerate. * arm-tdep.c: Don't use GDBARCH_BREAKPOINT_FROM_PC. * arc-tdep.c, bfin-tdep.c, cris-tdep.c, iq2000-tdep.c: Likewise. * m32r-tdep.c, mips-tdep.c, mt-tdep.c: Likewise. * nios2-tdep.c, score-tdep.c, sh-tdep.c: Likewise. * sh64-tdep.c, tic6x-tdep.c, v850-tdep.c, xtensa-tdep.c: Likewise.
2016-11-03Remove gdbarch_remote_breakpoint_from_pcYao Qi8-66/+13
This patch removes gdbarch method remote_breakpoint_from_pc, as it is no longer used. gdb: 2016-11-03 Yao Qi <yao.qi@linaro.org> * arch-utils.c (default_remote_breakpoint_from_pc): Remove. * arch-utils.h (default_remote_breakpoint_from_pc): Remove. * arm-tdep.c (arm_remote_breakpoint_from_pc): Remove. (arm_gdbarch_init): Don't call set_gdbarch_remote_breakpoint_from_pc. * gdbarch.sh (remote_breakpoint_from_pc): Remove. * gdbarch.c, gdbarch.h: Regenerate. * mips-tdep.c (mips_remote_breakpoint_from_pc): Remove. (mips_gdbarch_init): Don't call set_gdbarch_remote_breakpoint_from_pc.
2016-11-03Rename placed_size to kindYao Qi5-15/+17
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.
2016-11-03New gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kindYao Qi22-52/+238
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.
2016-11-03Split breakpoint_from_pc to breakpoint_kind_from_pc and sw_breakpoint_from_kindYao Qi18-386/+522
We convert each ARCH_breakpoint_from_pc to ARCH_breakpoint_kind_from_pc and ARCH_sw_breakpoint_from_kind. Note that gdbarch doesn't have methods breakpoint_kind_from_pc and sw_breakpoint_from_kind so far. gdb: 2016-11-03 Yao Qi <yao.qi@linaro.org> * arch-utils.h (GDBARCH_BREAKPOINT_FROM_PC): New macro. (GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): New macro. * arm-tdep.c (arm_breakpoint_from_pc): Remove. (arm_breakpoint_kind_from_pc): New function. (arm_sw_breakpoint_from_kind): New function. (arm_breakpoint_from_pc): Call arm_breakpoint_kind_from_pc and arm_sw_breakpoint_from_kind. Use GDBARCH_BREAKPOINT_FROM_PC. (arm_remote_breakpoint_from_pc): Call arm_breakpoint_kind_from_pc. (arm_gdbarch_init): Replace set_gdbarch_breakpoint_from_pc with SET_GDBARCH_BREAKPOINT_MANIPULATION. * arc-tdep.c: Likewise. * bfin-tdep.c: Likewise. * cris-tdep.c: Likewise. * iq2000-tdep.c: Likewise. * m32r-tdep.c: Likewise. * mips-tdep.c: Likewise. * mt-tdep.c: Likewise. * nios2-tdep.c: Likewise. * rs6000-tdep.c: Likewise. * score-tdep.c: Likewise. * sh-tdep.c: Likewise. * sh64-tdep.c: Likewise. * tic6x-tdep.c: Likewise. * v850-tdep.c: Likewise. * xtensa-tdep.c: Likewise.
2016-11-03Add enum for mips breakpoint kindsYao Qi2-15/+31
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.
2016-11-03GDBARCH_BREAKPOINT_MANIPULATION and SET_GDBARCH_BREAKPOINT_MANIPULATIONYao Qi30-272/+147
Many archs have only one kind of breakpoint, so their breakpoint_from_pc implementations are quite similar. This patch uses macro GDBARCH_BREAKPOINT_MANIPULATION and SET_GDBARCH_BREAKPOINT_MANIPULATION for breakpoint_from_pc, so that we can easily switch from breakpoint_from_pc to breakpoint_kind_from_pc and sw_breakpoint_from_kind later. gdb: 2016-11-03 Yao Qi <yao.qi@linaro.org> * arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): New macro. (SET_GDBARCH_BREAKPOINT_MANIPULATION): New macro. aarch64-tdep.c (aarch64_breakpoint_from_pc): Remove. Use GDBARCH_BREAKPOINT_MANIPULATION. (aarch64_gdbarch_init): Replace set_gdbarch_breakpoint_from_pc with SET_GDBARCH_BREAKPOINT_MANIPULATION. * alpha-tdep.c: Likewise. * avr-tdep.c: Likewise. * frv-tdep.c: Likewise. * ft32-tdep.c: Likewise. * h8300-tdep.c: Likewise. * hppa-tdep.c: Likewise. * i386-tdep.c: Likewise. * lm32-tdep.c: Likewise. * m32c-tdep.c: Likewise. * m68hc11-tdep.c: Likewise. * m68k-tdep.c: Likewise. * m88k-tdep.c: Likewise. * mep-tdep.c: Likewise. * microblaze-tdep.c: Likewise. * mn10300-tdep.c: Likewise. * moxie-tdep.c: Likewise. * msp430-tdep.c: Likewise. * rl78-tdep.c: Likewise. * rx-tdep.c: Likewise. * s390-linux-tdep.c: Likewise. * sparc-tdep.c: Likewise. * spu-tdep.c: Likewise. * tilegx-tdep.c: Likewise. * vax-tdep.c: Likewise. * xstormy16-tdep.c: Likewise.
2016-11-03gdbarch_breakpoint_from_pc doesn't return NULLYao Qi4-6/+8
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.
2016-11-02Fix dwarf_expr_context method regressionsTom Tromey4-31/+38
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.
2016-10-31Remove IRIX 5 <sys/proc.h> _KMEMUSER workaroundMaciej W. Rozycki4-16/+7
Complement commit 3831839c089c ("Delete IRIX support") and remove the IRIX 5 <sys/proc.h> _KMEMUSER workaround from the `configure' script, as IRIX is no longer a supported host configuration. gdb/ * configure.ac <mips-sgi-irix5*>: Remove <sys/proc.h> _KMEMUSER workaround. * configure: Regenerate. * config.in: Regenerate.
2016-10-31MIPS: Remove remains of legacy remote target supportMaciej W. Rozycki2-38/+8
Complement commit f7c382926d78 ("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-31MIPS: Remove remains of IRIX OS ABI supportMaciej W. Rozycki4-36/+13
Complement commit 3831839c089c ("Delete IRIX support") and remove dead MIPS target IRIX OS ABI support code. gdb/ * defs.h (gdb_osabi): Remove GDB_OSABI_IRIX enum value. * osabi.c (gdb_osabi_names): Remove "Irix" entry. * mips-tdep.c (mips_irix_reg_names): Remove. (mips_register_type): Remove GDB_OSABI_IRIX code. (mips_pseudo_register_type): Likewise. (mips_breakpoint_from_pc): Likewise. (mips_gdbarch_init): Likewise.
2016-10-29gdb/NEWS: Clarify C++ requirementPedro Alves2-1/+5
gdb/ChangeLog: 2016-10-29 Pedro Alves <palves@redhat.com> * NEWS: Clarify C++ requirement.
2016-10-29gdb/NEWS: Mention C++11 requirementPedro Alves2-1/+7
gdb/ChangeLog: 2016-10-29 Pedro Alves <palves@redhat.com> * NEWS: Adjust to mention C++11 requirement.
2016-10-29Support command-line redirection in native MS-Windows debuggingEli Zaretskii3-33/+388
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.
2016-10-29gdb/doc: Remove mention of vCont's default actionsPedro Alves2-3/+7
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.
2016-10-28gdb: Require C++11Pedro Alves13-14/+2019
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.
2016-10-28gdb: Import AX_CXX_COMPILE_STDCXX from the GNU Autoconf ArchivePedro Alves2-0/+566
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.
2016-10-28gdb/testsuite: Avoid a buffer overrun in `gdb.base/maint.exp'Pedro Alves2-3/+41
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.
2016-10-28Make gdb.base/foll-exec.exp test pattern more generalLuis Machado2-1/+6
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.
2016-10-28Fix gdb.base/maint.exp regressionsPedro Alves2-0/+11
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 1e3b796d58ac ("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.
2016-10-28btrace: bridge gapsMarkus Metzger2-18/+425
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.
2016-10-28btrace: preserve function level for unexpected returnsMarkus Metzger2-9/+18
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.
2016-10-28btrace: update tail call heuristicMarkus Metzger2-2/+13
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.
2016-10-28btrace: allow leading trace gapsMarkus Metzger3-31/+61
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.
2016-10-28btrace: fix gap indicationMarkus Metzger2-19/+43
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.
2016-10-27Enable range stepping if software single step is supportedYao Qi2-0/+7
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.
2016-10-27Get pending events in randomYao Qi4-2/+61
Nowadays, we select events to be reported to GDB in random, however that is not enough when many GDBserver internal events (not reported to GDB) are generated. GDBserver pulls all events out of kernel via waitpid, and leave them pending. When goes through threads which have pending events, GDBserver uses find_inferior to find the first thread which has pending event, and consumes it. Note that find_inferior always iterate threads in a fixed order. If multiple threads keep hitting GDBserver breakpoints, range stepping with single-step breakpoint for example, threads in the head of the thread list are more likely to be processed and threads in the tail are starved. This causes some timeout fails in gdb.threads/non-stop-fair-events.exp when range stepping is enabled on arm-linux. This patch fixes this issue by randomly selecting pending events. It adds a new function find_inferior_in_random, which iterates threads which have pending events randomly. gdb/gdbserver: 2016-10-27 Yao Qi <yao.qi@linaro.org> * inferiors.c (find_inferior_in_random): New function. * inferiors.h (find_inferior_in_random): Declare. * linux-low.c (linux_wait_for_event_filtered): Call find_inferior_in_random instead of find_inferior.