web page -> http://hurd.dyndns.org/oskit-boot.txt
First off, the patch doesn't compile properly. There
are conflicting types between the prototype and the
function.
Here is the patch:
And here is the resulting error from Make:--- gdb-stub.diff ---
Index: kern/syscall_sw.c
===================================================================
RCS file: /cvs/gnumach/kern/syscall_sw.c,v
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.2 syscall_sw.c
--- kern/syscall_sw.c 2001/04/05 06:52:47 1.1.1.1.2.2
+++ kern/syscall_sw.c 2001/07/30 21:45:14
@@ -98,6 +98,8 @@
extern kern_return_t syscall_fipc_recv();
#endif /* FIPC */
+/*XXX*/extern kern_return_t gdb_break_stub ();
+
mach_trap_t mach_trap_table[] = {
MACH_TRAP(kern_invalid, 0), /* 0 */ /* Unix */
MACH_TRAP(kern_invalid, 0), /* 1 */ /* Unix */
@@ -283,7 +285,14 @@
MACH_TRAP(kern_invalid, 0), /* 126 */
MACH_TRAP(kern_invalid, 0), /* 127 */
MACH_TRAP(kern_invalid, 0), /* 128 */
- MACH_TRAP(kern_invalid, 0), /* 129 */
+ MACH_TRAP(gdb_break_stub, 1), /* 129 */
};
+volatile int gdb_break_stub (void *addr) /*XXX*/
+{< br>+ void *dummy;
+ dummy = addr;
+ return 0;
+}
+
int mach_trap_count = (sizeof(mach_trap_table) / sizeof(mach_trap_table[0]));
--- end ---
gcc -O -g -DOSKIT_MACH=1 -DMACH -DMACH_KERNEL -DKERNEL -DCONTINUATIONSNow, when I modified the source like this:
-DHAVE_CONFIG_H -D__ELF__=1 -Di386=1 -DAT386=1 -I../i386/i386at -I../i386/i386
-I../i386/include -I../i386/include/mach/sa -I../i386/bogus -I../i386 -I. -I..
-I../include -I../bogus -I../kern -I../device -c -o syscall_sw.o ../kern/syscall_sw.c
../kern/syscall_sw.c:292: conflicting types for `gdb_break_stub'
../kern/syscall_sw.c:101: previous declaration of `gdb_break_stub'
make: *** [syscall_sw.o] Error 1
Then it compiled ok, but I don't know if this is right or not. Should/*XXX*/ /* extern kern_return_t gdb_break_stub (); */
extern kern_return_t gdb_break_stub(void *addr);
... and ...
/* volatile int gdb_break_stub (void *addr) */ /*XXX*/
extern kern_return_t gdb_break_stub(void *addr)
{
void *dummy;
dummy = *addr;
return 0;
}
it be "volatile int" or should it be "extern kern_return_t" ? Apparently
it cannot be both. Also, why is it an "extern" since the function is right
there in the same file, does this perhaps coerce the compiler to
assign it a huge pointer for external linkage reasons?
Ant then finally, there is this: gdb-break.c
When starting an oskit-mach debug session with GDB set a break poit at `gdb_break_stub'. Then use this program to invoke the system call when desired:--- gdb-break.c --- /* Compile with: gcc -o gdb-break gdb-break.c gdb-break-stub.S */ #include <mach.h> #include <stdio.h> #include <string.h> extern int gdb_break_stub (void *addr); int main () { kern_return_t err; err = gdb_break_stub (&main); printf ("result from syscall: %s\n", strerror(err)); return 0; } --- end --- --- gdb-break-stub.S --- #include <mach/syscall_sw.h> kernel_trap(gdb_break_stub,-129,1) --- end ---
First of all, I don't have a <mach.h> anywhere on my system. The
sources for oskit-mach don't seem to install one when one does
a "make install-headers". Granted I can symlink /gnu/include/mach.h
to /usr/i386-gnu/include but should I? I am very wary of linking
"real" Hurd headers into my cross-compiler /usr/i386-gnu/include
directory.
Secondly, how do I run this program on the remote hppa machine?
How is it used anyways? I get the idea about putting a system call
into oskit-mach, but I can't see in my gdb manual any info on calling
an external program while remote debugging.
Is there a better way to call the trap?
Thanks,
- Doug