Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb:
  kgdbts: Use HW breakpoints with CONFIG_DEBUG_RODATA
  kgdb: use common ascii helpers and put_unaligned_be32 helper
This commit is contained in:
Linus Torvalds 2008-06-04 08:08:27 -07:00
commit 3b5b60b821
2 changed files with 32 additions and 17 deletions

View File

@ -102,7 +102,6 @@
#include <linux/nmi.h> #include <linux/nmi.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/delay.h>
#define v1printk(a...) do { \ #define v1printk(a...) do { \
if (verbose) \ if (verbose) \
@ -119,7 +118,6 @@
} while (0) } while (0)
#define MAX_CONFIG_LEN 40 #define MAX_CONFIG_LEN 40
static const char hexchars[] = "0123456789abcdef";
static struct kgdb_io kgdbts_io_ops; static struct kgdb_io kgdbts_io_ops;
static char get_buf[BUFMAX]; static char get_buf[BUFMAX];
static int get_buf_cnt; static int get_buf_cnt;
@ -131,6 +129,8 @@ static int repeat_test;
static int test_complete; static int test_complete;
static int send_ack; static int send_ack;
static int final_ack; static int final_ack;
static int force_hwbrks;
static int hwbreaks_ok;
static int hw_break_val; static int hw_break_val;
static int hw_break_val2; static int hw_break_val2;
#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_SPARC) #if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_SPARC)
@ -234,12 +234,12 @@ static void break_helper(char *bp_type, char *arg, unsigned long vaddr)
static void sw_break(char *arg) static void sw_break(char *arg)
{ {
break_helper("Z0", arg, 0); break_helper(force_hwbrks ? "Z1" : "Z0", arg, 0);
} }
static void sw_rem_break(char *arg) static void sw_rem_break(char *arg)
{ {
break_helper("z0", arg, 0); break_helper(force_hwbrks ? "z1" : "z0", arg, 0);
} }
static void hw_break(char *arg) static void hw_break(char *arg)
@ -619,8 +619,8 @@ static void fill_get_buf(char *buf)
count++; count++;
} }
strcat(get_buf, "#"); strcat(get_buf, "#");
get_buf[count + 2] = hexchars[checksum >> 4]; get_buf[count + 2] = hex_asc_hi(checksum);
get_buf[count + 3] = hexchars[checksum & 0xf]; get_buf[count + 3] = hex_asc_lo(checksum);
get_buf[count + 4] = '\0'; get_buf[count + 4] = '\0';
v2printk("get%i: %s\n", ts.idx, get_buf); v2printk("get%i: %s\n", ts.idx, get_buf);
} }
@ -781,6 +781,8 @@ static void run_breakpoint_test(int is_hw_breakpoint)
return; return;
eprintk("kgdbts: ERROR %s test failed\n", ts.name); eprintk("kgdbts: ERROR %s test failed\n", ts.name);
if (is_hw_breakpoint)
hwbreaks_ok = 0;
} }
static void run_hw_break_test(int is_write_test) static void run_hw_break_test(int is_write_test)
@ -798,9 +800,11 @@ static void run_hw_break_test(int is_write_test)
kgdb_breakpoint(); kgdb_breakpoint();
hw_break_val_access(); hw_break_val_access();
if (is_write_test) { if (is_write_test) {
if (test_complete == 2) if (test_complete == 2) {
eprintk("kgdbts: ERROR %s broke on access\n", eprintk("kgdbts: ERROR %s broke on access\n",
ts.name); ts.name);
hwbreaks_ok = 0;
}
hw_break_val_write(); hw_break_val_write();
} }
kgdb_breakpoint(); kgdb_breakpoint();
@ -809,6 +813,7 @@ static void run_hw_break_test(int is_write_test)
return; return;
eprintk("kgdbts: ERROR %s test failed\n", ts.name); eprintk("kgdbts: ERROR %s test failed\n", ts.name);
hwbreaks_ok = 0;
} }
static void run_nmi_sleep_test(int nmi_sleep) static void run_nmi_sleep_test(int nmi_sleep)
@ -912,6 +917,7 @@ static void kgdbts_run_tests(void)
/* All HW break point tests */ /* All HW break point tests */
if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) { if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) {
hwbreaks_ok = 1;
v1printk("kgdbts:RUN hw breakpoint test\n"); v1printk("kgdbts:RUN hw breakpoint test\n");
run_breakpoint_test(1); run_breakpoint_test(1);
v1printk("kgdbts:RUN hw write breakpoint test\n"); v1printk("kgdbts:RUN hw write breakpoint test\n");
@ -925,6 +931,19 @@ static void kgdbts_run_tests(void)
run_nmi_sleep_test(nmi_sleep); run_nmi_sleep_test(nmi_sleep);
} }
#ifdef CONFIG_DEBUG_RODATA
/* Until there is an api to write to read-only text segments, use
* HW breakpoints for the remainder of any tests, else print a
* failure message if hw breakpoints do not work.
*/
if (!(arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT && hwbreaks_ok)) {
eprintk("kgdbts: HW breakpoints do not work,"
"skipping remaining tests\n");
return;
}
force_hwbrks = 1;
#endif /* CONFIG_DEBUG_RODATA */
/* If the do_fork test is run it will be the last test that is /* If the do_fork test is run it will be the last test that is
* executed because a kernel thread will be spawned at the very * executed because a kernel thread will be spawned at the very
* end to unregister the debug hooks. * end to unregister the debug hooks.

View File

@ -52,6 +52,7 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <asm/atomic.h> #include <asm/atomic.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/unaligned.h>
static int kgdb_break_asap; static int kgdb_break_asap;
@ -227,8 +228,6 @@ void __weak kgdb_disable_hw_debug(struct pt_regs *regs)
* GDB remote protocol parser: * GDB remote protocol parser:
*/ */
static const char hexchars[] = "0123456789abcdef";
static int hex(char ch) static int hex(char ch)
{ {
if ((ch >= 'a') && (ch <= 'f')) if ((ch >= 'a') && (ch <= 'f'))
@ -316,8 +315,8 @@ static void put_packet(char *buffer)
} }
kgdb_io_ops->write_char('#'); kgdb_io_ops->write_char('#');
kgdb_io_ops->write_char(hexchars[checksum >> 4]); kgdb_io_ops->write_char(hex_asc_hi(checksum));
kgdb_io_ops->write_char(hexchars[checksum & 0xf]); kgdb_io_ops->write_char(hex_asc_lo(checksum));
if (kgdb_io_ops->flush) if (kgdb_io_ops->flush)
kgdb_io_ops->flush(); kgdb_io_ops->flush();
@ -478,8 +477,8 @@ static void error_packet(char *pkt, int error)
{ {
error = -error; error = -error;
pkt[0] = 'E'; pkt[0] = 'E';
pkt[1] = hexchars[(error / 10)]; pkt[1] = hex_asc[(error / 10)];
pkt[2] = hexchars[(error % 10)]; pkt[2] = hex_asc[(error % 10)];
pkt[3] = '\0'; pkt[3] = '\0';
} }
@ -510,10 +509,7 @@ static void int_to_threadref(unsigned char *id, int value)
scan = (unsigned char *)id; scan = (unsigned char *)id;
while (i--) while (i--)
*scan++ = 0; *scan++ = 0;
*scan++ = (value >> 24) & 0xff; put_unaligned_be32(value, scan);
*scan++ = (value >> 16) & 0xff;
*scan++ = (value >> 8) & 0xff;
*scan++ = (value & 0xff);
} }
static struct task_struct *getthread(struct pt_regs *regs, int tid) static struct task_struct *getthread(struct pt_regs *regs, int tid)