From c3946c92243406eff4aff274c8d297b34277330c Mon Sep 17 00:00:00 2001
From: ch <ch>
Date: Wed, 4 Apr 1990 18:26:15 +0000
Subject: [PATCH] Added backtrace.

---
 ldb/Makefile.orig |  4 ++--
 ldb/monitor.c     | 20 +++++++++++++++++++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ldb/Makefile.orig b/ldb/Makefile.orig
index 954ca7379..0d762a28e 100644
--- a/ldb/Makefile.orig
+++ b/ldb/Makefile.orig
@@ -1,10 +1,10 @@
-# $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/ldb/Attic/Makefile.orig,v 1.7 1990/03/29 21:17:49 ch Exp $
+# $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/ldb/Attic/Makefile.orig,v 1.8 1990/04/04 18:26:15 ch Exp $
 CFLAGS = -g
 
 OBJS = ldb.o egets.o coreparse.o alloc.o monitor.o print.o \
 	os.o vars.o assem.o parse.o interrupt.o test.o \
 	search.o validate.o gc.o globals.o dynbind.o \
-	regnames.o
+	regnames.o backtrace.o
 
 ldb.map: ldb
 	echo -n 'Map file for ldb version ' > ldb.map
diff --git a/ldb/monitor.c b/ldb/monitor.c
index 379d6ff85..90d92e345 100644
--- a/ldb/monitor.c
+++ b/ldb/monitor.c
@@ -16,6 +16,7 @@
 static void call_cmd(), dump_cmd(), print_cmd(), quit(), help();
 static void flush_cmd(), search_cmd(), regs_cmd(), exit_cmd(), throw_cmd();
 static void timed_call_cmd(), gc_cmd(), print_context_cmd();
+static void backtrace_cmd();
 
 static struct cmd {
     char *cmd, *help;
@@ -23,6 +24,7 @@ static struct cmd {
 } Cmds[] = {
     {"help", "Display this info", help},
     {"?", NULL, help},
+    {"backtrace", "backtrace up to N frames", backtrace_cmd},
     {"call", "call FUNCTION with ARG1, ARG2, ...", call_cmd},
     {"context", "print interrupt context number I.", print_context_cmd},
     {"dump", "dump memory starting at ADDRESS for COUNT words.", dump_cmd},
@@ -376,12 +378,13 @@ struct sigcontext *context;
 static void print_context_cmd(ptr)
 char **ptr;
 {
-	int index;
 	int free;
 
 	free = SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX)>>2;
 	
         if (more_p(ptr)) {
+		int index;
+
 		index = parse_number(ptr);
 
 		if ((index >= 0) && (index < free)) {
@@ -403,6 +406,21 @@ char **ptr;
 	}
 }
 
+static void backtrace_cmd(ptr)
+char **ptr;
+{
+	void backtrace();
+	int n;
+
+        if (more_p(ptr))
+		n = parse_number(ptr);
+	else
+		n = 100;
+	
+	printf("Backtrace:\n");
+	backtrace(n);
+}
+
 static void sub_monitor(csp, bsp)
 lispobj *csp, *bsp;
 {
-- 
GitLab