1 | #include <stdio.h> |
2 | #include <stdint.h> |
3 | |
4 | struct RegisterContext |
5 | { |
6 | uintptr_t r0; |
7 | uintptr_t r1; |
8 | uintptr_t r2; |
9 | uintptr_t r3; |
10 | uintptr_t r4; |
11 | uintptr_t pc; |
12 | uintptr_t fp; |
13 | uintptr_t sp; |
14 | }; |
15 | |
16 | struct ThreadInfo { |
17 | uint32_t tid; |
18 | const char *name; |
19 | RegisterContext regs; |
20 | ThreadInfo *next; |
21 | }; |
22 | int main (int argc, char const *argv[], char const *envp[]); |
23 | |
24 | ThreadInfo g_thread2 = { .tid: 0x2222, .name: "thread2" , .regs: { .r0: 0x2000, .r1: 0x2001, .r2: 0x2002, .r3: 0x2003, .r4: 0x2004, .pc: (uintptr_t)&main, .fp: 0x2006, .sp: 0x2007 }, NULL }; |
25 | ThreadInfo g_thread1 = { .tid: 0x1111, .name: "thread1" , .regs: { .r0: 0x1000, .r1: 0x1001, .r2: 0x1002, .r3: 0x1003, .r4: 0x1004, .pc: (uintptr_t)&main, .fp: 0x1006, .sp: 0x1007 }, .next: &g_thread2 }; |
26 | ThreadInfo *g_thread_list_ptr = &g_thread1; |
27 | |
28 | int main (int argc, char const *argv[], char const *envp[]) |
29 | { |
30 | printf (format: "g_thread_list is %p\n" , g_thread_list_ptr); |
31 | return 0; //% v = self.dbg.GetSelectedTarget().FindFirstGlobalVariable('g_thread_list_ptr') |
32 | //% v_gla = v.GetChildMemberWithName('regs').GetLoadAddress() |
33 | //% v_aof = v.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS) |
34 | //% expr = '(%s)0x%x' % (v.GetType().GetName(), v.GetValueAsUnsigned(0)) |
35 | //% e = v.CreateValueFromExpression('e', expr) |
36 | //% e_gla = e.GetChildMemberWithName('regs').GetLoadAddress() |
37 | //% e_aof = e.GetChildMemberWithName('regs').AddressOf().GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS) |
38 | //% self.assertTrue(v_gla == e_gla, "GetLoadAddress() differs") |
39 | //% self.assertTrue(v_aof == e_aof, "AddressOf() differs") |
40 | } |
41 | |