aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/elf-bfd.h2
-rw-r--r--bfd/elf.c4
-rw-r--r--bfd/elf32-arm.c35
-rw-r--r--bfd/elflink.c4
-rw-r--r--bfd/elfxx-riscv.c26
-rw-r--r--gas/config/tc-arm.c14
-rw-r--r--gas/testsuite/gas/arm/neon-suffix-bad.d2
-rw-r--r--gas/testsuite/gas/arm/neon-suffix-bad.l21
-rw-r--r--gas/testsuite/gas/arm/neon-suffix-bad.s22
-rw-r--r--gdb/testsuite/gdb.base/color-prompt.exp29
-rw-r--r--gdb/testsuite/gdb.base/exprs.exp5
-rw-r--r--gdb/testsuite/gdb.tui/basic.exp6
-rw-r--r--gdb/testsuite/gdb.tui/color-prompt.exp10
-rw-r--r--gdb/testsuite/gdb.tui/color-prompt.exp.tcl80
-rw-r--r--gdb/testsuite/gdb.tui/main-2.exp4
-rw-r--r--gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp10
-rw-r--r--gdb/testsuite/lib/tuiterm.exp37
-rw-r--r--opcodes/aarch64-asm.c6
-rw-r--r--opcodes/aarch64-dis.c37
-rw-r--r--opcodes/aarch64-opc.c2
-rw-r--r--opcodes/aarch64-opc.h12
21 files changed, 284 insertions, 84 deletions
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index b791623..f24342c 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2632,7 +2632,7 @@ extern bool _bfd_elf_link_output_relocs
struct elf_link_hash_entry **);
extern void _bfd_elf_link_add_glibc_version_dependency
- (struct elf_find_verdep_info *, const char *[]);
+ (struct elf_find_verdep_info *, const char *const []);
extern void _bfd_elf_link_add_dt_relr_dependency
(struct elf_find_verdep_info *);
diff --git a/bfd/elf.c b/bfd/elf.c
index dfa04c9..1b2e331 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -10948,7 +10948,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
type = bfd_get_32 (abfd, note->descdata);
- struct
+ static const struct
{
const char *type_name;
unsigned long min_size;
@@ -13345,7 +13345,7 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset,
case bfd_core:
{
#define GROKER_ELEMENT(S,F) {S, sizeof (S) - 1, F}
- struct
+ static const struct
{
const char * string;
size_t len;
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index b5d1866..df60430 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -12542,7 +12542,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto,
case R_ARM_THM_ALU_ABS_G2_NC:
case R_ARM_THM_ALU_ABS_G3_NC:
{
- const int shift_array[4] = {0, 8, 16, 24};
+ static const int shift_array[4] = {0, 8, 16, 24};
bfd_vma insn = bfd_get_16 (input_bfd, hit_data);
bfd_vma addr = value;
int shift = shift_array[r_type - R_ARM_THM_ALU_ABS_G0_NC];
@@ -14061,11 +14061,12 @@ set_secondary_compatible_arch (bfd *abfd, int arch)
static int
tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
- int newtag, int secondary_compat, const char* name_table[])
+ int newtag, int secondary_compat,
+ const char *const name_table[])
{
#define T(X) TAG_CPU_ARCH_##X
int tagl, tagh, result;
- const int v6t2[] =
+ static const int v6t2[] =
{
T(V6T2), /* PRE_V4. */
T(V6T2), /* V4. */
@@ -14077,7 +14078,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V7), /* V6KZ. */
T(V6T2) /* V6T2. */
};
- const int v6k[] =
+ static const int v6k[] =
{
T(V6K), /* PRE_V4. */
T(V6K), /* V4. */
@@ -14090,7 +14091,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V7), /* V6T2. */
T(V6K) /* V6K. */
};
- const int v7[] =
+ static const int v7[] =
{
T(V7), /* PRE_V4. */
T(V7), /* V4. */
@@ -14104,7 +14105,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V7), /* V6K. */
T(V7) /* V7. */
};
- const int v6_m[] =
+ static const int v6_m[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14119,7 +14120,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V7), /* V7. */
T(V6_M) /* V6_M. */
};
- const int v6s_m[] =
+ static const int v6s_m[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14135,7 +14136,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V6S_M), /* V6_M. */
T(V6S_M) /* V6S_M. */
};
- const int v7e_m[] =
+ static const int v7e_m[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14152,7 +14153,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V7E_M), /* V6S_M. */
T(V7E_M) /* V7E_M. */
};
- const int v8[] =
+ static const int v8[] =
{
T(V8), /* PRE_V4. */
T(V8), /* V4. */
@@ -14177,7 +14178,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V8), /* V8.3. */
T(V8), /* V8.1-M.MAIN. */
};
- const int v8r[] =
+ static const int v8r[] =
{
T(V8R), /* PRE_V4. */
T(V8R), /* V4. */
@@ -14196,7 +14197,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V8), /* V8. */
T(V8R), /* V8R. */
};
- const int v8m_baseline[] =
+ static const int v8m_baseline[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14216,7 +14217,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
-1, /* V8R. */
T(V8M_BASE) /* V8-M BASELINE. */
};
- const int v8m_mainline[] =
+ static const int v8m_mainline[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14237,7 +14238,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V8M_MAIN), /* V8-M BASELINE. */
T(V8M_MAIN) /* V8-M MAINLINE. */
};
- const int v8_1m_mainline[] =
+ static const int v8_1m_mainline[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14262,7 +14263,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
-1, /* Unused (20). */
T(V8_1M_MAIN) /* V8.1-M MAINLINE. */
};
- const int v9[] =
+ static const int v9[] =
{
T(V9), /* PRE_V4. */
T(V9), /* V4. */
@@ -14288,7 +14289,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V9), /* V8.1-M.MAIN. */
T(V9), /* V9. */
};
- const int v4t_plus_v6_m[] =
+ static const int v4t_plus_v6_m[] =
{
-1, /* PRE_V4. */
-1, /* V4. */
@@ -14315,7 +14316,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out,
T(V9), /* V9. */
T(V4T_PLUS_V6_M) /* V4T plus V6_M. */
};
- const int *comb[] =
+ static const int *const comb[] =
{
v6t2,
v6k,
@@ -14539,7 +14540,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info)
int secondary_compat = -1, secondary_compat_out = -1;
unsigned int saved_out_attr = out_attr[i].i;
int arch_attr;
- static const char *name_table[] =
+ static const char *const name_table[] =
{
/* These aren't real CPU names, but we can't guess
that from the architecture version alone. */
diff --git a/bfd/elflink.c b/bfd/elflink.c
index cdd58b2..7b03754 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -2380,7 +2380,7 @@ elf_link_add_glibc_verneed (struct elf_find_verdep_info *rinfo,
void
_bfd_elf_link_add_glibc_version_dependency
(struct elf_find_verdep_info *rinfo,
- const char *version_dep[])
+ const char *const version_dep[])
{
Elf_Internal_Verneed *t = NULL;
int glibc_minor_base = INT_MAX;
@@ -2405,7 +2405,7 @@ _bfd_elf_link_add_dt_relr_dependency (struct elf_find_verdep_info *rinfo)
{
if (rinfo->info->enable_dt_relr)
{
- const char *version[] =
+ static const char *const version[] =
{
"GLIBC_ABI_DT_RELR",
NULL
diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 1200032..3567573 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -43,7 +43,7 @@ static bfd_reloc_status_type riscv_elf_ignore_reloc
/* The relocation table used for SHT_RELA sections. */
-static reloc_howto_type howto_table[] =
+static const reloc_howto_type howto_table[] =
{
/* No relocation. */
HOWTO (R_RISCV_NONE, /* type */
@@ -879,7 +879,7 @@ static reloc_howto_type howto_table[] =
false) /* pcrel_offset */
};
-static reloc_howto_type howto_table_internal[] =
+static const reloc_howto_type howto_table_internal[] =
{
/* R_RISCV_DELETE. */
EMPTY_HOWTO (0),
@@ -1204,7 +1204,7 @@ struct riscv_implicit_subset
const riscv_subset_t *);
};
/* Please added in order since this table is only run once time. */
-static struct riscv_implicit_subset riscv_implicit_subsets[] =
+static const struct riscv_implicit_subset riscv_implicit_subsets[] =
{
{"g", "+i,+m,+a,+f,+d,+zicsr,+zifencei", check_implicit_always},
{"e", "+i", check_implicit_always},
@@ -1336,7 +1336,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] =
};
/* This table records the mapping form RISC-V Profiles into march string. */
-static struct riscv_profiles riscv_profiles_table[] =
+static const struct riscv_profiles riscv_profiles_table[] =
{
/* RVI20U only contains the base extension 'i' as mandatory extension. */
{"rvi20u64", "rv64i"},
@@ -1408,7 +1408,7 @@ struct riscv_supported_ext
/* The standard extensions must be added in canonical order. */
-static struct riscv_supported_ext riscv_supported_std_ext[] =
+static const struct riscv_supported_ext riscv_supported_std_ext[] =
{
{"e", ISA_SPEC_CLASS_20191213, 1, 9, 0 },
{"e", ISA_SPEC_CLASS_20190608, 1, 9, 0 },
@@ -1443,7 +1443,7 @@ static struct riscv_supported_ext riscv_supported_std_ext[] =
{NULL, 0, 0, 0, 0}
};
-static struct riscv_supported_ext riscv_supported_std_z_ext[] =
+static const struct riscv_supported_ext riscv_supported_std_z_ext[] =
{
{"zic64b", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
{"ziccamoa", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -1550,7 +1550,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] =
{NULL, 0, 0, 0, 0}
};
-static struct riscv_supported_ext riscv_supported_std_s_ext[] =
+static const struct riscv_supported_ext riscv_supported_std_s_ext[] =
{
{"sha", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
{"shcounterenw", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -1597,12 +1597,12 @@ static struct riscv_supported_ext riscv_supported_std_s_ext[] =
{NULL, 0, 0, 0, 0}
};
-static struct riscv_supported_ext riscv_supported_std_zxm_ext[] =
+static const struct riscv_supported_ext riscv_supported_std_zxm_ext[] =
{
{NULL, 0, 0, 0, 0}
};
-static struct riscv_supported_ext riscv_supported_vendor_x_ext[] =
+static const struct riscv_supported_ext riscv_supported_vendor_x_ext[] =
{
{"xcvalu", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
{"xcvbi", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 },
@@ -1639,7 +1639,7 @@ static struct riscv_supported_ext riscv_supported_vendor_x_ext[] =
{NULL, 0, 0, 0, 0}
};
-const struct riscv_supported_ext *riscv_all_supported_ext[] =
+static const struct riscv_supported_ext *riscv_all_supported_ext[] =
{
riscv_supported_std_ext,
riscv_supported_std_z_ext,
@@ -1701,7 +1701,7 @@ riscv_get_prefix_class (const char *arch)
static bool
riscv_known_prefixed_ext (const char *ext,
- struct riscv_supported_ext *known_exts)
+ const struct riscv_supported_ext *known_exts)
{
size_t i;
for (i = 0; known_exts[i].name != NULL; ++i)
@@ -1894,7 +1894,7 @@ riscv_get_default_ext_version (enum riscv_spec_class *default_isa_spec,
|| *default_isa_spec == ISA_SPEC_CLASS_NONE)
return;
- struct riscv_supported_ext *table = NULL;
+ const struct riscv_supported_ext *table = NULL;
enum riscv_prefix_ext_class class = riscv_get_prefix_class (name);
switch (class)
{
@@ -2185,7 +2185,7 @@ riscv_update_subset1 (riscv_parse_subset_t *, riscv_subset_t *, const char *);
static void
riscv_parse_add_implicit_subsets (riscv_parse_subset_t *rps)
{
- struct riscv_implicit_subset *t = riscv_implicit_subsets;
+ const struct riscv_implicit_subset *t = riscv_implicit_subsets;
for (; t->ext; t++)
{
riscv_subset_t *subset = NULL;
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 99c07d4..217864b 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -1474,7 +1474,7 @@ parse_neon_type (struct neon_type *type, char **str)
while (type->elems < NEON_MAX_TYPE_ELS)
{
enum neon_el_type thistype = NT_untyped;
- unsigned thissize = -1u;
+ unsigned long thissize = -1ul;
if (*ptr != '.')
break;
@@ -1505,14 +1505,17 @@ parse_neon_type (struct neon_type *type, char **str)
return FAIL;
}
ptr += 1;
+ if (!ISDIGIT (*ptr) || *ptr == '0')
+ goto unexpected;
thissize = strtoul (ptr, &ptr, 10);
if (thissize != 16)
{
- as_bad (_("bad size %d in type specifier"), thissize);
+ as_bad (_("bad size %lu in type specifier"), thissize);
return FAIL;
}
goto done;
default:
+ unexpected:
as_bad (_("unexpected character `%c' in type specifier"), *ptr);
return FAIL;
}
@@ -1525,12 +1528,14 @@ parse_neon_type (struct neon_type *type, char **str)
else
{
parsesize:
+ if (!ISDIGIT (*ptr) || *ptr == '0')
+ goto unexpected;
thissize = strtoul (ptr, &ptr, 10);
if (thissize != 8 && thissize != 16 && thissize != 32
&& thissize != 64)
{
- as_bad (_("bad size %d in type specifier"), thissize);
+ as_bad (_("bad size %lu in type specifier"), thissize);
return FAIL;
}
}
@@ -22470,7 +22475,8 @@ opcode_lookup (char **str)
if (parse_neon_type (&inst.vectype, str) == FAIL)
return NULL;
}
- else if (end[offset] != '\0' && !is_whitespace (end[offset]))
+
+ if (**str != '\0' && !is_whitespace (**str))
return NULL;
}
else
diff --git a/gas/testsuite/gas/arm/neon-suffix-bad.d b/gas/testsuite/gas/arm/neon-suffix-bad.d
index 7e3bdfe..3ffa493 100644
--- a/gas/testsuite/gas/arm/neon-suffix-bad.d
+++ b/gas/testsuite/gas/arm/neon-suffix-bad.d
@@ -1,3 +1,3 @@
-# name: Bad suffix for non-Neon mnemonic
+# name: Bad suffix for (non-)Neon mnemonic
# as: -mfpu=neon
# error_output: neon-suffix-bad.l
diff --git a/gas/testsuite/gas/arm/neon-suffix-bad.l b/gas/testsuite/gas/arm/neon-suffix-bad.l
index 091429d..234d95f 100644
--- a/gas/testsuite/gas/arm/neon-suffix-bad.l
+++ b/gas/testsuite/gas/arm/neon-suffix-bad.l
@@ -7,3 +7,24 @@
[^:]*:10: Error: invalid neon suffix for non neon instruction
[^:]*:11: Error: invalid neon suffix for non neon instruction
[^:]*:12: Error: invalid instruction shape -- `vcvt.f64.s32 d0,s0,#11'
+[^:]*:19: Error: unexpected character `0' .*
+#?[^:]*:19: Error: .*
+[^:]*:20: Error: unexpected character `0' .*
+#?[^:]*:20: Error: .*
+[^:]*:22: Error: unexpected character `-' .*
+#?[^:]*:22: Error: .*
+[^:]*:23: Error: bad instruction .*
+[^:]*:25: Error: bad size .*
+#?[^:]*:25: Error: .*
+[^:]*:26: Error: bad size .*
+#?[^:]*:26: Error: .*
+[^:]*:28: Error: unexpected type character `b' .*
+#?[^:]*:28: Error: .*
+[^:]*:29: Error: unexpected character ` ' .*
+#?[^:]*:29: Error: .*
+[^:]*:30: Error: .* register expected .*
+[^:]*:31: Error: unexpected character ` ' .*
+#?[^:]*:31: Error: .*
+[^:]*:32: Error: .* register expected .*
+[^:]*:34: Error: bad instruction .*
+[^:]*:35: Error: bad instruction .*
diff --git a/gas/testsuite/gas/arm/neon-suffix-bad.s b/gas/testsuite/gas/arm/neon-suffix-bad.s
index 20c60fe..50360f9 100644
--- a/gas/testsuite/gas/arm/neon-suffix-bad.s
+++ b/gas/testsuite/gas/arm/neon-suffix-bad.s
@@ -11,3 +11,25 @@ faddd.f32 d0, d0, d0
faddd.f64 d0, d0, d0
vcvt.f64.s32 d0, s0, #11
+ .arm
+ .arch armv8.6-a
+ .arch_extension simd
+ vcvt.bf16.f32 d0, q0 @ good, for reference
+
+ vcvt.bf016.f32 d0, q0
+ vcvt.bf16.f032 d0, q0
+
+ vcvt.bf-4294967280.f32 d0, q0
+ vcvt.bf16.f-4294967264 d0, q0
+
+ vcvt.bf4294967312.f32 d0, q0
+ vcvt.bf16.f4294967328 d0, q0
+
+ vcvt.b f16.f32 d0, q0
+ vcvt.bf 16.f32 d0, q0
+ vcvt.bf16 .f32 d0, q0
+ vcvt.bf16. f32 d0, q0
+ vcvt.bf16.f 32 d0, q0
+
+ vcvt.bf16.f32d0, q0
+ vcvt.bf16.fd0, q0
diff --git a/gdb/testsuite/gdb.base/color-prompt.exp b/gdb/testsuite/gdb.base/color-prompt.exp
new file mode 100644
index 0000000..c037185
--- /dev/null
+++ b/gdb/testsuite/gdb.base/color-prompt.exp
@@ -0,0 +1,29 @@
+# Copyright 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
+# 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/>.
+
+# Check using a prompt with color in CLI.
+
+# Using tuiterm requires setting TERM on host.
+require {!is_remote host}
+
+# We use a tuiterm, which allows us to determine cursor position.
+tuiterm_env
+Term::clean_restart 8 80
+
+# We start with an empty screen, to generate a visible prompt.
+Term::gen_prompt
+
+set tui 0
+source $srcdir/$subdir/../gdb.tui/color-prompt.exp.tcl
diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp
index f703c18..81f6f19 100644
--- a/gdb/testsuite/gdb.base/exprs.exp
+++ b/gdb/testsuite/gdb.base/exprs.exp
@@ -285,11 +285,14 @@ gdb_test "print v_short + " \
gdb_test "print v_short =}{= 3" \
"A syntax error in expression, near `\\}\\{= 3'\\."
+set hs {[^\r\n]}
+set re_debug [string cat $hs* {[Ss]hift} $hs*]
+
gdb_test_no_output "set debug parse 1"
set saw_start 0
set saw_val 0
gdb_test_multiple "print 23" "print with debugging" -lbl {
- -re "\r\nStarting parse(?=\r\n)" {
+ -re "\r\n${re_debug}(?=\r\n)" {
set saw_start 1
exp_continue
}
diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp
index 35c99bd..48b90da 100644
--- a/gdb/testsuite/gdb.tui/basic.exp
+++ b/gdb/testsuite/gdb.tui/basic.exp
@@ -112,5 +112,9 @@ set re_noattr "\[^<\]"
set status_window_line 15
set status [Term::get_line_with_attrs $status_window_line]
-gdb_assert { [regexp "^<reverse:1>$re_noattr*<reverse:0>$" $status] == 1} \
+verbose -log "status line: '$status'"
+
+# The status line uses standout, which may translate to different attributes
+# depending on the terminal settings. Just check for at least one attribute.
+gdb_assert { [regexp "^<.*>exec" $status] == 1 } \
"status window: reverse"
diff --git a/gdb/testsuite/gdb.tui/color-prompt.exp b/gdb/testsuite/gdb.tui/color-prompt.exp
index a95b24a..af6e467 100644
--- a/gdb/testsuite/gdb.tui/color-prompt.exp
+++ b/gdb/testsuite/gdb.tui/color-prompt.exp
@@ -15,18 +15,16 @@
# Check using a prompt with color in TUI.
+require allow_tui_tests
+
tuiterm_env
Term::clean_restart 24 80
-# Set colored prompt.
if {![Term::enter_tui]} {
unsupported "TUI not supported"
return
}
-Term::command "set prompt \\033\[31m(gdb) \\033\[0m"
-
-set line [Term::get_line_with_attrs $Term::_cur_row]
-gdb_assert { [regexp "^<fg:red>$gdb_prompt <fg:default> *$" $line] } \
- "prompt with color"
+set tui 1
+source $srcdir/$subdir/color-prompt.exp.tcl
diff --git a/gdb/testsuite/gdb.tui/color-prompt.exp.tcl b/gdb/testsuite/gdb.tui/color-prompt.exp.tcl
new file mode 100644
index 0000000..e6f4d3b
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/color-prompt.exp.tcl
@@ -0,0 +1,80 @@
+# Copyright 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
+# 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/>.
+
+# Check using a prompt with color in TUI ($tui == 0) or CLI ($tui == 0).
+
+set csi [string cat {\033} "\["]
+set rl_prompt_start_ignore {\001}
+set rl_prompt_end_ignore {\002}
+
+foreach_with_prefix rl_prompt_start_end_ignore { 0 1 } {
+ set color_on [string cat $csi 31m]
+ set color_off [string cat $csi 0m]
+
+ if { $rl_prompt_start_end_ignore } {
+ set color_on \
+ [string cat \
+ $rl_prompt_start_ignore \
+ $color_on \
+ $rl_prompt_end_ignore]
+ set color_off \
+ [string cat \
+ $rl_prompt_start_ignore \
+ $color_off \
+ $rl_prompt_end_ignore]
+ }
+
+ # Set prompt with color.
+ set prompt "${color_on}(gdb) $color_off"
+ Term::command "set prompt $prompt"
+
+ # Check the color.
+ set line [Term::get_line_with_attrs $Term::_cur_row]
+ gdb_assert { [regexp "^<fg:red>$gdb_prompt <fg:default> *$" $line] } \
+ "prompt with color"
+
+ # Type a string.
+ set cmd "some long command"
+ send_gdb $cmd
+ Term::wait_for_line ^[string_to_regexp "(gdb) $cmd"] 23
+
+ # Send ^A, aka C-a, trigger beginning-of-line.
+ send_gdb "\001"
+ if { $tui || $rl_prompt_start_end_ignore } {
+ Term::wait_for_line ^[string_to_regexp "(gdb) $cmd"] 6
+ } else {
+ # Without the markers, readline may get the cursor position wrong, so
+ # match less strict.
+ Term::wait_for_line ^[string_to_regexp "(gdb) $cmd"]
+ }
+ Term::dump_screen
+
+ # Type something else to flush out the effect of the ^A.
+ set prefix "A"
+ send_gdb $prefix
+ if { $tui || $rl_prompt_start_end_ignore } {
+ Term::wait_for_line ^[string_to_regexp "(gdb) $prefix$cmd"] 7
+ } else {
+ # Without the markers, readline may get the cursor position wrong, so
+ # match less strict.
+ Term::wait_for_line [string_to_regexp "$prefix"]
+ }
+
+ # Abort command line editing, and regenerate prompt.
+ send_gdb "\003"
+
+ # Reset prompt to default prompt.
+ Term::command "set prompt (gdb) "
+}
diff --git a/gdb/testsuite/gdb.tui/main-2.exp b/gdb/testsuite/gdb.tui/main-2.exp
index 71ad03b..14a7cb1 100644
--- a/gdb/testsuite/gdb.tui/main-2.exp
+++ b/gdb/testsuite/gdb.tui/main-2.exp
@@ -41,7 +41,7 @@ if {![Term::enter_tui]} {
set line " return 0;"
set nr [gdb_get_line_number $line]
-set screen_line [Term::get_string_with_attrs 6 1 79]
+set screen_line [Term::get_string_with_attrs 6 11 79]
verbose -log "screen line 6: '$screen_line'"
-gdb_assert { [regexp "$nr <reverse:1>$line<reverse:0>" $screen_line] } \
+gdb_assert { [regexp "<reverse:1>$line<reverse:0>" $screen_line] } \
"highlighted line in middle of source window"
diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp
index 51623e8..47482a2 100644
--- a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp
+++ b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp
@@ -20,9 +20,13 @@ tuiterm_env
standard_testfile tui-layout-asm-short-prog.S
-if {[build_executable "failed to prepare" ${testfile} ${srcfile} \
- {debug additional_flags=-nostdlib \
- additional_flags=-nostartfiles}] == -1} {
+set opts {}
+lappend opts debug
+lappend opts additional_flags=-static
+lappend opts additional_flags=-nostdlib
+lappend opts additional_flags=-nostartfiles
+
+if { [build_executable "failed to prepare" $testfile $srcfile $opts] == -1 } {
return -1
}
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index b83b8af..f4a8702 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -92,7 +92,9 @@ namespace eval Term {
# Return 1 if tuiterm has the bw/auto_left_margin enabled.
proc _have_bw {} {
- return [string equal $Term::_TERM "ansiw"]
+ return [expr \
+ [string equal $Term::_TERM "ansiw"] \
+ || [string equal $Term::_TERM "ansis"]]
}
# Backspace.
@@ -701,6 +703,14 @@ namespace eval Term {
}
}
+ # Request Terminal Parameters (DECREQTPARM)
+ #
+ # https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+ # https://vt100.net/docs/vt100-ug/chapter3.html
+ proc _csi_x {} {
+ # Ignore.
+ }
+
# Insert string at the cursor location.
proc _insert {str} {
_log_cur "Inserted string '$str'" {
@@ -886,6 +896,31 @@ namespace eval Term {
return 1
}
+ # Accept some output from gdb and update the screen. Wait for the current
+ # screen line to match REGEXP and cursor position POS, unless POS is empty.
+ # Return 0 on timeout, 1 on success.
+ proc wait_for_line { regexp {pos ""} } {
+ variable _cur_row
+ variable _cur_col
+ variable _cols
+
+ while 1 {
+ if { [accept_gdb_output] == 0 } {
+ return 0
+ }
+
+ if { ![check_region_contents_p 0 $_cur_row $_cols 1 $regexp] } {
+ continue
+ }
+
+ if { $pos == "" || $_cur_col == $pos } {
+ break
+ }
+ }
+
+ return 1
+ }
+
# Setup the terminal with dimensions ROWSxCOLS, TERM=ansi, and execute
# BODY.
proc with_tuiterm {rows cols body} {
diff --git a/opcodes/aarch64-asm.c b/opcodes/aarch64-asm.c
index a9d0aeb..75216fd 100644
--- a/opcodes/aarch64-asm.c
+++ b/opcodes/aarch64-asm.c
@@ -40,7 +40,6 @@ static inline void
insert_fields (aarch64_insn *code, aarch64_insn value, aarch64_insn mask, ...)
{
uint32_t num;
- const aarch64_field *field;
enum aarch64_field_kind kind;
va_list va;
@@ -50,9 +49,8 @@ insert_fields (aarch64_insn *code, aarch64_insn value, aarch64_insn mask, ...)
while (num--)
{
kind = va_arg (va, enum aarch64_field_kind);
- field = &fields[kind];
insert_field (kind, code, value, mask);
- value >>= field->width;
+ value >>= aarch64_fields[kind].width;
}
va_end (va);
}
@@ -72,7 +70,7 @@ insert_all_fields_after (const aarch64_operand *self, unsigned int start,
{
kind = self->fields[i];
insert_field (kind, code, value, 0);
- value >>= fields[kind].width;
+ value >>= aarch64_fields[kind].width;
}
}
diff --git a/opcodes/aarch64-dis.c b/opcodes/aarch64-dis.c
index 179addc..3ca22bb 100644
--- a/opcodes/aarch64-dis.c
+++ b/opcodes/aarch64-dis.c
@@ -149,7 +149,6 @@ aarch64_insn
extract_fields (aarch64_insn code, aarch64_insn mask, ...)
{
uint32_t num;
- const aarch64_field *field;
enum aarch64_field_kind kind;
va_list va;
@@ -160,8 +159,7 @@ extract_fields (aarch64_insn code, aarch64_insn mask, ...)
while (num--)
{
kind = va_arg (va, enum aarch64_field_kind);
- field = &fields[kind];
- value <<= field->width;
+ value <<= aarch64_fields[kind].width;
value |= extract_field (kind, code, mask);
}
va_end (va);
@@ -184,7 +182,7 @@ extract_all_fields_after (const aarch64_operand *self, unsigned int start,
i < ARRAY_SIZE (self->fields) && self->fields[i] != FLD_NIL; ++i)
{
kind = self->fields[i];
- value <<= fields[kind].width;
+ value <<= aarch64_fields[kind].width;
value |= extract_field (kind, code, 0);
}
return value;
@@ -503,21 +501,21 @@ aarch64_ext_ldst_reglist (const aarch64_operand *self ATTRIBUTE_UNUSED,
static const struct
{
- unsigned is_reserved;
- unsigned num_regs;
- unsigned num_elements;
+ unsigned num_regs:8;
+ unsigned num_elements:8;
+ bool is_reserved:1;
} data [] =
- { {0, 4, 4},
- {1, 4, 4},
- {0, 4, 1},
- {0, 4, 2},
- {0, 3, 3},
- {1, 3, 3},
- {0, 3, 1},
- {0, 1, 1},
- {0, 2, 2},
- {1, 2, 2},
- {0, 2, 1},
+ { {4, 4, false},
+ {4, 4, true},
+ {4, 1, false},
+ {4, 2, false},
+ {3, 3, false},
+ {3, 3, true},
+ {3, 1, false},
+ {1, 1, false},
+ {2, 2, false},
+ {2, 2, true},
+ {2, 1, false},
};
/* Rt */
@@ -1240,7 +1238,8 @@ aarch64_ext_addr_simm (const aarch64_operand *self, aarch64_opnd_info *info,
info->addr.base_regno = extract_field (FLD_Rn, code, 0);
/* simm (imm9 or imm7) */
imm = extract_field (self->fields[0], code, 0);
- info->addr.offset.imm = sign_extend (imm, fields[self->fields[0]].width - 1);
+ info->addr.offset.imm
+ = sign_extend (imm, aarch64_fields[self->fields[0]].width - 1);
if (self->fields[0] == FLD_imm7
|| info->qualifier == AARCH64_OPND_QLF_imm_tag)
/* scaled immediate in ld/st pair instructions. */
diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index f7dae4b..5980841 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -223,7 +223,7 @@ aarch64_select_operand_for_sizeq_field_coding (const aarch64_opcode *opcode)
/* Instruction bit-fields.
+ Keep synced with 'enum aarch64_field_kind'. */
-const aarch64_field fields[] =
+const aarch64_field aarch64_fields[] =
{
{ 0, 0 }, /* NIL. */
{ 8, 4 }, /* CRm: in the system instructions. */
diff --git a/opcodes/aarch64-opc.h b/opcodes/aarch64-opc.h
index d46c56d..68e297f 100644
--- a/opcodes/aarch64-opc.h
+++ b/opcodes/aarch64-opc.h
@@ -251,7 +251,7 @@ struct aarch64_field
typedef struct aarch64_field aarch64_field;
-extern const aarch64_field fields[];
+extern const aarch64_field aarch64_fields[];
/* Operand description. */
@@ -427,7 +427,7 @@ static inline unsigned
get_operand_field_width (const aarch64_operand *operand, unsigned n)
{
assert (operand->fields[n] != FLD_NIL);
- return fields[operand->fields[n]].width;
+ return aarch64_fields[operand->fields[n]].width;
}
/* Return the total width of the operand *OPERAND. */
@@ -437,7 +437,7 @@ get_operand_fields_width (const aarch64_operand *operand)
int i = 0;
unsigned width = 0;
while (operand->fields[i] != FLD_NIL)
- width += fields[operand->fields[i++]].width;
+ width += aarch64_fields[operand->fields[i++]].width;
assert (width > 0 && width < 32);
return width;
}
@@ -482,7 +482,7 @@ gen_mask (int width)
static inline int
gen_sub_field (enum aarch64_field_kind kind, int lsb_rel, int width, aarch64_field *ret)
{
- const aarch64_field *field = &fields[kind];
+ const aarch64_field *field = &aarch64_fields[kind];
if (lsb_rel < 0 || width <= 0 || lsb_rel + width > field->width)
return 0;
ret->lsb = field->lsb + lsb_rel;
@@ -528,7 +528,7 @@ static inline void
insert_field (enum aarch64_field_kind kind, aarch64_insn *code,
aarch64_insn value, aarch64_insn mask)
{
- insert_field_2 (&fields[kind], code, value, mask);
+ insert_field_2 (&aarch64_fields[kind], code, value, mask);
}
/* Extract field KIND of CODE and return the value. MASK can be zero or the
@@ -538,7 +538,7 @@ static inline aarch64_insn
extract_field (enum aarch64_field_kind kind, aarch64_insn code,
aarch64_insn mask)
{
- return extract_field_2 (&fields[kind], code, mask);
+ return extract_field_2 (&aarch64_fields[kind], code, mask);
}
extern aarch64_insn