Skip to content

Commit e0a51c4

Browse files
authored
Fix sgx-gdb throw exceptions on every ocall in Rust-SGX (#489)
* Fix sgx-gdb throw exceptions on every ocall in Rust-SGX In Rust-SGX environment, `sgx-gdb` always throws exception after ocall: ``` Python Exception <class 'gdb.error'> syntax error in expression, near `)0x7fffffffd840 = 0'.: ``` And the debugger stops immediately. At this time, the debugger is working in `Rust` mode instead of `C` mode: ``` gdb-peda$ set *(uintptr_t *)0x7fffffffd6d0 = 0 syntax error in expression, near `)0x7fffffffd6d0 = 0'. gdb-peda$ set *(u32)0x7fffffffd6d0 = 0 syntax error in expression, near `0x7fffffffd6d0 = 0'. gdb-peda$ p sizeof(u32) $4 = 0x4 gdb-peda$ show language The current source language is "auto; currently rust". gdb-peda$ set language c gdb-peda$ set *(uintptr_t *)0x7fffffffd6d0 = 0 gdb-peda$ ``` This PR helps set the language to `c` before execution of essential gdb commands, and rolls back to `auto` afterwards. This would benefit lots of developers who are developing SGX enclaves in other languages. Signed-off-by: Yu Ding <[email protected]> * Fix
1 parent 7b9f974 commit e0a51c4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sdk/debugger_interface/linux/gdb-sgx-plugin/gdb_sgx_plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,14 @@ def stop(self):
610610
return False
611611
ret_addr_tuple = struct.unpack_from(ret_addr_of_fmt, ret_addr_str)
612612

613+
gdb.execute("set language c++")
613614
gdb_cmd = "set *(uintptr_t *)%#x = 0" %(int(ocall_frame))
614615
gdb.execute(gdb_cmd, False, True)
615616
gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(int(ocall_frame+(2*SIZE)), xbp)
616617
gdb.execute(gdb_cmd, False, True)
617618
gdb_cmd = "set *(uintptr_t *)%#x = %#x" %(int(ocall_frame+(3*SIZE)), ret_addr_tuple[0])
618619
gdb.execute(gdb_cmd, False, True)
620+
gdb.execute("set language auto")
619621

620622
return False
621623

0 commit comments

Comments
 (0)