[PATCH] Move declaration of max_user_call_depth to header

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Move declaration of max_user_call_depth to header

Sourceware - gdb-patches mailing list
Also removes an unnecessary declaration of cmdlist in cli-cmds.c.
I don't understand why it is there, the definition of cmdlist is
at the top of the same file.

gdb/ChangeLog:

2019-10-09  Christian Biesinger  <[hidden email]>

        * cli/cli-cmds.c (max_user_call_depth): Move comment to header.
        (show_user): Remove declaration of cmdlist.
        * cli/cli-cmds.h (max_user_call_depth): Declare.
        * cli/cli-script.c (execute_user_command): Remove declaration
        of max_user_call_depth.
---
 gdb/cli/cli-cmds.c   | 3 +--
 gdb/cli/cli-cmds.h   | 4 ++++
 gdb/cli/cli-script.c | 1 -
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 9f7b052d8e0..a39ea226045 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -74,7 +74,7 @@ static void ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals,
 static void filter_sals (std::vector<symtab_and_line> &);
 
 
-/* Limit the call depth of user-defined commands */
+/* See cli-cmds.h. */
 unsigned int max_user_call_depth;
 
 /* Define all cmd_list_elements.  */
@@ -1538,7 +1538,6 @@ static void
 show_user (const char *args, int from_tty)
 {
   struct cmd_list_element *c;
-  extern struct cmd_list_element *cmdlist;
 
   if (args)
     {
diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h
index 1a8b9a0d506..94ae81475d6 100644
--- a/gdb/cli/cli-cmds.h
+++ b/gdb/cli/cli-cmds.h
@@ -101,6 +101,10 @@ extern struct cmd_list_element *setchecklist;
 
 extern struct cmd_list_element *showchecklist;
 
+/* Limit the call depth of user-defined commands */
+
+extern unsigned int max_user_call_depth;
+
 /* Exported to gdb/top.c */
 
 void init_cmd_lists (void);
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 4fc9c70259c..3137955265f 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -449,7 +449,6 @@ void
 execute_user_command (struct cmd_list_element *c, const char *args)
 {
   counted_command_line cmdlines_copy;
-  extern unsigned int max_user_call_depth;
 
   /* Ensure that the user commands can't be deleted while they are
      executing.  */
--
2.23.0.581.g78d2f28ef7-goog

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Move declaration of max_user_call_depth to header

Tom Tromey-2
>>>>> "Christian" == Christian Biesinger via gdb-patches <[hidden email]> writes:

Christian> 2019-10-09  Christian Biesinger  <[hidden email]>

Christian> * cli/cli-cmds.c (max_user_call_depth): Move comment to header.
Christian> (show_user): Remove declaration of cmdlist.
Christian> * cli/cli-cmds.h (max_user_call_depth): Declare.
Christian> * cli/cli-script.c (execute_user_command): Remove declaration
Christian> of max_user_call_depth.

Thanks, this is ok.

Christian>  /* Define all cmd_list_elements.  */
Christian> @@ -1538,7 +1538,6 @@ static void
Christian>  show_user (const char *args, int from_tty)
Christian>  {
Christian>    struct cmd_list_element *c;
Christian> -  extern struct cmd_list_element *cmdlist;

Changes like this particular one qualify as obvious IMO.

Christian> I don't understand why it is there, the definition of cmdlist is
Christian> at the top of the same file.

Could be the result of an earlier refactoring, or just plain old
mistake.

Tom
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Move declaration of max_user_call_depth to header

Sourceware - gdb-patches mailing list
On Fri, Oct 11, 2019 at 8:13 AM Tom Tromey <[hidden email]> wrote:

>
> >>>>> "Christian" == Christian Biesinger via gdb-patches <[hidden email]> writes:
>
> Christian> 2019-10-09  Christian Biesinger  <[hidden email]>
>
> Christian>      * cli/cli-cmds.c (max_user_call_depth): Move comment to header.
> Christian>      (show_user): Remove declaration of cmdlist.
> Christian>      * cli/cli-cmds.h (max_user_call_depth): Declare.
> Christian>      * cli/cli-script.c (execute_user_command): Remove declaration
> Christian>      of max_user_call_depth.
>
> Thanks, this is ok.

Thanks, pushed.

To ssh://sourceware.org/git/binutils-gdb.git
   03d0d46a0e6..cc8dee1f1c6  HEAD -> master

Christian

> Christian>  /* Define all cmd_list_elements.  */
> Christian> @@ -1538,7 +1538,6 @@ static void
> Christian>  show_user (const char *args, int from_tty)
> Christian>  {
> Christian>    struct cmd_list_element *c;
> Christian> -  extern struct cmd_list_element *cmdlist;
>
> Changes like this particular one qualify as obvious IMO.

Thanks, will keep that in mind, in this case I wanted to make sure I
wasn't missing anything.

Christian