aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2020-07-08Handle Windows drives in auto-load script pathsHannes Domani4-0/+21
Fixes this testsuite fail on Windows: FAIL: gdb.base/auto-load.exp: print $script_loaded Converts the debugfile path from c:/dir/file to /c/dir/file, so it can be appended to the auto-load path. gdb/ChangeLog: 2020-07-08 Hannes Domani <ssbssa@yahoo.de> * auto-load.c (auto_load_objfile_script_1): Convert drive part of debugfile path on Windows. gdb/doc/ChangeLog: 2020-07-08 Hannes Domani <ssbssa@yahoo.de> * gdb.texinfo: Document Windows drive conversion of 'set auto-load scripts-directory'.
2020-07-08Rename the 'obfd' argument to fbsd_nat_target::find_memory_regions.John Baldwin2-6/+11
The argument is passed as a generic cookie value to the supplied callback and is not necessarily a pointer to a bfd. gdb/ChangeLog: * fbsd-nat.c (fbsd_nat_target::find_memory_regions): Rename 'obfd' argument to 'data'.
2020-07-08Use read_memory in ada_exception_message_1Tom Tromey5-3/+17
Testing using the internal AdaCore test suite showed a regression from the target string reading changes. In particular, now ada_exception_message_1 can get the wrong answer in some cases. In particular, when an Ada exception catchpoint is hit, sometimes the exception name will be incorrect. The case I was seeing changed from the correct: Catchpoint 2, CONSTRAINT_ERROR (catch C_E) at [...] to: Catchpoint 2, CONSTRAINT_ERROR (catch C_EE) at [...] I was not able to reproduce this failure with the Fedora gnat. Perhaps it is related to some local change to gnat; I do not know. Meanwhile, because ada_exception_message_1 knows the length of the string to read, we can use read_memory here. This fixes the bug. I've updated the test suite to at least exercise this code path. However, as mentioned above, the new test does not actually provoke the failure. gdb/ChangeLog 2020-07-08 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_exception_message_1): Use read_memory. gdb/testsuite/ChangeLog 2020-07-08 Tom Tromey <tromey@adacore.com> * gdb.ada/catch_ex/foo.adb: Pass string to raise. * gdb.ada/catch_ex.exp: Examine catchpoint text.
2020-07-06gdb: Python unwinders, inline frames, and tail-call framesAndrew Burgess9-48/+185
This started with me running into the bug described in python/22748, in summary, if the frame sniffing code accessed any registers within an inline frame then GDB would crash with this error: gdb/frame.c:579: internal-error: frame_id get_frame_id(frame_info*): Assertion `fi->level == 0' failed. The problem is that, when in the Python unwinder I write this: pending_frame.read_register ("register-name") This is translated internally into a call to `value_of_register', which in turn becomes a call to `value_of_register_lazy'. Usually this isn't a problem, `value_of_register_lazy' requires the next frame (more inner) to have a valid frame_id, which will be the case (if we're sniffing frame #1, then frame #0 will have had its frame-id figured out). Unfortunately if frame #0 is inline within frame #1, then the frame-id for frame #0 can't be computed until we have the frame-id for #1. As a result we can't create a lazy register for frame #1 when frame #0 is inline. Initially I proposed a solution inline with that proposed in bugzilla, changing value_of_register to avoid creating a lazy register value. However, when this was discussed on the mailing list I got this reply: https://sourceware.org/pipermail/gdb-patches/2020-June/169633.html Which led me to look at these two patches: [1] https://sourceware.org/pipermail/gdb-patches/2020-April/167612.html [2] https://sourceware.org/pipermail/gdb-patches/2020-April/167930.html When I considered patches [1] and [2] I saw that all of the issues being addressed here were related, and that there was a single solution that could address all of these issues. First I wrote the new test gdb.opt/inline-frame-tailcall.exp, which shows that [1] and [2] regress the inline tail-call unwinder, the reason for this is that these two patches replace a call to gdbarch_unwind_pc with a call to get_frame_register, however, this is not correct. The previous call to gdbarch_unwind_pc takes THIS_FRAME and returns the $pc value in the previous frame. In contrast get_frame_register takes THIS_FRAME and returns the value of the $pc in THIS_FRAME; these calls are not equivalent. The reason these patches appear (or do) fix the regressions listed in [1] is that the tail call sniffer depends on identifying the address of a caller and a callee, GDB then looks for a tail-call sequence that takes us from the caller address to the callee, if such a series is found then tail-call frames are added. The bug that was being hit, and which was address in patch [1] is that in order to find the address of the caller, GDB ended up creating a lazy register value for an inline frame with to frame-id. The solution in patch [1] is to instead take the address of the callee and treat this as the address of the caller. Getting the address of the callee works, but we then end up looking for a tail-call series from the callee to the callee, which obviously doesn't return any sane results, so we don't insert any tail call frames. The original patch [1] did cause some breakage, so patch [2] undid patch [1] in all cases except those where we had an inline frame with no frame-id. It just so happens that there were no tests that fitted this description _and_ which required tail-call frames to be successfully spotted, as a result patch [2] appeared to work. The new test inline-frame-tailcall.exp, exposes the flaw in patch [2]. This commit undoes patch [1] and [2], and replaces them with a new solution, which is also different to the solution proposed in the python/22748 bug report. In this solution I propose that we introduce some special case logic to value_of_register_lazy. To understand what this logic is we must first look at how inline frames unwind registers, this is very simple, they do this: static struct value * inline_frame_prev_register (struct frame_info *this_frame, void **this_cache, int regnum) { return get_frame_register_value (this_frame, regnum); } And remember: struct value * get_frame_register_value (struct frame_info *frame, int regnum) { return frame_unwind_register_value (frame->next, regnum); } So in all cases, unwinding a register in an inline frame just asks the next frame to unwind the register, this makes sense, as an inline frame doesn't really exist, when we unwind a register in an inline frame, we're really just asking the next frame for the value of the register in the previous, non-inline frame. So, if we assume that we only get into the missing frame-id situation when we try to unwind a register from an inline frame during the frame sniffing process, then we can change value_of_register_lazy to not create lazy register values for an inline frame. Imagine this stack setup, where #1 is inline within #2. #3 -> #2 -> #1 -> #0 \______/ inline Now when trying to figure out the frame-id for #1, we need to compute the frame-id for #2. If the frame sniffer for #2 causes a lazy register read in #2, either due to a Python Unwinder, or for the tail-call sniffer, then we call value_of_register_lazy passing in frame #2. In value_of_register_lazy, we grab the next frame, which is #1, and we used to then ask for the frame-id of #1, which was not computed, and this was our bug. Now, I propose we spot that #1 is an inline frame, and so lookup the next frame of #1, which is #0. As #0 is not inline it will have a valid frame-id, and so we create a lazy register value using #0 as the next-frame-id. This will give us the exact same result we had previously (thanks to the code we inspected above). Encoding into value_of_register_lazy the knowledge that reading an inline frame register will always just forward to the next frame feels.... not ideal, but this seems like the cleanest solution to this recursive frame-id computation/sniffing issue that appears to crop up. The following two commits are fully reverted with this commit, these correspond to patches [1] and [2] respectively: commit 5939967b355ba6a940887d19847b7893a4506067 Date: Tue Apr 14 17:26:22 2020 -0300 Fix inline frame unwinding breakage commit 991a3e2e9944a4b3a27bd989ac03c18285bd545d Date: Sat Apr 25 00:32:44 2020 -0300 Fix remaining inline/tailcall unwinding breakage for x86_64 gdb/ChangeLog: PR python/22748 * dwarf2/frame-tailcall.c (dwarf2_tailcall_sniffer_first): Remove special handling for inline frames. * findvar.c (value_of_register_lazy): Skip inline frames when creating lazy register values. * frame.c (frame_id_computed_p): Delete definition. * frame.h (frame_id_computed_p): Delete declaration. gdb/testsuite/ChangeLog: PR python/22748 * gdb.opt/inline-frame-tailcall.c: New file. * gdb.opt/inline-frame-tailcall.exp: New file. * gdb.python/py-unwind-inline.c: New file. * gdb.python/py-unwind-inline.exp: New file. * gdb.python/py-unwind-inline.py: New file.
2020-07-06gdb/python: New method to access list of register groupsAndrew Burgess10-0/+371
Add a new method gdb.Architecture.register_groups which returns a new object of type gdb.RegisterGroupsIterator. This new iterator then returns objects of type gdb.RegisterGroup. Each gdb.RegisterGroup object just wraps a single reggroup pointer, and (currently) has just one read-only property 'name' that is a string, the name of the register group. As with the previous commit (adding gdb.RegisterDescriptor) I made gdb.RegisterGroup an object rather than just a string in case we want to add additional properties in the future. gdb/ChangeLog: * NEWS: Mention additions to Python API. * python/py-arch.c (archpy_register_groups): New function. (arch_object_methods): Add 'register_groups' method. * python/py-registers.c (reggroup_iterator_object): New struct. (reggroup_object): New struct. (gdbpy_new_reggroup): New function. (gdbpy_reggroup_to_string): New function. (gdbpy_reggroup_name): New function. (gdbpy_reggroup_iter): New function. (gdbpy_reggroup_iter_next): New function. (gdbpy_new_reggroup_iterator): New function (gdbpy_initialize_registers): Register new types. (reggroup_iterator_object_type): Define new Python type. (gdbpy_reggroup_getset): New static global. (reggroup_object_type): Define new Python type. * python/python-internal.h gdb/testsuite/ChangeLog: * gdb.python/py-arch-reg-groups.exp: New file. gdb/doc/ChangeLog: * gdb.texi (Registers): Add @anchor for 'info registers <reggroup>' command. * python.texi (Architectures In Python): Document new register_groups method. (Registers In Python): Document two new object types related to register groups.
2020-07-06gdb/python: Add gdb.Architecture.registers methodAndrew Burgess11-0/+452
This commit adds a new method gdb.Architecture.registers that returns an object of the new type gdb.RegisterDescriptorIterator. This iterator returns objects of the new type gdb.RegisterDescriptor. A RegisterDescriptor is not a way to read the value of a register, this is already covered by Frame.read_register, a RegisterDescriptor is simply a way to discover from Python, which registers are available for a given architecture. I did consider just returning a string, the name of each register, instead of a RegisterDescriptor, however, I'm aware that it we don't want to break the existing Python API in any way, so if I return just a string now, but in the future we want more information about a register then we would have to add a second API to get that information. By going straight to a descriptor object now, it is easy to add additional properties in the future should we wish to. Right now the only property of a register that a user can access is the name of the register. In future we might want to be able to ask the register about is register groups, or its type. gdb/ChangeLog: * Makefile.in (SUBDIR_PYTHON_SRCS): Add py-registers.c * python/py-arch.c (archpy_registers): New function. (arch_object_methods): Add 'registers' method. * python/py-registers.c: New file. * python/python-internal.h (gdbpy_new_register_descriptor_iterator): Declare. (gdbpy_initialize_registers): Declare. * python/python.c (do_start_initialization): Call gdbpy_initialize_registers. * NEWS: Mention additions to the Python API. gdb/testsuite/ChangeLog: * gdb.python/py-arch-reg-names.exp: New file. gdb/doc/ChangeLog: * python.texi (Python API): Add new section the menu. (Frames In Python): Add new @anchor. (Architectures In Python): Document new registers method. (Registers In Python): New section.
2020-07-06gdb/python: Add architecture method to gdb.PendingFrameAndrew Burgess7-1/+54
It could be useful to determine the architecture of a frame being unwound during the frame unwind process, that is, before we have a gdb.Frame, but when we only have a gdb.PendingFrame. The PendingFrame already has a pointer to the gdbarch internally, this commit just exposes an 'architecture' method to Python, and has this return a gdb.Architecture object (list gdb.Frame.architecture does). gdb/ChangeLog: * NEWS: Mention new Python API method. * python/py-unwind.c (pending_framepy_architecture): New function. (pending_frame_object_methods): Add architecture method. gdb/testsuite/ChangeLog: * gdb.python/py-unwind.py (TestUnwinder::__call__): Add test for gdb.PendingFrame.architecture method. gdb/doc/ChangeLog: * python.texi (Unwinding Frames in Python): Document PendingFrame.architecture method.
2020-07-06gdb: Remove deprecated_set_gdbarch_dataAndrew Burgess6-68/+33
There are currently two remaining uses of deprecated_set_gdbarch_data, both of which are needed because during gdbarch initialisation we call gdbarch_data for a data field that is registered using: gdbarch_data_register_post_init (....) However, in both of these cases, the only thing that the call back needs from the gdbarch struct is its obstack. Given this there is nothing stopping us changing the post-init hooks into pre-init hooks. The pre-init hooks don't get passed the full gdbarch, they only get passed its obstack. The IA64 change is completely untested. The user-regs change has been tested a little by locally adding some user-regs to the x86-64 target, and also by running the RISC-V tests, which do use user-regs. gdb/ChangeLog: * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (deprecated_set_gdbarch_data): Delete. (gdbarch_data): Use internal_error for the case where deprecated_set_gdbarch_data was originally needed. * ia64-libunwind-tdep.c (libunwind_descr_init): Update parameters, and use passed in obstack. (libunwind_frame_set_descr): Should no longer get back NULL from gdbarch_data. (_initialize_libunwind_frame): Register as a pre-init gdbarch data type. * user-regs.c (user_regs_init): Update parameters, and use passed in obstack. (user_reg_add): Should no longer get back NULL from gdbarch_data. (_initialize_user_regs): Register as a pre-init gdbarch data type.
2020-07-06[gdb/symtab] Fix line-table end-of-sequence sortingTom de Vries5-6/+30
Consider test-case gdb.dwarf2/dw2-ranges-base.exp. It has (ignoring non-sensical entries that are filtered out by buildsym_compunit::record_line) a line-table for dw2-ranges-base.c like this: ... Line Number Statements: [0x0000014e] Extended opcode 2: set Address to 0x4004ba [0x00000159] Advance Line by 10 to 11 [0x0000015b] Copy [0x0000015c] Advance PC by 12 to 0x4004c6 [0x0000015e] Extended opcode 1: End of Sequence [0x00000161] Extended opcode 2: set Address to 0x4004ae [0x0000016c] Advance Line by 20 to 21 [0x0000016e] Copy [0x0000016f] Advance PC by 12 to 0x4004ba [0x00000171] Extended opcode 1: End of Sequence [0x00000174] Extended opcode 2: set Address to 0x4004a7 [0x0000017f] Advance Line by 30 to 31 [0x00000181] Copy [0x00000182] Advance PC by 7 to 0x4004ae [0x00000184] Extended opcode 1: End of Sequence ... If we disable the sorting in buildsym_compunit::end_symtab_with_blockvector, we have the unsorted line table: ... INDEX LINE ADDRESS IS-STMT 0 11 0x00000000004004ba Y 1 END 0x00000000004004c6 Y 2 21 0x00000000004004ae Y 3 END 0x00000000004004ba Y 4 31 0x00000000004004a7 Y 5 END 0x00000000004004ae Y ... It contains 3 sequences, 11/END, 21/END and 31/END. We want to sort the 3 sequences relative to each other, while sorting on address, to get: ... INDEX LINE ADDRESS IS-STMT 0 31 0x00000000004004a7 Y 1 END 0x00000000004004ae Y 2 21 0x00000000004004ae Y 3 END 0x00000000004004ba Y 4 11 0x00000000004004ba Y 5 END 0x00000000004004c6 Y ... However, if we re-enable the sorting, we have instead: ... INDEX LINE ADDRESS IS-STMT 0 31 0x00000000004004a7 Y 1 21 0x00000000004004ae Y 2 END 0x00000000004004ae Y 3 11 0x00000000004004ba Y 4 END 0x00000000004004ba Y 5 END 0x00000000004004c6 Y ... This is a regression since commit 3d92a3e313 "gdb: Don't reorder line table entries too much when sorting", that introduced sorting on address while keeping entries with the same address in pre-sort order. Indeed the entries 1 and 2 are in pre-sort order (they map to entries 2 and 5 in the unsorted line table), but entry 1 does not belong in the sequence terminated by 2. Fix this by handling End-Of-Sequence entries in the sorting function, such that they are sorted before other entries with the same address. Also, revert the find_pc_sect_line workaround introduced in commit 3d92a3e313, since that's no longer necessary. Tested on x86_64-linux. gdb/ChangeLog: 2020-07-06 Tom de Vries <tdevries@suse.de> * buildsym.c (buildsym_compunit::end_symtab_with_blockvector): Handle End-Of-Sequence in lte_is_less_than. * symtab.c (find_pc_sect_line): Revert change from commit 3d92a3e313 "gdb: Don't reorder line table entries too much when sorting". gdb/testsuite/ChangeLog: 2020-07-06 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/dw2-ranges-base.exp: Test line-table order.
2020-07-06[gdb/tui,c++17] Fix NULL string_view in tui_partial_win_by_nameTom de Vries2-13/+15
When building gdb with CFLAGS=-std=gnu17 and CXXFLAGS=-std=gnu++17 and running test-case gdb.tui/new-layout.exp, we run into: ... UNRESOLVED: gdb.tui/new-layout.exp: left window box after shrink (ll corner) FAIL: gdb.tui/new-layout.exp: right window box after shrink (ll corner) ... In a minimal form, we run into an abort when issuing a winheight command: ... $ gdb -tui -ex "winheight src - 5" <tui stuff> Aborted (core dumped) $ ... with this backtrace at the abort: ... \#0 0x0000000000438db0 in std::char_traits<char>::length (__s=0x0) at /usr/include/c++/9/bits/char_traits.h:335 \#1 0x000000000043b72e in std::basic_string_view<char, \ std::char_traits<char> >::basic_string_view (this=0x7fffffffd4f0, \ __str=0x0) at /usr/include/c++/9/string_view:124 \#2 0x000000000094971b in tui_partial_win_by_name (name="src") at src/gdb/tui/tui-win.c:663 ... due to a NULL comparison which constructs a string_view object from NULL: ... 657 /* Answer the window represented by name. */ 658 static struct tui_win_info * 659 tui_partial_win_by_name (gdb::string_view name) 660 { 661 struct tui_win_info *best = nullptr; 662 663 if (name != NULL) ... In gdbsupport/gdb_string_view.h, we either use: - gdb's copy of libstdc++-v3/include/experimental/string_view, or - the standard implementation of string_view, when built with C++17 or later (which in gcc's case comes from libstdc++-v3/include/std/string_view) In the first case, there's support for constructing a string_view from a NULL pointer: ... /*constexpr*/ basic_string_view(const _CharT* __str) : _M_len{__str == nullptr ? 0 : traits_type::length(__str)}, _M_str{__str} { } ... but in the second case, there's not: ... __attribute__((__nonnull__)) constexpr basic_string_view(const _CharT* __str) noexcept : _M_len{traits_type::length(__str)}, _M_str{__str} { } ... Fix this by removing the NULL comparison altogether. Build on x86_64-linux with CFLAGS=-std=gnu17 and CXXFLAGS=-std=gnu++17, and tested. gdb/ChangeLog: 2020-07-06 Tom de Vries <tdevries@suse.de> PR tui/26205 * tui/tui-win.c (tui_partial_win_by_name): Don't test for NULL name.
2020-07-05[gdb/build,c++17] Fix use of deprecated std::uncaught_exceptionTom de Vries2-1/+16
When compiling gdb with -std=gnu++17, we run into: ... ../../gdb/inferior.h: In member function ‘void \ infcall_suspend_state_deleter::operator()(infcall_suspend_state*) const’: ../../gdb/inferior.h:83:12: error: ‘bool std::uncaught_exception()’ is \ deprecated [-Werror=deprecated-declarations] 83 | if (!std::uncaught_exception ()) ... Fix this by rewriting using std::uncaught_exceptions. Tested on x86_64-linux with gcc 9.3.1 and -std=gnu17/gnu++17. Tested with test-case from RFC patch https://sourceware.org/pipermail/gdb-patches/2020-June/169970.html. gdb/ChangeLog: 2020-07-05 Tom de Vries <tdevries@suse.de> PR build/26187 * inferior.h (struct infcall_suspend_state_deleter): If available, use std::uncaught_exceptions instead of deprecated std::uncaught_exception.
2020-07-03gdb: make macro_stringify return a gdb::unique_xmalloc_ptr<char>Simon Marchi4-16/+15
The change to macro_stringify is straightforward. This allows removing the manual memory management in fixup_definition. gdb/ChangeLog: * macroexp.h (macro_stringify): Return gdb::unique_xmalloc_ptr<char>. * macroexp.c (macro_stringify): Likewise. * macrotab.c (fixup_definition): Update. Change-Id: Id7db8988bdbd569dd51c4f4655b00eb26db277cb
2020-07-03gdb: make macro_expand_next return a gdb::unique_xmalloc_ptr<char>Simon Marchi4-22/+28
For some reason, macro_expand_next does not return a gdb::unique_xmalloc_ptr<char>, like its counterparts macro_expand and macro_expand_once. This patch fixes that. macro_buffer::release now returns a gdb::unique_xmalloc_ptr<char> too, which required updating the other callers. The `.release (). release ()` in macro_stringify looks a bit funny, but it's because one release is for the macro_buffer, and the other is for the unique ptr. I removed the ATTRIBUTE_UNUSED_RESULT on macro_buffer::release, I don't really understand why it's there. I don't see how this method could be called without using the result, that would be an obvious memory leak. The commit that introduced it (4e4a8b932b7 "Add ATTRIBUTE_UNUSED_RESULT to macro_buffer") doesn't give any details. gdb/ChangeLog: * c-exp.y (scan_macro_expansion): Don't free `expansion`. (lex_one_token): Update. * macroexp.c (struct macro_buffer) <release>: Return gdb::unique_xmalloc_ptr<char>. (macro_stringify): Update. (macro_expand): Update. (macro_expand_next): Return gdb::unique_xmalloc_ptr<char>. * macroexp.h (macro_expand_next): Likewise. Change-Id: I67a74d0d479d2c20cdc82161ead7c54cea034f56
2020-07-03gdb: remove callback in macro expand functionsSimon Marchi7-91/+72
I started to look into changing the callbacks in macroexp.h to use gdb::function_view. However, I noticed that the passed lookup function was always `standard_macro_lookup`, which looks up a macro in a `macro_scope` object. Since that doesn't look like a very useful abstraction, it would be simpler to just pass the scope around and have the various functions call standard_macro_lookup themselves. This is what this patch does. gdb/ChangeLog: * macroexp.h (macro_lookup_ftype): Remove. (macro_expand, macro_expand_once, macro_expand_next): Remove lookup function parameters, add scope parameter. * macroexp.c (scan, substitute_args, expand, maybe_expand, macro_expand, macro_expand_once, macro_expand_next): Likewise. * macroscope.h (standard_macro_lookup): Change parameter type to macro_scope. * macroscope.c (standard_macro_lookup): Likewise. * c-exp.y (lex_one_token): Update. * macrocmd.c (macro_expand_command): Likewise. (macro_expand_once_command): Likewise. Change-Id: Id2431b1489359e1b0274dc2b81e5ea5d225d730c
2020-07-03Fix gdb.base/structs2.exp with ClangPedro Alves3-2/+8
gdb.base/structs2.exp fails to run with Clang, because of: gdb compile failed, /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/structs2.c:16:14: warning: implicit conversion from 'int' to 'signed char' changes value from 130 to -126 [-Wconstant-conversion] param_reg (130, 120, 33000, 32000); ~~~~~~~~~ ^~~ /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/structs2.c:16:24: warning: implicit conversion from 'int' to 'short' changes value from 33000 to -32536 [-Wconstant-conversion] param_reg (130, 120, 33000, 32000); ~~~~~~~~~ ^~~~~ 2 warnings generated. === gdb Summary === # of untested testcases 1 Fix it by passing actual negative numbers. gdb/testsuite/ChangeLog: * gdb.base/structs2.c (main): Adjust second parem_reg call to explicitly write negative numbers. * gdb.base/structs2.exp: Adjust expected output.
2020-07-03Fix gdb.base/charset.exp with ClangPedro Alves2-4/+18
gdb.base/charset.exp fails to run with Clang, because of: gdb compile failed, /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/charset.c:144:20: warning: implicit conversion from 'int' to 'char' changes value from 162 to -94 [-Wconstant-conversion] 11, 162, 17); ^~~ /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/charset.c:151:16: warning: implicit conversion from 'int' to 'char' changes value from 167 to -89 [-Wconstant-conversion] 167, ^~~ /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/charset.c:168:16: warning: implicit conversion from 'int' to 'char' changes value from 167 to -89 [-Wconstant-conversion] 167, ^~~ 3 warnings generated. === gdb Summary === # of untested testcases 1 Fix it by changing init_string to take unsigned char parameters. gdb/testsuite/ChangeLog: * gdb.base/charset.c (init_string): Change all char parameters to unsigned char parameters.
2020-07-03Remove stale -DNO_PROTOTYPES bits from gdb testsuitePedro Alves8-67/+27
The gdb.base/call-sc.exp, gdb.base/structs.exp and gdb.base/structs2.exp testcases still try compiling the sources with -DNO_PROTOTYPES, but the corresponding sources don't have any #ifdef NO_PROTOTYPES any longer. Those were removed throughout years ago. OTOH, gdb.base/ovlymgr.h does check for NO_PROTOTYPES, but no .exp file compiles it with -DNO_PROTOTYPES. gdb.base/reread.exp and gdb.base/varargs.exp set a 'prototypes' global, which is a stale bit left behind when the "try-compiling without and then with -DNO_PROTOTYPES" logic was around. gdb/testsuite/ChangeLog: * gdb.base/call-sc.exp (start_scalars_test): Use prepare_for_testing and don't try compiling with -DNO_PROTOTYPES. * gdb.base/overlays.c: Remove references to PARAMS. * gdb.base/ovlymgr.h (PARAMS): Delete, and remove all references. * gdb.base/reread.exp: Don't set 'prototypes' global. * gdb.base/structs.exp (start_structs_test): Use prepare_for_testing and don't try compiling with -DNO_PROTOTYPES. * gdb.base/structs2.exp: Don't set 'prototypes' global. Use prepare_for_testing and don't try compiling with -DNO_PROTOTYPES. Don't issue "set width 0". Remove gdb_stop_suppressing_tests call. * gdb.base/varargs.exp: Don't set 'prototypes' global.
2020-07-03Remove stale overlay testcase bitsPedro Alves4-583/+5
D10V support was removed years ago, but the gdb.base/d10vovly.c file stayed behind. Looking a bit closer, I can't find anywhere that references gdb.base/m32rovly.c either. Both gdb.base/m32rovly.c and gdb.base/d10vovly.c seem to be older copies of gdb.base/ovlymgr.c, that are exactly the same, except for some cosmetic differences, and for missing _ovly_debug_event. Note that gdb.base/ovlymgr.c has the #ifdef __M32R__ bits too. Note also that gdb.base/overlays.exp is currently only supported on m32r, and that uses ovlymgr.c not gdb.base/m32rovly.c. gdb/testsuite/ChangeLog: * gdb.base/d10vovly.c: Delete. * gdb.base/m32rovly.c: Delete. * gdb.base/ovlymgr.c: Remove all code guarded by __D10V__.
2020-07-02gdb: remove unused fetch_inferior_event and inferior_event_handler parametersSimon Marchi10-18/+31
I noticed that fetch_inferior_event receives the client_data parameter from its caller, inferior_event_handler, but doesn't actually need it. This patch removes it. In turn, inferior_event_handler doesn't use its parameter, so remove it too. The `data` argument used when registering remote_async_inferior_event_handler is changed to NULL, to avoid confusion. It could make people think that the value passed is used somewhere, when in fact it's not. gdb/ChangeLog: * inf-loop.c (inferior_event_handler): Remove client_data param. * inf-loop.h (inferior_event_handler): Likewise. * infcmd.c (step_1): Adjust. * infrun.c (proceed): Adjust. (fetch_inferior_event): Remove client_data param. (infrun_async_inferior_event_handler): Adjust. * infrun.h (fetch_inferior_event): Remove `void *` param. * linux-nat.c (handle_target_event): Adjust. * record-btrace.c (record_btrace_handle_async_inferior_event): Adjust. * record-full.c (record_full_async_inferior_event_handler): Adjust. * remote.c (remote_async_inferior_event_handler): Adjust. Change-Id: I3c2aa1eb0ea3e0985df096660d2dcd794674f2ea
2020-07-01Make tui_win_info::name pure virtualTom Tromey3-4/+11
It seemed cleaner to me for tui_win_info::name to be pure virtual. This meant adding a name method to the locator window; but this too seems like an improvement. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-data.h (struct tui_win_info) <name>: Now pure virtual. * tui/tui-stack.h (struct tui_locator_window) <name>: New method.
2020-07-01Remove tui_gen_win_infoTom Tromey6-93/+76
This merges the tui_gen_win_info base class with tui_win_info; renaming the resulting class to tui_win_info. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-wingeneral.c (tui_win_info::refresh_window): Move from tui_gen_win_info. (tui_win_info::make_window): Merge with tui_gen_win_info::make_window. (tui_win_info::make_visible): Move from tui_gen_win_info. * tui/tui-win.c (tui_win_info::max_width): Move from tui_gen_win_info. * tui/tui-layout.h (class tui_layout_window) <m_window>: Change type. <window_factory>: Likewise. * tui/tui-layout.c (tui_win_info::resize): Move from tui_gen_win_info. (make_standard_window): Change return type. (get_locator_window, tui_get_window_by_name): Likewise. (tui_layout_window::apply): Remove a cast. * tui/tui-data.h (MIN_WIN_HEIGHT): Move earlier. (struct tui_win_info): Merge with tui_gen_win_info. (struct tui_gen_win_info): Remove.
2020-07-01Derive tui_locator_window from tui_win_infoTom Tromey2-1/+23
tui_locator_window is the last remaining concrete child class of tui_gen_win_info. It seems a bit cleaner to me to flatten the hierarchy a bit; this patch prepares for that by changing tui_locator_window to derive from tui_win_info. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-stack.h (struct tui_locator_window): Derive from tui_win_info. <do_scroll_horizontal, do_scroll_vertical>: New methods. <can_box>: New method.
2020-07-01Remove body of tui_locator_window constructorTom Tromey2-5/+5
The tui_locator_window constructor initializes the first character of two of its members. However, this is actually an error, since these were changed to be std::string. This removes the erroneous code. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-stack.h (struct tui_locator_window): Remove body.
2020-07-01Don't derive tui_data_item_window from tui_gen_win_infoTom Tromey4-78/+51
There's no deep reason that tui_data_item_window should derive from tui_gen_win_info -- it currently uses a curses window to render, but that isn't truly needed, and it adds some hacks to other parts of the TUI. This patch changes tui_data_item_window so that it doesn't have a base class, and updates the register window. This simplifies the code and enables a subsequent cleanup. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-regs.c (tui_data_window::display_registers_from) (tui_data_window::display_registers_from) (tui_data_window::first_data_item_displayed) (tui_data_window::delete_data_content_windows): Update. (tui_data_window::refresh_window, tui_data_window::no_refresh): Remove. (tui_data_window::check_register_values): Update. (tui_data_item_window::rerender): Add parameters. Update. (tui_data_item_window::refresh_window): Remove. * tui/tui-data.h (struct tui_gen_win_info) <no_refresh>: No longer virtual. * tui/tui-regs.h (struct tui_data_item_window): Don't derive from tui_gen_win_info. <refresh_window, max_height, min_height>: Remove. <rerender>: Add parameters. <x, y, visible>: New members. (struct tui_data_window) <refresh_window, no_refresh>: Remove. <m_item_width>: New member.
2020-07-01Rename tui_data_item_window::item_noTom Tromey3-4/+11
tui_data_item_window::item_no is misnamed -- it only can be used for a register, but it references a "display" number as well. (Based on other comments I've seen in the past -- most since deleted -- I think there were plans at one point to display variables in this window as well. However, this was never implemented.) This patch renames this member to be more correct. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-regs.c (tui_data_window::show_register_group) (tui_data_window::check_register_values): Update. * tui/tui-regs.h (struct tui_data_item_window) <regno>: Rename from item_no.
2020-07-01Remove useless "if' from tui-regs.cTom Tromey2-7/+9
tui_data_window::show_register_group had a useless "if" -- the condition could never be false. This patch removes it. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-regs.c (tui_data_window::show_register_group): Remove useless "if".
2020-07-01Remove tui_data_window::nameTom Tromey3-2/+5
The "name" member of tui_data_window was set, but never used. This removes it. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-regs.c (tui_data_window::show_register_group): Update. * tui/tui-regs.h (struct tui_data_item_window) <name>: Remove.
2020-07-01Move some code out of tui-data.hTom Tromey5-26/+35
This moves some code out of tui-data.h, to more closely related places. Some unused forward declarations are also removed. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-stack.c (SINGLE_KEY): Move from tui-data.h * tui/tui-winsource.h (enum tui_line_or_address_kind) (struct tui_line_or_address): Move from tui-data.h. * tui/tui-win.c (DEFAULT_TAB_LEN): Move from tui-data.h. * tui/tui-data.h (DEFAULT_TAB_LEN): Move to tui-win.c. (tui_cmd_window, tui_source_window_base, tui_source_window) (tui_disasm_window): Don't declare. (enum tui_line_or_address_kind, struct tui_line_or_address): Move to tui-winsource.h. (SINGLE_KEY): Move to tui-stack.c.
2020-07-01Remove tui_expand_tabsTom Tromey5-73/+61
tui_expand_tabs only has a single caller. This patch removes this function, in favor of a tab-expanding variant of string_file. This simplifies the code somewhat. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-regs.h (struct tui_data_item_window) <content>: Now a std::string. * tui/tui-regs.c (class tab_expansion_file): New. (tab_expansion_file::write): New method. (tui_register_format): Change return type. Use tab_expansion_file. (tui_get_register, tui_data_window::display_registers_from) (tui_data_item_window::rerender): Update. * tui/tui-io.h (tui_expand_tabs): Don't declare. * tui/tui-io.c (tui_expand_tabs): Remove.
2020-07-01Use complete_on_enum in tui_reggroup_completerTom Tromey2-9/+6
tui_reggroup_completer has an "XXXX" comment suggesting the use of complete_on_enum. This patch implements this suggestion. gdb/ChangeLog 2020-07-01 Tom Tromey <tom@tromey.com> * tui/tui-regs.c (tui_reggroup_completer): Use complete_on_enum.
2020-07-01Recognize -1 as a tombstone value in .debug_lineFangrui Song2-6/+11
LLD from 11 onwards (https://reviews.llvm.org/D81784) uses -1 to represent a relocation in .debug_line referencing a discarded symbol. Recognize -1 to fix gdb.base/break-on-linker-gcd-function.exp when the linker is a newer LLD. gdb/ChangeLog: * dwarf2/read.c (lnp_state_machine::check_line_address): Test -1.
2020-07-01Allow reference form for DW_AT_associated and DW_AT_allocated attributesAlok Kumar Sharma2-14/+8
Currently, GDB rejects the (die) reference form while it accepts exprloc form. It is allowed in DWARF standard. "Table 7.5: Attribute encodings" in DWARF5 standard. Flang compiler assigns (die) reference to DW_AT_associated and DW_AT_allocated for some cases. gdb/ChangeLog * dwarf2/read.c (set_die_type): Removed conditions to restrict forms for DW_AT_associated and DW_AT_allocated attributes, which is already checked in function attr_to_dynamic_prop.
2020-06-30Fix test breakages caused by removal of gdb_py_test_multiple.Philippe Waroquiers10-39/+52
Tom de Vries detected that some python tests were broken as they were still using gdb_py_test_multiple that was replaced by gdb_test_multiline. Repair these tests by using the new function. gdb/testsuite/ChangeLog 2020-06-30 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.python/py-breakpoint.exp: use gdb_test_multiline instead of gdb_py_test_multiple. * gdb.python/py-cmd.exp: Likewise. * gdb.python/py-events.exp: Likewise. * gdb.python/py-function.exp: Likewise. * gdb.python/py-inferior.exp: Likewise. * gdb.python/py-infthread.exp: Likewise. * gdb.python/py-linetable.exp: Likewise. * gdb.python/py-parameter.exp: Likewise. * gdb.python/py-value.exp: Likewise.
2020-06-30Fix bug in quirk_rust_enumTom Tromey2-1/+6
Tom de Vries pointed out that some Rust tests were failing after the variant part rewrite. He sent an executable, which helped track down this bug. quirk_rust_enum was passing 1 to alloc_rust_variant in one case. However, a comment earlier says: /* We don't need a range entry for the discriminant, but we do need one for every other field, as there is no default variant. */ In this case, we must pass -1 for this parameter. That is what this patch implements. gdb/ChangeLog 2020-06-30 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (quirk_rust_enum): Correctly call alloc_rust_variant for default-less enum.
2020-06-30Do not define basic_string_view::to_stringTom Tromey2-4/+10
gdb's copy of basic_string_view includes a to_string method. However, according to cppreference, this is not a method on the real std::basic_string_view: https://en.cppreference.com/w/cpp/string/basic_string_view This difference matters because gdb_string_view.h will use the standard implementation when built with a C++17 or later. This caused PR build/26183. This patch fixes the problem by changing the method to be a standalone helper function, and then rewriting the uses. Tested by rebuilding with a version of GCC that defaults to C++17. (Note that the build still is not clean; and also I noticed that the libstdc++ string_view forbids the use of nullptr ... I wonder if gdb violates that.) gdb/ChangeLog 2020-06-30 Tom Tromey <tromey@adacore.com> PR build/26183: * ada-lang.c (ada_lookup_name_info::ada_lookup_name_info): Use gdb::to_string. gdbsupport/ChangeLog 2020-06-30 Tom Tromey <tromey@adacore.com> PR build/26183: * gdb_string_view.h (basic_string_view::to_string): Remove. (gdb::to_string): New function.
2020-06-30[gdb/testsuite] Handle early_flags in gdb_default_target_compileTom de Vries2-7/+16
In gdb_default_target_compile, we use dejagnu's default_target_compile, unless we need support for languages that are not yet support in the used dejagnu version, in which case we use a local default_target_compile: gdb_default_target_compile_1. However, there's another reason to use the local default_target_compile: when early_flags is used, because there's no dejagnu release available yet supporting this. Fix this by detecting and handling early_flags in gdb_default_target_compile. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-06-30 Tom de Vries <tdevries@suse.de> PR testsuite/26175 * lib/future.exp (gdb_default_target_compile): Detect and handle early_flags.
2020-06-29gdb: fix documentation of gdbarch_displaced_step_copy_insnSimon Marchi3-6/+7
I spotted something that looks wrong in the doc of gdbarch_displaced_step_copy_insn. It says that if the function returns NULL, it means that it has emulated the behavior of the instruction and written the result to REGS. However, it says below that the function may return NULL to indicate that the instruction can't be single-stepped out-of-line, in which case the core steps the instruction in-line. The two are contradictory. The right one is the latter, if the function returns NULL, the core falls back to in-line stepping. I checked all the implementations of this function and they all agree with this. gdb/ChangeLog: * gdbarch.sh (displaced_step_copy_insn): Update doc. * gdbarch.h: Re-generate. Change-Id: I98163cdd38970cde4c77680e249b10f5d2d5bf9b
2020-06-29gdb/testsuite: better handle failures in simavr board, reap simavr processSimon Marchi2-4/+39
This patch makes a few adjustments to the simavr.exp to handle tests that error out more gracefully. I put all the changes in the same patch because right now it's in a very bad shape, so it's very painful to do small incremental adjustements. I found that with these changes, it becomes reasonably stable. For example, the gdb.base/step-over-syscall.exp test is a bit buggy (stuff for another patch...), in that it calls gdb_load (through clean_restart) with a file that doesn't exist. The gdb_load implementation in simavr.exp gets called with a file that doesn't exist, and simavr (expectedly) fails to start. When this happens, we currently leave the $simavr_spawn_id variable set. However, because the simavr process has terminated, its spawn id is closed. When the next test tries to close the previous connection to simavr, it fails to, and this error is thrown: ERROR: close: spawn id exp86 not open while executing "close -i $simavr_spawn_id" (procedure "gdb_load" line 18) invoked from within In other words, any test ran after step-over-syscall.exp will have simavr.exp's gdb_load fail on it. This patch tries to make sure that simavr.exp's gdb_load only leaves simavr_spawn_id set if everything went fine. If we couldn't start simavr, don't see the expected output, or fail to connect to it, we close the spawn id (if needed) and unset simavr_spawn_id. As an additional precaution, I added a catch around the "close the previous connection" code. Ideally, this shouldn't be necessary, but I bet there are other similar scenarios where we might try to close an already close spawn id. So I think displaying a warning is better than messing up all following tests. Also, the board never wait'ed for the simavr process, resulting in tons of zombie simavr processes hanging around. This patch adds some calls to "wait" whenever we close the connection (or realize it is already closed), which seems to fix the problem. Finally I switched a `gdb_expect` to bare `expect`, where we wait for the "listening" message from simavr. I found it necessary because gdb_expect (through remote_expect) adds a `-i <gdb spawn id> -timeout 10`. So if for some reason the GDB process has crashed in the mean time, this expect will unexpectedly error out with a `spawn id <gdb spawn id> not open`. Therefore, change `gdb_expect` to `expect` so that we only deal with simavr's spawn id here. Here are the results on TESTS="gdb.base/*.exp" before: # of expected passes 4816 # of unexpected failures 4433 # of known failures 2 # of unresolved testcases 300 # of untested testcases 143 # of unsupported tests 7 # of paths in test names 2 # of duplicate test names 10 and after: # of expected passes 21957 # of unexpected failures 1564 # of expected failures 8 # of unknown successes 1 # of known failures 31 # of unresolved testcases 532 # of untested testcases 153 # of unsupported tests 28 # of paths in test names 2 # of duplicate test names 32 I tested using simavr's current master (7c254e2081b5). gdb/testsuite/ChangeLog: * boards/simavr.exp (gdb_load): Catch errors when closing previous connection. Close connection, wait for process and unset simavr_spawn_id on failure. Change-Id: I695fc765e1c22e1d1dc0b08e0f5141244986b868
2020-06-29[gdb/testsuite] Emit unresolved for unknown procTom de Vries2-0/+6
Since commit 26783bce15 "[gdb/testsuite] Don't abort testrun for invalid command in test-case" we don't abort the testrun when encountering an invalid command. However, since we don't report errors in the summary, there's a chance that the error goes unnoticed. Make the invalid command error more visible by marking the test-case unresolved, such that we have f.i.: ... PASS: gdb.python/py-breakpoint.exp: test_bkpt_internal: Test watchpoint write UNRESOLVED: gdb.python/py-breakpoint.exp: test_bkpt_eval_funcs: \ testcase aborted due to invalid command name: gdb_py_test_multiple ERROR: tcl error sourcing py-breakpoint.exp. ERROR: invalid command name "gdb_py_test_multiple" while executing ... === gdb Summary === nr of expected passes 56 nr of unresolved testcases 1 ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-06-29 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (unknown): Make test-case unresolved.
2020-06-29[gdb/testsuite] Expect conformation question in gdb.server/solib-list.expTom de Vries2-0/+9
Before commit a8654e7d78 'Fixes PR 25475: ensure exec-file-mismatch "ask" always asks in case of mismatch', there was a difference in behaviour in test-case gdb.server/solib-list.exp. If the executable did not contain debug info (as is usually the case), gdb would detect a mismatch but not ask for confirmation: ... (gdb) target remote localhost:2346^M Remote debugging using localhost:2346^M warning: Mismatch between current exec-file solib-list^M and automatically determined exec-file /lib64/ld-2.26.so^M exec-file-mismatch handling is currently "ask"^M Reading symbols from /lib64/ld-2.26.so...^M Reading symbols from /usr/lib/debug/lib64/ld-2.26.so.debug...^M 0x00007ffff7dd7ea0 in _start () at rtld.c:745^M 745 }^M (gdb) PASS: gdb.server/solib-list.exp: non-stop 0: target remote ... If the executable did contain debug info (as happens to be the case for openSUSE), gdb would detect a mismatch and ask for confirmation: ... (gdb) PASS: gdb.server/solib-list.exp: non-stop 0: file binfile target remote localhost:2346^M Remote debugging using localhost:2346^M warning: Mismatch between current exec-file solib-list^M and automatically determined exec-file /lib64/ld-2.26.so^M exec-file-mismatch handling is currently "ask"^M Load new symbol table from "/lib64/ld-2.26.so"? (y or n) y^M Reading symbols from /lib64/ld-2.26.so...^M Reading symbols from /usr/lib/debug/lib64/ld-2.26.so.debug...^M 0x00007ffff7dd7ea0 in _start () at rtld.c:745^M 745 }^M (gdb) PASS: gdb.server/solib-list.exp: non-stop 0: target remote ... After commit a8654e7d78, the confirmation is now also asked in case there's no debug info. Tighten the test-case by verifying that the confirmation question is asked, as suggested in the log message of commit a8654e7d78: ... we can remove the bypass introduced by Tom in 6b9374f1, in order to always answer to the 'load' question. ... gdb/testsuite/ChangeLog: 2020-06-29 Tom de Vries <tdevries@suse.de> PR gdb/25475 * gdb.server/solib-list.exp: Verify that the symbol reload confirmation question is asked.
2020-06-28Remove "cmd_type" functionTom Tromey5-34/+16
The cmd_type function only has a single caller, which is in the CLI implementation code. This patch removes the function, and moves the cmd_types enum definition from command.h to cli-decode.h, fixing an 18 year old FIXME. gdb/ChangeLog 2020-06-28 Tom Tromey <tom@tromey.com> * command.h (cmd_types): Remove. (cmd_type): Don't declare. * cli/cli-decode.h (enum cmd_types): Uncomment. No longer a typedef. * cli/cli-cmds.c (setting_cmd): Use cmd->type directly. * cli/cli-decode.c (cmd_type): Remove.
2020-06-27Make {get,set}_inferior_io_terminal inferior methodsPedro Alves9-54/+68
This converts the get_inferior_io_terminal and set_inferior_io_terminal free functions to inferior methods. Since the related commands are called "tty", "{set,show} inferior-tty", and MI's "-inferior-tty-{set,show}", to make the connection between the commands and the code more obvious, the methods are named set_tty/tty instead of set_io_terminal/io_terminal. gdb/ChangeLog: * fork-child.c (prefork_hook): Adjust. * infcmd.c (set_inferior_io_terminal, get_inferior_io_terminal): Delete. (set_inferior_tty_command, show_inferior_tty_command): Adjust. * inferior.c (inferior::set_tty, inferior::tty): New methods. * inferior.h (set_inferior_io_terminal, get_inferior_io_terminal): Remove declarations. (struct inferior) <set_tty, tty>: New methods. (struct inferior) <terminal>: Rename to ... (struct inferior) <m_terminal>: ... this and make private. * main.c (captured_main_1): Adjust. * mi/mi-cmd-env.c (mi_cmd_inferior_tty_set): Adjust. (mi_cmd_inferior_tty_show): Adjust. * nto-procfs.c (nto_procfs_target::create_inferior): Adjust. * windows-nat.c (windows_nat_target::create_inferior): Adjust.
2020-06-26Make test names unique in python.exp and guile.expPhilippe Waroquiers5-95/+95
Version 2, handles the comments of Simon and Pedro. Note that gdb_test_multiline and gdb_py_test_multiple are using the "input line" as the test name, and so when there is a duplicated input line (such as a line containing "end"), we have duplicated test names => as gdb_test_multiline and gdb_py_test_multiple are identical, as indicated in FIXME, move this to gdb.exp, and make the test name unique by adding the inputnr to the pass message for each input. 2020-06-26 Philippe Waroquiers <philippe.waroquiers@skynet.be> * lib/gdb.exp (gdb_test_multiline): New, moved from gdb-guile.exp, have a input seq nr in each pass message. * lib/gdb-guile.exp (gdb_test_multiline): Move to gdb.exp. * lib/gdb-python.exp (gdb_py_test_multiple): Remove. * gdb.python/python.exp: Make test names unique, use gdb_test_multiline instead of gdb_py_test_multiple, use $gdb_test_name. * gdb.guile/guile.exp: Make test names unique, use $gdb_test_name
2020-06-26Fix --enable-libctf and --disable-staticNick Alcock15-6/+146
This fixes test runs and compilation when --disable-libctf, --disable-static, or --enable-shared are passed. Changes since v2: Use GCC_ENABLE and fix indentation. Fix prototype using 'void'. Use 'unsupported' and gdb_caching_proc. Changes since v3: Adapt to upstream changes providing skip_ctf_tests. Changes since v4: Adapt to upstream changes in the seven months (!) since I last looked at this. gdb/ChangeLog * configure.ac: Add --enable-libctf: handle --disable-static properly. * acinclude.m4: sinclude ../config/enable.m4. * Makefile.in (aclocal_m4_deps): Adjust accordingly. (LIBCTF): Substitute in. (CTF_DEPS): New, likewise. (CLIBS): libctf needs symbols from libbfd: move earlier. (CDEPS): Use CTF_DEPS, not LIBCTF, now LIBCTF can include rpath flags. * ctfread.c: Surround in ENABLE_LIBCTF. (elfctf_build_psymtabs) [!ENABLE_LIBCTF]: New stub. * configure: Regenerate. * config.in: Likewise. gdb/testsuite/ChangeLog * configure.ac: Add --enable-libctf. * aclocal.m4: sinclude ../config/enable.m4. * Makefile.in (site.exp): Add enable_libctf to site.exp. * lib/gdb.exp (skip_ctf_tests): Use it. * gdb.base/ctf-constvars.exp: Error message tweak. * gdb.base/ctf-ptype.exp: Likewise. * configure: Regenerate.
2020-06-26Fix -Wstring-compare testcase build failureGary Benson3-2/+16
Clang fails to compile the file gdb/testsuite/gdb.cp/try_catch.cc with the following error: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare] This commit fixes the error, replacing the pointer comparison with a call to strcmp. This commit also adds a final check: the test program is run to the final return statement, and the value of "test" is checked to ensure it is still "true" at that point. gdb/testsuite/ChangeLog: * gdb.cp/try_catch.cc: Include string.h. (main): Replace comparison against string literal with strcmp, avoiding build failure with -Wstring-compare. Add "marker test-complete". * gdb.cp/try_catch.exp: Run the test to the above marker, then verify that the value of "test" is still true.
2020-06-26Improve documentation of which shell is used by GDB's shell commandsEli Zaretskii2-3/+9
gdb/doc/ChangeLog: 2020-06-26 Eli Zaretskii <eliz@gnu.org> * gdb.texinfo (Shell Commands): More accurate description of use of $SHELL. Reported by Sandra Loosemore <sandra@codesourcery.com>.
2020-06-25gdb: use make_unique_xstrdup in set_inferior_io_terminalSimon Marchi2-1/+5
gdb/ChangeLog: * infcmd.c (set_inferior_io_terminal): Use make_unique_xstrdup. Change-Id: I38b6e753f58947531fe4a293d574bc27ec128f47
2020-06-25gdb: make inferior::terminal a unique ptrSimon Marchi4-6/+13
This changes the inferior::terminal field to be a unique pointer, so its deallocation is automatically managed. gdb/ChangeLog: * inferior.h (struct inferior) <terminal>: Change type to gdb::unique_xmalloc_ptr<char>. * inferior.c (inferior::~inferior): Don't free inf->terminal. * infcmd.c (set_inferior_io_terminal): Don't free terminal field, adjust to unique pointer. (get_inferior_io_terminal): Adjust to unique pointer. Change-Id: Iedb6459b4f9eeae812b0cb9d514b5707d5107cdb
2020-06-25gdb/riscv: Loop over all registers for 'info all-registers'Andrew Burgess4-4/+17
Currently the 'info all-registers' command only loops over those registers that are known to GDB. Any registers that are unknown, that is, are mentioned in the target description, but are not something GDB otherwise knows, will not be displayed. This feels wrong, so this commit fixes this mistake. The output of 'info all-registers' now matches 'info registers all'. gdb/ChangeLog: * riscv-tdep.c (riscv_print_registers_info): Loop over all registers, not just the known core set of registers. gdb/testsuite/ChangeLog: * gdb.arch/riscv-tdesc-regs.exp: New test cases.
2020-06-25gdb/riscv: Record information about unknown tdesc registersAndrew Burgess5-3/+145
Making use of the previous commit, record information about unknown registers in the target description, and use this to resolve two issues. 1. Some targets (QEMU) are reporting three register fflags, frm, and fcsr, twice, once in the FPU feature, and once in the CSR feature. GDB does create two registers with identical names, but this is (sort of) fine, we only ever use the first one, and as both registers access the same target state things basically work OK. The only real problem is that the register names show up twice in 'info registers all' output. In this commit we spot the duplicates of these registers and then return NULL when asked for the name of these registers. This causes GDB to hide these registers from the user, fixing this problem. 2. Some targets (QEMU) advertise CSRs that GDB then can't read. The problem is these targets also say these CSRs are part of the save/restore register groups. This means that before an inferior call GDB tries to save all of these CSRs, and a failure to read one causes the inferior call to be abandoned. We already work around this issue to some degree, known CSRs are removed from the save/restore groups, despite what the target might say. However, any unknown CSRs are (currently) not removed in this way. After this commit we keep a log of the register numbers for all unknown CSRs, then when asked about the register groups, we override the group information for unknown CSRs, removing them from the save and restore groups. gdb/ChangeLog: * riscv-tdep.c (riscv_register_name): Return NULL for duplicate fflags, frm, and fcsr registers. (riscv_register_reggroup_p): Remove unknown CSRs from save and restore groups. (riscv_tdesc_unknown_reg): New function. (riscv_gdbarch_init): Pass riscv_tdesc_unknown_reg to tdesc_use_registers. * riscv-tdep.h (struct gdbarch_tdep): Add unknown_csrs_first_regnum, unknown_csrs_count, duplicate_fflags_regnum, duplicate_frm_regnum, and duplicate_fcsr_regnum fields. gdb/testsuite/ChangeLog: * gdb.arch/riscv-tdesc-regs.exp: Extend test case.