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]

End markers for functions.



This patch lets the user add some assembler at the end of a function,
which can be very helpful for various kinds of post-processing and
analysis of the generated object code.

OK to commit?

-- 
Geoffrey Keating <geoffk@cygnus.com>

===File ~/patches/cygnus/ascend-endmarker.patch=============
md5sum: d55ba85d5fdd51c8 82d0f010b2b59a4e 442937
Index: egcs/gcc/ChangeLog
0a
Wed Nov 17 20:53:29 1999  Greg McGary  <gkm@gnu.org>
			  Geoffrey Keating  <geoffk@cygnus.com>

	* final.c (final_end_function): Emit function_end_marker.
	* flags.h (function_end_marker): Add global var decl.
	* toplev.c (function_end_marker): Add global var defn.
	(display_help): Document new flag.
	(decode_f_option): Parse `-ffunction-end-marker=ASM' argument.
	* invoke.texi: Document new flag.

.
Changed files:
egcs/gcc/ChangeLog
egcs/gcc/final.c
egcs/gcc/flags.h
egcs/gcc/invoke.texi
egcs/gcc/toplev.c
md5sum: 31424a6ff7d00749 9436a1a6c2fb8f60 116549
--- /sloth/disk0/co/egcs-mainline/egcs/gcc/final.c	Thu Nov  4 13:47:44 1999
+++ egcs/gcc/final.c	Wed Nov 17 20:52:26 1999
@@ -1837,6 +1837,9 @@ final_end_function (first, file, optimiz
     xcoffout_end_epilogue (file);
 #endif
 
+  if (function_end_marker)
+    fprintf (file, "\t%s\n", function_end_marker);
+  
   bb_func_label_num = -1;	/* not in function, nuke label # */
 
   /* If FUNCTION_EPILOGUE is not defined, then the function body
md5sum: 239e5c883e5cc5d8 2649fd44b49ec9b2 18075
--- /sloth/disk0/co/egcs-mainline/egcs/gcc/flags.h	Fri Nov  5 10:45:44 1999
+++ egcs/gcc/flags.h	Wed Nov 17 20:41:57 1999
@@ -446,6 +446,18 @@ extern int flag_verbose_asm;
 
 extern int flag_debug_asm;
 
+/* -ffunction-end-marker=ASM causes ASM to be emitted after the
+   function epilogue.  This can be used to help runtime systems to
+   construct a stack-trace for architectures that don't maintain a
+   frame pointer chain.  At stack-trace time, the runtime system scans
+   backward from the PC to find the end of the previous function (and
+   thus the beginning of this one), and from there find and decode the
+   prologue.  The end of the function is marked because control flow
+   can, on some systems, fall into the start of the function at the
+   beginning of the file.  */
+
+extern char *function_end_marker;
+
 /* -fgnu-linker specifies use of the GNU linker for initializations.
    -fno-gnu-linker says that collect will be used.  */
 extern int flag_gnu_linker;
md5sum: 04178e21db692f7e 23b898f72c47fc1f 292228
--- /sloth/disk0/co/egcs-mainline/egcs/gcc/invoke.texi	Sun Nov 14 16:28:42 1999
+++ egcs/gcc/invoke.texi	Wed Nov 17 20:58:24 1999
@@ -437,7 +437,7 @@ in the following sections.
 -fverbose-asm -fpack-struct  -fstack-check
 -fargument-alias  -fargument-noalias
 -fargument-noalias-global
--fleading-underscore
+-ffunction-end-marker=@var{asm}  -fleading-underscore
 @end smallexample
 @end table
 
@@ -6794,6 +6794,16 @@ debugging the compiler itself).
 @samp{-fno-verbose-asm}, the default, causes the
 extra information to be omitted and is useful when comparing two assembler
 files.
+
+@item -ffunction-end-marker=@var{asm}
+Cause @var{asm} to be emitted after the function epilogue.  This can be
+used to help runtime systems to construct a stack-trace for
+architectures that don't maintain a frame pointer chain.  At stack-trace
+time, the runtime system scans backward from the PC to find the end of
+the previous function (and thus the beginning of this one), and from
+there find and decode the prologue.  The end of the function is marked
+instead of the beginning because control flow can, on some systems, fall
+into the start of the function at the beginning of the file.
 
 @item -fvolatile
 Consider all memory references through pointers to be volatile.
md5sum: 285ed454c09a290e 5b64016a33567b39 164117
--- /sloth/disk0/co/egcs-mainline/egcs/gcc/toplev.c	Mon Nov 15 19:58:29 1999
+++ egcs/gcc/toplev.c	Wed Nov 17 20:47:42 1999
@@ -704,6 +704,18 @@ int flag_verbose_asm = 0;
 
 int flag_debug_asm = 0;
 
+/* -ffunction-end-marker=ASM causes ASM to be emitted after the
+   function epilogue.  This can be used to help runtime systems to
+   construct a stack-trace for architectures that don't maintain a
+   frame pointer chain.  At stack-trace time, the runtime system scans
+   backward from the PC to find the end of the previous function (and
+   thus the beginning of this one), and from there find and decode the
+   prologue.  The end of the function is marked because control flow
+   can, on some systems, fall into the start of the function at the
+   beginning of the file.  */
+
+char *function_end_marker;
+
 /* -fgnu-linker specifies use of the GNU linker for initializations.
    (Or, more generally, a linker that handles initializations.)
    -fno-gnu-linker says that collect2 will be used.  */
@@ -4536,6 +4548,7 @@ display_help ()
   printf ("  -fcall-used-<register>  Mark <register> as being corrupted by function calls\n");
   printf ("  -fcall-saved-<register> Mark <register> as being preserved across functions\n");
   printf ("  -finline-limit=<number> Limits the size of inlined functions to <number>\n");
+  printf ("  -ffunction-end-marker=<asm> Output <asm> at the end of each function\n");
 
   for (i = NUM_ELEM (f_options); i--;)
     {
@@ -4883,6 +4896,10 @@ decode_f_option (arg)
     align_jumps = read_integral_parameter (arg + 12, arg - 2, align_jumps);
   else if (!strncmp (arg, "align-labels=", 13))
     align_labels = read_integral_parameter (arg + 13, arg - 2, align_labels);
+  else if (!strncmp (arg, "function-end-marker=", 20))
+    function_end_marker = xstrdup (arg + 20);
+  else if (!strcmp (arg, "no-function-end-marker"))
+    function_end_marker = NULL;
   else if (!strcmp (arg, "preprocessed"))
     /* Recognise this switch but do nothing.  This prevents warnings
        about an unrecognised switch if cpplib has not been linked in.  */
============================================================


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