Commit 94786cb8 authored by Diana Picus's avatar Diana Picus
Browse files

[Morello][lldb] Add more end-to-end tests

Test the disassembly command, as well as memory and register reads.
parent 792db891
cc_test {
name: "disassembly",
srcs: [
"main.c"
],
cflags: [
"-g", "-O0"
],
compile_multilib: "c64",
gtest: false,
}
breakpoint set -p "Break here"
process launch --
disassemble -n func_in_same_exec
# CHECK-LABEL: (lldb) disassemble -n func_in_same_exec
# CHECK: sub csp, csp, #0x10
# CHECK-NEXT: add c1, csp, #0xc
# CHECK-NEXT: scbnds c1, c1, #0x4
# CHECK-NEXT: add csp, csp, #0x10
# CHECK-NEXT: ret c30
# TODO: Check that we can disassemble a function from a .so
process kill
__attribute__((naked)) void func_in_same_exec() {
// This doesn't need to make sense or do anything useful, anything goes as
// long as it contains some capabilities and doesn't trigger any faults.
asm volatile(
"\tsub csp, csp, #0x10\n"
"\tadd c1, csp, #0xc\n"
"\tscbnds c1, c1, #0x4\n"
"\tadd csp, csp, #0x10\n"
"\tret c30\n"
);
}
int main() {
func_in_same_exec(); // Break here
return 0;
}
cc_test {
name: "memory",
srcs: [
"main.c"
],
cflags: [
"-g", "-O0"
],
compile_multilib: "c64",
gtest: false,
}
int function_using_address() {
int data = 133;
int *an_address = &data;
return *an_address; // Break here
}
int main() {
function_using_address();
return 0;
}
breakpoint set -p "Break here"
process launch --
frame variable an_address
memory read -C -c 1 -f capability &an_address
# CHECK-LABEL: (lldb) frame variable an_address
# CHECK: {[[ADDRESS:.*]]}
# CHECK: (lldb) memory read -C -c 1 -f capability &an_address
# CHECK: 0x{{[0-9a-fA-F]*}}: {[[ADDRESS]]}
process kill
cc_test {
name: "register",
srcs: [
"main.c"
],
cflags: [
"-g", "-O0"
],
compile_multilib: "c64",
gtest: false,
}
#include <stdint.h>
int main() {
uint64_t value = 0xdeaddeaddeadbeef;
asm volatile(
"\tscvalue c11, c11, %[VALUE]\n"
"\tscbnds c11, c11, #4\n"
:
: [VALUE] "r"(value)
: "c11"
);
return 0; // Break here
}
breakpoint set -p "Break here"
process launch --
register read c11
# CHECK-LABEL: (lldb) register read c11
# CHECK: c11 = 0x{{[0-9a-fA-F]+}}7ef3beefdeaddeaddeadbeef
register read -f capability c11
# CHECK-LABEL: (lldb) register read -f capability c11
# CHECK: c11 = {tag = {{.*}}, address = 0xdeaddeaddeadbeef, {{.*}}range = [0xdeaddeaddeadbeef-0xdeaddeaddeadbef3)
register read x11
# CHECK-LABEL: (lldb) register read x11
# CHECK: x11 = 0xdeaddeaddeadbeef
register read c29
# CHECK-LABEL: (lldb) register read c29
# CHECK: cfp = [[C29:.*]]
register read cfp
# CHECK-LABEL: (lldb) register read cfp
# CHECK: cfp = [[C29]]
register read x29
# CHECK-LABEL: (lldb) register read x29
# CHECK: fp = [[X29:.*]]
register read fp
# CHECK-LABEL: (lldb) register read fp
# CHECK: fp = [[X29]]
register read clr
# CHECK-LABEL: (lldb) register read clr
# CHECK: clr = 0x{{[0-9a-fA-F]+}}
register read csp
# CHECK-LABEL: (lldb) register read csp
# CHECK: csp = 0x{{[0-9a-fA-F]+}}
register read pcc
# CHECK-LABEL: (lldb) register read pcc
# CHECK: pcc = 0x{{[0-9a-fA-F]+}}
register read ddc
# CHECK-LABEL: (lldb) register read ddc
# CHECK: ddc = 0x{{[0-9a-fA-F]+}}
process kill
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment