Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146727
b: refs/heads/master
c: cb3a86c
h: refs/heads/master
i:
  146725: 20bd048
  146723: dca3f43
  146719: 801d479
v: v3
  • Loading branch information
Paul Mundt committed May 8, 2009
1 parent 821a041 commit 146a360
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 233 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1af2fe45fec15bdba446c22b9b602699cdabfc9f
refs/heads/master: cb3a86c89ebdf917b88665f70e06863986fbab5c
8 changes: 0 additions & 8 deletions trunk/arch/sh/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,4 @@ config SH64_SR_WATCH
bool "Debug: set SR.WATCH to enable hardware watchpoints and trace"
depends on SUPERH64

config POOR_MANS_STRACE
bool "Debug: enable rudimentary strace facility"
depends on SUPERH64
help
This option allows system calls to be traced to the console. It also
aids in detecting kernel stack underflow. It is useful for debugging
early-userland problems (e.g. init incurring fatal exceptions.)

endmenu
34 changes: 2 additions & 32 deletions trunk/arch/sh/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ zImage uImage uImage.srec vmlinux.srec: vmlinux

compressed: zImage

archprepare: maketools arch/sh/lib64/syscalltab.h
archprepare: maketools

archclean:
$(Q)$(MAKE) $(clean)=$(boot)
Expand All @@ -205,34 +205,4 @@ define archhelp
@echo ' uImage.srec - Create an S-record for U-Boot'
endef

define filechk_gen-syscalltab
(set -e; \
echo "/*"; \
echo " * DO NOT MODIFY."; \
echo " *"; \
echo " * This file was generated by arch/sh/Makefile"; \
echo " * Any changes will be reverted at build time."; \
echo " */"; \
echo ""; \
echo "#ifndef __SYSCALLTAB_H"; \
echo "#define __SYSCALLTAB_H"; \
echo ""; \
echo "#include <linux/kernel.h>"; \
echo ""; \
echo "struct syscall_info {"; \
echo " const char *name;"; \
echo "} syscall_info_table[] = {"; \
sed -e '/^.*\.long /!d;s// { "/;s/\(\([^/]*\)\/\)\{1\}.*/\2/; \
s/[ \t]*$$//g;s/$$/" },/;s/\("\)sys_/\1/g'; \
echo "};"; \
echo ""; \
echo "#define NUM_SYSCALL_INFO_ENTRIES ARRAY_SIZE(syscall_info_table)";\
echo ""; \
echo "#endif /* __SYSCALLTAB_H */" )
endef

arch/sh/lib64/syscalltab.h: arch/sh/kernel/syscalls_64.S
$(call filechk,gen-syscalltab)

CLEAN_FILES += arch/sh/lib64/syscalltab.h \
include/asm-sh/machtypes.h
CLEAN_FILES += include/asm-sh/machtypes.h
57 changes: 0 additions & 57 deletions trunk/arch/sh/kernel/cpu/sh5/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -812,27 +812,6 @@ no_underflow:
! exceptions
add SP, ZERO, r14

#ifdef CONFIG_POOR_MANS_STRACE
/* We've pushed all the registers now, so only r2-r4 hold anything
* useful. Move them into callee save registers */
or r2, ZERO, r28
or r3, ZERO, r29
or r4, ZERO, r30

/* Preserve r2 as the event code */
movi evt_debug, r3
ori r3, 1, r3
ptabs r3, tr0

or SP, ZERO, r6
getcon TRA, r5
blink tr0, LINK

or r28, ZERO, r2
or r29, ZERO, r3
or r30, ZERO, r4
#endif

/* For syscall and debug race condition, get TRA now */
getcon TRA, r5

Expand Down Expand Up @@ -887,11 +866,6 @@ no_underflow:
*/
.global ret_from_irq
ret_from_irq:
#ifdef CONFIG_POOR_MANS_STRACE
pta evt_debug_ret_from_irq, tr0
ori SP, 0, r2
blink tr0, LINK
#endif
ld.q SP, FRAME_S(FSSR), r6
shlri r6, 30, r6
andi r6, 1, r6
Expand All @@ -905,12 +879,6 @@ ret_from_irq:
ret_from_exception:
preempt_stop()

#ifdef CONFIG_POOR_MANS_STRACE
pta evt_debug_ret_from_exc, tr0
ori SP, 0, r2
blink tr0, LINK
#endif

ld.q SP, FRAME_S(FSSR), r6
shlri r6, 30, r6
andi r6, 1, r6
Expand Down Expand Up @@ -1236,18 +1204,6 @@ syscall_bad:
.global syscall_ret
syscall_ret:
st.q SP, FRAME_R(9), r2 /* Expecting SP back to BASIC frame */

#ifdef CONFIG_POOR_MANS_STRACE
/* nothing useful in registers at this point */

movi evt_debug2, r5
ori r5, 1, r5
ptabs r5, tr0
ld.q SP, FRAME_R(9), r2
or SP, ZERO, r3
blink tr0, LINK
#endif

ld.q SP, FRAME_S(FSPC), r2
addi r2, 4, r2 /* Move PC, being pre-execution event */
st.q SP, FRAME_S(FSPC), r2
Expand All @@ -1268,25 +1224,12 @@ ret_from_fork:
ptabs r5, tr0
blink tr0, LINK

#ifdef CONFIG_POOR_MANS_STRACE
/* nothing useful in registers at this point */

movi evt_debug2, r5
ori r5, 1, r5
ptabs r5, tr0
ld.q SP, FRAME_R(9), r2
or SP, ZERO, r3
blink tr0, LINK
#endif

ld.q SP, FRAME_S(FSPC), r2
addi r2, 4, r2 /* Move PC, being pre-execution event */
st.q SP, FRAME_S(FSPC), r2
pta ret_from_syscall, tr0
blink tr0, ZERO



syscall_allowed:
/* Use LINK to deflect the exit point, default is syscall_ret */
pta syscall_ret, tr0
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/sh/lib64/.gitignore

This file was deleted.

134 changes: 0 additions & 134 deletions trunk/arch/sh/lib64/dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,140 +135,6 @@ void print_itlb(void)
(" =============================================================\n");
}

/* ======================================================================= */

#ifdef CONFIG_POOR_MANS_STRACE

#include "syscalltab.h"

struct ring_node {
int evt;
int ret_addr;
int event;
int tra;
int pid;
unsigned long sp;
unsigned long pc;
};

static struct ring_node event_ring[16];
static int event_ptr = 0;

struct stored_syscall_data {
int pid;
int syscall_number;
};

#define N_STORED_SYSCALLS 16

static struct stored_syscall_data stored_syscalls[N_STORED_SYSCALLS];
static int syscall_next=0;
static int syscall_next_print=0;

void evt_debug(int evt, int ret_addr, int event, int tra, struct pt_regs *regs)
{
int syscallno = tra & 0xff;
unsigned long sp;
unsigned long stack_bottom;
int pid;
struct ring_node *rr;

pid = current->pid;
stack_bottom = (unsigned long) task_stack_page(current);
asm volatile("ori r15, 0, %0" : "=r" (sp));
rr = event_ring + event_ptr;
rr->evt = evt;
rr->ret_addr = ret_addr;
rr->event = event;
rr->tra = tra;
rr->pid = pid;
rr->sp = sp;
rr->pc = regs->pc;

if (sp < stack_bottom + 3092) {
int i, j;
printk("evt_debug : stack underflow report\n");
for (j=0, i = event_ptr; j<16; j++) {
rr = event_ring + i;
printk("evt=%08x event=%08x tra=%08x pid=%5d sp=%08lx pc=%08lx\n",
rr->evt, rr->event, rr->tra, rr->pid, rr->sp, rr->pc);
i--;
i &= 15;
}
panic("STACK UNDERFLOW\n");
}

event_ptr = (event_ptr + 1) & 15;

if ((event == 2) && (evt == 0x160)) {
if (syscallno < NUM_SYSCALL_INFO_ENTRIES) {
/* Store the syscall information to print later. We
* can't print this now - currently we're running with
* SR.BL=1, so we can't take a tlbmiss (which could occur
* in the console drivers under printk).
*
* Just overwrite old entries on ring overflow - this
* is only for last-hope debugging. */
stored_syscalls[syscall_next].pid = current->pid;
stored_syscalls[syscall_next].syscall_number = syscallno;
syscall_next++;
syscall_next &= (N_STORED_SYSCALLS - 1);
}
}
}

static void drain_syscalls(void) {
while (syscall_next_print != syscall_next) {
printk("Task %d: %s()\n",
stored_syscalls[syscall_next_print].pid,
syscall_info_table[stored_syscalls[syscall_next_print].syscall_number].name);
syscall_next_print++;
syscall_next_print &= (N_STORED_SYSCALLS - 1);
}
}

void evt_debug2(unsigned int ret)
{
drain_syscalls();
printk("Task %d: syscall returns %08x\n", current->pid, ret);
}

void evt_debug_ret_from_irq(struct pt_regs *regs)
{
int pid;
struct ring_node *rr;

pid = current->pid;
rr = event_ring + event_ptr;
rr->evt = 0xffff;
rr->ret_addr = 0;
rr->event = 0;
rr->tra = 0;
rr->pid = pid;
rr->pc = regs->pc;
event_ptr = (event_ptr + 1) & 15;
}

void evt_debug_ret_from_exc(struct pt_regs *regs)
{
int pid;
struct ring_node *rr;

pid = current->pid;
rr = event_ring + event_ptr;
rr->evt = 0xfffe;
rr->ret_addr = 0;
rr->event = 0;
rr->tra = 0;
rr->pid = pid;
rr->pc = regs->pc;
event_ptr = (event_ptr + 1) & 15;
}

#endif /* CONFIG_POOR_MANS_STRACE */

/* ======================================================================= */

void show_excp_regs(char *from, int trapnr, int signr, struct pt_regs *regs)
{

Expand Down

0 comments on commit 146a360

Please sign in to comment.