Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions | Variables
kgdb.c File Reference
#include <linux/spinlock.h>
#include <linux/kdebug.h>
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/ptrace.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/kgdb.h>
#include <linux/init.h>
#include <linux/smp.h>
#include <linux/nmi.h>
#include <linux/hw_breakpoint.h>
#include <linux/uaccess.h>
#include <linux/memory.h>
#include <asm/debugreg.h>
#include <asm/apicdef.h>
#include <asm/apic.h>
#include <asm/nmi.h>

Go to the source code of this file.

Data Structures

struct  hw_breakpoint
 

Functions

int dbg_set_reg (int regno, void *mem, struct pt_regs *regs)
 
chardbg_get_reg (int regno, void *mem, struct pt_regs *regs)
 
void sleeping_thread_to_gdb_regs (unsigned long *gdb_regs, struct task_struct *p)
 
int kgdb_arch_handle_exception (int e_vector, int signo, int err_code, char *remcomInBuffer, char *remcomOutBuffer, struct pt_regs *linux_regs)
 
int kgdb_ll_trap (int cmd, const char *str, struct pt_regs *regs, long err, int trap, int sig)
 
int kgdb_arch_init (void)
 
void kgdb_arch_late (void)
 
void kgdb_arch_exit (void)
 
int kgdb_skipexception (int exception, struct pt_regs *regs)
 
unsigned long kgdb_arch_pc (int exception, struct pt_regs *regs)
 
void kgdb_arch_set_pc (struct pt_regs *regs, unsigned long ip)
 
int kgdb_arch_set_breakpoint (struct kgdb_bkpt *bpt)
 
int kgdb_arch_remove_breakpoint (struct kgdb_bkpt *bpt)
 

Variables

struct dbg_reg_def_t dbg_reg_def [DBG_MAX_REG_NUM]
 
struct kgdb_arch arch_kgdb_ops
 

Function Documentation

char* dbg_get_reg ( int  regno,
void mem,
struct pt_regs regs 
)

Definition at line 114 of file kgdb.c.

int dbg_set_reg ( int  regno,
void mem,
struct pt_regs regs 
)

Definition at line 99 of file kgdb.c.

void kgdb_arch_exit ( void  )

kgdb_arch_exit - Perform any architecture specific uninitalization.

This function will handle the uninitalization of any architecture specific callbacks, for dynamic registration and unregistration.

Definition at line 698 of file kgdb.c.

int kgdb_arch_handle_exception ( int  e_vector,
int  signo,
int  err_code,
char remcomInBuffer,
char remcomOutBuffer,
struct pt_regs linux_regs 
)

kgdb_arch_handle_exception - Handle architecture specific GDB packets. : The error vector of the exception that happened. : The signal number of the exception that happened. : The error code of the exception that happened. : The buffer of the packet we have read. : The buffer of BUFMAX bytes to write a packet into. : The &struct pt_regs of the current process.

This function MUST handle the 'c' and 's' command packets, as well packets to set / remove a hardware breakpoint, if used. If there are additional packets which the hardware needs to handle, they are handled here. The code should return -1 if it wants to process more packets, and a %0 or %1 if it wants to exit from the kgdb callback.

Definition at line 461 of file kgdb.c.

int kgdb_arch_init ( void  )

kgdb_arch_init - Perform any architecture specific initalization.

This function will handle the initalization of any architecture specific callbacks.

Definition at line 613 of file kgdb.c.

void kgdb_arch_late ( void  )

Definition at line 653 of file kgdb.c.

unsigned long kgdb_arch_pc ( int  exception,
struct pt_regs regs 
)

Definition at line 734 of file kgdb.c.

int kgdb_arch_remove_breakpoint ( struct kgdb_bkpt *  bpt)

Definition at line 781 of file kgdb.c.

int kgdb_arch_set_breakpoint ( struct kgdb_bkpt *  bpt)

Definition at line 746 of file kgdb.c.

void kgdb_arch_set_pc ( struct pt_regs regs,
unsigned long  ip 
)

Definition at line 741 of file kgdb.c.

int kgdb_ll_trap ( int  cmd,
const char str,
struct pt_regs regs,
long  err,
int  trap,
int  sig 
)

Definition at line 572 of file kgdb.c.

int kgdb_skipexception ( int  exception,
struct pt_regs regs 
)

kgdb_skipexception - Bail out of KGDB when we've been triggered.

Exceptions
Exception vector number : Current &struct pt_regs.

On some architectures we need to skip a breakpoint exception when it occurs after a breakpoint has been removed.

Skip an int3 exception when it occurs after a breakpoint has been removed. Backtrack eip by 1 since the int3 would have caused it to increment by 1.

Definition at line 725 of file kgdb.c.

void sleeping_thread_to_gdb_regs ( unsigned long gdb_regs,
struct task_struct p 
)

sleeping_thread_to_gdb_regs - Convert ptrace regs to GDB regs : A pointer to hold the registers in the order GDB wants. : The &struct task_struct of the desired process.

Convert the register values of the sleeping process in to the format that GDB expects. This function is called when kgdb does not have access to the &struct pt_regs and therefore it should fill the gdb registers with what has been saved in &struct thread_struct thread field during switch_to.

Definition at line 158 of file kgdb.c.

Variable Documentation

struct kgdb_arch arch_kgdb_ops
Initial value:
= {
.gdb_bpt_instr = { 0xcc },
.flags = KGDB_HW_BREAKPOINT,
.set_hw_breakpoint = kgdb_set_hw_break,
.remove_hw_breakpoint = kgdb_remove_hw_break,
.disable_hw_break = kgdb_disable_hw_debug,
.remove_all_hw_break = kgdb_remove_all_hw_break,
.correct_hw_break = kgdb_correct_hw_break,
}

Definition at line 806 of file kgdb.c.

struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM]

Definition at line 54 of file kgdb.c.