提交 71d47611 编写于 作者: C Cleber Rosa

GDB: use gdbserver --server-sdtderr option if available

A new command line option is being added to upstream GDB. This new
option allows gdbserver's own stderr (but not its inferior process
stderr) to be redirected to another file.

If that feature is available on the about to be used gdbserver, then
let's make use of it. This redirects its stderr to /dev/null, because
avocado itself has no real use for gdbserver's own stderr output.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 7a69ae5b
......@@ -20,6 +20,7 @@ import os
import time
import fcntl
import tempfile
import commands
import subprocess
from avocado.utils import network
......@@ -457,6 +458,17 @@ class GDBServer(object):
args = [self.path]
args += self.REQUIRED_ARGS
# The output on stderr generated by gdbserver itself is of no use to
# avocado. Quite on the contrary, it gets mixed with the "inferior"
# process stderr. Support is being added to gdbserver to send its own
# stderr output somewhere else. If available, use it.
output = commands.getoutput("%s --help" % self.path)
if '--server-stderr=' in output:
self.redirected_stderr = True
args.append('--server-stderr=/dev/null')
else:
self.redirected_stderr = False
if port is None:
self.port = network.find_free_port(*self.PORT_RANGE)
else:
......
......@@ -4,6 +4,7 @@ import os
from avocado import test
from avocado import gdb
from avocado import runtime
from avocado.utils import process
......@@ -352,6 +353,23 @@ class gdbtest(test.Test):
listening_line = "Listening on port %s\n" % s.port
self.assertIn(listening_line, stderr_lines)
def test_server_stderr_redirected(self):
s = gdb.GDBServer(runtime.GDBSERVER_PATH)
if not s.redirected_stderr:
s.exit()
return
self.log.info('Testing server stderr redirection')
c = gdb.GDB()
c.connect(s.port)
c.set_file(self.return99_binary_path)
c.run()
s.exit()
# only thing in stderr should be the output generated by return99
stderr = open(s.stderr_path, 'r').read()
self.assertEqual("testing output to stderr\n", stderr)
def test_server_stdout(self):
self.log.info('Testing server stdout/stderr collection')
s = gdb.GDBServer()
......@@ -400,5 +418,6 @@ class gdbtest(test.Test):
self.test_interactive_args()
self.test_exit_status()
self.test_server_stderr()
self.test_server_stderr_redirected()
self.test_server_stdout()
self.test_interactive_stdout()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册