I'm working on a project that consists of adding a system call to xv6. The code that I wrote is not working as I expected and I want to use gdb to know what is happening.
This is the test program.
#include "types.h"
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[]) {
int x1 = getreadcount();
int x2 = getreadcount();
char buf[100];
(void) read(4, buf, 1);
int x3 = getreadcount();
int i;
for (i = 0; i < 1000; i++) {
(void) read(4, buf, 1);
}
int x4 = getreadcount();
printf(1, "XV6_TEST_OUTPUT %d %d %d\n", x2-x1, x3-x2, x4-x3);
exit();
}
The problem is that this code is going to be executed in an operating system running on qemu and I don't know how to use gdb in this case. In other words: the function fork() from xv6 is going to generate a new process (the test program) and that is the process that I need to have access to from gdb.
How can I do it?