|
|
|
@ -4,8 +4,6 @@
@@ -4,8 +4,6 @@
|
|
|
|
|
#include "util.c" |
|
|
|
|
#include "command.c" |
|
|
|
|
|
|
|
|
|
// TODO: read the directory table, get full path as comp_dir + directory_table (can be ".." or w/e) + filename
|
|
|
|
|
|
|
|
|
|
int |
|
|
|
|
main(int argc, char *argv[]) |
|
|
|
|
{ |
|
|
|
@ -34,9 +32,9 @@ main(int argc, char *argv[])
@@ -34,9 +32,9 @@ main(int argc, char *argv[])
|
|
|
|
|
fflush(stdout); |
|
|
|
|
|
|
|
|
|
parse_debug_line(process.elf, 0, 0, 0, &process.debug.sp_count, &process.source_file_count, &process.source_dirs_count); |
|
|
|
|
process.debug.sp_table = malloc(process.debug.sp_count * sizeof(struct mi_sourcepoint)); |
|
|
|
|
process.source_directories = malloc(process.source_dirs_count * sizeof(char *)); |
|
|
|
|
process.source_files = malloc(process.source_file_count * sizeof(struct mi_sourcefile)); |
|
|
|
|
process.debug.sp_table = calloc(1, process.debug.sp_count * sizeof(struct mi_sourcepoint)); |
|
|
|
|
process.source_directories = calloc(1, process.source_dirs_count * sizeof(char *)); |
|
|
|
|
process.source_files = calloc(1, process.source_file_count * sizeof(struct mi_sourcefile)); |
|
|
|
|
parse_debug_line(process.elf, process.debug.sp_table, process.source_files, process.source_directories, 0, 0, 0); |
|
|
|
|
|
|
|
|
|
while ((command_length = getline(&command, &max_command_length, stdin))) { |
|
|
|
@ -45,6 +43,8 @@ main(int argc, char *argv[])
@@ -45,6 +43,8 @@ main(int argc, char *argv[])
|
|
|
|
|
memcpy(command, last_command, command_length); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int wait = 0; |
|
|
|
|
|
|
|
|
|
if (0 == strncmp(command, "exit\n", command_length) || 0 == strncmp(command, "q\n", command_length)) { |
|
|
|
|
break; |
|
|
|
|
} else if (0 == strncmp(command, "regs\n", command_length)) { |
|
|
|
@ -59,12 +59,43 @@ main(int argc, char *argv[])
@@ -59,12 +59,43 @@ main(int argc, char *argv[])
|
|
|
|
|
command_list(process); |
|
|
|
|
} else if (0 == strncmp(command, "cont\n", command_length)) { |
|
|
|
|
command_cont(process); |
|
|
|
|
wait = 1; |
|
|
|
|
} else if (0 == strncmp(command, "stop\n", command_length)) { |
|
|
|
|
command_stop(process); |
|
|
|
|
wait = 1; |
|
|
|
|
} else { |
|
|
|
|
printf("Unknown command: %*s", command_length, command); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (wait) { |
|
|
|
|
int wstatus; |
|
|
|
|
int cpid = waitpid(process.pid, &wstatus, 0); |
|
|
|
|
|
|
|
|
|
if (cpid != 0) { |
|
|
|
|
if (WIFEXITED(wstatus)) { |
|
|
|
|
int status = WEXITSTATUS(wstatus); |
|
|
|
|
printf("Child terminated normally with status %d\n", status); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (WIFSIGNALED(wstatus)) { |
|
|
|
|
int signal = WTERMSIG(wstatus); |
|
|
|
|
printf("Child terminated by signal %d (%s)\n", signal, strsignal(signal)); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (WIFSTOPPED(wstatus)) { |
|
|
|
|
int signal = WSTOPSIG(wstatus); |
|
|
|
|
printf("Child stopped by signal %d (%s)\n", signal, strsignal(signal)); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (WIFCONTINUED(wstatus)) { |
|
|
|
|
printf("Child continued by SIGCONT\n"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
memset(last_command, 0, max_command_length); |
|
|
|
|
memcpy(last_command, command, command_length); |
|
|
|
|
|
|
|
|
|