aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2017-11-27Move cli object files to cli subdirectoryTom Tromey2-15/+9
Following the "arch" move, this moves the object files corresponding to the cli/*.c source files to the "cli" build directory. ChangeLog 2017-11-27 Tom Tromey <tom@tromey.com> * Makefile.in (SUBDIR_CLI_OBS): Redefine. (%.o): Remove cli rule. (CONFIG_SRC_SUBDIR): Add cli.
2017-11-27A simpler way to make the "arch" build directoryTom Tromey4-28/+17
This implements a simpler way to make the "arch" build directory -- namely, now it is done as an order-only dependency in the Makefile, rather than being created when config.status is run. This simpler because it means that the build directories can be changed without re-running autoconf. ChangeLog 2017-11-27 Tom Tromey <tom@tromey.com> * configure.ac (CONFIG_SRC_SUBDIR): Don't subst. * configure: Rebuild. * Makefile.in (CONFIG_SRC_SUBDIR): Redefine. (CONFIG_DEP_SUBDIR): New variable. (%.o): Add order-only dependency. ($(CONFIG_DEP_SUBDIR)): New target.
2017-11-27fix two issues in gdb.ada/mi_catch_ex.exp (re: "exception-message")Joel Brobecker2-2/+9
The following patch introduced a new feature related to Ada exception catchpoints: commit e547c119d043f2ecffb70452020ab9150d083a91 Author: Joel Brobecker <brobecker@adacore.com> Date: Fri Nov 24 17:09:42 2017 -0500 Subject: (Ada) provide the exception message when hitting an exception catchpoint Unfortunately, the patch left 2 errors in gdb.ada/mi_catch_ex.exp, both inside the "continue_to_exception" function: 1. The exception message on the console can include the exception message, and thus this patch adjust the expected output in the corresponding gdb_expect call to allow it; to allow it. 2. There was a TCL syntax confusion in "$exception_name(..." that caused TCL to evaluate "exception_name as an array, rather than as a variable. This patch fixes this by escaping the '(' (and the corresponding closing parenthesis, for consistency). gdb/testsuite/ChangeLog: * gdb.ada/mi_catch_ex.exp (continue_to_exception): Adjust expected output in gdb_expect call to allow the exception message to be present as well. Fix syntax confusion to avoid TCL thinking that exception_name is an array. Tested on x86_64-linux, with: DejaGnu version 1.6 Expect version 5.45 Tcl version 8.6
2017-11-26Update find command help and search memory docsDominik Czarnota4-2/+22
This patch updates the `find` command help and docs description to show how to search for not null terminated strings when current language's strings includes it. gdb/ChangeLog: PR gdb/21945 * findcmd.c (_initialize_mem_search): Update find command help text. gdb/doc/ChangeLog: PR gdb/21945 * gdb.texinfo (Search Memory): Update description and example about how to search a string without NULL terminator.
2017-11-26python: Fix memleak in do_start_initializationSimon Marchi2-6/+12
While playing with valgrind, I noticed that with Python 3, the progname variable in do_start_initialization is not being freed (concat returns a malloc'ed string). This patch uses unique_xmalloc_ptr to manage it. With Python 2, we pass progname it directly to Py_SetProgramName, so it should not be freed. We therefore release it before passing it. gdb/ChangeLog: * python/python.c (do_start_initialization): Change progname type to gdb::unique_xmalloc_ptr. Release the pointer when using Python 2.
2017-11-26Add include guards to common/format.hTom Tromey2-0/+9
This adds include guards to common/format.h. ChangeLog 2017-11-26 Tom Tromey <tom@tromey.com> * common/format.h: Add include guards.
2017-11-26Change maybe_disable_address_space_randomization to a classTom Tromey6-67/+72
This changes maybe_disable_address_space_randomization to be an RAII class, rather than having it return a cleanup. Regression tested by the buildbot. ChangeLog 2017-11-26 Tom Tromey <tom@tromey.com> * nat/linux-personality.h (class maybe_disable_address_space_randomization): New class. (maybe_disable_address_space_randomization): Don't declare function. * nat/linux-personality.c (restore_personality) (make_disable_asr_cleanup): Remove. (maybe_disable_address_space_randomization): Now a constructor. (~maybe_disable_address_space_randomization): New destructor. * linux-nat.c (linux_nat_create_inferior): Update. gdbserver/ChangeLog 2017-11-26 Tom Tromey <tom@tromey.com> * linux-low.c (linux_create_inferior): Update.
2017-11-26Removes a cleanup from gcore.cTom Tromey2-9/+10
This removes a cleanup from gcore.c, replacing it with unique_xmalloc_ptr. Regression tested by the buildbot. ChangeLog 2017-11-26 Tom Tromey <tom@tromey.com> * gcore.c (write_gcore_file_1): Use gdb::unique_xmalloc_ptr.
2017-11-26Fix broken ChangeLog entry for last commit.Ulrich Weigand1-0/+17
2017-11-26[spu] Fix various test casesUlrich Weigand22-72/+68
The SPU-specific test cases were not modified to use standard_output_file and therefore all were no longer being executed. Fixing this exposed a few other bugs in spu-info noticed by using a more recent compiler, which are also fixed here. gdb/testsuite/ChangeLog: 2017-11-26 Ulrich Weigand <uweigand@de.ibm.com> * gdb.arch/spu-info.c: Include <unistd.h>. (do_signal_test): Fix broken calls to write. * gdb.arch/spu-info.exp: Use prepare_for_testing. Fix checks for empty mailboxes. Update signal tests for corrected do_signal_test routine. Allow nonzero event status.
2017-11-26[spu] Fix single-stepping regressionUlrich Weigand2-3/+12
Switching spu_software_single_step to use a regcache instead of a frame: https://sourceware.org/ml/gdb-patches/2016-11/msg00355.html cause a serious regression to SPU single-stepping. There were two separate problems: - SPU_LSLR_REGNUM is a pseudo register, so we must use the "cooked" regcache methods instead of the "raw" ones to access it. - When accessing a branch target register, we must only use the first four bytes of the 16-byte vector register. This was done automatically by the frame routines, but not by the regcache routines. gdb/ChangeLog: 2017-11-26 Ulrich Weigand <uweigand@de.ibm.com> * spu-tdep.c (spu_software_single_step): Access SPU_LSLR_REGNUM as "cooked" register. Access only first four bytes of branch target registers.
2017-11-25Adding ChangeLog entry for the last commit.Sergio Durigan Junior1-0/+9
2017-11-25Fix PR gdb/22491: Regression when setting SystemTap probe semaphoresSergio Durigan Junior1-4/+12
Pedro has kindly pointed out that gdb.arch/amd64-stap-optional-prefix.exp was failing after my C++-ification patches touching the probe interface. The failure is kind of cryptic: 77 break -pstap bar 78 Breakpoint 3 at 0x40048d 79 (gdb) PASS: gdb.arch/amd64-stap-optional-prefix.exp: bar: break -pstap bar 80 continue 81 Continuing. 82 83 Program received signal SIGILL, Illegal instruction. 84 main () at amd64-stap-optional-prefix.S:26 85 26 STAP_PROBE1(probe, foo, (%rsp)) It took me a while to figure out where this SIGILL is coming from. Initially I thought it was something related to writing registers to the inferior when dealing with probe arguments, but I discarded this since the arguments were not touching any registers. In the end, this was a mistake that was introduced during the review process of the patch. When setting/clearing a SystemTap probe's semaphore, the code was using 'm_address' (which refers the probe's address) instead of 'm_sem_addr' (which refers to the semaphore's address). This caused GDB to write a bogus value in the wrong memory position, which in turn caused the SIGILL. I am pushing this patch to correct the mistake. On a side note: I told Pedro that the BuildBot hadn't caught the failure during my try build, and for a moment there was a suspicion that the BuildBot might be at fault here. However, I investigate this and noticed that I only did one try build, with a patch that was correctly using 'm_sem_addr' where applicable, and therefore no failure should have happened indeed. I probably should have requested another try build after addressing the review's comments, but they were mostly basic and I didn't think it was needed. Oh, well. 2017-11-25 Sergio Durigan Junior <sergiodj@redhat.com> PR gdb/22491 * stap-probe.c (relocate_address): New function. (stap_probe::get_relocated_address): Use 'relocate_address'. (stap_probe::set_semaphore): Use 'relocate_address' and pass 'm_sem_addr'. (stap_probe::clear_semaphore): Likewise.
2017-11-25Use TOLOWER in SYMBOL_HASH_NEXTPedro Alves4-1/+9
The support for setting breakpoint in functions with ABI tags patch will add a use of SYMBOL_HASH_NEXT in cp-support.c, which fails to compile with: src/gdb/cp-support.c:38:0: src/gdb/cp-support.c: In function ‘unsigned int cp_search_name_hash(const char*)’: src/gdb/../include/safe-ctype.h:148:20: error: ‘do_not_use_tolower_with_safe_ctype’ was not declared in this scope #define tolower(c) do_not_use_tolower_with_safe_ctype ^ src/gdb/minsyms.h:174:18: note: in expansion of macro ‘tolower’ ((hash) * 67 + tolower ((unsigned char) (c)) - 113) ^ src/gdb/cp-support.c:1677:14: note: in expansion of macro ‘SYMBOL_HASH_NEXT’ hash = SYMBOL_HASH_NEXT (hash, *string); ^ This fixes the problem before it happens. I was somewhat worried about whether this might have an impact with languages that are case insensitive, but I convinced myself that it doesn't. As bonus, this improves GDB's minsym interning performance a bit (3%-10%). See <https://sourceware.org/ml/gdb/2017-11/msg00021.html>. gdb/ChangeLog: 2017-11-25 Pedro Alves <palves@redhat.com> * dictionary.c: Include "safe-ctype.h". * minsyms.c: Include "safe-ctype.h". * minsyms.c (SYMBOL_HASH_NEXT): Use TOLOWER instead of tolower.
2017-11-25Fix completing an empty stringPedro Alves5-6/+63
Earlier while working on the big completer rework series, I managed to break (gdb) [TAB] locally, and make GDB crash, but only notice a few weeks down the road, because we have no test for that... I also noticed that: (gdb) [TAB] didn't work (didn't show all commands as matches), even though entering a command with leading whitespace works: (gdb) help This commit fixes the latter and adds a testcase that covers both issues. The gdb.base/completion.exp change is necessary because the new test has a file name that also starts with "gdb.base/complet", making that particular test ambiguous. Adding another letter disambiguates. gdb/ChangeLog: 2017-11-25 Pedro Alves <palves@redhat.com> * completer.c (complete_line_internal_1): Skip spaces until the start of the command. gdb/testsuite/ChangeLog: 2017-11-25 Pedro Alves <palves@redhat.com> * gdb.base/complete-empty.exp: New file. * gdb.base/completion.exp: Adjust.
2017-11-25Add comprehensive C++ operator linespec/location/completion testsPedro Alves4-7/+843
This exercises the special handling C++ operators require in several places in the linespec parser, both the linespec and explicit location completers, symbol lookup, etc. Particularly, makes sure all that works without quoting. Note that despite the apparent smallish size, this adds thousands of tests to the testsuite, due to combination explosion (linespecs, explicit locations, tab completion, complete command, completion at different points in each function, etc.) Grows the gdb.linespec/ tests like this: -# of expected passes 3464 +# of expected passes 7823 gdb/testsuite/ChangeLog: 2017-11-25 Pedro Alves <palves@redhat.com> * gdb.linespec/cpls-ops.cc: New file. * gdb.linespec/cpls-ops.exp: New file. * lib/completion-support.exp (test_complete_prefix_range_re): New, factored out from ... (test_complete_prefix_range): ... this.
2017-11-24Comprehensive C++ linespec/completer testsPedro Alves7-7/+1682
Exercises all sorts of aspects fixed by previous patches, going back a few months. - Exercises label completion, linespecs and explicit locations. - Exercises both quoting vs non-quoting, source filenames, function names, labels, with both linespecs and explicit locations. - Tests corner cases around not-quoting function names, and whitespace and/and completing inside a parameter or template argument list, anonymous namespace awareness, etc. E.g., "break foo<[TAB]" -> "break foo<int>()" "break bar ( int[TAB]" -> "break bar ( int) "break ( anon" -> "break ( anonymous namespace)::func()" "b cfunc() [tab]" -> "b cfunc() const" "b rettype templfunc[tab]" -> "b rettype templfunc<bar>()" ... and others. - Tests the "b source.c[TAB] -> b source.cc:" feature. I.e., colon auto-appending. - Exercises corner cases around C++ "operator<" / "operator<<". (Much more extensive C++ operator completion/linespec handling in a separate patch.) - Exercises both tab completion and "complete" command completion, using routines that handle it automatically, to ensure no test forgets either mode. - Many of the completion tests test completion at at prefix of a given tricky name, to make sure all corner cases are covered. E.g., completing before, at and after ":", "(", "<". - Exercises "keyword" completion. I.e., "b function() [TAB]" displaying "if task thread" as completion match list. Likewise for display explicit location options matches at the appropriate points. - Ensures that the completer finds the same breakpoint locations that setting a breakpoint finds. - Tests that linespec/location completion doesn't find data symbols. - Tests that expression completion still kicks in after a linespec/location keyword. I.e., this: "b function () if global1 + global[TAB]" knows that after "if", you're completing on an expression, and thus breaks words after "if" as an expression and matches on "global" as a data symbol. - Adds common routines to help with all the above, to be used by multiple completion and linespec/location test cases. - More... Grows the gdb.linespec/ tests like this: -# of expected passes 573 +# of expected passes 3464 gdb/testsuite/ChangeLog: 2017-11-24 Pedro Alves <palves@redhat.com> * gdb.linespec/cpcompletion.exp: New file. * gdb.linespec/cpls-hyphen.cc: New file. * gdb.linespec/cpls.cc: New file. * gdb.linespec/cpls2.cc: New file. * gdb.linespec/explicit.exp: Load completion-support.exp. Adjust test to use test_gdb_complete_unique. Add label completion, keyword completion and explicit location completion tests. * lib/completion-support.exp: New file.
2017-11-24Make strcmp_iw NOT ignore whitespace in the middle of tokensPedro Alves5-22/+429
currently "b func tion" manages to set a breakpoint at "function" ! All these years I had never noticed this, but now that the linespec completer actually works, this easily happens by accident, with: "b func t<tab>" expecting to get "thread", but getting instead: "b func tion" ... Also, this: "b rettypefunc<int>" manages to set a breakpoint on "rettype func<int>()". These things happen due to strcmp_iw "magic". Fix it by teaching strcmp_iw about when can it skip whitespace. This required handling user-defined operators, and scope operators, complicating the code a bit, unfortunately. I added unit tests for all the corner cases I stumbled on, as I was developing this, and then in the end wrote a testsuite testcase covering many of the same things and more (to be added later). gdb/ChangeLog: 2017-11-24 Pedro Alves <palves@redhat.com> * cp-support.c (cp_symbol_name_matches_1): New, factored out from cp_fq_symbol_name_matches. Pass language_cplus to strncmp_with_mode. (cp_fq_symbol_name_matches): Call cp_symbol_name_matches_1. (selftests::test_cp_symbol_name_cmp): New. (_initialize_cp_support): Register "cp_symbol_name_matches" selftests. * language.c (default_symbol_name_matcher): Pass language_minimal to strncmp_iw_with_mode. * utils.c: Include "cp-support.h" and <algorithm>. (valid_identifier_name_char, cp_skip_operator_token, skip_ws) (cp_is_operator): New functions. (strncmp_iw_with_mode): Use them. Add language parameter. Don't skip whitespace in the symbol name when the lookup name doesn't have spaces, and vice versa. (strncmp_iw, strcmp_iw): Pass language to strncmp_iw_with_mode. * utils.h (strncmp_iw_with_mode): Add language parameter.
2017-11-24(Ada) provide the exception message when hitting an exception catchpointJoel Brobecker9-12/+118
This patch enhances the debugger to print the exception message, when available, as part of an exception catchpoint hit notification (both GDB/CLI and GDB/MI). For instance, with the following code... procedure A is begin raise Constraint_Error with "hello world"; end A; ... instead of printing... Catchpoint 1, CONSTRAINT_ERROR at 0x000000000040245c in a () at a.adb:3 ... it now prints: Catchpoint 1, CONSTRAINT_ERROR (hello world) at 0x000000000040245c in a () ^^^^^^^^^^^^^ This enhancement requires runtime support. If not present, the debugger just behaves as before. In GDB/MI mode, if the exception message is available, it is provided as an extra field named "exception-message" in the catchpoint notification: *stopped,bkptno="1",[...],exception-name="CONSTRAINT_ERROR", exception-message="hello world",[...] gdb/ChangeLog: * ada-lang.c (ada_exception_message_1, ada_exception_message): New functions. (print_it_exception): If available, display the exception message as well. * NEWS: Document new feature. gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Ada Exception Information): Document new "exception-message" field. gdb/testsuite/ChangeLog: * gdb.ada/catch_ex.exp, gdb.ada/mi_catch_ex.exp, gdb.ada/mi_ex_cond.exp: Accept optional exception message in when hitting an exception catchpoint.
2017-11-24Fix issues with gdb-memory-map.dtdSimon Marchi2-6/+9
While writing a unit test for parse_memory_map, I tried to validate my test input against gdb-memory-map.dtd, and found a few problems with it. This doesn't influence how gdb parses it (AFAIK it doesn't use the linked dtd), but if you edit the xml file in an editor that supports dtds, you'll get plenty of errors. - The <memory-map> element accepts exactly one <memory> OR <property> as a child. This is a problem because you can't have multiple <memory> elements and you shouldn't be able to have <property> elements as direct children of <memory-map>. - The <memory> element wants exactly one <property> child. This is wrong, since you could have zero or more (even though we only support one kind of property currently). - I have no idea wht the device attribute of <memory> is, GDB doesn't read that. I searched back in time a bit but couldn't find a trace of it. I took the opportunity to tighten what is accepted as a value of the memory type and property name attributes. We currently accept any string, but we can restrict them to the values GDB really accepts (and which are documented). AFAIK, this "file" only exists in the documentation, in gdb.texinfo, so this is what I modified. However, it's also available at http://sourceware.org/gdb/gdb-memory-map.dtd. This one should be updated too, but I don't know how that should be done. gdb/doc/ChangeLog: * gdb.texinfo (Memory Map Format): Update gdb-memory-map.dtd.
2017-11-24[spu] Fix spu-linux gdbserver buildUlrich Weigand2-1/+5
Fix a typo in a newly added argument name. gdb/ChangeLog: 2017-11-24 Ulrich Weigand <uweigand@de.ibm.com> * spu-low.c (spu_create_inferior): Fix typo in argument name.
2017-11-24[spu] Fix spu-linux native buildUlrich Weigand2-1/+6
Add missing file to NATDEPFILES. gdb/ChangeLog: 2017-11-24 Ulrich Weigand <uweigand@de.ibm.com> * configure.nat <spu-linux>: Add fork-inferior.o to NATDEPFILES.
2017-11-24Workaround build bug with GCC 6.2.1Philipp Rudo3-6/+16
Building GDB with GCC 6.2.1 gives multiple errors like gdb/dtrace-probe.c: In member function ‘void dtrace_probe::build_arg_exprs(gdbarch*)’: gdb/dtrace-probe.c:627:8: error: types may not be defined in a for-range-declaration [-Werror] for (struct dtrace_probe_arg &arg : m_args Fix it by removing the 'struct' keyword. A similar Bug was already fixed for GCC 6.3.1 https://sourceware.org/ml/gdb-patches/2017-10/msg00442.html gdb/ChangeLog: * dtrace-probe.c (dtrace_probe::build_arg_exprs) (dtrace_probe::is_enabled, dtrace_probe::enable) (dtrace_probe::disable): Remove keyword 'struct' at for-range variable * probe.c (gen_ui_out_table_header_info) (print_ui_out_not_applicables): Remove keyword 'struct' at for-range variable
2017-11-24Fix aarch64-none-elf build errorAlan Hayward2-1/+5
gdb/ * configure.tgt: Add arch/aarch64.o
2017-11-24Poison XNEW and friends for types that should use new/deleteSimon Marchi4-8/+174
This patch (finally!) makes it so that trying to use XNEW with a type that requires "new" will cause a compilation error. The criterion I initially used to allow a type to use XNEW (which calls malloc in the end) was std::is_trivially_constructible, but then realized that gcc 4.8 did not have it. Instead, I went with: using IsMallocatable = std::is_pod<T>; which is just a bit more strict, which doesn't hurt. A similar thing is done for macros that free instead of allocated, the criterion is: using IsFreeable = gdb::Or<std::is_trivially_destructible<T>, std::is_void<T>>; Trying to use XNEW on a type that requires new will result in an error like this: In file included from /home/simark/src/binutils-gdb/gdb/common/common-utils.h:26:0, from /home/simark/src/binutils-gdb/gdb/common/common-defs.h:78, from /home/simark/src/binutils-gdb/gdb/defs.h:28, from /home/simark/src/binutils-gdb/gdb/lala.c:1: /home/simark/src/binutils-gdb/gdb/common/poison.h: In instantiation of ‘T* xnew() [with T = bar]’: /home/simark/src/binutils-gdb/gdb/lala.c:13:3: required from here /home/simark/src/binutils-gdb/gdb/common/poison.h:103:3: error: static assertion failed: Trying to use XNEW with a non-POD data type. Use operator new instead. static_assert (IsMallocatable<T>::value, "Trying to use XNEW with a non-POD\ ^~~~~~~~~~~~~ Generated-code-wise, it adds one more function call (xnew<T>) when using XNEW and building with -O0, but it all goes away with optimizations enabled. gdb/ChangeLog: * common/common-utils.h: Include poison.h. (xfree): Remove declaration, add definition with static_assert. * common/common-utils.c (xfree): Remove. * common/poison.h (IsMallocatable): Define. (IsFreeable): Define. (free): Delete for non-freeable types. (xnew): New. (XNEW): Undef and redefine. (xcnew): New. (XCNEW): Undef and redefine. (xdelete): New. (XDELETE): Undef and redefine. (xnewvec): New. (XNEWVEC): Undef and redefine. (xcnewvec): New. (XCNEWVEC): Undef and redefine. (xresizevec): New. (XRESIZEVEC): Undef and redefine. (xdeletevec): New. (XDELETEVEC): Undef and redefine. (xnewvar): New. (XNEWVAR): Undef and redefine. (xcnewvar): New. (XCNEWVAR): Undef and redefine. (xresizevar): New. (XRESIZEVAR): Undef and redefine.
2017-11-24Create private_thread_info hierarchySimon Marchi11-169/+256
There are multiple definitions of the private_thread_info structure compiled in the same GDB build. Because of the one definition rule, we need to change this if we want to be able to make them non-POD (e.g. use std::vector fields). This patch creates a class hierarchy, with private_thread_info being an abstract base class, and all the specific implementations inheriting from it. In order to poison XNEW/xfree for non-POD types, it is also needed to get rid of the xfree in thread_info::~thread_info, which operates on an opaque type. This is replaced by thread_info::priv now being a unique_ptr, which calls the destructor of the private_thread_info subclass when the thread is being destroyed. Including gdbthread.h from darwin-nat.h gave these errors: /Users/simark/src/binutils-gdb/gdb/gdbthread.h:609:3: error: must use 'class' tag to refer to type 'thread_info' in this scope thread_info *m_thread; ^ class /usr/include/mach/thread_act.h:240:15: note: class 'thread_info' is hidden by a non-type declaration of 'thread_info' here kern_return_t thread_info ^ It turns out that there is a thread_info function in the Darwin/XNU/mach API: http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/thread_info.html Therefore, I had to add the class keyword at a couple of places in gdbthread.h, I don't really see a way around it. gdb/ChangeLog: * gdbthread.h (private_thread_info): Define structure type, add virtual pure destructor. (thread_info) <priv>: Change type to unique_ptr. <private_dtor>: Remove. * thread.c (add_thread_with_info): Adjust to use of unique_ptr. (private_thread_info::~private_thread_info): Provide default implementation. (thread_info::~thread_info): Don't call private_dtor nor manually free priv. * aix-thread.c (private_thread_info): Rename to ... (aix_thread_info): ... this. (get_aix_thread_info): New. (sync_threadlists): Adjust. (iter_tid): Adjust. (aix_thread_resume): Adjust. (aix_thread_fetch_registers): Adjust. (aix_thread_store_registers): Adjust. (aix_thread_extra_thread_info): Adjust. * darwin-nat.h (private_thread_info): Rename to ... (darwin_thread_info): ... this. (get_darwin_thread_info): New. * darwin-nat.c (darwin_init_thread_list): Adjust. (darwin_check_new_threads): Adjust. (thread_info_from_private_thread_info): Adjust. * linux-thread-db.c (private_thread_info): Rename to ... (thread_db_thread_info): ... this, initialize fields. (get_thread_db_thread_info): New. <dying>: Change type to bool. (update_thread_state): Adjust to type rename. (record_thread): Adjust to type rename an use of unique_ptr. (thread_db_pid_to_str): Likewise. (thread_db_extra_thread_info): Likewise. (thread_db_thread_handle_to_thread_info): Likewise. (thread_db_get_thread_local_address): Likewise. * nto-tdep.h (private_thread_info): Rename to ... (nto_thread_info): ... this, initialize fields. (get_nto_thread_info): New. <name>: Change type to std::string. * nto-tdep.c (nto_extra_thread_info): Adjust to type rename and use of unique_ptr. * nto-procfs.c (update_thread_private_data_name): Adjust to std::string change, allocate nto_private_thread_info with new. (update_thread_private_data): Adjust to unique_ptr. * remote.c (private_thread_info): Rename to ... (remote_thread_info): ... this, initialize data members with default values. <extra, name>: Change type to std::string. <thread_handle>: Change type to non-pointer. (free_private_thread_info): Remove. (get_private_info_thread): Rename to... (get_remote_thread_info): ... this, change return type, adjust to use of unique_ptr, use remote_thread_info constructor. (remote_add_thread): Adjust. (get_private_info_ptid): Rename to... (get_remote_thread_info): ...this, change return type. (remote_thread_name): Use get_remote_thread_info, adjust to change to std::string. (struct thread_item) <~thread_item>: Remove. <thread_handle>: Make non pointer. (start_thread): Adjust to thread_item::thread_handle type change. (remote_update_thread_list): Adjust to type name change, move strings from temporary to long-lived object instead of duplicating. (remote_threads_extra_info): Use get_remote_thread_info. (process_initial_stop_replies): Likewise. (resume_clear_thread_private_info): Likewise. (remote_resume): Adjust to type name change. (remote_commit_resume): Use get_remote_thread_info. (process_stop_reply): Adjust to type name change. (remote_stopped_by_sw_breakpoint): Use get_remote_thread_info. (remote_stopped_by_hw_breakpoint): Likewise. (remote_stopped_by_watchpoint): Likewise. (remote_stopped_data_address): Likewise. (remote_core_of_thread): Likewise. (remote_thread_handle_to_thread_info): Use get_private_info_thread, adjust to thread_handle field type change.
2017-11-24remote: C++ify thread_item and threads_listing_contextSimon Marchi6-121/+189
This patch C++ifies the thread_item and threads_listing_context structures in remote.c. thread_item::{extra,name} are changed to std::string. As a result, there's a bit of awkwardness in remote_update_thread_list, where we have to xstrdup those strings when filling the private_thread_info structure. This is removed in the following patch, where private_thread_info is also C++ified and its corresponding fields made std::string too. The xstrdup then becomes an std::move. Other than that there's nothing really special, it's a usual day-to-day VEC -> vector and char* -> std::string change. It allows removing a cleanup in remote_update_thread_list. Note that an overload of hex2bin that returns a gdb::byte_vector is added, with corresponding selftests. gdb/ChangeLog: * remote.c (struct thread_item): Add constructor, disable copy construction and copy assignment, define default move construction and move assignment. <extra, name>: Change type to std::string. <core>: Initialize. <thread_handle>: Make non-pointer. (thread_item_t): Remove typedef. (DEF_VEC_O(thread_item_t)): Remove. (threads_listing_context) <contains_thread>: New method. <remove_thread>: New method. <items>: Change type to std::vector. (clear_threads_listing_context): Remove. (threads_listing_context_remove): Remove. (remote_newthread_step): Use thread_item constructor, adjust to change to std::vector. (start_thread): Use thread_item constructor, adjust to change to std::vector. (end_thread): Adjust to change to std::vector and std::string. (remote_get_threads_with_qthreadinfo): Use thread_item constructor, adjust to std::vector. (remote_update_thread_list): Adjust to change to std::vector and std::string, use threads_listing_context methods. (remove_child_of_pending_fork): Adjust. (remove_new_fork_children): Adjust. * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add rsp-low-selftests.c. (SUBDIR_UNITTESTS_OBS): Add rsp-low-selftests.o. * unittests/rsp-low-selftests.c: New file. * common/rsp-low.h: Include common/byte-vector.h. (hex2bin): New overload. * common/rsp-low.c (hex2bin): New overload.
2017-11-24Create private_inferior class hierarchySimon Marchi7-192/+280
There are currently multiple definitions of private_inferior, defined in remote.c and darwin-nat.h. The patch that poisons XNEW and friends for non-POD types trips on that, because private_inferior is freed in ~inferior(), where it is an opaque type. Since the compiler can't tell whether the type is POD, it gives an error. Also, we can't start using C++ features in these structures (make them non-POD) as long as there are multiple definitions with the same name. For these reasons, this patch makes a class hierarchy, with private_inferior being the abstract base class, and darwin_inferior & remote_inferior inheriting from it. Destruction is done through the virtual destructor. I stumbled on some suspicious code in the darwin implementation though. darwin_check_new_threads does an XCNEW(darwin_thread_t) when it finds a new thread, allocating a new structure for it (darwin_thread_t is a typedef for private_thread_info). It then VEC_safe_pushes it in a vector defined as DEF_VEC_O (a vector of objects). This means that the structure content gets copied in the vector. The thread_info object is created with the XCNEW'ed structure as the private thread info, while the rest of the code works with the instance in the vector. We have therefore two distinct instances of darwin_thread_t/private_thread_info for each thread. This is not really a problem in practice, because thread_info::priv is not used in the darwin code. I still find it weird and far from ideal, so I tried to fix it by changing the vector to be a vector of pointers. There should now be a single instance of the structure for each thread. The deallocation of the darwin_thread_t/private_thread_info structure is done by the thread_info destructor. I am able to build on macOS, but not really test, since the port seems a bit broken. I am not able to debug reliably on the machine I have access to, which runs macOS 10.12.6. gdb/ChangeLog: * inferior.h (private_inferior): Define structure type, add virtual pure destructor. (inferior) <priv>: Change type to unique_ptr. * inferior.c (private_inferior::~private_inferior): Provide default implementation. (inferior::~inferior): Don't free priv field. (exit_inferior_1): Likewise. * darwin-nat.h (struct darwin_exception_info): Initialize fields. (darwin_exception_info): Remove typedef. (DEF_VEC_O (darwin_thread_t)); Remove. (private_inferior): Rename to ... (darwin_private_inferior): ... this, extend private_inferior. (get_darwin_inferior): New. <threads>: Change type to std::vector of darwin_thread_t pointers. * darwin-nat.c (darwin_check_new_threads): Adjust. (find_inferior_task_it): Adjust. (darwin_find_thread); Adjust. (darwin_suspend_inferior): Adjust. (darwin_resume_inferior): Adjust. (darwin_find_new_inferior): Adjust. (darwin_decode_notify_message): Adjust. (darwin_send_reply): Adjust. (darwin_resume_inferior_threads): Adjust. (darwin_suspend_inferior_threads): Adjust. (darwin_decode_message): Adjust. (darwin_wait): Adjust. (darwin_interrupt): Adjust. (darwin_deallocate_threads): Adjust. (darwin_mourn_inferior): Adjust, don't free private data. (darwin_reply_to_all_pending_messages): Adjust. (darwin_stop_inferior): Adjust. (darwin_setup_exceptions): Adjust. (darwin_kill_inferior): Adjust. (darwin_setup_request_notification): Adjust. (darwin_attach_pid): Adjust. (darwin_init_thread_list): Adjust. (darwin_setup_fake_stop_event): Adjust. (darwin_attach): Adjust. (darwin_detach): Adjust. (darwin_xfer_partial): Adjust. (set_enable_mach_exceptions): Adjust. (darwin_pid_to_exec_file): Adjust. (darwin_get_ada_task_ptid): Adjust. * darwin-nat-info.c (get_task_from_args): Adjust. (info_mach_ports_command): Adjust. (info_mach_region_command): Adjust. (info_mach_exceptions_command): Adjust. * remote.c (private_inferior): Rename to ... (remote_private_inferior): ... this, initialize fields. (get_remote_inferior); New. (remote_commit_resume): Use get_remote_inferior. (check_pending_event_prevents_wildcard_vcont_callback): Likewise.
2017-11-24Document linespec/explicit locations & completion improvements (manual + NEWS)Pedro Alves4-22/+80
gdb/ChangeLog: 2017-11-24 Pedro Alves <palves@redhat.com> * NEWS: Mention linespecs and explicit locations, and completion improvements. gdb/doc/ChangeLog: 2017-11-24 Pedro Alves <palves@redhat.com> * gdb.texinfo (Completion): Update need-quoting examples. Remove false claim that GDB inserts quoting automatically. (Symbols): Add anchor.
2017-11-24Remove dead code in regcache::dumpYao Qi2-4/+4
footnote_register_size in regcache::dump is a constant zero, so the condition check against footnote_register_size is dead code. The code writing to footnote_register_size was removed by 01e1877. This patche removes footnote_register_size and the dead code. gdb: 2017-11-24 Yao Qi <yao.qi@linaro.org> * regcache.c (regcache::dump): Remove footnote_register_size.
2017-11-24cooked_read test for readonly regcacheYao Qi2-0/+81
This patch adds a test to check cooked_read for readonly regcache. For raw registers, cooked_read get either REG_VALID or REG_UNKNOWN, depends on the raw register is in save_reggroup or not. For pseudo register, cooked_read get different result in different ports. gdb: 2017-11-24 Yao Qi <yao.qi@linaro.org> * regcache.c (cooked_read_test): Add more test for readonly regcache.
2017-11-24regcache::cooked_read unit testYao Qi5-49/+278
This patch adds a unit test to regcache::cooked_read. This unit test is a little different from normal unit test, it is more about conformance test or interaction test. This test pass both raw register number and pseudo register number to regcache::cooked_read, in order to inspect 1) return value of cooked_read, 2) how are target_ops to_xfer_partial, to_{fetch,store}_registers called (because regcache is updated by means of these three target_ops methods). With this test here, we have a clear picture about how each port of GDB get cooked registers. This patch also shares some code on mock target. gdb: 2017-11-24 Yao Qi <yao.qi@linaro.org> * gdbarch-selftests.c (test_target_has_registers): Move it to target.c. (test_target_has_stack): Likewise. (test_target_has_memory): Likewise. (test_target_prepare_to_store): Likewise. (test_target_store_registers): Likewise. (test_target_ops): Likewise. * regcache.c: Include selftest-arch.h and gdbthread.h. (target_ops_no_register): New class. (test_target_fetch_registers): New. (test_target_store_registers): New. (test_target_xfer_partial): New. (readwrite_regcache): New. (cooked_read_test): New. (_initialize_regcache): Register the test. * target.c: (test_target_has_registers): Moved from gdbarch-selftests.c. (test_target_has_stack): Likewise. (test_target_has_memory): Likewise. (test_target_prepare_to_store): Likewise. (test_target_store_registers): Likewise. * target.h (test_target_ops): New class.
2017-11-24Add xml selftests for aarch64 target description.Alan Hayward7-0/+75
gdb/ * aarch64-tdep.c (_initialize_aarch64_tdep): Add target desc selftest. gdbserver/ * configure.srv: Add linux-aarch64-tdesc-selftest.o. * linux-aarch64-low.c (initialize_low_arch): Call init func. * linux-aarch64-tdesc-selftest.c: New file. * linux-aarch64-tdesc.h (initialize_low_tdesc): New declaration.
2017-11-24Use flexible target descriptors for aarch64Alan Hayward12-212/+244
gdb/ * aarch64-tdep.c (_initialize_aarch64_tdep): Remove init. * arch/aarch64.c (aarch64_create_target_description): Create new target description. * features/Makefile: Add new files. * features/aarch64.c: Remove file. * features/aarch64-core.c: New autogenerated file. * features/aarch64-fpu.c: New autogenerated file. * target-descriptions.c (maint_print_c_tdesc_cmd): Check for aarch64. gdbserver/ * linux-aarch64-ipa.c (initialize_low_tracepoint): Remove init. * linux-aarch64-low.c (initialize_low_arch): Remove init. * linux-aarch64-tdesc.c (aarch64_linux_read_description): Add init.
2017-11-24gdbserver: add aarch64_create_target_descriptionAlan Hayward6-20/+85
gdbserver/ * configure.srv: Add new files. * linux-aarch64-ipa.c (get_ipa_tdesc): Call aarch64_linux_read_description. * linux-aarch64-low.c (aarch64_linux_read_description): Merge with aarch64_arch_setup. (aarch64_arch_setup): Call aarch64_linux_read_description. * linux-aarch64-tdesc.c: New file. * linux-aarch64-tdesc.h: New file.
2017-11-24Add aarch64_create_target_descriptionAlan Hayward9-5/+69
gdb/ * Makefile.in: Add new files. * aarch64-linux-nat.c (aarch64_linux_read_description): Call aarch64_read_description. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Call aarch64_read_description. * aarch64-tdep.c (aarch64_read_description): New function. (aarch64_gdbarch_init): Call aarch64_read_description. * aarch64-tdep.h (aarch64_read_description): New function. * arch/aarch64.c: New file. * configure.tgt: Add new files.
2017-11-24Change value_contents_eq return boolYao Qi4-19/+26
This patch changes value_contents_eq return type from int to bool. gdb: 2017-11-24 Yao Qi <yao.qi@linaro.org> * mi/mi-main.c (register_changed_p): Update. * value.c (value_contents_bits_eq): Change return type. (value_contents_eq): Likewise. * value.h: Update comments.
2017-11-24Change register_changed_p returns boolYao Qi2-20/+18
register_changed_p actually returns bool, but return type is still int. This patch changes the return type to bool. The caller of register_changed_p also checked whether the return value can be negative, which is not needed now. Such check was added in fb40c2090 in 2000, at that moment, register_changed_p returns -1 when read_relative_register_raw_bytes fails. I can tell from its name that it reads register contents, but we don't have this function called inside register_changed_p, and the regcache is read-only. gdb: 2017-11-24 Yao Qi <yao.qi@linaro.org> * mi/mi-main.c (mi_cmd_data_list_changed_registers): Remove local 'changed'. Remove error. (register_changed_p): Change return type to bool.
2017-11-24Change tic6x target descriptionsYao Qi11-44/+286
This patch changes tic6x target descriptions to be more flexible. Rebuild tic6x-uclinux GDBserver with my x86 g++, and the unit test passes. gdb: 2017-11-24 Yao Qi <yao.qi@linaro.org> * arch/tic6x.c: New file. * arch/tic6x.h: New file. * features/Makefile (FEATURE_XMLFILES): Add tic6x-c6xp.xml, tic6x-core.xml and tic6x-gp.xml. * features/tic6x-c6xp.c: Generated. * features/tic6x-core.c: Generated. * features/tic6x-gp.c: Generated. * target-descriptions.c (maint_print_c_tdesc_cmd): Match "tic6x-". gdb/gdbserver: 2017-11-24 Yao Qi <yao.qi@linaro.org> * configure.srv: Set $srv_regobj for tic6x-linux. * linux-tic6x-low.c: Include "arch/tic6x.h" and "tdesc.h". (tic6x_read_description): Move some code to tic6x_arch_setup. (tic6x_tdesc_test): New function. (initialize_low_arch): Call selftests::register_test.
2017-11-23Fix memory leak in list_available_thread_groupsSimon Marchi2-16/+11
Commit C++ify osdata 479f8de1b3b7e69ca8d557bbe9d843c7d1bc89c5 introduced a memory leak. We allocate std::vectors and insert them in a map, but never free them. Instead, the map value type can be std::vector objects directly. gdb/ChangeLog: * mi/mi-main.c (list_available_thread_groups): Change map value type to std::vector.
2017-11-23Fix clang warnings about copy elisionSimon Marchi2-2/+6
When building with clang, I get: /home/emaisin/src/binutils-gdb/gdb/osdata.c:107:9: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move] std::move (std::string (body_text))); ^ /home/emaisin/src/binutils-gdb/gdb/osdata.c:107:9: note: remove std::move call here std::move (std::string (body_text))); ^~~~~~~~~~~ ~ /home/emaisin/src/binutils-gdb/gdb/osdata.c:181:10: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move] return std::move (osdata); ^ /home/emaisin/src/binutils-gdb/gdb/osdata.c:181:10: note: remove std::move call here return std::move (osdata); ^~~~~~~~~~~ ~ Indeed, those two std::move are unnecessary. gdb/ChangeLog: * osdata.c (osdata_end_column, get_osdata): Remove std::move.
2017-11-23Revert unexpected rename in previous patchSimon Marchi2-3/+10
While working on the previous patch, I renamed variables whose type I changed to let the compiler help me find their usages, but I forgot to rename one back to its original name. This patch fixes it. gdb/ChangeLog: * varobj.c (struct varobj_dynamic) <children_requested_>: Rename back to... <children_requested>: ... this. (varobj_get_num_children, varobj_update): Adjust.
2017-11-23Change int -> bool where applicable throughout varobjSimon Marchi6-195/+257
This patch changes all the "int" I could find in varobj.{c,h} that are really boolean values to use bool. I followed the ramifications (parameters and return values of exported functions), so the changes spilled a bit on other, related files (ada-varobj.c and c-varobj.c). gdb/ChangeLog: * ada-varobj.c (ada_value_is_changeable_p): Change int to bool where applicable. (ada_value_has_mutated): Likewise. * c-varobj.c (varobj_is_anonymous_child): Likewise. (c_is_path_expr_parent): Likewise. * mi/mi-cmd-var.c (varobj_update_one): Likewise. (mi_cmd_var_set_frozen): Likewise. (mi_cmd_var_update_iter): Likewise. (mi_cmd_var_update): Likewise. * varobj.c (pretty_printing): Likewise. (varobj_enable_pretty_printing): Likewise. (struct varobj_root) <floating, is_valid>: Likewise. (struct varobj_dynamic) <children_requested>: Likewise. (delete_variable): Likewise. (delete_variable_1): Likewise. (install_variable): Likewise. (update_type_if_necessary): Likewise. (install_new_value): Likewise. (value_of_root): Likewise. (is_root_p): Likewise. (varobj_create): Likewise. (varobj_delete): Likewise. (varobj_has_more): Likewise. (varobj_set_frozen): Likewise. (varobj_get_frozen): Likewise. (install_dynamic_child): Likewise. (dynamic_varobj_has_child_method): Likewise. (update_dynamic_varobj_children): Likewise. (varobj_get_num_children): Likewise. (varobj_list_children): Likewise. (is_path_expr_parent): Likewise. (varobj_default_is_path_expr_parent): Likewise. (varobj_is_dynamic_p): Likewise. (varobj_set_value): Likewise. (varobj_value_has_mutated): Likewise. (varobj_update): Likewise. (check_scope): Likewise. (value_of_root_1): Likewise. (varobj_value_get_print_value): Likewise. (varobj_editable_p): Likewise. (varobj_value_is_changeable_p): Likewise. (varobj_floating_p): Likewise. (varobj_default_value_is_changeable_p): Likewise. (varobj_invalidate_iter): Likewise. * varobj.h (struct varobj_update_result) <type_changed, children_changed, changed, value_installed>: Likewise. (struct varobj) <updated, frozen, not_fetched>: Likewise. (struct lang_varobj_ops) <value_is_changeable_p, value_has_mutated, is_path_expr_parent>: Likewise. (varobj_delete): Likewise. (varobj_set_frozen): Likewise. (varobj_get_frozen): Likewise. (varobj_set_value): Likewise. (varobj_update): Likewise. (varobj_editable_p): Likewise. (varobj_floating_p): Likewise. (varobj_has_more): Likewise. (varobj_is_dynamic_p): Likewise. (varobj_default_value_is_changeable_p): Likewise. (varobj_value_is_changeable_p): Likewise. (varobj_is_anonymous_child): Likewise. (varobj_default_is_path_expr_parent): Likewise.
2017-11-23[testsuite] Pass -g3 to clang in gdb.base/macscp.expYao Qi2-1/+5
clang accepts option -g3 too. I checked the manual of xlc and icc, looks they don't accept -g3 option, so I don't pass -g3 for them. gdb/testsuite: 2017-11-23 Yao Qi <yao.qi@linaro.org> * gdb.base/macscp.exp: Append -g3 to additional_flags for clang.
2017-11-22Convert DTrace probe interface to C++ (and perform some cleanups)Sergio Durigan Junior2-276/+340
This patch converts the DTrace probe interface (gdb/dtrace-probe.[ch]) to C++, and also performs some cleanups that were on my TODO list for a while. The main changes were the conversion of 'struct dtrace_probe' to 'class dtrace_probe', and a new 'class dtrace_static_probe_ops' to replace the use of 'dtrace_probe_ops'. Both classes implement the virtual methods exported by their parents, 'class probe' and 'class static_probe_ops', respectively. I believe it's now a bit simpler to understand the logic behind the dtrace-probe interface. There are several helper functions used to parse parts of a dtrace probe, and since they are generic and don't need to know about the probe they're working on, I decided to leave them as simple static functions (instead of e.g. converting them to class methods). I've also converted a few uses of "VEC" to "std::vector", which makes the code simpler and easier to maintain. And, as usual, some cleanups here and there. Even though I'm sending a series of patches, they need to be tested and committed as a single unit, because of inter-dependencies. But it should be easier to review in separate logical units. I wasn't able to test these modifications because the current test framework for DTrace probes is not working. See <https://sourceware.org/bugzilla/show_bug.cgi?id=22420>. gdb/ChangeLog: 2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com> * dtrace-probe.c (struct probe_ops dtrace_probe_ops): Delete. (struct dtrace_probe_arg) <dtrace_probe_arg>: New constructor. <type_str>: Convert to 'std::string'. <expr>: Convert to 'expression_up'. (dtrace_probe_arg_s): Delete type and VEC. (dtrace_probe_enabler_s): Likewise. (struct dtrace_probe): Replace by... (class dtrace_static_probe_ops): ...this and... (class dtrace_probe): ...this. (dtrace_probe_is_linespec): Rename to... (dtrace_static_probe_ops::is_linespec): ...this. Adjust code to reflect change. (dtrace_process_dof_probe): Use 'std::vector' instead of VEC. Adjust code. Create new instance of 'dtrace_probe'. (dtrace_build_arg_exprs): Rename to... (dtrace_probe::build_arg_exprs): ...this. Adjust code to reflect change. (dtrace_get_probes): Rename to... (dtrace_static_probe_ops::get_probes): ...this. Adjust code to reflect change. (dtrace_get_arg): Rename to... (dtrace_probe::get_arg_by_number): ...this. Adjust code to reflect change. (dtrace_probe_is_enabled): Rename to... (dtrace_probe::is_enabled): ...this. Adjust code to reflect change. (dtrace_get_probe_address): Rename to... (dtrace_probe::get_relocated_address): ...this. Adjust code to reflect change. (dtrace_get_probe_argument_count): Rename to... (dtrace_probe::get_argument_count): ...this. Adjust code to reflect change. (dtrace_can_evaluate_probe_arguments): Rename to... (dtrace_probe::can_evaluate_arguments): ...this. Adjust code to reflect change. (dtrace_evaluate_probe_argument): Rename to... (dtrace_probe::evaluate_argument): ...this. Adjust code to reflect change. (dtrace_compile_to_ax): Rename to... (dtrace_probe::compile_to_ax): ...this. Adjust code to reflect change. (dtrace_probe_destroy): Delete. (dtrace_type_name): Rename to... (dtrace_static_probe_ops::type_name): ...this. Adjust code to reflect change. (dtrace_probe::get_static_ops): New method. (dtrace_gen_info_probes_table_header): Rename to... (dtrace_static_probe_ops::gen_info_probes_table_header): ...this. Adjust code to reflect change. (dtrace_gen_info_probes_table_values): Rename to... (dtrace_probe::gen_info_probes_table_values): ...this. Adjust code to reflect change. (dtrace_enable_probe): Rename to... (dtrace_probe::enable_probe): ...this. Adjust code to reflect change. (dtrace_disable_probe): Rename to... (dtrace_probe::disable_probe): ...this. Adjust code to reflect change. (struct probe_ops dtrace_probe_ops): Delete. (info_probes_dtrace_command): Call 'info_probes_for_spops' instead of 'info_probes_for_ops'. (_initialize_dtrace_probe): Use 'all_static_probe_ops' instead of 'all_probe_ops'.
2017-11-22Convert SystemTap probe interface to C++ (and perform some cleanups)Sergio Durigan Junior2-273/+328
This patch converts the SystemTap probe interface (gdb/stap-probe.[ch]) to C++, and also performs some cleanups that were on my TODO list for a while. The main changes were the conversion of 'struct stap_probe' to 'class stap_probe', and a new 'class stap_static_probe_ops' to replace the use of 'stap_probe_ops'. Both classes implement the virtual methods exported by their parents, 'class probe' and 'class static_probe_ops', respectively. I believe it's now a bit simpler to understand the logic behind the stap-probe interface. There are several helper functions used to parse parts of a stap probe, and since they are generic and don't need to know about the probe they're working on, I decided to leave them as simple static functions (instead of e.g. converting them to class methods). I've also converted a few uses of "VEC" to "std::vector", which makes the code simpler and easier to maintain. And, as usual, some cleanups here and there. Even though I'm sending a series of patches, they need to be tested and committed as a single unit, because of inter-dependencies. But it should be easier to review in separate logical units. I've regtested this patch on BuildBot, no regressions found. gdb/ChangeLog: 2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com> Simon Marchi <simark@simark.ca> * stap-probe.c (struct probe_ops stap_probe_ops): Delete variable. (struct stap_probe_arg) <stap_probe_arg>: New constructor. <aexpr>: Change type to 'expression_up'. (stap_probe_arg_s): Delete type and VEC. (struct stap_probe): Delete. Replace by... (class stap_static_probe_ops): ...this and... (class stap_probe): ...this. Rename variables to add 'm_' prefix. Do not use 'union' for arguments anymore. (stap_get_expected_argument_type): Receive probe name instead of 'struct stap_probe'. Adjust code. (stap_parse_probe_arguments): Rename to... (stap_probe::parse_arguments): ...this. Adjust code to reflect change. (stap_get_probe_address): Rename to... (stap_probe::get_relocated_address): ...this. Adjust code to reflect change. (stap_get_probe_argument_count): Rename to... (stap_probe::get_argument_count): ...this. Adjust code to reflect change. (stap_get_arg): Rename to... (stap_probe::get_arg_by_number'): ...this. Adjust code to reflect change. (can_evaluate_probe_arguments): Rename to... (stap_probe::can_evaluate_arguments): ...this. Adjust code to reflect change. (stap_evaluate_probe_argument): Rename to... (stap_probe::evaluate_argument): ...this. Adjust code to reflect change. (stap_compile_to_ax): Rename to... (stap_probe::compile_to_ax): ...this. Adjust code to reflect change. (stap_probe_destroy): Delete. (stap_modify_semaphore): Adjust comment. (stap_set_semaphore): Rename to... (stap_probe::set_semaphore): ...this. Adjust code to reflect change. (stap_clear_semaphore): Rename to... (stap_probe::clear_semaphore): ...this. Adjust code to reflect change. (stap_probe::get_static_ops): New method. (handle_stap_probe): Adjust code to create instance of 'stap_probe'. (stap_get_probes): Rename to... (stap_static_probe_ops::get_probes): ...this. Adjust code to reflect change. (stap_probe_is_linespec): Rename to... (stap_static_probe_ops::is_linespec): ...this. Adjust code to reflect change. (stap_type_name): Rename to... (stap_static_probe_ops::type_name): ...this. Adjust code to reflect change. (stap_gen_info_probes_table_header): Rename to... (stap_static_probe_ops::gen_info_probes_table_header): ...this. Adjust code to reflect change. (stap_gen_info_probes_table_values): Rename to... (stap_probe::gen_info_probes_table_values): ...this. Adjust code to reflect change. (struct probe_ops stap_probe_ops): Delete. (info_probes_stap_command): Use 'info_probes_for_spops' instead of 'info_probes_for_ops'. (_initialize_stap_probe): Use 'all_static_probe_ops' instead of 'all_probe_ops'.
2017-11-22Convert generic probe interface to C++ (and perform some cleanups)Sergio Durigan Junior12-490/+524
This patch converts the generic probe interface (gdb/probe.[ch]) to C++, and also performs some cleanups that were on my TODO list for a while. The main changes were the conversion of 'struct probe' to 'class probe', and 'struct probe_ops' to 'class static_probe_ops'. The former now contains all the "dynamic", generic methods that act on a probe + the generic data related to it; the latter encapsulates a bunch of "static" methods that relate to the probe type, but not to a specific probe itself. I've had to do a few renamings (e.g., on 'struct bound_probe' the field is called 'probe *prob' now, instead of 'struct probe *probe') because GCC was complaining about naming the field using the same name as the class. Nothing major, though. Generally speaking, the logic behind and the design behind the code are the same. Even though I'm sending a series of patches, they need to be tested and committed as a single unit, because of inter-dependencies. But it should be easier to review in separate logical units. I've regtested this patch on BuildBot, no regressions found. gdb/ChangeLog: 2017-11-22 Sergio Durigan Junior <sergiodj@redhat.com> * break-catch-throw.c (fetch_probe_arguments): Use 'probe.prob' instead of 'probe.probe'. * breakpoint.c (create_longjmp_master_breakpoint): Call 'can_evaluate_arguments' and 'get_relocated_address' methods from probe. (create_exception_master_breakpoint): Likewise. (add_location_to_breakpoint): Use 'sal->prob' instead of 'sal->probe'. (bkpt_probe_insert_location): Call 'set_semaphore' method from probe. (bkpt_probe_remove_location): Likewise, for 'clear_semaphore'. * elfread.c (elf_get_probes): Use 'static_probe_ops' instead of 'probe_ops'. (probe_key_free): Call 'delete' on probe. (check_exception_resume): Use 'probe.prob' instead of 'probe.probe'. * location.c (string_to_event_location_basic): Call 'probe_linespec_to_static_ops'. * probe.c (class any_static_probe_ops): New class. (any_static_probe_ops any_static_probe_ops): New variable. (parse_probes_in_pspace): Receive 'static_probe_ops' as argument. Adjust code to reflect change. (parse_probes): Use 'static_probe_ops' instead of 'probe_ops'. Adjust code to reflect change. (find_probes_in_objfile): Call methods to get name and provider from probe. (find_probe_by_pc): Use 'result.prob' instead of 'result.probe'. Call 'get_relocated_address' method from probe. (collect_probes): Adjust comment and argument list to receive 'static_probe_ops' instead of 'probe_ops'. Adjust code to reflect change. Call necessary methods from probe. (compare_probes): Call methods to get name and provider from probes. (gen_ui_out_table_header_info): Receive 'static_probe_ops' instead of 'probe_ops'. Use 'std::vector' instead of VEC, adjust code accordingly. (print_ui_out_not_applicables): Likewise. (info_probes_for_ops): Rename to... (info_probes_for_spops): ...this. Receive 'static_probe_ops' as argument instead of 'probe_ops'. Adjust code. Call necessary methods from probe. (info_probes_command): Use 'info_probes_for_spops'. (enable_probes_command): Pass correct argument to 'collect_probes'. Call methods from probe. (disable_probes_command): Likewise. (get_probe_address): Move to 'any_static_probe_ops::get_address'. (get_probe_argument_count): Move to 'any_static_probe_ops::get_argument_count'. (can_evaluate_probe_arguments): Move to 'any_static_probe_ops::can_evaluate_arguments'. (evaluate_probe_argument): Move to 'any_static_probe_ops::evaluate_argument'. (probe_safe_evaluate_at_pc): Use 'probe.prob' instead of 'probe.probe'. (probe_linespec_to_ops): Rename to... (probe_linespec_to_static_ops): ...this. Adjust code. (probe_any_is_linespec): Rename to... (any_static_probe_ops::is_linespec): ...this. (probe_any_get_probes): Rename to... (any_static_probe_ops::get_probes): ...this. (any_static_probe_ops::type_name): New method. (any_static_probe_ops::gen_info_probes_table_header): New method. (compute_probe_arg): Use 'pc_probe.prob' instead of 'pc_probe.probe'. Call methods from probe. (compile_probe_arg): Likewise. (std::vector<const probe_ops *> all_probe_ops): Delete. (std::vector<const static_probe_ops *> all_static_probe_ops): New variable. (_initialize_probe): Use 'all_static_probe_ops' instead of 'all_probe_ops'. * probe.h (struct info_probe_column) <field_name>: Delete extraneous newline (info_probe_column_s): Delete type and VEC. (struct probe_ops): Delete. Replace with... (class static_probe_ops): ...this and... (clas probe): ...this. (struct bound_probe) <bound_probe>: Delete extraneous newline. Adjust constructor to receive 'probe' instead of 'struct probe'. <probe>: Rename to... <prob>: ...this. Delete extraneous newline. <objfile>: Delete extraneous newline. (register_probe_ops): Delete unused prototype. (info_probes_for_ops): Rename to... (info_probes_for_spops): ...this. Adjust comment. (get_probe_address): Move to 'probe::get_address'. (get_probe_argument_count): Move to 'probe::get_argument_count'. (can_evaluate_probe_arguments): Move to 'probe::can_evaluate_arguments'. (evaluate_probe_argument): Move to 'probe::evaluate_argument'. * solib-svr4.c (struct svr4_info): Adjust comment. (struct probe_and_action) <probe>: Rename to... <prob>: ...this. (register_solib_event_probe): Receive 'probe' instead of 'struct probe' as argument. Use 'prob' instead of 'probe' when applicable. (solib_event_probe_action): Call 'get_argument_count' method from probe. Adjust comment. (svr4_handle_solib_event): Adjust comment. Call 'evaluate_argument' method from probe. (svr4_create_probe_breakpoints): Call 'get_relocated_address' from probe. (svr4_create_solib_event_breakpoints): Use 'probe' instead of 'struct probe'. Call 'can_evaluate_arguments' from probe. * symfile.h: Forward declare 'class probe' instead of 'struct probe'. * symtab.h: Likewise. (struct symtab_and_line) <probe>: Rename to... <prob>: ...this. * tracepoint.c (start_tracing): Use 'prob' when applicable. Call probe methods. (stop_tracing): Likewise.
2017-11-22(Ada) ravenscar-thread.c: remove unwanted trailing \n in call to warningJoel Brobecker2-1/+6
A recent patch introduced a call to warning, and the string used had a trailing newline, which is not correct; the nightly ARI run caught it, so this patch removes it. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_inferior_created): Remove trailing newline at end of string in call to warning. Tested on powerpc-eabispe, no regression.
2017-11-22C++ify osdataSimon Marchi4-263/+138
This patch c++ifies the osdata structure: osdata_column, osdata_item and osdata. char* are replaced with std::string and VEC are replaced with std::vector. This allows to get rid of a great deal of cleanup and free'ing code. I replaced the splay tree in list_available_thread_groups with an std::map. Unless there's a good advantage to keep using a splay tree, I think using the standard type should make things simpler to understand. gdb/ChangeLog: * osdata.h: Include vector isntead of vec.h. (osdata_column_s): Remove typedef. (struct osdata_column): Add constructor. <name, value>: Change type to std::string. (DEF_VEC_O (osdata_column_s)): Remove. (osdata_item_s): Remove typedef. (struct osdata_item) <columns>: Change type to std::vector. (DEF_VEC_O (osdata_item_s)): Remove. (struct osdata): Add constructor. <type>: Change type to std::string. <items>: Change type to std::vector. (osdata_p): Remove typedef. (DEF_VEC_P (osdata_p)): Remove. (osdata_parse): Return a unique_ptr. (osdata_free): Remove. (make_cleanup_osdata_free): Remove. (get_osdata): Return a unique_ptr. (get_osdata_column): Return pointer to std::string, take a reference to osdata_item as parameter. * osdata.c (struct osdata_parsing_data) <osdata>: Change type to unique_ptr. <property_name>: Change type to std::string. (osdata_start_osdata): Allocate osdata with new and adjust. (osdata_start_item): Adjust. (osdata_start_column): Adjust. (osdata_end_column): Adjust. (clear_parsing_data): Remove. (osdata_parse): Return a unique_ptr and adjust, remove cleanup. (osdata_item_clear): Remove. (get_osdata): return a unique_ptr and adjust. (get_osdata_column): Return a pointer to std::string and adjust. (info_osdata): Adjust. * mi/mi-main.c: Include <map>. (free_vector_of_osdata_items): Remove. (list_available_thread_groups): Adjust, use std::map instead of splay tree.
2017-11-22Show optimized out local variables in "info locals"Simon Marchi6-0/+111
Currently, optimized out variables are not shown when doing "info locals". Some users found that confusing, thinking GDB forgot to print their variable. This patch adds them to the "info locals" output. I added a test in gdb.dwarf2 to test for that behavior. I think doing a synthetic DWARF test is the easiest way to have an optimized out local variable for sure. However, this change reveals what I think is a bug in GDB, see: http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/2017-September/004394.html This patch marks the tests in inline-locals.exp that start failing as KFAIL. I'd like to tackle this bug eventually, but I don't have the time right now. I think it's still better to show an extra erroneous entry than to not show the optimized out variables at all. I haven't created a bug in bugzilla yet, but if we agree it's indeed a bug, I'll create one and update the setup_kfail lines with the actual bug number before pushing. gdb/ChangeLog: * stack.c (iterate_over_block_locals): Add LOC_OPTIMIZED_OUT case in switch. gdb/testsuite/ChangeLog: * gdb.opt/inline-locals.exp: Mark tests as KFAIL. * gdb.dwarf2/info-locals-optimized-out.exp: New file. * gdb.dwarf2/info-locals-optimized-out.c: New file.