Browse Source
This commit removes the previous tdesc_cortex_a, tdesc_cortex_m, and tdesc_cortex_mf XML string literals used for target description to GDB, now instead programmatically generating them at runtime to significantly deduplicate the characters that get embedded into the binary. Output of ld's --print-memory-usage during final link before: Memory region Used Size Region Size %age Used rom: 116388 B 128 KB 88.80% ram: 3348 B 20 KB 16.35% Output of ld's --print-memory-usage during final link now: Memory region Used Size Region Size %age Used rom: 113032 B 128 KB 86.24% ram: 3376 B 20 KB 16.48% So all in all this saves 3356 bytes of flash. Note: the exact size saved when compiled on your machine may differ, as the size of the build seems at least partially non-deterministic. We've gotten slightly different sizes (within 15 bytes of each other) at different times, with the only differences being things like which files were rebuilt in an incremental rebuild, or the order object files were given to the linker command line. The numbers given above were the numbers we got when testing the final builds from scratch, but all the sizes we got were extremely similar to the sizes listed above.pull/1196/head
Mikaela Szekely
2 years ago
5 changed files with 486 additions and 16 deletions
@ -0,0 +1,46 @@ |
|||
/*
|
|||
* This file is part of the Black Magic Debug project. |
|||
* |
|||
* Copyright (C) 2022 1bitsquared - Mikaela Szekely <mikaela.szekely@qyriad.me> |
|||
* Written by Mikaela Szekely <mikaela.szekely@qyriad.me> |
|||
* |
|||
* 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 |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include "gdb_reg.h" |
|||
|
|||
|
|||
const char *gdb_arm_preamble_first = |
|||
"<?xml version=\"1.0\"?>" |
|||
"<!DOCTYPE"; |
|||
|
|||
const char *gdb_arm_preamble_second = |
|||
"SYSTEM " |
|||
"\"gdb-target.dtd\">" |
|||
"<target>" |
|||
" <architecture>arm</architecture>"; |
|||
|
|||
|
|||
|
|||
const char *gdb_reg_type_strings[] = { |
|||
"", // GDB_TYPE_UNSPECIFIED.
|
|||
" type=\"data_ptr\"", // GDB_TYPE_DATA_PTR.
|
|||
" type=\"code_ptr\"", // GDB_TYPE_CODE_PTR.
|
|||
}; |
|||
|
|||
|
|||
const char *gdb_reg_save_restore_strings[] = { |
|||
"", // GDB_SAVE_RESTORE_UNSPECIFIED.
|
|||
" save-restore=\"no\"" // GDB_SAVE_RESTORE_NO.
|
|||
}; |
@ -0,0 +1,58 @@ |
|||
/*
|
|||
* This file is part of the Black Magic Debug project. |
|||
* |
|||
* Copyright (C) 2022 1bitsquared - Mikaela Szekely <mikaela.szekely@qyriad.me> |
|||
* Written by Mikaela Szekely <mikaela.szekely@qyriad.me> |
|||
* |
|||
* 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 |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#ifndef __GDB_REG_H |
|||
#define __GDB_REG_H |
|||
|
|||
|
|||
// The beginning XML for GDB target descriptions that are common to ARM targets,
|
|||
// save for one word: the word after DOCTYPE, which is "target" for Cortex-M, and "feature"
|
|||
// for Cortex-A. The "preamble" is thus split into two halves, with this single word missing
|
|||
// and as the split point.
|
|||
extern const char *gdb_arm_preamble_first; |
|||
|
|||
// The beginning XML for GDB target descriptions that are common to ARM targets,
|
|||
// save for one word: the word after DOCTYPE, which is "target" for Cortex-M, and "feature"
|
|||
// for Cortex-A. The "preamble" is thus split into two halves, with this single word missing
|
|||
// and as the split point.
|
|||
extern const char *gdb_arm_preamble_second; |
|||
|
|||
|
|||
// The "type" field of a register tag.
|
|||
typedef enum gdb_reg_type { |
|||
GDB_TYPE_UNSPECIFIED = 0, |
|||
GDB_TYPE_DATA_PTR, |
|||
GDB_TYPE_CODE_PTR, |
|||
} gdb_reg_type_e; |
|||
|
|||
// The strings for the "type" field of a register tag, respective to its gdb_reg_type_e value.
|
|||
extern const char *gdb_reg_type_strings[]; |
|||
|
|||
|
|||
// The "save-restore" field of a register tag.
|
|||
typedef enum gdb_reg_save_restore { |
|||
GDB_SAVE_RESTORE_UNSPECIFIED = 0, |
|||
GDB_SAVE_RESTORE_NO, |
|||
} gdb_reg_save_restore_e; |
|||
|
|||
// The strings for the "save-restore" field of a register tag, respective to its gdb_reg_save_restore_e value.
|
|||
extern const char *gdb_reg_save_restore_strings[]; |
|||
|
|||
#endif |
Loading…
Reference in new issue