Karm / mandrel-integration-tests

Integration tests for GraalVM and its Mandrel distribution. Runs Quarkus, Helidon and Micronaut applications and small targeted reproducers. The focus is solely on native-image utility and compilation of Java applications into native executables.
Apache License 2.0
5 stars 3 forks source link

Improve handling of gdb commands #174

Closed zakkak closed 11 months ago

zakkak commented 11 months ago

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 https://github.com/Karm/mandrel-integration-tests/issues/173

zakkak commented 11 months ago

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 https://github.com/Karm/mandrel-integration-tests/blob/5eace8d7031a241d3fb9f4a2b64cb083a8556198/testsuite/src/it/java/org/graalvm/tests/integration/DebugSymbolsTest.java#L405

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

Karm commented 11 months ago

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.

zakkak commented 11 months ago

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.