diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-17 14:00:48 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-17 14:00:48 -0400 |
commit | 413b49c2b6619a7ce16322c7f94079205031cda4 (patch) | |
tree | 0784421d737876d900e539b9b5e3acca4f77b933 /gdb | |
parent | e683cb412046b40085505f42dd141f542661a6ae (diff) | |
download | gdb-413b49c2b6619a7ce16322c7f94079205031cda4.zip gdb-413b49c2b6619a7ce16322c7f94079205031cda4.tar.gz gdb-413b49c2b6619a7ce16322c7f94079205031cda4.tar.bz2 |
gdb: move cmd_list_element::prefixname to cli/cli-decode.c
I don't think this method really benefits from being implemented in the
header file, especially because it's recursive, it can't be inlined.
Move it to the source file, so it's no re-compiled by every CU
including cli/cli-decode.h.
I also noticed this method could be const, make it so.
gdb/ChangeLog:
* cli/cli-decode.h (prefixname): Make const, move implementation
to cli/cli-decode.c.
* cli/cli-decode.c (cmd_list_element::prefixname): New.
Change-Id: I1597cace98d9a4ba71f51f1f495e73cc07b5dcf3
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/cli/cli-decode.c | 17 | ||||
-rw-r--r-- | gdb/cli/cli-decode.h | 16 |
3 files changed, 25 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 81e9dd5..c9f5181 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2021-05-17 Simon Marchi <simon.marchi@polymtl.ca> + + * cli/cli-decode.h (prefixname): Make const, move implementation + to cli/cli-decode.c. + * cli/cli-decode.c (cmd_list_element::prefixname): New. + 2021-05-16 Weimin Pan <weimin.pan@oracle.com> * ctfread.c (new_symbol): Set function address. diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 32edb52..a3b153f 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -160,6 +160,23 @@ set_cmd_completer_handle_brkchars (struct cmd_list_element *cmd, cmd->completer_handle_brkchars = func; } +std::string +cmd_list_element::prefixname () const +{ + if (this->prefixlist == nullptr) + /* Not a prefix command. */ + return ""; + + std::string prefixname; + if (this->prefix != nullptr) + prefixname = this->prefix->prefixname (); + + prefixname += this->name; + prefixname += " "; + + return prefixname; +} + /* Add element named NAME. Space for NAME and DOC must be allocated by the caller. CLASS is the top level category into which commands are broken down diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index da6013a..e6d6f32 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -76,20 +76,8 @@ struct cmd_list_element space. It is used before the word "command" in describing the commands reached through this prefix. - For non-prefix commands, an empty string is returned. */ - std::string prefixname () - { - if (prefixlist == nullptr) - /* Not a prefix command. */ - return ""; - - std::string prefixname; - if (prefix != nullptr) - prefixname = prefix->prefixname (); - prefixname += name; - prefixname += " "; - return prefixname; - } + For non-prefix commands, return an empty string. */ + std::string prefixname () const; /* Points to next command in this list. */ struct cmd_list_element *next = nullptr; |