From patchwork Thu Jun 29 23:32:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 21343 Received: (qmail 13551 invoked by alias); 29 Jun 2017 23:33:21 -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 13429 invoked by uid 89); 29 Jun 2017 23:33:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=WHICH X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Jun 2017 23:33:16 +0000 Received: from ralph.baldwin.cx.com (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 8E81510AF08; Thu, 29 Jun 2017 19:33:14 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org, binutils@sourceware.org Subject: [PATCH 3/8] Move the thread_section_name class to gdbcore.h. Date: Thu, 29 Jun 2017 16:32:21 -0700 Message-Id: <20170629233226.20155-4-jhb@FreeBSD.org> In-Reply-To: <20170629233226.20155-1-jhb@FreeBSD.org> References: <20170629233226.20155-1-jhb@FreeBSD.org> X-IsSubscribed: yes This allows it to be used outside of corelow.c. --- gdb/ChangeLog | 5 +++++ gdb/corelow.c | 45 --------------------------------------------- gdb/gdbcore.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 45 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1e624d3667..bdedb63435 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2017-06-28 John Baldwin + * corelow.c (thread_section_name): Move to ... + * gdbcore.h (thread_section_name): ... here. + +2017-06-28 John Baldwin + * fbsd-nat.c [PT_LWPINFO && __LP64__] (union sigval32) (struct siginfo32): New. [PT_LWPINFO] (fbsd_siginfo_size, fbsd_convert_siginfo): New. diff --git a/gdb/corelow.c b/gdb/corelow.c index 0aff02d4db..578c910bb5 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -485,51 +485,6 @@ core_detach (struct target_ops *ops, const char *args, int from_tty) printf_filtered (_("No core file now.\n")); } -/* Build either a single-thread or multi-threaded section name for - PTID. - - If ptid's lwp member is zero, we want to do the single-threaded - thing: look for a section named NAME (as passed to the - constructor). If ptid's lwp member is non-zero, we'll want do the - multi-threaded thing: look for a section named "NAME/LWP", where - LWP is the shortest ASCII decimal representation of ptid's lwp - member. */ - -class thread_section_name -{ -public: - /* NAME is the single-threaded section name. If PTID represents an - LWP, then the build section name is "NAME/LWP", otherwise it's - just "NAME" unmodified. */ - thread_section_name (const char *name, ptid_t ptid) - { - if (ptid.lwp_p ()) - { - m_storage = string_printf ("%s/%ld", name, ptid.lwp ()); - m_section_name = m_storage.c_str (); - } - else - m_section_name = name; - } - - /* Return the computed section name. The result is valid as long as - this thread_section_name object is live. */ - const char *c_str () const - { return m_section_name; } - - /* Disable copy. */ - thread_section_name (const thread_section_name &) = delete; - void operator= (const thread_section_name &) = delete; - -private: - /* Either a pointer into M_STORAGE, or a pointer to the name passed - as parameter to the constructor. */ - const char *m_section_name; - /* If we need to build a new section name, this is where we store - it. */ - std::string m_storage; -}; - /* Try to retrieve registers from a section in core_bfd, and supply them to core_vec->core_read_registers, as the register set numbered WHICH. diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h index e3eed0395d..87f3dcd64d 100644 --- a/gdb/gdbcore.h +++ b/gdb/gdbcore.h @@ -226,6 +226,51 @@ struct core_fns }; +/* Build either a single-thread or multi-threaded section name for + PTID. + + If ptid's lwp member is zero, we want to do the single-threaded + thing: look for a section named NAME (as passed to the + constructor). If ptid's lwp member is non-zero, we'll want do the + multi-threaded thing: look for a section named "NAME/LWP", where + LWP is the shortest ASCII decimal representation of ptid's lwp + member. */ + +class thread_section_name +{ +public: + /* NAME is the single-threaded section name. If PTID represents an + LWP, then the build section name is "NAME/LWP", otherwise it's + just "NAME" unmodified. */ + thread_section_name (const char *name, ptid_t ptid) + { + if (ptid.lwp_p ()) + { + m_storage = string_printf ("%s/%ld", name, ptid.lwp ()); + m_section_name = m_storage.c_str (); + } + else + m_section_name = name; + } + + /* Return the computed section name. The result is valid as long as + this thread_section_name object is live. */ + const char *c_str () const + { return m_section_name; } + + /* Disable copy. */ + thread_section_name (const thread_section_name &) = delete; + void operator= (const thread_section_name &) = delete; + +private: + /* Either a pointer into M_STORAGE, or a pointer to the name passed + as parameter to the constructor. */ + const char *m_section_name; + /* If we need to build a new section name, this is where we store + it. */ + std::string m_storage; +}; + /* NOTE: cagney/2004-04-05: Replaced by "regset.h" and regset_from_core_section(). */ extern void deprecated_add_core_fns (struct core_fns *cf);