aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-05-10gas: document V3 BPF atomic instructions in the GAS manualusers/jemarch/new-bpf-atomicsJose E. Marchesi2-5/+56
gas/ChangeLog: 2023-05-10 Jose E. Marchesi <jose.marchesi@oracle.com> * doc/c-bpf.texi (BPF Opcodes): Document the V3 BPF atomic instructions.
2023-05-10gas: add tests for BPF V3 atomic instructionsJose E. Marchesi5-1/+92
2023-05-10 Jose E. Marchesi <jose.marchesi@oracle.com> * testsuite/gas/bpf/atomic-v3.s: New file. * testsuite/gas/bpf/atomic-v3.d: Likewise. * testsuite/gas/bpf/atomic-v3-be.d: Likewise. * testsuite/gas/bpf/bpf.exp: Run atomic-v3 and atomic-v3-be.
2023-05-10cpu: add V3 BPF atomic instructionsJose E. Marchesi7-40/+593
This patch adds a set of new atomic instructions that were introduced in the version 3 BPF ISA: Atomic operations: xor{w,dw} xand{w,dw} xxor{w,dw} Atomic fetch-and-operate: xfadd{w,dw} xfor{w,dw} xfand{w,dw} xfxor{w,dw} Other: xchg{w,dw} xcmp{w,dw}
2023-05-10opcodes: use CGEN_INSN_LGUINT for base instructionsJose E. Marchesi19-24/+47
This patch changes the opcodes CGEN support code in order to support base instructions with opcodes past the least significative 32 bits. Note that the masks have been adapted in a previous patch. include/ChangeLog: 2023-05-10 Jose E. Marchesi <jose.marchesi@oracle.com> * opcode/cgen.h (CGEN_IVALUE): Make room for 64-bit base values. opcodes/ChangeLog: 2023-05-10 Jose E. Marchesi <jose.marchesi@oracle.com> * cgen-dis.in (print_insn): Use CGEN_INSN_LGUINT for instruction base values. * cgen-dis.c (cgen_dis_lookup_insn): Likewise. * cgen-opc.c (cgen_macro_insn_count): Likewise. * epiphany-dis.c: Regenerate. * fr30-dis.c: Likewise. * frv-dis.c: Likewise. * ip2k-dis.c: Likewise. * iq2000-dis.c: Likewise. * lm32-dis.c: Likewise. * m32c-dis.c: Likewise. * m32r-dis.c: Likewise. * mep-dis.c: Likewise. * mt-dis.c: Likewise. * or1k-dis.c: Likewise. * xstormy16-dis.c: Likewise.
2023-04-27gas: bpf: fix tests for pseudo-c syntaxJose E. Marchesi36-392/+489
This patch fixes the GAS BPF testsuite so the tests for pseudo-c syntax are actually executed. 2023-04-27 Jose E. Marchesi <jose.marchesi@oracle.com> * testsuite/gas/bpf/mem.dump: New file. * testsuite/gas/bpf/mem-pseudoc.d: Likewise. * testsuite/gas/bpf/mem.d: #dump mem.dump. * testsuite/gas/bpf/lddw.dump: New file. * testsuite/gas/bpf/lddw-pseudoc.d: Likewise. * testsuite/gas/bpf/lddw.d: #dump lddw.dump. * testsuite/gas/bpf/jump.dump: New file. * testsuite/gas/bpf/jump-pseudoc.d: Likewise * testsuite/gas/bpf/jump.d: #dump jump.dump. * testsuite/gas/bpf/jump32.dump: New file. * testsuite/gas/bpf/jump32-pseudoc.d: Likewise. * testsuite/gas/bpf/jump32.d: #dump jump32.dump. * testsuite/gas/bpf/lddw-be.dump: New file. * testsuite/gas/bpf/lddw-be-pseudoc.d: Likewise. * testsuite/gas/bpf/lddw-be.d: #dump lddw-be.dump. * testsuite/gas/bpf/indcall-1.dump: New file. * testsuite/gas/bpf/indcall-1-pseudoc.d: Likewise. * testsuite/gas/bpf/indcall-1.d: #dump indcall-1.dump. * testsuite/gas/bpf/indcall-1-pseudoc.s (main): Fix lddw instruction. * testsuite/gas/bpf/atomic.dump: New file. * testsuite/gas/bpf/atomic-pseudoc.d: Likewise. * testsuite/gas/bpf/atomic.d: #dump atomic.dump. * testsuite/gas/bpf/alu32.dump: New file. * testsuite/gas/bpf/alu32-pseudoc.d: Likewise. * testsuite/gas/bpf/alu32.d: #dump alu32.dump. * testsuite/gas/bpf/alu.dump: New file. * testsuite/gas/bpf/alu-pseudoc.d: Likewise. * testsuite/gas/bpf/alu.d: #dump alu.dump. * testsuite/gas/bpf/alu-be.dump: New file. * testsuite/gas/bpf/alu-be-pseudoc.d: Likewise. * testsuite/gas/bpf/alu-be.d: #dump alu-be.dump. * testsuite/gas/bpf/alu32-be-pseudoc.d: New file. * testsuite/gas/bpf/alu32-be-dump: Likewise. * testsuite/gas/bpf/alu32-be.d: #dump alu32-be-dump. * testsuite/gas/bpf/bpf.exp: Run *-pseudoc tests.
2023-04-27Avoid some compiler warnings in gdb.adaTom Tromey2-4/+4
Running gdb.ada/verylong.exp shows a warning from the Ada compiler: prog.adb:16:11: warning: file name does not match unit name, should be "main.adb" [enabled by default] This patch fixes the problem, and another similar one in unchecked_union.exp.
2023-04-27Fix PR30358, performance with --sort-sectionMichael Matz1-31/+61
since af31506c we only use the binary tree when section sorting is required. While its unbalanced and hence can degrade to a linear list it should otherwise have been equivalent to the old code relying on insertion sort. Unfortunately it was not. The old code directly used lang_add_section to populate the sorted list, the new code first populates the tree and only then does lang_add_section on the sorted result. In the testcase we have very many linkonce section groups, and hence lang_add_section won't actually insert anything for most of them. That limited the to-be-sorted list length previously. The tree-sorting code OTOH first created a tree of all candidates sections, including those that wouldn't be inserted by lang_add_section, hence increasing the size of the sorting problem. In the testcase the chain length went from about 1500 to 106000, and in the degenerated case (as in the testcase) that goes in quadratically. This splits out most of the early-out code from lang_add_section to its own function and uses the latter to avoid inserting into the tree. This refactoring slightly changes the order of early-out tests (the ones based on section flags is now done last, and only in lang_add_section). The new function is not a pure predicate: it can give warnings and it might change output_section, like the old early-out code did. I have also added a skip-warning case in the first discard case, whose non-existence seemed to have been an oversight. PR 30358 * ldlang.c (wont_add_section_p): Split out from ... (lang_add_section): ... here. (output_section_callback_sort): Use wont_add_section_p to not always add sections to the sort tree.
2023-04-27gdb/doc: extend the documentation of the jump commandAndrew Burgess1-0/+8
This commit addresses PR gdb/7946. While checking for bugs relating to the jump command I noticed a long standing bug that points out a deficiency with GDB's documentation of the jump command. The bug points out that 'jump 0x...' is not always the same as 'set $pc = 0x...' and then 'continue'. Writing directly to the $pc register does not update any auxiliary state, e.g. $npc on SPARC, while using 'jump' does. It felt like this would be an easy issue to address by adding a paragraph to the docs, so I took a stab at writing something suitable. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7946 Approved-By: Eli Zaretskii <eliz@gnu.org>
2023-04-27gdb/testsuite: special case '^' in gdb_test patternAndrew Burgess17-58/+109
In this commit I propose that we add special handling for the '^' when used at the start of a gdb_test pattern. Consider this usage: gdb_test "some_command" "^command output pattern" I think the intention here is pretty clear - run 'some_command', and the output from the command should be exactly 'command output pattern'. After the previous commit which tightened up how gdb_test matches the final newline and prompt we know that the only thing after the output pattern will be a single newline and prompt, and the leading '^' ensures that there's no output before 'command output pattern', so this will do what I want, right? ... except it doesn't. The command itself will also needs to be matched, so I should really write: gdb_test "some_command" "^some_command\r\ncommand output pattern" which will do what I want, right? Well, that's fine until I change the command and include some regexp character, then I have to write: gdb_test "some_command" \ "^[string_to_regexp some_command]\r\ncommand output pattern" but this all gets a bit verbose, so in most cases I simply don't bother anchoring the output with a '^', and a quick scan of the testsuite would indicate that most other folk don't both either. What I propose is this: the *only* thing that can appear immediately after the '^' is the command converted into a regexp, so lets do that automatically, moving the work into gdb_test. Thus, when I write: gdb_test "some_command" "^command output pattern" Inside gdb_test we will spot the leading '^' in the pattern, and inject the regexp version of the command after the '^', followed by a '\r\n'. My hope is that given this new ability, folk will be more inclined to anchor their output patterns when this makes sense to do so. This should increase our ability to catch any unexpected output from GDB that appears as a result of running a particular command. There is one problem case we need to consider, sometime people do this: gdb_test "" "^expected output pattern" In this case no command is sent to GDB, but we are still expecting some output from GDB. This might be a result of some asynchronous event for example. As there is no command sent to GDB (from the gdb_test) there will be no command text to parse. In this case my proposed new feature injects the command regexp, which is the empty string (as the command itself is empty), but still injects the '\r\n' after the command regexp, thus we end up with this pattern: ^\r\nexpected output pattern This extra '\r\n' is not what we should expected here, and so there is a special case inside gdb_test -- if the command is empty then don't add anything after the '^' character. There are a bunch of tests that do already use '^' followed by the command, and these can all be simplified in this commit. I've tried to run all the tests that I can to check this commit, but I am certain that there will be some tests that I manage to miss. Apologies for any regressions this commit causes, hopefully fixing the regressions will not be too hard. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-04-27gdb/testsuite: change newline patterns used in gdb_testAndrew Burgess39-241/+264
This commit makes two changes to how we match newline characters in the gdb_test proc. First, for the newline pattern between the command output and the prompt, I propose changing from '[\r\n]+' to an explicit '\r\n'. The old pattern would spot multiple newlines, and so there are a few places where, as part of this commit, I've needed to add an extra trailing '\r\n' to the pattern in the main test file, where GDB's output actually includes a blank line. But I think this is a good thing. If a command produces a blank line then we should be checking for it, the current gdb_test doesn't do that. But also, with the current gdb_test, if a blank line suddenly appears in the output, this is going to be silently ignored, and I think this is wrong, the test should fail in that case. Additionally, the existing pattern will happily match a partial newline. There are a strangely large number of tests that end with a random '.' character. Not matching a literal period, but matching any single character, this is then matching half of the trailing newline sequence, while the \[\r\n\]+ in gdb_test is matching the other half of the sequence. I can think of no reason why this would be intentional, I suspect that the expected output at one time included a period, which has since been remove, but I haven't bothered to check on this. In this commit I've removed all these unneeded trailing '.' characters. The basic rule of gdb_test after this is that the expected pattern needs to match everything up to, but not including the newline sequence immediately before the GDB prompt. This is generally how the proc is used anyway, so in almost all cases, this commit represents no significant change. Second, while I was cleaning up newline matching in gdb_test, I've also removed the '[\r\n]*' that was added to the start of the pattern passed to gdb_test_multiple. The addition of this pattern adds no value. If the user pattern matches at the start of a line then this would match against the newline sequence. But, due to the '*', if the user pattern doesn't match at the start of a line then this group doesn't care, it'll happily match nothing. As such, there's no value to it, it just adds more complexity for no gain, so I'm removing it. No tests will need updating as a consequence of this part of the patch. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-04-27gdb/testsuite: use 'return' in gdb_test_no_outputAndrew Burgess2-9/+17
A TCL proc will return the return value of the last command executed within the proc's body if there is no explicit return call, so gdb_test_no_output is already returning the return value of gdb_test_multiple. However, I'm not a fan of (relying on) this implicit return value behaviour -- I prefer to be explicit about what we are doing. So in this commit I have extended the comment on gdb_test_no_output to document the possible return values (just as gdb_test does), and explicitly call return. This should make no different to our testing, but I think it's clearer now what the gdb_test_no_output proc is expected to do. The two tests gdb.base/auxv.exp and gdb.base/list.exp both rely on the return value of gdb_test_no_output, and continue to pass after this change. I also spotted that gdb.base/watchpoint.exp could be updated to make use of gdb_test_no_output, so I did that. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-04-27gdb: remove some trailing newlines from warning messagesAndrew Burgess2-6/+6
While working on a later patch in this series, which tightens up some of our pattern matching when using gdb_test, I ran into some failures caused by some warnings having a trailing newline character. The warning function already adds a trailing newline, and it is my understanding that we should not be adding a second by including a newline at the end of any warning message. The problem cases I found were in language.c and remote.c, in this patch I fix the cases I hit, but I also checked all the other warning calls in these two files and removed any additional trailing newlines I found. In remote.c the warning actually had a newline character in the middle of the warning message (in addition to the trailing newline), which I've removed. I don't think it's helpful to forcibly split a warning as was done here -- in the middle of a sentence. Additionally, the message isn't even that long (71 characters), so I think removing this newline is an improvement. None of the expected test result need updating with this commit, currently the patterns in gdb_test will match one or more newline sequences, so the tests are as happy with one newline (after this commit) as they are with two newlines (before this commit). A later commit will change gdb_test so that it is not so forgiving, and these warnings would have caused some failures. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-04-27gdb/testsuite: fix occasional failure in gdb.base/clear_non_user_bp.expAndrew Burgess1-1/+1
I noticed that the gdb.base/clear_non_user_bp.exp test would sometimes fail when run from a particular directory. The test tries to find the number of the first internal breakpoint using this proc: proc get_first_maint_bp_num { } { gdb_test_multiple "maint info break" "find first internal bp num" { -re -wrap "(-\[0-9\]).*" { return $expect_out(1,string) } } return "" } The problem is, at the time we issue 'maint info break' there are both internal breakpoint and non-internal (user created) breakpoints in place. The user created breakpoints include the path to the source file. Sometimes, I'll be working from a directory that includes a number, like '/tmp/blah-1/gdb/etc', in which case the pattern above actually matches the '-1' from 'blah-1'. In this case there's no significant problem as it turns out that -1 is the number of the first internal breakpoint. Sometimes my directory name might be '/tmp/blah-4/gdb/etc', in which case the above pattern patches '-4' from 'blah-4'. It turns out this is also not a problem -- the test doesn't actually need the first internal breakpoint number, it just needs the number of any internal breakpoint. But sometimes my directory name might be '/tmp/blah-0/gdb/etc', in which case the pattern above matches '-0' from 'blah-0', and in this case the test fails - there is no internal breakpoint '-0'. Fix this by spotting that the internal breakpoint numbers always occurs after a '\r\n', and that they never start with a 0. Our pattern becomes: -re -wrap "\r\n(-\[1-9\]\[0-9\]*).*" { return $expect_out(1,string) } After this I'm no longer seeing any failures. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-04-27gdb, doc: add index entry for the $_inferior_thread_count convenience varTankut Baris Aktemur1-0/+1
Add a marker in the documentation for indexing the $_inferior_thread_count variable. Approved-By: Eli Zaretskii <eliz@gnu.org>
2023-04-27Add support for %x and %lx formats to the linker's vinfo() function.Nick Clifton2-1/+21
2023-04-27Automatic date update in version.inGDB Administrator1-1/+1
2023-04-26 RISC-V: Support XVentanaCondOps extensionPhilipp Tomsich7-0/+39
Ventana Micro has published the specification for their XVentanaCondOps ("conditional ops") extension at https://github.com/ventanamicro/ventana-custom-extensions/releases/download/v1.0.0/ventana-custom-extensions-v1.0.0.pdf which contains two new instructions - vt.maskc - vt.maskcn that can be used in constructing branchless sequences for various conditional-arithmetic, conditional-logical, and conditional-select operations. To support such vendor-defined instructions in the mainline binutils, this change also adds a riscv_supported_vendor_x_ext secondary dispatch table (but also keeps the behaviour of allowing any unknow X-extension to be specified in addition to the known ones from this table). As discussed, this change already includes the planned/agreed future requirements for X-extensions (which are likely to be captured in the riscv-toolchain-conventions repository): - a public specification document is available (see above) and is referenced from the gas-documentation - the naming follows chapter 27 of the RISC-V ISA specification - instructions are prefixed by a vendor-prefix (vt for Ventana) to ensure that they neither conflict with future standard extensions nor clash with other vendors bfd/ChangeLog: * elfxx-riscv.c (riscv_get_default_ext_version): Add riscv_supported_vendor_x_ext. (riscv_multi_subset_supports): Recognize INSN_CLASS_XVENTANACONDOPS. gas/ChangeLog: * doc/c-riscv.texi: Add section to list custom extensions and their documentation URLs. * testsuite/gas/riscv/x-ventana-condops.d: New test. * testsuite/gas/riscv/x-ventana-condops.s: New test. include/ChangeLog: * opcode/riscv-opc.h Add vt.maskc and vt.maskcn. * opcode/riscv.h (enum riscv_insn_class): Add INSN_CLASS_XVENTANACONDOPS. opcodes/ChangeLog: * riscv-opc.c: Add vt.maskc and vt.maskcn. Series-version: 1 Series-to: binutils@sourceware.org Series-cc: Kito Cheng <kito.cheng@sifive.com> Series-cc: Nelson Chu <nelson.chu@sifive.com> Series-cc: Greg Favor <gfavor@ventanamicro.com> Series-cc: Christoph Muellner <cmuellner@gcc.gnu.org>
2023-04-26gas: documentation for the BPF pseudo-c asm syntaxJose E. Marchesi2-6/+201
This patch expands the GAS manual in order to specify the alternate pseudo-C assembly syntax used in BPF, and now supported by the assembler. gas/ChangeLog: 2023-04-19 Jose E. Marchesi <jose.marchesi@oracle.com> PR gas/29757 * doc/c-bpf.texi (BPF Pseudo-C Syntax): New section.
2023-04-26gas: BPF pseudo-c syntax testsGuillermo E. Martinez31-5/+880
This patch expands the GAS BPF testsuite in order to also test the alternative pseudo-C syntax used in BPF assembly. This includes three main changes: - Some general GAS tests involving assignment and equality operands in expressions (such as = and ==) are disabled in bpf-* targets, because the syntax collides with the pseudo-C BPF assembly syntax. - New tests are added to the BPF GAS testsuite that test the pseudo-c syntax. Tests for all BPF instructions are included. - New tests are added to the BPF GAS testsuite that test the support for both syntaxes in the same source. gas/ChangeLog: 2023-04-20 Guillermo E. Martinez <guillermo.e.martinez@oracle.com> PR gas/29728 * testsuite/gas/all/assign-bad-recursive.d: Skip test in bpf-* targets. * testsuite/gas/all/eqv-dot.d: Likewise. * testsuite/gas/all/gas.exp: Skip other assignment tests in bpf-*. * testsuite/gas/bpf/alu-pseudoc.s: New file. * testsuite/gas/bpf/pseudoc-normal.s: Likewise. * testsuite/gas/bpf/pseudoc-normal.d: Likewise. * testsuite/gas/bpf/pseudoc-normal-be.d: Likewise. * testsuite/gas/bpf/mem-pseudoc.s: Likewise. * testsuite/gas/bpf/lddw-pseudoc.s: Likewise. * testsuite/gas/bpf/jump32-pseudoc.s: Likewise. * testsuite/gas/bpf/jump-pseudoc.s: Likewise. * testsuite/gas/bpf/indcall-1-pseudoc.s: Likewise. * testsuite/gas/bpf/atomic-pseudoc.s: Likewise. * testsuite/gas/bpf/alu32-pseudoc.s: Likewise. * testsuite/gas/bpf/*.d: Add -pseudoc variants of the tests.
2023-04-26gas: support for the BPF pseudo-c assembly syntaxGuillermo E. Martinez3-4/+1551
This patch adds support to the GNU assembler for an alternative assembly syntax used in BPF. This syntax is C-like and very unconventional for an assembly language, but it is generated by clang/llvm and is also used in inline asm templates in kernel code, so we ought to support it. After this patch, the assembler is able to parse instructions in both supported syntax: the normal assembly-like syntax and the pseudo-C syntax. Instruction formats can be mixed in the source program: the assembler recognizes the right syntax to use. gas/ChangeLog: 2023-04-20 Guillermo E. Martinez <guillermo.e.martinez@oracle.com> PR gas/29728 * config/tc-bpf.h (TC_EQUAL_IN_INSN): Define. * config/tc-bpf.c (LEX_IS_SYMBOL_COMPONENT): Define. (LEX_IS_WHITESPACE): Likewise. (LEX_IS_NEWLINE): Likewise. (LEX_IS_ARITHM_OP): Likewise. (LEX_IS_STAR): Likewise. (LEX_IS_CLSE_BR): Likewise. (LEX_IS_OPEN_BR): Likewise. (LEX_IS_EQUAL): Likewise. (LEX_IS_EXCLA): Likewise. (ST_EOI): Likewise. (MAX_TOKEN_SZ): Likewise. (init_pseudoc_lex): New function. (md_begin): Call init_pseudoc_lex. (valid_expr): New function. (build_bpf_non_generic_load): Likewise. (build_bpf_atomic_insn): Likewise. (build_bpf_jmp_insn): Likewise. (build_bpf_arithm_insn): Likewise. (build_bpf_endianness): Likewise. (build_bpf_load_store_insn): Likewise. (look_for_reserved_word): Likewise. (is_register): Likewise. (is_cast): Likewise. (get_token): Likewise. (bpf_pseudoc_to_normal_syntax): Likewise. (md_assemble): Try pseudo-C syntax if an instruction cannot be parsed.
2023-04-26sim: bpf: update to new BPF relocationsJose E. Marchesi1-1/+1
This patch updates the BPF GNU sim testsuite in order to match the new BPF relocations introduced in binutils in a recent patch [1]. [1] https://sourceware.org/pipermail/binutils/2023-March/126429.html
2023-04-26[gdb/tui] Fix length of status line stringTom de Vries1-4/+7
In commit 5d10a2041eb ("gdb: add string_file::release method") this was added: ... + std::string string_val = string.release (); ... without updating subsequent uses of string.size (), which returns 0 after the string.release () call. Fix this by: - using string_val.size () instead of string.size (), and - adding an assert that would have caught this regression. Tested on x86_64-linux. Reviewed-By: Simon Marchi <simon.marchi@efficios.com> PR tui/30389 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30389
2023-04-26Rewrite gdb_mpz::operator==Tom Tromey1-25/+19
Simon pointed out that the recent changes to gdb_mpz caused a build failure on amd64 macOS. It turns out to be somewhat difficult to overload a method in a way that will work "naturally" for all integer types; especially in a case like gdb_mpz::operator==, where it's desirable to special case all integer types that are no wider than 'long'. After a false start, I came up with this patch, which seems to work. It applies the desirable GMP special cases directly in the body, rather than via overloads. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-04-26Updated debug architecture version checks for fbsdLuis Machado1-0/+2
There are two new debug architecture version entries. I updated the code for Linux, but fbsd also needs updating. This patch does this, and should be pretty straightforward. I can't test this on native fbsd, but I'm fairly confident it should work. Signed-off-by: Luis Machado <luis.machado@arm.com>
2023-04-26Add new debug architecture versionLuis Machado2-0/+4
Teach gdb about a new debug architecture version for AArch64 (0x11). No user-visible changes. Regression-tested on aarch64-linux Ubuntu 20.04/22.04. Signed-off-by: Luis Machado <luis.machado@arm.com>
2023-04-26i386-dis.c UB shift and other tidiesAlan Modra1-94/+76
1) i386-dis.c:12055:11: runtime error: left shift of negative value -1 Bit twiddling is best done unsigned, due to UB on overflow of signed expressions. Fix this by using bfd_vma rather than bfd_signed_vma everywhere in i386-dis.c except print_displacement. 2) Return get32s and get16 value in a bfd_vma, reducing the need for temp variables. 3) Introduce get16s and get8s functions to simplify the code. 4) With some optimisation options gcc-13 legitimately complains about a fall-through in OP_I. Fix that. OP_I also doesn't need to use "mask" which was wrong for w_mode anyway. 5) Masking with & 0xffffffff is better than casting to unsigned. We don't know for sure that unsigned int is 32-bit. 6) We also don't know that unsigned char is 8 bits. Mask codep accesses everywhere. I don't expect binutils will work on anything other than an 8-bit char host, but if we are masking codep accesses in some places we might as well be consistent. (Better would be to use stdint.h types more in binutils.)
2023-04-26binutils runtest $CCAlan Modra3-9/+13
I noticed in the binutile Makefile that runtest is being invoked with CC, CC_FOR_BUILD and other compiler related flags in the environment. That doesn't work. Those variables ought to be passed on the runtest command line. After fixing that I had some fails due to binutils testprog.c now being compiled with the default "-g -O2" picked up in CFLAGS_FOR_TARGET. Hack around that by passing -O0. Also, with the binutils testsuite now taking notice of CC_FOR_TARGET, I found a couple of debuginfod.exp fails with one of my compilers that happened to be built without --debug-id being enabled by default. * Makefile.am (check-DEJAGNU): Pass $CC and other variable on the runtest command line rather than futilely in the environment. Add -O0 to CFLAGS_FOR_TARGET. * Makefile.in: Regenerate. * testsuite/binutils-all/debuginfod.exp: Compile testprog.c with -Wl,--build-id.
2023-04-26Avoid another -Werror=dangling-pointerAlan Modra1-2/+3
write.c:415:7: error: dangling pointer ‘prev_frag’ to ‘dummy’ may be used * write.c (chain_frchains_together_1): Rewrite loop as a do while to avoid false positive -Wdangling-pointer.
2023-04-26Automatic date update in version.inGDB Administrator1-1/+1
2023-04-25Use scoped_restore in varobj.cTom Tromey1-3/+2
One spot in varobj.c should use scoped_restore to save and restore input_radix. Note that the current code may fail to restore it on error, so this patch fixes a latent bug. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-04-25Remove some "goto"s from parse.cTom Tromey1-14/+12
parser_state::push_dollar has some unnecessary "goto"s. Replacing them cleans up the code. Regression tested on x86-64 Fedora 36. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-04-25section-select: Fix performance problem (PR30367)Michael Matz1-4/+12
when using many wild-statements with non-wildcard filenames we were running into quadraticness via repeatedly using lookup_name on a long list of loaded files. I've originally retained using lookup_name because that preserved existing behaviour most obviously. In particular in matching wild-statements when using a non-wildcard filename it matches against local_sym_name, not the filename member. If the wildspec would have an archive-spec or a wildcard it would use the filename member, though. Also it would load the named file (and ignore it, as being not equal to the currently considered input-statement). Rewrite this to not use lookup_name but retain the comparison against local_sym_name with a comment to that effect. PR 30367 * ldlang.c (walk_wild_section_match): Don't use lookup_name but directly compare spec and local_sym_name.
2023-04-25RISC-V: adjust logic to avoid register name symbolsJan Beulich2-27/+98
Special casing GPR names in my_getSmallExpression() leads to a number of inconsistencies. Generalize this by utilizing the md_parse_name() hook, limited to when instruction operands are being parsed (really: probed). Then both the GPR lookup there and the yet more ad hoc workaround for PR/gas 29940 can be removed (including its extension needed for making the compressed form JAL work again).
2023-04-25RISC-V: test for expected / no unexpected symbolsJan Beulich3-0/+22
Both the temporary workaround for PR/gas 29940 and the existing special casing of GPRs in my_getSmallExpression() aren't really tested anywhere (i.e. with the workarounds remove testing would still succeed). Nor is there any test for uses of symbols with names matching GPRs, where such is permitted. Before altering how this is to be dealt with, install two testcases covering the expected behavior. (For now this includes only known affected insns; re-ordering of entries in riscv_opcodes[] could, however, yield more of them.)
2023-04-25RISC-V: don't recognize bogus relocationsJan Beulich1-2/+1
With my_getSmallExpression() consistently and silently failing on relocation operators not fitting an insn, it is no longer necessary to hand it percent_op_itype[] "just in case" (i.e. to avoid errors when a subsequent parsing attempt for another operand combination might succeed). This also eliminates the latent problem of percent_op_itype[] and percent_op_stype[] growing a non-identical set of recognized relocation operators.
2023-04-25RISC-V: avoid redundant and misleading/wrong error messagesJan Beulich2-1/+9
The use of a wrong (for the insn) relocation operator (or a future one which simply isn't recognized by older gas yet) doesn't render the (rest of the) expression "bad". Furthermore alongside the error from expression() in most cases the parser would emit another error then anyway. Suppress the call to my_getExpression() in such a case, arranging for a guaranteed subsequent error message by marking the expression "illegal".
2023-04-25RISC-V: drop "percent_op" parameter from my_getOpcodeExpression()Jan Beulich1-4/+4
Both callers check for no relocations, so there's no point parsing for some. Have the function pass percent_op_null into my_getSmallExpression(). Note that there's no point passing percent_op_itype: Elsewhere, especially when processing compressed alias insns ahead of non-alias ones, this has the effect of avoiding "bad expression" errors when another parsing pass may follow (and succeed). Here, however, all alternative forms of an insn type will again start with the same O4 or O2, so avoiding errors earlier on doesn't really help. Plus constructs with a relocation specifier (as percent_op_itype would permit) can't be specified anyway, as the scrubber eats the whitespace between .insn's type and the O4 or O2 expression when that starts with % or ( - i.e. these will be seen as e.g. "i%lo(x)", and riscv_ip() looks only for whitespace when finding the end of a mnemonic.
2023-04-25RISC-V: minor effort reduction in relocation specifier parsingJan Beulich1-16/+16
The sole caller of parse_relocation() has already checked for the % prefix, so there's no need to check for it again in the strncasecmp() and there's also no reason to make the involved string literals longer than necessary.
2023-04-25[gdb/testsuite] Fix timeout in gdb.tui/empty.expTom de Vries1-2/+2
In test-case gdb.tui/empty.exp we run into: ... WARNING: timeout in accept_gdb_output PASS: gdb.tui/empty.exp: src: 90x40: box 1 ... We timeout here in Term::resize: ... # Due to the strange column resizing behavior, and because we # don't care about this intermediate resize, we don't check # the size here. wait_for "@@ resize done $_resize_count" ... because the string we're trying to match is split over two lines: ... 25 -----------------------------------------------------------------------------+No 26 ne No process In: L?? PC: ?? @@ 27 resize done 0, size = 79x40 28 (gdb) ... Fix this by dropping the "@@ " prefix. Tested on x86_64-linux.
2023-04-25[gdb/testsuite] Fix timeout in gdb.tui/completion.expTom de Vries1-1/+1
With test-case gdb.tui/completion.exp, we run into: ... WARNING: timeout in accept_gdb_output PASS: gdb.tui/completion.exp: check focus completions ... The timeout happens in this command: ... Term::command "layout src" ... which waits for: - "(gdb) layout src", and then - "(gdb) ". Because the "layout src" command enables the TUI there's just a prompt. Fix this by using Term::command_no_prompt_prefix. Tested on x86_64-linux.
2023-04-25[gdb/testsuite] Fix timeout in gdb.tui/new-layout.expTom de Vries1-1/+1
In test-case gdb.tui/new-layout.exp we run into: ... WARNING: timeout in accept_gdb_output PASS: gdb.tui/new-layout.exp: layout=cmd_only {cmd 1} {} {}: \ bottom of cmd window is blank ... The timeout happens here: ... Term::command "layout src" ... Before the "layout src" command we have: ... Screen Dump (size 80 columns x 24 rows, cursor at column 46, row 7): 0 +-tui-layout.c-------------------------+(gdb) layout example3 1 | 20 { |(gdb) layout src 2 | 21 return 0; |(gdb) winheight cmd 8 3 | 22 } |(gdb) layout example4 4 | 23 |(gdb) layout src 5 | 24 |(gdb) winheight cmd 8 6 | 25 |(gdb) layout example5 7 | 26 |(gdb) 8 | 27 | 9 | 28 | 10 | 29 | 11 | 30 | 12 | 31 | 13 | 32 | 14 | 33 | 15 | 34 | 16 | 35 | 17 | 36 | 18 | 37 | 19 | 38 | 20 | 39 | 21 | 40 | 22 +--------------------------------------+ 23 exec No process In: L?? PC: ?? ... and after: ... Screen Dump (size 80 columns x 24 rows, cursor at column 6, row 16): 0 +-tui-layout.c-----------------------------------------------------------------+ 1 | 20 { | 2 | 21 return 0; | 3 | 22 } | 4 | 23 | 5 | 24 | 6 | 25 | 7 | 26 | 8 | 27 | 9 | 28 | 10 | 29 | 11 | 30 | 12 | 31 | 13 | 32 | 14 +------------------------------------------------------------------------------+ 15 exec No process In: L?? PC: ?? 16 (gdb) 17 18 19 20 21 22 23 ... The Term::command "layout src" is waiting to match: - "(gdb) layout src", and then - "(gdb) ". The first part fails to match on a line: ... | 26 |(gdb) layout src ... because it expects the prompt at the start of the line. Fix this by allowing the prompt at the start of a window as well. Tested by x86_64-linux.
2023-04-25[gdb/testsuite] Fix timeout in gdb.tui/main.expTom de Vries1-1/+2
With test-case gdb.tui/main.exp we run into: ... WARNING: timeout in accept_gdb_output PASS: gdb.tui/main.exp: show main after file ... The problem is that this command: ... Term::command "file [standard_output_file $testfile]" ... tries to match "(gdb) $cmd", but due to the long file name, $cmd is split up over two lines: ... 16 (gdb) file /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.tui/main/ma 17 in 18 Reading symbols from /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.t 19 ui/main/main... 20 (gdb) ... Fix this by matching "Reading symbols from" instead. Tested on x86_64-linux.
2023-04-25[gdb/testsuite] Fix timeout in gdb.tui/corefile-run.expTom de Vries1-1/+2
With test-case gdb.tui/corefile-run.exp we run into: ... WARNING: timeout in accept_gdb_output PASS: gdb.tui/corefile-run.exp: load corefile ... The timeout happens in this command: ... Term::command "core-file $core" ... because it tries to match "(gdb) $cmd" but $cmd is split over two lines: ... 16 (gdb) core-file /data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb.tui/co 17 refile-run/corefile-run.core 18 [New LWP 5370] 19 Core was generated by `/data/vries/gdb/leap-15-4/build/gdb/testsuite/outputs/gdb 20 .tui/corefile-run/coref'. 21 Program terminated with signal SIGTRAP, Trace/breakpoint trap. 22 #0 main () at tui-layout.c:21 23 (gdb) ... Fix this by using send_gdb "$cmd\n" and wait_for "Program terminated" instead. Tested on x86_64-linux.
2023-04-25[gdb/testsuite] Add debug prints in Term::wait_forTom de Vries1-0/+21
The semantics of wait_for are non-trivial, and a bit hard to understand sometimes. Add some debug prints in wait_for that make it clear: - what regexps we're trying to match, - what strings we compare to the regexps, and - whether there's a match or mismatch. I've added this ad-hoc a couple of times, and it seems that it's worth having readily available. The debug prints are enabled by adding DEBUG_TUI_MATCHING=1 to the RUNTESTFLAGS: ... $ make check RUNTESTFLAGS="gdb.tui/empty.exp DEBUG_TUI_MATCHING=1" ... Tested on x86_64-linux.
2023-04-25[gdb/testsuite] Add warning for timeout in accept_gdb_outputTom de Vries1-0/+2
In accept_gdb_output we have: ... timeout { # Assume a timeout means we somehow missed the # expected result, and carry on. return 0 } ... The timeout is silent, and though in some places the return value is checked, this is not done consistently, and consequently there are silent timeouts when running the TUI testsuite (gdb.tui/*.exp and gdb.python/tui*.exp). Each timeout is 10 seconds, and there are 5 in total in the TUI tests, taking 50 seconds overall: ... real 1m0.275s user 0m10.440s sys 0m1.343s ... With an entire testsuite run taking about 30 minutes, that is about 2.5% of the time spent waiting in TUI tests. Let's make the timeouts visible using a warning, such that they can be fixed. Tested on x86_64-linux.
2023-04-25Automatic date update in version.inGDB Administrator1-1/+1
2023-04-24[gdb/testsuite] Fix auto-indent in gdb.gdb/python-helper.expTom de Vries1-10/+10
When editing gdb.gdb/python-helper.exp, auto-indent is broken in my editor (emacs). The problem is that this: ... if { 1 } { foo "{" "}"<ENTER>bar } ... produces this: ... if { 1 } { foo "{" "}" bar } ... Note that this doesn't happen for "{}". Fix this by using "\{" and "\}". Tested on x86_64-linux.
2023-04-24[gdb/testsuite] Fix gdb.gdb/python-helper.exp with -O2 -fltoTom de Vries1-19/+58
On openSUSE Leap 15.4, with gcc 7.5.0, when building gdb with -O2 -g -flto=auto, I run into: ... FAIL: gdb.gdb/python-helper.exp: hit breakpoint in outer gdb FAIL: gdb.gdb/python-helper.exp: print integer from DWARF info FAIL: gdb.gdb/python-helper.exp: print *type->main_type ... Fix the first two FAILs by using $bkptno_numopt_re. The last FAIL is due to: ... (outer-gdb) print *type->main_type^M A syntax error in expression, near `->main_type'.^M (outer-gdb) FAIL: gdb.gdb/python-helper.exp: print *type->main_type ... because: ... (outer-gdb) print type^M Attempt to use a type name as an expression^M ... Fix this by making the test unresolved if "print type" or "print type->main_type" doesn't succeed. On openSUSE Tumbleweed, with gcc 13.0.1, when building gdb with -O2 -g -flto=auto, I run into timeouts due to the breakpoint in c_print_type not hitting. Fix this by detecting the situation and bailing out. Tested on x86_64-linux.
2023-04-24[gdb/testsuite] Fix -wrap in presence of -prompt in gdb_test_multipleTom de Vries2-1/+12
While writing a gdb_test_multiple call in a test-case I tried to use -wrap in combination with -prompt and found out that it doesn't work, because -wrap uses "$gdb_prompt $" instead of $prompt_regexp. Fix this by making -wrap use $prompt_regexp. Tested on x86_64-linux.
2023-04-24gdb: remove end_stepping_range observableSimon Marchi6-57/+0
I noticed that this observable was never notified, which means we can probably safely remove it. The notification was removed in: commit 243a925328f8e3184b2356bee497181049c0174f Author: Pedro Alves <palves@redhat.com> Date: Wed Sep 9 18:23:24 2015 +0100 Replace "struct continuation" mechanism by something more extensible print_end_stepping_range_reason in turn becomes unused, so remote it as well. Change-Id: If5da5149276c282d2540097c8c4327ce0f70431a