Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Feb 2024 13:24:32 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: c5f972e7fced - stable/14 - bhyve: Add support for the 'p' query
Message-ID:  <202402211324.41LDOWbh015470@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=c5f972e7fced3aa1825564d70b05e58c88fac678

commit c5f972e7fced3aa1825564d70b05e58c88fac678
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-02-07 13:46:59 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-02-21 13:16:12 +0000

    bhyve: Add support for the 'p' query
    
    This lets gdb query individual registers.  It's easy to implement and is
    used by gdb when attaching to a CHERI target, so let's support it.
    
    Sponsored by:   Innovate UK
    Reviewed by:    corvink, jhb
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D43664
    
    (cherry picked from commit e6516294f4c7afa9da40a39caab86a5cd2aeb35a)
---
 usr.sbin/bhyve/gdb.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/bhyve/gdb.c b/usr.sbin/bhyve/gdb.c
index f2976622c79a..6bdfbc5e8536 100644
--- a/usr.sbin/bhyve/gdb.c
+++ b/usr.sbin/bhyve/gdb.c
@@ -1036,6 +1036,29 @@ gdb_read_regs(void)
 	finish_packet();
 }
 
+static void
+gdb_read_one_reg(const uint8_t *data, size_t len)
+{
+	uint64_t regval;
+	uintmax_t reg;
+
+	reg = parse_integer(data, len);
+	if (reg >= nitems(gdb_regset)) {
+		send_error(EINVAL);
+		return;
+	}
+
+	if (vm_get_register(vcpus[cur_vcpu], gdb_regset[reg].id, &regval) ==
+	    -1) {
+		send_error(errno);
+		return;
+	}
+
+	start_packet();
+	append_unsigned_native(regval, gdb_regset[reg].size);
+	finish_packet();
+}
+
 static void
 gdb_read_mem(const uint8_t *data, size_t len)
 {
@@ -1598,10 +1621,12 @@ handle_command(const uint8_t *data, size_t len)
 
 		/* TODO: Resume any stopped CPUs. */
 		break;
-	case 'g': {
+	case 'g':
 		gdb_read_regs();
 		break;
-	}
+	case 'p':
+		gdb_read_one_reg(data + 1, len - 1);
+		break;
 	case 'H': {
 		int tid;
 
@@ -1673,7 +1698,6 @@ handle_command(const uint8_t *data, size_t len)
 	case 'v':
 		/* Handle 'vCont' */
 		/* 'vCtrlC' */
-	case 'p': /* TODO */
 	case 'P': /* TODO */
 	case 'Q': /* TODO */
 	case 't': /* TODO */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202402211324.41LDOWbh015470>