xref: /haiku/headers/private/debug/debug_support.h (revision b46615c55ad2c8fe6de54412055a0713da3d610a)
1 /*
2  * Copyright 2005-2009, 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 ssize_t debug_write_memory_partial(debug_context *context, const void *address,
37 			void *buffer, size_t size);
38 ssize_t debug_write_memory(debug_context *context, const void *address,
39 			void *buffer, size_t size);
40 
41 status_t debug_get_cpu_state(debug_context *context, thread_id thread,
42 			debug_debugger_message *messageCode, debug_cpu_state *cpuState);
43 
44 
45 // stack trace support
46 
47 typedef struct debug_stack_frame_info {
48 	void	*frame;
49 	void	*parent_frame;
50 	void	*return_address;
51 } debug_stack_frame_info;
52 
53 status_t debug_get_instruction_pointer(debug_context *context, thread_id thread,
54 			void **ip, void **stackFrameAddress);
55 status_t debug_get_stack_frame(debug_context *context,
56 			void *stackFrameAddress, debug_stack_frame_info *stackFrameInfo);
57 
58 
59 // symbol lookup support
60 
61 typedef struct debug_symbol_lookup_context debug_symbol_lookup_context;
62 typedef struct debug_symbol_iterator debug_symbol_iterator;
63 
64 status_t debug_create_symbol_lookup_context(team_id team,
65 			debug_symbol_lookup_context **lookupContext);
66 void debug_delete_symbol_lookup_context(
67 			debug_symbol_lookup_context *lookupContext);
68 
69 status_t debug_get_symbol(debug_symbol_lookup_context* lookupContext,
70 			image_id image, const char* name, int32 symbolType,
71 			void** _symbolLocation, size_t* _symbolSize, int32* _symbolType);
72 status_t debug_lookup_symbol_address(debug_symbol_lookup_context *lookupContext,
73 			const void *address, void **baseAddress, char *symbolName,
74 			int32 symbolNameSize, char *imageName, int32 imageNameSize,
75 			bool *exactMatch);
76 
77 status_t debug_create_image_symbol_iterator(
78 			debug_symbol_lookup_context* lookupContext, image_id imageID,
79 			debug_symbol_iterator** _iterator);
80 status_t debug_create_file_symbol_iterator(const char* path,
81 			debug_symbol_iterator** _iterator);
82 void debug_delete_symbol_iterator(debug_symbol_iterator* iterator);
83 
84 status_t debug_next_image_symbol(debug_symbol_iterator* iterator,
85 			char* nameBuffer, size_t nameBufferLength, int32* _symbolType,
86 			void** _symbolLocation, size_t* _symbolSize);
87 status_t debug_get_symbol_iterator_image_info(debug_symbol_iterator* iterator,
88 			image_info* info);
89 
90 #ifdef __cplusplus
91 }	// extern "C"
92 #endif
93 
94 
95 #endif	// _DEBUG_SUPPORT_H
96