瀏覽代碼

[librm] Provide symbols for inline code placed into other sections

Provide symbols constructed from the object name and line number for
code fragments placed into alternative sections, such as inline
REAL_CODE() assembly placed into .text16.  This simplifies the
debugging task of finding the source code corresponding to a given
instruction pointer.

Note that we cannot use __FUNCTION__ since it is not a preprocessor
macro and so cannot be concatenated with string literals.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 6 年之前
父節點
當前提交
6149e0af3c
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5
    0
      src/arch/x86/include/librm.h

+ 5
- 0
src/arch/x86/include/librm.h 查看文件

@@ -254,9 +254,13 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
254 254
 #define CODE_DEFAULT ".code32"
255 255
 #endif
256 256
 
257
+/* LINE_SYMBOL: declare a symbol for the current source code line */
258
+#define LINE_SYMBOL _S2 ( OBJECT ) "__line_" _S2 ( __LINE__ ) ":"
259
+
257 260
 /* TEXT16_CODE: declare a fragment of code that resides in .text16 */
258 261
 #define TEXT16_CODE( asm_code_str )			\
259 262
 	".section \".text16\", \"ax\", @progbits\n\t"	\
263
+	"\n" LINE_SYMBOL "\n\t"				\
260 264
 	".code16\n\t"					\
261 265
 	asm_code_str "\n\t"				\
262 266
 	CODE_DEFAULT "\n\t"				\
@@ -276,6 +280,7 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
276 280
 	"push $1f\n\t"					\
277 281
 	"call phys_call\n\t"				\
278 282
 	".section \".text.phys\", \"ax\", @progbits\n\t"\
283
+	"\n" LINE_SYMBOL "\n\t"				\
279 284
 	".code32\n\t"					\
280 285
 	"\n1:\n\t"					\
281 286
 	asm_code_str					\

Loading…
取消
儲存