From patchwork Mon Apr 16 15:14:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 26756 Received: (qmail 104192 invoked by alias); 16 Apr 2018 15:15:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 104010 invoked by uid 89); 16 Apr 2018 15:15:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=areas, 2357, DATA, Request X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Apr 2018 15:14:52 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B1AC54023156 for ; Mon, 16 Apr 2018 15:14:50 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB5597C41 for ; Mon, 16 Apr 2018 15:14:49 +0000 (UTC) Subject: [RESEND][PATCH 01/40] Convert struct target_ops to C++ To: gdb-patches@sourceware.org References: <20180414190953.24481-1-palves@redhat.com> From: Pedro Alves Message-ID: Date: Mon, 16 Apr 2018 16:14:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180414190953.24481-1-palves@redhat.com> I'm not sure why, but PATCH 01/40 never made it to the list. Maybe because it's too large (the patch file is 477K). Here's the same patch, but without the (generated) target-delegates.c hunk. You can still see the generated code in the branch, here, of course: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blobdiff;f=gdb/target-delegates.c;h=3aea00ea9d92c61ea009b3641cc7d2a64082fe9b;hp=6ff3e06cc83e00b737922e3fb16fd271aceb2183;hb=8c60ef81bb3076d86a10e5fdf2ab60dac64ec0fd;hpb=f1dd326b642d1aa7d7497264642bce06aab7135c From 8c60ef81bb3076d86a10e5fdf2ab60dac64ec0fd Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 6 Apr 2018 23:51:22 +0100 Subject: [PATCH 01/40] Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. Since the patch would be too big to review and manage as a single unit, I split it in many chunks. This patch contains the core changes. The following patches that have "target_ops/C++:" in their subject line each converts some target or targets over. For pushing, all the "target_ops/C++:" patches must be squashed into this patch and pushed together, to avoid breaking the build (as much as possible). I also haven't written ChangeLog entries for this part of the series yet, because it's going to be very mechanical, and I'd rather send this out sooner than later, in order to hopefuly get some help with testing on native ports that I don't have access to. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced to references to target_stack (the top of the stack) directly. - To keep "set debug target" working, This adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overriden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. This is fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch (actually patches until it's all squashed before pushing) replaces instances of such a pattern with template mixins. A case seen in this patch in isolation is memory_breakpoint_target defined in target.h. --- gdb/auxv.c | 13 +- gdb/auxv.h | 3 +- gdb/avr-tdep.c | 4 +- gdb/breakpoint.c | 7 +- gdb/elfread.c | 10 +- gdb/eval.c | 2 +- gdb/exceptions.c | 6 +- gdb/frame.c | 2 +- gdb/gdbarch-selftests.c | 4 +- gdb/gnu-v3-abi.c | 2 +- gdb/ia64-tdep.c | 2 +- gdb/ia64-vms-tdep.c | 2 +- gdb/infcall.c | 4 +- gdb/infcmd.c | 36 +- gdb/infrun.c | 12 +- gdb/linux-tdep.c | 18 +- gdb/make-target-delegates | 205 +- gdb/mi/mi-main.c | 13 +- gdb/minsyms.c | 4 +- gdb/parse.c | 2 +- gdb/ppc-linux-nat.c | 2 +- gdb/ppc-linux-tdep.c | 10 +- gdb/procfs.c | 2 +- gdb/regcache.c | 64 +- gdb/remote.c | 12 +- gdb/rs6000-tdep.c | 2 +- gdb/s390-linux-nat.c | 2 +- gdb/s390-tdep.c | 2 +- gdb/solib-aix.c | 2 +- gdb/solib-darwin.c | 2 +- gdb/solib-dsbt.c | 4 +- gdb/solib-spu.c | 6 +- gdb/solib-svr4.c | 18 +- gdb/solib-target.c | 2 +- gdb/sparc-tdep.c | 2 +- gdb/sparc64-tdep.c | 4 +- gdb/spu-tdep.c | 30 +- gdb/symfile.c | 2 +- gdb/target-debug.h | 6 + gdb/target-delegates.c | 5036 +++++++++----------- gdb/target-descriptions.c | 4 +- gdb/target-memory.c | 4 +- gdb/target.c | 846 ++-- gdb/target.h | 830 ++-- gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp | 4 +- gdb/testsuite/gdb.base/sss-bp-on-user-bp-2.exp | 4 +- gdb/tracepoint.c | 2 +- gdb/valops.c | 4 +- gdb/valprint.c | 2 +- gdb/value.c | 2 +- gdb/windows-tdep.c | 2 +- 51 files changed, 3389 insertions(+), 3876 deletions(-) diff --git a/gdb/auxv.c b/gdb/auxv.c index ce7a63b894..86a1ba88a6 100644 --- a/gdb/auxv.c +++ b/gdb/auxv.c @@ -283,16 +283,15 @@ default_auxv_parse (struct target_ops *ops, gdb_byte **readptr, Return -1 if there is insufficient buffer for a whole entry. Return 1 if an entry was read into *TYPEP and *VALP. */ int -target_auxv_parse (struct target_ops *ops, gdb_byte **readptr, - gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) +target_auxv_parse (gdb_byte **readptr, + gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) { struct gdbarch *gdbarch = target_gdbarch(); if (gdbarch_auxv_parse_p (gdbarch)) return gdbarch_auxv_parse (gdbarch, readptr, endptr, typep, valp); - return current_target.to_auxv_parse (¤t_target, readptr, endptr, - typep, valp); + return target_stack->auxv_parse (readptr, endptr, typep, valp); } @@ -382,7 +381,7 @@ target_auxv_search (struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp) size_t len = info->data->size (); while (1) - switch (target_auxv_parse (ops, &ptr, data + len, &type, &val)) + switch (target_auxv_parse (&ptr, data + len, &type, &val)) { case 1: /* Here's an entry, check it. */ if (type == match) @@ -532,7 +531,7 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops) gdb_byte *ptr = data; size_t len = info->data->size (); - while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0) + while (target_auxv_parse (&ptr, data + len, &type, &val) > 0) { gdbarch_print_auxv_entry (gdbarch, file, type, val); ++ents; @@ -550,7 +549,7 @@ info_auxv_command (const char *cmd, int from_tty) error (_("The program has no auxiliary information now.")); else { - int ents = fprint_target_auxv (gdb_stdout, ¤t_target); + int ents = fprint_target_auxv (gdb_stdout, target_stack); if (ents < 0) error (_("No auxiliary vector found, or failed reading it.")); diff --git a/gdb/auxv.h b/gdb/auxv.h index 4a1a95e692..29c75fbfe8 100644 --- a/gdb/auxv.h +++ b/gdb/auxv.h @@ -35,8 +35,7 @@ extern int default_auxv_parse (struct target_ops *ops, gdb_byte **readptr, Return 0 if *READPTR is already at the end of the buffer. Return -1 if there is insufficient buffer for a whole entry. Return 1 if an entry was read into *TYPEP and *VALP. */ -extern int target_auxv_parse (struct target_ops *ops, - gdb_byte **readptr, gdb_byte *endptr, +extern int target_auxv_parse (gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp); /* Extract the auxiliary vector entry with a_type matching MATCH. diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 2b9be5e313..5aa61ba2d9 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1555,7 +1555,7 @@ avr_io_reg_read_command (const char *args, int from_tty) /* Find out how many io registers the target has. */ gdb::optional buf - = target_read_alloc (¤t_target, TARGET_OBJECT_AVR, "avr.io_reg"); + = target_read_alloc (target_stack, TARGET_OBJECT_AVR, "avr.io_reg"); if (!buf) { @@ -1589,7 +1589,7 @@ avr_io_reg_read_command (const char *args, int from_tty) j = nreg - i; /* last block is less than 8 registers */ snprintf (query, sizeof (query) - 1, "avr.io_reg:%x,%x", i, j); - buf = target_read_alloc (¤t_target, TARGET_OBJECT_AVR, query); + buf = target_read_alloc (target_stack, TARGET_OBJECT_AVR, query); if (!buf) { diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 11b89bcf88..a5287128d0 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3493,8 +3493,7 @@ create_exception_master_breakpoint (void) } addr = BMSYMBOL_VALUE_ADDRESS (bp_objfile_data->exception_msym); - addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, - ¤t_target); + addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, target_stack); b = create_internal_breakpoint (gdbarch, addr, bp_exception_master, &internal_breakpoint_ops); initialize_explicit_location (&explicit_loc); @@ -4753,7 +4752,7 @@ watchpoints_triggered (struct target_waitstatus *ws) return 0; } - if (!target_stopped_data_address (¤t_target, &addr)) + if (!target_stopped_data_address (target_stack, &addr)) { /* We were stopped by a watchpoint, but we don't know where. Mark all watchpoints as unknown. */ @@ -4793,7 +4792,7 @@ watchpoints_triggered (struct target_waitstatus *ws) } } /* Exact match not required. Within range is sufficient. */ - else if (target_watchpoint_addr_within_range (¤t_target, + else if (target_watchpoint_addr_within_range (target_stack, addr, loc->address, loc->length)) { diff --git a/gdb/elfread.c b/gdb/elfread.c index 260789062d..48404e111c 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -806,8 +806,7 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p) if (target_read_memory (pointer_address, buf, ptr_size) != 0) continue; addr = extract_typed_address (buf, ptr_type); - addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, - ¤t_target); + addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, target_stack); addr = gdbarch_addr_bits_remove (gdbarch, addr); if (addr_p) @@ -872,13 +871,12 @@ elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc) parameter. FUNCTION is the function entry address. ADDRESS may be a function descriptor. */ - target_auxv_search (¤t_target, AT_HWCAP, &hwcap); + target_auxv_search (target_stack, AT_HWCAP, &hwcap); hwcap_val = value_from_longest (builtin_type (gdbarch) ->builtin_unsigned_long, hwcap); address_val = call_function_by_hand (function, NULL, 1, &hwcap_val); address = value_as_address (address_val); - address = gdbarch_convert_from_func_ptr_addr (gdbarch, address, - ¤t_target); + address = gdbarch_convert_from_func_ptr_addr (gdbarch, address, target_stack); address = gdbarch_addr_bits_remove (gdbarch, address); if (name_at_pc) @@ -985,7 +983,7 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b) resolved_address = value_as_address (value); resolved_pc = gdbarch_convert_from_func_ptr_addr (gdbarch, resolved_address, - ¤t_target); + target_stack); resolved_pc = gdbarch_addr_bits_remove (gdbarch, resolved_pc); gdb_assert (current_program_space == b->pspace || b->pspace == NULL); diff --git a/gdb/eval.c b/gdb/eval.c index b6fbfcf6c9..26dc58d761 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1742,7 +1742,7 @@ evaluate_subexp_standard (struct type *expect_type, /* The address might point to a function descriptor; resolve it to the actual code address instead. */ addr = gdbarch_convert_from_func_ptr_addr (exp->gdbarch, addr, - ¤t_target); + target_stack); /* Is it a high_level symbol? */ sym = find_pc_function (addr); diff --git a/gdb/exceptions.c b/gdb/exceptions.c index 49af8a2985..5abbaf2137 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -39,7 +39,11 @@ print_flush (void) deprecated_error_begin_hook (); gdb::optional term_state; - if (target_supports_terminal_ours ()) + /* While normally there's always something pushed on the target + stack, the NULL check is needed here because we can get here very + early during startup, before the target stack is first + initialized. */ + if (target_stack != NULL && target_supports_terminal_ours ()) { term_state.emplace (); target_terminal::ours_for_output (); diff --git a/gdb/frame.c b/gdb/frame.c index 90d0ac7b87..07fa2bc77d 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2217,7 +2217,7 @@ inside_main_func (struct frame_info *this_frame) returned. */ maddr = gdbarch_convert_from_func_ptr_addr (get_frame_arch (this_frame), BMSYMBOL_VALUE_ADDRESS (msymbol), - ¤t_target); + target_stack); return maddr == get_frame_func (this_frame); } diff --git a/gdb/gdbarch-selftests.c b/gdb/gdbarch-selftests.c index 1655f13b0e..23afe3d75e 100644 --- a/gdb/gdbarch-selftests.c +++ b/gdb/gdbarch-selftests.c @@ -71,8 +71,8 @@ register_to_value_test (struct gdbarch *gdbarch) /* Error out if debugging something, because we're going to push the test target, which would pop any existing target. */ - if (current_target.to_stratum >= process_stratum) - error (_("target already pushed")); + if (target_stack->to_stratum >= process_stratum) + error (_("target already pushed")); /* Create a mock environment. An inferior with a thread, with a process_stratum target pushed. */ diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 859187f2e9..ddbec13891 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1217,7 +1217,7 @@ gnuv3_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc) of the real function from the function descriptor before passing on the address to other layers of GDB. */ func_addr = gdbarch_convert_from_func_ptr_addr (gdbarch, method_stop_pc, - ¤t_target); + target_stack); if (func_addr != 0) method_stop_pc = func_addr; diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 4f02f05375..26e112e7bc 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -2660,7 +2660,7 @@ getunwind_table (gdb_byte **buf_p) we should find a way to override the corefile layer's xfer_partial method. */ - x = target_read_alloc (¤t_target, TARGET_OBJECT_UNWIND_TABLE, + x = target_read_alloc (target_stack, TARGET_OBJECT_UNWIND_TABLE, NULL, buf_p); return x; diff --git a/gdb/ia64-vms-tdep.c b/gdb/ia64-vms-tdep.c index c9565ce298..9b78576608 100644 --- a/gdb/ia64-vms-tdep.c +++ b/gdb/ia64-vms-tdep.c @@ -42,7 +42,7 @@ ia64_vms_find_proc_info_x (unw_addr_space_t as, unw_word_t ip, CORE_ADDR table_addr; unsigned int info_len; - res = target_read (¤t_target, TARGET_OBJECT_OPENVMS_UIB, + res = target_read (target_stack, TARGET_OBJECT_OPENVMS_UIB, annex + 2, buf, 0, sizeof (buf)); if (res != sizeof (buf)) diff --git a/gdb/infcall.c b/gdb/infcall.c index 9f02674bdf..d5a60eb55c 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -270,7 +270,7 @@ find_function_addr (struct value *function, struct type **retval_type) if (TYPE_CODE (ftype) == TYPE_CODE_FUNC || TYPE_CODE (ftype) == TYPE_CODE_METHOD) funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr, - ¤t_target); + target_stack); } if (TYPE_CODE (ftype) == TYPE_CODE_FUNC || TYPE_CODE (ftype) == TYPE_CODE_METHOD) @@ -306,7 +306,7 @@ find_function_addr (struct value *function, struct type **retval_type) funaddr = value_as_address (value_addr (function)); nfunaddr = funaddr; funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr, - ¤t_target); + target_stack); if (funaddr != nfunaddr) found_descriptor = 1; } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index d43e7f202d..1a84ea817a 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -531,7 +531,7 @@ prepare_execution_command (struct target_ops *target, int background) { /* If we get a request for running in the bg but the target doesn't support it, error out. */ - if (background && !target->to_can_async_p (target)) + if (background && !target->can_async_p ()) error (_("Asynchronous execution not supported on this target.")); if (!background) @@ -600,7 +600,7 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how) prepare_execution_command (run_target, async_exec); - if (non_stop && !run_target->to_supports_non_stop (run_target)) + if (non_stop && !run_target->supports_non_stop ()) error (_("The target does not support running in non-stop mode.")); /* Done. Can now set breakpoints, change inferior args, etc. */ @@ -639,10 +639,10 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how) /* We call get_inferior_args() because we might need to compute the value now. */ - run_target->to_create_inferior (run_target, exec_file, - std::string (get_inferior_args ()), - current_inferior ()->environment.envp (), - from_tty); + run_target->create_inferior (exec_file, + std::string (get_inferior_args ()), + current_inferior ()->environment.envp (), + from_tty); /* to_create_inferior should push the target, so after this point we shouldn't refer to run_target again. */ run_target = NULL; @@ -660,7 +660,7 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how) /* Pass zero for FROM_TTY, because at this point the "run" command has done its thing; now we are setting up the running program. */ - post_create_inferior (¤t_target, 0); + post_create_inferior (target_stack, 0); /* Queue a pending event so that the program stops immediately. */ if (run_how == RUN_STOP_AT_FIRST_INSN) @@ -896,7 +896,7 @@ continue_command (const char *args, int from_tty) ensure_not_running (); } - prepare_execution_command (¤t_target, async_exec); + prepare_execution_command (target_stack, async_exec); if (from_tty) printf_filtered (_("Continuing.\n")); @@ -1043,7 +1043,7 @@ step_1 (int skip_subroutines, int single_inst, const char *count_string) = strip_bg_char (count_string, &async_exec); count_string = stripped.get (); - prepare_execution_command (¤t_target, async_exec); + prepare_execution_command (target_stack, async_exec); count = count_string ? parse_and_eval_long (count_string) : 1; @@ -1232,7 +1232,7 @@ jump_command (const char *arg, int from_tty) gdb::unique_xmalloc_ptr stripped = strip_bg_char (arg, &async_exec); arg = stripped.get (); - prepare_execution_command (¤t_target, async_exec); + prepare_execution_command (target_stack, async_exec); if (!arg) error_no_arg (_("starting address")); @@ -1312,7 +1312,7 @@ signal_command (const char *signum_exp, int from_tty) = strip_bg_char (signum_exp, &async_exec); signum_exp = stripped.get (); - prepare_execution_command (¤t_target, async_exec); + prepare_execution_command (target_stack, async_exec); if (!signum_exp) error_no_arg (_("signal number")); @@ -1585,7 +1585,7 @@ until_command (const char *arg, int from_tty) gdb::unique_xmalloc_ptr stripped = strip_bg_char (arg, &async_exec); arg = stripped.get (); - prepare_execution_command (¤t_target, async_exec); + prepare_execution_command (target_stack, async_exec); if (arg) until_break_command (arg, from_tty, 0); @@ -1610,7 +1610,7 @@ advance_command (const char *arg, int from_tty) gdb::unique_xmalloc_ptr stripped = strip_bg_char (arg, &async_exec); arg = stripped.get (); - prepare_execution_command (¤t_target, async_exec); + prepare_execution_command (target_stack, async_exec); until_break_command (arg, from_tty, 1); } @@ -1990,7 +1990,7 @@ finish_command (const char *arg, int from_tty) gdb::unique_xmalloc_ptr stripped = strip_bg_char (arg, &async_exec); arg = stripped.get (); - prepare_execution_command (¤t_target, async_exec); + prepare_execution_command (target_stack, async_exec); if (arg) error (_("The \"finish\" command does not take any arguments.")); @@ -2675,7 +2675,7 @@ setup_inferior (int from_tty) /* Take any necessary post-attaching actions for this platform. */ target_post_attach (ptid_get_pid (inferior_ptid)); - post_create_inferior (¤t_target, from_tty); + post_create_inferior (target_stack, from_tty); } /* What to do after the first program stops after attaching. */ @@ -2838,10 +2838,10 @@ attach_command (const char *args, int from_tty) prepare_execution_command (attach_target, async_exec); - if (non_stop && !attach_target->to_supports_non_stop (attach_target)) + if (non_stop && !attach_target->supports_non_stop ()) error (_("Cannot attach to this target in non-stop mode")); - attach_target->to_attach (attach_target, args, from_tty); + attach_target->attach (args, from_tty); /* to_attach should push the target, so after this point we shouldn't refer to attach_target again. */ attach_target = NULL; @@ -2892,7 +2892,7 @@ attach_command (const char *args, int from_tty) /* Some system don't generate traps when attaching to inferior. E.g. Mach 3 or GNU hurd. */ - if (!target_attach_no_wait) + if (!target_attach_no_wait ()) { struct attach_command_continuation_args *a; diff --git a/gdb/infrun.c b/gdb/infrun.c index c1db689c1c..c51626d7df 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3236,7 +3236,7 @@ start_remote (int from_tty) /* Now that the inferior has stopped, do any bookkeeping like loading shared libraries. We want to do this before normal_stop, so that the displayed frame is up to date. */ - post_create_inferior (¤t_target, from_tty); + post_create_inferior (target_stack, from_tty); normal_stop (); } @@ -5693,7 +5693,7 @@ handle_signal_stop (struct execution_control_state *ecs) fprintf_unfiltered (gdb_stdlog, "infrun: stopped by watchpoint\n"); - if (target_stopped_data_address (¤t_target, &addr)) + if (target_stopped_data_address (target_stack, &addr)) fprintf_unfiltered (gdb_stdlog, "infrun: stopped data address = %s\n", paddress (gdbarch, addr)); @@ -8727,7 +8727,7 @@ siginfo_value_read (struct value *v) validate_registers_access (); transferred = - target_read (¤t_target, TARGET_OBJECT_SIGNAL_INFO, + target_read (target_stack, TARGET_OBJECT_SIGNAL_INFO, NULL, value_contents_all_raw (v), value_offset (v), @@ -8749,7 +8749,7 @@ siginfo_value_write (struct value *v, struct value *fromval) vice versa. */ validate_registers_access (); - transferred = target_write (¤t_target, + transferred = target_write (target_stack, TARGET_OBJECT_SIGNAL_INFO, NULL, value_contents_all_raw (fromval), @@ -8828,7 +8828,7 @@ save_infcall_suspend_state (void) siginfo_data = (gdb_byte *) xmalloc (len); back_to = make_cleanup (xfree, siginfo_data); - if (target_read (¤t_target, TARGET_OBJECT_SIGNAL_INFO, NULL, + if (target_read (target_stack, TARGET_OBJECT_SIGNAL_INFO, NULL, siginfo_data, 0, len) == len) discard_cleanups (back_to); else @@ -8878,7 +8878,7 @@ restore_infcall_suspend_state (struct infcall_suspend_state *inf_state) struct type *type = gdbarch_get_siginfo_type (gdbarch); /* Errors ignored. */ - target_write (¤t_target, TARGET_OBJECT_SIGNAL_INFO, NULL, + target_write (target_stack, TARGET_OBJECT_SIGNAL_INFO, NULL, inf_state->siginfo_data, 0, TYPE_LENGTH (type)); } diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 552a2a495b..145d05d923 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -402,8 +402,8 @@ linux_is_uclinux (void) { CORE_ADDR dummy; - return (target_auxv_search (¤t_target, AT_NULL, &dummy) > 0 - && target_auxv_search (¤t_target, AT_PAGESZ, &dummy) == 0); + return (target_auxv_search (target_stack, AT_NULL, &dummy) > 0 + && target_auxv_search (target_stack, AT_PAGESZ, &dummy) == 0); } static int @@ -1423,7 +1423,7 @@ linux_spu_make_corefile_notes (bfd *obfd, char *note_data, int *note_size) /* Determine list of SPU ids. */ gdb::optional - spu_ids = target_read_alloc (¤t_target, TARGET_OBJECT_SPU, NULL); + spu_ids = target_read_alloc (target_stack, TARGET_OBJECT_SPU, NULL); if (!spu_ids) return nullptr; @@ -1439,7 +1439,7 @@ linux_spu_make_corefile_notes (bfd *obfd, char *note_data, int *note_size) xsnprintf (annex, sizeof annex, "%d/%s", fd, spu_files[j]); gdb::optional spu_data - = target_read_alloc (¤t_target, TARGET_OBJECT_SPU, annex); + = target_read_alloc (target_stack, TARGET_OBJECT_SPU, annex); if (spu_data && !spu_data->empty ()) { @@ -1661,7 +1661,7 @@ linux_get_siginfo_data (thread_info *thread, struct gdbarch *gdbarch) gdb::byte_vector buf (TYPE_LENGTH (siginfo_type)); - bytes_read = target_read (¤t_target, TARGET_OBJECT_SIGNAL_INFO, NULL, + bytes_read = target_read (target_stack, TARGET_OBJECT_SIGNAL_INFO, NULL, buf.data (), 0, TYPE_LENGTH (siginfo_type)); if (bytes_read != TYPE_LENGTH (siginfo_type)) buf.clear (); @@ -1970,7 +1970,7 @@ linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size) /* Auxillary vector. */ gdb::optional auxv = - target_read_alloc (¤t_target, TARGET_OBJECT_AUXV, NULL); + target_read_alloc (target_stack, TARGET_OBJECT_AUXV, NULL); if (auxv && !auxv->empty ()) { note_data = elfcore_write_note (obfd, note_data, note_size, @@ -2253,7 +2253,7 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range) char filename[100]; long pid; - if (target_auxv_search (¤t_target, AT_SYSINFO_EHDR, &range->start) <= 0) + if (target_auxv_search (target_stack, AT_SYSINFO_EHDR, &range->start) <= 0) return 0; /* It doesn't make sense to access the host's /proc when debugging a @@ -2443,14 +2443,14 @@ linux_displaced_step_location (struct gdbarch *gdbarch) local-store address and is thus not usable as displaced stepping location. The auxiliary vector gets us the PowerPC-side entry point address instead. */ - if (target_auxv_search (¤t_target, AT_ENTRY, &addr) <= 0) + if (target_auxv_search (target_stack, AT_ENTRY, &addr) <= 0) throw_error (NOT_SUPPORTED_ERROR, _("Cannot find AT_ENTRY auxiliary vector entry.")); /* Make certain that the address points at real code, and not a function descriptor. */ addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, - ¤t_target); + target_stack); /* Inferior calls also use the entry point as a breakpoint location. We don't want displaced stepping to interfere with those diff --git a/gdb/make-target-delegates b/gdb/make-target-delegates index bf91ddc17c..10853e3e20 100755 --- a/gdb/make-target-delegates +++ b/gdb/make-target-delegates @@ -30,16 +30,27 @@ $ENDER = qr,^\s*};$,; # Match a C symbol. $SYMBOL = qr,[a-zA-Z_][a-zA-Z0-9_]*,; # Match the name part of a method in struct target_ops. -$NAME_PART = qr,\(\*(?${SYMBOL}+)\)\s,; +$NAME_PART = qr,(?${SYMBOL}+)\s,; # Match the arguments to a method. $ARGS_PART = qr,(?\(.*\)),; # We strip the indentation so here we only need the caret. $INTRO_PART = qr,^,; +$POINTER_PART = qr,\s*(\*)?\s*,; + +# Match a C++ symbol, including scope operators and template +# parameters. E.g., 'std::vector'. +$CP_SYMBOL = qr,[a-zA-Z_][a-zA-Z0-9_<>:]*,; # Match the return type when it is "ordinary". -$SIMPLE_RETURN_PART = qr,[^\(]+,; +$SIMPLE_RETURN_PART = qr,((struct|class|enum|union)\s+)?${CP_SYMBOL}+,; # Match the return type when it is a VEC. -$VEC_RETURN_PART = qr,VEC\s*\([^\)]+\)[^\(]*,; +$VEC_RETURN_PART = qr,VEC\s*\([^\)]+\),; + +# Match a return type. +$RETURN_PART = qr,((const|volatile)\s+)?(${SIMPLE_RETURN_PART}|${VEC_RETURN_PART})${POINTER_PART},; + +# Match "virtual". +$VIRTUAL_PART = qr,virtual\s,; # Match the TARGET_DEFAULT_* attribute for a method. $TARGET_DEFAULT_PART = qr,TARGET_DEFAULT_(?