From: Pierre-Marc Fournier Date: Mon, 7 Dec 2009 20:54:40 +0000 (-0500) Subject: fix 32 bit support by conditionally compiling gdb support X-Git-Tag: v1.9.1~818 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=defa46a7f4207b7f3df4d87a0bc9814642e5e886;p=lttng-ust.git fix 32 bit support by conditionally compiling gdb support must define CONFIG_UST_GDB_INTEGRATION for gdb support to be enabled --- diff --git a/include/ust/marker.h b/include/ust/marker.h index 2d995e9f..79b861cb 100644 --- a/include/ust/marker.h +++ b/include/ust/marker.h @@ -94,15 +94,10 @@ struct marker { 0, 0, 0, 0, marker_probe_cb, \ { __mark_empty_function, NULL}, \ NULL, tp_name_str, tp_cb, NULL }; \ - asm (".section __marker_addr,\"aw\",@progbits\n\t" \ - _ASM_PTR "%c[marker_struct], (1f)\n\t" \ - ".previous\n\t" \ - "1:\n\t" \ - :: [marker_struct] "i" (&__mark_##channel##_##name));\ + save_ip(); \ save_registers(®s) - #define DEFINE_MARKER(channel, name, format) \ _DEFINE_MARKER(channel, name, NULL, NULL, format) @@ -304,7 +299,9 @@ struct marker_addr { struct lib { struct marker *markers_start; +#ifdef CONFIG_UST_GDB_INTEGRATION struct marker_addr *markers_addr_start; +#endif int markers_count; struct list_head list; }; @@ -313,6 +310,8 @@ extern int marker_register_lib(struct marker *markers_start, struct marker_addr *marker_addr_start, int markers_count); +#ifdef CONFIG_UST_GDB_INTEGRATION + #define MARKER_LIB \ extern struct marker __start___markers[] __attribute__((weak, visibility("hidden"))); \ extern struct marker __stop___markers[] __attribute__((weak, visibility("hidden"))); \ @@ -327,4 +326,20 @@ extern int marker_register_lib(struct marker *markers_start, extern void marker_set_new_marker_cb(void (*cb)(struct marker *)); extern void init_markers(void); -#endif +#else /* CONFIG_UST_GDB_INTEGRATION */ + +#define MARKER_LIB \ + extern struct marker __start___markers[] __attribute__((weak, visibility("hidden"))); \ + extern struct marker __stop___markers[] __attribute__((weak, visibility("hidden"))); \ + \ + static void __attribute__((constructor)) __markers__init(void) \ + { \ + marker_register_lib(__start___markers, NULL, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker)); \ + } + +extern void marker_set_new_marker_cb(void (*cb)(struct marker *)); +extern void init_markers(void); + +#endif /* CONFIG_UST_GDB_INTEGRATION */ + +#endif /* _UST_MARKER_H */ diff --git a/include/ust/processor.h b/include/ust/processor.h index 6caae6e7..2ee7efa6 100644 --- a/include/ust/processor.h +++ b/include/ust/processor.h @@ -7,9 +7,14 @@ extern __thread long ust_reg_stack[500]; extern volatile __thread long *ust_reg_stack_ptr; +#ifndef CONFIG_UST_GDB_INTEGRATION +static inline save_ip(void) +{ +} +#endif + -#ifdef x86_32 -#error "32-bit support broken" +#ifndef x86_64 struct registers { long eax; @@ -30,15 +35,25 @@ struct registers { int xss; }; -static inline save_registers(struct registers *regs) -{ -} +#ifdef CONFIG_UST_GDB_ITEGRATION + +#error "GDB integration not supported for x86-32 yet." + +#define save_ip() +#define save_registers(a) + +#else /* CONFIG_UST_GDB_ITEGRATION */ + +#define save_ip() +#define save_registers(a) + +#endif /* CONFIG_UST_GDB_ITEGRATION */ #define RELATIVE_ADDRESS(__rel_label__) __rel_label__ #define _ASM_PTR ".long " -#else +#else /* below is code for x86-64 */ struct registers { int padding; /* 4 bytes */ @@ -63,6 +78,14 @@ struct registers { unsigned long rsp; }; +#ifdef CONFIG_UST_GDB_ITEGRATION +#define save_ip() \ + asm (".section __marker_addr,\"aw\",@progbits\n\t" \ + _ASM_PTR "%c[marker_struct], (1f)\n\t" \ + ".previous\n\t" \ + "1:\n\t" \ + :: [marker_struct] "i" (&__mark_##channel##_##name));\ + #define save_registers(regsptr) \ asm volatile ( \ /* save original rsp */ \ @@ -188,6 +211,8 @@ struct registers { memcpy(regsptr, (void *)ust_reg_stack_ptr, sizeof(struct registers)); \ ust_reg_stack_ptr = (void *)(((long)ust_reg_stack_ptr) + sizeof(struct registers)); +#endif /* CONFIG_UST_GDB_ITEGRATION */ + /* Macro to insert the address of a relative jump in an assembly stub, * in a relocatable way. On x86-64, this uses a special (%rip) notation. */ #define RELATIVE_ADDRESS(__rel_label__) __rel_label__(%%rip) diff --git a/libust/marker.c b/libust/marker.c index 47b6d11f..da16e4f6 100644 --- a/libust/marker.c +++ b/libust/marker.c @@ -46,8 +46,11 @@ volatile __thread long *ust_reg_stack_ptr = (long *) 0; extern struct marker __start___markers[] __attribute__((visibility("hidden"))); extern struct marker __stop___markers[] __attribute__((visibility("hidden"))); + +#ifdef CONFIG_UST_GDB_INTEGRATION extern struct marker_addr __start___marker_addr[] __attribute__((visibility("hidden"))); extern struct marker_addr __stop___marker_addr[] __attribute__((visibility("hidden"))); +#endif /* Set to 1 to enable marker debug output */ static const int marker_debug; @@ -1509,7 +1512,9 @@ int marker_register_lib(struct marker *markers_start, struct marker_addr *marker pl = (struct lib *) malloc(sizeof(struct lib)); pl->markers_start = markers_start; +#ifdef CONFIG_UST_GDB_INTEGRATION pl->markers_addr_start = marker_addr_start; +#endif pl->markers_count = markers_count; lock_markers(); @@ -1545,7 +1550,11 @@ static int initialized = 0; void __attribute__((constructor)) init_markers(void) { if(!initialized) { +#ifdef CONFIG_UST_GDB_INTEGRATION marker_register_lib(__start___markers, __start___marker_addr, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker)); +#else + marker_register_lib(__start___markers, NULL, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker)); +#endif //DBG("markers_start: %p, markers_stop: %p\n", __start___markers, __stop___markers); initialized = 1; }