This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Support -mpoke-function-name for the ARM



This patch adds support for the -mpoke-function-name switch for ARM
targets. It's purpose is to inline the name of the function just
before the prologue is output.


Cheers,


Nick.


Fri Sep 05 09:25:21 1997  Nick Burrett  <nick.burrett@btinternet.com>

	* arm.c (arm_poke_function_name): New function to implement
	-mpoke-function-name.
	* aof.h (ASM_DECLARE_FUNCTION_NAME): Call it.
	* aout.h (ASM_DECLARE_FUNCTION_NAME): Likewise.
	* arm.h: Prototype it.
	(TARGET_SWITCHES): Add `no-poke-function-name'.
	


*** arm.c.orig	Mon Apr 26 13:47:39 1999
--- arm.c	Mon Apr 26 13:50:54 1999
*************** arm_volatile_func ()
*** 5398,5403 ****
--- 5398,5446 ----
    return (optimize > 0 && TREE_THIS_VOLATILE (current_function_decl));
  }
  
+ /* Write the function name into the code section, directly preceding
+    the function prologue.
+ 
+    Code will be output similar to this:
+      t0
+ 	 .ascii "arm_poke_function_name", 0
+ 	 .align
+      t1
+ 	 .word 0xff000000 + (t1 - t0)
+      arm_poke_function_name
+ 	 mov     ip, sp
+ 	 stmfd   sp!, {fp, ip, lr, pc}
+ 	 sub     fp, ip, #4
+ 
+    When performing a stack backtrace, code can inspect the value
+    of 'pc' stored at 'fp' + 0.  If the trace function then looks
+    at location pc - 12 and the top 8 bits are set, then we know
+    that there is a function name embedded immediately preceding this
+    location and has length ((pc[-3]) & 0xff000000).
+ 
+    We assume that pc is declared as a pointer to an unsigned long.
+ 
+    It is of no benefit to output the function name if we are assembling
+    a leaf function.  These function types will not contain a stack
+    backtrace structure, therefore it is not possible to determine the
+    function name.  */
+ 
+ void
+ arm_poke_function_name (stream, name)
+    FILE *stream;
+    char *name;
+ {
+   unsigned long alignlength, length;
+   rtx x;
+ 
+   length = strlen (name);
+   alignlength = (length + 1) + 3 & ~3;
+   ASM_OUTPUT_ASCII (stream, name, length + 1);
+   ASM_OUTPUT_ALIGN (stream, 2);
+   x = GEN_INT (0xff000000UL + alignlength);
+   ASM_OUTPUT_INT (stream, x);
+ }
+ 
  /* The amount of stack adjustment that happens here, in output_return and in
     output_epilogue must be exactly the same as was calculated during reload,
     or things will point to the wrong place.  The only time we can safely
*** arm.h.orig	Mon Apr 26 13:47:42 1999
--- arm.h	Mon Apr 26 13:59:25 1999
*************** function tries to return. */
*** 346,351 ****
--- 346,352 ----
    {"no-apcs-frame",	       -ARM_FLAG_APCS_FRAME, "" }, \
    {"poke-function-name",	ARM_FLAG_POKE, 		\
       "Store function names in object code" },		\
+   {"no-poke-function-name",    -ARM_FLAG_POKE, "" },	\
    {"fpe",			ARM_FLAG_FPE,  "" },	\
    {"apcs-32",			ARM_FLAG_APCS_32, 	\
       "Use the 32bit version of the APCS" },		\
*************** char * arithmetic_instr PROTO ((Rtx, int
*** 2161,2166 ****
--- 2162,2168 ----
  void   output_ascii_pseudo_op STDIO_PROTO ((FILE *, unsigned char *, int));
  char * output_return_instruction PROTO ((Rtx, int, int));
  int    arm_volatile_func PROTO ((void));
+ void   arm_poke_function_name STDIO_PROTO ((FILE *, char *));
  void   output_func_prologue STDIO_PROTO ((FILE *, int));
  void   output_func_epilogue STDIO_PROTO ((FILE *, int));
  void   arm_expand_prologue PROTO ((void));
*** aof.h.orig	Mon Apr 26 13:53:20 1999
--- aof.h	Mon Apr 26 13:54:42 1999
*************** do {					\
*** 324,329 ****
--- 324,331 ----
  
  #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \
  {						\
+   if (TARGET_POKE_FUNCTION_NAME)		\
+     arm_poke_function_name ((STREAM), (NAME));	\
    ASM_OUTPUT_LABEL (STREAM, NAME);		\
    if (! TREE_PUBLIC (DECL))			\
      {						\
*** aout.h.orig	Mon Apr 26 13:53:25 1999
--- aout.h	Mon Apr 26 13:55:40 1999
*************** do {									\
*** 129,135 ****
    
  /* Output a function label definition.  */
  #ifndef ASM_DECLARE_FUNCTION_NAME
! #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) ASM_OUTPUT_LABEL (STREAM, NAME)
  #endif
  
  #ifndef ASM_OUTPUT_LABEL
--- 129,140 ----
    
  /* Output a function label definition.  */
  #ifndef ASM_DECLARE_FUNCTION_NAME
! #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL)	\
! {							\
!   if (TARGET_POKE_FUNCTION_NAME)			\
!     arm_poke_function_name ((STREAM), (NAME));		\
!   ASM_OUTPUT_LABEL (STREAM, NAME);			\
! }
  #endif
  
  #ifndef ASM_OUTPUT_LABEL


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]