Browse Source

sysr0: bring back sysr0

sysr0 is a general purpose debugging system call. It's intended to
not have a fixed function over time. Make it what you need.

In this implementation, when you call sysr0, the GPRs of curproc
get dumped to the console. This is a very lightweight kind of dump;
all we need to do in the Go runtime assembly is
MOVQ $4096, AX
SYSCALL

and we can see them.

Want to DOS your system? Call it a lot. This is probably something
we don't want in there for long but for debugging the Go port it's handy,
until gdbserver gets more usable.

Don't LGTM unless you really think this hack is a good idea.

Fun point: Most of this system call is in port/.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 7 years ago
parent
commit
8e6606a969
4 changed files with 12 additions and 14 deletions
  1. 1 0
      sys/include/libc.h
  2. 8 0
      sys/src/9/port/sysproc.c
  3. 1 0
      sys/src/libc/libc.json
  4. 2 14
      sys/src/sysconf.json

+ 1 - 0
sys/include/libc.h

@@ -634,6 +634,7 @@ extern	int32_t	pread(int, void*, int32_t, int64_t);
 extern	int32_t	preadv(int, IOchunk*, int, int64_t);
 extern	int32_t	pwrite(int, void*, int32_t, int64_t);
 extern	int32_t	pwritev(int, IOchunk*, int, int64_t);
+extern	int32_t	r0(void);
 extern	int32_t	read(int, void*, int32_t);
 extern	int32_t	readn(int, void*, int32_t);
 extern	int32_t	readv(int, IOchunk*, int);

+ 8 - 0
sys/src/9/port/sysproc.c

@@ -989,6 +989,14 @@ sysnoted(Ar0* ar0, ...)
 	ar0->i = 0;
 }
 
+void
+sysr0(Ar0* ar0, ...)
+{
+	Proc *up = externup();
+	dumpgpr(up->ureg);
+	ar0->i = 0;
+}
+
 void
 sysrendezvous(Ar0* ar0, ...)
 {

+ 1 - 0
sys/src/libc/libc.json

@@ -89,6 +89,7 @@
 		"9syscall/pipe.s",
 		"9syscall/pread.s",
 		"9syscall/pwrite.s",
+		"9syscall/r0.s",
 		"9syscall/remove.s",
 		"9syscall/rendezvous.s",
 		"9syscall/rfork.s",

+ 2 - 14
sys/src/sysconf.json

@@ -3,21 +3,9 @@
 		{
 			"#Id": 0,
 			"Id": 4096,
-			"Name": "sysr1",
+			"Name": "r0",
 			"Ret": [
-				"int32_t"
-			],
-			"Sysname": "sysr1"
-		},
-		{
-			"#Id": 1,
-			"Args": [
-				"char*"
-			],
-			"Id": 4097,
-			"Name": "_errstr",
-			"Ret": [
-				"int32_t"
+				"int64_t"
 			]
 		},
 		{