From 78eb5a7b3cfa8ad6646ea4ac4b46dc4813fa1acb Mon Sep 17 00:00:00 2001 From: rtoy <rtoy> Date: Thu, 23 Dec 2010 22:23:48 +0000 Subject: [PATCH] Fix tracing for NetBSD. Function end breakpoints didn't seem to be working when tracing, for example (declaim (ftype (function (double-float) double-float) fact)) (defun fact (x) (declare (double-float x)) (if (= x 1) 1d0 (* x (fact (1- x))))) lisp/x86-lispregs.h o NetBSD has access to the eflags register lisp/x86-arch.c: o Add some debugging prints (disabled). o The stuff near line 262 about pc-9 pointing to the pushf instruction should be conditioned on SC_EFLAGS because that's what decides whether we insert the pushf instructions for single stepping. --- lisp/x86-arch.c | 12 ++++++++---- lisp/x86-lispregs.h | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/x86-arch.c b/lisp/x86-arch.c index 1c87c1b97..90ff96b8a 100644 --- a/lisp/x86-arch.c +++ b/lisp/x86-arch.c @@ -1,6 +1,6 @@ /* x86-arch.c -*- Mode: C; comment-column: 40 -*- * - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-arch.c,v 1.40 2010/12/22 02:12:52 rtoy Exp $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-arch.c,v 1.41 2010/12/23 22:23:48 rtoy Exp $ * */ @@ -250,6 +250,8 @@ arch_do_displaced_inst(os_context_t * context, unsigned long orig_inst) * single-stepping and stop on the next instruction. */ + DFPRINTF(0, (stderr, "Installing helper instructions\n")); + single_step_save1 = *(pc - 3); single_step_save2 = *(pc - 2); single_step_save3 = *(pc - 1); @@ -260,12 +262,13 @@ arch_do_displaced_inst(os_context_t * context, unsigned long orig_inst) single_stepping = (unsigned int *) pc; -#if !(defined(__linux__) || defined(DARWIN)) +#ifndef SC_EFLAGS /* * pc - 9 points to the pushf instruction that we installed for * the helper. */ + DFPRINTF(0, (stderr, " Setting pc to pushf instruction at %p\n", (void*) ((char*) pc - 9))); SC_PC(context) = (int)((char *) pc - 9); #endif } @@ -277,8 +280,8 @@ sigtrap_handler(HANDLER_ARGS) unsigned int trap; #if 0 - fprintf(stderr, "x86sigtrap: %8x %x\n", - SC_PC(context), *(unsigned char *) (SC_PC(context) - 1)); + fprintf(stderr, "x86sigtrap: %8x %x\n", + SC_PC(context), *(unsigned char *) (SC_PC(context) - 1)); fprintf(stderr, "sigtrap(%d %d %x)\n", signal, CODE(code), context); #endif @@ -295,6 +298,7 @@ sigtrap_handler(HANDLER_ARGS) *(single_stepping - 3) = single_step_save1; *(single_stepping - 2) = single_step_save2; *(single_stepping - 1) = single_step_save3; + DFPRINTF(0, (stderr, "Uninstalling helper instructions\n")); #endif /* diff --git a/lisp/x86-lispregs.h b/lisp/x86-lispregs.h index 0e9735e24..863740924 100644 --- a/lisp/x86-lispregs.h +++ b/lisp/x86-lispregs.h @@ -1,5 +1,5 @@ /* x86-lispregs.h -*- Mode: C; -*- - * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-lispregs.h,v 1.13 2008/12/29 14:40:34 rtoy Rel $ + * $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/lisp/x86-lispregs.h,v 1.14 2010/12/23 22:23:48 rtoy Exp $ */ #ifndef _X86_LISPREGS_H_ @@ -58,6 +58,8 @@ #endif #elif defined(__linux__) #define SC_EFLAGS(sc) ((sc)->uc_mcontext.gregs[REG_EFL]) +#elif defined(__NetBSD__) +#define SC_EFLAGS(sc) ((sc)->uc_mcontext.__gregs[_REG_EFL]) #endif #endif /* _X86_LISPREGS_H_ */ -- GitLab