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 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(team_id team, 61 debug_symbol_lookup_context **lookupContext); 62 void debug_delete_symbol_lookup_context( 63 debug_symbol_lookup_context *lookupContext); 64 65 status_t debug_get_symbol(debug_symbol_lookup_context* lookupContext, 66 image_id image, const char* name, int32 symbolType, 67 void** _symbolLocation, size_t* _symbolSize, int32* _symbolType); 68 status_t debug_lookup_symbol_address(debug_symbol_lookup_context *lookupContext, 69 const void *address, void **baseAddress, char *symbolName, 70 int32 symbolNameSize, char *imageName, int32 imageNameSize, 71 bool *exactMatch); 72 73 status_t debug_create_image_symbol_iterator( 74 debug_symbol_lookup_context* lookupContext, image_id imageID, 75 debug_symbol_iterator** _iterator); 76 status_t debug_create_file_symbol_iterator(const char* path, 77 debug_symbol_iterator** _iterator); 78 void debug_delete_symbol_iterator(debug_symbol_iterator* iterator); 79 80 status_t debug_next_image_symbol(debug_symbol_iterator* iterator, 81 char* nameBuffer, size_t nameBufferLength, int32* _symbolType, 82 void** _symbolLocation, size_t* _symbolSize); 83 status_t debug_get_symbol_iterator_image_info(debug_symbol_iterator* iterator, 84 image_info* info); 85 86 #ifdef __cplusplus 87 } // extern "C" 88 #endif 89 90 91 #endif // _DEBUG_SUPPORT_H 92