Patchwork [v2,12/24] Introduce generic command options framework

login
register
mail settings
Submitter Pedro Alves
Date June 4, 2019, 9:37 p.m.
Message ID <6fea8eb8-ae7d-bbca-d94f-9d82854e9238@redhat.com>
Download mbox | patch
Permalink /patch/32984/
State New
Headers show

Comments

Pedro Alves - June 4, 2019, 9:37 p.m.
On 6/3/19 8:16 PM, Tom Tromey wrote:
> 
> Pedro> +  if (len > 0 && strncmp ("unlimited", *arg, len) == 0)
> 
> I should have mentioned this in an earlier patch, but won't this also
> match things like "unlimitedjunk"?

It won't -- the code reads:

 static int
 is_unlimited_literal (const char *arg)
 {
   arg = skip_spaces (arg);

   const char *p = skip_to_space (arg);

   size_t len = p - arg;

   if (len > 0 && strncmp ("unlimited", arg, len) == 0)
     return true;

   return false;
 }

So for "unlimitedjunk", LEN will be 13, which is longer than
strlen ("unlimited"), so the strncmp returns != 0.

Thanks for bringing this up -- I missed adding a test for that
case.  I'm adding the below to the new settings.exp testcase.

Also, while writing the test I realized that we don't error
out with:

  (gdb) maint test-settings set uinteger unlimited junk

I wrote a follow up patch on top of the series to fix that.

Thanks,
Pedro Alves

Patch

diff --git c/gdb/testsuite/gdb.base/settings.exp w/gdb/testsuite/gdb.base/settings.exp
index 36c80086a3d..c62957181e2 100644
--- c/gdb/testsuite/gdb.base/settings.exp
+++ w/gdb/testsuite/gdb.base/settings.exp
@@ -141,7 +141,10 @@  proc test-integer {variant} {
            "$set_cmd unlimited"
     }
 
+    gdb_test "$set_cmd unlimitedu" "No symbol table is loaded.*"
+
     test_gdb_complete_none "$set_cmd unlimited "
+    test_gdb_complete_none "$set_cmd unlimitedu"