Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kamil Rytarowski <n54@gmx.com>
To: gdb-patches@sourceware.org, jhb@FreeBSD.org, tom@tromey.com
Subject: [PATCH v2 2/2] gdb: Implement native dumpcore function for NetBSD
Date: Tue, 28 Jul 2020 17:46:02 +0200	[thread overview]
Message-ID: <20200728154602.3824-2-n54@gmx.com> (raw)
In-Reply-To: <20200728154602.3824-1-n54@gmx.com>

Define supports_dumpcore and dumpcore for NetBSD, that wraps
the ptrace(2) call with the PT_DUMPCORE operation.

gdb/ChangeLog:

       * nbsd-nat.h (nbsd_nat_target::supports_native_dumpcore)
       (nbsd_nat_target::native_dumpcore): New declarations.
       * nbsd-nat.c (nbsd_nat_target::supports_native_dumpcore)
       (nbsd_nat_target::native_dumpcore): New functions.
---
 gdb/ChangeLog  |  7 +++++++
 gdb/nbsd-nat.c | 19 +++++++++++++++++++
 gdb/nbsd-nat.h |  2 ++
 3 files changed, 28 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 118bb4f89a2..75b9a0bd13d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2020-07-28  Kamil Rytarowski  <n54@gmx.com>
+
+	* nbsd-nat.h (nbsd_nat_target::supports_native_dumpcore)
+	(nbsd_nat_target::native_dumpcore): New declarations.
+	* nbsd-nat.c (nbsd_nat_target::supports_native_dumpcore)
+	(nbsd_nat_target::native_dumpcore): New functions.
+
 2020-07-28  Kamil Rytarowski  <n54@gmx.com>

 	* target.h (supports_native_dumpcore, native_dumpcore): New
diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c
index a9405ebf862..c893c5498bb 100644
--- a/gdb/nbsd-nat.c
+++ b/gdb/nbsd-nat.c
@@ -845,3 +845,22 @@ nbsd_nat_target::supports_multi_process ()
 {
   return true;
 }
+
+/* Implement the "supports_dumpcore" target_ops method.  */
+
+bool
+nbsd_nat_target::supports_dumpcore ()
+{
+  return true;
+}
+
+/* Implement the "dumpcore" target_ops method.  */
+
+bool
+nbsd_nat_target::dumpcore (const char *filename)
+{
+  pid_t pid = inferior_ptid.pid ();
+
+  return ptrace (PT_DUMPCORE, pid, const_cast<char *>(filename),
+		 strlen (filename)) != -1;
+}
diff --git a/gdb/nbsd-nat.h b/gdb/nbsd-nat.h
index 0a7048ecf35..550ea6a5d8d 100644
--- a/gdb/nbsd-nat.h
+++ b/gdb/nbsd-nat.h
@@ -49,6 +49,8 @@ struct nbsd_nat_target : public inf_ptrace_target
     override;

   bool supports_multi_process () override;
+  bool supports_dumpcore () override;
+  bool dumpcore (const char* filename) override;
 };

 #endif /* nbsd-nat.h */
--
2.26.2



  reply	other threads:[~2020-07-28 15:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 14:43 [PATCH] gdb: Implement native dumpcore function Kamil Rytarowski
2020-07-27 15:47 ` John Baldwin
2020-07-27 21:09 ` Tom Tromey
2020-07-28 15:46 ` [PATCH v2 1/2] " Kamil Rytarowski
2020-07-28 15:46   ` Kamil Rytarowski [this message]
2020-08-05 16:24     ` [PATCH v2 2/2] gdb: Implement native dumpcore function for NetBSD Tom Tromey
2020-08-13 17:16       ` Kamil Rytarowski
2020-07-28 18:56   ` [PATCH v2 1/2] gdb: Implement native dumpcore function Christian Biesinger
2020-07-28 20:39     ` Kamil Rytarowski
2020-07-29 15:45       ` Tom Tromey
2020-08-05 16:23   ` Tom Tromey
2020-08-13 17:15     ` Kamil Rytarowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200728154602.3824-2-n54@gmx.com \
    --to=n54@gmx.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox