From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129077 invoked by alias); 29 Nov 2018 23:16:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 128888 invoked by uid 89); 29 Nov 2018 23:15:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=827 X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.47.80) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Nov 2018 23:15:50 +0000 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 12A492C26F for ; Thu, 29 Nov 2018 17:15:46 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id SVX8gkZC0RPojSVX8gsrcX; Thu, 29 Nov 2018 17:15:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DhYY3M+iFmzbyHWdyHEEzINS8lYWsvEUuBGiQ4IkwgQ=; b=SDnwsHSnvBPKiwqboSVxu0EhHS caqXQs517NuaR8VrPnxzFi5/AMyRd/YxKlWcKMoqU1QHev1lrlfyK7E+Kw/eAc0MyuRSEp3BZvtLl JGt8ucQyGqs/jmNpeomZGDz8w; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:56318 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gSVX7-00226Z-Mx; Thu, 29 Nov 2018 17:15:45 -0600 From: Tom Tromey To: Tom Tromey Cc: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [PATCH 2/3] Introduce process_stratum_target References: <20181127202247.7646-1-palves@redhat.com> <20181127202247.7646-3-palves@redhat.com> <87bm67bv0h.fsf@tromey.com> Date: Thu, 29 Nov 2018 23:16:00 -0000 In-Reply-To: <87bm67bv0h.fsf@tromey.com> (Tom Tromey's message of "Thu, 29 Nov 2018 11:26:06 -0700") Message-ID: <8736rj8ogv.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-11/txt/msg00559.txt.bz2 Tom> What if I added a protected constructor to target_ops that took the Tom> stratum as an argument? Would there be a problem with that? Like this. If it's reasonable I'll rebase it on top of yours after it goes in. Tom commit 207fb6d5368f6406c536e8dee356ee1564e4d494 Author: Tom Tromey Date: Thu Nov 29 16:04:37 2018 -0700 Add target_ops constructor This adds a protected target_ops constructor that sets the to_stratum member, and updates subclasses to invoke it. gdb/ChangeLog 2018-11-29 Tom Tromey * spu-multiarch.c (spu_multiarch_target::spu_multiarch_target): Update. * ravenscar-thread.c (ravenscar_thread_target::ravenscar_thread_target): Update. * bsd-uthread.c (bsd_uthread_target::bsd_uthread_target): Update. * sol-thread.c (sol_thread_target::sol_thread_target): Update. * aix-thread.c (aix_thread_target::aix_thread_target): Update. * bsd-kvm.c (bsd_kvm_target::bsd_kvm_target): Update. * tracefile.c (tracefile_target::tracefile_target): Update. * target.h (struct target_ops) : New constructor. (struct memory_breakpoint_target) : Likewise. (test_target_ops::test_target_ops): Update. * target.c (dummy_target::dummy_target): Update. (debug_target::debug_target): Update. * remote.c (remote_target::remote_target): Update. * remote-sim.c (gdbsim_target::gdbsim_target): Update. * record-full.c (record_full_base_target::record_full_base_target): Update. * record-btrace.c (record_btrace_target::record_btrace_target): Update. * linux-thread-db.c (thread_db_target::thread_db_target): Update. * inf-child.c (inf_child_target::inf_child_target): Update. * exec.c (exec_target::exec_target): Update. * corelow.c (core_target::core_target): Update. * bfd-target.c (target_bfd::target_bfd): Update. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 70d4c06742..d1cd119484 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,32 @@ +2018-11-29 Tom Tromey + + * spu-multiarch.c (spu_multiarch_target::spu_multiarch_target): + Update. + * ravenscar-thread.c + (ravenscar_thread_target::ravenscar_thread_target): Update. + * bsd-uthread.c (bsd_uthread_target::bsd_uthread_target): Update. + * sol-thread.c (sol_thread_target::sol_thread_target): Update. + * aix-thread.c (aix_thread_target::aix_thread_target): Update. + * bsd-kvm.c (bsd_kvm_target::bsd_kvm_target): Update. + * tracefile.c (tracefile_target::tracefile_target): Update. + * target.h (struct target_ops) : New constructor. + (struct memory_breakpoint_target) : + Likewise. + (test_target_ops::test_target_ops): Update. + * target.c (dummy_target::dummy_target): Update. + (debug_target::debug_target): Update. + * remote.c (remote_target::remote_target): Update. + * remote-sim.c (gdbsim_target::gdbsim_target): Update. + * record-full.c + (record_full_base_target::record_full_base_target): Update. + * record-btrace.c (record_btrace_target::record_btrace_target): + Update. + * linux-thread-db.c (thread_db_target::thread_db_target): Update. + * inf-child.c (inf_child_target::inf_child_target): Update. + * exec.c (exec_target::exec_target): Update. + * corelow.c (core_target::core_target): Update. + * bfd-target.c (target_bfd::target_bfd): Update. + 2018-11-29 Tom Tromey * valarith.c (value_x_unop): Don't set argvec[3]. diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 97592e5b1f..a5460dc61f 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -118,7 +118,8 @@ class aix_thread_target final : public target_ops { public: aix_thread_target () - { to_stratum = thread_stratum; } + : target_ops (thread_stratum) + { } const target_info &info () const override { return aix_thread_target_info; } diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c index 6138d450d9..837f0f32f3 100644 --- a/gdb/bfd-target.c +++ b/gdb/bfd-target.c @@ -90,9 +90,9 @@ target_bfd::get_section_table () } target_bfd::target_bfd (struct bfd *abfd) - : m_bfd (gdb_bfd_ref_ptr::new_reference (abfd)) + : target_ops (file_stratum), + m_bfd (gdb_bfd_ref_ptr::new_reference (abfd)) { - this->to_stratum = file_stratum; m_table.sections = NULL; m_table.sections_end = NULL; build_section_table (abfd, &m_table.sections, &m_table.sections_end); diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c index af8305f386..342645e3ad 100644 --- a/gdb/bsd-kvm.c +++ b/gdb/bsd-kvm.c @@ -75,7 +75,8 @@ class bsd_kvm_target final : public target_ops { public: bsd_kvm_target () - { this->to_stratum = process_stratum; } + : target_ops (process_stratum) + { } const target_info &info () const override { return bsd_kvm_target_info; } diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 3229a18055..7e456ad101 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -42,7 +42,8 @@ static const target_info bsd_uthread_target_info = { struct bsd_uthread_target final : public target_ops { bsd_uthread_target () - { to_stratum = thread_stratum; } + : target_ops (thread_stratum) + { } const target_info &info () const override { return bsd_uthread_target_info; } diff --git a/gdb/corelow.c b/gdb/corelow.c index 72f2807640..69e9d6e922 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -131,9 +131,8 @@ private: /* per-core data */ }; core_target::core_target () + : target_ops (process_stratum) { - to_stratum = process_stratum; - m_core_gdbarch = gdbarch_from_bfd (core_bfd); /* Find a suitable core file handler to munch on core_bfd */ diff --git a/gdb/exec.c b/gdb/exec.c index 615fb2b5db..f95a0fbda4 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -61,7 +61,8 @@ Specify the filename of the executable file.") struct exec_target final : public target_ops { exec_target () - { to_stratum = file_stratum; } + : target_ops (file_stratum) + { } const target_info &info () const override { return exec_target_info; } diff --git a/gdb/inf-child.c b/gdb/inf-child.c index 44aa2f66fb..ab02f97f68 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -441,7 +441,6 @@ inf_child_target::can_use_agent () inf_child_target::inf_child_target () { - this->to_stratum = process_stratum; } /* See inf-child.h. */ diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 74acec2629..433cb5800c 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -108,8 +108,8 @@ public: }; thread_db_target::thread_db_target () + : target_ops (thread_stratum) { - this->to_stratum = thread_stratum; } static char *libthread_db_search_path; diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c index e60fad8746..6bbb4d13a2 100644 --- a/gdb/ravenscar-thread.c +++ b/gdb/ravenscar-thread.c @@ -82,7 +82,8 @@ static const target_info ravenscar_target_info = { struct ravenscar_thread_target final : public target_ops { ravenscar_thread_target () - { to_stratum = thread_stratum; } + : target_ops (thread_stratum) + { } const target_info &info () const override { return ravenscar_target_info; } diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 814f080941..d33de7ee15 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -54,7 +54,8 @@ class record_btrace_target final : public target_ops { public: record_btrace_target () - { to_stratum = record_stratum; } + : target_ops (record_stratum) + { } const target_info &info () const override { return record_btrace_target_info; } diff --git a/gdb/record-full.c b/gdb/record-full.c index dbaa8c3d40..ce799308a0 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -219,7 +219,8 @@ class record_full_base_target : public target_ops { public: record_full_base_target () - { to_stratum = record_stratum; } + : target_ops (record_stratum) + { } const target_info &info () const override = 0; diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 63e41458d7..186503f34f 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -85,7 +85,7 @@ struct gdbsim_target final : public memory_breakpoint_target { gdbsim_target () - { to_stratum = process_stratum; } + { } const target_info &info () const override { return gdbsim_target_info; } diff --git a/gdb/remote.c b/gdb/remote.c index 90b5dabc8a..d389468919 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -408,8 +408,8 @@ class remote_target : public target_ops { public: remote_target () + : target_ops (process_stratum) { - to_stratum = process_stratum; } ~remote_target () override; diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index c6a5aca501..212a8fcbca 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -79,7 +79,8 @@ class sol_thread_target final : public target_ops { public: sol_thread_target () - { this->to_stratum = thread_stratum; } + : target_ops (thread_stratum) + { } const target_info &info () const override { return thread_db_target_info; } diff --git a/gdb/spu-multiarch.c b/gdb/spu-multiarch.c index 7e642d663a..30c4586c5b 100644 --- a/gdb/spu-multiarch.c +++ b/gdb/spu-multiarch.c @@ -45,7 +45,8 @@ static const target_info spu_multiarch_target_info = { struct spu_multiarch_target final : public target_ops { spu_multiarch_target () - { to_stratum = arch_stratum; }; + : spu_multiarch_target (arch_stratum) + { } const target_info &info () const override { return spu_multiarch_target_info; } diff --git a/gdb/target.c b/gdb/target.c index 29ce5eb414..3d82e7ce8b 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3330,13 +3330,13 @@ static const target_info dummy_target_info = { }; dummy_target::dummy_target () + : target_ops (dummy_stratum) { - to_stratum = dummy_stratum; } debug_target::debug_target () + : target_ops (debug_stratum) { - to_stratum = debug_stratum; } const target_info & diff --git a/gdb/target.h b/gdb/target.h index 4731e3bf79..a0a5da25b6 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -431,6 +431,15 @@ struct target_info struct target_ops { + protected: + + explicit target_ops (enum strata stratum) + : to_stratum (stratum) + { + } + + public: + /* To the target under this one. */ target_ops *beneath () const; @@ -2419,6 +2428,15 @@ extern int memory_insert_breakpoint (struct target_ops *, template struct memory_breakpoint_target : public BaseTarget { +protected: + + memory_breakpoint_target () + : BaseTarget (process_stratum) + { + } + +public: + int insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt) override { return memory_insert_breakpoint (this, gdbarch, bp_tgt); } @@ -2584,9 +2602,8 @@ class test_target_ops : public target_ops { public: test_target_ops () - : target_ops {} + : target_ops (process_stratum) { - to_stratum = process_stratum; } const target_info &info () const override; diff --git a/gdb/tracefile.c b/gdb/tracefile.c index b367f6e403..5db8426e33 100644 --- a/gdb/tracefile.c +++ b/gdb/tracefile.c @@ -471,8 +471,8 @@ tracefile_target::get_trace_status (struct trace_status *ts) } tracefile_target::tracefile_target () + : target_ops (process_stratum) { - this->to_stratum = process_stratum; } void