Currently there is one big caveat when running binaries inside GDB: there's
no way to perform input/output with the process `STDIN`, `STDOUT` and `STDERR`.
Currently, when using the Avocado GDB plugin, that is, when using the
`--gdb-run-bin` option, there are some caveats you should be aware of:
There are a couple of reasons for that:
* It is not currently compatible with Avocado's `--output-check-record` feature
* There's no way to perform proper input to the process, that is, manipulate its `STDIN`
* The process `STDERR` content is mixed with the content generated by `gdbserver` on its
own `STDERR` (because they are in fact, the same thing)
* The process that runs inside GDB has, by default, the same controlling `tty` of the `gdb` process that avocado *initially* runs. When avocado reaches a given breakpoint, it pauses the tests and allows the user to run another `gdb` process. This second `gdb` process is still connected to the same running process by means of a separate `gdbserver`. At this point, the process is still using the original `tty`.
But, you can still depend on the process `STDOUT`, as exemplified by this fictional
test::
* Even when using a single `tty`, there's no reliable way of separating multiple streams of data, say from `gdb` and from your application, or even `STDOUT` and `STDERR` streams from either one.
from avocado import test
from avocado.utils import process
The complete resolution to this caveat suggests the creating of a Pseudo `tty`
for the process running inside GDB, so that the process is the only entity reading
and writing to that `tty`. This will be addressed in future avocado versions.
class hello_output_test(test.Test):
def action(self):
result = process.run("/path/to/hello", ignore_status=True)
self.assertIn("hello\n", result.stdout)
If run under GDB or not, `result.stdout` behavior and content is expected to be the same.
Reasons for the caveats
~~~~~~~~~~~~~~~~~~~~~~~
There are a two basic reasons for the mentioned caveats:
* The architecture of Avocado's GDB feature
* GDB's own behavior and limitations
When using the Avocado GDB plugin, that is, `--gdb-run-bin`, avocado runs a `gdbserver` instance
transparently and controls it by means of a `gdb` process. When a given event happens, say a
breakpoint is reached, it disconnects its own `gdb` from the server, and allows the user to use
a standard `gdb` to connect to the `gdbserver`. This provides a natural and seamless user experience.
But, `gdbserver` has some limitations at this point, including:
* Not being able to set a controlling `tty`
* Not separating its own `STDERR` content from the application being run
These limitations are being addressed both on Avocado and GDB, and will be resolved in future avocado