From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: bsd-kvm target, always a thread
Date: Fri, 08 Aug 2008 03:20:00 -0000 [thread overview]
Message-ID: <200808080420.05897.pedro@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 519 bytes --]
Hi,
This patches makes the bsd-kvm target register a main thread.
I've "tested" this on a x86 OpenBSD-4.3 VM, but I'm not qualified
to do much more openbsd kernel debugging other than:
(gdb) tar kvm
#0 0x00000006 in ?? ()
(gdb) info threads
* 1 <kvm> 0x00000006 in ?? ()
B.T.W, with GDB 6.3, which came with the distro I always get:
(gdb) tar kvm
#0 0xd034ee05 in ?? ()
With HEAD I always get 0x00000006.
Is this difference expected? Related to the recent change to
build on 4.3?
OK?
--
Pedro Alves
[-- Attachment #2: bsd_kvm.diff --]
[-- Type: text/x-diff, Size: 3048 bytes --]
2008-08-08 Pedro Alves <pedro@codesourcery.com>
* bsd-kvm.c: Include "gdbthread.h".
(bsd_kvm_ptid): New.
(bsd_kvm_open): Add a main thread.
(bsd_kvm_close): Delete it.
(bsd_kvm_thread_alive): New.
(bsd_kvm_pid_to_str): New.
(bsd_kvm_add_target): Register bsd_kvm_thread_alive and
bsd_kvm_pid_to_str.
---
gdb/bsd-kvm.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
Index: src/gdb/bsd-kvm.c
===================================================================
--- src.orig/gdb/bsd-kvm.c 2008-08-08 04:04:34.000000000 +0100
+++ src/gdb/bsd-kvm.c 2008-08-08 04:10:58.000000000 +0100
@@ -25,6 +25,7 @@
#include "target.h"
#include "value.h"
#include "gdbcore.h" /* for get_exec_file */
+#include "gdbthread.h"
#include "gdb_assert.h"
#include <fcntl.h>
@@ -56,6 +57,12 @@ static int (*bsd_kvm_supply_pcb)(struct
/* Target ops for libkvm interface. */
static struct target_ops bsd_kvm_ops;
+/* This is the ptid we use while we're connected to kvm. Its value is
+ arbitrary, as the kvm target don't have a notion or processes or
+ thread ids, but we need something non-null to place in
+ inferior_ptid. */
+static ptid_t bsd_kvm_ptid;
+
static void
bsd_kvm_open (char *filename, int from_tty)
{
@@ -89,6 +96,9 @@ bsd_kvm_open (char *filename, int from_t
core_kd = temp_kd;
push_target (&bsd_kvm_ops);
+ add_thread_silent (bsd_kvm_ptid);
+ inferior_ptid = bsd_kvm_ptid;
+
target_fetch_registers (get_current_regcache (), -1);
reinit_frame_cache ();
@@ -104,6 +114,9 @@ bsd_kvm_close (int quitting)
warning (("%s"), kvm_geterr(core_kd));
core_kd = NULL;
}
+
+ inferior_ptid = null_ptid;
+ delete_thread_silent (bsd_kvm_ptid);
}
static LONGEST
@@ -297,6 +310,20 @@ bsd_kvm_pcb_cmd (char *arg, int fromtty)
print_stack_frame (get_selected_frame (NULL), -1, 1);
}
+static int
+bsd_kvm_thread_alive (ptid_t ptid)
+{
+ return 1;
+}
+
+static char *
+bsd_kvm_pid_to_str (ptid_t ptid)
+{
+ static char buf[64];
+ xsnprintf (buf, sizeof buf, "<kvm>");
+ return buf;
+}
+
/* Add the libkvm interface to the list of all possible targets and
register CUPPLY_PCB as the architecture-specific process control
block interpreter. */
@@ -316,6 +343,8 @@ Optionally specify the filename of a cor
bsd_kvm_ops.to_fetch_registers = bsd_kvm_fetch_registers;
bsd_kvm_ops.to_xfer_partial = bsd_kvm_xfer_partial;
bsd_kvm_ops.to_files_info = bsd_kvm_files_info;
+ bsd_kvm_ops.to_thread_alive = bsd_kvm_thread_alive;
+ bsd_kvm_ops.to_pid_to_str = bsd_kvm_pid_to_str;
bsd_kvm_ops.to_stratum = process_stratum;
bsd_kvm_ops.to_has_memory = 1;
bsd_kvm_ops.to_has_stack = 1;
@@ -335,4 +364,8 @@ Generic command for manipulating the ker
add_cmd ("pcb", class_obscure, bsd_kvm_pcb_cmd,
/* i18n: PCB == "Process Control Block" */
_("Set current context from pcb address"), &bsd_kvm_cmdlist);
+
+ /* Yes, 42000 is arbitrary. The only sense out of it, is that it
+ isn't 0. */
+ bsd_kvm_ptid = ptid_build (42000, 0, 42000);
}
next reply other threads:[~2008-08-08 3:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-08 3:20 Pedro Alves [this message]
2008-08-09 8:17 ` Mark Kettenis
2008-08-09 8:34 ` Mark Kettenis
2008-08-09 11:28 ` Pedro Alves
2008-08-09 12:13 ` Mark Kettenis
2008-08-09 14:31 ` Pedro Alves
2008-08-10 15:56 ` Mark Kettenis
2008-08-10 17:34 ` Pedro Alves
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=200808080420.05897.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/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