Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Avoid strict-aliasing related issues when compiling with optimization
[palacios.git] / linux_usr / v3_debug.c
1 /* 
2  * V3 debug interface
3  * (c) Jack Lange, 2012
4  */
5
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <sys/ioctl.h> 
10 #include <errno.h>
11 #include <assert.h>
12 #include <string.h>
13 #include <fcntl.h>
14 #include <unistd.h>
15
16 #include "v3_ctrl.h"
17
18
19 int main(int argc, char* argv[]) {
20     int vm_fd;
21     char * vm_dev = NULL;
22     struct v3_debug_cmd cmd; 
23
24     if (argc < 4) {
25         printf("usage: v3_debug <vm_device> <vm core> <cmd>\n");
26         printf("This will cause debugging output to be sent to the log\n\n");
27         printf("<cmds>: \n");
28         printf(" 1   telemetry\n");
29         printf(" 2   core state\n");
30         printf(" 3   arch state\n");
31         printf(" 4   stack\n");
32         printf(" 5   backtrace\n");
33         printf(" 100 everything\n");
34         printf(" 101 telemetry+core state+arch state\n");
35         return -1;
36     }
37
38     vm_dev = argv[1];
39     cmd.core = atoi(argv[2]);
40     cmd.cmd = atoi(argv[3]);
41
42     printf("Debug Virtual Core %d with Command %d\n", cmd.core, cmd.cmd);
43
44     vm_fd = open(vm_dev, O_RDONLY);
45
46     if (vm_fd == -1) {
47         printf("Error opening VM device: %s\n", vm_dev);
48         return -1;
49     }
50
51     int err = ioctl(vm_fd, V3_VM_DEBUG, &cmd); 
52
53     if (err < 0) {
54         printf("Error write core migrating command to vm\n");
55         return -1;
56     }
57
58     close(vm_fd); 
59
60     return 0; 
61 }
62
63