summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1997-07-08 20:33:41 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1997-07-08 20:33:41 +0000
commit2c87ffcf26747c048df7c96109e82be7202cbfff (patch)
tree9708a763461b5a53d91babcb2693a449c4669e29 /sys/arch
parent020889c633ed355d7884ac44f1d42d0ef6dc5bca (diff)
Copyright. Backtrace for non-optimized code from Theo. Will get replaced
son enough.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/alpha/alpha/db_trace.c70
1 files changed, 52 insertions, 18 deletions
diff --git a/sys/arch/alpha/alpha/db_trace.c b/sys/arch/alpha/alpha/db_trace.c
index 86996a3cc71..0873eb30872 100644
--- a/sys/arch/alpha/alpha/db_trace.c
+++ b/sys/arch/alpha/alpha/db_trace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_trace.c,v 1.1 1997/07/06 16:31:14 niklas Exp $ */
+/* $OpenBSD: db_trace.c,v 1.2 1997/07/08 20:33:40 niklas Exp $ */
/*
* Copyright (c) 1997 Niklas Hallqvist. All rights reserverd.
@@ -13,23 +13,20 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * This product includes software developed by Niklas Hallqvist.
+ * 4. 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 REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+ * 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 <sys/types.h>
@@ -37,8 +34,18 @@
#include <machine/db_machdep.h>
+#include <ddb/db_access.h>
+#include <ddb/db_command.h>
+#include <ddb/db_output.h>
+#include <ddb/db_sym.h>
+#include <ddb/db_variables.h>
+#include <ddb/db_extern.h>
#include <ddb/db_interface.h>
+/*
+ * XXX This is not yet functional on optimized code.
+ * However it might be useful for you if you turn off debugging.
+ */
void
db_stack_trace_cmd(addr, have_addr, count, modif)
db_expr_t addr;
@@ -46,5 +53,32 @@ db_stack_trace_cmd(addr, have_addr, count, modif)
db_expr_t count;
char *modif;
{
- printf("trace not implemented yet\n");
+ u_long *frame;
+ int i;
+ db_addr_t pc;
+
+ if (count == -1)
+ count = 65535;
+
+ if (!have_addr)
+ frame = (u_long *)ddb_regs.tf_regs[FRAME_SP];
+ else
+ frame = (u_long *)addr;
+
+ while (count--) {
+ db_printf("frame %p: \n", frame);
+ pc = frame[0];
+ db_printf("%lx(", pc);
+
+ /*
+ * Print first possible arguments... like 6 of 'em.
+ */
+ for (i = 0; i < 6; i++)
+ db_printf("%lx, ", frame[2+i]);
+ db_printf(") at ");
+ db_printsym(pc, DB_STGY_PROC);
+ db_printf("\n");
+
+ frame = (u_long *)frame[1];
+ }
}