diff options
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-cmds.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.h | 2 | ||||
-rw-r--r-- | gdb/cli/cli-decode.c | 48 | ||||
-rw-r--r-- | gdb/cli/cli-decode.h | 2 | ||||
-rw-r--r-- | gdb/cli/cli-dump.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-interp.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-interp.h | 2 | ||||
-rw-r--r-- | gdb/cli/cli-logging.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-option.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-option.h | 2 | ||||
-rw-r--r-- | gdb/cli/cli-script.c | 65 | ||||
-rw-r--r-- | gdb/cli/cli-script.h | 12 | ||||
-rw-r--r-- | gdb/cli/cli-setshow.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-setshow.h | 2 | ||||
-rw-r--r-- | gdb/cli/cli-style.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-style.h | 2 | ||||
-rw-r--r-- | gdb/cli/cli-utils.c | 2 | ||||
-rw-r--r-- | gdb/cli/cli-utils.h | 2 |
18 files changed, 108 insertions, 47 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 923b67b2..7e13ef8 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1,6 +1,6 @@ /* GDB CLI commands. - Copyright (C) 2000-2024 Free Software Foundation, Inc. + Copyright (C) 2000-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/cli/cli-cmds.h b/gdb/cli/cli-cmds.h index 6719ad7..33d13fb 100644 --- a/gdb/cli/cli-cmds.h +++ b/gdb/cli/cli-cmds.h @@ -1,5 +1,5 @@ /* Header file for GDB CLI command implementation library. - Copyright (C) 2000-2024 Free Software Foundation, Inc. + Copyright (C) 2000-2025 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 5008b48..48a3466 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1,6 +1,6 @@ /* Handle lists of commands, their decoding and documentation, for GDB. - Copyright (C) 1986-2024 Free Software Foundation, Inc. + Copyright (C) 1986-2025 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2041,40 +2041,28 @@ void print_doc_line (struct ui_file *stream, const char *str, bool for_value_prefix) { - static char *line_buffer = 0; - static int line_size; - const char *p; + const char *p = strchr (str, '\n'); - if (!line_buffer) - { - line_size = 80; - line_buffer = (char *) xmalloc (line_size); - } + /* Only copy the input string if we really need to. */ + std::optional<std::string> line_buffer; + if (p != nullptr) + line_buffer = std::string (str, p); + else if (for_value_prefix) + line_buffer = str; - /* Searches for the first end of line or the end of STR. */ - p = str; - while (*p && *p != '\n') - p++; - if (p - str > line_size - 1) - { - line_size = p - str + 1; - xfree (line_buffer); - line_buffer = (char *) xmalloc (line_size); - } - strncpy (line_buffer, str, p - str); if (for_value_prefix) { - if (islower (line_buffer[0])) - line_buffer[0] = toupper (line_buffer[0]); - gdb_assert (p > str); - if (line_buffer[p - str - 1] == '.') - line_buffer[p - str - 1] = '\0'; - else - line_buffer[p - str] = '\0'; + char &c = (*line_buffer)[0]; + if (islower (c)) + c = toupper (c); + if (line_buffer->back () == '.') + line_buffer->pop_back (); } - else - line_buffer[p - str] = '\0'; - gdb_puts (line_buffer, stream); + + gdb_puts (line_buffer.has_value () + ? line_buffer->c_str () + : str, + stream); } /* Print one-line help for command C. diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 85bd474..217afbc 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -1,6 +1,6 @@ /* Header file for GDB command decoding library. - Copyright (C) 2000-2024 Free Software Foundation, Inc. + Copyright (C) 2000-2025 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index 2b9307e..0ecc7b0 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -1,6 +1,6 @@ /* Dump-to-file commands, for GDB, the GNU debugger. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. Contributed by Red Hat. diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index dbe2ed1..32ba9d9 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -1,6 +1,6 @@ /* CLI Definitions for GDB, the GNU debugger. - Copyright (C) 2002-2024 Free Software Foundation, Inc. + Copyright (C) 2002-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h index ed3d904..8f41725 100644 --- a/gdb/cli/cli-interp.h +++ b/gdb/cli/cli-interp.h @@ -1,6 +1,6 @@ /* CLI Definitions for GDB, the GNU debugger. - Copyright (C) 2016-2024 Free Software Foundation, Inc. + Copyright (C) 2016-2025 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c index 2c54cea..d225533 100644 --- a/gdb/cli/cli-logging.c +++ b/gdb/cli/cli-logging.c @@ -1,6 +1,6 @@ /* Command-line output logging for GDB, the GNU debugger. - Copyright (C) 2003-2024 Free Software Foundation, Inc. + Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c index 34ac164..a30261e 100644 --- a/gdb/cli/cli-option.c +++ b/gdb/cli/cli-option.c @@ -1,6 +1,6 @@ /* CLI options framework, for GDB. - Copyright (C) 2017-2024 Free Software Foundation, Inc. + Copyright (C) 2017-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h index 38dcd82..6a56d5a 100644 --- a/gdb/cli/cli-option.h +++ b/gdb/cli/cli-option.h @@ -1,6 +1,6 @@ /* CLI options framework, for GDB. - Copyright (C) 2017-2024 Free Software Foundation, Inc. + Copyright (C) 2017-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 5decf3b..bdbf850 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1,6 +1,6 @@ /* GDB CLI command scripting. - Copyright (C) 1986-2024 Free Software Foundation, Inc. + Copyright (C) 1986-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -660,9 +660,13 @@ execute_control_command_1 (struct command_line *cmd, int from_tty) } case compile_control: +#if defined(HAVE_COMPILE) eval_compile_command (cmd, NULL, cmd->control_u.compile.scope, cmd->control_u.compile.scope_data); ret = simple_control; +#else + error (_("compile support has not been compiled into gdb")); +#endif break; case define_control: @@ -1621,6 +1625,65 @@ define_prefix_command (const char *comname, int from_tty) c->allow_unknown = c->user_commands.get () != nullptr; } +/* See cli/cli-script.h. */ + +bool +commands_equal (const command_line *a, const command_line *b) +{ + if ((a == nullptr) != (b == nullptr)) + return false; + + while (a != nullptr) + { + /* We are either at the end of both command lists, or there's + another command in both lists. */ + if ((a->next == nullptr) != (b->next == nullptr)) + return false; + + /* There's a command line for both, or neither. */ + if ((a->line == nullptr) != (b->line == nullptr)) + return false; + + /* Check control_type matches. */ + if (a->control_type != b->control_type) + return false; + + if (a->control_type == compile_control) + { + if (a->control_u.compile.scope != b->control_u.compile.scope) + return false; + + /* This is where we "fail safe". The scope_data is a 'void *' + pointer which changes in meaning based on the value of + 'scope'. It is possible that two different 'void *' pointers + could point to the equal scope data, however, we just assume + that if the pointers are different, then the scope_data is + different. This could be improved in the future. */ + if (a->control_u.compile.scope_data + != b->control_u.compile.scope_data) + return false; + } + + /* Check lines are identical. */ + if (a->line != nullptr && strcmp (a->line, b->line) != 0) + return false; + + /* Check body_list_0. */ + if (!commands_equal (a->body_list_0.get (), b->body_list_0.get ())) + return false; + + /* Check body_list_1. */ + if (!commands_equal (a->body_list_1.get (), b->body_list_1.get ())) + return false; + + /* Move to the next element in each chain. */ + a = a->next; + b = b->next; + } + + return true; +} + /* Used to implement source_command. */ diff --git a/gdb/cli/cli-script.h b/gdb/cli/cli-script.h index df7316e..1ce0754 100644 --- a/gdb/cli/cli-script.h +++ b/gdb/cli/cli-script.h @@ -1,5 +1,5 @@ /* Header file for GDB CLI command implementation library. - Copyright (C) 2000-2024 Free Software Foundation, Inc. + Copyright (C) 2000-2025 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -184,4 +184,14 @@ extern void print_command_trace (const char *cmd, ...) extern void reset_command_nest_depth (void); +/* Return true if A and B are identical. Some commands carry around a + 'void *' compilation context, in this case this function doesn't try to + validate if the context is actually the same or not, and will just + return false indicating the commands have changed. That is, a return + value of true is a guarantee that the commands are equal, a return + value of false means the commands are possibly different (and in most + cases are different). */ + +extern bool commands_equal (const command_line *a, const command_line *b); + #endif /* GDB_CLI_CLI_SCRIPT_H */ diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index b438e98..4d4695f 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -1,6 +1,6 @@ /* Handle set and show GDB commands. - Copyright (C) 2000-2024 Free Software Foundation, Inc. + Copyright (C) 2000-2025 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gdb/cli/cli-setshow.h b/gdb/cli/cli-setshow.h index 9eac86f..886f89f 100644 --- a/gdb/cli/cli-setshow.h +++ b/gdb/cli/cli-setshow.h @@ -1,5 +1,5 @@ /* Header file for GDB CLI set and show commands implementation. - Copyright (C) 2000-2024 Free Software Foundation, Inc. + Copyright (C) 2000-2025 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index 5484245..30c7afb 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -1,6 +1,6 @@ /* CLI colorizing - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h index e94b48d..77f4ac2 100644 --- a/gdb/cli/cli-style.h +++ b/gdb/cli/cli-style.h @@ -1,6 +1,6 @@ /* CLI stylizing - Copyright (C) 2018-2024 Free Software Foundation, Inc. + Copyright (C) 2018-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index 152fee9..23706e0 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -1,6 +1,6 @@ /* CLI utilities. - Copyright (C) 2011-2024 Free Software Foundation, Inc. + Copyright (C) 2011-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/cli/cli-utils.h b/gdb/cli/cli-utils.h index 4832d01..f9b0123 100644 --- a/gdb/cli/cli-utils.h +++ b/gdb/cli/cli-utils.h @@ -1,6 +1,6 @@ /* CLI utilities. - Copyright (C) 2011-2024 Free Software Foundation, Inc. + Copyright (C) 2011-2025 Free Software Foundation, Inc. This file is part of GDB. |