Skip to content

Commit

Permalink
gdb/testsuite/rocm: fix test_struct size in vega20 tests
Browse files Browse the repository at this point in the history
Running gdb.rocm/lane-pc-vega20.exp with -D_GLIBCXX_DEBUG=1 enabled, I
hit this internal error:

/home/smarchi/src/wt/amd/gdb/../gdbsupport/array-view.h:190: internal-error: slice: Assertion `start + size <= m_size' failed.

at:

    #0  internal_error (file=0x5555577495e0 "/home/smarchi/src/wt/amd/gdb/../gdbsupport/array-view.h", line=190, fmt=0x55555773d5e0 "%s: Assertion `%s' failed.") at /home/smarchi/src/wt/amd/gdbsupport/errors.cc:51
    #1  0x0000555555b53350 in gdb::array_view<unsigned char>::slice (this=0x7fffffffc2a0, start=8, size=128) at /home/smarchi/src/wt/amd/gdb/../gdbsupport/array-view.h:190
    #2  0x000055555722909c in value_contents_copy_raw (dst=0x6110001d3700, dst_offset=0, src=0x6110001d2f80, src_offset=8, src_bit_offset=0, length=128) at /home/smarchi/src/wt/amd/gdb/value.c:1355
    #3  0x0000555557233571 in value_primitive_field (arg1=0x6110001d2f80, offset=8, fieldno=2, arg_type=0x621000c3ba40) at /home/smarchi/src/wt/amd/gdb/value.c:3142
    #4  0x00005555560ff905 in cp_print_value_fields (val=0x6110001d2f80, stream=0x603000044950, recurse=0, options=0x7fffffffcab0, dont_print_vb=0x0, dont_print_statmem=0) at /home/smarchi/src/wt/amd/gdb/cp-valprint.c:333
    #5  0x0000555555f69189 in c_value_print_struct (val=0x6110001d2f80, stream=0x603000044950, recurse=0, options=0x7fffffffcab0) at /home/smarchi/src/wt/amd/gdb/c-valprint.c:383
    #6  0x0000555555f69878 in c_value_print_inner (val=0x6110001d2f80, stream=0x603000044950, recurse=0, options=0x7fffffffcab0) at /home/smarchi/src/wt/amd/gdb/c-valprint.c:438
    #7  0x00005555566a87f4 in language_defn::value_print_inner (this=0x5555587ed980 <opencl_language_defn>, val=0x6110001d2f80, stream=0x603000044950, recurse=0, options=0x7fffffffcab0) at /home/smarchi/src/wt/amd/gdb/language.c:632
    #8  0x0000555557211916 in do_val_print (value=0x6110001d2f80, stream=0x603000044950, recurse=0, options=0x7fffffffcc50, language=0x5555587ed980 <opencl_language_defn>) at /home/smarchi/src/wt/amd/gdb/valprint.c:1049
    #9  0x0000555557212286 in common_val_print (val=0x6110001d2f80, stream=0x603000044950, recurse=0, options=0x7fffffffcc50, language=0x5555587ed980 <opencl_language_defn>) at /home/smarchi/src/wt/amd/gdb/valprint.c:1152
    #10 0x0000555555f6a387 in c_value_print (val=0x6110001d2f80, stream=0x603000044950, options=0x7fffffffcf00) at /home/smarchi/src/wt/amd/gdb/c-valprint.c:587
    #11 0x00005555566a8799 in language_defn::value_print (this=0x5555587ed980 <opencl_language_defn>, val=0x6110001d2f80, stream=0x603000044950, options=0x7fffffffcf00) at /home/smarchi/src/wt/amd/gdb/language.c:614
    #12 0x0000555557212522 in value_print (val=0x6110001d2f80, stream=0x603000044950, options=0x7fffffffcf00) at /home/smarchi/src/wt/amd/gdb/valprint.c:1190
    #13 0x00005555569ac849 in print_formatted (val=0x6110001d2f80, size=0, options=0x7fffffffcf00, stream=0x603000044950) at /home/smarchi/src/wt/amd/gdb/printcmd.c:338
    #14 0x00005555569b2126 in print_value (val=0x6110001d2f80, opts=...) at /home/smarchi/src/wt/amd/gdb/printcmd.c:1262
    #15 0x00005555569b2a16 in print_command_1 (args=0x7fffffffe52c "const_struct", voidprint=1) at /home/smarchi/src/wt/amd/gdb/printcmd.c:1371
    #16 0x00005555569b32a3 in print_command (exp=0x7fffffffe52c "const_struct", from_tty=1) at /home/smarchi/src/wt/amd/gdb/printcmd.c:1462
    #17 0x0000555555fadffb in do_simple_func (args=0x7fffffffe52c "const_struct", from_tty=1, c=0x61200005ddc0) at /home/smarchi/src/wt/amd/gdb/cli/cli-decode.c:95
    #18 0x0000555555fbb9b4 in cmd_func (cmd=0x61200005ddc0, args=0x7fffffffe52c "const_struct", from_tty=1) at /home/smarchi/src/wt/amd/gdb/cli/cli-decode.c:2490
    #19 0x0000555556fd00b0 in execute_command (p=0x7fffffffe537 "t", from_tty=1) at /home/smarchi/src/wt/amd/gdb/top.c:670
    #20 0x00005555567cee87 in catch_command_errors (command=0x555556fcf25c <execute_command(char const*, int)>, arg=0x7fffffffe526 "print const_struct", from_tty=1, do_bp_actions=true) at /home/smarchi/src/wt/amd/gdb/main.c:523
    #21 0x00005555567cf543 in execute_cmdargs (cmdarg_vec=0x7fffffffda80, file_type=CMDARG_FILE, cmd_type=CMDARG_COMMAND, ret=0x7fffffffd740) at /home/smarchi/src/wt/amd/gdb/main.c:618
    #22 0x00005555567d2b50 in captured_main_1 (context=0x7fffffffdf20) at /home/smarchi/src/wt/amd/gdb/main.c:1317
    #23 0x00005555567d31bb in captured_main (data=0x7fffffffdf20) at /home/smarchi/src/wt/amd/gdb/main.c:1338
    #24 0x00005555567d325c in gdb_main (args=0x7fffffffdf20) at /home/smarchi/src/wt/amd/gdb/main.c:1363
    #25 0x0000555555aa654d in main (argc=19, argv=0x7fffffffe098) at /home/smarchi/src/wt/amd/gdb/gdb.c:32

The root cause is that the hand-written DWARF in lane-pc-vega20.exp says
the test_struct is 133 (0x85) bytes long, when in reality it's 136
(0x88) bytes long.  When fetching the last member, GDB tries to create
an array_view slice that extends to the 136th byte of the value, but its
value is only 133 bytes long.

Change the byte size of test_struct in the test to reflect the actual
size.  I saw the same mistake in
gdb.rocm/aspace-watchpoint-src-vega20.exp as well, so I fixed it there
too, although I did not see that test fail.

Change-Id: Ia8bc78a7260d1b0657bd41d25667606fd3967181
  • Loading branch information
Simon Marchi authored and lmoriche committed Dec 21, 2021
1 parent e34d28a commit 28edb8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gdb/testsuite/gdb.rocm/aspace-watchpoint-src-vega20.exp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Dwarf::assemble $asmfile2 {

struct_label: structure_type {
{DW_AT_name test_struct}
{DW_AT_byte_size 0x85 DW_FORM_sdata}
{DW_AT_byte_size 0x88 DW_FORM_sdata}
{DW_AT_decl_file 1 DW_FORM_sdata}
{DW_AT_decl_line 19 DW_FORM_sdata}
} {
Expand Down
4 changes: 2 additions & 2 deletions gdb/testsuite/gdb.rocm/lane-pc-vega20.exp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Dwarf::assemble $asmfile2 {

struct_label: structure_type {
{DW_AT_name test_struct}
{DW_AT_byte_size 0x85 DW_FORM_sdata}
{DW_AT_byte_size 0x88 DW_FORM_sdata}
{DW_AT_decl_file 1 DW_FORM_sdata}
{DW_AT_decl_line 19 DW_FORM_sdata}
} {
Expand Down Expand Up @@ -288,7 +288,7 @@ Dwarf::assemble $asmfile2 {
# pointer and the new one.
local_struct_label: structure_type {
{DW_AT_name test_struct}
{DW_AT_byte_size 0x85 DW_FORM_sdata}
{DW_AT_byte_size 0x88 DW_FORM_sdata}
{DW_AT_decl_file 1 DW_FORM_sdata}
{DW_AT_decl_line 19 DW_FORM_sdata}
} {
Expand Down

0 comments on commit 28edb8d

Please sign in to comment.