public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: options: increase max option count
@ 2021-04-24  4:18 Michael Frysinger
  0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2021-04-24  4:18 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=837b53fd088d13dda77b1d9db73800163692c2e3

commit 837b53fd088d13dda77b1d9db73800163692c2e3
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Sat Apr 24 00:10:44 2021 -0400

    sim: options: increase max option count
    
    As we turn on more modules by default for all ports, the number of
    options has been increasing.  The sim-options module has a limit on
    the number of options it can support, and if it's exceeded, it likes
    to go into an infinite loop.  Increase the ceiling and add an assert
    so we abort right away instead of hanging.
    
    This will be needed to turn on hw support for v850 as it will then
    exceed the current limit.

Diff:
---
 sim/common/ChangeLog     | 5 +++++
 sim/common/sim-options.c | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 61149e21213..ed4d9f7da65 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-24  Mike Frysinger  <vapier@gentoo.org>
+
+	* sim-options.c (ARG_HASH_SIZE): Increase to 256.
+	(sim_parse_args): Call SIM_ASSERT.
+
 2021-04-22  Tom Tromey  <tom@tromey.com>
 
 	* sim-utils.c: Update includes.
diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c
index d4434cfd738..ab95984e833 100644
--- a/sim/common/sim-options.c
+++ b/sim/common/sim-options.c
@@ -416,7 +416,7 @@ standard_install (SIM_DESC sd)
 /* Return non-zero if arg is a duplicate argument.
    If ARG is NULL, initialize.  */
 
-#define ARG_HASH_SIZE 97
+#define ARG_HASH_SIZE 256
 #define ARG_HASH(a) ((256 * (unsigned char) a[0] + (unsigned char) a[1]) % ARG_HASH_SIZE)
 
 static int
@@ -478,6 +478,9 @@ sim_parse_args (SIM_DESC sd, char * const *argv)
       for (opt = ol->options; OPTION_VALID_P (opt); ++opt)
 	++num_opts;
 
+  /* We build a hash table of all options, so make sure they all fit.  */
+  SIM_ASSERT (num_opts <= ARG_HASH_SIZE);
+
   /* Initialize duplicate argument checker.  */
   (void) dup_arg_p (NULL);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-24  4:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-24  4:18 [binutils-gdb] sim: options: increase max option count Michael Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).