From: Andrew Morton Signed-off-by: Andrew Morton --- arch/i386/Kconfig.kgdb | 12 arch/i386/kernel/kgdb_stub.c | 903 +++++++++++--------------------- arch/i386/kernel/smp.c | 12 include/asm-i386/kgdb_local.h | 11 4 files changed, 326 insertions(+), 612 deletions(-) diff -puN arch/i386/Kconfig.kgdb~kgdb-remove-NO_CPUS arch/i386/Kconfig.kgdb --- devel/arch/i386/Kconfig.kgdb~kgdb-remove-NO_CPUS 2006-02-27 02:43:39.000000000 -0800 +++ devel-akpm/arch/i386/Kconfig.kgdb 2006-02-27 02:43:39.000000000 -0800 @@ -64,18 +64,6 @@ config KGDB_IRQ correctly and the kernel has interrupts on a control C to the port should cause a break into the kernel debug stub. -config NO_KGDB_CPUS - int "Number of CPUs" - depends on KGDB && SMP - default NR_CPUS - help - - This option sets the number of cpus for kgdb ONLY. It is used - to prune some internal structures so they look "nice" when - displayed with gdb. This is to overcome possibly larger - numbers that may have been entered above. Enter the real - number to get nice clean kgdb_info displays. - config KGDB_TS bool "Enable kgdb time stamp macros?" depends on KGDB diff -puN arch/i386/kernel/kgdb_stub.c~kgdb-remove-NO_CPUS arch/i386/kernel/kgdb_stub.c --- devel/arch/i386/kernel/kgdb_stub.c~kgdb-remove-NO_CPUS 2006-02-27 02:43:39.000000000 -0800 +++ devel-akpm/arch/i386/kernel/kgdb_stub.c 2006-02-27 02:43:39.000000000 -0800 @@ -100,18 +100,23 @@ #define KGDB_VERSION "<20030915.1651.33>" #include #include -#include /* for strcpy */ #include #include +#include +#include + #include #include #include /* for linux pt_regs struct */ #include -#include #include #include -#include #include +#include /* for strcpy */ + +#ifdef CONFIG_SMP +#include +#endif /************************************************************************ * @@ -181,29 +186,21 @@ enum regnames { _EAX, /* 0 */ #define PID_MAX PID_MAX_DEFAULT #ifdef CONFIG_SMP -void smp_send_nmi_allbutself(void); -#define IF_SMP(x) x -#undef MAX_NO_CPUS -#ifndef CONFIG_NO_KGDB_CPUS -#define CONFIG_NO_KGDB_CPUS 2 -#endif -#if CONFIG_NO_KGDB_CPUS > NR_CPUS -#define MAX_NO_CPUS NR_CPUS -#else -#define MAX_NO_CPUS CONFIG_NO_KGDB_CPUS -#endif -#define hold_init hold_on_sstep: 1, -#define MAX_CPU_MASK (unsigned long)((1LL << MAX_NO_CPUS) - 1LL) -#define NUM_CPUS num_online_cpus() +/* + * By using the NMI code instead of a vector we just sneak thru the + * word generator coming out with just what we want. AND it does + * not matter if clustered_apic_mode is set or not. + */ +void smp_send_nmi_allbutself(void) +{ + send_IPI_allbutself(APIC_DM_NMI); +} #else -#define IF_SMP(x) -#define hold_init -#undef MAX_NO_CPUS -#define MAX_NO_CPUS 1 -#define NUM_CPUS 1 +void smp_send_nmi_allbutself(void) +{ +} #endif -#define NOCPU (struct task_struct *)0xbad1fbad -/* *INDENT-OFF* */ + struct kgdb_info { int used_malloc; void *called_from; @@ -211,18 +208,18 @@ struct kgdb_info { int errcode; int vector; int print_debug_info; -#ifdef CONFIG_SMP int hold_on_sstep; struct { volatile struct task_struct *task; int pid; int hold; struct pt_regs *regs; - } cpus_waiting[MAX_NO_CPUS]; -#endif -} kgdb_info = {hold_init print_debug_info:REMOTE_DEBUG, vector:-1}; - -/* *INDENT-ON* */ + } cpus_waiting[NR_CPUS]; +} kgdb_info = { + .hold_on_sstep = 1, + .print_debug_info = REMOTE_DEBUG, + .vector = -1, +}; #define used_m kgdb_info.used_malloc /* @@ -237,30 +234,87 @@ struct kgdb_info { struct { unsigned int esp; int array[LOOKASIDE_SIZE]; -} fn_call_lookaside[MAX_NO_CPUS]; +} fn_call_lookaside[NR_CPUS]; static int trap_cpu; static unsigned int OLD_esp; +static int in_kgdb_console; #define END_OF_LOOKASIDE &fn_call_lookaside[trap_cpu].array[LOOKASIDE_SIZE] #define IF_BIT 0x200 #define TF_BIT 0x100 -#define MALLOC_ROUND 8-1 +static char gdbconbuf[BUFMAX]; -static char malloc_array[MALLOC_MAX]; -IF_SMP(static void to_gdb(const char *mess)); -void * -malloc(int size) +static char *pack_hex_byte(char *pkt, int byte) { + *pkt++ = hexchars[(byte >> 4) & 0xf]; + *pkt++ = hexchars[(byte & 0xf)]; + return pkt; +} - if (size <= (MALLOC_MAX - used_m)) { - int old_used = used_m; - used_m += ((size + MALLOC_ROUND) & (~MALLOC_ROUND)); - return &malloc_array[old_used]; - } else { - return NULL; +static void putpacket(char *buffer) +{ + unsigned char checksum; + int count; + char ch; + + /* $#. */ + do { + if (kgdb_info.print_debug_info) + printk("T:%s\n", buffer); + putDebugChar('$'); + checksum = 0; + count = 0; + + while ((ch = buffer[count])) { + putDebugChar(ch); + checksum += ch; + count += 1; + } + + putDebugChar('#'); + putDebugChar(hexchars[checksum >> 4]); + putDebugChar(hexchars[checksum % 16]); + + } while ((getDebugChar() & 0x7f) != '+'); + +} + +static void kgdb_gdb_message(const char *s, unsigned count) +{ + int i; + int wcount; + char *bufptr; + + /* + * This takes care of NMI while spining out chars to gdb + */ + in_kgdb_console = 1; + gdbconbuf[0] = 'O'; + bufptr = gdbconbuf + 1; + while (count > 0) { + if ((count << 1) > (BUFMAX - 2)) + wcount = (BUFMAX - 2) >> 1; + else + wcount = count; + count -= wcount; + for (i = 0; i < wcount; i++) + bufptr = pack_hex_byte(bufptr, s[i]); + *bufptr = '\0'; + s += wcount; + putpacket(gdbconbuf); } + in_kgdb_console = 0; +} + +static void to_gdb(const char *s) +{ + int count = 0; + + while (s[count] && (count++ < BUFMAX)) + ; + kgdb_gdb_message(s, count); } /* @@ -294,7 +348,7 @@ malloc(int size) */ extern asmlinkage void fn_call_stub(void); extern asmlinkage void fn_rtn_stub(void); -/* *INDENT-OFF* */ + __asm__("fn_rtn_stub:\n\t" "movl %eax,%esp\n\t" "fn_call_stub:\n\t" @@ -308,32 +362,28 @@ __asm__("fn_rtn_stub:\n\t" "popl %ebx\n\t" "popl %ecx\n\t" "iret \n\t"); -/* *INDENT-ON* */ -#define gdb_i386vector kgdb_info.vector -#define gdb_i386errcode kgdb_info.errcode -#define waiting_cpus kgdb_info.cpus_waiting -#define remote_debug kgdb_info.print_debug_info -#define hold_cpu(cpu) kgdb_info.cpus_waiting[cpu].hold + /* gdb locks */ -#ifdef CONFIG_SMP -static int in_kgdb_called; -static spinlock_t waitlocks[MAX_NO_CPUS] = - {[0 ... MAX_NO_CPUS - 1] = SPIN_LOCK_UNLOCKED }; +static spinlock_t waitlocks[NR_CPUS] = + {[0 ... NR_CPUS - 1] = SPIN_LOCK_UNLOCKED }; +volatile struct pt_regs *in_kgdb_here_log[NR_CPUS]; /* * The following array has the thread pointer of each of the "other" * cpus. We make it global so it can be seen by gdb. */ -volatile int in_kgdb_entry_log[MAX_NO_CPUS]; -volatile struct pt_regs *in_kgdb_here_log[MAX_NO_CPUS]; -/* -static spinlock_t continuelocks[MAX_NO_CPUS]; -*/ +volatile int in_kgdb_entry_log[NR_CPUS]; + +#ifdef CONFIG_SMP +static int in_kgdb_called; + spinlock_t kgdb_spinlock = SPIN_LOCK_UNLOCKED; + /* waiters on our spinlock plus us */ static atomic_t spinlock_waiters = ATOMIC_INIT(1); static int spinlock_count = 0; static int spinlock_cpu = 0; + /* * Note we use nested spin locks to account for the case where a break * point is encountered when calling a function by user direction from @@ -341,27 +391,27 @@ static int spinlock_cpu = 0; * Well, yes, but this lets other cpus thru too. Lets add a * cpu id to the lock. */ -#define KGDB_SPIN_LOCK(x) if( spinlock_count == 0 || \ - spinlock_cpu != smp_processor_id()){\ - atomic_inc(&spinlock_waiters); \ - while (! spin_trylock(x)) {\ - in_kgdb(®s);\ - }\ - atomic_dec(&spinlock_waiters); \ - spinlock_count = 1; \ - spinlock_cpu = smp_processor_id(); \ - }else{ \ - spinlock_count++; \ +#define KGDB_SPIN_LOCK(x) if (spinlock_count == 0 || \ + spinlock_cpu != smp_processor_id()){ \ + atomic_inc(&spinlock_waiters); \ + while (! spin_trylock(x)) { \ + in_kgdb(regs); \ + } \ + atomic_dec(&spinlock_waiters); \ + spinlock_count = 1; \ + spinlock_cpu = smp_processor_id();\ + } else { \ + spinlock_count++; \ } -#define KGDB_SPIN_UNLOCK(x) if( --spinlock_count == 0) spin_unlock(x) +#define KGDB_SPIN_UNLOCK(x) if (--spinlock_count == 0) spin_unlock(x) #else unsigned kgdb_spinlock = 0; #define KGDB_SPIN_LOCK(x) --*x #define KGDB_SPIN_UNLOCK(x) ++*x +#define spinlock_count 0 #endif -int -hex(char ch) +static int hex(char ch) { if ((ch >= 'a') && (ch <= 'f')) return (ch - 'a' + 10); @@ -373,8 +423,7 @@ hex(char ch) } /* scan for the sequence $# */ -void -getpacket(char *buffer) +static void getpacket(char *buffer) { unsigned char checksum; unsigned char xmitcsum; @@ -383,7 +432,10 @@ getpacket(char *buffer) char ch; do { - /* wait around for the start character, ignore all other characters */ + /* + * wait around for the start character, ignore all other + * characters + */ while ((ch = (getDebugChar() & 0x7f)) != '$') ; checksum = 0; xmitcsum = -1; @@ -404,17 +456,21 @@ getpacket(char *buffer) if (ch == '#') { xmitcsum = hex(getDebugChar() & 0x7f) << 4; xmitcsum += hex(getDebugChar() & 0x7f); - if ((remote_debug) && (checksum != xmitcsum)) { - printk - ("bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n", - checksum, xmitcsum, buffer); + if ((kgdb_info.print_debug_info) && + (checksum != xmitcsum)) { + printk("bad checksum. My count = 0x%x, " + "sent=0x%x. buf=%s\n", + checksum, xmitcsum, buffer); } if (checksum != xmitcsum) putDebugChar('-'); /* failed checksum */ else { - putDebugChar('+'); /* successful transfer */ - /* if a sequence char is present, reply the sequence ID */ + putDebugChar('+'); /* successful transfer */ + /* + * if a sequence char is present, reply the + * sequence ID + */ if (buffer[2] == ':') { putDebugChar(buffer[0]); putDebugChar(buffer[1]); @@ -427,41 +483,12 @@ getpacket(char *buffer) } } while (checksum != xmitcsum); - if (remote_debug) + if (kgdb_info.print_debug_info) printk("R:%s\n", buffer); } /* send the packet in buffer. */ -void -putpacket(char *buffer) -{ - unsigned char checksum; - int count; - char ch; - - /* $#. */ - do { - if (remote_debug) - printk("T:%s\n", buffer); - putDebugChar('$'); - checksum = 0; - count = 0; - - while ((ch = buffer[count])) { - putDebugChar(ch); - checksum += ch; - count += 1; - } - - putDebugChar('#'); - putDebugChar(hexchars[checksum >> 4]); - putDebugChar(hexchars[checksum % 16]); - - } while ((getDebugChar() & 0x7f) != '+'); - -} - static char remcomInBuffer[BUFMAX]; static char remcomOutBuffer[BUFMAX]; static short error; @@ -469,7 +496,7 @@ static short error; void debug_error(char *format, char *parm) { - if (remote_debug) + if (kgdb_info.print_debug_info) printk(format, parm); } @@ -572,20 +599,24 @@ get_gdb_regs(struct task_struct *p, stru { unsigned long stack_page; int count = 0; - IF_SMP(int i); + if (!p || p == current) { regs_to_gdb_regs(gdb_regs, regs); return; } #ifdef CONFIG_SMP - for (i = 0; i < MAX_NO_CPUS; i++) { - if (p == kgdb_info.cpus_waiting[i].task) { - regs_to_gdb_regs(gdb_regs, - kgdb_info.cpus_waiting[i].regs); - gdb_regs[_ESP] = - (int) &kgdb_info.cpus_waiting[i].regs->esp; + { + int i; - return; + for (i = 0; i < NR_CPUS; i++) { + if (p == kgdb_info.cpus_waiting[i].task) { + regs_to_gdb_regs(gdb_regs, + kgdb_info.cpus_waiting[i].regs); + gdb_regs[_ESP] = + (int) &kgdb_info.cpus_waiting[i].regs->esp; + + return; + } } } #endif @@ -659,12 +690,13 @@ set_char(char *addr, int val, int may_fa *addr = val; } -/* convert the memory pointed to by mem into hex, placing result in buf */ -/* return a pointer to the last char put in buf (null) */ -/* If MAY_FAULT is non-zero, then we should set mem_err in response to - a fault; if zero treat a fault like any other fault in the stub. */ -char * -mem2hex(char *mem, char *buf, int count, int may_fault) +/* + * convert the memory pointed to by mem into hex, placing result in buf + * return a pointer to the last char put in buf (null) + * If MAY_FAULT is non-zero, then we should set mem_err in response to + * a fault; if zero treat a fault like any other fault in the stub. + */ +static char *mem2hex(char *mem, char *buf, int count, int may_fault) { int i; unsigned char ch; @@ -674,13 +706,9 @@ mem2hex(char *mem, char *buf, int count, mem_err = 0; } for (i = 0; i < count; i++) { - /* printk("%lx = ", mem) ; */ - ch = get_char(mem++); - - /* printk("%02x\n", ch & 0xFF) ; */ if (may_fault && mem_err) { - if (remote_debug) + if (kgdb_info.print_debug_info) printk("Mem fault fetching from addr %lx\n", (long) (mem - 1)); *buf = 0; /* truncate buffer */ @@ -700,8 +728,7 @@ mem2hex(char *mem, char *buf, int count, /* NOTE: We use the may fault flag to also indicate if the write is to * the registers (0) or "other" memory (!=0) */ -char * -hex2mem(char *buf, char *mem, int count, int may_fault) +static char *hex2mem(char *buf, char *mem, int count, int may_fault) { int i; unsigned char ch; @@ -716,7 +743,7 @@ hex2mem(char *buf, char *mem, int count, set_char(mem++, ch, may_fault); if (may_fault && mem_err) { - if (remote_debug) + if (kgdb_info.print_debug_info) printk("Mem fault storing to addr %lx\n", (long) (mem - 1)); return (mem); @@ -727,12 +754,7 @@ hex2mem(char *buf, char *mem, int count, return (mem); } -/**********************************************/ -/* WHILE WE FIND NICE HEX CHARS, BUILD AN INT */ -/* RETURN NUMBER OF CHARS PROCESSED */ -/**********************************************/ -int -hexToInt(char **ptr, int *intValue) +static int hexToInt(char **ptr, int *intValue) { int numChars = 0; int hexValue; @@ -753,37 +775,10 @@ hexToInt(char **ptr, int *intValue) return (numChars); } -#define stubhex(h) hex(h) -#ifdef old_thread_list - -static int -stub_unpack_int(char *buff, int fieldlength) -{ - int nibble; - int retval = 0; - - while (fieldlength) { - nibble = stubhex(*buff++); - retval |= nibble; - fieldlength--; - if (fieldlength) - retval = retval << 4; - } - return retval; -} -#endif -static char * -pack_hex_byte(char *pkt, int byte) -{ - *pkt++ = hexchars[(byte >> 4) & 0xf]; - *pkt++ = hexchars[(byte & 0xf)]; - return pkt; -} #define BUF_THREAD_ID_SIZE 16 -static char * -pack_threadid(char *pkt, threadref * id) +static char *pack_threadid(char *pkt, threadref *id) { char *limit; unsigned char *altid; @@ -795,49 +790,22 @@ pack_threadid(char *pkt, threadref * id) return pkt; } -#ifdef old_thread_list -static char * -unpack_byte(char *buf, int *value) -{ - *value = stub_unpack_int(buf, 2); - return buf + 2; -} - -static char * -unpack_threadid(char *inbuf, threadref * id) -{ - char *altref; - char *limit = inbuf + BUF_THREAD_ID_SIZE; - int x, y; - - altref = (char *) id; - - while (inbuf < limit) { - x = stubhex(*inbuf++); - y = stubhex(*inbuf++); - *altref++ = (x << 4) | y; - } - return inbuf; -} -#endif -void -int_to_threadref(threadref * id, int value) +static void int_to_threadref(threadref *id, int value) { unsigned char *scan; + int i; scan = (unsigned char *) id; - { - int i = 4; - while (i--) - *scan++ = 0; - } + i = 4; + while (i--) + *scan++ = 0; *scan++ = (value >> 24) & 0xff; *scan++ = (value >> 16) & 0xff; *scan++ = (value >> 8) & 0xff; *scan++ = (value & 0xff); } -int -int_to_hex_v(unsigned char * id, int value) + +static int int_to_hex_v(unsigned char *id, int value) { unsigned char *start = id; int shift; @@ -853,24 +821,8 @@ int_to_hex_v(unsigned char * id, int val *id++ = '0'; return id - start; } -#ifdef old_thread_list -static int -threadref_to_int(threadref * ref) -{ - int i, value = 0; - unsigned char *scan; - - scan = (char *) ref; - scan += 4; - i = 4; - while (i-- > 0) - value = (value << 8) | ((*scan++) & 0xff); - return value; -} -#endif -static int -cmp_str(char *s1, char *s2, int count) +static int cmp_str(char *s1, char *s2, int count) { while (count--) { if (*s1++ != *s2++) @@ -879,21 +831,15 @@ cmp_str(char *s1, char *s2, int count) return 1; } -#if 1 /* this is a hold over from 2.4 where O(1) was "sometimes" */ extern struct task_struct *kgdb_get_idle(int cpu); #define idle_task(cpu) kgdb_get_idle(cpu) -#else -#define idle_task(cpu) init_tasks[cpu] -#endif extern int kgdb_pid_init_done; -struct task_struct * -getthread(int pid) +struct task_struct *getthread(int pid) { struct task_struct *thread; - if (pid >= PID_MAX && pid <= (PID_MAX + MAX_NO_CPUS)) { - + if (pid >= PID_MAX && pid <= (PID_MAX + NR_CPUS)) { return idle_task(pid - PID_MAX); } else { /* @@ -903,38 +849,32 @@ getthread(int pid) * in the middle of most any lock down). * Still we don't want to call until the table exists! */ - if (kgdb_pid_init_done){ + if (kgdb_pid_init_done) { thread = find_task_by_pid(pid); - if (thread) { + if (thread) return thread; - } } } return NULL; } -/* *INDENT-OFF* */ -struct hw_breakpoint { + +static struct hw_breakpoint { unsigned enabled; unsigned type; unsigned len; unsigned addr; -} breakinfo[4] = { {enabled:0}, - {enabled:0}, - {enabled:0}, - {enabled:0}}; -/* *INDENT-ON* */ +} breakinfo[4]; + unsigned hw_breakpoint_status; -void -correct_hw_break(void) + +static void correct_hw_break(void) { int breakno; int correctit; int breakbit; unsigned dr7; - asm volatile ("movl %%db7, %0\n":"=r" (dr7) - :); - /* *INDENT-OFF* */ + asm volatile ("movl %%db7, %0\n":"=r" (dr7) : ); do { unsigned addr0, addr1, addr2, addr3; asm volatile ("movl %%db0, %0\n" @@ -945,7 +885,6 @@ correct_hw_break(void) "=r"(addr2), "=r"(addr3) :); } while (0); - /* *INDENT-ON* */ correctit = 0; for (breakno = 0; breakno < 3; breakno++) { breakbit = 2 << (breakno << 1); @@ -988,22 +927,19 @@ correct_hw_break(void) } } -int -remove_hw_break(unsigned breakno) +static int remove_hw_break(unsigned breakno) { - if (!breakinfo[breakno].enabled) { + if (!breakinfo[breakno].enabled) return -1; - } breakinfo[breakno].enabled = 0; return 0; } -int -set_hw_break(unsigned breakno, unsigned type, unsigned len, unsigned addr) +static int set_hw_break(unsigned breakno, unsigned type, unsigned len, + unsigned addr) { - if (breakinfo[breakno].enabled) { + if (breakinfo[breakno].enabled) return -1; - } breakinfo[breakno].enabled = 1; breakinfo[breakno].type = type; breakinfo[breakno].len = len; @@ -1012,13 +948,12 @@ set_hw_break(unsigned breakno, unsigned } #ifdef CONFIG_SMP -static int in_kgdb_console = 0; -int -in_kgdb(struct pt_regs *regs) +int in_kgdb(struct pt_regs *regs) { - unsigned flags; + unsigned long flags; int cpu = smp_processor_id(); + in_kgdb_called = 1; if (!spin_is_locked(&kgdb_spinlock)) { if (in_kgdb_here_log[cpu] || /* we are holding this cpu */ @@ -1037,7 +972,7 @@ in_kgdb(struct pt_regs *regs) * to have any resources, like printk() for example. */ - kgdb_local_irq_save(flags); /* only local here, to avoid hanging */ + local_irq_save(flags); /* only local here, to avoid hanging */ /* * log arival of this cpu * The NMI keeps on ticking. Protect against recurring more @@ -1045,7 +980,7 @@ in_kgdb(struct pt_regs *regs) */ in_kgdb_entry_log[cpu]++; in_kgdb_here_log[cpu] = regs; - if (cpu == spinlock_cpu || waiting_cpus[cpu].task) { + if (cpu == spinlock_cpu || kgdb_info.cpus_waiting[cpu].task) { goto exit_in_kgdb; } /* @@ -1061,21 +996,21 @@ in_kgdb(struct pt_regs *regs) if (!spin_is_locked(&kgdb_spinlock)) { goto exit_in_kgdb; } - waiting_cpus[cpu].task = current; - waiting_cpus[cpu].pid = (current->pid) ? : (PID_MAX + cpu); - waiting_cpus[cpu].regs = regs; + kgdb_info.cpus_waiting[cpu].task = current; + kgdb_info.cpus_waiting[cpu].pid = (current->pid) ? : (PID_MAX + cpu); + kgdb_info.cpus_waiting[cpu].regs = regs; spin_unlock_wait(waitlocks + cpu); /* * log departure of this cpu */ - waiting_cpus[cpu].task = 0; - waiting_cpus[cpu].pid = 0; - waiting_cpus[cpu].regs = 0; + kgdb_info.cpus_waiting[cpu].task = 0; + kgdb_info.cpus_waiting[cpu].pid = 0; + kgdb_info.cpus_waiting[cpu].regs = 0; correct_hw_break(); exit_in_kgdb: in_kgdb_here_log[cpu] = 0; - kgdb_local_irq_restore(flags); + local_irq_restore(flags); return 1; /* spin_unlock(continuelocks + smp_processor_id()); @@ -1143,9 +1078,8 @@ printexceptioninfo(int exceptionNo, int * it is always necessary to do a restore_flags before returning * so as to let go of that lock. */ -int -kgdb_handle_exception(int exceptionVector, - int signo, int err_code, struct pt_regs *linux_regs) +int kgdb_handle_exception(int exceptionVector, int signo, int err_code, + struct pt_regs *regs) { struct task_struct *usethread = NULL; struct task_struct *thread_list_start = 0, *thread = NULL; @@ -1155,30 +1089,27 @@ kgdb_handle_exception(int exceptionVecto int newPC; threadref thref; int threadid; - int thread_min = PID_MAX + MAX_NO_CPUS; -#ifdef old_thread_list - int maxthreads; -#endif + int thread_min = PID_MAX + NR_CPUS; int nothreads; unsigned long flags; int gdb_regs[NUMREGBYTES / 4]; int dr6; - IF_SMP(int entry_state = 0); /* 0, ok, 1, no nmi, 2 sync failed */ + int entry_state = 0; /* 0, ok, 1, no nmi, 2 sync failed */ + static long no_idt[2]; #define NO_NMI 1 #define NO_SYNC 2 -#define regs (*linux_regs) #define NUMREGS NUMREGBYTES/4 /* * If the entry is not from the kernel then return to the Linux * trap handler and let it process the interrupt normally. */ - if ((linux_regs->eflags & VM_MASK) || (3 & linux_regs->xcs)) { + if ((regs->eflags & VM_MASK) || (3 & regs->xcs)) { printk("ignoring non-kernel exception\n"); - print_regs(®s); + print_regs(regs); return (0); } - kgdb_local_irq_save(flags); + local_irq_save(flags); /* Get kgdb spinlock */ @@ -1190,27 +1121,15 @@ kgdb_handle_exception(int exceptionVecto * NMI and will wait there for the following spin locks to be * released. */ -#ifdef CONFIG_SMP - -#if 0 - if (cpu_callout_map & ~MAX_CPU_MASK) { - printk("kgdb : too many cpus, possibly not mapped" - " in contiguous space, change MAX_NO_CPUS" - " in kgdb_stub and make new kernel.\n" - " cpu_callout_map is %lx\n", cpu_callout_map); - goto exit_just_unlock; - } -#endif if (spinlock_count == 1) { int time = 0, end_time, dum = 0; int i; - int cpu_logged_in[MAX_NO_CPUS] = {[0 ... MAX_NO_CPUS - 1] = (0) - }; - if (remote_debug) { + int cpu_logged_in[NR_CPUS] = { 0 }; + + if (kgdb_info.print_debug_info) printk("kgdb : cpu %d entry, syncing others\n", smp_processor_id()); - } - for (i = 0; i < MAX_NO_CPUS; i++) { + for (i = 0; i < NR_CPUS; i++) { /* * Use trylock as we may already hold the lock if * we are holding the cpu. Net result is all @@ -1218,7 +1137,7 @@ kgdb_handle_exception(int exceptionVecto */ spin_trylock(&waitlocks[i]); } - for (i = 0; i < MAX_NO_CPUS; i++) + for (i = 0; i < NR_CPUS; i++) cpu_logged_in[i] = 0; /* * Wait for their arrival. We know the watch dog is active if @@ -1233,30 +1152,32 @@ kgdb_handle_exception(int exceptionVecto smp_send_nmi_allbutself(); while (i < num_online_cpus() && time != end_time) { int j; - for (j = 0; j < MAX_NO_CPUS; j++) { - if (waiting_cpus[j].task && + for (j = 0; j < NR_CPUS; j++) { + if (kgdb_info.cpus_waiting[j].task && !cpu_logged_in[j]) { i++; cpu_logged_in[j] = 1; - if (remote_debug) { + if (kgdb_info.print_debug_info) { printk ("kgdb : cpu %d arrived at kgdb\n", j); } break; - } else if (!waiting_cpus[j].task && + } else if (!kgdb_info.cpus_waiting[j].task && !cpu_online(j)) { - waiting_cpus[j].task = NOCPU; + kgdb_info.cpus_waiting[j].task = + (struct task_struct *) + 0xbad1fbad; cpu_logged_in[j] = 1; - waiting_cpus[j].hold = 1; + kgdb_info.cpus_waiting[j].hold = 1; break; } - if (!waiting_cpus[j].task && + if (!kgdb_info.cpus_waiting[j].task && in_kgdb_here_log[j]) { int wait = 100000; while (wait--) ; - if (!waiting_cpus[j].task && + if (!kgdb_info.cpus_waiting[j].task && in_kgdb_here_log[j]) { printk ("kgdb : cpu %d stall" @@ -1264,7 +1185,7 @@ kgdb_handle_exception(int exceptionVecto j); i++; cpu_logged_in[j] = 1; - waiting_cpus[j].task = + kgdb_info.cpus_waiting[j].task = (struct task_struct *) 1; } @@ -1281,28 +1202,10 @@ kgdb_handle_exception(int exceptionVecto if (i < num_online_cpus()) { printk ("kgdb : time out, proceeding without sync\n"); -#if 0 - printk("kgdb : Waiting_cpus: 0 = %d, 1 = %d\n", - waiting_cpus[0].task != 0, - waiting_cpus[1].task != 0); - printk("kgdb : Cpu_logged in: 0 = %d, 1 = %d\n", - cpu_logged_in[0], cpu_logged_in[1]); - printk - ("kgdb : in_kgdb_here_log in: 0 = %d, 1 = %d\n", - in_kgdb_here_log[0] != 0, - in_kgdb_here_log[1] != 0); -#endif entry_state = NO_SYNC; - } else { -#if 0 - int ent = - in_kgdb_entry_log[smp_processor_id()] - - me_in_kgdb; - printk("kgdb : sync after %d entries\n", ent); -#endif } } else { - if (remote_debug) { + if (kgdb_info.print_debug_info) { printk ("kgdb : %d cpus, but watchdog not active\n" "proceeding without locking down other cpus\n", @@ -1311,16 +1214,15 @@ kgdb_handle_exception(int exceptionVecto } } } -#endif - if (remote_debug) { - unsigned long *lp = (unsigned long *) &linux_regs; + if (kgdb_info.print_debug_info) { + unsigned long *lp = (unsigned long *) ®s; printk("handle_exception(exceptionVector=%d, " - "signo=%d, err_code=%d, linux_regs=%p)\n", - exceptionVector, signo, err_code, linux_regs); + "signo=%d, err_code=%d, regs=%p)\n", + exceptionVector, signo, err_code, regs); if (debug_regs) { - print_regs(®s); + print_regs(regs); printk("Stk: %8lx %8lx %8lx %8lx" " %8lx %8lx %8lx %8lx\n", lp[0], lp[1], lp[2], lp[3], @@ -1342,16 +1244,10 @@ kgdb_handle_exception(int exceptionVecto /* Disable hardware debugging while we are in kgdb */ /* Get the debug register status register */ -/* *INDENT-OFF* */ - __asm__("movl %0,%%db7" - : /* no output */ - :"r"(0)); + __asm__("movl %0,%%db7" : /* no output */ :"r"(0)); - asm volatile ("movl %%db6, %0\n" - :"=r" (hw_breakpoint_status) - :); + asm volatile ("movl %%db6, %0\n" :"=r" (hw_breakpoint_status) :); -/* *INDENT-ON* */ switch (exceptionVector) { case 0: /* divide error */ case 1: /* debug exception */ @@ -1388,23 +1284,23 @@ kgdb_handle_exception(int exceptionVecto mem_err_expected = 0; mem_err_cnt++; /* helps in debugging */ /* make valid address */ - regs.eax = (long) &garbage_loc; + regs->eax = (long)&garbage_loc; /* make valid address */ - regs.edx = (long) &garbage_loc; - if (remote_debug) + regs->edx = (long)&garbage_loc; + if (kgdb_info.print_debug_info) printk("Return after memory error: " "mem_err_cnt=%d\n", mem_err_cnt); if (debug_regs) - print_regs(®s); + print_regs(regs); goto exit_kgdb; } break; } - if (remote_debug) + if (kgdb_info.print_debug_info) printk("kgdb : entered kgdb on cpu %d\n", smp_processor_id()); - gdb_i386vector = exceptionVector; - gdb_i386errcode = err_code; + kgdb_info.vector = exceptionVector; + kgdb_info.errcode = err_code; kgdb_info.called_from = __builtin_return_address(0); #ifdef CONFIG_SMP /* @@ -1421,22 +1317,22 @@ kgdb_handle_exception(int exceptionVecto } #endif -/* - * Set up the gdb function call area. - */ + /* + * Set up the gdb function call area. + */ trap_cpu = smp_processor_id(); - OLD_esp = NEW_esp = (int) (&linux_regs->esp); + OLD_esp = NEW_esp = (int)(®s->esp); - IF_SMP(once_again:) +once_again: /* reply to host that an exception has occurred */ - remcomOutBuffer[0] = 'S'; + remcomOutBuffer[0] = 'S'; remcomOutBuffer[1] = hexchars[signo >> 4]; remcomOutBuffer[2] = hexchars[signo % 16]; remcomOutBuffer[3] = 0; putpacket(remcomOutBuffer); - while (1 == 1) { + while (1) { error = 0; remcomOutBuffer[0] = 0; getpacket(remcomInBuffer); @@ -1448,20 +1344,21 @@ kgdb_handle_exception(int exceptionVecto remcomOutBuffer[3] = 0; break; case 'd': - remote_debug = !(remote_debug); /* toggle debug flag */ + kgdb_info.print_debug_info = !(kgdb_info.print_debug_info); /* toggle debug flag */ printk("Remote debug %s\n", - remote_debug ? "on" : "off"); + kgdb_info.print_debug_info ? "on" : "off"); break; case 'g': /* return the value of the CPU registers */ - get_gdb_regs(usethread, ®s, gdb_regs); - mem2hex((char *) gdb_regs, + get_gdb_regs(usethread, regs, gdb_regs); + mem2hex((char *)gdb_regs, remcomOutBuffer, NUMREGBYTES, 0); break; - case 'G': /* set the value of the CPU registers - return OK */ + /* set the value of the CPU registers - return OK */ + case 'G': hex2mem(&remcomInBuffer[1], - (char *) gdb_regs, NUMREGBYTES, 0); + (char *)gdb_regs, NUMREGBYTES, 0); if (!usethread || usethread == current) { - gdb_regs_to_regs(gdb_regs, ®s); + gdb_regs_to_regs(gdb_regs, regs); strcpy(remcomOutBuffer, "OK"); } else { strcpy(remcomOutBuffer, "E00"); @@ -1480,7 +1377,7 @@ kgdb_handle_exception(int exceptionVecto int regno; ptr = &remcomInBuffer[1]; - regs_to_gdb_regs(gdb_regs, ®s); + regs_to_gdb_regs(gdb_regs, regs); if ((!usethread || usethread == current) && hexToInt(&ptr, ®no) && *ptr++ == '=' && (regno >= 0)) { @@ -1488,7 +1385,7 @@ kgdb_handle_exception(int exceptionVecto (regno >= NUMREGS ? _GS : regno); hex2mem(ptr, (char *) &gdb_regs[regno], 4, 0); - gdb_regs_to_regs(gdb_regs, ®s); + gdb_regs_to_regs(gdb_regs, regs); strcpy(remcomOutBuffer, "OK"); break; } @@ -1574,7 +1471,7 @@ kgdb_handle_exception(int exceptionVecto } /* cAA..AA Continue at address AA..AA(optional) */ - /* sAA..AA Step one instruction from AA..AA(optional) */ + /* sAA..AA Step one instruction from AA..AA(optional)*/ /* D detach, reply OK and then continue */ case 'c': case 's': @@ -1584,20 +1481,20 @@ kgdb_handle_exception(int exceptionVecto pc unchanged if no parm */ ptr = &remcomInBuffer[1]; if (hexToInt(&ptr, &addr)) { - if (remote_debug) + if (kgdb_info.print_debug_info) printk("Changing EIP to 0x%x\n", addr); - regs.eip = addr; + regs->eip = addr; } - newPC = regs.eip; + newPC = regs->eip; /* clear the trace bit */ - regs.eflags &= 0xfffffeff; + regs->eflags &= 0xfffffeff; /* set the trace bit if we're stepping */ if (remcomInBuffer[0] == 's') - regs.eflags |= 0x100; + regs->eflags |= 0x100; /* detach is a friendly version of continue. Note that debugging is still enabled (e.g hit control C) @@ -1607,9 +1504,9 @@ kgdb_handle_exception(int exceptionVecto putpacket(remcomOutBuffer); } - if (remote_debug) { + if (kgdb_info.print_debug_info) { printk("Resuming execution\n"); - print_regs(®s); + print_regs(regs); } asm volatile ("movl %%db6, %0\n":"=r" (dr6) :); @@ -1618,7 +1515,7 @@ kgdb_handle_exception(int exceptionVecto if (dr6 & (1 << breakno) && (breakinfo[breakno].type == 0)) { /* Set restore flag */ - regs.eflags |= 0x10000; + regs->eflags |= 0x10000; break; } } @@ -1645,7 +1542,7 @@ kgdb_handle_exception(int exceptionVecto break; remcomOutBuffer[nothreads++] = 'm'; - for (; threadid < PID_MAX + MAX_NO_CPUS; + for (; threadid < PID_MAX + NR_CPUS; threadid++) { thread = getthread(threadid); if (thread) { @@ -1662,59 +1559,13 @@ kgdb_handle_exception(int exceptionVecto break; } } - if (remcomOutBuffer[nothreads - 1] == 'm') { + if (remcomOutBuffer[nothreads - 1] == 'm') remcomOutBuffer[nothreads - 1] = 'l'; - } else { + else nothreads--; - } remcomOutBuffer[nothreads] = 0; break; -#ifdef old_thread_list /* Old thread info request */ - case 'L': - /* List threads */ - thread_list = 2; - thread_list_start = (usethread ? : current); - unpack_byte(remcomInBuffer + 3, &maxthreads); - unpack_threadid(remcomInBuffer + 5, &thref); - do { - int buf_thread_limit = - (BUFMAX - 22) / BUF_THREAD_ID_SIZE; - if (maxthreads > buf_thread_limit) { - maxthreads = buf_thread_limit; - } - } while (0); - remcomOutBuffer[0] = 'q'; - remcomOutBuffer[1] = 'M'; - remcomOutBuffer[4] = '0'; - pack_threadid(remcomOutBuffer + 5, &thref); - - threadid = threadref_to_int(&thref); - for (nothreads = 0; - nothreads < maxthreads && - threadid < PID_MAX + MAX_NO_CPUS; - threadid++) { - thread = getthread(threadid); - if (thread) { - int_to_threadref(&thref, - threadid); - pack_threadid(remcomOutBuffer + - 21 + - nothreads * 16, - &thref); - nothreads++; - if (thread_min > threadid) - thread_min = threadid; - } - } - - if (threadid == PID_MAX + MAX_NO_CPUS) { - remcomOutBuffer[4] = '1'; - } - pack_hex_byte(remcomOutBuffer + 2, nothreads); - remcomOutBuffer[21 + nothreads * 16] = '\0'; - break; -#endif case 'C': /* Current thread id */ remcomOutBuffer[0] = 'Q'; @@ -1725,11 +1576,10 @@ kgdb_handle_exception(int exceptionVecto * idle thread */ for (threadid = PID_MAX; - threadid < PID_MAX + MAX_NO_CPUS; + threadid < PID_MAX + NR_CPUS; threadid++) { if (current == - idle_task(threadid - - PID_MAX)) + idle_task(threadid-PID_MAX)) break; } } @@ -1747,9 +1597,8 @@ kgdb_handle_exception(int exceptionVecto char * nptr; /* Thread extra info */ if (!cmp_str(&remcomInBuffer[2], - "hreadExtraInfo,", 15)) { + "hreadExtraInfo,", 15)) break; - } ptr = &remcomInBuffer[17]; hexToInt(&ptr, &threadid); thread = getthread(threadid); @@ -1759,7 +1608,7 @@ kgdb_handle_exception(int exceptionVecto do { length++; ptr = pack_hex_byte(ptr, *nptr++); - } while (*nptr && length < 16); + } while (*nptr && length < 16); /* * would like that 16 to be the size of * task_struct.comm but don't know the @@ -1808,15 +1657,13 @@ kgdb_handle_exception(int exceptionVecto */ usethread = thread; if ((thread_list == 1) && - (thread == thread_list_start)) { + (thread == thread_list_start)) thread_list = 0; - } if (thread_list && (threadid == thread_min)) { - if (thread == thread_list_start) { + if (thread == thread_list_start) thread_list = 0; - } else { + else thread_list = 1; - } } /* follow through */ case 'c': @@ -1878,21 +1725,15 @@ kgdb_handle_exception(int exceptionVecto putpacket(remcomOutBuffer); /*to_gdb("Rebooting\n"); */ /* triplefault no return from here */ - { - static long no_idt[2]; - __asm__ __volatile__("lidt %0"::"m"(no_idt[0])); - BREAKPOINT; - } - - } /* switch */ - - /* reply to the request */ - putpacket(remcomOutBuffer); - } /* while(1==1) */ + __asm__ __volatile__("lidt %0"::"m"(no_idt[0])); + BREAKPOINT; + } + putpacket(remcomOutBuffer); /* reply to the request */ + } /* * reached by goto only. */ - exit_kgdb: +exit_kgdb: /* * Here is where we set up to trap a gdb function call. NEW_esp * will be changed if we are trying to do this. We handle both @@ -1903,39 +1744,39 @@ kgdb_handle_exception(int exceptionVecto int *ptr = END_OF_LOOKASIDE; if (NEW_esp < OLD_esp) ptr -= (OLD_esp - NEW_esp) / sizeof (int); - *--ptr = linux_regs->eflags; - *--ptr = linux_regs->xcs; - *--ptr = linux_regs->eip; - *--ptr = linux_regs->ecx; - *--ptr = linux_regs->ebx; - *--ptr = linux_regs->eax; - linux_regs->ecx = NEW_esp - (sizeof (int) * 6); - linux_regs->ebx = (unsigned int) END_OF_LOOKASIDE; + *--ptr = regs->eflags; + *--ptr = regs->xcs; + *--ptr = regs->eip; + *--ptr = regs->ecx; + *--ptr = regs->ebx; + *--ptr = regs->eax; + regs->ecx = NEW_esp - (sizeof (int) * 6); + regs->ebx = (unsigned int) END_OF_LOOKASIDE; if (NEW_esp < OLD_esp) { - linux_regs->eip = (unsigned int) fn_call_stub; + regs->eip = (unsigned int) fn_call_stub; } else { - linux_regs->eip = (unsigned int) fn_rtn_stub; - linux_regs->eax = NEW_esp; + regs->eip = (unsigned int) fn_rtn_stub; + regs->eax = NEW_esp; } - linux_regs->eflags &= ~(IF_BIT | TF_BIT); + regs->eflags &= ~(IF_BIT | TF_BIT); } -#ifdef CONFIG_SMP + /* * Release gdb wait locks * Sanity check time. Must have at least one cpu to run. Also single * step must not be done if the current cpu is on hold. */ if (spinlock_count == 1) { - int ss_hold = (regs.eflags & 0x100) && kgdb_info.hold_on_sstep; + int ss_hold = (regs->eflags & 0x100) && + kgdb_info.hold_on_sstep; int cpu_avail = 0; int i; - for (i = 0; i < MAX_NO_CPUS; i++) { + for (i = 0; i < NR_CPUS; i++) { if (!cpu_online(i)) break; - if (!hold_cpu(i)) { + if (!kgdb_info.cpus_waiting[i].hold) cpu_avail = 1; - } } /* * Early in the bring up there will be NO cpus on line... @@ -1944,17 +1785,16 @@ kgdb_handle_exception(int exceptionVecto to_gdb("No cpus unblocked, see 'kgdb_info.hold_cpu'\n"); goto once_again; } - if (hold_cpu(smp_processor_id()) && (regs.eflags & 0x100)) { + if (kgdb_info.cpus_waiting[smp_processor_id()].hold && + (regs->eflags & 0x100)) { to_gdb ("Current cpu must be unblocked to single step\n"); goto once_again; } - if (!(ss_hold)) { - int i; - for (i = 0; i < MAX_NO_CPUS; i++) { - if (!hold_cpu(i)) { + if (!ss_hold) { + for (i = 0; i < NR_CPUS; i++) { + if (!kgdb_info.cpus_waiting[i].hold) spin_unlock(&waitlocks[i]); - } } } else { spin_unlock(&waitlocks[smp_processor_id()]); @@ -1968,68 +1808,22 @@ kgdb_handle_exception(int exceptionVecto * We will stay here till another cpu releases the lock for us. */ spin_unlock_wait(waitlocks + smp_processor_id()); - kgdb_local_irq_restore(flags); + local_irq_restore(flags); return (0); } -#if 0 -exit_just_unlock: -#endif -#endif /* Release kgdb spinlock */ KGDB_SPIN_UNLOCK(&kgdb_spinlock); - kgdb_local_irq_restore(flags); + local_irq_restore(flags); return (0); } -/* this function is used to set up exception handlers for tracing and - * breakpoints. - * This function is not needed as the above line does all that is needed. - * We leave it for backward compatitability... - */ -void -set_debug_traps(void) -{ - /* - * linux_debug_hook is defined in traps.c. We store a pointer - * to our own exception handler into it. - - * But really folks, every hear of labeled common, an old Fortran - * concept. Lots of folks can reference it and it is define if - * anyone does. Only one can initialize it at link time. We do - * this with the hook. See the statement above. No need for any - * executable code and it is ready as soon as the kernel is - * loaded. Very desirable in kernel debugging. - - linux_debug_hook = handle_exception ; - */ - - /* In case GDB is started before us, ack any packets (presumably - "$?#xx") sitting there. - putDebugChar ('+'); - - initialized = 1; - */ -} - -/* This function will generate a breakpoint exception. It is used at the - beginning of a program to sync up with a debugger and can be used - otherwise as a quick means to stop program execution and "break" into - the debugger. */ -/* But really, just use the BREAKPOINT macro. We will handle the int stuff - */ - -#ifdef later /* - * possibly we should not go thru the traps.c code at all? Someday. + * This function will generate a breakpoint exception. It is used at the + * beginning of a program to sync up with a debugger and can be used + * otherwise as a quick means to stop program execution and "break" into + * the debugger. But really, just use the BREAKPOINT macro. We will handle the + * int stuff */ -void -do_kgdb_int3(struct pt_regs *regs, long error_code) -{ - kgdb_handle_exception(3, 5, error_code, regs); - return; -} -#endif -#undef regs #ifdef CONFIG_TRAP_BAD_SYSCALL_EXITS fastcall void sys_call_exit(struct pt_regs *regs) { @@ -2052,49 +1846,6 @@ fastcall void stack_overflow(void) } #endif -#if defined(CONFIG_SMP) || defined(CONFIG_KGDB_CONSOLE) -char gdbconbuf[BUFMAX]; - -static void -kgdb_gdb_message(const char *s, unsigned count) -{ - int i; - int wcount; - char *bufptr; - /* - * This takes care of NMI while spining out chars to gdb - */ - IF_SMP(in_kgdb_console = 1); - gdbconbuf[0] = 'O'; - bufptr = gdbconbuf + 1; - while (count > 0) { - if ((count << 1) > (BUFMAX - 2)) { - wcount = (BUFMAX - 2) >> 1; - } else { - wcount = count; - } - count -= wcount; - for (i = 0; i < wcount; i++) { - bufptr = pack_hex_byte(bufptr, s[i]); - } - *bufptr = '\0'; - s += wcount; - - putpacket(gdbconbuf); - - } - IF_SMP(in_kgdb_console = 0); -} -#endif -#ifdef CONFIG_SMP -static void -to_gdb(const char *s) -{ - int count = 0; - while (s[count] && (count++ < BUFMAX)) ; - kgdb_gdb_message(s, count); -} -#endif #ifdef CONFIG_KGDB_CONSOLE #include #include @@ -2102,11 +1853,10 @@ to_gdb(const char *s) #include #include -void -kgdb_console_write(struct console *co, const char *s, unsigned count) +void kgdb_console_write(struct console *co, const char *s, unsigned count) { - if (gdb_i386vector == -1) { + if (kgdb_info.vector == -1) { /* * We have not yet talked to gdb. What to do... * lets break, on continue we can do the write. @@ -2148,8 +1898,7 @@ static struct console kgdbcons = { */ static int kgdb_console_enabled; -int __init -kgdb_console_init(char *str) +int __init kgdb_console_init(char *str) { if ((strncmp(str, "kgdb", 4) == 0) || (strncmp(str, "gdb", 3) == 0)) { register_console(&kgdbcons); @@ -2157,7 +1906,6 @@ kgdb_console_init(char *str) } return 0; /* let others look at the string */ } - __setup("console=", kgdb_console_init); #ifdef CONFIG_KGDB_USER_CONSOLE @@ -2172,15 +1920,13 @@ static kdev_t kgdb_console_device(struct * space activities. */ -static int -kgdb_consdev_open(struct inode *inode, struct file *file) +static int kgdb_consdev_open(struct inode *inode, struct file *file) { return 0; } -static ssize_t -kgdb_consdev_write(struct file *file, const char *buf, - size_t count, loff_t * ppos) +static ssize_t kgdb_consdev_write(struct file *file, const char *buf, + size_t count, loff_t * ppos) { int size, ret = 0; static char kbuf[128]; @@ -2210,12 +1956,12 @@ kgdb_consdev_write(struct file *file, co return ret; } -struct file_operations kgdb_consdev_fops = { - open:kgdb_consdev_open, - write:kgdb_consdev_write +static struct file_operations kgdb_consdev_fops = { + .open = kgdb_consdev_open, + .write = kgdb_consdev_write, }; -static kdev_t -kgdb_console_device(struct console *c) + +static kdev_t kgdb_console_device(struct console *c) { return MKDEV(TTYAUX_MAJOR, 1); } @@ -2224,8 +1970,7 @@ kgdb_console_device(struct console *c) * This routine gets called from the serial stub in the i386/lib * This is so it is done late in bring up (just before the console open). */ -void -kgdb_console_finit(void) +void kgdb_console_finit(void) { if (kgdb_console_enabled) { char *cptr = cdevname(MKDEV(TTYAUX_MAJOR, 1)); @@ -2300,7 +2045,7 @@ kgdb_tstamp(int line, char *source, int { static spinlock_t ts_spin = SPIN_LOCK_UNLOCKED; int flags; - kgdb_local_irq_save(flags); + local_irq_save(flags); spin_lock(&ts_spin); rdtscll(kgdb_and_then->at_time); #ifdef CONFIG_SMP @@ -2316,7 +2061,7 @@ kgdb_tstamp(int line, char *source, int kgdb_and_then->data1 = data1; kgdb_and_then = &kgdb_data[++kgdb_and_then_count & INDEX_MASK]; spin_unlock(&ts_spin); - kgdb_local_irq_restore(flags); + local_irq_restore(flags); #ifdef CONFIG_PREEMPT #endif @@ -2325,4 +2070,4 @@ kgdb_tstamp(int line, char *source, int #endif typedef int gdb_debug_hook(int exceptionVector, int signo, int err_code, struct pt_regs *linux_regs); -gdb_debug_hook *linux_debug_hook = &kgdb_handle_exception; /* histerical reasons... */ +gdb_debug_hook *linux_debug_hook = &kgdb_handle_exception; diff -puN arch/i386/kernel/smp.c~kgdb-remove-NO_CPUS arch/i386/kernel/smp.c --- devel/arch/i386/kernel/smp.c~kgdb-remove-NO_CPUS 2006-02-27 02:43:39.000000000 -0800 +++ devel-akpm/arch/i386/kernel/smp.c 2006-02-27 02:43:39.000000000 -0800 @@ -468,17 +468,7 @@ void flush_tlb_all(void) { on_each_cpu(do_flush_tlb_all, NULL, 1, 1); } -#ifdef CONFIG_KGDB -/* - * By using the NMI code instead of a vector we just sneak thru the - * word generator coming out with just what we want. AND it does - * not matter if clustered_apic_mode is set or not. - */ -void smp_send_nmi_allbutself(void) -{ - send_IPI_allbutself(APIC_DM_NMI); -} -#endif + /* * this function sends a 'reschedule' IPI to another CPU. * it goes straight through and wastes no time serializing diff -puN include/asm-i386/kgdb_local.h~kgdb-remove-NO_CPUS include/asm-i386/kgdb_local.h --- devel/include/asm-i386/kgdb_local.h~kgdb-remove-NO_CPUS 2006-02-27 02:43:39.000000000 -0800 +++ devel-akpm/include/asm-i386/kgdb_local.h 2006-02-27 02:43:39.000000000 -0800 @@ -83,17 +83,8 @@ tty: (struct tty_struct *)&state, \ IER: SB_IER, \ MCR: SB_MCR} -extern void putDebugChar(int); -/* RTAI support needs us to really stop/start interrupts */ -#define kgdb_sti() __asm__ __volatile__("sti": : :"memory") -#define kgdb_cli() __asm__ __volatile__("cli": : :"memory") -#define kgdb_local_save_flags(x) __asm__ __volatile__(\ - "pushfl ; popl %0":"=g" (x): /* no input */) -#define kgdb_local_irq_restore(x) __asm__ __volatile__(\ - "pushl %0 ; popfl": \ - /* no output */ :"g" (x):"memory", "cc") -#define kgdb_local_irq_save(x) kgdb_local_save_flags(x); kgdb_cli() +extern void putDebugChar(int); #ifdef CONFIG_SERIAL extern void shutdown_for_kgdb(struct async_struct *info); _