Version 0.3.21
* Get rid of arch/breakpoint.c; we can do it arch-independent
diff --git a/debian/changelog b/debian/changelog
index 818e8b8..cccfa4a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ltrace (0.3.21) unstable; urgency=low
+
+ * Get rid of arch/breakpoint.c; we can do it arch-independent
+
+ -- Juan Cespedes <cespedes@debian.org> Sun, 3 Mar 2002 02:37:46 +0100
+
ltrace (0.3.20) unstable; urgency=low
* Added s390 port (Timothy R. Fesig <slate@us.ibm.com>)
diff --git a/ltrace.spec b/ltrace.spec
deleted file mode 100644
index 02a9089..0000000
--- a/ltrace.spec
+++ /dev/null
@@ -1,50 +0,0 @@
-%define package ltrace
-%define version 0.3.20
-%define release 1
-%define _mandir /usr/share/man
-Summary: Tracks runtime library calls for dynamically linked executables
-Name: %{package}
-Version: %{version}
-Release: %{release}
-Copyright: GPL
-Group: Development/Debuggers
-ExclusiveArch: arm i386 m68k s390
-Source0: ftp://ftp.debian.org/debian/dists/unstable/main/source/utils/ltrace_%{version}.tar.gz
-Prefix: %{_prefix}
-BuildRoot: /tmp/%{name}-root
-
-%description
-ltrace is a debugging program which runs a specified command until it
-exits. While the command is executing, ltrace intercepts and records
-the dynamic library calls which are called by
-the executed process and the signals received by that process.
-It can also intercept and print the system calls executed by the program.
-
-The program to be traced need not be recompiled for this, so you can
-use it on binaries for which you don't have the source handy.
-
-You should install ltrace if you need a sysadmin tool for tracking the
-execution of processes.
-
-%prep
-%setup -q
-./configure --prefix=/usr
-
-%build
-make
-
-%install
-rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT
-make DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} install
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-%defattr(-,root,root)
-%config /etc/ltrace.conf
-%doc COPYING README TODO BUGS ChangeLog
-/usr/bin/ltrace
-%{_mandir}/ltrace.1
-%changelog
diff --git a/options.h b/options.h
index 282b45b..60ccade 100644
--- a/options.h
+++ b/options.h
@@ -3,6 +3,7 @@
#endif
#include <stdio.h>
+#include <sys/types.h>
extern FILE * output;
extern int opt_a; /* default alignment column for results */
diff --git a/sysdeps/linux-gnu/Makefile b/sysdeps/linux-gnu/Makefile
index ed8b812..cdea9af 100644
--- a/sysdeps/linux-gnu/Makefile
+++ b/sysdeps/linux-gnu/Makefile
@@ -2,7 +2,7 @@
CFLAGS += -I$(TOPDIR)/sysdeps/linux-gnu/$(ARCH)
-OBJ = trace.o proc.o
+OBJ = trace.o proc.o breakpoint.o
all: sysdep.h signalent.h syscallent.h ../sysdep.o
diff --git a/sysdeps/linux-gnu/arm/Makefile b/sysdeps/linux-gnu/arm/Makefile
index f630626..7886d8d 100644
--- a/sysdeps/linux-gnu/arm/Makefile
+++ b/sysdeps/linux-gnu/arm/Makefile
@@ -1,4 +1,4 @@
-OBJ = breakpoint.o trace.o regs.o
+OBJ = trace.o regs.o
all: arch.o
diff --git a/sysdeps/linux-gnu/arm/arch.h b/sysdeps/linux-gnu/arm/arch.h
index 8eda583..8a242e6 100644
--- a/sysdeps/linux-gnu/arm/arch.h
+++ b/sysdeps/linux-gnu/arm/arch.h
@@ -1,4 +1,4 @@
-#define BREAKPOINT_VALUE 0xef9f0001
+#define BREAKPOINT_VALUE { 0x01, 0x00, 0x9f, 0xef }
#define BREAKPOINT_LENGTH 4
/* we don't need to decr the pc; the kernel does it for us! */
#define DECR_PC_AFTER_BREAK 0
diff --git a/sysdeps/linux-gnu/arm/breakpoint.c b/sysdeps/linux-gnu/arm/breakpoint.c
deleted file mode 100644
index f2eed98..0000000
--- a/sysdeps/linux-gnu/arm/breakpoint.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/ptrace.h>
-#include "ltrace.h"
-
-void
-enable_breakpoint(pid_t pid, struct breakpoint * sbp) {
- int a;
-
- a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr, 0);
- sbp->orig_value[0] = a;
- sbp->orig_value[1] = a>>8;
- sbp->orig_value[2] = a>>16;
- sbp->orig_value[3] = a>>24;
- a = BREAKPOINT_VALUE;
- ptrace(PTRACE_POKETEXT, pid, sbp->addr, a);
-}
-
-void
-disable_breakpoint(pid_t pid, const struct breakpoint * sbp) {
- int a;
-
- a = sbp->orig_value[0] + (sbp->orig_value[1]<<8) + (sbp->orig_value[2]<<16) + (sbp->orig_value[3]<<24);
- ptrace(PTRACE_POKETEXT, pid, sbp->addr, a);
-}
diff --git a/sysdeps/linux-gnu/breakpoint.c b/sysdeps/linux-gnu/breakpoint.c
new file mode 100644
index 0000000..e2bd6d7
--- /dev/null
+++ b/sysdeps/linux-gnu/breakpoint.c
@@ -0,0 +1,49 @@
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/ptrace.h>
+#include "arch.h"
+#include "options.h"
+#include "output.h"
+
+static unsigned char break_insn[] = BREAKPOINT_VALUE;
+
+void
+enable_breakpoint(pid_t pid, struct breakpoint * sbp) {
+ int i,j;
+
+ if (opt_d>1) {
+ output_line(0, "enable_breakpoint(%d,0x%08x)", pid, sbp->addr);
+ }
+
+ for(i=0; i < 1+((BREAKPOINT_LENGTH-1)/sizeof(long)); i++) {
+ long a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr + i*sizeof(long), 0);
+ for(j=0; j<sizeof(long) && i*sizeof(long)+j < BREAKPOINT_LENGTH; j++) {
+ unsigned char * bytes = (unsigned char *)&a;
+
+ sbp->orig_value[i*sizeof(long)+j] = bytes[i*sizeof(long)+j];
+ bytes[i*sizeof(long)+j] = break_insn[i*sizeof(long)+j];
+ }
+ ptrace(PTRACE_POKETEXT, pid, sbp->addr + i*sizeof(long), a);
+ }
+}
+
+void
+disable_breakpoint(pid_t pid, const struct breakpoint * sbp) {
+ int i,j;
+
+ if (opt_d>1) {
+ output_line(0, "disable_breakpoint(%d,0x%08x)", pid, sbp->addr);
+ }
+
+ for(i=0; i < 1+((BREAKPOINT_LENGTH-1)/sizeof(long)); i++) {
+ long a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr + i*sizeof(long), 0);
+ for(j=0; j<sizeof(long) && i*sizeof(long)+j < BREAKPOINT_LENGTH; j++) {
+ unsigned char * bytes = (unsigned char *)&a;
+
+ bytes[i*sizeof(long)+j] = sbp->orig_value[i*sizeof(long)+j];
+ }
+ ptrace(PTRACE_POKETEXT, pid, sbp->addr + i*sizeof(long), a);
+ }
+}
diff --git a/sysdeps/linux-gnu/i386/Makefile b/sysdeps/linux-gnu/i386/Makefile
index 2af3c25..4b347a5 100644
--- a/sysdeps/linux-gnu/i386/Makefile
+++ b/sysdeps/linux-gnu/i386/Makefile
@@ -1,4 +1,4 @@
-OBJ = breakpoint.o trace.o regs.o
+OBJ = trace.o regs.o
all: arch.o
diff --git a/sysdeps/linux-gnu/i386/breakpoint.c b/sysdeps/linux-gnu/i386/breakpoint.c
deleted file mode 100644
index 39c1330..0000000
--- a/sysdeps/linux-gnu/i386/breakpoint.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/ptrace.h>
-#include <assert.h>
-#include "ltrace.h"
-#include "options.h"
-#include "output.h"
-
-void
-enable_breakpoint(pid_t pid, struct breakpoint * sbp) {
- int a;
-
- if (opt_d>1) {
- output_line(0, "enable_breakpoint(%d,0x%08x)", pid, sbp->addr);
- }
- a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr, 0);
- assert((a & 0xFF) != 0xCC);
- sbp->orig_value[0] = a & 0xFF;
- a &= 0xFFFFFF00;
- a |= 0xCC;
- ptrace(PTRACE_POKETEXT, pid, sbp->addr, a);
-}
-
-void
-disable_breakpoint(pid_t pid, const struct breakpoint * sbp) {
- int a;
-
- if (opt_d>1) {
- output_line(0, "disable_breakpoint(%d,0x%08x)", pid, sbp->addr);
- }
- a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr, 0);
- assert((a & 0xFF) == 0xCC);
- a &= 0xFFFFFF00;
- a |= sbp->orig_value[0];
- ptrace(PTRACE_POKETEXT, pid, sbp->addr, a);
-}
diff --git a/sysdeps/linux-gnu/m68k/Makefile b/sysdeps/linux-gnu/m68k/Makefile
index 2af3c25..4b347a5 100644
--- a/sysdeps/linux-gnu/m68k/Makefile
+++ b/sysdeps/linux-gnu/m68k/Makefile
@@ -1,4 +1,4 @@
-OBJ = breakpoint.o trace.o regs.o
+OBJ = trace.o regs.o
all: arch.o
diff --git a/sysdeps/linux-gnu/m68k/arch.h b/sysdeps/linux-gnu/m68k/arch.h
index b701e29..a29e5f1 100644
--- a/sysdeps/linux-gnu/m68k/arch.h
+++ b/sysdeps/linux-gnu/m68k/arch.h
@@ -1,3 +1,3 @@
-#define BREAKPOINT_VALUE {0x4e,0x4f}
+#define BREAKPOINT_VALUE { 0x4e, 0x4f }
#define BREAKPOINT_LENGTH 2
#define DECR_PC_AFTER_BREAK 2
diff --git a/sysdeps/linux-gnu/m68k/breakpoint.c b/sysdeps/linux-gnu/m68k/breakpoint.c
deleted file mode 100644
index c74c4d2..0000000
--- a/sysdeps/linux-gnu/m68k/breakpoint.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/ptrace.h>
-#include "ltrace.h"
-
-void
-enable_breakpoint(pid_t pid, struct breakpoint * sbp) {
- int a;
-
- a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr, 0);
- sbp->orig_value[0] = (a & 0xFF000000) >> 24;
- sbp->orig_value[1] = (a & 0x00FF0000) >> 16;
- a &= 0x0000FFFF;
- a |= 0x4E4F0000;
- ptrace(PTRACE_POKETEXT, pid, sbp->addr, a);
-}
-
-void
-disable_breakpoint(pid_t pid, const struct breakpoint * sbp) {
- int a;
-
- a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr, 0);
- a &= 0x0000FFFF;
- a |= (sbp->orig_value[0] << 24) | (sbp->orig_value[1] << 16);
- ptrace(PTRACE_POKETEXT, pid, sbp->addr, a);
-}
diff --git a/sysdeps/linux-gnu/s390/arch.h b/sysdeps/linux-gnu/s390/arch.h
index d37d92b..fc66afb 100644
--- a/sysdeps/linux-gnu/s390/arch.h
+++ b/sysdeps/linux-gnu/s390/arch.h
@@ -3,6 +3,6 @@
** (C) Copyright 2001 IBM Poughkeepsie, IBM Corporation
*/
-#define BREAKPOINT_VALUE 0x00010000
+#define BREAKPOINT_VALUE { 0x00, 0x01 }
#define BREAKPOINT_LENGTH 2
#define DECR_PC_AFTER_BREAK 2
diff --git a/sysdeps/linux-gnu/s390/breakpoint.c b/sysdeps/linux-gnu/s390/breakpoint.c
deleted file mode 100644
index 65c5e8f..0000000
--- a/sysdeps/linux-gnu/s390/breakpoint.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-** S/390 version
-** (C) Copyright 2001 IBM Poughkeepsie, IBM Corporation
-*/
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/ptrace.h>
-#include "ltrace.h"
-#include "s390/arch.h"
-
-void
-enable_breakpoint(pid_t pid, struct breakpoint * sbp) {
- long a;
- long mask1;
- long mask2;
- int shift;
- int i;
-
- mask1 = 0xFF000000;
- mask2 = 0x00000000;
- shift = 24;
-
- a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr, 0);
-
- for( i=0; i < BREAKPOINT_LENGTH; i++ ) {
- sbp->orig_value[i] = (a & mask1) >> shift;
- mask2 |= mask1;
- mask1 = (mask1 >> 8) & 0x00FFFFFF;
- shift -= 8;
- }
- mask2 = ~mask2;
-
- a &= mask2;
- a |= BREAKPOINT_VALUE;
-
- ptrace(PTRACE_POKETEXT, pid, sbp->addr, a);
-}
-
-void
-disable_breakpoint(pid_t pid, const struct breakpoint * sbp) {
- long a;
- long b;
- long mask1;
- long mask2;
- int shift;
- int i;
-
- b = 0x00000000;
- mask1 = 0xFF000000;
- mask2 = 0x00000000;
- shift = 24;
-
- a = ptrace(PTRACE_PEEKTEXT, pid, sbp->addr, 0);
-
- for( i=0; i < BREAKPOINT_LENGTH; i++ ) {
- b |= sbp->orig_value[i] << shift;
- mask2 |= mask1;
- mask1 = (mask1 >> 8) & 0x00FFFFFF;
- shift -= 8;
- }
- mask2 = ~mask2;
-
- a &= mask2;
- a |= b;
-
- ptrace(PTRACE_POKETEXT, pid, sbp->addr, a);
-}