Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of gdb commands #174

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

zakkak
Copy link
Collaborator

@zakkak zakkak commented Jul 26, 2023

Instead of waiting till the gdb output matches the expected command or timeouts, wait for the command to complete (or timeout), i.e. for the prompt to appear. This way if a command prints the expected output but doesn't complete, it's execution time is not being counted by the next waitForBufferToMatch invocation, additionally if the command completes but doesn't return the expected result we don't have to wait for the timeout. Furthermore, we can enhance the logging to see if the command timed out or completed but without matching the expected output.

To ensure the prompt appears consistently across gdb versions after every command we use the GDB/MI mode, i.e. the "--interpreter=mi" option.

Closes #173

@zakkak zakkak requested a review from Karm July 26, 2023 11:32
@zakkak zakkak marked this pull request as draft July 26, 2023 12:51
Instead of waiting till the gdb output matches the expected command or
timeouts, wait for the command to complete (or timeout), i.e. for the
prompt to appear. This way if a command prints the expected output but
doesn't complete, it's execution time is not being counted by the next
`waitForBufferToMatch` invocation, additionally if the command completes
but doesn't return the expected result we don't have to wait for the
timeout. Furthermore, we can enhance the logging to see if the command
timed out or completed but without matching the expected output.

To ensure the prompt appears consistently across gdb versions after
every command we use the GDB/MI mode, i.e. the "--interpreter=mi"
option.

Closes Karm#173
@zakkak zakkak force-pushed the 2023-07-26-improve-gdb-handling branch from 4e9aa59 to ac40ff0 Compare July 26, 2023 13:46
@zakkak
Copy link
Collaborator Author

zakkak commented Jul 26, 2023

As a side effect, GDB/MI also gives more informative output in case of failures, e.g. in https://github.com/Karm/mandrel-integration-tests/actions/runs/5669589091/job/15362638665?pr=174#step:5:1268

it shows:

Command 'bt' did not match the expected pattern '.*at org/acme/vertx/Fruit.java:48.*'.
Output was:
"bt
""Selected thread is running.
"^error,msg="Selected thread is running."(gdb)  ==> expected: <true> but was: <false>

Which is an indication that the breakpoint was not hit maybe because of the race condition described in

// Well, there is a possible race condition where the request didn't hit the app yet...

(I am rerunning the failed job to see if the issue is persistent)

@zakkak zakkak marked this pull request as ready for review July 26, 2023 15:17
@Karm
Copy link
Owner

Karm commented Jul 26, 2023

My only concern is that it breaks on older gdb, but lets move forward and merge and we can attend to that later as I don't have any apparent failure at hand now.

@Karm Karm merged commit e42c120 into Karm:master Jul 26, 2023
36 checks passed
@zakkak
Copy link
Collaborator Author

zakkak commented Jul 26, 2023

My only concern is that it breaks on older gdb, but lets move forward and merge and we can attend to that later as I don't have any apparent failure at hand now.

There is the option to make it more backwards friendly by passing --interpreter=mi2:

mi

    The newest GDB/MI interface (currently mi3). Used primarily by programs wishing to use GDB as a backend for a debugger GUI or an IDE. For more information, see [The GDB/MI Interface](https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI.html#GDB_002fMI).
mi3

    The GDB/MI interface introduced in GDB 9.1.
mi2

    The GDB/MI interface introduced in GDB 6.0.
mi1

    The GDB/MI interface introduced in GDB 5.1.

If you see any failure let me know on which gdb version it was.

@zakkak zakkak deleted the 2023-07-26-improve-gdb-handling branch July 26, 2023 22:33
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.

gdb show version times out with JDK 21+32 and latest graal/master
2 participants