Skip to content

gdb/testsuite: add DAP tests for core-file state-tracking bugs#137

Open
czidev-amd wants to merge 1 commit into
amd-stagingfrom
users/czissule/dap-tests
Open

gdb/testsuite: add DAP tests for core-file state-tracking bugs#137
czidev-amd wants to merge 1 commit into
amd-stagingfrom
users/czissule/dap-tests

Conversation

@czidev-amd
Copy link
Copy Markdown

Add two tests in gdb.dap/ covering bugs reported against rocgdb 16.3, where GDB DAP's state tracker fell out of sync with the inferior after a core file was loaded.

corefile-cli-preload.exp
Spawn gdb with a core file already attached on the command line
(either '-ex "core-file "' or '-c '), then send one DAP
'initialize' request. In rocgdb 16.3 the response came back with
success=false and message="notStopped" because the pre-loaded core
was not registered as a stopped target. The test asserts
success=true; on failure, a follow-up assertion fires to flag
whether the specific "notStopped" message was returned.

corefile-after-launch.exp
Launch a binary with stopAtBeginningOfMainSubprogram, wait for the
stopped event at main, then load a core file by sending the CLI
command through a DAP 'evaluate' request in the repl context. The
evaluate succeeds and the new core inferior reaches stopped state,
but in rocgdb 16.3 every follow-up DAP request (threads, evaluate,
stackTrace, ...) returned success=false with message="notStopped"
because the state tracker missed the CLI-driven inferior switch.
The test issues 'threads', 'evaluate("info threads")', and
'stackTrace' and asserts each one succeeds.

Both tests reuse the existing gdb.dap/corefile.c source by setting testfile/srcfile/binfile manually; standard_testfile would otherwise derive the source name from the .exp basename.

The bugs do not reproduce against current trunk (gdb 18.0.50), so the tests pass today and will catch regressions if either bug returns.

@czidev-amd czidev-amd requested a review from a team as a code owner May 21, 2026 16:18
Add two tests in gdb.dap/ covering bugs reported against rocgdb 16.3,
where GDB DAP's state tracker fell out of sync with the inferior
after a core file was loaded.

corefile-cli-preload.exp
  Spawn gdb with a core file already attached on the command line
  (either '-ex "core-file <core>"' or '-c <core>'), then send one DAP
  'initialize' request.  In rocgdb 16.3 the response came back with
  success=false and message="notStopped" because the pre-loaded core
  was not registered as a stopped target.  The test asserts
  success=true; on failure, a follow-up assertion fires to flag
  whether the specific "notStopped" message was returned.

corefile-after-launch.exp
  Launch a binary with stopAtBeginningOfMainSubprogram, wait for the
  stopped event at main, then load a core file by sending the CLI
  command through a DAP 'evaluate' request in the repl context.  The
  evaluate succeeds and the new core inferior reaches stopped state,
  but in rocgdb 16.3 every follow-up DAP request (threads, evaluate,
  stackTrace, ...) returned success=false with message="notStopped"
  because the state tracker missed the CLI-driven inferior switch.
  The test issues 'threads', 'evaluate("info threads")', and
  'stackTrace' and asserts each one succeeds.

Both tests reuse the existing gdb.dap/corefile.c source by setting
testfile/srcfile/binfile manually; standard_testfile would otherwise
derive the source name from the .exp basename.

The bugs do not reproduce against current trunk (gdb 18.0.50), so the
tests pass today and will catch regressions if either bug returns.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@amd.com>
@czidev-amd czidev-amd force-pushed the users/czissule/dap-tests branch from 4c29af0 to 4e7b707 Compare May 21, 2026 16:34
@czidev-amd
Copy link
Copy Markdown
Author

Bug-fixing commit:
0a481bb — "gdb/dap: add support for opening core files" by Andrew Burgess,
2026-03-23.

@motokultivator
Copy link
Copy Markdown
Contributor

I tested, reviewed and it looks good to me.

Copy link
Copy Markdown
Collaborator

@lumachad lumachad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only some nits. Furthermore, this should be pursue upstream rather than rocgdb. Once pushed upstream, we will pick this up from the regular master syncs.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

### Test if GDB DAP doesn't recognize CLI-driven inferior state changes
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style. We don't tend to use this format of comment. I'm fine with it, but you might want to stick to single hash.

# load the core
# Then:
# - evaluate(core-file) succeeds and the core is loaded
# - All subsequent DAP requests (threads, evaluate, pause) return
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment. We don't do pause in this test.

"evaluate message is not notStopped"
}

# 3. A backtrace request on thread 1 of the new inferior must succeed.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Thread 1 a fixed thing? If we don't care about the number, then we should make it generic.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

## Test if initialize returns notStopped when core is pre-loaded via CLI
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Styling. Stick with single hash.

if {[dict exists $response message]} {
set msg [dict get $response message]
}
gdb_assert { $msg != "notStopped" } \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the title: Test if initialize returns notStopped

And then we check if it is NOT notStopped. We might want to clarify the title.

Suggestion:

"Verify initialize succeeds when a core file is pre-loaded via CLI."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants