On Thu, 16 Aug 2001, Rex Luo wrote:
>
> May I ask where to get this utility?
> Thanks!
It's beeing added to gcc in -current..
here are my patches: WARNING..CUT_N_PASTE.. will not patch cleanly.
Index: calls.c
===================================================================
RCS file: /usr/home/cvs/src/contrib/gcc.295/calls.c,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 calls.c
--- calls.c 2001/02/17 08:35:01 1.1.1.5
+++ calls.c 2001/08/15 22:07:43
@@ -2293,6 +2293,16 @@
/* All arguments and registers used for the call must be set up by
now! */
+ if (warn_arglist_size_flag)
+ {
+ if (unadjusted_args_size > warn_arglist_size)
+ {
+ warning ("%d byte arglist in function call",
unadjusted_args_size);
+ warning ("exceeds user specified limit (%d bytes)",
+ warn_arglist_size);
+ }
+ }
+
/* Generate the actual call instruction. */
emit_call_1 (funexp, fndecl, funtype, unadjusted_args_size,
args_size.constant, struct_value_size,
Index: flags.h
===================================================================
RCS file: /usr/home/cvs/src/contrib/gcc.295/flags.h,v
retrieving revision 1.4
diff -u -r1.4 flags.h
--- flags.h 1999/10/26 08:45:23 1.4
+++ flags.h 2001/08/15 22:07:43
@@ -121,6 +121,18 @@
extern int warn_template_debugging;
+/* Nonzero means warn if a frame is larger that N bytes. The value
+ of N is warn_frame_size. */
+
+extern int warn_frame_size_flag;
+extern int warn_frame_size;
+
+/* Nonzero means warn if a function call pushes more than N bytes
+ onto the stack. The value of N is warn_arglist_size. */
+
+extern int warn_arglist_size_flag;
+extern int warn_arglist_size;
+
/* Nonzero means warn about any identifiers that match in the first N
characters. The value N is in `id_clash_len'. */
Index: invoke.texi
===================================================================
RCS file: /usr/home/cvs/src/contrib/gcc.295/invoke.texi,v
retrieving revision 1.8
diff -u -r1.8 invoke.texi
--- invoke.texi 2001/02/17 09:04:50 1.8
+++ invoke.texi 2001/08/15 22:07:43
@@ -122,13 +122,13 @@
@xref{Warning Options,,Options to Request or Suppress Warnings}.
@smallexample
-fsyntax-only -pedantic -pedantic-errors
--w -W -Wall -Waggregate-return -Wbad-function-cast
--Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment
--Wconversion -Werror -Wformat
+-w -W -Wall -Waggregate-return -Warglist-size-@var{n}
+-Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts
+-Wcomment -Wconversion -Werror -Wformat
-Wid-clash-@var{len} -Wimplicit -Wimplicit-int
-Wimplicit-function-declaration -Wimport
--Werror-implicit-function-declaration -Winline
--Wlarger-than-@var{len} -Wlong-long
+-Werror-implicit-function-declaration -Wframe-size-@var{n}
+-Winline -Wlarger-than-@var{len} -Wlong-long
-Wmain -Wmissing-declarations -Wmissing-noreturn
-Wmissing-prototypes -Wmultichar -Wnested-externs -Wno-import
-Wparentheses -Wpointer-arith -Wredundant-decls
@@ -1811,6 +1811,17 @@
the warning messages, use @samp{-Wno-long-long}. Flags
@samp{-Wlong-long} and @samp{-Wno-long-long} are taken into account
only when @samp{-pedantic} flag is used.
+
+@item -Wframe-size-@var{n}
+Warn if a frame uses greater than @var{n} bytes. This warning can be
useful
+when stack space is limited, as is typical in embedded
environments. This
+warning, and also @samp{-Warglist-size-@var{n}}, can help locate
functions
+who may contribute to a stack overrun.
+
+@item -Warglist-size-@var{n}
+Warn if function argument list uses greater than @var{n} bytes. As with
+@samp{-Wframe-size-@var{n}}, this warning can help locate functions who
+may contribute to a stack overrun.
@item -Werror
Make all warnings into errors.
Index: toplev.c
===================================================================
RCS file: /usr/home/cvs/src/contrib/gcc.295/toplev.c,v
retrieving revision 1.11
diff -u -r1.11 toplev.c
--- toplev.c 2001/02/17 09:06:31 1.11
+++ toplev.c 2001/08/15 22:07:44
@@ -1075,6 +1075,10 @@
{ "-Wlong-long","" },
{ "-Wno-long-long", "Do not warn about using 'long long' when
-pedantic" },
{ "-Wmain", "Warn about suspicious declarations of main" },
+ { "-Wframe-size-<N> ",
+ "Warn if frame uses greater than <N> bytes." },
+ { "-Warglist-size-<N> ",
+ "Warn if function argument list uses greater than <N> bytes." },
{ "-Wno-main", "" },
{ "-Wmissing-braces",
"Warn about possibly missing braces around initialisers" },
@@ -1229,6 +1233,18 @@
int warn_cast_align;
+/* Nonzero means warn if a frame is larger that N bytes. The value
+ of N is warn_frame_size. */
+
+int warn_frame_size_flag=0;
+int warn_frame_size;
+
+/* Nonzero means warn if a function call pushes more than N bytes
+ onto the stack. The value of N is warn_arglist_size. */
+
+int warn_arglist_size_flag=0;
+int warn_arglist_size;
+
/* Nonzero means warn about any identifiers that match in the first N
characters. The value N is in `id_clash_len'. */
@@ -4382,6 +4398,12 @@
}
#endif
+
+ if (warn_frame_size_flag)
+ if (get_frame_size () > warn_frame_size)
+ warning ("%d byte frame exceeds user specified limit (%d bytes)",
+ get_frame_size (), warn_frame_size);
+
/* Now turn the rtl into assembler code. */
TIMEVAR (final_time,
@@ -5203,6 +5225,26 @@
{
larger_than_size = larger_than_val;
warn_larger_than = 1;
+ }
+ }
+ else if (!strncmp (p, "frame-size-", 11))
+ {
+ const int larger_than_val
+ = read_integral_parameter (p + 11, p - 2, -1);
+ if (larger_than_val != -1)
+ {
+ warn_frame_size = larger_than_val;
+ warn_frame_size_flag = 1;
+ }
+ }
+ else if (!strncmp (p, "arglist-size-", 13))
+ {
+ const int larger_than_val
+ = read_integral_parameter (p + 13, p - 2, -1);
+ if (larger_than_val != -1)
+ {
+ warn_arglist_size = larger_than_val;
+ warn_arglist_size_flag = 1;
}
}
else
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message