extern void set_sortby(const char *);
extern void set_overhead(int);
-extern void print_pc(struct tcb *);
+
+extern bool get_instruction_pointer(struct tcb *, kernel_ulong_t *);
+extern void print_instruction_pointer(struct tcb *);
extern int syscall_entering_decode(struct tcb *);
extern int syscall_entering_trace(struct tcb *, unsigned int *);
--- /dev/null
+/*
+ * Copyright (c) 1999-2018 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "defs.h"
+
+void
+print_instruction_pointer(struct tcb *tcp)
+{
+ kernel_ulong_t ip;
+
+ if (get_instruction_pointer(tcp, &ip)) {
+ tprintf(current_wordsize == 4
+ ? "[%08" PRI_klx "] "
+ : "[%016" PRI_klx "] ", ip);
+ } else {
+ tprints(current_wordsize == 4
+ ? "[????????] "
+ : "[????????????????] ");
+ }
+}
# include "arch_getrval2.c"
#endif
-void
-print_pc(struct tcb *tcp)
-{
-#if defined ARCH_PC_REG
-# define ARCH_GET_PC 0
-#elif defined ARCH_PC_PEEK_ADDR
- kernel_ulong_t pc;
-# define ARCH_PC_REG pc
-# define ARCH_GET_PC upeek(tcp, ARCH_PC_PEEK_ADDR, &pc)
-#else
-# error Neither ARCH_PC_REG nor ARCH_PC_PEEK_ADDR is defined
-#endif
- if (get_regs(tcp) < 0 || ARCH_GET_PC)
- tprints(current_wordsize == 4 ? "[????????] "
- : "[????????????????] ");
- else
- tprintf(current_wordsize == 4
- ? "[%08" PRI_klx "] " : "[%016" PRI_klx "] ",
- (kernel_ulong_t) ARCH_PC_REG);
-}
-
#include "getregs_old.h"
#undef ptrace_getregset_or_getregs
free(ptr);
}
+bool
+get_instruction_pointer(struct tcb *tcp, kernel_ulong_t *ip)
+{
+#if defined ARCH_PC_REG
+ if (get_regs(tcp) < 0)
+ return false;
+ *ip = (kernel_ulong_t) ARCH_PC_REG;
+ return true;
+#elif defined ARCH_PC_PEEK_ADDR
+ if (upeek(tcp, ARCH_PC_PEEK_ADDR, ip) < 0)
+ return false;
+ return true;
+#else
+# error Neither ARCH_PC_REG nor ARCH_PC_PEEK_ADDR is defined
+#endif
+}
+
/*
* Returns:
* 0: "ignore this ptrace stop", syscall_entering_decode() should return a "bail