mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
gdbstub: Re-factor gdb command extensions
Coverity reported a memory leak (CID 1549757) in this code and its admittedly rather clumsy handling of extending the command table. Instead of handing over a full array of the commands lets use the lighter weight GPtrArray and simply test for the presence of each entry as we go. This avoids complications of transferring ownership of arrays and keeps the final command entries as static entries in the target code. Cc: Akihiko Odaki <akihiko.odaki@daynix.com> Cc: Gustavo Bueno Romero <gustavo.romero@linaro.org> Cc: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20240718094523.1198645-4-alex.bennee@linaro.org>
This commit is contained in:
parent
955ad1121d
commit
e8122a7118
5 changed files with 105 additions and 86 deletions
|
@ -477,11 +477,9 @@ static GDBFeature *arm_gen_dynamic_m_secextreg_feature(CPUState *cs,
|
|||
|
||||
void arm_cpu_register_gdb_commands(ARMCPU *cpu)
|
||||
{
|
||||
GArray *query_table =
|
||||
g_array_new(FALSE, FALSE, sizeof(GdbCmdParseEntry));
|
||||
GArray *set_table =
|
||||
g_array_new(FALSE, FALSE, sizeof(GdbCmdParseEntry));
|
||||
GString *qsupported_features = g_string_new(NULL);
|
||||
g_autoptr(GPtrArray) query_table = g_ptr_array_new();
|
||||
g_autoptr(GPtrArray) set_table = g_ptr_array_new();
|
||||
g_autoptr(GString) qsupported_features = g_string_new(NULL);
|
||||
|
||||
if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
|
||||
#ifdef TARGET_AARCH64
|
||||
|
@ -492,16 +490,12 @@ void arm_cpu_register_gdb_commands(ARMCPU *cpu)
|
|||
|
||||
/* Set arch-specific handlers for 'q' commands. */
|
||||
if (query_table->len) {
|
||||
gdb_extend_query_table(&g_array_index(query_table,
|
||||
GdbCmdParseEntry, 0),
|
||||
query_table->len);
|
||||
gdb_extend_query_table(query_table);
|
||||
}
|
||||
|
||||
/* Set arch-specific handlers for 'Q' commands. */
|
||||
if (set_table->len) {
|
||||
gdb_extend_set_table(&g_array_index(set_table,
|
||||
GdbCmdParseEntry, 0),
|
||||
set_table->len);
|
||||
gdb_extend_set_table(set_table);
|
||||
}
|
||||
|
||||
/* Set arch-specific qSupported feature. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue