aboutsummaryrefslogtreecommitdiff
path: root/gdb
Commit message (Collapse)AuthorAgeFilesLines
* Fix python gdbpy_breakpoint_object leak.Philippe Waroquiers2019-11-142-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | valgrind reports a leak when a breakpoint is created then deleted: ==1313== 40 bytes in 1 blocks are definitely lost in loss record 1,115 of 8,596 ==1313== at 0x4835753: malloc (vg_replace_malloc.c:307) ==1313== by 0x6E05BC: _PyObject_New (object.c:255) ==1313== by 0x470E4B: gdbpy_breakpoint_created(breakpoint*) (py-breakpoint.c:1023) ==1313== by 0x2946D9: operator() (std_function.h:687) ==1313== by 0x2946D9: notify (observable.h:106) ==1313== by 0x2946D9: install_breakpoint(int, std::unique_ptr<breakpoint, std::default_delete<breakpoint> >&&, int) (breakpoint.c:8136) ==1313== by 0x295BCA: create_breakpoint_sal (breakpoint.c:8878) ==1313== by 0x295BCA: create_breakpoints_sal (breakpoint.c:8919) ==1313== by 0x295BCA: create_breakpoints_sal_default (breakpoint.c:13671) ... The leak is due to a superfluous Py_INCREF when the python object is allocated inside gdbpy_breakpoint_created, when the python object is allocated locally: this object has already a refcount of 1, and the only reference is the reference from the C breakpoint object. The Py_INCREF is however needed when the python object was created from python: the python object was stored in bppy_pending_object, and gdbpy_breakpoint_created creates a new reference to this object. Solve the leak by calling 'Py_INCREF (newbp);' only in the bppy_pending_object case. Regression tested on debian/amd64 natively and under valgrind on centos/amd64. Before the patch, 795 tests have a definite leak. After the patch, 197 have a definite leak. Thanks to Tom, that helped on irc with the python refcount logic. gdb/ChangeLog 2019-11-14 Philippe Waroquiers <philippe.waroquiers@skynet.be> * python/py-finishbreakpoint.c (gdbpy_breakpoint_created): only call Py_INCREF (newbp) in the bppy_pending_object case.
* Remove symbol-related static assertsTom Tromey2019-11-133-19/+6
| | | | | | | | | | | | | | | | | | commit 3573abe1d added static asserts to ensure that symbol sizes don't vary. However, this failed to build on Windows, on at least one ARM platform (see PR build/25182) and internally at AdaCore for PPC. So, I think it is probably best to just remove these assertions, effectively reverting 3573abe1d. gdb/ChangeLog 2019-11-13 Tom Tromey <tromey@adacore.com> PR build/25182: * psympriv.h (partial_symbol): Remove static assert. * symtab.h (general_symbol_info, symbol): Remove static assert. Change-Id: I51940fb2240c474838b48494b5072081701789bb
* gdb: Support printf 'z' size modifierAndrew Burgess2019-11-128-2/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The gdb format mechanism doesn't currently support the 'z' size modifier, there are a few places in GDB where this is used. Instead of removing these uses lets just add support to GDB for using 'z'. I found this issue when trying to use some of the debug output. Before this commit: (gdb) set debug dwarf-line 9 (gdb) file test Reading symbols from test... Unrecognized format specifier 'z' in printf (No debugging symbols found in test) (gdb) After this commit: (gdb) set debug dwarf-line 9 (gdb) file test Reading symbols from test... Adding dir 1: /usr/include Adding file 1: test.c Adding file 2: stdc-predef.h Processing actual line 3: file 1, address 0x4004a0, is_stmt 1, discrim 0 Processing actual line 4: file 1, address 0x4004a0, is_stmt 1, discrim 0 .... lots of debug output ... Processing actual line 10: file 1, address 0x4003b7, is_stmt 0, discrim 0 (gdb) I've added a self test to cover the integer format size modifiers, including the 'z' modifier. gdb/ChangeLog: * gdbsupport/format.c (format_pieces::format_pieces): Support printf 'z' size modifier. * gdbsupport/format.h (enum argclass): Add size_t_arg. * printcmd.c (ui_printf): Handle size_t_arg. * ui-out.c (ui_out::vmessage): Likewise. * unittests/format_pieces-selftests.c (test_format_int_sizes): New function. (run_tests): Call test_format_int_sizes. gdb/gdbserver/ChangeLog: * ax.c (ax_printf): Handle size_t_arg. Change-Id: Ib6c44d88aa5bce265d757e4c0698881803dd186f
* Make struct symbol inherit from general_symbol_infoChristian Biesinger2019-11-129-73/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since this is now no longer a POD, also give it a constructor that initializes all fields. (I have considered overloading operator new to zero-initialize the memory instead; let me know if you prefer that) gdb/ChangeLog: 2019-11-12 Christian Biesinger <cbiesinger@google.com> * ada-exp.y (write_ambiguous_var): Update. * buildsym.c (add_symbol_to_list): Update. * dwarf2read.c (read_variable): Update. (new_symbol): Update. * jit.c (finalize_symtab): Update. * language.c (language_alloc_type_symbol): Update. * symtab.c (fixup_symbol_section): Update. (initialize_objfile_symbol_1): Move code to... (initialize_objfile_symbol): ...here. Remove now-unnecessary memset. (allocate_symbol): Update. (allocate_template_symbol): Update. (get_symbol_address): Update. * symtab.h (struct symbol): Inherit from general_symbol_info instead of having as a field, and add a constructor. (SYMBOL_VALUE): Update. (SYMBOL_VALUE_ADDRESS): Update. (SET_SYMBOL_VALUE_ADDRESS): Update. (SYMBOL_VALUE_BYTES): Update. (SYMBOL_VALUE_COMMON_BLOCK): Update. (SYMBOL_BLOCK_VALUE): Update. (SYMBOL_VALUE_CHAIN): Update. (SYMBOL_LANGUAGE): Update. (SYMBOL_SECTION): Update. (SYMBOL_OBJ_SECTION): Update. (SYMBOL_SET_LANGUAGE): Update. (SYMBOL_SET_LINKAGE_NAME): Update. (SYMBOL_SET_NAMES): Update. (SYMBOL_NATURAL_NAME): Update. (SYMBOL_LINKAGE_NAME): Update. (SYMBOL_DEMANGLED_NAME): Update. (SYMBOL_SEARCH_NAME): Update. (SYMBOL_MATCHES_SEARCH_NAME): Update. (struct symbol): Update. (struct template_symbol): Update. (struct rust_vtable_symbol): Update. * xcoffread.c (SYMBOL_DUP): Update. Change-Id: I05b1628455bcce3efaa101e65ef051708d17eb07
* Consolidate setting of current_layoutTom Tromey2019-11-122-4/+7
| | | | | | | | | | | | | | | Currently several functions in tui-layout.c set current_layout after their work is done. This moves this assignment to show_layout, instead. gdb/ChangeLog 2019-11-12 Tom Tromey <tom@tromey.com> * tui/tui-layout.c (show_layout): Set current_layout. (show_source_disasm_command, show_data) (show_source_or_disasm_and_command): Don't set current_layout. Change-Id: Id8b23797d68e607f0fcd6d29b8801869d40d1869
* Move _initialize_tui_layout to end of fileTom Tromey2019-11-122-25/+30
| | | | | | | | | | | | This moves _initialize_tui_layout to the end of the file, conforming to the typical gdb style. gdb/ChangeLog 2019-11-12 Tom Tromey <tom@tromey.com> * tui/tui-layout.c (_initialize_tui_layout): Move to end. Change-Id: I667f741b44b2bc470878a36f093a96d89fa31893
* Make TUI resizing tests more robustTom Tromey2019-11-128-46/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As Sergio pointed out, the TUI resizing tests are flaky. Debugging this showed three main problems. 1. expect's "stty" command processes its arguments one-by-one. So, rather than requesting a single resize, it sends two separate resize requests (one for rows and one for columns). This means gdb sees two SIGWINCH signals and resizes the terminal twice. I consider this a bug in expect, but I couldn't readily see how to report a bug; and anyway the fix wouldn't propagate very quickly. This patch works around this problem by explicitly doing two separate resizes (so it will be robust if expect ever does change); and then by waiting for each resize to complete before continuing. 2. gdb uses curses to drive the console rendering. Currently the test suite looks for terminal text insertion sequences to decide when a command has completed. However, it turns out that, sometimes, curses can output things in non-obvious ways. I didn't debug into curses but I guess this can happen due to output optimizations. No matter the reason, sometimes the current approach of only tracking text insertions is not enough to detect that gdb has finished rendering. This patch fixes this problem by arranging to detect the termination output after any curses command, not just insertion. 3. Detecting when a resize has completed is tricky. In fact, I could not find a way to reliably do this. This patch fixes this problem by adding a special maint "tui-resize-message" setting to gdb. When this is enabled, gdb will print a message after each SIGWINCH has been fully processed. The test suite enables this mode and then waits for the message in order to know when control can be returned to the calling test. This patch also adds a timeout, to avoid the situation where the terminal code fails to notice a change for some reason. This lets the test at least try to continue. gdb/ChangeLog 2019-11-12 Tom Tromey <tom@tromey.com> * tui/tui-win.c (resize_message): New global. (show_tui_resize_message): New function. (tui_async_resize_screen): Print message if requested. (_initialize_tui_win): Add tui-resize-message setting. * NEWS: Add entry for new commands. gdb/doc/ChangeLog 2019-11-12 Tom Tromey <tom@tromey.com> * gdb.texinfo (Maintenance Commands): Document new command. gdb/testsuite/ChangeLog 2019-11-12 Tom Tromey <tom@tromey.com> * lib/tuiterm.exp (_accept): Add wait_for parameter. Check output after any command. Expect prompt after WAIT_FOR is seen. (enter_tui): Enable resize messages. (command): Expect command in output. (get_line): Avoid error when cursor appears to be off-screen. (dump_screen): Include screen size in title. (_do_resize): New proc, from "resize". (resize): Rewrite. Do resize in two steps. * gdb.tui/empty.exp (layouts): Fix entries. (check_boxes): Remove xfail. (check_text): Dump screen on failure. Change-Id: I420e0259cb99b21adcd28f671b99161eefa7a51d
* Document and extend readline-bindable functionsTom Tromey2019-11-114-1/+27
| | | | | | | | | | | | | | | | | | | | | | | This adds readline-bindable function names to a few gdb functions that already had key bindings. This lets users change the bindings. This also removes the gdb-command function. Due to how this function is implemented, it doesn't make sense to allow binding it. Finally, this updates the documentation to reflect these changes. gdb/ChangeLog 2019-11-11 Tom Tromey <tom@tromey.com> * tui/tui.c (tui_initialize_readline): Add new bindable readline functions. gdb/doc/ChangeLog 2019-11-11 Tom Tromey <tom@tromey.com> * gdb.texinfo (TUI Keys): Document readline function names. Change-Id: I2233779b7aefe372f19bd03c8f325733c3385e72
* Document operate-and-get-nextTom Tromey2019-11-112-0/+11
| | | | | | | | | | | | | This adds some documentation for the operate-and-get-next readline function that gdb supplies. The text is largely taken from the Bash manual. gdb/doc/ChangeLog 2019-11-11 Tom Tromey <tom@tromey.com> * gdb.texinfo (Editing): Document operate-and-get-next. Change-Id: I9adb16d9ce84bfbda5fe8a2828f668ea878c080c
* Use getpwuid_r instead of getpwuidChristian Biesinger2019-11-112-1/+8
| | | | | | | | | | gdb/ChangeLog: 2019-11-11 Christian Biesinger <cbiesinger@google.com> * nat/linux-osdata.c (user_from_uid): Use getpwuid_r. Change-Id: I587359267f8963ef1da6ba0223a1525807a721de
* Fix typo in vFile:pwrite documentationTom Tromey2019-11-112-1/+5
| | | | | | | | | | | | | | A user on irc noticed that the remote protocol documentation mentioned "vFile:write" -- but this is a typo, there is only "vFile:pwrite". This patch fixes the bug. Tested by rebuilding, committing as obvious. gdb/doc/ChangeLog 2019-11-11 Tom Tromey <tromey@adacore.com> * gdb.texinfo (Host I/O Packets): Fix typo in "vFile:pwrite". Change-Id: I2f668a691eed7883ba6bc092471739f44c82301b
* gdb/python: Introduce gdb.lookup_static_symbolsAndrew Burgess2019-11-109-0/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If gdb.lookup_static_symbol is going to return a single symbol then it makes sense (I think) for it to return a context sensitive choice of symbol, that is the global static symbol that would be visible to the program at that point. However, if the user of the python API wants to instead get a consistent set of global static symbols, no matter where they stop, then they have to instead consider all global static symbols with a given name - there could be many. That is what this new API function offers, it returns a list (possibly empty) of all global static symbols matching a given name (and optionally a given symbol domain). gdb/ChangeLog: * python/py-symbol.c (gdbpy_lookup_static_symbols): New function. * python/python-internal.h (gdbpy_lookup_static_symbols): Declare new function. * python/python.c (python_GdbMethods): Add gdb.lookup_static_symbols method. * NEWS: Mention gdb.lookup_static_symbols. gdb/testsuite/ChangeLog: * gdb.python/py-symbol.exp: Add test for gdb.lookup_static_symbols. gdb/doc/ChangeLog: * python.texi (Symbols In Python): Add documentation for gdb.lookup_static_symbols. Change-Id: I1153b0ae5bcbc43b3dcf139043c7a48bf791e1a3
* gdb/python: smarter symbol lookup for gdb.lookup_static_symbolAndrew Burgess2019-11-108-14/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using gdb.lookup_static_symbol I think that GDB should find static symbols (global symbol with static linkage) from the current object file ahead of static symbols from other object files. This means that if we have two source files f1.c and f2.c, and both files contains 'static int foo;', then when we are stopped in f1.c a call to 'gdb.lookup_static_symbol ("foo")' will find f1.c::foo, and if we are stopped in f2.c we would find 'f2.c::foo'. Given that gdb.lookup_static_symbol always returns a single symbol, but there can be multiple static symbols with the same name GDB is always making a choice about which symbols to return. I think that it makes sense for the choice GDB makes in this case to match what a user would get on the command line if they asked to 'print foo'. gdb/testsuite/ChangeLog: * gdb.python/py-symbol.c: Declare and call function from new py-symbol-2.c file. * gdb.python/py-symbol.exp: Compile both source files, and add new tests for gdb.lookup_static_symbol. * gdb.python/py-symbol-2.c: New file. gdb/doc/ChangeLog: * python.texi (Symbols In Python): Extend documentation for gdb.lookup_static_symbol. gdb/ChangeLog: * python/py-symbol.c (gdbpy_lookup_static_symbol): Lookup in static block of current object file first. Also fix typo in header comment. Change-Id: Ie55dbeb8806f35577b46015deecde27a0ca2ab64
* gdb: Add a class to track last display symtab and line informationAndrew Burgess2019-11-103-73/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In stack.c we currently have a set of static global variables to track the last displayed symtab and line. This commit moves all of these into a class and adds an instance of the class to track the same information. The API into stack.c is unchanged after this cleanup. There should be no user visible changes after this commit. gdb/ChangeLog: * stack.c (set_last_displayed_sal): Delete. (last_displayed_sal_valid): Delete. (last_displayed_pspace): Delete. (last_displayed_addr): Delete. (last_displayed_symtab): Delete. (last_displayed_line): Delete. (class last_displayed_symtab_info_type): New. (last_displayed_symtab_info): New static global variable. (print_frame_info): Call methods on last_displayed_symtab_info. (clear_last_displayed_sal): Update header comment, and make use of last_displayed_symtab_info. (last_displayed_sal_is_valid): Likewise. (get_last_displayed_pspace): Likewise. (get_last_displayed_addr): Likewise. (get_last_displayed_symtab): Likewise. (get_last_displayed_line): Likewise. (get_last_displayed_sal): Likewise. * stack.h (clear_last_displayed_sal): Update header comment. (last_displayed_sal_is_valid): Likewise. (get_last_displayed_pspace): Likewise. (get_last_displayed_addr): Likewise. (get_last_displayed_symtab): Likewise. (get_last_displayed_line): Likewise. (get_last_displayed_sal): Likewise. Change-Id: Ia3dbfe267feec03108c5c8ed8bd94fc0a030c3ed
* gdb: Convert frame_show_address to return a boolAndrew Burgess2019-11-103-4/+10
| | | | | | | | | | | | Just a clean up, should be no user visible changes after this commit. gdb/ChangeLog: * stack.c (frame_show_address): Convert return type to bool. * stack.h (frame_show_address): Likewise, and update header comment. Change-Id: Iaaa9ebd4ff6534db19c5329f1c604932c747bd7f
* gdb_vecs.h: Avoid self move assignAndrew Burgess2019-11-104-1/+75
| | | | | | | | | | | | | | | | | | | | | | | | | While working on another patch I ran into an issue with unordered_remove (in gdb_vecs.h), where removing the last item of the vector can cause a self move assign. When compiling the C++ standard library in debug mode (with -D_GLIBCXX_DEBUG=1) this causes an error to trigger. I've fixed the issue in this patch and provided a unit test. The provided unit test includes an assignment operator which checks for self move assign, this removes the need to compile with -D_GLIBCXX_DEBUG=1 in order to spot the bug. If you're keen to see the error reported from the C++ standard library then remove operator= from the unit test and recompile GDB with -D_GLIBCXX_DEBUG=1. gdb/ChangeLog: * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add new file to the list. * unittests/vec-utils-selftests.c: New file. * gdbsupport/gdb_vecs.h (unordered_remove): Avoid self move assign. Change-Id: I80247b20cd5212038117db7412865f5e6a9257cd
* Remove can_highlight from TUI windowsTom Tromey2019-11-104-7/+12
| | | | | | | | | | | | | | | | | | | Each TUI window has a "can_highlight" member. However, this has the same meaning as "can_box" -- a window can be highlighted if and only if it can be boxed. So, this patch removes can_highlight in favor of simply using can_box. gdb/ChangeLog 2019-11-10 Tom Tromey <tom@tromey.com> * tui/tui-wingeneral.c (tui_unhighlight_win): Use can_box. (tui_highlight_win): Likewise. (tui_win_info::check_and_display_highlight_if_needed): Likewise. * tui/tui-data.h (struct tui_win_info) <can_highlight>: Remove. * tui/tui-command.h (struct tui_cmd_window) <tui_cmd_window>: Don't set can_highlight. Change-Id: I35916859070efcdfcc6e692c71cc6070956dcfce
* Remove unused constructor declaration from cli_style_optionTom Tromey2019-11-102-3/+5
| | | | | | | | | | | | | I noticed that cli_style_option declares a constructor that is never defined. This removes it. gdb/ChangeLog 2019-11-10 Tom Tromey <tom@tromey.com> * cli/cli-style.h (class cli_style_option) <cli_style_option>: Remove unused declaration. Change-Id: Ic59ec7eab4d7183d9392b58709354b2d4449b7be
* Constify command_line_inputTom Tromey2019-11-087-9/+20
| | | | | | | | | | | | | | | | | | | | | | | | | This changes command_line_input to return a "const char *", which is appropriate because the memory is owned by command_line_input. Then it fixes up the users. I looked at making command_line_input transfer ownership to its caller instead, but this is complicated due to the way read_next_line is called, so I decided against it. Tested by rebuilding. gdb/ChangeLog 2019-11-08 Tom Tromey <tromey@adacore.com> * top.c (read_command_file): Update. (command_line_input): Make return type const. * python/py-gdb-readline.c: Update. * linespec.c (decode_line_2): Update. * defs.h (command_line_input): Make return type const. * cli/cli-script.c (read_next_line): Make return type const. * ada-lang.c (get_selections): Update. Change-Id: I27e6c9477fd1005ab5b16e0d337e4c015b6e6248
* [gdb/contrib] Add words.sh scriptTom de Vries2019-11-071-0/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a script that takes a list of files as arguments and output a list of words from the C comments with their frequencies. For: ... $ ./gdb/contrib/words.sh $(find gdb -type f -name "*.c" -o -name "*.h") ... it generates a list of ~15000 words prefixed with frequency. This could be used to generate a dictionary that is kept as part of the sources, against which new code can be checked, generating a warning or error. The hope is that misspellings would trigger this frequently, and rare words rarely, otherwise the burden of updating the dictionary would be too much. And for: ... $ ./gdb/contrib/words.sh -f 1 $(find gdb -type f -name "*.c" -o -name "*.h") ... it generates a list of ~5000 words with frequency 1. This can be used to scan for misspellings manually. Change-Id: I7b119c9a4519cdbf62a3243d1df2927c80813e8b
* Use strtok_r instead of strtokChristian Biesinger2019-11-0610-27/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improves threadsafety. This will be important when the patch series at https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/176 lands. gdb/ChangeLog: 2019-11-06 Christian Biesinger <cbiesinger@google.com> * linux-tdep.c (linux_info_proc): Use strtok_r instead of strtok. * mi/mi-main.c (output_cores): Likewise. * nat/linux-osdata.c (linux_xfer_osdata_cpus): Likewise. (linux_xfer_osdata_modules): Likewise. * remote.c (register_remote_support_xml): Likewise. * sparc64-tdep.c (adi_is_addr_mapped): Likewise. * xml-syscall.c (syscall_create_syscall_desc): Likewise. gdb/gdbserver/ChangeLog: 2019-11-06 Christian Biesinger <cbiesinger@google.com> * linux-x86-low.c (x86_linux_process_qsupported): Use strtok_r instead of strtok. * server.c (handle_query): Likewise. (captured_main): Likewise. Change-Id: Ief6138965a24398e5fc064598cd8f2abd3b5047c
* Remove some includes of readline.hTom Tromey2019-11-0612-15/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | I went through most of the spots that include readline.h and, when appropriate, either removed the include or changed it to include tilde.h. Note that remote-sim.c and bsd-kvm.c could probably include tilde.h instead, but I did not change these. I think I can't build the latter, and I didn't want to set up a sim build for the former. Tested by rebuilding. gdb/ChangeLog 2019-11-06 Tom Tromey <tom@tromey.com> * tui/tui-interp.c: Don't include readline.h. * tui/tui-hooks.c: Don't include readline.h. * symmisc.c: Include tilde.h, not readline.h. * symfile.c: Include tilde.h, not readline.h. * source.c: Include tilde.h, not readline.h. * solib.c: Include tilde.h, not readline.h. * psymtab.c: Include tilde.h, not readline.h. * exec.c: Include tilde.h, not readline.h. * corelow.c: Include tilde.h, not readline.h. * cli/cli-dump.c: Include tilde.h, not readline.h. * cli/cli-cmds.c: Don't include readline.h. Change-Id: I60487a190c43128b800ef77517d1ab42957571d7
* Fix regression from TUI disassembly style patchTom Tromey2019-11-052-2/+9
| | | | | | | | | | | | | | | My previous patch to add styling to the TUI disassembly failed to correctly fix a bug that Simon had pointed out in review. This patch fixes the bug. gdb/ChangeLog 2019-11-05 Tom Tromey <tom@tromey.com> * tui/tui-disasm.c (struct tui_asm_line) <addr_size>: New member. (tui_disassemble): Set addr_size. (tui_disasm_window::set_contents): Use addr_size. Change-Id: Ic0152f3b82a2f79be28ae46d590096661f271580
* Remove la_get_string memberTom Tromey2019-11-0515-47/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The la_get_string member of struct language_defn was intended to provide a way to fetch string data from a "string" object in a language-dependent way. However, it turned out that this was never needed, and was only ever implemented for C. This patch removes the language hook entirely. gdb/ChangeLog 2019-11-05 Tom Tromey <tom@tromey.com> * rust-lang.c (rust_language_defn): Update. * python/py-value.c (valpy_string): Call c_get_string. * 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.c (unknown_language_defn, auto_language_defn): Update. (default_get_string): Remove. * guile/scm-value.c (gdbscm_value_to_string): Use c_get_string. * go-lang.c (go_language_defn): Update. * f-lang.c (f_language_defn): Update. * d-lang.c (d_language_defn): Update. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Update. * ada-lang.c (ada_language_defn): Update. * language.h (struct language_defn) <la_get_string>: Remove. (LA_GET_STRING): Remove. (default_get_string): Don't declare. Change-Id: Ia97763dfe34dc8ecb46587f7a651f8af9be8fdbd
* Style disassembly in the TUITom Tromey2019-11-056-142/+205
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes the TUI disassembly window to style its contents. The styling should be identical to what is seen in the CLI. This involved a bit of rearrangement, so that the source and disassembly windows could share both the copy_source_line utility function, and the ability to react to changes in "set style enabled". This version introduces a new function to strip the styling from the address string when computing the length. As a byproduct, it also removes the unused "insn_size" computation from tui_disasm_window::set_contents. gdb/ChangeLog 2019-11-05 Tom Tromey <tom@tromey.com> * tui/tui-source.h (struct tui_source_window): Inline constructor. Remove destructor. <style_changed, m_observable>: Move to superclass. * tui/tui-winsource.h (tui_copy_source_line): Declare. (struct tui_source_window_base): Move private members to end. <style_changed, m_observable>: Move from tui_source_window. * tui/tui-winsource.c (tui_copy_source_line): Move from tui-source.c. Rename from copy_source_line. Add special handling for negative line number. (tui_source_window_base::style_changed): Move from tui_source_window. (tui_source_window_base): Register observer. (~tui_source_window_base): New. * tui/tui-source.c (copy_source_line): Move to tui-winsource.c; rename. (tui_source_window::set_contents): Use tui_copy_source_line. (tui_source_window::tui_source_window): Move to tui-source.h. (tui_source_window::~tui_source_window): Remove. (tui_source_window::style_changed): Move to superclass. * tui/tui-disasm.c (tui_disassemble): Create string file with styling, when possible. Add "addr_size" parameter. (tui_disasm_window::set_contents): Use tui_copy_source_line. Don't compute maximum size. (len_without_escapes): New function Change-Id: I8722635eeecbbb1633d943a65b856404c2d467b0
* Change tui_source_element::line to have type std::stringTom Tromey2019-11-055-6/+14
| | | | | | | | | | | | | | | | This changes tui_source_element::line to be of type std::string. This reduces the number of copies made. gdb/ChangeLog 2019-11-05 Tom Tromey <tom@tromey.com> * tui/tui-winsource.h (struct tui_source_element) <line>: Now a std::string. * tui/tui-winsource.c (tui_show_source_line): Update. * tui/tui-source.c (tui_source_window::set_contents): Update. * tui/tui-disasm.c (tui_disasm_window::set_contents): Update. Change-Id: Id600f3e1d386a2911f187366e05e2ec599068dd2
* Fix ARI warning in symtab.hChristian Biesinger2019-11-052-2/+7
| | | | | | | | | | | gdb/ChangeLog: 2019-11-05 Christian Biesinger <cbiesinger@google.com> * symtab.h (gdb_static_assert): Put && operator at the beginning of the line instead of the end. Change-Id: I6d05c2f5e46c3f317ba97458509b2da9fd03464b
* Add static_asserts for the sizes of space-critical structsChristian Biesinger2019-11-043-0/+25
| | | | | | | | | | | | | | | | | | | Specifically the three structs mentioned in symtab.h: - general_symbol_info - symbol - partial_symbol This ensures that those structs won't accidentally get bigger. gdb/ChangeLog: 2019-11-04 Christian Biesinger <cbiesinger@google.com> * psympriv.h: Add static_asserts for sizeof (general_symbol_info) and sizeof (symbol). * symtab.h: Add a static_assert for sizeof (partial_symbol). Change-Id: Idd68320aa3e79ee7cc749019724636a58ce4b9c6
* Obsolete Solaris 10 supportRainer Orth2019-11-045-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here's the patch corresponding to the Solaris 10 obsoletion announcement https://sourceware.org/ml/gdb/2019-10/msg00008.html Right now it doesn't remove any code, but obviates the need to test on that ancient platform. Besides, some of the patches I have in my queue would require different solutions for Solaris 10 and 11. There are a few comment-only references that I've kept since they are still correct as is, even when GDB doesn't support Solaris 10 any longer. The only code fragment I've left in is support for /proc/<pid/path/a.out in procfs.c (procfs_target::pid_to_exec_file): while current Solaris 11 updates provide /proc/<pid>/execname, that wasn't present in Solaris 11.0 and still isn't in current Illumos and I didn't want to make live harder for them. Tested on i386-pc-solaris2.10 (obsolete configuration rejected) and x86_64-pc-linux-gnu x sparc64-solaris2.10 (likewise) resp. x86_64-pc-linux-gnu x sparcv9-solaris2.11 (still builds; I'm using the sparcv9 form for 64-bit SPARC customary on Solaris in the MAINTAINERS file now). * NEWS (Changes since GDB 8.3): Document Solaris 10 removal. * configure.host: Mark *-*-solaris2.10* obsolete. * configure.tgt: Mark Solaris < 11 obsolete. * MAINTAINERS (Target Instruction Set Architectures) <sparc>: Update target triplet.
* [gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (4)Tom de Vries2019-11-0243-397/+359
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a pattern: ... gdb_test <command> <pattern> <command> ... that can be written shorter as: ... gdb_test <command> <pattern> ... Detect this pattern in proc gdb_test: ... global gdb_prompt upvar timeout timeout if [llength $args]>2 then { set message [lindex $args 2] + if { $message == [lindex $args 0] && [llength $args] == 3 } { + error "HERE" + } } else { set message [lindex $args 0] } ... and fix all occurrences in the testsuite/gdb.base subdir. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-11-02 Tom de Vries <tdevries@suse.de> * gdb.base/advance.exp: Drop superfluous 3rd argument to gdb_test. * gdb.base/anon.exp: Same. * gdb.base/auto-connect-native-target.exp: Same. * gdb.base/call-ar-st.exp: Same. * gdb.base/catch-syscall.exp: Same. * gdb.base/commands.exp: Same. * gdb.base/default.exp: Same. * gdb.base/display.exp: Same. * gdb.base/float.exp: Same. * gdb.base/foll-fork.exp: Same. * gdb.base/help.exp: Same. * gdb.base/info-macros.exp: Same. * gdb.base/info-proc.exp: Same. * gdb.base/info-target.exp: Same. * gdb.base/long_long.exp: Same. * gdb.base/macscp.exp: Same. * gdb.base/memattr.exp: Same. * gdb.base/nofield.exp: Same. * gdb.base/pointers.exp: Same. * gdb.base/printcmds.exp: Same. * gdb.base/ptype.exp: Same. * gdb.base/restore.exp: Same. * gdb.base/return.exp: Same. * gdb.base/scope.exp: Same. * gdb.base/set-noassign.exp: Same. * gdb.base/setshow.exp: Same. * gdb.base/shlib-call.exp: Same. * gdb.base/signals.exp: Same. * gdb.base/sigstep.exp: Same. * gdb.base/skip.exp: Same. * gdb.base/solib-symbol.exp: Same. * gdb.base/stap-probe.exp: Same. * gdb.base/step-line.exp: Same. * gdb.base/step-test.exp: Same. * gdb.base/style.exp: Same. * gdb.base/varargs.exp: Same. * gdb.base/vla-datatypes.exp: Same. * gdb.base/vla-ptr.exp: Same. * gdb.base/vla-sideeffect.exp: Same. * gdb.base/volatile.exp: Same. * gdb.base/watch-cond-infcall.exp: Same. * gdb.base/watchpoint.exp: Same. Change-Id: Ifd24dc13d552e7dd03f9049db419b08c6adc4112
* [gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (3)Tom de Vries2019-11-0217-69/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a pattern: ... gdb_test <command> <pattern> <command> ... that can be written shorter as: ... gdb_test <command> <pattern> ... Detect this pattern in proc gdb_test: ... global gdb_prompt upvar timeout timeout if [llength $args]>2 then { set message [lindex $args 2] + if { $message == [lindex $args 0] && [llength $args] == 3 } { + error "HERE" + } } else { set message [lindex $args 0] } ... and fix all occurrences in the testsuite/gdb.cp subdir. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-11-02 Tom de Vries <tdevries@suse.de> * gdb.cp/anon-union.exp: Drop superfluous 3rd argument to gdb_test. * gdb.cp/cpexprs.exp: Same. * gdb.cp/except-multi-location.exp: Same. * gdb.cp/exceptprint.exp: Same. * gdb.cp/gdb2384.exp: Same. * gdb.cp/inherit.exp: Same. * gdb.cp/m-static.exp: Same. * gdb.cp/meth-typedefs.exp: Same. * gdb.cp/misc.exp: Same. * gdb.cp/namespace.exp: Same. * gdb.cp/non-trivial-retval.exp: Same. * gdb.cp/overload.exp: Same. * gdb.cp/pr17132.exp: Same. * gdb.cp/re-set-overloaded.exp: Same. * gdb.cp/rvalue-ref-types.exp: Same. * gdb.cp/templates.exp: Same. Change-Id: I0254d0cea71e7376aedb078166188a8010eeaebe
* Simplify print_sys_errmsgTom Tromey2019-11-012-6/+5
| | | | | | | | | | | | On irc, Christian pointed out that print_sys_errmsg could be simplified by avoiding alloca entirely. This patch implements this. gdb/ChangeLog 2019-11-01 Tom Tromey <tromey@adacore.com> * utils.c (print_sys_errmsg): Simplify. Change-Id: Ic399dade274ea61b63ef0540b3a3be2f0f80160a
* Fix up safe_strerror constificationTom Tromey2019-11-012-1/+5
| | | | | | | | | | | | The earlier patch to constify safe_strerror missed a couple of spots, corrected here. gdb/ChangeLog 2019-11-01 Tom Tromey <tromey@adacore.com> * gdbsupport/mingw-strerror.c (safe_strerror): Constify result. Change-Id: I36d5ced144d27b1a6734d9ab9a10a7b9f339ae88
* Move check for strerror_r to common.m4 where it belongsChristian Biesinger2019-11-017-7/+18
| | | | | | | | | | | | | | | | | | | gdb/ChangeLog: 2019-11-01 Christian Biesinger <cbiesinger@google.com> * configure: Regenerate. * configure.ac: Remove check for strerror_r. * gdbsupport/common.m4: Check for strerror_r. gdb/gdbserver/ChangeLog: 2019-11-01 Christian Biesinger <cbiesinger@google.com> * configure: Regenerate. * configure.ac: Remove check for strerror_r. Change-Id: Ibc290c3f84b1db23e998cffdbe2c1f97651d2a8d
* [ARM, thumb] Fix disassembling bug after reloading a symbol fileLuis Machado2019-11-015-10/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The speed optimization from commit 5f6cac4085c95c5339b9549dc06d4f9184184fa6 made GDB skip reloading all symbols when the same symbol file is reloaded. As a result, ARM targets only read the mapping symbols the first time we load a symbol file. When reloaded, the speed optimization above will cause an early return and gdbarch_record_special_symbol won't be called to save mapping symbol data, which in turn affects disassembling of thumb instructions. First load and correct disassemble output: Dump of assembler code for function main: 0x0000821c <+0>: bx pc 0x0000821e <+2>: nop 0x00008220 <+4>: mov r0, #0 0x00008224 <+8>: bx lr Second load and incorrect disassemble output: Dump of assembler code for function main: 0x0000821c <+0>: bx pc 0x0000821e <+2>: nop 0x00008220 <+4>: movs r0, r0 0x00008222 <+6>: b.n 0x8966 0x00008224 <+8>: vrhadd.u16 d14, d14, d31 This happens because the mapping symbol data is stored in an objfile_key-based container, and that data isn't preserved across the two symbol loading operations. The following patch fixes this by storing the mapping symbol data in a bfd_key-based container, which doesn't change as long as the bfd is the same. I've also added a new test to verify the correct disassemble output. gdb/ChangeLog: 2019-11-01 Luis Machado <luis.machado@linaro.org> PR gdb/25124 * arm-tdep.c (arm_per_objfile): Rename to ... (arm_per_bfd): ... this. (arm_objfile_data_key): Rename to ... (arm_bfd_data_key): ... this. (arm_find_mapping_symbol): Adjust access to new bfd_key-based data. (arm_record_special_symbol): Likewise. gdb/testsuite/ChangeLog: 2019-11-01 Luis Machado <luis.machado@linaro.org> PR gdb/25124 * gdb.arch/pr25124.S: New file. * gdb.arch/pr25124.exp: New file. Change-Id: I22c3e6ebe9bfedad66d56fe9656994fa1761c485
* gdb: Don't print a newline in language la_print_typedef methodsAndrew Burgess2019-10-318-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | When calling the language la_print_typedef method, don't include a newline at the end, instead print the newline from the users of la_print_typedef. This change will be useful in a later commit when the output from la_print_typedef will be placed into an MI output field, in which case the trailing newline is not required. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-typeprint.c (ada_print_typedef): Don't print newline at the end. * c-typeprint.c (c_print_typedef): Likewise. * f-typeprint.c (f_print_typedef): Likewise. * m2-typeprint.c (m2_print_typedef): Likewise. * p-typeprint.c (pascal_print_typedef): Likewise. * rust-lang.c (rust_print_typedef): Likewise. * symtab.c (print_symbol_info): Print a newline after calling typedef_print. Change-Id: I6e697ea1ec0eadaa31aefaea959b2055188d680d
* gdb: Add new commands to list module variables and functionsAndrew Burgess2019-10-3111-3/+586
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds two new commands "info module functions" and "info module variables". These commands list all of the functions and variables grouped by module and then by file. For example: (gdb) info module functions All functions in all modules: Module "mod1": File /some/path/gdb/testsuite/gdb.fortran/info-types.f90: 35: void mod1::__copy_mod1_M1t1(Type m1t1, Type m1t1); 25: void mod1::sub_m1_a(integer(kind=4)); 31: integer(kind=4) mod1::sub_m1_b(void); Module "mod2": File /some/path/gdb/testsuite/gdb.fortran/info-types.f90: 41: void mod2::sub_m2_a(integer(kind=4), logical(kind=4)); 49: logical(kind=4) mod2::sub_m2_b(real(kind=4)); The new commands take set of flags that allow the output to be filtered, the user can filter by variable/function name, type, or containing module. As GDB doesn't currently track the relationship between a module and the variables or functions within it in the symbol table, so I filter based on the module prefix in order to find the functions or variables in each module. What this makes clear is that a user could get this same information using "info variables" and simply provide the prefix themselves, for example: (gdb) info module functions -m mod1 _a All functions matching regular expression "_a", in all modules matching regular expression "mod1": Module "mod1": File /some/path/gdb/testsuite/gdb.fortran/info-types.f90: 25: void mod1::sub_m1_a(integer(kind=4)); Is similar to: (gdb) info functions mod1::.*_a.* All functions matching regular expression "mod1::.*_a": File /some/path/gdb/testsuite/gdb.fortran/info-types.f90: 25: void mod1::sub_m1_a(integer(kind=4)); The benefits I see for a separate command are that the user doesn't have to think (or know) about the module prefix format, nor worry about building a proper regexp. The user can also easily scan across modules without having to build complex regexps. The new function search_module_symbols is extern in this patch despite only being used within symtab.c, this is because a later patch in this series will also be using this function from outside symtab.c. This patch is a new implementation of an idea originally worked on by Mark O'Connor, Chris January, David Lecomber, and Xavier Oro from ARM. gdb/ChangeLog: * symtab.c (info_module_cmdlist): New variable. (info_module_command): New function. (search_module_symbols): New function. (info_module_subcommand): New function. (struct info_modules_var_func_options): New struct. (info_modules_var_func_options_defs): New variable. (make_info_modules_var_func_options_def_group): New function. (info_module_functions_command): New function. (info_module_variables_command): New function. (info_module_var_func_command_completer): New function. (_initialize_symtab): Register new 'info module functions' and 'info module variables' commands. * symtab.h (typedef symbol_search_in_module): New typedef. (search_module_symbols): Declare new function. * NEWS: Mention new commands. gdb/doc/ChangeLog: * gdb.texinfo (Symbols): Document new 'info module variables' and 'info module functions' commands. gdb/testsuite/ChangeLog: * gdb.fortran/info-modules.exp: Update expected results, and add additional tests for 'info module functinos', and 'info module variables'. * gdb.fortran/info-types.exp: Update expected results. * gdb.fortran/info-types.f90: Extend testcase with additional module variables and functions. Change-Id: I8c2960640e2e101b77eff54027d687e21ec22e2b
* gdb/fortran: Add new 'info modules' commandAndrew Burgess2019-10-3113-9/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new command 'info modules' that lists all of the modules GDB knows about from the debug information. A module is a debugging entity in the DWARF defined with DW_TAG_module, currently Fortran is known to use this tag for its modules. I'm not aware of any other language that currently makes use of DW_TAG_module. The output style is similar to the 'info type' output: (gdb) info modules All defined modules: File info-types.f90: 16: mod1 24: mod2 (gdb) Where the user is told the file the module is defined in and, on the left hand side, the line number at which the module is defined along with the name of the module. This patch is a new implementation of an idea originally worked on by Mark O'Connor, Chris January, David Lecomber, and Xavier Oro from ARM. gdb/ChangeLog: * dwarf2read.c (dw2_symtab_iter_next): Handle MODULE_DOMAIN. (dw2_expand_marked_cus): Handle MODULES_DOMAIN. (dw2_debug_names_iterator::next): Handle MODULE_DOMAIN and MODULES_DOMAIN. (scan_partial_symbols): Only create partial module symbols for non declarations. * psymtab.c (recursively_search_psymtabs): Handle MODULE_DOMAIN and MODULES_DOMAIN. * symtab.c (search_domain_name): Likewise. (search_symbols): Likewise. (print_symbol_info): Likewise. (symtab_symbol_info): Likewise. (info_modules_command): New function. (_initialize_symtab): Register 'info modules' command. * symtab.h (enum search_domain): Add MODULES_DOMAIN. * NEWS: Mention new 'info modules' command. gdb/doc/ChangeLog: * gdb.texinfo (Symbols): Document new 'info modules' command. gdb/testsuite/ChangeLog: * gdb.fortran/info-modules.exp: New file. * gdb.fortran/info-types.exp: Build with new file. * gdb.fortran/info-types.f90: Include and use new module. * gdb.fortran/info-types-2.f90: New file. Change-Id: I2b781dd5a06bcad04620ccdc45f01a0f711adfad
* NEWS and documentation for $_gdb_setting and $_gdb_setting_str.Philippe Waroquiers2019-10-314-1/+107
| | | | | | | | | | | | | | | gdb/ChangeLog 2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS: Mention $_gdb_setting, $_gdb_setting_str, $_gdb_maint_setting and $_gdb_maint_setting_str. gdb/doc/ChangeLog 2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Convenience Funs): Document the new $_gdb_setting_str, $_gdb_maint_setting and $_gdb_maint_setting_str convenience functions.
* Test the convenience functions $_gdb_setting and $_gdb_setting_str.Philippe Waroquiers2019-10-314-10/+179
| | | | | | | | | | | | | gdb/testsuite/ChangeLog 2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/setshow.exp: Test $_gdb_setting and $_gdb_setting_str. * gdb.base/settings.exp: Test all settings types using $_gdb_maint_setting and $_gdb_maint_setting_str in proc_show_setting, that now verifies that the value of "maint show" is the same as returned by the settings functions. Test the type of the maintenance settings. * gdb.base/default.exp: Update show_conv_list.
* Implement convenience functions to examine GDB settings.Philippe Waroquiers2019-10-314-2/+244
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new convenience functions $_gdb_setting and $_gdb_setting_str provide access to the GDB settings in user-defined commands. Similarly, $_gdb_maint_setting and $_gdb_maint_setting_str provide access to the GDB maintenance settings. The patch was developed following a comment of Eli about the 'set may-call-functions'. Eli said that user-defined functions should have a way to change their behavior according to this setting. Rather than have a specialized $_may_call_functions, this patch implements a general way to access any GDB setting. Compared to doing such access via Python 'gdb.parameter' and/or 'gdb.execute("set somesetting tosomevalue"): * The 'with' command is much better than the above python usage: if the user types C-c or an error happens between the set pagination off and the python "set pagination on", the above python does not restore the original setting. * Effectively, with the "gdb.parameter" python one liner, it is possible to do simple 'if' conditions, such as set and restore pagination. But mixing the "python if" within canned sequence of commands is cumbersome for non trivial combinations. E.g. if several commands have to be done for a certain condition accessed from python, I guess something like will be needed: python if __some_setting: gdb.execute("some command") python if __some_setting: gdb.execute("some other command") python if __some_setting: gdb.execute("some different command") (without speaking about nested "if-s"). With the convenience function: if $_gdb_setting("some_setting") some command some other command some different command end Integer settings (for example print elements) will also be more difficult to use. For example, a user defined function that scans and prints a linked list might want to use the value of "set print elements" to stop printing the linked list. Doing that by mixing python expression/if is likely doable, but seems not easy with the above one liners. So, in summary, the $_gdb_setting and $_gdb_setting_str avoids to have the heterogeneous mix of python and GDB commands in one single script (and of course, it works even if python is not configured, but that must be an unusual setup I guess). gdb/ChangeLog 2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-cmds.c (setting_cmd, value_from_setting) (gdb_setting_internal_fn, gdb_maint_setting_internal_fn) (str_value_from_setting, gdb_setting_str_internal_fn) (gdb_maint_setting_str_internal_fn): New functions. (_initialize_cli_cmds): Define the new convenience functions. * gdb/cli/cli-setshow.h (get_setshow_command_value_string): Constify. * gdb/cli/cli-setshow.c (get_setshow_command_value_string): Constify.
* Also check for strerror_r in gdbserverChristian Biesinger2019-10-314-2/+11
| | | | | | | | | | | | | | | | | | I forgot to do this in b231e86ac9608056ea837e24d42a878927f5787a Since safe_strerror is in gdbsupport, gdbserver also needs to check for strerror_r, although it's less critical since gdbserver does not use threads as much. gdb/gdbserver/ChangeLog: 2019-10-31 Christian Biesinger <cbiesinger@google.com> * config.in: Regenerate. * configure: Regenerate. * configure.ac: Also check for strerror_r. Change-Id: I6a67c8543cd7a28d6dc94f5986f56abcb55727fe
* [gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (2)Tom de Vries2019-10-3133-183/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a pattern: ... gdb_test <command> <pattern> <command> ... that can be written shorter as: ... gdb_test <command> <pattern> ... Detect this pattern in proc gdb_test: ... global gdb_prompt upvar timeout timeout if [llength $args]>2 then { set message [lindex $args 2] + if { $message == [lindex $args 0] && [llength $args] == 3 } { + error "HERE" + } } else { set message [lindex $args 0] } ... and fix all occurrences in some gdb testsuite subdirs. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-31 Tom de Vries <tdevries@suse.de> * gdb.arch/amd64-disp-step-avx.exp: Drop superfluous 3rd argument to gdb_test. * gdb.arch/amd64-disp-step.exp: Same. * gdb.asm/asm-source.exp: Same. * gdb.btrace/buffer-size.exp: Same. * gdb.btrace/cpu.exp: Same. * gdb.btrace/enable.exp: Same. * gdb.dwarf2/count.exp: Same. * gdb.dwarf2/dw2-ranges-func.exp: Same. * gdb.dwarf2/dw2-ranges-psym.exp: Same. * gdb.fortran/vla-datatypes.exp: Same. * gdb.fortran/vla-history.exp: Same. * gdb.fortran/vla-ptype.exp: Same. * gdb.fortran/vla-value.exp: Same. * gdb.fortran/whatis_type.exp: Same. * gdb.guile/guile.exp: Same. * gdb.multi/tids.exp: Same. * gdb.python/py-finish-breakpoint.exp: Same. * gdb.python/py-framefilter.exp: Same. * gdb.python/py-pp-registration.exp: Same. * gdb.python/py-xmethods.exp: Same. * gdb.python/python.exp: Same. * gdb.server/connect-with-no-symbol-file.exp: Same. * gdb.server/no-thread-db.exp: Same. * gdb.server/run-without-local-binary.exp: Same. * gdb.stabs/weird.exp: Same. * gdb.threads/attach-many-short-lived-threads.exp: Same. * gdb.threads/thread-find.exp: Same. * gdb.threads/tls-shared.exp: Same. * gdb.threads/tls.exp: Same. * gdb.threads/wp-replication.exp: Same. * gdb.trace/ax.exp: Same. * lib/gdb.exp (gdb_test_exact, help_test_raw): Same. Change-Id: I2fa544c68f8c0099a77e03ff04ddc010eb2b6c7c
* Don't read agent symbols when disabledChristian Biesinger2019-10-312-4/+22
| | | | | | | | | | | | | | | | This avoids unnecessary work, and becomes important with the patch in https://sourceware.org/ml/gdb-patches/2019-10/msg01143.html gdb/ChangeLog: 2019-10-31 Christian Biesinger <cbiesinger@google.com> * agent.c (set_can_use_agent): When the setting is turned on, look up agent symbols if we don't have them yet. (agent_new_objfile): Don't look up agent symbols when the agent setting is off. Change-Id: I6523a5640c95d38299998050a6c620e51096e8ed
* Regenerate config.inChristian Biesinger2019-10-312-0/+7
| | | | | | | | | | | | | I forgot to do this in the last commit (b231e86ac9608056ea837e24d42a878927f5787a) gdb/ChangeLog: 2019-10-31 Christian Biesinger <cbiesinger@google.com> * config.in: Regenerate. Change-Id: I60946ffd853a59469c35f19ef8012ac6ea88a31c
* Use strerror_r in safe_strerror if availableChristian Biesinger2019-10-316-17/+33
| | | | | | | | | | | | | | | | | | | | | | | | | Also stores the result in a thread-local static variable and changes the return value to a const char*. This is already important because Guile creates threads and Python can create threads, but with the patch series here: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/176 GDB itself will create threads, too. gdb/ChangeLog: 2019-10-31 Christian Biesinger <cbiesinger@google.com> * configure: Regenerate. * configure.ac: Check for strerror_r. * gdbsupport/common-utils.h (safe_strerror): Change return value to const char * and document that this function is now threadsafe. * gdbsupport/posix-strerror.c (safe_strerror): Make buf thread_local and call strerror_r, if available. * utils.c (perror_string): Update. (print_sys_errmsg): Update. Change-Id: I81048fbaf148035c221c528727f7efe58ba528eb
* [ARM] Store exception handling information per-bfd instead of per-objfileLuis Machado2019-10-312-4/+13
| | | | | | | | | | | | | | | | | | Based on feedback from Tromey, update the use of objfile_key in gdb/arm-tdep.c to use bfd_key instead. That way we don't have to re-create the exception handling data all over again if it was done before for the same BFD. gdb/ChangeLog: 2019-10-31 Luis Machado <luis.machado@linaro.org> * arm-tdep.c (arm_exidx_data_key): Use bfd_key instead of objfile_key. (arm_exidx_new_objfile): Adjust to use objfile->obfd instead of objfile to fetch per-bfd data. (arm_find_exidx_entry): Likewise. Change-Id: Ia7b3208ea8d788414600fa6d770ac76db0562859
* Convert int to bool in agent.cChristian Biesinger2019-10-315-16/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also moves an int declaration inside the for loop. Code cleanup, no change in behavior intended. gdb/ChangeLog: 2019-10-31 Christian Biesinger <cbiesinger@google.com> * gdbsupport/agent.c (debug_agent): Change type to bool. (use_agent): Likewise. (all_agent_symbols_look_up): Likewise. (agent_loaded_p): Change return value to bool. (agent_look_up_symbols): Update. (agent_capability_check): Change return value to bool. * gdbsupport/agent.h (agent_loaded_p): Likewise. (debug_agent): Change type to bool. (use_agent): Likewise. (agent_capability_check): Change return value to bool. gdb/gdbserver/ChangeLog: 2019-10-31 Christian Biesinger <cbiesinger@google.com> * ax.h (debug_agent): Remove duplicate declaration. Change-Id: Icb28a65fcc8c7108bcd59287e6be66bf56f8ccb5
* [gdb/testsuite] Remove superfluous 3rd argument from gdb_test callTom de Vries2019-10-3129-144/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a pattern: ... gdb_test <command> <pattern> <command> ... that can be written shorter as: ... gdb_test <command> <pattern> ... Detect this pattern in proc gdb_test: ... global gdb_prompt upvar timeout timeout if [llength $args]>2 then { set message [lindex $args 2] + if { $message == [lindex $args 0] } { + error "HERE" + } } else { set message [lindex $args 0] } ... and fix all occurences in gdb.ada. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-31 Tom de Vries <tdevries@suse.de> * gdb.ada/array_bounds.exp: Drop superfluous 3rd argument to gdb_test. * gdb.ada/array_subscript_addr.exp: Same. * gdb.ada/arrayidx.exp: Same. * gdb.ada/arrayparam.exp: Same. * gdb.ada/arrayptr.exp: Same. * gdb.ada/boolean_expr.exp: Same. * gdb.ada/call_pn.exp: Same. * gdb.ada/complete.exp: Same. * gdb.ada/fixed_cmp.exp: Same. * gdb.ada/fun_addr.exp: Same. * gdb.ada/funcall_param.exp: Same. * gdb.ada/interface.exp: Same. * gdb.ada/mod_from_name.exp: Same. * gdb.ada/null_array.exp: Same. * gdb.ada/packed_array.exp: Same. * gdb.ada/packed_tagged.exp: Same. * gdb.ada/print_chars.exp: Same. * gdb.ada/print_pc.exp: Same. * gdb.ada/ptype_arith_binop.exp: Same. * gdb.ada/ptype_field.exp: Same. * gdb.ada/ptype_tagged_param.exp: Same. * gdb.ada/rec_return.exp: Same. * gdb.ada/ref_tick_size.exp: Same. * gdb.ada/str_ref_cmp.exp: Same. * gdb.ada/taft_type.exp: Same. * gdb.ada/tagged.exp: Same. * gdb.ada/type_coercion.exp: Same. * gdb.ada/uninitialized_vars.exp: Same. Change-Id: Ibb84a41573c7f21295f3fd42da9b96534205c5c4
* [gdb/testsuite] Add -early pattern flag for gdb_test_multipleTom de Vries2019-10-302-9/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Proc gdb_test_multiple builds up and executes a gdb_expect expression with pattern/action clauses. The clauses are either implicit (added by gdb_test_multiple) or explicit (passed via the gdb_test_multiple parameter user_code). However, there are a few implicit clauses which are inserted before the explicit ones, making sure those take precedence. Add an -early pattern flag for a gdb_test_multiple user_code clause to specify that the clause needs to be inserted before any implicit clause. Using this pattern flag, we can f.i. setup a kfail for an assertion failure <assert> during gdb_continue_to_breakpoint by the rewrite: ... gdb_continue_to_breakpoint <msg> <pattern> ... into: ... set breakpoint_pattern "(?:Breakpoint|Temporary breakpoint) .* (at|in)" gdb_test_multiple "continue" "continue to breakpoint: <msg>" { -early -re "internal-error: <assert>" { setup_kfail gdb/nnnnn "*-*-*" exp_continue } -re "$breakpoint_pattern <pattern>\r\n$gdb_prompt $" { pass $gdb_test_name } } Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-30 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gdb_test_multiple): Handle -early pattern flag. Change-Id: I376c636b0812be52e7137634b1a4f50bf2b999b6