aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Cespedes <cespedes@debian.org>1998-03-11 00:03:00 +0100
committerJuan Cespedes <cespedes@debian.org>1998-03-11 00:03:00 +0100
commitf0fdae9e2444c2fb7764774088c574ab53c787f4 (patch)
tree79ab46d1bcdc4e5f6d7bbb3b3daa86e7c5f21b2c
parente188705c4f1c5c8e377c2438114a99acaeaf8a3a (diff)
downloadltrace-f0fdae9e2444c2fb7764774088c574ab53c787f4.tar.gz
Version 0.2.2
* After a successful execve(), syscalls are now correctly logged
-rw-r--r--BUGS1
-rw-r--r--config_file.c8
-rw-r--r--debian/changelog6
-rw-r--r--ltrace.h3
-rw-r--r--process_event.c18
-rw-r--r--sysdeps/Linux/i386/trace.c20
-rw-r--r--wait_for_something.c15
7 files changed, 57 insertions, 14 deletions
diff --git a/BUGS b/BUGS
index 7f61d96..d7c583f 100644
--- a/BUGS
+++ b/BUGS
@@ -1,4 +1,5 @@
* options -p and -f don't work yet
+* if a program uses `execve()', later syscalls aren't logged correctly
* 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/config_file.c b/config_file.c
index 71e7d3a..1b03465 100644
--- a/config_file.c
+++ b/config_file.c
@@ -73,18 +73,18 @@ struct function * process_line (char * buf) {
int i;
line_no++;
- if (opt_d>1) {
+ if (opt_d>2) {
output_line(0, "Reading line %d of `%s'", line_no, filename);
}
eat_spaces(&str);
fun.return_type = str2type(&str);
if (fun.return_type==LT_PT_UNKNOWN) {
- if (opt_d>1) {
+ if (opt_d>2) {
output_line(0, " Skipping line %d", line_no);
}
return NULL;
}
- if (opt_d>2) {
+ if (opt_d>3) {
output_line(0, " return_type = %d", fun.return_type);
}
eat_spaces(&str);
@@ -153,7 +153,7 @@ void read_config_file(char * file)
struct function * tmp = process_line(buf);
if (tmp) {
- if (opt_d) {
+ if (opt_d > 1) {
output_line(0, "New function: `%s'", tmp->name);
}
tmp->next = list_of_functions;
diff --git a/debian/changelog b/debian/changelog
index d405191..41ef965 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ltrace (0.2.2) unstable; urgency=low
+
+ * After a successful execve(), syscalls are now logged correctly
+
+ -- Juan Cespedes <cespedes@debian.org> Wed, 11 Mar 1998 00:02:35 +0100
+
ltrace (0.2.1) unstable; urgency=low
* Added -u option (run command as other username)
diff --git a/ltrace.h b/ltrace.h
index 54a5ee2..afbceb6 100644
--- a/ltrace.h
+++ b/ltrace.h
@@ -120,7 +120,8 @@ extern void * get_return_addr(int pid, void * stack_pointer);
extern void insert_breakpoint(int pid, struct breakpoint * sbp);
extern void delete_breakpoint(int pid, struct breakpoint * sbp);
extern int child_p(int sysnum);
-extern int syscall_p(pid_t pid, int status);
+extern int syscall_p(struct process * proc, int status);
+extern int sysret_p(struct process * proc, int status);
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/process_event.c b/process_event.c
index 481f1bc..0689a74 100644
--- a/process_event.c
+++ b/process_event.c
@@ -19,18 +19,33 @@ void process_event(struct event * event)
case LT_EV_NONE:
return;
case LT_EV_SIGNAL:
+ if (opt_d>0) {
+ output_line(0, "event: signal (%d)", event->e_un.signum);
+ }
process_signal(event);
return;
case LT_EV_EXIT:
+ if (opt_d>0) {
+ output_line(0, "event: exit (%d)", event->e_un.ret_val);
+ }
process_exit(event);
return;
case LT_EV_EXIT_SIGNAL:
+ if (opt_d>0) {
+ output_line(0, "event: exit signal (%d)", event->e_un.signum);
+ }
process_exit_signal(event);
return;
case LT_EV_SYSCALL:
+ if (opt_d>0) {
+ output_line(0, "event: syscall (%d)", event->e_un.sysnum);
+ }
process_syscall(event);
return;
case LT_EV_SYSRET:
+ if (opt_d>0) {
+ output_line(0, "event: sysret (%d)", event->e_un.sysnum);
+ }
process_sysret(event);
return;
case LT_EV_BREAKPOINT:
@@ -130,6 +145,9 @@ static void process_breakpoint(struct event * event)
{
struct library_symbol * tmp;
+ if (opt_d>1) {
+ output_line(0,"event: breakpoint (0x%08x)", event->e_un.brk_addr);
+ }
if (event->proc->breakpoint_being_enabled) {
continue_enabling_breakpoint(event->proc->pid, event->proc->breakpoint_being_enabled);
event->proc->breakpoint_being_enabled = NULL;
diff --git a/sysdeps/Linux/i386/trace.c b/sysdeps/Linux/i386/trace.c
index b08ae44..8577d0e 100644
--- a/sysdeps/Linux/i386/trace.c
+++ b/sysdeps/Linux/i386/trace.c
@@ -8,11 +8,25 @@
/* Returns syscall number if `pid' stopped because of a syscall.
* Returns -1 otherwise
*/
-int syscall_p(pid_t pid, int status)
+int syscall_p(struct process * proc, int status)
{
if (WIFSTOPPED(status) && WSTOPSIG(status)==SIGTRAP) {
- int tmp = ptrace(PTRACE_PEEKUSER, pid, 4*ORIG_EAX);
- if (tmp>=0) {
+ 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;
}
}
diff --git a/wait_for_something.c b/wait_for_something.c
index 8b0fe1f..1f9a91d 100644
--- a/wait_for_something.c
+++ b/wait_for_something.c
@@ -38,21 +38,24 @@ struct event * wait_for_something(void)
exit(1);
}
event.proc->instruction_pointer = get_instruction_pointer(pid);
- if (opt_d>1) {
+ if (opt_d>2) {
output_line(0,"signal from pid %u", pid);
}
if (event.proc->breakpoints_enabled == -1) {
- if (opt_d>0) {
- output_line(0,"Enabling breakpoints for pid %u...", pid);
- }
enable_all_breakpoints(event.proc);
event.thing = LT_EV_NONE;
continue_process(event.proc->pid);
return &event;
}
- tmp = syscall_p(pid, status);
+ tmp = syscall_p(event.proc, status);
+ if (tmp>=0) {
+ event.thing = LT_EV_SYSCALL;
+ event.e_un.sysnum = tmp;
+ return &event;
+ }
+ tmp = sysret_p(event.proc, status);
if (tmp>=0) {
- event.thing = (event.proc->current_syscall >= 0) ? LT_EV_SYSRET : LT_EV_SYSCALL;
+ event.thing = LT_EV_SYSRET;
event.e_un.sysnum = tmp;
return &event;
}