I am debugging a risc-v processor and I am using LLDB with On-Chip Debugging trough JTAG.
Going straight to the point, I want to write some data through JTAG and I want to do it at a certain point in my program. For this purpose, I insert a breakpoint at the specific point I want the program to stop:
b main.c:<XX>
Then I continue the execution of the program, but I do want to write some data exactly when the breakpoint is hit, not before, and I want to script that, not having to do it manually. Is there any way of doing so in LLDB?
I found a similar issue but with GDB, but not sure if it is possible to do so in LLDB: gdb command file scripting: wait for breakpoint supported?
Ideally, when hitting the breakpoint and the program stops, I do want to write my data sourcing an external file:
command source --silent-run false <dir/file>
which contains basically writing into specific memory addresses:
memory write 0x1c010000 0x01
memory write 0x1c010010 0x02
memory write 0x1c010020 0x03
...
Any help is appreciated. Thanks.
Have a look at:
(lldb) help break command add
Add LLDB commands to a breakpoint, to be executed whenever the breakpoint is
hit. The commands added to the breakpoint replace any commands previously
added to it. If no breakpoint is specified, adds the commands to the last
created breakpoint.
etc...
You can specify the actions in two ways: you can give a list of lldb commands to get run, or you can attach a Python callback to the breakpoint. Both are described in that help output, and more details on the Python approach are here:
https://lldb.llvm.org/use/python-reference.html#running-a-python-script-when-a-breakpoint-gets-hit
And for more on what you can do with lldb from Python:
https://lldb.llvm.org/python_api.html#
lldb's command set is organized by topic, so pretty much anything you want to do with breakpoints will be under the breakpoint
top-level command, so when you want to do something with breakpoints, start with help breakpoint
and what you want will be somewhere under there. Also, like gdb, lldb has an apropos
command to search the help (though both command
and breakpoint
not surprisingly have a fair number of hits in apropos
.)