| 1 |
/* Copyright (C) 2019-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
This file is part of GDB. |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU General Public License as published by |
| 7 |
the Free Software Foundation; either version 3 of the License, or |
| 8 |
(at your option) any later version. |
| 9 |
|
| 10 |
This program is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 17 |
|
| 18 |
|
| 19 |
#include "linux-arm-tdesc.h" |
| 20 |
|
| 21 |
#include "tdesc.h" |
| 22 |
#include "arch/arm.h" |
| 23 |
#include <inttypes.h> |
| 24 |
|
| 25 |
/* All possible Arm target descriptors. */ |
| 26 |
static struct target_desc *tdesc_arm_list[ARM_FP_TYPE_INVALID]; |
| 27 |
|
| 28 |
/* See linux-arm-tdesc.h. */ |
| 29 |
|
| 30 |
const target_desc * |
| 31 |
arm_linux_read_description (arm_fp_type fp_type) |
| 32 |
{ |
| 33 |
struct target_desc *tdesc = tdesc_arm_list[fp_type]; |
| 34 |
|
| 35 |
if (tdesc == nullptr) |
| 36 |
{ |
| 37 |
tdesc = arm_create_target_description (fp_type, false); |
| 38 |
|
| 39 |
static const char *expedite_regs[] = { "r11", "sp", "pc", 0 }; |
| 40 |
init_target_desc (tdesc, expedite_regs, GDB_OSABI_LINUX); |
| 41 |
|
| 42 |
tdesc_arm_list[fp_type] = tdesc; |
| 43 |
} |
| 44 |
|
| 45 |
return tdesc; |
| 46 |
} |
| 47 |
|
| 48 |
/* See linux-arm-tdesc.h. */ |
| 49 |
|
| 50 |
arm_fp_type |
| 51 |
arm_linux_get_tdesc_fp_type (const target_desc *tdesc) |
| 52 |
{ |
| 53 |
gdb_assert (tdesc != nullptr); |
| 54 |
|
| 55 |
/* Many of the tdesc_arm_list entries may not have been initialised yet. This |
| 56 |
is ok, because tdesc must be one of the initialised ones. */ |
| 57 |
for (int i = ARM_FP_TYPE_NONE; i < ARM_FP_TYPE_INVALID; i++) |
| 58 |
{ |
| 59 |
if (tdesc == tdesc_arm_list[i]) |
| 60 |
return (arm_fp_type) i; |
| 61 |
} |
| 62 |
|
| 63 |
return ARM_FP_TYPE_INVALID; |
| 64 |
} |