Merge "Adding placeholder documentation for TLib Workflow"
diff --git a/RenodeTlibWorkflowDocumentation.md b/RenodeTlibWorkflowDocumentation.md
new file mode 100644
index 0000000..bb43227
--- /dev/null
+++ b/RenodeTlibWorkflowDocumentation.md
@@ -0,0 +1,114 @@
+# Renode TLib Workflow (Placeholder)
+
+Commands here are subject to change.
+
+* [Building](#building)
+* [Running Qemu without debugging](#running-qemu-without-debugging)
+* [Running Qemu with debugging](#running-qemu-with-debugging)
+* [Running gdb for Qemu](#running-gdb-for-qemu)
+ * [Run gdb on the target elf](#run-gdb-on-the-target-elf)
+* [Running gdb for Renode](#running-gdb-for-renode)
+ * [Setup .gdbinit file](#setup-.gdbinit-file)
+* [Running Renode](#running-renode)
+
+## Building
+
+```
+m springbok
+m qemu_clean qemu
+m renode_clean renode
+```
+
+Note: as we continually make changes to renode, will have to `m renode_clean renode` to apply updates:
+
+`m renode_clean renode`
+
+
+## Running Qemu without debugging
+
+```
+qemu_sim_springbok ./out/springbok/test_vsetvl/test_vsetvl.elf
+```
+
+## Running Qemu with debugging
+
+```
+qemu_sim_springbok ./out/springbok/test_vsetvl/test_vsetvl.elf -s -S
+```
+
+## Running gdb for Qemu
+
+### Run gdb on the target elf
+
+Note, same as for Renode but with `target remote :1234`
+
+```sh
+riscv32-unknown-elf-gdb out/springbok/test_vsetvl/test_vsetvl.elf \
+ -ex "target remote :1234" \
+ -ex "layout split" \
+ -ex "b main" \
+ -ex "c"
+```
+## Running gdb for Renode
+
+```sh
+riscv32-unknown-elf-gdb out/springbok/test_vsetvl/test_vsetvl.elf \
+ -ex "target remote :3333" \
+ -ex "monitor start" \
+ -ex "sysbus.cpu2 IsHalted False" \
+ -ex "layout split" \
+ -ex "b main" \
+ -ex "c"
+```
+### Setup .gdbinit file
+
+Save the following to `${HOME}/.gdbinit`:
+
+```
+set auto-load safe-path /
+handle SIGXCPU SIG33 SIG35 SIG36 SIG37 SIG38 SIGPWR nostop noprint
+
+define mono_backtrace
+ select-frame 0
+ set $i = 0
+ while ($i < $arg0)
+ set $foo = (char*) mono_pmip ($pc)
+ if ($foo)
+ printf "#%d %p in %s\n", $i, $pc, $foo
+ else
+ frame
+ end
+ up-silently
+ set $i = $i + 1
+ end
+end
+
+define mono_stack
+ set $mono_thread = mono_thread_current ()
+ if ($mono_thread == 0x00)
+ printf "No mono thread associated with this thread\n"
+ else
+ set $ucp = malloc (sizeof (ucontext_t))
+ call (void) getcontext ($ucp)
+ call (void) mono_print_thread_dump ($ucp)
+ call (void) free ($ucp)
+ end
+end
+```
+
+
+## Running Renode
+
+```sh
+gdb -ex "set breakpoint pending on" \
+ -ex "set pagination off" \
+ -ex "b helper_vsetvl" \
+ -ex "layout split" \
+ -ex "r" \
+ --args mono \
+ --debug out/host/renode/Renode.exe \
+ -e "\$bin=@out/springbok/test_vsetvl/test_vsetvl.elf; i @sim/config/springbok.resc;" \
+ --disable-xwt \
+ --console
+```
+