aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)Author
2017-05-26Add regcache raw_supply_integer and raw_collect_integer.Alan Hayward
Use these to replace instances of MAX_REGISTER_SIZE. * defs.h (copy_integer_to_size): New declaration. * findvar.c (copy_integer_to_size): New function. (do_cint_test): New selftest function. (copy_integer_to_size_test): Likewise. (_initialize_findvar): Likewise. * mips-fbsd-tdep.c (mips_fbsd_supply_reg): Use raw_supply_integer. (mips_fbsd_collect_reg): Use raw_collect_integer. * mips-linux-tdep.c (supply_32bit_reg): Use raw_supply_integer. (mips64_fill_gregset): Use raw_collect_integer (mips64_fill_fpregset): Use raw_supply_integer. * regcache.c (regcache::raw_supply_integer): New function. (regcache::raw_collect_integer): Likewise. * regcache.h: (regcache::raw_supply_integer): New declaration. (regcache::raw_collect_integer): Likewise.
2017-05-24Add unit test to gdbarch methods register_to_value and value_to_registerYao Qi
This patch adds one unit test for gdbarch methods register_to_value and value_to_register. The test pass different combinations of {regnu, type} to gdbarch_register_to_value and gdbarch_value_to_register. In order to do the test, add a new function create_new_frame to create a fake frame. It can be improved after we converted frame_info to class. In order to isolate regcache (from target_ops operations on writing registers, like target_store_registers), the sub-class of regcache in the test override raw_write. Also, in order to get the right regcache from get_thread_arch_aspace_regcache, the sub-class of regcache inserts itself to current_regcache. Suppose I incorrectly modified the size of buffer as below, @@ -1228,7 +1228,7 @@ ia64_register_to_value (struct frame_info *frame, int regnum, int *optimizedp, int *unavailablep) { struct gdbarch *gdbarch = get_frame_arch (frame); - gdb_byte in[MAX_REGISTER_SIZE]; + gdb_byte in[1]; /* Convert to TYPE. */ if (!get_frame_register_bytes (frame, regnum, 0, build GDB with "-fsanitize=address" and run unittest.exp, asan can detect such error ==2302==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff98193870 at pc 0xbd55ea bp 0x7fff981935a0 sp 0x7fff98193598 WRITE of size 16 at 0x7fff98193870 thread T0 #0 0xbd55e9 in frame_register_unwind(frame_info*, int, int*, int*, lval_type*, unsigned long*, int*, unsigned char*) /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1119 #1 0xbd58c8 in frame_register(frame_info*, int, int*, int*, lval_type*, unsigned long*, int*, unsigned char*) /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1147 #2 0xbd6e25 in get_frame_register_bytes(frame_info*, int, unsigned long, int, unsigned char*, int*, int*) /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1427 #3 0x70080a in ia64_register_to_value /home/yao/SourceCode/gnu/gdb/git/gdb/ia64-tdep.c:1236 #4 0xbf570e in gdbarch_register_to_value(gdbarch*, frame_info*, int, type*, unsigned char*, int*, int*) /home/yao/SourceCode/gnu/gdb/git/gdb/gdbarch.c:2619 #5 0xc05975 in register_to_value_test /home/yao/SourceCode/gnu/gdb/git/gdb/gdbarch-selftests.c:131 Or, even if GDB is not built with asan, GDB just crashes. *** stack smashing detected ***: ./gdb terminated Aborted (core dumped) gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * Makefile.in (SFILES): Add gdbarch-selftests.c. (COMMON_OBS): Add gdbarch-selftests.o. * frame.c [GDB_SELF_TESTS] (create_new_frame): New function. * frame.h [GDB_SELF_TESTS] (create_new_frame): Declare. * gdbarch-selftests.c: New file. * regcache.h (regcache) <~regcache>: Mark it virtual if GDB_SELF_TEST. <raw_write>: Likewise.
2017-05-24Move current_regcache to regcache::current_regcacheYao Qi
This patches moves global variable current_regcache to a class regcache static variable (protected) so that the unit test I add in the following patch can access it (by means of extending class regcache in unit test). gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * regcache.c (current_regcache): Change it to regcache::current_regcache. (regcache_observer_target_changed): Update. (regcache_thread_ptid_changed): Make it a regcache static method. (regcache_thread_ptid_changed): Update. (class regcache_access): New. (current_regcache_test): Update. (_initialize_regcache): Update. * regcache.h: Include forward_list. (regcache): Declare regcache_thread_ptid_changed and declare registers_changed_ptid as friend.
2017-05-24Get register contents by register_size instead of TYPE_LENGTHYao Qi
We should use register_size to get register contents instead of TYPE_LENGTH. gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * i387-tdep.c (i387_register_to_value): Use register_size instead of TYPE_LENGTH. * m68k-tdep.c (m68k_register_to_value): Likewise.
2017-05-24Restrict i387_convert_register_pYao Qi
gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * i387-tdep.c (i387_convert_register_p): Return false if type code isn't TYPE_CODE_FLT.
2017-05-24Restrict alpha_convert_register_pYao Qi
This patch restricts alpha_convert_register_p from "TYPE_LENGTH (type) != 8" to "TYPE_LENGTH (type) == 4", because, - we have check "TYPE_LENGTH (valtype) == 4" in alpha_register_to_value and alpha_value_to_register, - alpha lds and sts instruction access 4 bytes, - comments "It might need to convert the [float] register into the corresponding [integer] type (see Alpha)" and integer is 4-byte on alpha, I think it is the right restrict condition to "TYPE_LENGTH (valtype) == 4". gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * alpha-tdep.c (alpha_convert_register_p): Return true if type length is 4. (alpha_register_to_value): Remove type length check. (alpha_value_to_register): Likewise.
2017-05-24Restrict ia64_convert_register_pYao Qi
gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * ia64-tdep.c (ia64_convert_register_p): Check type's code is TYPE_CODE_FLT.
2017-05-24Restrict m68k_convert_register_pYao Qi
We need to convert register if the type is float. Suppose we get a value from float point register, but its type is integer, we don't have to convert. This case may not exist in real code, but exist in my unit test case. warning: Cannot convert floating-point register value to non-floating-point type. Self test failed: arch m68k: self-test failed at gdb/git/gdb/findvar.c:1072 ok = gdbarch_register_to_value (gdbarch, frame, regnum, type, buf.data (), &optim, &unavail); 1072: SELF_CHECK (ok); gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * m68k-tdep.c (m68k_convert_register_p): Check type's code is TYPE_CODE_FLT or not.
2017-05-24Use XCNEW gdbarch_tdepYao Qi
This patch uses XCNEW gdbarch_tdep instead of XNEW. gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * alpha-tdep.c (alpha_gdbarch_init): Use XCNEW instead of XNEW. * avr-tdep.c (avr_gdbarch_init): Likewise. * bfin-tdep.c (bfin_gdbarch_init): Likewise. * cris-tdep.c (cris_gdbarch_init): Likewise. * ft32-tdep.c (ft32_gdbarch_init): Likewise. * lm32-tdep.c (lm32_gdbarch_init): Likewise. * m32r-tdep.c (m32r_gdbarch_init): Likewise. * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise. * mep-tdep.c (mep_gdbarch_init): Likewise. * microblaze-tdep.c (microblaze_gdbarch_init): Likewise. * mips-tdep.c (mips_gdbarch_init): Likewise. * mn10300-tdep.c (mn10300_gdbarch_init): Likewise. * moxie-tdep.c (moxie_gdbarch_init): Likewise. * msp430-tdep.c (msp430_gdbarch_init): Likewise. * sh64-tdep.c (sh64_gdbarch_init): Likewise. * v850-tdep.c (v850_gdbarch_init): Likewise.
2017-05-24Clear GDB internal state after each unit testYao Qi
GDB has some global variables, like sentinel_frame, current_thread_arch, and etc, we need to reset them after each unit tests. gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * selftest-arch.c (tests_with_arch): Call registers_changed and reinit_frame_cache. * selftest.c (run_self_tests): Likewise.
2017-05-24Use disassemble.c:disassembler select rs6000 disassemblerYao Qi
Nowadays, rs6000 disassembler is selected in different ways in opcodes and gdb, opcodes: case bfd_arch_rs6000: if (mach == bfd_mach_ppc_620) disassemble = print_insn_big_powerpc; else disassemble = print_insn_rs6000; break; gdb: if (arch == bfd_arch_rs6000) set_gdbarch_print_insn (gdbarch, print_insn_rs6000); else set_gdbarch_print_insn (gdbarch, gdb_print_insn_powerpc); I am not sure which one is the right one. However, such selection should be done in one place instead of two. gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * rs6000-tdep.c (gdb_print_insn_powerpc): Remove. (rs6000_gdbarch_init): Don't call set_gdbarch_print_insn.
2017-05-24Use disassemble.c:disassembler select rl78 disassemblerYao Qi
This patch changes rl78 to let disassble.c:disassembler select disassembler. rl78_get_disassembler doesn't handle the case that abfd is NULL, so this patch also fix it. gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * rl78-tdep.c (rl78_gdbarch_init): Don't call set_gdbarch_print_insn. opcodes: 2017-05-24 Yao Qi <yao.qi@linaro.org> * rl78-dis.c (rl78_get_disassembler): If parameter abfd is NULL, set cpu to E_FLAG_RL78_ANY_CPU.
2017-05-24Use disassemble.c:disassembler select h8300 disassemblerYao Qi
opcodes/disassble.c:disassembler select h8300 disassembler like this, if (mach == bfd_mach_h8300h || mach == bfd_mach_h8300hn) disassemble = print_insn_h8300h; else if (mach == bfd_mach_h8300s || mach == bfd_mach_h8300sn || mach == bfd_mach_h8300sx || mach == bfd_mach_h8300sxn) disassemble = print_insn_h8300s; else disassemble = print_insn_h8300; which is the same as what gdb/h8300-tdpe.c does, switch (info.bfd_arch_info->mach) { case bfd_mach_h8300: ... set_gdbarch_print_insn (gdbarch, print_insn_h8300); case bfd_mach_h8300h: case bfd_mach_h8300hn: ... set_gdbarch_print_insn (gdbarch, print_insn_h8300h); case bfd_mach_h8300s: case bfd_mach_h8300sn: ... set_gdbarch_print_insn (gdbarch, print_insn_h8300s); so we can leave disassble.c:disassembler doing the selection. gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * h8300-tdep.c (h8300_gdbarch_init): Don't call set_gdbarch_print_insn.
2017-05-24Delegate opcodes to select disassembler in GDBYao Qi
This patch changes GDB to use disassembler selected by opcodes in default, so that we don't have to duplicate the selection logic again in GDB side. For example, gdb/score-tdep.c has static int score_print_insn (bfd_vma memaddr, struct disassemble_info *info) { if (info->endian == BFD_ENDIAN_BIG) return print_insn_big_score (memaddr, info); else return print_insn_little_score (memaddr, info); } and opcodes/disassemble.c has the same logic, case bfd_arch_score: if (big) disassemble = print_insn_big_score; else disassemble = print_insn_little_score; This patch removes the logic in GDB and calls opcodes/disassemble.c:disassembler in default to select disassembler. gdb: 2017-05-24 Yao Qi <yao.qi@linaro.org> * alpha-tdep.c (alpha_gdbarch_init): Don't call set_gdbarch_print_insn. * arc-tdep.c (arc_gdbarch_init): Likewise. * arch-utils.c: include dis-asm.h. (default_print_insn): New function. * arch-utils.h (default_print_insn): Declare. * avr-tdep.c (avr_gdbarch_init): Don't call set_gdbarch_print_insn. * bfin-tdep.c (bfin_gdbarch_init): Likewise. * cris-tdep.c (cris_delayed_get_disassembler): Remove. (cris_gdbarch_init): Don't call set_gdbarch_print_insn. * frv-tdep.c (frv_gdbarch_init): Likewise. * ft32-tdep.c (ft32_gdbarch_init): Likewise. * gdbarch.sh (print_insn): Use default_print_insn. * gdbarch.c: Regenerated. * hppa-tdep.c (hppa_gdbarch_init): Likewise. * iq2000-tdep.c (iq2000_gdbarch_init): Likewise. * lm32-tdep.c (lm32_gdbarch_init): Likewise. * m32c-tdep.c (m32c_gdbarch_init): Likewise. * m32r-tdep.c (m32r_gdbarch_init): Likewise. * m68hc11-tdep.c (gdb_print_insn_m68hc11): Remove. (m68hc11_gdbarch_init): Don't call set_gdbarch_print_insn. * m68k-tdep.c (m68k_gdbarch_init): Likewise. * m88k-tdep.c (m88k_gdbarch_init): Likewise. * microblaze-tdep.c (microblaze_gdbarch_init): Likewise. * mn10300-tdep.c (mn10300_gdbarch_init): Likewise. * moxie-tdep.c (moxie_gdbarch_init): Likewise. * msp430-tdep.c (msp430_gdbarch_init): Likewise. * mt-tdep.c (mt_gdbarch_init): Likewise. * nds32-tdep.c (nds32_gdbarch_init): Likewise. * nios2-tdep.c (nios2_print_insn): Remove. (nios2_gdbarch_init): Don't call set_gdbarch_print_insn. * rx-tdep.c (rx_gdbarch_init): Likewise. * s390-linux-tdep.c (s390_gdbarch_init): Likewise. * score-tdep.c (score_print_insn): Remove. (score_gdbarch_init): Don't call set_gdbarch_print_insn. * sh-tdep.c (sh_gdbarch_init): Likewise. * sh64-tdep.c (sh64_gdbarch_init): Likewise. * sparc-tdep.c (sparc32_gdbarch_init): Likewise. * tic6x-tdep.c (tic6x_print_insn): Remove. (tic6x_gdbarch_init): Don't call set_gdbarch_print_insn. * tilegx-tdep.c (tilegx_gdbarch_init): Likewise. * v850-tdep.c (v850_gdbarch_init): Likewise. * vax-tdep.c (vax_gdbarch_init): Likewise. * xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise. * xtensa-tdep.c (xtensa_gdbarch_init): Likewise.
2017-05-23Use mips_regnum instead of constants for FreeBSD/mips register operations.John Baldwin
gdb/ChangeLog: * mips-fbsd-tdep.c (MIPS_PC_REGNUM): Remove. (MIPS_FP0_REGNUM): Remove. (MIPS_FSR_REGNUM): Remove. (mips_fbsd_supply_fpregs): Use mips_regnum. (mips_fbsd_supply_gregs): Likewise. (mips_fbsd_collect_fpregs): Likewise. (mips_fbsd_collect_gregs): Likewise.
2017-05-23Cleanups to FreeBSD/mips native register operations.John Baldwin
Compare against the "raw" PC register number instead of the cooked register number when determining if a register was handled by PT_GETREGS. Previously the register fetch/store operations only tried PT_GETREGS to fetch any individual register. The result was that fetching or storing an individual register not covered by PT_GETREGS (such as floating point registers) did not work. While here, remove an early exit to simplify the code flow from the PT_GETREGS / PT_SETREGS case, and add a getfpregs_supplies similar to getregs_supplies to describe the registers supplied by PT_GETFPREGS and PT_SETFPREGS. gdb/ChangeLog: * mips-fbsd-nat.c (getregs_supplies): Fix upper bound comparison. (getpfpregs_supplies): New function. (mips_fbsd_fetch_inferior_registers): Remove early exit and use getfpregs_supplies. (mips_fbsd_store_inferior_registers): Likewise.
2017-05-22gdb: Document vMustReplyEmpty remote packetAndrew Burgess
Add mention of the vMustReplyEmpty to the remote serial protocol documentation. It is important that this packet be treated in the same fashion as any other unknown 'v' packet, and I have tried to reflect this in the description of the packet, it is not simply the case that we _must_ return the empty string for this packet. As the intention is that we should treat this packet as unknown then an argument could be made that we should not document it, however, for someone implementing a gdbserver from scratch, seeing an undocumented packet arrive from gdb is confusing, and will probably cause them to have to read the code in order to check how this packet should be handled, which is not ideal. gdb/doc/ChangeLog: * gdb.texinfo (Packets): Document vMustReplyEmpty packet.
2017-05-22gdb: Add John Baldwin as FreeBSD MaintainerPedro Alves
gdb/ChangeLog: 2017-05-22 Pedro Alves <palves@redhat.com> * MAINTAINERS (Host/Native): Add John Baldwin as FreeBSD maintainer.
2017-05-22Add PPC_MAX_REGISTER_SIZEAlan Hayward
gdb/ * ppc-linux-nat.c (fetch_register): Use PPC_MAX_REGISTER_SIZE. (store_register): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Likewise. (get_decimal_float_return_value): Likewise. (do_ppc_sysv_return_value): Likewise. (ppc64_sysv_abi_push_integer): Likewise. (ppc64_sysv_abi_push_freg): Likewise. (ppc64_sysv_abi_return_value_base): Likewise. (ppc64_sysv_abi_return_value): Likewise. * rs6000-aix-tdep.c (rs6000_push_dummy_call): Likewise. * rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Likewise. * rs6000-nat.c: Likewise. * rs6000-tdep.c (rs6000_register_to_value): Likewise. (rs6000_value_to_register): Likewise. * ppc-tdep.h (PPC_MAX_REGISTER_SIZE): Add.
2017-05-21Print Rust unsized array types a bit more nicelyTom Tromey
It's a bit difficult to create an unsized array type in Rust, but if you do, right now ptype will show something like "[u8; ]". It really should print "[u8]", though, which is what this patch implements. This is part of PR 21466. Built and regtested on x86-64 Fedora 25. I'm checking this in. ChangeLog 2017-05-21 Tom Tromey <tom@tromey.com> PR rust/21466: * rust-lang.c (rust_print_type) <TYPE_CODE_ARRAY>: Print unsized arrays as "[T]", not "[T; ]". testsuite/ChangeLog 2017-05-21 Tom Tromey <tom@tromey.com> PR rust/21466: * gdb.rust/unsized.exp: New file. * gdb.rust/unsized.rs: New file.
2017-05-19Use watchpoint's language when re-parsing expressionTom Tromey
PR rust/21484 notes that watch -location does not work with Rust: (gdb) watch -location a syntax error in expression, near `) 0x00007fffffffe0f4'. update_watchpoint tries to tell gdb that the new expression it creates has C syntax: /* The above expression is in C. */ b->language = language_c; However, update_watchpoint doesn't actually use this language when re-parsing the expression. Originally I was going to fix this by saving and restoring the language in update_watchpoint, but this regressed gdb.dlang/watch-loc.exp, because the constructed expression actually has D syntax (specifically the name is not parseable by C). Next I looked at directly constructing an expression, and not relying on the parser at all; but it seemed to me that upon a re-set, we'd want to reparse the type, and there is no existing API to do this correctly. So, in the end I made a hook to let each language choose what expression to use. I made all the languages other than Rust use the C expression, because that is the status quo ante. However, this is probably not truly correct. After this patch, at least, it is easy to correct by someone who knows the language(s) in question. Regtested by the buildbot. ChangeLog 2017-05-19 Tom Tromey <tom@tromey.com> PR rust/21484: * rust-lang.c (exp_descriptor_rust): New function. (rust_language_defn): Use it. * p-lang.c (pascal_language_defn): Update. * opencl-lang.c (opencl_language_defn): Update. * objc-lang.c (objc_language_defn): Update. * m2-lang.c (m2_language_defn): Update. * language.h (struct language_defn) <la_watch_location_expression>: New member. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Update. * go-lang.c (go_language_defn): Update. * f-lang.c (f_language_defn): Update. * d-lang.c (d_language_defn): Update. * c-lang.h (c_watch_location_expression): Declare. * c-lang.c (c_watch_location_expression): New function. (c_language_defn, cplus_language_defn, asm_language_defn) (minimal_language_defn): Use it. * breakpoint.c (watch_command_1): Call la_watch_location_expression. * ada-lang.c (ada_language_defn): Update. testsuite/ChangeLog 2017-05-19 Tom Tromey <tom@tromey.com> PR rust/21484: * gdb.rust/watch.exp: New file. * gdb.rust/watch.rs: New file.
2017-05-19Fix tui compilation with Solaris libcurses: clear define (PR tui/21482)Rainer Orth
On both mainline and the 8.0 branch, gdb compilation fails on Solaris 10 with the native libcurses like this: In file included from /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/gdb_curses.h:42: 0, from /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-data.h:2 6, from /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c :31: /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c: In function `CORE_A DDR tui_disassemble(gdbarch*, tui_asm_line*, CORE_ADDR, int)': /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c:71:19: error: `class string_file' has no member named `wclear'; did you mean `clear'? gdb_dis_out.clear (); ^ /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-disasm.c:78:19: error: `class string_file' has no member named `wclear'; did you mean `clear'? gdb_dis_out.clear (); ^ make[2]: *** [Makefile:1927: tui-disasm.o] Error 1 It turned out this happens because <curses.h> has #define clear() wclear(stdscr) This can be avoided by defining NOMACROS, which the patch below does. ncurses potentially has a similar problem, which can be avoided by defining NCURSES_NOMACROS. PR tui/21482 * gdb_curses.h (NOMACROS): Define. (NCURSES_NOMACROS): Define.
2017-05-19Fix tui compilation with Solaris libcurses: non-const last arg to mvwaddstr ↵Rainer Orth
(PR tui/21482) On both mainline and the 8.0 branch, gdb compilation fails on Solaris 10 with the native libcurses in gdb/tui for several instances of the same problem: /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c: In function `void tui_erase_source_content(tui_win_info*, int)': /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c:257:18: error: invalid conversion from `const char*' to `char*' [-fpermissive] no_src_str); ^ In file included from /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/gdb_curses.h:42:0, from /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-data.h:26, from /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c:33: /vol/gcc-7/lib/gcc/sparc-sun-solaris2.10/7.1.0/include-fixed/curses.h:699:12: note: initializing argument 4 of `int mvwaddstr(WINDOW*, int, int, char*)' extern int mvwaddstr(WINDOW *, int, int, char *); ^~~~~~~~~ make[2]: *** [Makefile:1927: tui-winsource.o] Error 1 Unlike ncurses, <curses.h> declares extern int mvwaddstr(WINDOW *, int, int, char *); i.e. the last arg is char *, not const char *. The patch fixes this by casting the last arg to mvwaddstr to char *, as was recently done on mainline in a newterm() call (the only difference between 8.0 and mainline gdb/tui). * tui/tui-windata.c (tui_erase_data_content): Cast last mvwaddstr arg to char *. * tui/tui-wingeneral.c (box_win): Likewise. * tui/tui-winsource.c (tui_erase_source_content): Likewise. (tui_show_source_line): Likewise. (tui_show_exec_info_content): Likewise.
2017-05-19gdb: fix TYPE_CODE_ARRAY handling in sparc targetsVladimir Mezentsev
gdb has a special type (TYPE_CODE_ARRAY) to support the gcc extension (https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html). TYPE_CODE_ARRAY is handled incorrectly for both (32- and 64-bit) modes on Sparc machines. Tested on sparc64-linux-gnu and sparc-solaris (32- and 64-bit mode). 6 tests ( from gdb/testsuite/gdb.base/gnu_vector.exp) failed on sparc64-Linux and on sparc-Solaris in 32- and 64-bit mode. Now all these tests passed. gdb/testsuite/gdb.base/gnu_vector.exp has 117 different cases for small (and not small) arrays and structures. No regressions. gdb/ChangeLog: 2017-05-19 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> * sparc-tdep.c (sparc_structure_return_p) (sparc_arg_on_registers_p): New functions. (sparc32_store_arguments): Use them. * sparc64-tdep.c (sparc64_16_byte_align_p) (sparc64_store_floating_fields, sparc64_extract_floating_fields): Handle TYPE_CODE_ARRAY.
2017-05-18Fix test failure with Rust 1.18 and 1.19Tom Tromey
With Rust 1.18 and 1.19, I saw some test suite failures. They were all of the same form -- Box seems to be qualified in the output now, like: print box_some $64 = core::option::Option<alloc::boxed::Box<u8>>::Some(0x7ffff6c21018 "\001\000") ... where the test was expecting Option<Box<u8>>. This patch fixes the problem in a way that should work with earlier versions of Rust. gdb/testsuite/ChangeLog 2017-05-18 Tom Tromey <tom@tromey.com> * gdb.rust/simple.exp: Allow Box to be qualified.
2017-05-18Expect prompt after no FPU warningThomas Preud'homme
2017-05-18 Thomas Preud'homme <thomas.preudhomme@arm.com> gdb/testsuite/ * gdb.base/float.exp: Expect GDB prompt for targets without FPU.
2017-05-18gdb.base/fileio.c: Fix several -Wmaybe-uninitialized warningsPedro Alves
src/gdb/testsuite/gdb.base/fileio.c: In function ‘test_write’: src/gdb/testsuite/gdb.base/fileio.c:158:5: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized] printf ("write 1: ret = %d, errno = %d\n", ret, errno); ^ gdb/ChangeLog: 2017-05-18 Pedro Alves <palves@redhat.com> * gdb.base/fileio.c (test_write, test_read, test_close) (test_fstat): Don't print 'ret' in the fail path.
2017-05-18gdb.base/fileio.c: Fix several -Wreturn-type warningsPedro Alves
All the "test_" functions warn like: src/gdb/testsuite/gdb.base/fileio.c: In function ‘test_close’: src/gdb/testsuite/gdb.base/fileio.c:280:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ Nothing looks at the return of these functions, so just make them return void. While at it, "()" is not the same as "(void)" in C - fix that too. gdb/ChangeLog: 2017-05-18 Pedro Alves <palves@redhat.com> * gdb.base/fileio.c (stop, test_open, test_write, test_read) (test_lseek, test_close, test_stat, test_fstat, test_isatty) (test_system, test_rename, test_unlink, test_time): Change prototypes. * gdb.base/fileio.exp (stop_msg): Adjust.
2017-05-18gdb.base/fileio.exp: Remove nowarningsPedro Alves
... and quiet -Wnonnull in a different way. gdb/testsuite/ChangeLog: 2017-05-18 Pedro Alves <palves@redhat.com> * gdb.base/fileio.c (null_str): New global. (test_stat): Use it. * gdb.base/fileio.exp: Remove nowarnings.
2017-05-17Add nowarnings in gdb.base/fileio.expYao Qi
I see the following warning in gdb.base/fileio.c, testsuite/gdb.base/fileio.c:297:3: warning: null argument where non-null required (argument 1) [-Wnonnull] ret = stat (NULL, &st); ^ This patch adds "nowarnings" to the list passed to gdb_compile. gdb/testsuite: 2017-05-17 Yao Qi <yao.qi@linaro.org> * gdb.base/fileio.exp: Pass nowarnings to gdb_compile.
2017-05-17Add alias command to cmd_list_elementYao Qi
When we add alias command, we call add_alias_cmd and pass the alias name and command name. This implicitly requires the command and its prefix commands are already added to cmdlist. This may not be true, for example, add_com_alias ("tty", "set inferior-tty", class_alias, 0); "inferior-tty" command is added to setlist, but setlist may not be added to cmdlist (It depends on the order of related _initialize_XXX functions called) so that we can't find "set inferior-tty" from cmdlist. This patch fixes this problem by passing cmd_list_element of "inferior-tty" to add_alias_cmd, so that cmd_list_element of "inferior-tty" doesn't have to be reachable from cmdlist at that moment. gdb: 2017-05-17 Yao Qi <yao.qi@linaro.org> * cli/cli-decode.c (add_alias_cmd): New function. * command.h (add_alias_cmd): Declare. * infcmd.c (_initialize_infcmd): Don't call add_com_alias, instead call add_alias_cmd. gdb/testsuite: 2017-05-17 Simon Marchi <simon.marchi@ericsson.com> * gdb.base/set-inferior-tty.exp (test_set_inferior_tty): Add argument command. (top-level): Invoke test_set_inferior_tty.
2017-05-17nat_extra_makefile_frag -> nat_makefile_fragPedro Alves
gdb/ChangeLog: 2017-05-17 Pedro Alves <palves@redhat.com> * Makefile.in (nat_extra_makefile_frag): Rename to ... (nat_makefile_frag): ... this. All references updated. * configure.ac: Likewise. * configure.nat: Likewise. Enhance comments. * configure: Regenerate.
2017-05-15Fix gdb procfs.c compilation on SolarisRainer Orth
Prompted by the creation of the gdb 8.0 branch, I tried to build it on x86_64-pc-solaris2.12, but failed: /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/procfs.c: In function `target_ops* procfs_target()': /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/procfs.c:186:27: error: invalid conversion from `void (*)(target_ops*, char*, char*, char**, int)' to `void (*)(target_ops*, const char*, const string&, char**, int) {aka void (*)(target_ops*, const char*, const std::__cxx11::basic_string<char>&, char**, int)}' [-fpermissive] t->to_create_inferior = procfs_create_inferior; ^~~~~~~~~~~~~~~~~~~~~~ /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/procfs.c: At global scope: /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/procfs.c:125:13: warning: `void procfs_create_inferior(target_ops*, char*, char*, char**, int)' declared `static' but never defined [-Wunused-function] static void procfs_create_inferior (struct target_ops *, char *, ^~~~~~~~~~~~~~~~~~~~~~ /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/procfs.c:4529:1: warning: `void procfs_create_inferior(target_ops*, const char*, const string&, char**, int)' defined but not used [-Wunused-function] procfs_create_inferior (struct target_ops *ops, const char *exec_file, ^~~~~~~~~~~~~~~~~~~~~~ This can easily be fixed by the following patch. * procfs.c (procfs_create_inferior): Change prototype to match definition.
2017-05-13Avoid compiler warning in MinGW buildEli Zaretskii
gdb: 2017-05-13 Eli Zaretskii <eliz@gnu.org> * tui/tui.c (tui_enable): Cast "unknown" to 'char *' to avoid a C++ compiler warning.
2017-05-12Avoid exponential behavior in rust_evaluate_subexpTom Tromey
The STRUCTOP_STRUCT case in rust_evaluate_subexp would evaluate its LHS, and then, if it did not need Rust-specific treatment, it would back up and re-evaluate the entire STRUCTOP_STRUCT part of the expression using evaluate_subexp_standard. This yields exponential behavior and causes some expressions to evaluate extremely slowly. The fix is to simply do the needed work inline. This is PR rust/21483. ChangeLog 2017-05-12 Tom Tromey <tom@tromey.com> PR rust/21483: * rust-lang.c (rust_evaluate_subexp) <STRUCTOP_STRUCT>: Don't recurse, just call value_struct_elt directly.
2017-05-12Fix rust_dump_subexp_bodyTom Tromey
rust_dump_subexp_body was not correct in a couple of cases. While debugging the bug I was really interested in, this caused a crash. This patch fixes the problems. No test case because, IIRC there generally aren't tests for expression dumping. ChangeLog 2017-05-12 Tom Tromey <tom@tromey.com> * rust-lang.c (rust_dump_subexp_body) <STRUCTOP_ANONYMOUS, OP_RUST_ARRAY>: Fix.
2017-05-12Replace "return" with "break"Tom Tromey
This replaces a "return" with a "break" in rust_print_subexp, for consistency. ChangeLog 2017-05-12 Tom Tromey <tom@tromey.com> * rust-lang.c (rust_print_subexp): Replace "return" with "break".
2017-05-09Use std::forward_list for current_regcacheYao Qi
gdb: 2017-05-09 Yao Qi <yao.qi@linaro.org> * regcache.c: Include <forward_list>. (struct regcache_list): Remove. (current_regcache): Update. (get_thread_arch_aspace_regcache): Update for std::forward_list. (regcache_thread_ptid_changed): Likewise. (registers_changed_ptid): Likewise. (current_regcache_size): Likewise.
2017-05-09Add current_regcache unit testYao Qi
This patch adds a unit test to current_regcache, to make sure it is correctly updated by get_thread_arch_aspace_regcache and registers_changed_ptid. gdb: 2017-05-09 Yao Qi <yao.qi@linaro.org> * regcache.c [GDB_SELF_TEST]: Include selftest.h. (current_regcache_size): New function. (current_regcache_test): New function. (_initialize_regcache) [GDB_SELF_TEST]: Register the unit test.
2017-05-08Remove some uses of MAX_REGISTER_SIZE from mips-tdep.cAlan Hayward
gdb/ * mips-tdep.c (mips_o32_return_value): Remove unused buffer. (print_gp_register_row): Use get_frame_register_value.
2017-05-08Remove some uses of MAX_REGISTER_SIZE from mips-linux-tdep.cAlan Hayward
gdb/ * mips-linux-tdep.c (mips_supply_gregset): Use raw_supply_zeroed. (mips_supply_fpregset): Likewise. (mips64_supply_gregset): Likewise.
2017-05-08Remove some uses of MAX_REGISTER_SIZE uses from mn10300-linux-tdep.cAlan Hayward
gdb/ * mn10300-linux-tdep.c (am33_supply_gregset_method): Use regcache->raw_supply_zeroed.
2017-05-06Rearrange gdb/configure.nat to make it simpler and less redundantSergio Durigan Junior
The previous commit introduced gdb/configure.nat, but it was just a copy-and-past (with the necessary adjustments) from the files under gdb/config/. We can do better than that. Instead of using one big 'case' statement that matches the ${gdb_host_cpu} and then match each ${gdb_host}, it is possible to remove a lof of redundancy by matching the most common ${gdb_host}'s first, setting the common variables for each, and then proceed to matching specific ${gdb_host}'s and ${gdb_host_cpu}'s. In other words, reverse the order of the 'case's and take advantage of the fact that a lot of parameters are the same for each host. This commit was tested on x86_64 without regressions. gdb/ChangeLog: 2017-05-06 Sergio Durigan Junior <sergiodj@redhat.com> * configure.nat: Rearrange 'case' statements to match host before cpu.
2017-05-06Introduce "gdb/configure.nat" (and delete "gdb/config/*/*.mh" files)Sergio Durigan Junior
Due to my ongoing work to make it possible for gdbserver to start the inferior using the shell, I had to share the fork_inferior function under the "nat/" directory. In order to do that, I created a new file and put the function there; however, this meant that I now had to update some of the *.mh files (under "gdb/config") and add the new file as a dependency to be built natively. Bleh... After talking a bit to Pedro about this, the idea came up to write a new "gdb/configure.nat" file, a la "gdb/configure.tgt", which would concentrate all of the native settings for each host/system. I decided to tackle this issue. The patch is simple. All of the previous Makefile variables that were being declared inside the *.mh files are now inside "gdb/Makefile.in", and "gdb/configure" is responsible for AC_SUBST'ing them. The definitions of these variables were put inside "gdb/configure.nat", so now they're shell variables. For excerpts of Makefile code, one must create a file under "gdb/config/${gdb_cpu_host}" and reference it on the "nat_extra_makefile_frag" variable. It should now be easier to update the native dependencies of hosts in this single file. This has been tested on x86_64 without regressions. gdb/ChangeLog: 2017-05-06 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile.in: Remove "@host_makefile_frag@". Add variables NAT_FILE, NATDEPFILES, NAT_CDEPS, LOADLIBES, MH_CFLAGS, XM_CLIBS, NAT_GENERATED_FILES, HAVE_NATIVE_GCORE_HOST. Add "@nat_extra_makefile_frag@". (Makefile): Remove dependency on "@frags@". ($(GNULIB_BUILDDIR)/Makefile): Likewise. (data-directory/Makefile): Likewise. * config/aarch64/linux.mh: Deleted; moved contents to "gdb/configure.nat". * config/alpha/alpha-linux.mh: Likewise. * config/alpha/nbsd.mh: Likewise. * config/arm/linux.mh: Likewise. * config/arm/nbsdelf.mh: Likewise. * config/i386/cygwin.mh: Likewise. * config/i386/cygwin64.mh: Likewise. * config/i386/darwin.mh: Likewise. * config/i386/fbsd.mh: Likewise. * config/i386/fbsd64.mh: Likewise. * config/i386/go32.mh: Likewise. * config/i386/i386gnu.mh: Likewise. * config/i386/i386sol2.mh: Likewise. * config/i386/linux.mh: Likewise. * config/i386/linux64.mh: Likewise. * config/i386/mingw.mh: Likewise. * config/i386/mingw64.mh: Likewise. * config/i386/nbsd64.mh: Likewise. * config/i386/nbsdelf.mh: Likewise. * config/i386/nto.mh: Likewise. * config/i386/obsd.mh: Likewise. * config/i386/obsd64.mh: Likewise. * config/i386/sol2-64.mh: Likewise. * config/ia64/linux.mh: Likewise. * config/m32r/linux.mh: Likewise. * config/m68k/linux.mh: Likewise. * config/m68k/nbsdelf.mh: Likewise. * config/m68k/obsd.mh: Likewise. * config/m88k/obsd.mh: Likewise. * config/mips/fbsd.mh: Likewise. * config/mips/linux.mh: Likewise. * config/mips/nbsd.mh: Likewise. * config/mips/obsd64.mh: Likewise. * config/pa/linux.mh: Likewise. * config/pa/nbsd.mh: Likewise. * config/pa/obsd.mh: Likewise. * config/powerpc/aix.mh: Likewise. * config/powerpc/fbsd.mh: Likewise. * config/powerpc/linux.mh: Likewise. * config/powerpc/nbsd.mh: Likewise. * config/powerpc/obsd.mh: Likewise. * config/powerpc/ppc64-linux.mh: Likewise. * config/powerpc/spu-linux.mh: Likewise. * config/s390/linux.mh: Likewise. * config/sh/nbsd.mh: Likewise. * config/sparc/fbsd.mh: Likewise. * config/sparc/linux.mh: Likewise. * config/sparc/linux64.mh: Likewise. * config/sparc/nbsd64.mh: Likewise. * config/sparc/nbsdelf.mh: Likewise. * config/sparc/obsd64.mh: Likewise. * config/sparc/sol2.mh: Likewise. * config/tilegx/linux.mh: Likewise. * config/vax/nbsdelf.mh: Likewise. * config/vax/obsd.mh: Likewise. * config/xtensa/linux.mh: Likewise. * config/i386/i386gnu.mn: New file, with excerpts from "config/i386/i386gnu.mh". * configure: Regenerate. * configure.ac: Rewrite code to use "gdb/configure.nat" instead of *.mh files under "gdb/config". * configure.nat: New file, with contents from the "gdb/config/*/*.mh" files. gdb/doc/ChangeLog: 2017-05-06 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile: Remove "@host_makefile_frag@".
2017-05-05btrace: Fix memory leak in btrace_clear.Tim Wiederhake
2017-05-05gdb: Disable -Werror for -Wmaybe-uninitializedPedro Alves
Newer GCCs are triggering false-positive -Wmaybe-uninitialized warnings around code that uses gdb::optional: https://sourceware.org/ml/gdb-patches/2017-05/msg00118.html Using std::optional wouldn't help, it triggers the same warnings: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635 Initializing the variables to quiet the warning would defeat the purpose of gdb::optional. Making the optional ctor memset its storage would be a pessimization. Wrapping gdb::optional's internals with "#pragma GCC diagnostic push/ignored/pop" doesn't work, we'd have to wrap uses of gdb::optional instead, which I think would get unwieldy and ugly as we start using gdb::optional more and more. The -Wmaybe-uninitialized warning is documented as producing false positives (unlike -Wuninialized), so until we find a better workaround, disable -Werror for this warning. You'll still see the warning when building gdb, but it won't cause a build failure. Tested by building with gcc 4.8.5, 5.3.1, and gcc trunk (20170428). gdb/ChangeLog: 2017-05-05 Pedro Alves <palves@redhat.com> * warning.m4 (build_warnings): Add -Wno-error=maybe-uninitialized. * configure: Regenerate. gdb/gdbserver/ChangeLog: 2017-05-05 Pedro Alves <palves@redhat.com> * configure: Regenerate.
2017-05-04Fix gdb.python/py-record-btrace-threads.exp with Python 3Pedro Alves
Fix several instances of: ... python print not f1calls File "<string>", line 1 print not f1calls ^ SyntaxError: Missing parentheses in call to 'print' Error while executing Python code. (gdb) FAIL: gdb.python/py-record-btrace-threads.exp: thread=1: checking thread 1: python print not f1calls ... gdb/testsuite/ChangeLog: 2017-05-04 Pedro Alves <palves@redhat.com> * gdb.python/py-record-btrace-threads.exp (check_insn_for_thread): Add parens to print call for Python 3.
2017-05-04RAII-fy make_cleanup_restore_current_thread & friendsPedro Alves
After all the make_cleanup_restore_current_thread fixing, I thought I'd convert that and its relatives (which are all cleanups) to RAII classes. scoped_restore_current_pspace_and_thread was put in a separate file to avoid a circular dependency. Tested on x86-64 Fedora 23, native and gdbserver. gdb/ChangeLog: 2017-05-04 Pedro Alves <palves@redhat.com> * Makefile.in (SFILES): Add progspace-and-thread.c. (HFILES_NO_SRCDIR): Add progspace-and-thread.h. (COMMON_OBS): Add progspace-and-thread.o. * breakpoint.c: Include "progspace-and-thread.h". (update_inserted_breakpoint_locations) (insert_breakpoint_locations, create_longjmp_master_breakpoint): Use scoped_restore_current_pspace_and_thread. (create_std_terminate_master_breakpoint): Use scoped_restore_current_program_space. (remove_breakpoint): Use scoped_restore_current_pspace_and_thread. (print_breakpoint_location): Use scoped_restore_current_program_space. (bp_loc_is_permanent): Use scoped_restore_current_pspace_and_thread. (resolve_sal_pc): Use scoped_restore_current_pspace_and_thread. (download_tracepoint_locations): Use scoped_restore_current_pspace_and_thread. (breakpoint_re_set): Use scoped_restore_current_pspace_and_thread. * exec.c (exec_close_1): Use scoped_restore_current_program_space. (enum step_over_calls_kind): Moved from inferior.h. (class scoped_restore_current_thread): New class. * gdbthread.h (make_cleanup_restore_current_thread): Delete declaration. (scoped_restore_current_thread): New class. * infcmd.c: Include "common/gdb_optional.h". (continue_1, proceed_after_attach): Use scoped_restore_current_thread. (notice_new_inferior): Use scoped_restore_current_thread. * inferior.c: Include "progspace-and-thread.h". (restore_inferior, save_current_inferior): Delete. (add_inferior_command, clone_inferior_command): Use scoped_restore_current_pspace_and_thread. * inferior.h (scoped_restore_current_inferior): New class. * infrun.c: Include "progspace-and-thread.h" and "common/gdb_optional.h". (follow_fork_inferior): Use scoped_restore_current_pspace_and_thread. (scoped_restore_exited_inferior): New class. (handle_vfork_child_exec_or_exit): Use scoped_restore_exited_inferior, scoped_restore_current_pspace_and_thread, scoped_restore_current_thread and scoped_restore. (fetch_inferior_event): Use scoped_restore_current_thread. * linespec.c (decode_line_full, decode_line_1): Use scoped_restore_current_program_space. * mi/mi-main.c: Include "progspace-and-thread.h". (exec_continue): Use scoped_restore_current_thread. (mi_cmd_exec_run): Use scoped_restore_current_pspace_and_thread. (mi_cmd_trace_frame_collected): Use scoped_restore_current_thread. * proc-service.c (ps_pglobal_lookup): Use scoped_restore_current_program_space. * progspace-and-thread.c: New file. * progspace-and-thread.h: New file. * progspace.c (release_program_space, clone_program_space): Use scoped_restore_current_program_space. (restore_program_space, save_current_program_space) (save_current_space_and_thread): Delete. (switch_to_program_space_and_thread): Moved to progspace-and-thread.c. * progspace.h (save_current_program_space) (save_current_space_and_thread): Delete declarations. (scoped_restore_current_program_space): New class. * remote.c (remote_btrace_maybe_reopen): Use scoped_restore_current_thread. * symtab.c: Include "progspace-and-thread.h". (skip_prologue_sal): Use scoped_restore_current_pspace_and_thread. * thread.c (print_thread_info_1): Use scoped_restore_current_thread. (struct current_thread_cleanup): Delete. (do_restore_current_thread_cleanup) (restore_current_thread_cleanup_dtor): Rename/convert both to ... (scoped_restore_current_thread::~scoped_restore_current_thread): ... this new dtor. (make_cleanup_restore_current_thread): Rename/convert to ... (scoped_restore_current_thread::scoped_restore_current_thread): ... this new ctor. (thread_apply_all_command): Use scoped_restore_current_thread. (thread_apply_command): Use scoped_restore_current_thread. * tracepoint.c (tdump_command): Use scoped_restore_current_thread. * varobj.c (value_of_root_1): Use scoped_restore_current_thread.
2017-05-04make_cleanup_restore_current_thread: Look up thread earlierPedro Alves
The unconditional is_stopped call already asserts that the thread exists. gdb/ChangeLog: 2017-05-04 Pedro Alves <palves@redhat.com> * thread.c (make_cleanup_restore_current_thread): Move find_thread_ptid call before the is_stopped call. Assert that the thread is found. Replace is_stopped call by checking the thread's state directly. Remove unnecessary NULL-thread check.
2017-05-04Fix get_core_register_section leak, introduce thread_section_namePedro Alves
This plugs a leak introduced in the previous change to get_core_register_section, which removed an xfree call that is actually necessary because the 'section_name' local is static. From [1] it looks like the reason the variable was made static to begin with, was just "laziness" to avoid having to think about freeing it on every function return path: https://sourceware.org/ml/gdb-patches/2005-03/msg00237.html The easiest to fix that nowadays is to use a std::string. I don't see a need to xstrdup the section name in the single-threaded case though, and also there's more than one place that computes a multi-threaded section name in the same way. So put the section name computation in a wrapper class with state. gdb/ChangeLog: 2017-05-04 Pedro Alves <palves@redhat.com> * corelow.c (thread_section_name): New class. (get_core_register_section, get_core_siginfo): Use it.