summaryrefslogtreecommitdiff
path: root/sys/src/cmd/vmx/vmxgdb.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-05-12 18:17:06 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2021-05-12 18:17:06 +0200
commit682414ce0d8245bef6c09d9e7ca015331a5ddd35 (patch)
tree5f41a2fdda9d93c3d0de4bc7728744f37097793f /sys/src/cmd/vmx/vmxgdb.c
parent532c7479e96e439a13df421d3b9f547cde5b5642 (diff)
vmx: fix 9p debug server and make it compatible to /proc
The 9p debug server was broken as it assumed the first tree file added would have a qid of 0 (it has a qid of 1 as the root directory is using 0 already). Instead, just compare File* pointers and get rid of the table (less code). When passing 64-bit unsigned addresses as 64-bit signed file offsets, we have to make sure to not pass negative offsets (filtered out by kernel and lib9p)! This is solved by clearing and sign bit in encoding and 63-bit sign extension on decoding. Make the mem file writable (needed for acid). The 9p debug server provided a single directory containing mem and regs files. This patch renames the regs file (which is in vmx specific text format) to "xregs" and adds "regs" and "kregs" file which use the same format as exported by the kernels /proc filesystem. This allows one to bind the vmx directory over a proc directory and attach acid to a running system like: mount -b /srv/vmx /proc/1 acid -k -lkernel 1 /sys/src/9/pc64/9pc64
Diffstat (limited to 'sys/src/cmd/vmx/vmxgdb.c')
-rw-r--r--sys/src/cmd/vmx/vmxgdb.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/src/cmd/vmx/vmxgdb.c b/sys/src/cmd/vmx/vmxgdb.c
index 07aba25c5..79f9f464d 100644
--- a/sys/src/cmd/vmx/vmxgdb.c
+++ b/sys/src/cmd/vmx/vmxgdb.c
@@ -132,7 +132,7 @@ char *
regpacket(void)
{
char *buf;
- char rbuf[8192];
+ char rbuf[4096];
int rc;
char *p, *q, *f[2];
int pos, i, l;
@@ -148,10 +148,7 @@ regpacket(void)
return strdup("");
}
rbuf[rc] = 0;
- p = rbuf;
- for(;; p = q + 1){
- q = strchr(p, '\n');
- if(q == nil) break;
+ for(p = rbuf; (q = strchr(p, '\n')) != nil; p = q + 1){
*q = 0;
if(tokenize(p, f, nelem(f)) < 2) continue;
v = strtoull(f[1], nil, 0);
@@ -183,6 +180,11 @@ memread(char *p)
char tbuf[3];
addr = strtoull(p, &q, 16);
+
+ /* avoid negative file offset */
+ addr <<= 1;
+ addr >>= 1;
+
if(p == q || *q != ',') return strdup("E99");
count = strtoull(q + 1, &p, 16);
if(q+1 == p || *p != 0) return strdup("E99");
@@ -213,7 +215,7 @@ main(int, char **)
free(p);
if(memfd < 0) sysfatal("open: %r");
- p = smprint("%s/regs", vmxroot);
+ p = smprint("%s/xregs", vmxroot);
regsfd = open(p, OREAD);
free(p);
if(regsfd < 0) sysfatal("open: %r");