Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 108595
b: refs/heads/master
c: d3d0ac2
h: refs/heads/master
i:
  108593: 38457da
  108591: 52fd665
v: v3
  • Loading branch information
Robin Getz authored and Bryan Wu committed Aug 6, 2008
1 parent 1ab50cb commit 487dca2
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 36 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: 56f5f59052bb662a77d5ffd6cbe5861a2ef2407c
refs/heads/master: d3d0ac23a308f92fc5e5e2846ca40e7bffa5cec3
88 changes: 53 additions & 35 deletions trunk/arch/blackfin/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,55 @@ bool get_instruction(unsigned short *val, unsigned short *address)
return false;
}

/*
* decode the instruction if we are printing out the trace, as it
* makes things easier to follow, without running it through objdump
* These are the normal instructions which cause change of flow, which
* would be at the source of the trace buffer
*/
void decode_instruction(unsigned short *address)
{
unsigned short opcode;

if (get_instruction(&opcode, address)) {
if (opcode == 0x0010)
printk("RTS");
else if (opcode == 0x0011)
printk("RTI");
else if (opcode == 0x0012)
printk("RTX");
else if (opcode >= 0x0050 && opcode <= 0x0057)
printk("JUMP (P%i)", opcode & 7);
else if (opcode >= 0x0060 && opcode <= 0x0067)
printk("CALL (P%i)", opcode & 7);
else if (opcode >= 0x0070 && opcode <= 0x0077)
printk("CALL (PC+P%i)", opcode & 7);
else if (opcode >= 0x0080 && opcode <= 0x0087)
printk("JUMP (PC+P%i)", opcode & 7);
else if ((opcode >= 0x1000 && opcode <= 0x13FF) || (opcode >= 0x1800 && opcode <= 0x1BFF))
printk("IF !CC JUMP");
else if ((opcode >= 0x1400 && opcode <= 0x17ff) || (opcode >= 0x1c00 && opcode <= 0x1fff))
printk("IF CC JUMP");
else if (opcode >= 0x2000 && opcode <= 0x2fff)
printk("JUMP.S");
else if (opcode >= 0xe080 && opcode <= 0xe0ff)
printk("LSETUP");
else if (opcode >= 0xe200 && opcode <= 0xe2ff)
printk("JUMP.L");
else if (opcode >= 0xe300 && opcode <= 0xe3ff)
printk("CALL pcrel");
else
printk("0x%04x", opcode);
}

}

void dump_bfin_trace_buffer(void)
{
#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
int tflags, i = 0;
char buf[150];
unsigned short val = 0, *addr;
unsigned short *addr;
#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
int j, index;
#endif
Expand All @@ -615,52 +658,25 @@ void dump_bfin_trace_buffer(void)

printk(KERN_NOTICE "Hardware Trace:\n");

#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
printk(KERN_NOTICE "WARNING: Expanded trace turned on - can not trace exceptions\n");
#endif

if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) {
for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) {
decode_address(buf, (unsigned long)bfin_read_TBUF());
printk(KERN_NOTICE "%4i Target : %s\n", i, buf);
addr = (unsigned short *)bfin_read_TBUF();
decode_address(buf, (unsigned long)addr);
printk(KERN_NOTICE " Source : %s ", buf);
if (get_instruction(&val, addr)) {
if (val == 0x0010)
printk("RTS");
else if (val == 0x0011)
printk("RTI");
else if (val == 0x0012)
printk("RTX");
else if (val >= 0x0050 && val <= 0x0057)
printk("JUMP (P%i)", val & 7);
else if (val >= 0x0060 && val <= 0x0067)
printk("CALL (P%i)", val & 7);
else if (val >= 0x0070 && val <= 0x0077)
printk("CALL (PC+P%i)", val & 7);
else if (val >= 0x0080 && val <= 0x0087)
printk("JUMP (PC+P%i)", val & 7);
else if ((val >= 0x1000 && val <= 0x13FF) ||
(val >= 0x1800 && val <= 0x1BFF))
printk("IF !CC JUMP");
else if ((val >= 0x1400 && val <= 0x17ff) ||
(val >= 0x1c00 && val <= 0x1fff))
printk("IF CC JUMP");
else if (val >= 0x2000 && val <= 0x2fff)
printk("JUMP.S");
else if (val >= 0xe080 && val <= 0xe0ff)
printk("LSETUP");
else if (val >= 0xe200 && val <= 0xe2ff)
printk("JUMP.L");
else if (val >= 0xe300 && val <= 0xe3ff)
printk("CALL pcrel");
else
printk("0x%04x", val);
}
decode_instruction(addr);
printk("\n");
}
}

#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
if (trace_buff_offset)
index = trace_buff_offset/4 - 1;
index = trace_buff_offset / 4;
else
index = EXPAND_LEN;

Expand All @@ -672,7 +688,9 @@ void dump_bfin_trace_buffer(void)
if (index < 0 )
index = EXPAND_LEN;
decode_address(buf, software_trace_buff[index]);
printk(KERN_NOTICE " Source : %s\n", buf);
printk(KERN_NOTICE " Source : %s ", buf);
decode_instruction((unsigned short *)software_trace_buff[index]);
printk("\n");
index -= 1;
if (index < 0)
index = EXPAND_LEN;
Expand Down

0 comments on commit 487dca2

Please sign in to comment.