mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-07 06:18:42 +00:00
implement raddbg markup lib functions only once, allow inclusion of header across many TUs, linking with the implementation in only one
This commit is contained in:
@@ -66,6 +66,20 @@
|
|||||||
#define raddbg_glue(a, b) raddbg_glue_(a, b)
|
#define raddbg_glue(a, b) raddbg_glue_(a, b)
|
||||||
#define raddbg_gen_data_id() raddbg_glue(raddbg_data__, __COUNTER__)
|
#define raddbg_gen_data_id() raddbg_glue(raddbg_data__, __COUNTER__)
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ Global Symbols
|
||||||
|
|
||||||
|
#if !defined(RADDBG_MARKUP_STUBS)
|
||||||
|
int raddbg_is_attached__impl(void);
|
||||||
|
int raddbg_thread_id__impl(void);
|
||||||
|
void raddbg_thread_name__impl(int id, char *fmt, ...);
|
||||||
|
void raddbg_thread_color__impl(int id, unsigned int hexcode);
|
||||||
|
void raddbg_watch__impl(char *fmt, ...);
|
||||||
|
void raddbg_log__impl(char *fmt, ...);
|
||||||
|
void raddbg_add_or_remove_breakpoint__impl(void *ptr, int set, int size, int r, int w, int x);
|
||||||
|
void raddbg_annotate_vaddr_range__impl(void *ptr, unsigned __int64 size, char *fmt, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Win32 Implementations
|
//~ Win32 Implementations
|
||||||
|
|
||||||
@@ -82,7 +96,7 @@
|
|||||||
#define raddbg_exe_data __declspec(allocate(".raddbg"))
|
#define raddbg_exe_data __declspec(allocate(".raddbg"))
|
||||||
|
|
||||||
//- first byte of exe data section -> is attached
|
//- first byte of exe data section -> is attached
|
||||||
raddbg_exe_data unsigned char raddbg_is_attached_byte_marker[1];
|
static raddbg_exe_data unsigned char raddbg_is_attached_byte_marker[1];
|
||||||
|
|
||||||
//- types
|
//- types
|
||||||
|
|
||||||
@@ -137,7 +151,7 @@ struct RADDBG_MARKUP_UnicodeDecode
|
|||||||
};
|
};
|
||||||
static __int8 raddbg_utf8_class[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,2,2,2,2,3,3,4,5};
|
static __int8 raddbg_utf8_class[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,2,2,2,2,3,3,4,5};
|
||||||
|
|
||||||
static inline RADDBG_MARKUP_UnicodeDecode
|
static RADDBG_MARKUP_UnicodeDecode
|
||||||
raddbg_decode_utf8(char *str, unsigned __int64 max)
|
raddbg_decode_utf8(char *str, unsigned __int64 max)
|
||||||
{
|
{
|
||||||
RADDBG_MARKUP_UnicodeDecode result = {1, 0xffffffff};
|
RADDBG_MARKUP_UnicodeDecode result = {1, 0xffffffff};
|
||||||
@@ -192,7 +206,7 @@ raddbg_decode_utf8(char *str, unsigned __int64 max)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned __int32
|
static unsigned __int32
|
||||||
raddbg_encode_utf16(wchar_t *str, unsigned __int32 codepoint)
|
raddbg_encode_utf16(wchar_t *str, unsigned __int32 codepoint)
|
||||||
{
|
{
|
||||||
unsigned __int32 inc = 1;
|
unsigned __int32 inc = 1;
|
||||||
@@ -216,20 +230,20 @@ raddbg_encode_utf16(wchar_t *str, unsigned __int32 codepoint)
|
|||||||
|
|
||||||
//- implementations
|
//- implementations
|
||||||
|
|
||||||
static inline int
|
int
|
||||||
raddbg_is_attached__impl(void)
|
raddbg_is_attached__impl(void)
|
||||||
{
|
{
|
||||||
return !!raddbg_is_attached_byte_marker[0];
|
return !!raddbg_is_attached_byte_marker[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
int
|
||||||
raddbg_thread_id__impl(void)
|
raddbg_thread_id__impl(void)
|
||||||
{
|
{
|
||||||
DWORD result = GetCurrentThreadId();
|
DWORD result = GetCurrentThreadId();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
raddbg_thread_name__impl(int id, char *fmt, ...)
|
raddbg_thread_name__impl(int id, char *fmt, ...)
|
||||||
{
|
{
|
||||||
// rjf: resolve variadic arguments
|
// rjf: resolve variadic arguments
|
||||||
@@ -309,7 +323,7 @@ raddbg_thread_name__impl(int id, char *fmt, ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
raddbg_thread_color__impl(int id, unsigned int hexcode)
|
raddbg_thread_color__impl(int id, unsigned int hexcode)
|
||||||
{
|
{
|
||||||
if(raddbg_is_attached())
|
if(raddbg_is_attached())
|
||||||
@@ -342,13 +356,13 @@ raddbg_thread_color__impl(int id, unsigned int hexcode)
|
|||||||
|
|
||||||
#define raddbg_break__impl() (__debugbreak())
|
#define raddbg_break__impl() (__debugbreak())
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
raddbg_watch__impl(char *fmt, ...)
|
raddbg_watch__impl(char *fmt, ...)
|
||||||
{
|
{
|
||||||
// TODO(rjf)
|
// TODO(rjf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
raddbg_log__impl(char *fmt, ...)
|
raddbg_log__impl(char *fmt, ...)
|
||||||
{
|
{
|
||||||
// rjf: resolve variadic arguments
|
// rjf: resolve variadic arguments
|
||||||
@@ -364,7 +378,7 @@ raddbg_log__impl(char *fmt, ...)
|
|||||||
OutputDebugStringA(buffer);
|
OutputDebugStringA(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
raddbg_add_or_remove_breakpoint__impl(void *ptr, int set, int size, int r, int w, int x)
|
raddbg_add_or_remove_breakpoint__impl(void *ptr, int set, int size, int r, int w, int x)
|
||||||
{
|
{
|
||||||
if(raddbg_is_attached())
|
if(raddbg_is_attached())
|
||||||
@@ -401,7 +415,7 @@ raddbg_add_or_remove_breakpoint__impl(void *ptr, int set, int size, int r, int w
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
raddbg_annotate_vaddr_range__impl(void *ptr, unsigned __int64 size, char *fmt, ...)
|
raddbg_annotate_vaddr_range__impl(void *ptr, unsigned __int64 size, char *fmt, ...)
|
||||||
{
|
{
|
||||||
if(raddbg_is_attached())
|
if(raddbg_is_attached())
|
||||||
|
|||||||
Reference in New Issue
Block a user