Age | Commit message (Collapse) | Author | Files | Lines |
|
This changes gdb to use the C++17 [[fallthrough]] attribute rather
than special comments.
This was mostly done by script, but I neglected a few spellings and so
also fixed it up by hand.
I suspect this fixes the bug mentioned below, by switching to a
standard approach that, presumably, clang supports.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23159
Approved-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Pedro Alves <pedro@palves.net>
|
|
This function is just a wrapper around the current inferior's gdbarch.
I find that having that wrapper just obscures where the arch is coming
from, and that it's often used as "I don't know which arch to use so
I'll use this magical target_gdbarch function that gets me an arch" when
the arch should in fact come from something in the context (a thread,
objfile, symbol, etc). I think that removing it and inlining
`current_inferior ()->arch ()` everywhere will make it a bit clearer
where that arch comes from and will trigger people into reflecting
whether this is the right place to get the arch or not.
Change-Id: I79f14b4e4934c88f91ca3a3155f5fc3ea2fadf6b
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
|
|
This simplifies the parser_state constructor by having it accept a
parser_flags parameter.
|
|
"&str" is an important type in Rust -- it's the type of string
literals. However, the compiler puts it in the DWARF in a funny way.
The slice itself is present and named "&str". However, the Rust
parser doesn't look for types with names like this, but instead tries
to construct them from components. In this case it tries to make a
pointer-to-"str" -- but "str" isn't always available, and in any case
that wouldn't yield the best result.
This patch adds a special case for &str.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22251
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
|
|
A user found that an array expression with just a single value (like
"[23]") caused the Rust expression parser to crash.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30410
|
|
This adds support for 128-bit integers to the Rust parser.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21185
|
|
Replace spaces with tabs in a bunch of places.
Change-Id: If0f87180f1d13028dc178e5a8af7882a067868b0
|
|
This converts block_static_block and block_global_block to be methods.
This was mostly written by script. It was simpler to convert them at
the same time because they're often used near each other.
|
|
This converts block_scope, block_set_scope, block_using, and
block_set_using to be methods. These are all done at once to make it
easier to also convert block_initialize_namespace at the same time.
This was mostly written by script.
|
|
block_scope has special behavior when the block is NULL.
Remove this and patch up the callers instead.
|
|
This commit is the result of running the gdb/copyright.py script,
which automated the update of the copyright year range for all
source files managed by the GDB project to be updated to include
year 2023.
|
|
My earlier patch to fix PR rust/29859 introduced a new operator
precedence bug in the Rust parser. Assignment operators are
right-associative in Rust. And, while this doesn't often matter, as
Rust assignments always have the value (), still as a matter of
principle we should get this correct.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29859
|
|
PR rust/29859 points out an operator precedence bug in the Rust
parser. This patch fixes it and adds a regression test.
|
|
In commit 1390b65a1b9 ("[gdb/rust] Fix literal truncation") I forgot to add
_() around a string using in an error call.
Fix this by adding the missing _().
Tested on x86_64-linux.
|
|
Make sure we error out on overflow instead of truncating in all cases.
I've used as overflow string: "Integer literal is too large", based
on what I found at
<rust-lang/rust>/src/test/ui/parser/int-literal-too-large-span.rs
but perhaps someone has a better idea.
Tested on x86_64-linux, with a build with --enable-targets=all.
|
|
I noticed that "print 5," passed in Rust -- the parser wasn't checking
that the entire input was used. This patch fixes the problem. This
in turn pointed out another bug in the parser, namely that it didn't
lex the next token after handling a string token. This is also fixed
here.
|
|
rust-parse.c has a #define for the host-specific UTF-32 charset name.
A later patch needs the same thing, so this patch moves the definition
to charset.h for easier reuse.
|
|
Add a getter and a setter for a symbol's type. Remove the corresponding
macro and adjust all callers.
Change-Id: Ie1a137744c5bfe1df4d4f9ae5541c5299577c8de
|
|
Change-Id: I83211d5a47efc0564386e5b5ea4a29c00b1fd46a
|
|
Rust 1.53 (quite a while ago now) ungated the support for non-ASCII
identifiers. This didn't work in gdb. This is PR rust/20166.
This patch fixes the problem by allowing non-ASCII characters to be
considered as identifier components. It seemed simplest to just pass
them through -- doing any extra checking didn't seem worthwhile.
The new test also verifies that such characters are allowed in strings
and character literals as well. The latter also required a bit of
work in the lexer.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20166
|
|
In Rust, 'obj.f()' is a method call -- but '(obj.f)()' is a call of a
function-valued field 'f' in 'obj'. The Rust parser in gdb currently
gets this wrong. This is PR rust/24082.
The expression and Rust parser rewrites made this simple to fix --
simply wrapping a parenthesized expression in a new operation handles
it. This patch has a slight hack because I didn't want to introduce a
new exp_opcode enumeration constant just for this. IMO this doesn't
matter, since we should work toward removing dependencies on these
opcodes anyway; but let me know what you think of this.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24082
|
|
This moves the gdb_regex convenience class to gdbsupport.
|
|
This moves the gdb-specific obstack code -- both extensions like
obconcat and obstack_strdup, and things like auto_obstack -- to
gdbsupport.
|
|
This commit brings all the changes made by running gdb/copyright.py
as per GDB's Start of New Year Procedure.
For the avoidance of doubt, all changes in this commits were
performed by the script.
|
|
There are some loops in gdb that use ARRAY_SIZE (or a wordier
equivalent) to loop over a static array. This patch changes some of
these to use foreach instead.
Regression tested on x86-64 Fedora 34.
|
|
The Rust lex selftest fails on our Windows build. I tracked this down
to a use of UTF-32 as a parameter to convert_between_encodings. Here,
iconv_open succeeds, but the actual conversion of a tab character
fails with EILSEQ. I suspect that "UTF-32" is being interpreted as
big-endian, as changing the call to use "UTF-32LE" makes it work.
This patch implements this fix.
|
|
This patch implements Rust raw identifiers in the lexer in gdb. There
was an earlier patch to do this, but the contributor didn't reply to
my email asking whether he had sorted out his copyright assignment.
This is relatively straightforward, but a small test suite addition
was needd to ensure that the new test is skipped on older versions of
rustc -- ones that predate the introduction of raw identifiers.
gdb/ChangeLog
2021-06-11 Tom Tromey <tom@tromey.com>
PR rust/23427
* rust-parse.c (rust_parser::lex_identifier): Handle raw
identifiers.
(rust_lex_tests): Add raw identifier tests.
gdb/testsuite/ChangeLog
2021-06-11 Tom Tromey <tom@tromey.com>
PR rust/23427
* lib/rust-support.exp (rust_compiler_version): New caching proc.
* gdb.rust/rawids.exp: New file.
* gdb.rust/rawids.rs: New file.
|
|
I enabled code coverage and ran the gdb test suite, and noticed that
the new Rust parser was missing testing on a few lines that were easy
to cover. This patch mostly adds tests for certain syntax errors; but
this process also uncovered a couple of real bugs: I must have
cut-and-pasted the 'sizeof' parsing code from some other code, because
it is checking for KW_MUT (the old bison parser did not do this), and
the array length check is actually impossible because a negative
number like '-1' is parsed as two tokens.
gdb/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* rust-parse.c (rust_parser::parse_sizeof): Remove KW_MUT code.
(struct typed_val_int) <val>: Now ULONGEST.
(rust_parser::parse_array_type): Remove negative check.
(rust_lex_int_test): Change 'value' to ULONGEST.
gdb/testsuite/ChangeLog
2021-04-22 Tom Tromey <tom@tromey.com>
* gdb.rust/modules.exp: Add checks for syntax errors.
* gdb.rust/expr.exp: Add checks for syntax errors.
* gdb.rust/simple.exp: Add checks for syntax errors.
|
|
The Rust expression parser was written to construct its own AST, then
lower this to GDB expressions. I did this primarily because the old
expressions were difficult to work with; after rewriting those, I
realized I could remove the AST from the Rust parser.
After looking at this, I realized it might be simpler to rewrite the
parser. This patch reimplements it as a recursive-descent parser. I
kept a fair amount of the existing code -- the lexer is pulled in
nearly unchanged.
There are several benefits to this approach:
* The parser is shorter now (from 2882 LOC to 2351).
* The parser is just ordinary C++ code that can be debugged in the
usual way.
* Memory management in the parser is now straightforward, as
parsing methods simply return a unique pointer or vector.
This required a couple of minor changes to the test suite, as some
errors have changed.
While this passes the tests, it's possible there are lurking bugs,
particularly around error handling.
gdb/ChangeLog
2021-04-16 Tom Tromey <tom@tromey.com>
* rust-parse.c: New file.
* rust-exp.y: Remove.
* Makefile.in (COMMON_SFILES): Add rust-parse.c.
(SFILES): Remove rust-exp.y.
(YYFILES, local-maintainer-clean): Remove rust-exp.c.
gdb/testsuite/ChangeLog
2021-04-16 Tom Tromey <tom@tromey.com>
* gdb.rust/simple.exp: Change error text.
* gdb.rust/expr.exp: Change error text.
|