Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+32 -17
+26 -7
drivers/misc/kgdbts.c
··· 102 102 #include <linux/nmi.h> 103 103 #include <linux/delay.h> 104 104 #include <linux/kthread.h> 105 - #include <linux/delay.h> 106 105 107 106 #define v1printk(a...) do { \ 108 107 if (verbose) \ ··· 118 119 } while (0) 119 120 #define MAX_CONFIG_LEN 40 120 121 121 - static const char hexchars[] = "0123456789abcdef"; 122 122 static struct kgdb_io kgdbts_io_ops; 123 123 static char get_buf[BUFMAX]; 124 124 static int get_buf_cnt; ··· 129 131 static int test_complete; 130 132 static int send_ack; 131 133 static int final_ack; 134 + static int force_hwbrks; 135 + static int hwbreaks_ok; 132 136 static int hw_break_val; 133 137 static int hw_break_val2; 134 138 #if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_SPARC) ··· 234 234 235 235 static void sw_break(char *arg) 236 236 { 237 - break_helper("Z0", arg, 0); 237 + break_helper(force_hwbrks ? "Z1" : "Z0", arg, 0); 238 238 } 239 239 240 240 static void sw_rem_break(char *arg) 241 241 { 242 - break_helper("z0", arg, 0); 242 + break_helper(force_hwbrks ? "z1" : "z0", arg, 0); 243 243 } 244 244 245 245 static void hw_break(char *arg) ··· 619 619 count++; 620 620 } 621 621 strcat(get_buf, "#"); 622 - get_buf[count + 2] = hexchars[checksum >> 4]; 623 - get_buf[count + 3] = hexchars[checksum & 0xf]; 622 + get_buf[count + 2] = hex_asc_hi(checksum); 623 + get_buf[count + 3] = hex_asc_lo(checksum); 624 624 get_buf[count + 4] = '\0'; 625 625 v2printk("get%i: %s\n", ts.idx, get_buf); 626 626 } ··· 781 781 return; 782 782 783 783 eprintk("kgdbts: ERROR %s test failed\n", ts.name); 784 + if (is_hw_breakpoint) 785 + hwbreaks_ok = 0; 784 786 } 785 787 786 788 static void run_hw_break_test(int is_write_test) ··· 800 798 kgdb_breakpoint(); 801 799 hw_break_val_access(); 802 800 if (is_write_test) { 803 - if (test_complete == 2) 801 + if (test_complete == 2) { 804 802 eprintk("kgdbts: ERROR %s broke on access\n", 805 803 ts.name); 804 + hwbreaks_ok = 0; 805 + } 806 806 hw_break_val_write(); 807 807 } 808 808 kgdb_breakpoint(); ··· 813 809 return; 814 810 815 811 eprintk("kgdbts: ERROR %s test failed\n", ts.name); 812 + hwbreaks_ok = 0; 816 813 } 817 814 818 815 static void run_nmi_sleep_test(int nmi_sleep) ··· 917 912 918 913 /* All HW break point tests */ 919 914 if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) { 915 + hwbreaks_ok = 1; 920 916 v1printk("kgdbts:RUN hw breakpoint test\n"); 921 917 run_breakpoint_test(1); 922 918 v1printk("kgdbts:RUN hw write breakpoint test\n"); ··· 930 924 v1printk("kgdbts:RUN NMI sleep %i seconds test\n", nmi_sleep); 931 925 run_nmi_sleep_test(nmi_sleep); 932 926 } 927 + 928 + #ifdef CONFIG_DEBUG_RODATA 929 + /* Until there is an api to write to read-only text segments, use 930 + * HW breakpoints for the remainder of any tests, else print a 931 + * failure message if hw breakpoints do not work. 932 + */ 933 + if (!(arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT && hwbreaks_ok)) { 934 + eprintk("kgdbts: HW breakpoints do not work," 935 + "skipping remaining tests\n"); 936 + return; 937 + } 938 + force_hwbrks = 1; 939 + #endif /* CONFIG_DEBUG_RODATA */ 933 940 934 941 /* If the do_fork test is run it will be the last test that is 935 942 * executed because a kernel thread will be spawned at the very
+6 -10
kernel/kgdb.c
··· 52 52 #include <asm/byteorder.h> 53 53 #include <asm/atomic.h> 54 54 #include <asm/system.h> 55 + #include <asm/unaligned.h> 55 56 56 57 static int kgdb_break_asap; 57 58 ··· 228 227 * GDB remote protocol parser: 229 228 */ 230 229 231 - static const char hexchars[] = "0123456789abcdef"; 232 - 233 230 static int hex(char ch) 234 231 { 235 232 if ((ch >= 'a') && (ch <= 'f')) ··· 315 316 } 316 317 317 318 kgdb_io_ops->write_char('#'); 318 - kgdb_io_ops->write_char(hexchars[checksum >> 4]); 319 - kgdb_io_ops->write_char(hexchars[checksum & 0xf]); 319 + kgdb_io_ops->write_char(hex_asc_hi(checksum)); 320 + kgdb_io_ops->write_char(hex_asc_lo(checksum)); 320 321 if (kgdb_io_ops->flush) 321 322 kgdb_io_ops->flush(); 322 323 ··· 477 478 { 478 479 error = -error; 479 480 pkt[0] = 'E'; 480 - pkt[1] = hexchars[(error / 10)]; 481 - pkt[2] = hexchars[(error % 10)]; 481 + pkt[1] = hex_asc[(error / 10)]; 482 + pkt[2] = hex_asc[(error % 10)]; 482 483 pkt[3] = '\0'; 483 484 } 484 485 ··· 509 510 scan = (unsigned char *)id; 510 511 while (i--) 511 512 *scan++ = 0; 512 - *scan++ = (value >> 24) & 0xff; 513 - *scan++ = (value >> 16) & 0xff; 514 - *scan++ = (value >> 8) & 0xff; 515 - *scan++ = (value & 0xff); 513 + put_unaligned_be32(value, scan); 516 514 } 517 515 518 516 static struct task_struct *getthread(struct pt_regs *regs, int tid)