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 59 status_t debug_create_symbol_lookup_context(debug_context *debugContext, 60 debug_symbol_lookup_context **lookupContext); 61 void debug_delete_symbol_lookup_context( 62 debug_symbol_lookup_context *lookupContext); 63 64 status_t debug_lookup_symbol_address(debug_symbol_lookup_context *lookupContext, 65 const void *address, void **baseAddress, char *symbolName, 66 int32 symbolNameSize, char *imageName, int32 imageNameSize, 67 bool *exactMatch); 68 69 70 #ifdef __cplusplus 71 } // extern "C" 72 #endif 73 74 75 #endif // _DEBUG_SUPPORT_H 76