aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/flexible-array-member.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-01-13Rename to allow_python_testsTom Tromey1-1/+1
This changes skip_python_tests to invert the sense, and renames it to allow_python_tests.
2023-01-13Use "require" for Python testsTom Tromey1-3/+2
This changes various tests to use "require" for the Python feature.
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-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-05-04gdb/testsuite: adjust gdb.python/flexible-array-member.exp expected patternSimon Marchi1-4/+12
The `Type.range ()` tests in gdb.python/flexible-array-member.exp pass when the test is compiled with gcc 9 or later, but not with gcc 8 or earlier: $ make check TESTS="gdb.python/flexible-array-member.exp" RUNTESTFLAGS="CC_FOR_TARGET='gcc-8'" python print(zs['items'].type.range())^M (0, 0)^M (gdb) FAIL: gdb.python/flexible-array-member.exp: python print(zs['items'].type.range()) python print(zso['items'].type.range())^M (0, 0)^M (gdb) FAIL: gdb.python/flexible-array-member.exp: python print(zso['items'].type.range()) The value that we get for the upper bound of a flexible array member declared with a "0" size is 0 with gcc <= 8 and is -1 for gcc >= 9. This is due to different debug info. For this member, gcc 8 does: 0x000000d5: DW_TAG_array_type DW_AT_type [DW_FORM_ref4] (0x00000034 "int") DW_AT_sibling [DW_FORM_ref4] (0x000000e4) 0x000000de: DW_TAG_subrange_type DW_AT_type [DW_FORM_ref4] (0x0000002d "long unsigned int") For the same type, gcc 9 does: 0x000000d5: DW_TAG_array_type DW_AT_type [DW_FORM_ref4] (0x00000034 "int") DW_AT_sibling [DW_FORM_ref4] (0x000000e5) 0x000000de: DW_TAG_subrange_type DW_AT_type [DW_FORM_ref4] (0x0000002d "long unsigned int") DW_AT_count [DW_FORM_data1] (0x00) Ideally, GDB would present a consistent and documented value for an array member declared with size 0, regardless of how the debug info looks like. But for now, just change the test to accept the two values, to get rid of the failure and make the test in sync I also realized (by looking at the py-type.exp test) that calling the fields method on an array type yields one field representing the "index" of the array. The type of that field is of type range (gdb.TYPE_CODE_RANGE). When calling `.range()` on that range type, it yields the same range tuple as when calling `.range()` on the array type itself. For completeness, add some tests to access the range tuple through that range type as well. gdb/testsuite/ChangeLog: * gdb.python/flexible-array-member.exp: Adjust expected range value for member declared with 0 size. Test accessing range tuple through range type. Change-Id: Ie4e06d99fe9315527f04577888f48284d649ca4c
2021-04-22gdb/testsuite: add Python support check in gdb.python/flexible-array-member.expSimon Marchi1-0/+3
We don't want to execute this test if Python support is not compiled in GDB, add the necessary check. gdb/testsuite/ChangeLog: * gdb.python/flexible-array-member.exp: Add check for Python support. Change-Id: I853b937d2a193a0bb216566bef1a35354264b1c5
2021-04-22gdb: fix getting range of flexible array member in PythonSimon Marchi1-0/+81
As reported in bug 27757, we get an internal error when doing: $ cat test.c struct foo { int len; int items[]; }; struct foo *p; int main() { return 0; } $ gcc test.c -g -O0 -o test $ ./gdb -q -nx --data-directory=data-directory ./test -ex 'python gdb.parse_and_eval("p").type.target()["items"].type.range()' Reading symbols from ./test... /home/simark/src/binutils-gdb/gdb/gdbtypes.h:435: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) This is because the Python code (typy_range) blindly reads the high bound of the type of `items` as a constant value. Since it is a flexible array member, it has no high bound, the property is undefined. Since commit 8c2e4e0689 ("gdb: add accessors to struct dynamic_prop"), the getters check that you are not getting a property value of the wrong kind, so this causes a failed assertion. Fix it by checking if the property is indeed a constant value before accessing it as such. Otherwise, use 0. This restores the previous GDB behavior: because the structure was zero-initialized, this is what was returned before. But now this behavior is explicit and not accidental. Add a test, gdb.python/flexible-array-member.exp, that is derived from gdb.base/flexible-array-member.exp. It tests the same things, but through the Python API. It also specifically tests getting the range from the various kinds of flexible array member types (AFAIK it wasn't possible to do the equivalent through the CLI). gdb/ChangeLog: PR gdb/27757 * python/py-type.c (typy_range): Check that bounds are constant before accessing them as such. * guile/scm-type.c (gdbscm_type_range): Likewise. gdb/testsuite/ChangeLog: PR gdb/27757 * gdb.python/flexible-array-member.c: New test. * gdb.python/flexible-array-member.exp: New test. * gdb.guile/scm-type.exp (test_range): Add test for flexible array member. * gdb.guile/scm-type.c (struct flex_member): New. (main): Use it. Change-Id: Ibef92ee5fd871ecb7c791db2a788f203dff2b841