public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] fix for checking the command ambiguousness.
@ 2013-08-27  9:22 Muhammad Bilal
  2013-08-27 18:10 ` Pedro Alves
  0 siblings, 1 reply; 11+ messages in thread
From: Muhammad Bilal @ 2013-08-27  9:22 UTC (permalink / raw)
  To: gdb-patches

Hi,

While I was looking the code of 'lookup_cmd_composition' function, I saw
there incorrect command ambiguousness checking.
Actually  'find_cmd' function does not return the CMD_LIST_AMBIGUOUS
macro, whereas  'lookup_cmd_1' function return this macro on the bases 
of 'nfound'
variable and 'nfound' variable determines the command ambiguousness.

So, checking the command  ambiguousness condition with 'nfound' variables
fixes the bug.


  gdb/cli/cli-decode.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)


2013-07-27  Muhammad Bilal  <mbilal@codesourcery.com>

     * cli/cli-decode.c (lookup_cmd_composition): Check command 
ambiguousness
     with 'nfound' instead of CMD_LIST_AMBIGOUS.

diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 2fdd9e4..30000d8 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1729,7 +1729,7 @@ lookup_cmd_composition (const char *text,
           *cmd = find_cmd (command, len, cur_list, 1, &nfound);
         }

-      if (*cmd == CMD_LIST_AMBIGUOUS)
+      if (nfound > 1)
         {
           return 0;              /* ambiguous */
         }


OK?




Thanks,
-Bilal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] fix for checking the command ambiguousness.
  2013-08-27  9:22 [patch] fix for checking the command ambiguousness Muhammad Bilal
@ 2013-08-27 18:10 ` Pedro Alves
  2013-08-28  8:16   ` Muhammad Bilal
  0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2013-08-27 18:10 UTC (permalink / raw)
  To: Muhammad Bilal; +Cc: gdb-patches

Is it possible to construct a testcase that triggers this?

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] fix for checking the command ambiguousness.
  2013-08-27 18:10 ` Pedro Alves
@ 2013-08-28  8:16   ` Muhammad Bilal
  2013-08-28 11:44     ` Pedro Alves
  0 siblings, 1 reply; 11+ messages in thread
From: Muhammad Bilal @ 2013-08-28  8:16 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On 08/27/2013 11:10 PM, Pedro Alves wrote:
> Is it possible to construct a testcase that triggers this?
>
yes, I found a test case to triggers this.

Before apply the patch, GDB does not recognize the command ambiguity as.

(gdb) python gdb.parameter("print symbo on")
(gdb) show print symbo
Ambiguous show print command "symbo": symbol, symbol-filename.
(gdb)




And after applied my patch GBD shows.

(gdb) python gdb.parameter("print symbo on")
Traceback (most recent call last):
   File "<string>", line 1, in <module>
RuntimeError: Could not find parameter `print symbo on'.
Error while executing Python code.
(gdb) set print symbo
Ambiguous set print command "symbo": symbol, symbol-filename.
(gdb)


Now
Find below updated patch with test suite also.

./
2013-07-27  Muhammad Bilal <mbilal@codesourcery.com>

     * cli/cli-decode.c (lookup_cmd_composition): Check command 
ambiguousness
     with 'nfound' instead of CMD_LIST_AMBIGUOUS.



./testsuite/

2013-08-28  Muhammad Bilal  <mbilal@codesourcery.com>

     * gdb.python/py-parameter.exp: Test command ambiguousness.





Index: ../src/gdb/cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.119
diff -u -p -r1.119 cli-decode.c
--- ../src/gdb/cli/cli-decode.c    24 Apr 2013 14:29:17 -0000 1.119
+++ ../src/gdb/cli/cli-decode.c    28 Aug 2013 08:11:19 -0000
@@ -1729,7 +1729,7 @@ lookup_cmd_composition (const char *text
        *cmd = find_cmd (command, len, cur_list, 1, &nfound);
      }

-      if (*cmd == CMD_LIST_AMBIGUOUS)
+      if (nfound > 1)
      {
        return 0;              /* ambiguous */
      }

Index: ../src/gdb/testsuite/gdb.python/py-parameter.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-parameter.exp,v
retrieving revision 1.8
diff -u -p -r1.8 py-parameter.exp
--- ../src/gdb/testsuite/gdb.python/py-parameter.exp    1 Jan 2013 
06:41:26 -0000    1.8
+++ ../src/gdb/testsuite/gdb.python/py-parameter.exp    28 Aug 2013 
08:12:42 -0000
@@ -29,6 +29,13 @@ if { [skip_python_tests] } { continue }
  # We use "." here instead of ":" so that this works on win32 too.
  gdb_test "python print (gdb.parameter ('directories'))" 
"$srcdir/$subdir.\\\$cdir.\\\$cwd"

+#Test command ambiguousness
+gdb_test "python gdb.parameter('print symbo on')" \
+"Traceback.*File.*line 1.*RuntimeError.*Could not find parameter.*print 
symbo on.*Error while executing Python code.*" \
+"set print symbo on"
+gdb_test "show print symbo" "Ambiguous show print command \"symbo\".*" \
+"show print symbo"
+
  # Test a simple boolean parameter.
  gdb_py_test_multiple "Simple gdb booleanparameter" \
     "python" "" \


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] fix for checking the command ambiguousness.
  2013-08-28  8:16   ` Muhammad Bilal
@ 2013-08-28 11:44     ` Pedro Alves
  2013-08-28 14:17       ` Muhammad Bilal
  0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2013-08-28 11:44 UTC (permalink / raw)
  To: Muhammad Bilal; +Cc: gdb-patches

Hi!

Unfortunately, I'm having trouble applying your patches.  Seems like
they're mangled somehow (line wrapped, etc.).  From your email's headers
I see you're using Thunderbird.  Could you please go through:

 http://sourceware.org/gdb/wiki/ContributionChecklist#Submitting_patches

and fix it up as necessary (and then check if you can apply
a patch that you privately send yourself?)

Thanks,
-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] fix for checking the command ambiguousness.
  2013-08-28 11:44     ` Pedro Alves
@ 2013-08-28 14:17       ` Muhammad Bilal
  2013-09-04 12:34         ` Muhammad Bilal
  2013-11-07 14:53         ` Tom Tromey
  0 siblings, 2 replies; 11+ messages in thread
From: Muhammad Bilal @ 2013-08-28 14:17 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 854 bytes --]

On 08/28/2013 04:44 PM, Pedro Alves wrote:
> Hi!
>
> Unfortunately, I'm having trouble applying your patches.  Seems like
> they're mangled somehow (line wrapped, etc.).  From your email's headers
> I see you're using Thunderbird.  Could you please go through:
>
>   http://sourceware.org/gdb/wiki/ContributionChecklist#Submitting_patches
>
> and fix it up as necessary (and then check if you can apply
> a patch that you privately send yourself?)
>
> Thanks,
Sorry, for inconvenience

Please, find attached file.

./
2013-07-27  Muhammad Bilal <mbilal@codesourcery.com>

     * cli/cli-decode.c (lookup_cmd_composition): Check command 
ambiguousness
     with 'nfound' instead of CMD_LIST_AMBIGUOUS.



./testsuite/

2013-08-28  Muhammad Bilal <mbilal@codesourcery.com>

     * gdb.python/py-parameter.exp: Test command ambiguousness.



Thanks,
-Bilal

[-- Attachment #2: ambiguity.patch --]
[-- Type: text/x-patch, Size: 1574 bytes --]

Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.119
diff -u -p -r1.119 cli-decode.c
--- cli/cli-decode.c	24 Apr 2013 14:29:17 -0000	1.119
+++ cli/cli-decode.c	28 Aug 2013 14:00:46 -0000
@@ -1729,7 +1729,7 @@ lookup_cmd_composition (const char *text
 	  *cmd = find_cmd (command, len, cur_list, 1, &nfound);
 	}
       
-      if (*cmd == CMD_LIST_AMBIGUOUS)
+      if (nfound > 1)
 	{
 	  return 0;              /* ambiguous */
 	}
Index: testsuite/gdb.python/py-parameter.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-parameter.exp,v
retrieving revision 1.8
diff -u -p -r1.8 py-parameter.exp
--- testsuite/gdb.python/py-parameter.exp	1 Jan 2013 06:41:26 -0000	1.8
+++ testsuite/gdb.python/py-parameter.exp	28 Aug 2013 14:00:46 -0000
@@ -29,6 +29,13 @@ if { [skip_python_tests] } { continue }
 # We use "." here instead of ":" so that this works on win32 too.
 gdb_test "python print (gdb.parameter ('directories'))" "$srcdir/$subdir.\\\$cdir.\\\$cwd"
 
+#Test command ambiguousness
+gdb_test "python gdb.parameter('print symbo on')" \
+"Traceback.*File.*line 1.*RuntimeError.*Could not find parameter.*print symbo on.*Error while executing Python code.*" \
+"set print symbo on"
+gdb_test "show print symbo" "Ambiguous show print command \"symbo\".*" \
+"show print symbo"
+
 # Test a simple boolean parameter.
 gdb_py_test_multiple "Simple gdb booleanparameter" \
    "python" "" \


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] fix for checking the command ambiguousness.
  2013-08-28 14:17       ` Muhammad Bilal
@ 2013-09-04 12:34         ` Muhammad Bilal
  2013-09-10 10:33           ` Muhammad Bilal
  2013-11-07 14:53         ` Tom Tromey
  1 sibling, 1 reply; 11+ messages in thread
From: Muhammad Bilal @ 2013-09-04 12:34 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On 08/28/2013 07:17 PM, Muhammad Bilal wrote:
> On 08/28/2013 04:44 PM, Pedro Alves wrote:
>> Hi!
>>
>> Unfortunately, I'm having trouble applying your patches.  Seems like
>> they're mangled somehow (line wrapped, etc.).  From your email's headers
>> I see you're using Thunderbird.  Could you please go through:
>>
>> http://sourceware.org/gdb/wiki/ContributionChecklist#Submitting_patches
>>
>> and fix it up as necessary (and then check if you can apply
>> a patch that you privately send yourself?)
>>
>> Thanks,
> Sorry, for inconvenience
>
> Please, find attached file.
>
> ./
> 2013-07-27  Muhammad Bilal <mbilal@codesourcery.com>
>
>     * cli/cli-decode.c (lookup_cmd_composition): Check command 
> ambiguousness
>     with 'nfound' instead of CMD_LIST_AMBIGUOUS.
>
>
>
> ./testsuite/
>
> 2013-08-28  Muhammad Bilal <mbilal@codesourcery.com>
>
>     * gdb.python/py-parameter.exp: Test command ambiguousness.
>
>
>
> Thanks,
> -Bilal
ping




Thanks,
-Bilal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] fix for checking the command ambiguousness.
  2013-09-04 12:34         ` Muhammad Bilal
@ 2013-09-10 10:33           ` Muhammad Bilal
  2013-09-17 16:28             ` Muhammad Bilal
  0 siblings, 1 reply; 11+ messages in thread
From: Muhammad Bilal @ 2013-09-10 10:33 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

ping ^2

On 09/04/2013 05:34 PM, Muhammad Bilal wrote:
> On 08/28/2013 07:17 PM, Muhammad Bilal wrote:
>> On 08/28/2013 04:44 PM, Pedro Alves wrote:
>>> Hi!
>>>
>>> Unfortunately, I'm having trouble applying your patches. Seems like
>>> they're mangled somehow (line wrapped, etc.).  From your email's 
>>> headers
>>> I see you're using Thunderbird.  Could you please go through:
>>>
>>> http://sourceware.org/gdb/wiki/ContributionChecklist#Submitting_patches
>>>
>>> and fix it up as necessary (and then check if you can apply
>>> a patch that you privately send yourself?)
>>>
>>> Thanks,
>> Sorry, for inconvenience
>>
>> Please, find attached file.
>>
>> ./
>> 2013-07-27  Muhammad Bilal <mbilal@codesourcery.com>
>>
>>     * cli/cli-decode.c (lookup_cmd_composition): Check command 
>> ambiguousness
>>     with 'nfound' instead of CMD_LIST_AMBIGUOUS.
>>
>>
>>
>> ./testsuite/
>>
>> 2013-08-28  Muhammad Bilal <mbilal@codesourcery.com>
>>
>>     * gdb.python/py-parameter.exp: Test command ambiguousness.
>>
>>
>>
>> Thanks,
>> -Bilal
> ping
>
>
>
>
> Thanks,
> -Bilal

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] fix for checking the command ambiguousness.
  2013-09-10 10:33           ` Muhammad Bilal
@ 2013-09-17 16:28             ` Muhammad Bilal
  2013-09-17 16:31               ` Pedro Alves
  0 siblings, 1 reply; 11+ messages in thread
From: Muhammad Bilal @ 2013-09-17 16:28 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

ping ^3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] fix for checking the command ambiguousness.
  2013-09-17 16:28             ` Muhammad Bilal
@ 2013-09-17 16:31               ` Pedro Alves
  2013-11-07 15:04                 ` Tom Tromey
  0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2013-09-17 16:31 UTC (permalink / raw)
  To: Muhammad Bilal; +Cc: gdb-patches

As the test uses Python stuff to expose the bug, I'd appreciate
it if a Python person took a look.

Is this only triggerable with Python?  If so, why?

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] fix for checking the command ambiguousness.
  2013-08-28 14:17       ` Muhammad Bilal
  2013-09-04 12:34         ` Muhammad Bilal
@ 2013-11-07 14:53         ` Tom Tromey
  1 sibling, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2013-11-07 14:53 UTC (permalink / raw)
  To: Muhammad Bilal; +Cc: Pedro Alves, gdb-patches

>>>>> ">" == Muhammad Bilal <mbilal@codesourcery.com> writes:

>> 2013-07-27  Muhammad Bilal <mbilal@codesourcery.com>
>>     * cli/cli-decode.c (lookup_cmd_composition): Check command
>> ambiguousness
>>     with 'nfound' instead of CMD_LIST_AMBIGUOUS.
>> 2013-08-28  Muhammad Bilal <mbilal@codesourcery.com>
>>     * gdb.python/py-parameter.exp: Test command ambiguousness.

Thanks, this is ok.

Tom

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [patch] fix for checking the command ambiguousness.
  2013-09-17 16:31               ` Pedro Alves
@ 2013-11-07 15:04                 ` Tom Tromey
  0 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2013-11-07 15:04 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Muhammad Bilal, gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> As the test uses Python stuff to expose the bug, I'd appreciate
Pedro> it if a Python person took a look.

Pedro> Is this only triggerable with Python?  If so, why?

I looked, and there aren't many callers of lookup_cmd_composition:
maintenance_do_deprecate, deprecated_cmd_warning, and gdbpy_parameter.
The last one is the path the test case takes.

Tom

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-11-07 14:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-27  9:22 [patch] fix for checking the command ambiguousness Muhammad Bilal
2013-08-27 18:10 ` Pedro Alves
2013-08-28  8:16   ` Muhammad Bilal
2013-08-28 11:44     ` Pedro Alves
2013-08-28 14:17       ` Muhammad Bilal
2013-09-04 12:34         ` Muhammad Bilal
2013-09-10 10:33           ` Muhammad Bilal
2013-09-17 16:28             ` Muhammad Bilal
2013-09-17 16:31               ` Pedro Alves
2013-11-07 15:04                 ` Tom Tromey
2013-11-07 14:53         ` Tom Tromey

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).