backport the latest gdb fixes from master to 4.7

Review Request #121527 - Created Dec. 15, 2014 and discarded - Latest diff uploaded

Andreas Roth

I backported all the gdb related changes from master to the 4.7 branch. This also includes fixes to restore the gdb unit tests. Many thanks to Nikolai who did a great job there.
My entire git tree is available at

gdb: do not use addCommandToFront in DisassembleWidget

gdb: DebugSession: add a testing mode for unit tests

Attempt to provide a cleaner environment during unit tests, in particular do
not read the user's .gdbinit files (those can mess up breakpoint counts etc.).

gdb: match structure more closely to the GDB/MI documentation and use cmd tokens

In particular, split Result and Async records into separate categories to mirror
the GDB documentation and account for the reality that async records can come
at any time according to the GDB doc, and need to be processed in any case.
These changes should help make the debugger more robust in the long term.

fix merge error

gdb: always process async notifications from GDB

The GDB documentation says that async notifications may arrive at any time,
even when all commands have returned a result.

gdb: remove magic constants in GDBMI::StreamRecord

gdb: remove flaky DebugSession::parseStreamRecord

gdb: add braces around multi-line if statement

gdb: examineCoreFile: update IDebugSession::state() to match unit tests

gdb: update session state more robustly based on async notifications

This is a first step towards picking up changes of the running state that are
caused by user commands to GDB.

gdb: make testIgnoreHitsBreakpoint more robust to timing issues

Instead of waiting for a debugger state, wait for a combination of debugger
state + breakpoint hit-count. This ensures that the test does the right thing
even when an intermediate PausedState is encountered during program startup.
It also happens to verify that the breakpoint hitCount is updated correctly.
gdb: testManualAttach: fix timing

gdb: unit tests: make timing more robust in some tests

Wait explicitly until the debugger is idle, which should avoid accidentally
accepting an intermittent pause state; it also ensures that data reloading
has completed e.g. for the frame stack model.

gdb: unittests: remove unused WAIT_FOR_STATE_FAIL

gdb: source code formatting changes

test_gdb: remove code duplication in check whether ptrace attach is allowed

test_gdb: add missing gdb_script_empty

gdb: make loading of our Python pretty printers into gdb more robust

Instead of relying on a cmake-configured gdbinit that might end up being
moved around by the user, we add the Python path at the point where we also
determine the path to gdbinit.

REVIEW: 121464

gdb: do not crash when receiving thread-info responses with running threads

gdb can operate in a mode where gdb receives commands while the inferior (or
a subset of the threads of the inferior) is running.

REVIEW: 121465

gdb: quick fix for compile error on OSX

gdb: fix two compile errors that were missed in the previous commit

test_gdb: make more unit tests more robust to timing variances

gdb: ignore "library-loaded" async notifications

gdb: warn the user when a debug launch will kill a currently running debug session

REVIEW: 121469

correct signal/slot connections caused by using different parameter types

test_gdb: use Breakpoint::State, anticipating potential future API changes

GDB unit tests runs without any failure