Version: 0.3.18
* Simplified arch-dependent stuff
* Updated list of syscalls and signals to Linux 2.4.18
* Unified coding-style of all function declarations
* Do not indent lines indicating signals, exit codes, etc
* Updated description
* fix off-by-one problem in checking syscall number (Tim Waugh
<twaugh@redhat.com> fixed this problem in RedHat two years ago;
thank you for NOT noticing me...)
diff --git a/sysdeps/linux-gnu/trace.c b/sysdeps/linux-gnu/trace.c
index e9397dd..797fc13 100644
--- a/sysdeps/linux-gnu/trace.c
+++ b/sysdeps/linux-gnu/trace.c
@@ -12,8 +12,8 @@
* (ie, with fork() or clone())
* Returns 0 otherwise.
*/
-int fork_p(int sysnum)
-{
+int
+fork_p(int sysnum) {
return 0
#if defined(__NR_fork)
|| (sysnum == __NR_fork)
@@ -29,45 +29,67 @@
/* Returns 1 if the sysnum may make the process exec other program
*/
-int exec_p(int sysnum)
-{
+int
+exec_p(int sysnum) {
return (sysnum == __NR_execve);
}
-void trace_me(void)
-{
+void
+trace_me(void) {
if (ptrace(PTRACE_TRACEME, 0, 1, 0)<0) {
perror("PTRACE_TRACEME");
exit(1);
}
}
-int trace_pid(pid_t pid)
-{
+int
+trace_pid(pid_t pid) {
if (ptrace(PTRACE_ATTACH, pid, 1, 0) < 0) {
return -1;
}
return 0;
}
-void untrace_pid(pid_t pid)
-{
+void
+untrace_pid(pid_t pid) {
ptrace(PTRACE_DETACH, pid, 1, 0);
}
-void continue_after_signal(pid_t pid, int signum)
-{
+void
+continue_after_signal(pid_t pid, int signum) {
/* We should always trace syscalls to be able to control fork(), clone(), execve()... */
ptrace(PTRACE_SYSCALL, pid, 0, signum);
}
-void continue_process(pid_t pid)
-{
+void
+continue_process(pid_t pid) {
continue_after_signal(pid, 0);
}
-void continue_enabling_breakpoint(pid_t pid, struct breakpoint * sbp)
-{
+void
+continue_enabling_breakpoint(pid_t pid, struct breakpoint * sbp) {
enable_breakpoint(pid, sbp);
continue_process(pid);
}
+
+int
+umovestr(struct process * proc, void * addr, int len, void * laddr) {
+ long a;
+ int i;
+ int offset=0;
+
+ while(offset<len) {
+ a = ptrace(PTRACE_PEEKTEXT, proc->pid, addr+offset, 0);
+ for(i=0; i<sizeof(long); i++) {
+ if (((char*)&a)[i] && offset+i < len) {
+ *(char *)(laddr+offset+i) = ((char*)&a)[i];
+ } else {
+ *(char *)(laddr+offset+i) = '\0';
+ return 0;
+ }
+ }
+ offset += sizeof(long);
+ }
+ *(char *)(laddr+offset) = '\0';
+ return 0;
+}