cbiffle / lilosdbg

Prototype debugger for lilos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lilosdbg: a wee debugger for lilos

Technology Readiness Level: TRL 0 (leaning tower of hacks)

This is a very early prototype of a debugger for lilos, my async embedded operating system. I'm publishing it despite its immaturity to attempt to push the conversation forward on at-rest debugging of futures generated by async fn.

This is built on top of my DWARF program analysis crate, debugdb.

lilosdbg supports lilos 0.3.x and 1.0.0 at this time.

How to use it

lilosdbg currently can't talk directly to your target over SWD, and instead relies on a snapshot on disk. (This is deliberate; I want to make sure we can do snapshot / postmortem debugging, so I'm making sure that use case works great before attempting live debugging.)

Extract a memory snapshot of your running lilos program into a file. Using openocd the command is (address and size for an STM32G030 shown, you will need to adjust them):

dump_image memory-image.bin 0x20000000 8192

Alternatively, in GDB, the command would be

dump binary memory memory-image.bin 0x20000000 0x20002000

(If you don't have a lilos program, you can also test using the files in the demo directory. There's an ELF file and a saved memory snapshot from one of my programs.)

Now, run lildb with the path to the ELF file for your lilos program:

cargo run -q --bin lildb YOURPROJECT/target/thumbv6m-none-eabi/yourproject

(You'll need to change that path, in case that was unclear.)

At the lildb prompt, load your memory image to the right address:

load memory-image.bin 0x20000000

Then try asking about the status of your tasks by running tasks. Example output from the demo image in this repo:

current tick-time is: 1620

task 0:
async fn keybad_fw::serial::task
    suspended at src/serial.rs:35
waiting on: async fn lilos::spsc::{impl#4}::pop<keybad_fw::scanner::KeyEvent>
    suspended at /home/cbiffle/proj/lilos/os/src/spsc.rs:313
    waiting for data in spsc queue at 0x20001d7c
    queue type: lilos::spsc::Queue<keybad_fw::scanner::KeyEvent> <.debug_info+0x0000e5b4>

task 1:
async fn keybad_fw::scanner::task
    suspended at src/scanner.rs:134
waiting on: async fn lilos::exec::{impl#6}::next_time
    suspended at /home/cbiffle/proj/lilos/os/src/exec.rs:965
waiting on: async fn lilos::exec::sleep_until
    suspended at /home/cbiffle/proj/lilos/os/src/exec.rs:815
    sleeping until: 1621 (1 ms from now)

About

Prototype debugger for lilos

License:Mozilla Public License 2.0


Languages

Language:Rust 100.0%