Barrelfish
Macros | Functions
gdb_stub.c File Reference

Architecture-independent parts of in-kernel GDB stub. More...

Macros

#define DEBUG_ENABLED   true
 Flag. Enables debug messages from the stub itself.
 
#define DEBUG(...)
 Quick-and-dirty debug message macro.
 
#define BUFMAX   512
 Defines the maximum number of characters in in/outbound buffers. More...
 

Functions

void gdb_stub_entry (int signal_code, char *OPT NTS init_message)
 Generic entry point to the GDB stub. More...
 

Detailed Description

Architecture-independent parts of in-kernel GDB stub.

This file implements the kernel-side GDB stubs for remote debugging when running on hardware. It is loosely based on the public domain i386-stub.c which is part of the GDB sources.

The following gdb commands are supported:

commandfunctionReturn value
?What was the last sigval ?SNN (signal NN)
greturn the value of the CPU registershex data or ENN
Gset the value of the CPU registersOK or ENN
pread the value of a single CPU registerhex data or ENN
Pset the value of a single CPU registerOK or ENN
mAA..AA,LLLLRead LLLL bytes at address AA..AAhex data or ENN
MAA..AA,LLLL:Write LLLL bytes at address AA.AAOK or ENN
cResume at current addressSNN (signal NN)
cAA..AAContinue at address AA..AASNN
sStep one instructionSNN
sAA..AAStep one instruction from AA..AASNN
DGDB detached – attempt to resume(no reply)
kkill – reboots the system(no reply)

All commands and responses are sent with a packet which includes a checksum. A packet consists of $<packet info>#<checksum> where:

When a packet is received, it is first acknowledged with either '+' or '-'. '+' indicates a successful transfer. '-' indicates a failed transfer.

Example:

Macro Definition Documentation

#define BUFMAX   512

Defines the maximum number of characters in in/outbound buffers.

At least NUMREGBYTES * 2 are needed for register packets.

Function Documentation

void gdb_stub_entry ( int  signal_code,
char *OPT NTS  init_message 
)

Generic entry point to the GDB stub.

Wait for a remote GDB to start talking to us, and then service its requests. This function should run on a different stack the main kernel, and does not return.

Parameters
signal_codeUnix-style signal value indicating reason for interruption
init_messageOptional initial message to send to the remote GDB