From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22806 invoked by alias); 8 Aug 2008 03:20:07 -0000 Received: (qmail 22794 invoked by uid 22791); 8 Aug 2008 03:20:06 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 08 Aug 2008 03:19:30 +0000 Received: (qmail 10854 invoked from network); 8 Aug 2008 03:19:28 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 8 Aug 2008 03:19:28 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: bsd-kvm target, always a thread Date: Fri, 08 Aug 2008 03:20:00 -0000 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_lt7mIh9ZDRknwiO" Message-Id: <200808080420.05897.pedro@codesourcery.com> X-IsSubscribed: yes 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 X-SW-Source: 2008-08/txt/msg00182.txt.bz2 --Boundary-00=_lt7mIh9ZDRknwiO Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 519 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 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 --Boundary-00=_lt7mIh9ZDRknwiO Content-Type: text/x-diff; charset="utf-8"; name="bsd_kvm.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bsd_kvm.diff" Content-length: 3048 2008-08-08 Pedro Alves * 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 @@ -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, ""); + 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); } --Boundary-00=_lt7mIh9ZDRknwiO--