xref: /haiku/headers/private/debug/debug_support.h (revision e9c4d47ad719d6fd67cd9b75b41ebbec563e7a79)
1 /*
2  * Copyright 2005, Ingo Weinhold, bonefish@users.sf.net.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _DEBUG_SUPPORT_H
6 #define _DEBUG_SUPPORT_H
7 
8 #include <debugger.h>
9 #include <OS.h>
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 typedef struct debug_context {
16 	team_id	team;
17 	port_id	nub_port;
18 	port_id	reply_port;
19 } debug_context;
20 
21 
22 status_t init_debug_context(debug_context *context, team_id team,
23 	port_id nubPort);
24 void destroy_debug_context(debug_context *context);
25 
26 status_t send_debug_message(debug_context *context, int32 messageCode,
27 			const void *message, int32 messageSize, void *reply,
28 			int32 replySize);
29 
30 ssize_t debug_read_memory_partial(debug_context *context, const void *address,
31 			void *buffer, size_t size);
32 ssize_t debug_read_memory(debug_context *context, const void *address,
33 			void *buffer, size_t size);
34 ssize_t debug_read_string(debug_context *context, const void *_address,
35 			char *buffer, size_t size);
36 
37 status_t debug_get_cpu_state(debug_context *context, thread_id thread,
38 			debug_debugger_message *messageCode, debug_cpu_state *cpuState);
39 
40 
41 // stack trace support
42 
43 typedef struct debug_stack_frame_info {
44 	void	*frame;
45 	void	*parent_frame;
46 	void	*return_address;
47 } debug_stack_frame_info;
48 
49 status_t debug_get_instruction_pointer(debug_context *context, thread_id thread,
50 			void **ip, void **stackFrameAddress);
51 status_t debug_get_stack_frame(debug_context *context,
52 			void *stackFrameAddress, debug_stack_frame_info *stackFrameInfo);
53 
54 
55 // symbol lookup support
56 
57 typedef struct debug_symbol_lookup_context debug_symbol_lookup_context;
58 typedef struct debug_symbol_iterator debug_symbol_iterator;
59 
60 status_t debug_create_symbol_lookup_context(debug_context *debugContext,
61 			debug_symbol_lookup_context **lookupContext);
62 void debug_delete_symbol_lookup_context(
63 			debug_symbol_lookup_context *lookupContext);
64 
65 status_t debug_lookup_symbol_address(debug_symbol_lookup_context *lookupContext,
66 			const void *address, void **baseAddress, char *symbolName,
67 			int32 symbolNameSize, char *imageName, int32 imageNameSize,
68 			bool *exactMatch);
69 
70 status_t debug_create_image_symbol_iterator(
71 			debug_symbol_lookup_context* lookupContext, image_id imageID,
72 			debug_symbol_iterator** _iterator);
73 void debug_delete_image_symbol_iterator(debug_symbol_iterator* iterator);
74 
75 status_t debug_next_image_symbol(debug_symbol_iterator* iterator,
76 			char* nameBuffer, size_t nameBufferLength, int32* _symbolType,
77 			void** _symbolLocation, size_t* _symbolSize);
78 
79 #ifdef __cplusplus
80 }	// extern "C"
81 #endif
82 
83 
84 #endif	// _DEBUG_SUPPORT_H
85