Version 0.1.2
* Updated ``TODO''
* Added process.c:execute_process
* Added i386.c:type_of_stop
* Hopefully, system dependent stuff is now only in i386.[ch] and process.[ch]
* `-d' can now be used many times: many levels of debug
* removed breakpoint for children detecting fork()s.
Now, *every* program should work ok
* struct process now also has a field for the process filename
* Added "syscall.c" with a list of system call names in Linux/i386
diff --git a/ltrace.c b/ltrace.c
index bdffbc1..00653f5 100644
--- a/ltrace.c
+++ b/ltrace.c
@@ -1,18 +1,18 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
-#include <sys/wait.h>
-#include <signal.h>
#include "elf.h"
+#include "i386.h"
#include "symbols.h"
#include "functions.h"
#include "process.h"
extern void read_config_file(const char *);
-int debug = 0;
FILE * output = stderr;
+int opt_d = 0;
+int opt_i = 0;
unsigned long return_addr;
unsigned char return_value;
@@ -20,7 +20,7 @@
static void usage(void)
{
- fprintf(stderr," Usage: ltrace [-d][-o output] <program> [<arguments>...]\n");
+ fprintf(stderr,"Usage: ltrace [-d] [-o filename] command [arg ...]\n\n");
}
int main(int argc, char **argv)
@@ -29,7 +29,7 @@
while ((argc>2) && (argv[1][0] == '-') && (argv[1][2] == '\0')) {
switch(argv[1][1]) {
- case 'd': debug++;
+ case 'd': opt_d++;
break;
case 'o': output = fopen(argv[2], "w");
if (!output) {
@@ -38,6 +38,8 @@
}
argc--; argv++;
break;
+ case 'i': opt_i++;
+ break;
default: fprintf(stderr, "Unknown option '%c'\n", argv[1][1]);
usage();
exit(1);
@@ -56,18 +58,16 @@
init_sighandler();
- pid = attach_process(argv[1], argv+1);
- fprintf(output, "pid %u attached\n", pid);
-
-#if 1
- /* Enable breakpoints: */
- fprintf(output, "Enabling breakpoints...\n");
- enable_all_breakpoints(pid);
-#endif
- fprintf(output, "Reading config file(s)...\n");
+ if (opt_d>0) {
+ fprintf(output, "Reading config file(s)...\n");
+ }
read_config_file("/etc/ltrace.cfg");
read_config_file(".ltracerc");
- continue_process(pid, 0);
+
+ pid = execute_process(argv[1], argv+1);
+ if (opt_d>0) {
+ fprintf(output, "pid %u launched\n", pid);
+ }
while(1) {
pause();