aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.rust/expr.exp
AgeCommit message (Collapse)AuthorFilesLines
2024-01-12Update copyright year range in header of all files managed by GDBAndrew Burgess1-1/+1
This commit is the result of the following actions: - Running gdb/copyright.py to update all of the copyright headers to include 2024, - Manually updating a few files the copyright.py script told me to update, these files had copyright headers embedded within the file, - Regenerating gdbsupport/Makefile.in to refresh it's copyright date, - Using grep to find other files that still mentioned 2023. If these files were updated last year from 2022 to 2023 then I've updated them this year to 2024. I'm sure I've probably missed some dates. Feel free to fix them up as you spot them.
2023-12-08Allow cast of 128-bit integer to pointerTom Tromey1-0/+5
PR rust/31082 points out that casting a 128-bit integer to a pointer will fail. This happens because a case in value_cast was not converted to use GMP. This patch fixes the problem. I am not really sure that testing against the negative value here makes sense, but I opted to just preserve the existing behavior rather than change it. Regression tested on x86-64 Fedora 38. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31082
2023-05-10gdb/rust: fix crash for expression debug with stringsAndrew Burgess1-0/+21
While working on another patch I did this: (gdb) set debug expression 1 (gdb) set language rust (gdb) p "foo" Operation: OP_AGGREGATE Type: &str Fatal signal: Segmentation fault ... etc ... The problem is that the second field of the rust_aggregate_operation is created as a nullptr, this can be seen in rust-parse.c. in the function rust_parser::parse_string(). However, in expop.h, in the function dump_for_expression, we make the assumption that the expressions will never be nullptr. I did consider moving the nullptr handling into a new function rust_aggregate_operation::dump, however, as the expression debug dumping code is not exercised as much as it might be, I would rather that this code be hardened and able to handle a nullptr without crashing, so I propose that we add nullptr handling into the general dump_for_expression function. The behaviour is now: (gdb) set debug expression 1 (gdb) set language rust (gdb) p "foo" Operation: OP_AGGREGATE Type: &str nullptr Vector: String: data_ptr Operation: UNOP_ADDR Operation: OP_STRING String: foo String: length Operation: OP_LONG Type: usize Constant: 3 evaluation of this expression requires the target program to be active (gdb) There's a new test to check for this case. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-05-01Fix crash in Rust expression parserTom Tromey1-0/+1
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
2023-01-13Rename to allow_rust_testsTom Tromey1-1/+1
This changes skip_rust_tests to invert the sense, and renames it to allow_rust_tests.
2023-01-13Use require !skip_rust_testsTom Tromey1-1/+1
This changes some tests to use "require !skip_rust_tests".
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker1-1/+1
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.
2022-05-16gdb/testsuite: fix "continue outside of loop" TCL errorsBruno Larsen1-2/+2
Many test cases had a few lines in the beginning that look like: if { condition } { continue } Where conditions varied, but were mostly in the form of ![runto_main] or [skip_*_tests], making it quite clear that this code block was supposed to finish the test if it entered the code block. This generates TCL errors, as most of these tests are not inside loops. All cases on which this was an obvious mistake are changed in this patch.
2022-03-28Add Rust parser check for end of expressionTom Tromey1-0/+2
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.
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker1-1/+1
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.
2021-04-22Improve code coverage of Rust testingTom Tromey1-0/+2
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.
2021-04-16Rewrite the Rust expression parserTom Tromey1-1/+5
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.
2021-01-01Update copyright year range in all GDB filesJoel Brobecker1-1/+1
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files.
2019-01-01Update copyright year range in all GDB files.Joel Brobecker1-1/+1
This commit applies all changes made after running the gdb/copyright.py script. Note that one file was flagged by the script, due to an invalid copyright header (gdb/unittests/basic_string_view/element_access/char/empty.cc). As the file was copied from GCC's libstdc++-v3 testsuite, this commit leaves this file untouched for the time being; a patch to fix the header was sent to gcc-patches first. gdb/ChangeLog: Update copyright year range in all GDB files.
2018-11-19Handle TYPE_CODE_PTR when printing Rust typesTom Tromey1-2/+2
This changes the Rust type printers to handle TYPE_CODE_PTR. The current approach is not ideal, because currently the code can't distinguish between mut and const, or between pointers and references. (These are debuginfo deficiencies, for which there are rustc bugs on file.) Meanwhile, this at least clears up the case seen in PR rust/23625. Tested on x86-64 Fedora 28. The nightly compiler gives the best results, but I regression-tested with stable and beta as well. gdb/ChangeLog 2018-11-16 Tom Tromey <tom@tromey.com> PR rust/23625: * rust-lang.c (rust_internal_print_type): Handle TYPE_CODE_PTR. gdb/testsuite/ChangeLog 2018-11-19 Tom Tromey <tom@tromey.com> PR rust/23625: * gdb.rust/simple.exp: Add ptype test. Update expected output. * gdb.rust/expr.exp: Update expected output. Change one test.
2018-04-30rust: Fix null deref when casting (PR 23124)Dan Robertson1-1/+3
Fix a null dereference when casting a value to a unit type. ChangeLog 2018-04-28 Dan Robertson <danlrobertson89@gmail.com> PR rust/23124 * gdb/rust-exp.y (convert_params_to_types): Ensure that the params pointer is not null before dereferencing it. testsuite/ChangeLog 2018-04-28 Dan Robertson <danlrobertson89@gmail.com> PR rust/23124 * gdb.rust/expr.exp: Test that the unit type is correctly parsed when casting.
2018-01-02Update copyright year range in all GDB filesJoel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files
2017-01-01update copyright year range in GDB filesJoel Brobecker1-1/+1
This applies the second part of GDB's End of Year Procedure, which updates the copyright year range in all of GDB's files. gdb/ChangeLog: Update copyright year range in all GDB files.
2016-06-10Fix PR rust/20110Tom Tromey1-0/+2
PR rust/20110 concerns the type of an integer constant that is too large for "i32", the default integer type. This patch changes the type of such a constant to i64. This is important because such values are often addresses, so truncating them by default is unfriendly. Built and regtested on x86-64 Fedora 23. 2016-06-10 Tom Tromey <tom@tromey.com> PR rust/20110: * rust-exp.y (lex_number): Don't truncate large numbers to i32. 2016-06-10 Tom Tromey <tom@tromey.com> PR rust/20110: * gdb.rust/expr.exp: Add test for integer constant larger than i32.
2016-05-17Update gdb test suite for RustTom Tromey1-0/+137
This updates the gdb test suite for Rust. 2016-05-17 Tom Tromey <tom@tromey.com> Manish Goregaokar <manishsmail@gmail.com> * lib/rust-support.exp: New file. * lib/gdb.exp (skip_rust_tests): New proc. (build_executable_from_specs): Handle rust. * lib/future.exp (gdb_find_rustc): New proc. (gdb_default_target_compile): Handle rust. * gdb.rust/expr.exp: New file. * gdb.rust/generics.exp: New file. * gdb.rust/generics.rs: New file. * gdb.rust/methods.exp: New file. * gdb.rust/methods.rs: New file. * gdb.rust/modules.exp: New file. * gdb.rust/modules.rs: New file. * gdb.rust/simple.exp: New file. * gdb.rust/simple.rs: New file.