Re-organize file names
diff --git a/breakpoints.c b/breakpoints.c
index e0cdb6d..1805499 100644
--- a/breakpoints.c
+++ b/breakpoints.c
@@ -10,7 +10,7 @@
#include <sys/ptrace.h>
#endif
-#include "main.h"
+#include "common.h"
#include "options.h"
#include "debug.h"
#include "dict.h"
diff --git a/main.h b/common.h
similarity index 100%
rename from main.h
rename to common.h
diff --git a/display_args.c b/display_args.c
index 9b51c7d..42e7325 100644
--- a/display_args.c
+++ b/display_args.c
@@ -8,7 +8,7 @@
#include <string.h>
#include <limits.h>
-#include "main.h"
+#include "common.h"
#include "options.h"
static int display_char(int what);
diff --git a/elf.c b/elf.c
index 7d0fd17..83d10f1 100644
--- a/elf.c
+++ b/elf.c
@@ -12,7 +12,7 @@
#include <string.h>
#include <unistd.h>
-#include "main.h"
+#include "common.h"
#include "elf.h"
#include "debug.h"
#include "options.h"
diff --git a/elf.h b/elf.h
index af4493b..55055d2 100644
--- a/elf.h
+++ b/elf.h
@@ -4,7 +4,7 @@
#include <gelf.h>
#include <stdlib.h>
-#include "main.h"
+#include "common.h"
struct ltelf {
int fd;
diff --git a/execute_program.c b/execute_program.c
index 6704d51..cea6608 100644
--- a/execute_program.c
+++ b/execute_program.c
@@ -12,7 +12,7 @@
#include <pwd.h>
#include <grp.h>
-#include "main.h"
+#include "common.h"
#include "options.h"
#include "debug.h"
#include "sysdep.h"
diff --git a/libltrace.c b/libltrace.c
new file mode 100644
index 0000000..381cfa2
--- /dev/null
+++ b/libltrace.c
@@ -0,0 +1,131 @@
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/param.h>
+#include <signal.h>
+#include <sys/wait.h>
+
+#include "common.h"
+#include "output.h"
+#include "read_config_file.h"
+#include "options.h"
+#include "debug.h"
+
+char *command = NULL;
+Process *list_of_processes = NULL;
+
+int exiting = 0; /* =1 if a SIGINT or SIGTERM has been received */
+
+static void
+signal_alarm(int sig) {
+ Process *tmp = list_of_processes;
+
+ signal(SIGALRM, SIG_DFL);
+ while (tmp) {
+ struct opt_p_t *tmp2 = opt_p;
+ while (tmp2) {
+ if (tmp->pid == tmp2->pid) {
+ tmp = tmp->next;
+ if (!tmp) {
+ return;
+ }
+ tmp2 = opt_p;
+ continue;
+ }
+ tmp2 = tmp2->next;
+ }
+ debug(2, "Sending SIGSTOP to process %u\n", tmp->pid);
+ kill(tmp->pid, SIGSTOP);
+ tmp = tmp->next;
+ }
+}
+
+static void
+signal_exit(int sig) {
+ exiting = 1;
+ debug(1, "Received interrupt signal; exiting...");
+ signal(SIGINT, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+ signal(SIGALRM, signal_alarm);
+ if (opt_p) {
+ struct opt_p_t *tmp = opt_p;
+ while (tmp) {
+ debug(2, "Sending SIGSTOP to process %u\n", tmp->pid);
+ kill(tmp->pid, SIGSTOP);
+ tmp = tmp->next;
+ }
+ }
+ alarm(1);
+}
+
+static void
+normal_exit(void) {
+ output_line(0, 0);
+ if (options.summary) {
+ show_summary();
+ }
+ if (options.output) {
+ fclose(options.output);
+ options.output = NULL;
+ }
+}
+
+void
+ltrace_init(int argc, char **argv) {
+ struct opt_p_t *opt_p_tmp;
+
+ atexit(normal_exit);
+ signal(SIGINT, signal_exit); /* Detach processes when interrupted */
+ signal(SIGTERM, signal_exit); /* ... or killed */
+
+ argv = process_options(argc, argv);
+ while (opt_F) {
+ /* If filename begins with ~, expand it to the user's home */
+ /* directory. This does not correctly handle ~yoda, but that */
+ /* isn't as bad as it seems because the shell will normally */
+ /* be doing the expansion for us; only the hardcoded */
+ /* ~/.ltrace.conf should ever use this code. */
+ if (opt_F->filename[0] == '~') {
+ char path[PATH_MAX];
+ char *home_dir = getenv("HOME");
+ if (home_dir) {
+ strncpy(path, home_dir, PATH_MAX - 1);
+ path[PATH_MAX - 1] = '\0';
+ strncat(path, opt_F->filename + 1,
+ PATH_MAX - strlen(path) - 1);
+ read_config_file(path);
+ }
+ } else {
+ read_config_file(opt_F->filename);
+ }
+ opt_F = opt_F->next;
+ }
+ if (opt_e) {
+ struct opt_e_t *tmp = opt_e;
+ while (tmp) {
+ debug(1, "Option -e: %s\n", tmp->name);
+ tmp = tmp->next;
+ }
+ }
+ if (command) {
+ execute_program(open_program(command, 0), argv);
+ }
+ opt_p_tmp = opt_p;
+ while (opt_p_tmp) {
+ open_pid(opt_p_tmp->pid, 1);
+ opt_p_tmp = opt_p_tmp->next;
+ }
+}
+
+void
+ltrace_main(void) {
+ while (1) {
+ process_event(next_event());
+ }
+}
diff --git a/ltrace.c b/ltrace.c
deleted file mode 100644
index e6de362..0000000
--- a/ltrace.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "ltrace.h"
-
-int
-main(int argc, char *argv[]) {
- ltrace_init(argc, argv);
- ltrace_main();
- return 0;
-}
diff --git a/main.c b/main.c
index 96ca314..e6de362 100644
--- a/main.c
+++ b/main.c
@@ -1,131 +1,8 @@
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "ltrace.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/param.h>
-#include <signal.h>
-#include <sys/wait.h>
-
-#include "main.h"
-#include "output.h"
-#include "read_config_file.h"
-#include "options.h"
-#include "debug.h"
-
-char *command = NULL;
-Process *list_of_processes = NULL;
-
-int exiting = 0; /* =1 if a SIGINT or SIGTERM has been received */
-
-static void
-signal_alarm(int sig) {
- Process *tmp = list_of_processes;
-
- signal(SIGALRM, SIG_DFL);
- while (tmp) {
- struct opt_p_t *tmp2 = opt_p;
- while (tmp2) {
- if (tmp->pid == tmp2->pid) {
- tmp = tmp->next;
- if (!tmp) {
- return;
- }
- tmp2 = opt_p;
- continue;
- }
- tmp2 = tmp2->next;
- }
- debug(2, "Sending SIGSTOP to process %u\n", tmp->pid);
- kill(tmp->pid, SIGSTOP);
- tmp = tmp->next;
- }
-}
-
-static void
-signal_exit(int sig) {
- exiting = 1;
- debug(1, "Received interrupt signal; exiting...");
- signal(SIGINT, SIG_IGN);
- signal(SIGTERM, SIG_IGN);
- signal(SIGALRM, signal_alarm);
- if (opt_p) {
- struct opt_p_t *tmp = opt_p;
- while (tmp) {
- debug(2, "Sending SIGSTOP to process %u\n", tmp->pid);
- kill(tmp->pid, SIGSTOP);
- tmp = tmp->next;
- }
- }
- alarm(1);
-}
-
-static void
-normal_exit(void) {
- output_line(0, 0);
- if (options.summary) {
- show_summary();
- }
- if (options.output) {
- fclose(options.output);
- options.output = NULL;
- }
-}
-
-void
-ltrace_init(int argc, char **argv) {
- struct opt_p_t *opt_p_tmp;
-
- atexit(normal_exit);
- signal(SIGINT, signal_exit); /* Detach processes when interrupted */
- signal(SIGTERM, signal_exit); /* ... or killed */
-
- argv = process_options(argc, argv);
- while (opt_F) {
- /* If filename begins with ~, expand it to the user's home */
- /* directory. This does not correctly handle ~yoda, but that */
- /* isn't as bad as it seems because the shell will normally */
- /* be doing the expansion for us; only the hardcoded */
- /* ~/.ltrace.conf should ever use this code. */
- if (opt_F->filename[0] == '~') {
- char path[PATH_MAX];
- char *home_dir = getenv("HOME");
- if (home_dir) {
- strncpy(path, home_dir, PATH_MAX - 1);
- path[PATH_MAX - 1] = '\0';
- strncat(path, opt_F->filename + 1,
- PATH_MAX - strlen(path) - 1);
- read_config_file(path);
- }
- } else {
- read_config_file(opt_F->filename);
- }
- opt_F = opt_F->next;
- }
- if (opt_e) {
- struct opt_e_t *tmp = opt_e;
- while (tmp) {
- debug(1, "Option -e: %s\n", tmp->name);
- tmp = tmp->next;
- }
- }
- if (command) {
- execute_program(open_program(command, 0), argv);
- }
- opt_p_tmp = opt_p;
- while (opt_p_tmp) {
- open_pid(opt_p_tmp->pid, 1);
- opt_p_tmp = opt_p_tmp->next;
- }
-}
-
-void
-ltrace_main(void) {
- while (1) {
- process_event(next_event());
- }
+int
+main(int argc, char *argv[]) {
+ ltrace_init(argc, argv);
+ ltrace_main();
+ return 0;
}
diff --git a/options.c b/options.c
index 812036a..8a837ca 100644
--- a/options.c
+++ b/options.c
@@ -14,7 +14,7 @@
#include <getopt.h>
#endif
-#include "main.h"
+#include "common.h"
#include "options.h"
#include "defs.h"
diff --git a/output.c b/output.c
index 886260c..fd13d91 100644
--- a/output.c
+++ b/output.c
@@ -10,7 +10,7 @@
#include <sys/time.h>
#include <unistd.h>
-#include "main.h"
+#include "common.h"
#include "options.h"
#include "output.h"
#include "dict.h"
@@ -19,7 +19,7 @@
#include "demangle.h"
#endif
-/* TODO FIXME XXX: include in main.h: */
+/* TODO FIXME XXX: include in common.h: */
extern struct timeval current_time_spent;
struct dict *dict_opt_c = NULL;
diff --git a/output.h b/output.h
index da29505..7d594a6 100644
--- a/output.h
+++ b/output.h
@@ -1,6 +1,6 @@
#include <sys/types.h>
-#include "main.h"
+#include "common.h"
void output_line(Process *proc, char *fmt, ...);
diff --git a/proc.c b/proc.c
index c430e0c..186788d 100644
--- a/proc.c
+++ b/proc.c
@@ -8,7 +8,7 @@
#include <errno.h>
#include <stdlib.h>
-#include "main.h"
+#include "common.h"
#include "options.h"
#include "elf.h"
diff --git a/process_event.c b/process_event.c
index 169db09..43ff0ee 100644
--- a/process_event.c
+++ b/process_event.c
@@ -10,7 +10,7 @@
#include <assert.h>
#include <sys/time.h>
-#include "main.h"
+#include "common.h"
#include "output.h"
#include "options.h"
#include "elf.h"
diff --git a/read_config_file.c b/read_config_file.c
index dee5d21..d669158 100644
--- a/read_config_file.c
+++ b/read_config_file.c
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <ctype.h>
-#include "main.h"
+#include "common.h"
#include "read_config_file.h"
#include "output.h"
#include "debug.h"
@@ -49,7 +49,7 @@
/* Array of prototype objects for each of the types. The order in this
* array must exactly match the list of enumerated values in
- * main.h */
+ * common.h */
static arg_type_info arg_type_prototypes[] = {
{ ARGTYPE_VOID },
{ ARGTYPE_INT },
diff --git a/summary.c b/summary.c
index 09926bf..59e80b5 100644
--- a/summary.c
+++ b/summary.c
@@ -6,7 +6,7 @@
#include <stdlib.h>
#include <sys/time.h>
-#include "main.h"
+#include "common.h"
#include "options.h"
#ifdef USE_DEMANGLE
diff --git a/sysdeps/linux-gnu/alpha/plt.c b/sysdeps/linux-gnu/alpha/plt.c
index 4d7002d..11950c2 100644
--- a/sysdeps/linux-gnu/alpha/plt.c
+++ b/sysdeps/linux-gnu/alpha/plt.c
@@ -1,5 +1,5 @@
#include <gelf.h>
-#include "main.h"
+#include "common.h"
#include "elf.h"
GElf_Addr
diff --git a/sysdeps/linux-gnu/alpha/regs.c b/sysdeps/linux-gnu/alpha/regs.c
index 9e5e4e7..5521e84 100644
--- a/sysdeps/linux-gnu/alpha/regs.c
+++ b/sysdeps/linux-gnu/alpha/regs.c
@@ -6,7 +6,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/alpha/trace.c b/sysdeps/linux-gnu/alpha/trace.c
index ceda5a5..afd38a7 100644
--- a/sysdeps/linux-gnu/alpha/trace.c
+++ b/sysdeps/linux-gnu/alpha/trace.c
@@ -8,7 +8,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#include "debug.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
diff --git a/sysdeps/linux-gnu/arm/plt.c b/sysdeps/linux-gnu/arm/plt.c
index fa3cf9b..8866705 100644
--- a/sysdeps/linux-gnu/arm/plt.c
+++ b/sysdeps/linux-gnu/arm/plt.c
@@ -1,5 +1,5 @@
#include <gelf.h>
-#include "main.h"
+#include "common.h"
#include "elf.h"
GElf_Addr
diff --git a/sysdeps/linux-gnu/arm/regs.c b/sysdeps/linux-gnu/arm/regs.c
index 80cf8d9..1566e1c 100644
--- a/sysdeps/linux-gnu/arm/regs.c
+++ b/sysdeps/linux-gnu/arm/regs.c
@@ -6,7 +6,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/arm/trace.c b/sysdeps/linux-gnu/arm/trace.c
index fbbdaa0..2779a94 100644
--- a/sysdeps/linux-gnu/arm/trace.c
+++ b/sysdeps/linux-gnu/arm/trace.c
@@ -9,7 +9,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#include "output.h"
#include "ptrace.h"
diff --git a/sysdeps/linux-gnu/events.c b/sysdeps/linux-gnu/events.c
index af8b27f..f9cee73 100644
--- a/sysdeps/linux-gnu/events.c
+++ b/sysdeps/linux-gnu/events.c
@@ -11,7 +11,7 @@
#include <string.h>
#include <sys/ptrace.h>
-#include "main.h"
+#include "common.h"
#include "options.h"
#include "output.h"
#include "debug.h"
diff --git a/sysdeps/linux-gnu/i386/plt.c b/sysdeps/linux-gnu/i386/plt.c
index 2f7e238..834d3a3 100644
--- a/sysdeps/linux-gnu/i386/plt.c
+++ b/sysdeps/linux-gnu/i386/plt.c
@@ -1,5 +1,5 @@
#include <gelf.h>
-#include "main.h"
+#include "common.h"
#include "elf.h"
GElf_Addr
diff --git a/sysdeps/linux-gnu/i386/regs.c b/sysdeps/linux-gnu/i386/regs.c
index cb74cfb..0884217 100644
--- a/sysdeps/linux-gnu/i386/regs.c
+++ b/sysdeps/linux-gnu/i386/regs.c
@@ -6,7 +6,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/i386/trace.c b/sysdeps/linux-gnu/i386/trace.c
index fb0e392..aae7871 100644
--- a/sysdeps/linux-gnu/i386/trace.c
+++ b/sysdeps/linux-gnu/i386/trace.c
@@ -9,7 +9,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/ia64/plt.c b/sysdeps/linux-gnu/ia64/plt.c
index 2f8bb3c..5b8bbb0 100644
--- a/sysdeps/linux-gnu/ia64/plt.c
+++ b/sysdeps/linux-gnu/ia64/plt.c
@@ -1,5 +1,5 @@
#include <gelf.h>
-#include "main.h"
+#include "common.h"
#include "elf.h"
#include "debug.h"
diff --git a/sysdeps/linux-gnu/ia64/regs.c b/sysdeps/linux-gnu/ia64/regs.c
index dd7041e..e08f495 100644
--- a/sysdeps/linux-gnu/ia64/regs.c
+++ b/sysdeps/linux-gnu/ia64/regs.c
@@ -10,7 +10,7 @@
#include <stddef.h>
#include "debug.h"
-#include "main.h"
+#include "common.h"
void *
get_instruction_pointer(Process *proc) {
diff --git a/sysdeps/linux-gnu/ia64/trace.c b/sysdeps/linux-gnu/ia64/trace.c
index 842b7c0..63d4b73 100644
--- a/sysdeps/linux-gnu/ia64/trace.c
+++ b/sysdeps/linux-gnu/ia64/trace.c
@@ -12,7 +12,7 @@
#include <asm/ptrace_offsets.h>
#include <asm/rse.h>
-#include "main.h"
+#include "common.h"
/* What we think of as a bundle, ptrace thinks of it as two unsigned
* longs */
diff --git a/sysdeps/linux-gnu/m68k/plt.c b/sysdeps/linux-gnu/m68k/plt.c
index 5ef1e4c..79c1173 100644
--- a/sysdeps/linux-gnu/m68k/plt.c
+++ b/sysdeps/linux-gnu/m68k/plt.c
@@ -1,5 +1,5 @@
#include <gelf.h>
-#include "main.h"
+#include "common.h"
#include "elf.h"
GElf_Addr
diff --git a/sysdeps/linux-gnu/m68k/regs.c b/sysdeps/linux-gnu/m68k/regs.c
index 55c1fd0..5acfb61 100644
--- a/sysdeps/linux-gnu/m68k/regs.c
+++ b/sysdeps/linux-gnu/m68k/regs.c
@@ -6,7 +6,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/m68k/trace.c b/sysdeps/linux-gnu/m68k/trace.c
index 513a4be..67fc3ac 100644
--- a/sysdeps/linux-gnu/m68k/trace.c
+++ b/sysdeps/linux-gnu/m68k/trace.c
@@ -8,7 +8,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/mipsel/plt.c b/sysdeps/linux-gnu/mipsel/plt.c
index 94a9a6d..37fa0b1 100644
--- a/sysdeps/linux-gnu/mipsel/plt.c
+++ b/sysdeps/linux-gnu/mipsel/plt.c
@@ -1,7 +1,7 @@
#include <debug.h>
#include <gelf.h>
#include <sys/ptrace.h>
-#include "main.h"
+#include "common.h"
#include "ltrace_elf.h"
/**
diff --git a/sysdeps/linux-gnu/mipsel/regs.c b/sysdeps/linux-gnu/mipsel/regs.c
index ac9ebdc..552c922 100644
--- a/sysdeps/linux-gnu/mipsel/regs.c
+++ b/sysdeps/linux-gnu/mipsel/regs.c
@@ -7,7 +7,7 @@
#include <asm/ptrace.h>
#include <linux/user.h>
-#include "main.h"
+#include "common.h"
#include "mipsel.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
diff --git a/sysdeps/linux-gnu/mipsel/trace.c b/sysdeps/linux-gnu/mipsel/trace.c
index 57fa4f2..908e62d 100644
--- a/sysdeps/linux-gnu/mipsel/trace.c
+++ b/sysdeps/linux-gnu/mipsel/trace.c
@@ -8,7 +8,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
#include "debug.h"
-#include "main.h"
+#include "common.h"
#include "mipsel.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/ppc/plt.c b/sysdeps/linux-gnu/ppc/plt.c
index 55bca66..fb8af2c 100644
--- a/sysdeps/linux-gnu/ppc/plt.c
+++ b/sysdeps/linux-gnu/ppc/plt.c
@@ -1,5 +1,5 @@
#include <gelf.h>
-#include "main.h"
+#include "common.h"
#include "elf.h"
#include "debug.h"
#include "ptrace.h"
diff --git a/sysdeps/linux-gnu/ppc/regs.c b/sysdeps/linux-gnu/ppc/regs.c
index e81b35f..714d57f 100644
--- a/sysdeps/linux-gnu/ppc/regs.c
+++ b/sysdeps/linux-gnu/ppc/regs.c
@@ -6,7 +6,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/ppc/trace.c b/sysdeps/linux-gnu/ppc/trace.c
index d430cbd..9087879 100644
--- a/sysdeps/linux-gnu/ppc/trace.c
+++ b/sysdeps/linux-gnu/ppc/trace.c
@@ -10,7 +10,7 @@
#include <elf.h>
#include <errno.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/s390/plt.c b/sysdeps/linux-gnu/s390/plt.c
index adeb04f..c474b39 100644
--- a/sysdeps/linux-gnu/s390/plt.c
+++ b/sysdeps/linux-gnu/s390/plt.c
@@ -1,5 +1,5 @@
#include <gelf.h>
-#include "main.h"
+#include "common.h"
#include "elf.h"
GElf_Addr
diff --git a/sysdeps/linux-gnu/s390/regs.c b/sysdeps/linux-gnu/s390/regs.c
index 600eced..7d9e3d8 100644
--- a/sysdeps/linux-gnu/s390/regs.c
+++ b/sysdeps/linux-gnu/s390/regs.c
@@ -11,7 +11,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/s390/trace.c b/sysdeps/linux-gnu/s390/trace.c
index 418892c..d106b4a 100644
--- a/sysdeps/linux-gnu/s390/trace.c
+++ b/sysdeps/linux-gnu/s390/trace.c
@@ -19,7 +19,7 @@
#include <sys/ptrace.h>
#include <asm/ptrace.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/sparc/plt.c b/sysdeps/linux-gnu/sparc/plt.c
index a0d8bb6..7f1920d 100644
--- a/sysdeps/linux-gnu/sparc/plt.c
+++ b/sysdeps/linux-gnu/sparc/plt.c
@@ -1,5 +1,5 @@
#include <gelf.h>
-#include "main.h"
+#include "common.h"
#include "elf.h"
GElf_Addr
diff --git a/sysdeps/linux-gnu/sparc/ptrace.h b/sysdeps/linux-gnu/sparc/ptrace.h
index 2c4aa1d..c7a238f 100644
--- a/sysdeps/linux-gnu/sparc/ptrace.h
+++ b/sysdeps/linux-gnu/sparc/ptrace.h
@@ -12,7 +12,7 @@
#define PTRACE_DETACH PTRACE_SUNDETACH
#include <asm/reg.h>
-#include "main.h"
+#include "common.h"
typedef struct {
int valid;
diff --git a/sysdeps/linux-gnu/sparc/regs.c b/sysdeps/linux-gnu/sparc/regs.c
index ff967c0..6ba359c 100644
--- a/sysdeps/linux-gnu/sparc/regs.c
+++ b/sysdeps/linux-gnu/sparc/regs.c
@@ -4,7 +4,7 @@
#include <sys/types.h>
#include "ptrace.h"
-#include "main.h"
+#include "common.h"
void *
get_instruction_pointer(Process *proc) {
diff --git a/sysdeps/linux-gnu/sparc/trace.c b/sysdeps/linux-gnu/sparc/trace.c
index 069c0f5..34b416f 100644
--- a/sysdeps/linux-gnu/sparc/trace.c
+++ b/sysdeps/linux-gnu/sparc/trace.c
@@ -8,7 +8,7 @@
#include <signal.h>
#include <string.h>
#include "ptrace.h"
-#include "main.h"
+#include "common.h"
void
get_arch_dep(Process *proc) {
diff --git a/sysdeps/linux-gnu/trace.c b/sysdeps/linux-gnu/trace.c
index 15b597b..4ed6b41 100644
--- a/sysdeps/linux-gnu/trace.c
+++ b/sysdeps/linux-gnu/trace.c
@@ -8,7 +8,7 @@
#include "ptrace.h"
#include <asm/unistd.h>
-#include "main.h"
+#include "common.h"
#include "options.h"
#include "sysdep.h"
#include "debug.h"
diff --git a/sysdeps/linux-gnu/x86_64/plt.c b/sysdeps/linux-gnu/x86_64/plt.c
index 2f7e238..834d3a3 100644
--- a/sysdeps/linux-gnu/x86_64/plt.c
+++ b/sysdeps/linux-gnu/x86_64/plt.c
@@ -1,5 +1,5 @@
#include <gelf.h>
-#include "main.h"
+#include "common.h"
#include "elf.h"
GElf_Addr
diff --git a/sysdeps/linux-gnu/x86_64/regs.c b/sysdeps/linux-gnu/x86_64/regs.c
index 50da342..c865d09 100644
--- a/sysdeps/linux-gnu/x86_64/regs.c
+++ b/sysdeps/linux-gnu/x86_64/regs.c
@@ -6,7 +6,7 @@
#include <sys/ptrace.h>
#include <sys/reg.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR
diff --git a/sysdeps/linux-gnu/x86_64/trace.c b/sysdeps/linux-gnu/x86_64/trace.c
index 585b85e..3a765c9 100644
--- a/sysdeps/linux-gnu/x86_64/trace.c
+++ b/sysdeps/linux-gnu/x86_64/trace.c
@@ -9,7 +9,7 @@
#include <sys/ptrace.h>
#include <sys/reg.h>
-#include "main.h"
+#include "common.h"
#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
# define PTRACE_PEEKUSER PTRACE_PEEKUSR