"""Return an image of the loc component inside the given field
gdb.Value.
"""
- loc_val = field_val["loc"]
- loc_kind = str(field_val["loc_kind"])
+ loc_val = field_val["m_loc"]
+ loc_kind = str(field_val["m_loc_kind"])
if loc_kind == "FIELD_LOC_KIND_BITPOS":
return "bitpos = %d" % loc_val["bitpos"]
elif loc_kind == "FIELD_LOC_KIND_ENUMVAL":
elif loc_kind == "FIELD_LOC_KIND_DWARF_BLOCK":
return "dwarf_block = %s" % loc_val["dwarf_block"]
else:
- return "loc = ??? (unsupported loc_kind value)"
+ return "m_loc = ??? (unsupported m_loc_kind value)"
def struct_field_img(self, fieldno):
"""Return an image of the main_type field number FIELDNO."""
if f["artificial"]:
label += " (artificial)"
fields = []
- fields.append("name = %s" % f["name"])
- fields.append("type = %s" % f["m_type"])
- fields.append("loc_kind = %s" % f["loc_kind"])
+ fields.append("m_name = %s" % f["m_name"])
+ fields.append("m_type = %s" % f["m_type"])
+ fields.append("m_loc_kind = %s" % f["m_loc_kind"])
fields.append("bitsize = %d" % f["bitsize"])
fields.append(self.struct_field_location_img(f))
return label + "\n" + " {" + ",\n ".join(fields) + "}"
"scaling_factor: <opaque> (call __gmpz_dump with "
" _mp_num and _mp_den fields if needed)"
)
+ elif type_specific_kind == "TYPE_SPECIFIC_INT":
+ img = ("int_stuff = { bit_size = %d, bit_offset = %d }"
+ % (type_specific["int_stuff"]["bit_size"],
+ type_specific["int_stuff"]["bit_offset"]))
else:
img = (
- "type_specific = ??? (unknown type_secific_kind: %s)"
+ "type_specific = ??? (unknown type_specific_kind: %s)"
% type_specific_kind
)
return img
return
}
+standard_testfile .cc
+
+if { [build_executable "failed to build" $testfile $srcfile {debug c++}] } {
+ return -1
+}
+
# Find the helper script in the GDB build directory.
set py_helper_script [file dirname $GDB]/gdb-gdb.py
if { ![file readable $py_helper_script] \
"end"] ".*" \
"register the type pretty printer"
- # Now place a breakpoint somewhere useful. This can be any function that:
+ # Now place breakpoints somewhere useful. These locations can be
+ # any function that:
+ #
# (a) is easy to reach by issuing a simple gdb command, and
# (b) is unlikely to be modified very often within gdb, and
# (c) has a parameter that is either a 'struct type *' or a 'struct value *'.
- gdb_breakpoint value_print
+ gdb_breakpoint value_print qualified
+ gdb_breakpoint c_print_type qualified
+
+ # Disable all breakpoints until after we have loaded the test
+ # binary into the inner GDB.
+ gdb_test_no_output "disable breakpoints"
# Adjust the prompt on the outer gdb, this just makes things a
# little clearer when trying to unpick which GDB is active.
- gdb_test_multiple "set prompt (xgdb) " "set xgdb prompt" {
- -re "\[(\]xgdb\[)\].*\[(\]xgdb\[)\] $" {
+ gdb_test_multiple "set prompt (outer-gdb) " "set outer gdb prompt" {
+ -re "\[(\]outer-gdb\[)\].*\[(\]outer-gdb\[)\] $" {
pass $gdb_test_name
}
}
}
}
- # Send a command to the inner GDB (hence send_inferior), this
- # should result in the outer GDB stopping at the breakpoint we
- # just created.
+ # Load the test executable into the inner GDB. The output here is
+ # being read from the inner GDB, hence the use of -i here.
+ send_inferior "file -readnow $::binfile\n"
+ gdb_test_multiple "" "loading test binary into inner GDB" {
+ -i "$inferior_spawn_id"
+ -re "Reading symbols from.*\r\n$gdb_prompt $" {
+ pass $gdb_test_name
+ }
+ }
+
+ # Send Ctrl-C to the inner GDB, this should kick us back to the
+ # prompt of the outer GDB.
+ send_inferior "\003"
+ gdb_test_multiple "" "interrupted the inner" {
+ -re ".*\\(outer-gdb\\) $" {
+ pass $gdb_test_name
+ }
+ }
+
+ # Now enable all breakpoints within the outer GDB.
+ gdb_test_multiple "enable breakpoints" "" {
+ -re "\\(outer-gdb\\) $" {
+ pass $gdb_test_name
+ }
+ }
+
+ # We need to resume the inner GDB after interrupting it, this is
+ # done by sending 'continue'. However, GDB will not redisplay the
+ # prompt in this case, so we have nothing that we can detect in
+ # order to know this continue was successful. Still, if this
+ # didn't work, then later tests should fail.
+ send_gdb "continue\n"
+
+ # Control is back with the inner GDB. Send a command to the inner
+ # GDB, this should result in the outer GDB stopping at one of the
+ # breakpoints we created..
send_inferior "print 1\n"
- gdb_test_multiple "" "hit breakpoint in inner gdb" {
- -re "Breakpoint $decimal, value_print.*\\(xgdb\\) $" {
+ gdb_test_multiple "" "hit breakpoint in outer gdb" {
+ -re "Breakpoint $decimal, value_print.*\\(outer-gdb\\) $" {
pass $gdb_test_name
}
}
" instance_flags = 0," \
" length = $decimal," \
" main_type = $hex}" \
- "\\(xgdb\\) $"]
+ "\\(outer-gdb\\) $"]
gdb_test_multiple "print *val->type" "pretty print type" {
-re "$answer" {
pass $gdb_test_name
}
- -re "There is no member named.*\r\n\\(xgdb\\) $" {
+ -re "There is no member named.*\r\n\\(outer-gdb\\) $" {
fail $gdb_test_name
}
}
" owner = $hex \\(gdbarch\\)," \
" target_type = 0x0," \
" type_specific_field = TYPE_SPECIFIC_NONE}" \
- "\\(xgdb\\) $"]
+ "\\(outer-gdb\\) $"]
gdb_test_multiple "print *val->type->main_type" "pretty print type->main_type" {
-re "$answer" {
pass $gdb_test_name
}
- -re "There is no member named.*\r\n\\(xgdb\\) $" {
+ -re "There is no member named.*\r\n\\(outer-gdb\\) $" {
+ fail $gdb_test_name
+ }
+ }
+
+ # Send the continue to the outer GDB, which resumes the inner GDB,
+ # we then detect the prompt from the inner GDB, hence the use of
+ # -i here.
+ gdb_test_multiple "continue" "resume inner gdb" {
+ -i $inferior_spawn_id
+ -re "\r\n$gdb_prompt $" {
+ pass $gdb_test_name
+ }
+ }
+
+ # Now print an integer that was created from the DWARF
+ # information, this will include the TYPE_SPECIFIC_INT
+ # information.
+ send_inferior "print global_c.m_val\n"
+ gdb_test_multiple "" "print integer from DWARF info" {
+ -re "Breakpoint $decimal, value_print.*\\(outer-gdb\\) $" {
+ pass $gdb_test_name
+ }
+ }
+
+ set answer [multi_line \
+ "$decimal = " \
+ "{name = $hex \"int\"," \
+ " code = TYPE_CODE_INT," \
+ " flags = \[^\r\n\]+," \
+ " owner = $hex \\(objfile\\)," \
+ " target_type = 0x0," \
+ " int_stuff = { bit_size = $decimal, bit_offset = $decimal }}" \
+ "\\(outer-gdb\\) $"]
+ gdb_test_multiple "print *val->type->main_type" "pretty print type->main_type for DWARF type" {
+ -re "$answer" {
+ pass $gdb_test_name
+ }
+ -re "There is no member named.*\r\n\\(outer-gdb\\) $" {
+ fail $gdb_test_name
+ }
+ }
+
+ # Send the continue to the outer GDB, which resumes the inner GDB,
+ # we then detect the prompt from the inner GDB, hence the use of
+ # -i here.
+ gdb_test_multiple "continue" "resume inner gdb again" {
+ -i $inferior_spawn_id
+ -re "\r\n$gdb_prompt $" {
+ pass $gdb_test_name
+ }
+ }
+
+ # Send a command to the inner GDB, this should result in the outer
+ # GDB stopping at the value_print breakpoint again.
+ send_inferior "ptype global_c\n"
+ gdb_test_multiple "" "hit breakpoint in outer gdb again" {
+ -re "Breakpoint $decimal, c_print_type .*\\(outer-gdb\\) $" {
+ pass $gdb_test_name
+ }
+ }
+
+ set answer [multi_line \
+ "$decimal = " \
+ "{name = $hex \"CC\"," \
+ " code = TYPE_CODE_STRUCT," \
+ " flags = \[^\r\n\]+," \
+ " owner = $hex \\(objfile\\)," \
+ " target_type = 0x0," \
+ " flds_bnds\\.fields\\\[0\\\]:" \
+ " {m_name = $hex \"m_val\"," \
+ " m_type = $hex," \
+ " m_loc_kind = FIELD_LOC_KIND_BITPOS," \
+ " bitsize = 0," \
+ " bitpos = 0}," \
+ " cplus_stuff = $hex}" \
+ "\\(outer-gdb\\) $"]
+ gdb_test_multiple "print *type->main_type" "" {
+ -re "$answer" {
+ pass $gdb_test_name
+ }
+ -re "\r\n\\(outer-gdb\\) $" {
fail $gdb_test_name
}
}