[maemo-developers] [maemo-developers] Maemo alarms

From: Ed Bartosh eduard.bartosh at nokia.com
Date: Mon Jul 31 12:39:20 EEST 2006
On Mon, 2006-07-31 at 11:50 +0300, ext Kalle Vahlman wrote:
> 2006/7/31, Ed Bartosh <eduard.bartosh at nokia.com>:
> > On Mon, 2006-07-31 at 11:09 +0300, ext Kalle Vahlman wrote:
> > > 2006/7/31, Ed Bartosh <eduard.bartosh at nokia.com>:
> > > > On Fri, 2006-07-28 at 19:35 +0200, ext Nils Faerber wrote:
> > > > > Jean-Baptiste Note schrieb:
> > > > > > Hi Nils, Chris,
> > > > > Hi!
> > > > >
> > > > > > Chris Lord <chris at openedhand.com> wrote:
> > > > > >> On Fri, 2006-07-28 at 11:33 +0200, Nils Faerber wrote:
> > > > > >>>> Are there any header files/libraries available that provide this
> > > > > >>>> functionality that I'm missing? The Clock application has the
> > > > > >>>> ability to set alarms that wake the device, so it must be
> > > > > >>>> possible.
> > > > > > From the reverse-engineering department, have you straced this Clock
> > > > > > application to have a look at what it does (I don't have a N770, so
> > > > > > this is a very wild guess) ?
> > > > >
> > > > > He ;)
> > > > > Just need to get strace to the device ...
> > > > >
> > > > Any difficulties building strace?
> > > > I can give you a fix for strace-4.5.14-1 if you need it.
> > >
> > > Do you know if there is a reason for it not being available in the
> > > repositories? GDB is, so it's not like there was a "no useful
> > > debugging utils"-policy ;)
> > >
> > I think it's just because strace build was fixed after Maemo release.
> >
> > > And at least building from the debian stable version and upstream
> > > sources did not really work for me as-is (but I didn't really dig
> > > deeper to find out why).
> > >
> > True.
> > I have a fix for strace from the Debian testing version. And it seems to
> > work for me.
> 
> It would be great to get a binary or the fix (or both) available from
> somewhere, would this be possible?
> 
Sure.
Below is the patch for this package:
http://packages.debian.org/testing/utils/strace

Sorry, I have to put it right into the message, because maemo mailman
seems to strip attachments.

diff -ruN strace-4.5.14/configure.ac strace-4.5.14.modified/configure.ac
--- strace-4.5.14/configure.ac	2006-01-12 13:18:27.000000000 +0200
+++ strace-4.5.14.modified/configure.ac	2006-07-31 10:38:40.000000000 +0300
@@ -194,7 +194,10 @@
 AC_CHECK_FUNCS(sigaction strerror strsignal pread sys_siglist _sys_siglist getdents mctl prctl sendmsg inet_ntop if_indextoname)
 AC_CHECK_HEADERS([sys/reg.h sys/filio.h sys/acl.h sys/asynch.h sys/door.h stropts.h sys/conf.h sys/stream.h sys/tihdr.h sys/tiuser.h sys/sysconfig.h ioctls.h sys/ioctl.h sys/ptrace.h termio.h linux/ptrace.h asm/reg.h sys/uio.h sys/aio.h  poll.h sys/poll.h sys/vfs.h asm/sysmips.h linux/utsname.h sys/nscsys.h mqueue.h sys/epoll.h libaio.h], [], [])
 AC_CHECK_HEADERS([linux/icmp.h linux/in6.h linux/netlink.h linux/if_packet.h],
-                 [], [], [#include <linux/socket.h>])
+                 [], [], 
+[#include <linux/types.h>
+#include <bits/sockaddr.h>
+#include <linux/socket.h>])
 AC_CHECK_HEADERS([asm/sigcontext.h], [], [], [#include <signal.h>])
 AC_CHECK_HEADERS([netinet/tcp.h netinet/udp.h],,, [#include <netinet/in.h>])
 
diff -ruN strace-4.5.14/debian/control strace-4.5.14.modified/debian/control
--- strace-4.5.14/debian/control	2006-01-14 02:19:57.000000000 +0200
+++ strace-4.5.14.modified/debian/control	2006-07-31 10:38:40.000000000 +0300
@@ -7,7 +7,7 @@
 Standards-Version: 3.6.2
 
 Package: strace
-Architecture: alpha amd64 arm armeb hppa i386 ia64 m68k mips mipsel powerpc ppc64 s390 s390x sh sparc
+Architecture: alpha amd64 arm armel armeb hppa i386 ia64 m68k mips mipsel powerpc ppc64 s390 s390x sh sparc
 Depends: ${shlibs:Depends}
 Description: A system call tracer
  strace is a system call tracer, i.e. a debugging tool which prints out
@@ -22,7 +22,7 @@
 Package: strace-udeb
 Section: debian-installer
 Priority: extra
-Architecture: alpha amd64 arm armeb hppa i386 ia64 m68k mips mipsel powerpc ppc64 s390 sh sparc
+Architecture: alpha amd64 arm armel armeb hppa i386 ia64 m68k mips mipsel powerpc ppc64 s390 sh sparc
 Depends: ${shlibs:Depends}
 Description: A system call tracer
  strace is a system call tracer, i.e. a debugging tool which prints out
diff -ruN strace-4.5.14/defs.h strace-4.5.14.modified/defs.h
--- strace-4.5.14/defs.h	2006-01-12 12:18:53.000000000 +0200
+++ strace-4.5.14.modified/defs.h	2006-07-31 10:38:40.000000000 +0300
@@ -37,6 +37,39 @@
 #include <features.h>
 #endif
 
+/* Compilation hacks */
+
+#ifndef BITS_PER_LONG
+#define __KERNEL__
+#include <asm/types.h>
+#undef __KERNEL__
+//#define BITS_PER_LONG 32
+#endif
+
+#ifndef DECLARE_BITMAP
+#define BITS_TO_LONGS(bits) \
+        (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
+#define DECLARE_BITMAP(name,bits) \
+	        unsigned long name[BITS_TO_LONGS(bits)]
+#endif
+		
+#ifndef min_t
+#define min_t(type,x,y) \
+        ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
+#endif
+
+#ifndef max_t
+#define max_t(type,x,y) \
+        ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
+#endif
+
+typedef u64 cputime64_t;
+
+#define _STRUCT_TIMESPEC
+#define	_LINUX_TIME_H
+
+/* end of CH */
+		
 #ifdef _LARGEFILE64_SOURCE
 /* This is the macro everything checks before using foo64 names.  */
 # ifndef _LFS64_LARGEFILE
diff -ruN strace-4.5.14/process.c strace-4.5.14.modified/process.c
--- strace-4.5.14/process.c	2005-08-03 14:23:43.000000000 +0300
+++ strace-4.5.14.modified/process.c	2006-07-31 10:38:40.000000000 +0300
@@ -694,6 +694,15 @@
                                    0x100000 | new) < 0)
                        return -1;
        return 0;
+#elif defined(ARM)
+	/* Some kernels support this, some (pre-2.6.16 or so) don't. */
+# ifndef PTRACE_SET_SYSCALL
+# define PTRACE_SET_SYSCALL 23
+# endif
+
+	if (ptrace (PTRACE_SET_SYSCALL, tcp->pid, 0, new) != 0)
+		return -1;
+	return 0;
 #else
 #warning Do not know how to handle change_syscall for this architecture
 #endif /* architecture */
diff -ruN strace-4.5.14/syscall.c strace-4.5.14.modified/syscall.c
--- strace-4.5.14/syscall.c	2006-01-12 12:18:53.000000000 +0200
+++ strace-4.5.14.modified/syscall.c	2006-07-31 10:38:40.000000000 +0300
@@ -1108,10 +1108,17 @@
 				return 0;
 			}
 
-			if ((scno & 0x0ff00000) != 0x0f900000) {
-				fprintf(stderr, "syscall: unknown syscall trap 0x%08lx\n",
-					scno);
-				return -1;
+			/* Handle the EABI syscall convention. We do not
+			bother converting structures between the two
+			ABIs, but basic functionality should work even
+			if strace and the traced program have different ABIs. */
+			if (scno == 0xef000000) {
+				scno = regs.ARM_r7;
+			} else {
+				if ((scno & 0x0ff00000) != 0x0f900000) {
+					fprintf(stderr, "syscall: unknown syscall trap 0x%08lx\n", scno);
+					return -1;
+				}
 			}
 
 			/*
diff -ruN strace-4.5.14/time.c strace-4.5.14.modified/time.c
--- strace-4.5.14/time.c	2005-06-01 22:02:38.000000000 +0300
+++ strace-4.5.14.modified/time.c	2006-07-31 10:38:40.000000000 +0300
@@ -35,6 +35,8 @@
 #include <linux/version.h>
 #include <sys/timex.h>
 #include <linux/ioctl.h>
+#define LINUX_HARDIRQ_H
+#define _LINUX_SCHED_H
 #include <linux/rtc.h>
 #endif /* LINUX */
 



-- 
Ed Bartosh <eduard.bartosh at nokia.com>
Nokia-M/Helsinki

More information about the maemo-developers mailing list