aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUGS2
-rw-r--r--TODO2
-rw-r--r--debian/changelog6
-rw-r--r--etc/ltrace.conf1
-rw-r--r--ltrace.h3
-rw-r--r--proc.c20
-rw-r--r--process_event.c9
-rw-r--r--sysdeps/Linux/i386/trace.c31
-rw-r--r--wait_for_something.c25
9 files changed, 52 insertions, 47 deletions
diff --git a/BUGS b/BUGS
index 2967c3f..146d9b6 100644
--- a/BUGS
+++ b/BUGS
@@ -1,5 +1,5 @@
* processes attached with option -p die when the attacher is interrupted
-* Using option -f sometimes it doesn't trace some children
+* Option -f sometimes fails to trace some children
* Manual page is not accurate (config files...)
* elf.c only supports elf32 binaries
* netscape sometimes dies with SIGSEGV (is this still true?)
diff --git a/TODO b/TODO
index ddfecc2..ba8f411 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,5 @@
-* Improve documentation
* Regarding option -p: disable breakpoints on exit
+* Improve documentation
* Display different argument types:
+ format
+ how to display execl...?
diff --git a/debian/changelog b/debian/changelog
index d0d6caf..4ef9fd1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ltrace (0.2.7) unstable; urgency=low
+
+ * Some minor fixes
+
+ -- Juan Cespedes <cespedes@debian.org> Sun, 15 Mar 1998 14:01:40 +0100
+
ltrace (0.2.6) unstable; urgency=low
* Option `-f' now works (but it fails to attach some processes...)
diff --git a/etc/ltrace.conf b/etc/ltrace.conf
index 8c81e3c..d67fea6 100644
--- a/etc/ltrace.conf
+++ b/etc/ltrace.conf
@@ -113,6 +113,7 @@ int fork(void);
string2 getcwd(addr,uint);
int geteuid(void);
int gethostname(+string2,int);
+int getpid(void);
int isatty(int);
int mkdir(string,octal);
int read(int, +string0, uint);
diff --git a/ltrace.h b/ltrace.h
index 67bd794..088daf6 100644
--- a/ltrace.h
+++ b/ltrace.h
@@ -127,8 +127,7 @@ extern void insert_breakpoint(int pid, struct breakpoint * sbp);
extern void delete_breakpoint(int pid, struct breakpoint * sbp);
extern int fork_p(int sysnum);
extern int exec_p(int sysnum);
-extern int syscall_p(struct process * proc, int status);
-extern int sysret_p(struct process * proc, int status);
+extern int syscall_p(struct process * proc, int status, int * sysnum);
extern void continue_process(pid_t pid);
extern void continue_after_signal(pid_t pid, int signum);
extern void continue_after_breakpoint(struct process * proc, struct breakpoint * sbp, int delete_it);
diff --git a/proc.c b/proc.c
index c977535..3369127 100644
--- a/proc.c
+++ b/proc.c
@@ -23,7 +23,7 @@ struct process * open_program(char * filename)
proc->current_symbol = NULL;
proc->breakpoint_being_enabled = NULL;
proc->next = NULL;
- if (opt_L) {
+ if (opt_L && filename) {
proc->list_of_symbols = read_elf(filename);
} else {
proc->list_of_symbols = NULL;
@@ -39,21 +39,27 @@ void open_pid(pid_t pid, int verbose)
struct process * proc;
char * filename;
- filename = pid2name(pid);
-
- if (!filename) {
+ if (trace_pid(pid)<0) {
+#if 0
if (verbose) {
- fprintf(stderr, "Cannot trace pid %u: %s\n", pid, strerror(errno));
+#endif
+ fprintf(stderr, "Cannot attach to pid %u: %s\n", pid, strerror(errno));
+#if 0
}
+#endif
return;
}
- if (trace_pid(pid)<0) {
+ filename = pid2name(pid);
+
+#if 0
+ if (!filename) {
if (verbose) {
- fprintf(stderr, "Cannot attach to pid %u: %s\n", pid, strerror(errno));
+ fprintf(stderr, "Cannot trace pid %u: %s\n", pid, strerror(errno));
}
return;
}
+#endif
proc = open_program(filename);
proc->pid = pid;
diff --git a/process_event.c b/process_event.c
index ec1c56f..f3c5295 100644
--- a/process_event.c
+++ b/process_event.c
@@ -130,6 +130,7 @@ static void remove_proc(struct process * proc)
tmp->next = tmp->next->next;
free(tmp2);
}
+ tmp = tmp->next;
}
}
@@ -168,16 +169,16 @@ static void process_sysret(struct event * event)
}
}
if (fork_p(event->e_un.sysnum)) {
- enable_all_breakpoints(event->proc);
- if (event->proc->current_symbol) {
- insert_breakpoint(event->proc->pid, &event->proc->return_value);
- }
if (opt_f) {
pid_t child = gimme_arg(LT_TOF_SYSCALL,event->proc,-1);
if (child>0) {
open_pid(child, 0);
}
}
+ enable_all_breakpoints(event->proc);
+ if (event->proc->current_symbol) {
+ insert_breakpoint(event->proc->pid, &event->proc->return_value);
+ }
}
event->proc->current_syscall = -1;
continue_process(event->proc->pid);
diff --git a/sysdeps/Linux/i386/trace.c b/sysdeps/Linux/i386/trace.c
index 8577d0e..e9d3027 100644
--- a/sysdeps/Linux/i386/trace.c
+++ b/sysdeps/Linux/i386/trace.c
@@ -5,32 +5,21 @@
#include "ltrace.h"
-/* Returns syscall number if `pid' stopped because of a syscall.
- * Returns -1 otherwise
+/* Returns 1 if syscall, 2 if sysret, 0 otherwise.
*/
-int syscall_p(struct process * proc, int status)
+int syscall_p(struct process * proc, int status, int * sysnum)
{
if (WIFSTOPPED(status) && WSTOPSIG(status)==SIGTRAP) {
- int tmp = ptrace(PTRACE_PEEKUSER, proc->pid, 4*ORIG_EAX);
- if (tmp>=0 && proc->current_syscall!=tmp) {
- return tmp;
- }
- }
- return -1;
-}
-
-/* Returns syscall number if `pid' stopped because of a sysret.
- * Returns -1 otherwise
- */
-int sysret_p(struct process * proc, int status)
-{
- if (WIFSTOPPED(status) && WSTOPSIG(status)==SIGTRAP) {
- int tmp = ptrace(PTRACE_PEEKUSER, proc->pid, 4*ORIG_EAX);
- if (tmp>=0 && proc->current_syscall==tmp) {
- return tmp;
+ *sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 4*ORIG_EAX);
+ if (*sysnum>=0) {
+ if (proc->current_syscall!=*sysnum) {
+ return 1;
+ } else {
+ return 2;
+ }
}
}
- return -1;
+ return 0;
}
void continue_after_breakpoint(struct process *proc, struct breakpoint * sbp, int delete_it)
diff --git a/wait_for_something.c b/wait_for_something.c
index 1f9a91d..b5d8845 100644
--- a/wait_for_something.c
+++ b/wait_for_something.c
@@ -37,7 +37,7 @@ struct event * wait_for_something(void)
fprintf(stderr, "signal from wrong pid %u ?!?\n", pid);
exit(1);
}
- event.proc->instruction_pointer = get_instruction_pointer(pid);
+ event.proc->instruction_pointer = NULL;
if (opt_d>2) {
output_line(0,"signal from pid %u", pid);
}
@@ -47,17 +47,17 @@ struct event * wait_for_something(void)
continue_process(event.proc->pid);
return &event;
}
- tmp = syscall_p(event.proc, status);
- if (tmp>=0) {
- event.thing = LT_EV_SYSCALL;
- event.e_un.sysnum = tmp;
- return &event;
+ if (opt_i) {
+ event.proc->instruction_pointer = get_instruction_pointer(pid);
}
- tmp = sysret_p(event.proc, status);
- if (tmp>=0) {
- event.thing = LT_EV_SYSRET;
- event.e_un.sysnum = tmp;
- return &event;
+ switch(syscall_p(event.proc, status, &tmp)) {
+ case 1: event.thing = LT_EV_SYSCALL;
+ event.e_un.sysnum = tmp;
+ return &event;
+ case 2: event.thing = LT_EV_SYSRET;
+ event.e_un.sysnum = tmp;
+ return &event;
+ default:
}
if (WIFEXITED(status)) {
event.thing = LT_EV_EXIT;
@@ -79,6 +79,9 @@ struct event * wait_for_something(void)
return &event;
}
event.thing = LT_EV_BREAKPOINT;
+ if (!event.proc->instruction_pointer) {
+ event.proc->instruction_pointer = get_instruction_pointer(pid);
+ }
event.e_un.brk_addr = event.proc->instruction_pointer - DECR_PC_AFTER_BREAK;
return &event;
}