xref: /haiku/src/kits/debug/arch/riscv64/arch_debug_support.cpp (revision 072d3935c2497638e9c2502f574c133caeba9d3d)
1 /*
2  * Copyright 2005, Ingo Weinhold, bonefish@users.sf.net.
3  * Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
4  * Distributed under the terms of the MIT License.
5  */
6 
7 
8 #include <debug_support.h>
9 
10 #include "arch_debug_support.h"
11 
12 
13 struct stack_frame {
14 	struct stack_frame	*previous;
15 	void				*return_address;
16 };
17 
18 
19 status_t
20 arch_debug_get_instruction_pointer(debug_context *context, thread_id thread,
21 	void **ip, void **stackFrameAddress)
22 {
23 	#warning TODO RISCV64 get instruction pointer
24 	#if 0
25 	// get the CPU state
26 	debug_cpu_state cpuState;
27 	status_t error = debug_get_cpu_state(context, thread, NULL, &cpuState);
28 	if (error != B_OK)
29 		return error;
30 
31 	*ip = (void*)cpuState.rip;
32 	*stackFrameAddress = (void*)cpuState.rbp;
33 	#endif
34 
35 	return B_OK;
36 }
37 
38 
39 status_t
40 arch_debug_get_stack_frame(debug_context *context, void *stackFrameAddress,
41 	debug_stack_frame_info *stackFrameInfo)
42 {
43 	#warning TODO RISCV64 get stack frame
44 	#if 0
45 	stack_frame stackFrame;
46 	ssize_t bytesRead = debug_read_memory(context, stackFrameAddress,
47 		&stackFrame, sizeof(stackFrame));
48 	if (bytesRead < B_OK)
49 		return bytesRead;
50 	if (bytesRead != sizeof(stackFrame))
51 		return B_ERROR;
52 
53 	stackFrameInfo->frame = stackFrameAddress;
54 	stackFrameInfo->parent_frame = stackFrame.previous;
55 	stackFrameInfo->return_address = stackFrame.return_address;
56 	#endif
57 
58 	return B_OK;
59 }
60