If not found then let's look in the fixed type. */
if (!find_struct_field (name, t1, 0,
- &field_type, &byte_offset, &bit_offset,
- &bit_size, NULL))
+ nullptr, nullptr, nullptr,
+ nullptr, nullptr))
check_tag = 1;
else
check_tag = 0;
int tag_byte_offset;
struct type *tag_type;
- if (find_struct_field ("_tag", type, 0, &tag_type, &tag_byte_offset,
+ gdb::array_view<const gdb_byte> contents;
+ if (valaddr != nullptr)
+ contents = gdb::make_array_view (valaddr, TYPE_LENGTH (type));
+ struct type *resolved_type = resolve_dynamic_type (type, contents, address);
+ if (find_struct_field ("_tag", resolved_type, 0, &tag_type, &tag_byte_offset,
NULL, NULL, NULL))
{
const gdb_byte *valaddr1 = ((valaddr == NULL)
for (i = 0; i < type->num_fields (); i += 1)
{
- int bit_pos = TYPE_FIELD_BITPOS (type, i);
- int fld_offset = offset + bit_pos / 8;
+ /* These can't be computed using TYPE_FIELD_BITPOS for a dynamic
+ type. However, we only need the values to be correct when
+ the caller asks for them. */
+ int bit_pos = 0, fld_offset = 0;
+ if (byte_offset_p != nullptr || bit_offset_p != nullptr)
+ {
+ bit_pos = TYPE_FIELD_BITPOS (type, i);
+ fld_offset = offset + bit_pos / 8;
+ }
+
const char *t_field_name = type->field (i).name ();
if (t_field_name == NULL)
if (parent_offset != -1)
{
- int bit_pos = TYPE_FIELD_BITPOS (type, parent_offset);
- int fld_offset = offset + bit_pos / 8;
+ /* As above, only compute the offset when truly needed. */
+ int fld_offset = offset;
+ if (byte_offset_p != nullptr || bit_offset_p != nullptr)
+ {
+ int bit_pos = TYPE_FIELD_BITPOS (type, parent_offset);
+ fld_offset += bit_pos / 8;
+ }
if (find_struct_field (name, type->field (parent_offset).type (),
fld_offset, field_type_p, byte_offset_p,
standard_ada_testfile foo
-if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
- return -1
-}
+foreach_with_prefix scenario {all minimal} {
+ set flags [list debug additional_flags=-fgnat-encodings=$scenario]
+
+ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != "" } {
+ return -1
+ }
-clean_restart ${testfile}
+ clean_restart ${testfile}
-set bp_top_location [gdb_get_line_number "BREAK_TOP" ${testdir}/pck.adb]
-set bp_middle_location [gdb_get_line_number "BREAK_MIDDLE" ${testdir}/pck.adb]
-set bp_bottom_location [gdb_get_line_number "BREAK_BOTTOM" ${testdir}/pck.adb]
-set bp_dyn_middle_location [gdb_get_line_number "BREAK_DYN_MIDDLE" ${testdir}/pck.adb]
+ set bp_top_location [gdb_get_line_number "BREAK_TOP" ${testdir}/pck.adb]
+ set bp_middle_location [gdb_get_line_number "BREAK_MIDDLE" ${testdir}/pck.adb]
+ set bp_bottom_location [gdb_get_line_number "BREAK_BOTTOM" ${testdir}/pck.adb]
+ set bp_dyn_middle_location [gdb_get_line_number "BREAK_DYN_MIDDLE" ${testdir}/pck.adb]
+ set bp_foo [gdb_get_line_number "STOP" ${testdir}/foo.adb]
-gdb_breakpoint "pck.adb:$bp_top_location"
-gdb_breakpoint "pck.adb:$bp_middle_location"
-gdb_breakpoint "pck.adb:$bp_bottom_location"
-gdb_breakpoint "pck.adb:$bp_dyn_middle_location"
+ gdb_breakpoint "pck.adb:$bp_top_location"
+ gdb_breakpoint "pck.adb:$bp_middle_location"
+ gdb_breakpoint "pck.adb:$bp_bottom_location"
+ gdb_breakpoint "pck.adb:$bp_dyn_middle_location"
+ gdb_breakpoint "foo.adb:$bp_foo"
-gdb_run_cmd
+ gdb_run_cmd
-gdb_test "" \
- ".*Breakpoint $decimal, pck.top.assign \\(.*\\).*" \
- "run to top assign breakpoint"
+ gdb_test "" \
+ ".*Breakpoint $decimal, pck.top.assign \\(.*\\).*" \
+ "run to top assign breakpoint"
-gdb_test "print obj.n" " = 1" "Print top component field"
+ gdb_test "print obj.n" " = 1" "Print top component field"
-gdb_test "continue" \
- ".*Breakpoint $decimal, pck.assign \\(.*\\).*" \
- "continue to bottom assign breakpoint"
+ gdb_test "continue" \
+ ".*Breakpoint $decimal, pck.assign \\(.*\\).*" \
+ "continue to bottom assign breakpoint"
-gdb_test "print obj.n" " = 4\\.0" "Print bottom component field"
+ gdb_test "print obj.n" " = 4\\.0" "Print bottom component field"
-gdb_test "continue" \
- ".*Breakpoint $decimal, pck.middle.assign \\(.*\\).*" \
- "continue to middle assign breakpoint"
+ gdb_test "continue" \
+ ".*Breakpoint $decimal, pck.middle.assign \\(.*\\).*" \
+ "continue to middle assign breakpoint"
-gdb_test "print obj.a" " = 48" \
- "Print top component field in middle assign function"
+ gdb_test "print obj.a" " = 48" \
+ "Print top component field in middle assign function"
-gdb_test "continue" \
- ".*Breakpoint $decimal, pck.assign \\(.*\\).*" \
- "continue to bottom assign breakpoint, 2nd time"
+ gdb_test "continue" \
+ ".*Breakpoint $decimal, pck.assign \\(.*\\).*" \
+ "continue to bottom assign breakpoint, 2nd time"
-gdb_test "print obj.x" " = 6" \
- "Print field existing only in bottom component"
+ gdb_test "print obj.x" " = 6" \
+ "Print field existing only in bottom component"
-gdb_test "continue" \
- ".*Breakpoint $decimal, pck.dyn_middle.assign \\(.*\\).*" \
- "continue to dyn_middle assign breakpoint"
+ gdb_test "continue" \
+ ".*Breakpoint $decimal, pck.dyn_middle.assign \\(.*\\).*" \
+ "continue to dyn_middle assign breakpoint"
-gdb_test "print obj.u" " = 42" \
- "Print field existing only in dyn_middle component"
+ gdb_test "print obj.u" " = 42" \
+ "Print field existing only in dyn_middle component"
+ gdb_test "continue" \
+ ".*Breakpoint $decimal, foo \\(.*\\).*" \
+ "continue to foo breakpoint"
+
+ gdb_test "print dma.a" " = 48" \
+ "print field in dynamic tagged type via access"
+}