All Projects → real-xinu → xkdb

real-xinu / xkdb

Licence: GPL-3.0 license
Xinu Kernel DeBugger (xkdb) - GDB for Xinu backends

Programming Languages

c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to xkdb

rxinu
Rust implementation of Xinu educational operating system
Stars: ✭ 26 (+36.84%)
Mutual labels:  operating-system, xinu
xinu-avr
the Xinu OS for AVR atmega328p devices (e.g. Arduino)
Stars: ✭ 18 (-5.26%)
Mutual labels:  operating-system, xinu
mocka
Mocka - The complete testing framework for LUA and Nginx
Stars: ✭ 26 (+36.84%)
Mutual labels:  debugger
MeetixOS
An hobby OS written in modern C++20 which aims to be Unix-like. Currently based on EvangelionNG, a GhostOS derived kernel
Stars: ✭ 179 (+842.11%)
Mutual labels:  operating-system
ez-rtos
A micro real-time operating system supporting task switching, delay function, memory allocator and critical section. It is writen on ARM Cortex-M3 assemble language, it runs successfully on STM32F103 MCU.
Stars: ✭ 57 (+200%)
Mutual labels:  operating-system
WormholyForObjectiveC
Network debugging made easy,This network debugging tool is developed based on the swift version of Wormholy.
Stars: ✭ 21 (+10.53%)
Mutual labels:  debugger
purebasic
PureBasic OpenSource Projects
Stars: ✭ 83 (+336.84%)
Mutual labels:  debugger
TempleOS-EE
TempleOS Explorers Edition
Stars: ✭ 45 (+136.84%)
Mutual labels:  operating-system
stackvm
Virtual Machine with a 240x160 VRAM display.
Stars: ✭ 47 (+147.37%)
Mutual labels:  debugger
abanu
Abanu is an operating system written in C#
Stars: ✭ 18 (-5.26%)
Mutual labels:  operating-system
register-rs
Unified interface for type-safe MMIO and CPU register access in Rust
Stars: ✭ 48 (+152.63%)
Mutual labels:  operating-system
CS Offer
后台开发基础知识总结(春招/秋招)
Stars: ✭ 352 (+1752.63%)
Mutual labels:  operating-system
basicdos
A new 8086-based reimagining of PC DOS and BASIC
Stars: ✭ 72 (+278.95%)
Mutual labels:  operating-system
vscode-rdbg
VSCode Ruby rdbg Debugger
Stars: ✭ 102 (+436.84%)
Mutual labels:  debugger
gdbundle
Minimalist plugin manager for GDB and LLDB
Stars: ✭ 72 (+278.95%)
Mutual labels:  debugger
b1m0-dbg
linux debugger
Stars: ✭ 11 (-42.11%)
Mutual labels:  debugger
kwast
Rust operating system running WebAssembly as userspace in ring 0
Stars: ✭ 83 (+336.84%)
Mutual labels:  operating-system
esp-gdbstub
ESP8266 debugging tool
Stars: ✭ 13 (-31.58%)
Mutual labels:  debugger
saturn
A microkernel based operating system developed from scratch. This repository also includes all Saturn services and applications.
Stars: ✭ 21 (+10.53%)
Mutual labels:  operating-system
SDA
SDA is a rich cross-platform tool for reverse engineering that focused firstly on analysis of computer games. I'm trying to create a mix of the Ghidra, Cheat Engine and x64dbg. My tool will combine static and dynamic analysis of programs. Now SDA is being developed.
Stars: ✭ 98 (+415.79%)
Mutual labels:  debugger

Build Status Code Coverage

xkdb

Xinu Kernel DeBugger is a project that allows you to use GDB on remote xinu backends.

Demo

How to Use

Firstly, you need to find the right stub for your architecture. If you don't know the architecture of your Xinu backend board maybe pay more attention in your OS class :) For reference, here is a cheat sheet for Purdue's boards in 2019.

  • Galilelo - x86 / i386

  • Beaglebone Black - ARM

If a stub doesn't exist for your board, please read the instructions in PORTING.

Once you figure this out, you can do one of the following. Either follow the steps below to manually setup XKDB, or, use the tool xkdb_builder. You will need to reference the XKDB folder and your XINU folder in doing so.

  1. Compile appropriate stub into your xinu build

    Move stub/<arch>-stub.c into system/<arch>-stub.c.

    Make the following change in your system/initialize.c file, firstly add these prototypes on the top of the file with the other externs:

    extern void set_debug_traps(); // Add these two function
    extern void breakpoint();      // prototypes

    Next add these two function calls near the bottom of the sysinit() function (changes marked with // comments):

   static  void    sysinit()
   {
   ...
       /* Create a ready list for processes */

       readylist = newqueue();

       set_debug_traps(); // Add these two
       breakpoint();      // function calls here
        
       /* Initialize the real time clock */
    
       clkinit();
   ...
   }
  1. Add debug flag to your xinu Makefile

    Open up compile/Makefile and find the line with the compiler flags, it should look like this: CFLAGS = -march=i586 ...

    Add -g to the CFLAGS variable so it looks along the lines of: CFLAGS = -g -march=i586 -m32 -fno-builtin...

  2. Recompile

    Run make clean, make rebuild and make in order to compile the stub and debug symbols into your xinu image.

  3. Use xkdb.py to connect to a backend board

    Change into your Xinu /compile directory. You can then run xkdb with ~/path/to/xkdb/py-console/xkdb.py

    This will automatically upload the xinu image file and power cycle the backend. Use the --help option view all the options available for xkdb.py

    Tip: Add $HOME/path/to/xkdb/py-console to your PATH variable so you can simply use the command xkdb.py instead of specifying the full path.

    To do that edit your ~/.bashrc and add the line export PATH=${PATH}:$HOME/path/to/xkdb/py-console . If you already have this line to add another path, just add the path next to your list of path seperate by a colon :.

    Then just run . ~/.bashrc or source ~/.bashrc to update your bash profile.

  4. Connect GDB to the backend

    Open up another terminal and run gdb -x ~/.xkdb

    GDB will be unresponsive until the backend is fully booted, then you should see the breakpoint be hit.

Project Structure

  • stub/ - The gdb stub and changes on the Xinu side to act as a remote debugging target.

  • py-console/ - A Python version of the cs-console command, used to establish a connection to the Xinu backends and pipe data in and out through to GDB.

Running Tests

cd py-console

python -m pytest

How does it work?

This project leverages the ability of GDB to debug remote targets using a thin text protocol. The primary purpose of this protocol is to allow the use of GDB on systems where compiling the full debugger is too difficult. A remote host can then drive the debugging session by sending simple commands to the small gdb server.

By equipping a board running Xinu with the GDB stub, we allow a remote host running GDB to debug it. The main problems this project solves are:

  1. Getting the GDB stub to compile on the Xinu source tree.

  2. Augmenting the cs-console command to patch through the GDB protocol to a local instance of GDB.

The final architecture to allow remote debugging then looks like:

+---------+         +------------+
| Galileo | Serial  |    Xinu    |
|  Board  <--------->   Server   |
|         |         |            |
+---------+         +-----^------+
                          |  Network
      +-------------------|-------+
      |  +-----+    +-----v----+  |
      |  | GDB |    |cs-console|  |
      |  |     <---->          |  |
      |  +-----+    +----------+  |
      |      Xinu Workstation     |
      +---------------------------+

In order to allow regular output and the GDB protocol to both be sent through serial, we prefix each GDB message with <STX>G where STX is the ASCII start of text character (\x02). Each message is terminated with <EOT> (end of transmission \x04).

Our re-written version of cs-console does the following:

  • Opens up a server socket that gdb can connect to as a target.

  • Prints output as the original cs-console normally would but upon encountering <STX>G will stop printing and start piping the messages through to gdb.

  • Forward any data sent by gdb through to the galileo board.

Known Issues

  1. Caution when using GDB Plugins with this project

If you choose to do so, expect that they may potentially cause problems that xinu doesn't like. gdb-peda (https://github.com/longld/peda) calls getpid() in the remote process when it starts up, which makes it look like xinu is crashing there. It's not :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].