Commit Graph

2333 Commits

Author SHA1 Message Date
Todd Fiala 8d7ab8c617 Added gdb-remote auxv tests.
First batch of auxv-related tests from llgs branch.

Includes helpers for unescaping gdb-remote binary-escaped
data, converting binary data from inferior endian-ness to
integral values, etc.

Tests on debugserver are expected to be skipped since it
doesn't support auxv and the tests are geared to be skipped
on platforms that don't broadcast support for the feature
in qSupported.  (llgs is listed as XFAIL since qSupported
support in llgs upstream is not there, so the support check
cannot work in upstream llgs.)

llvm-svn: 211105
2014-06-17 16:04:45 +00:00
Todd Fiala 43ab82c562 Minor gdb-remote test QListThreadsInStopReply changes from llgs branch.
llvm-svn: 211006
2014-06-15 23:33:09 +00:00
Todd Fiala 50a211bb86 Added several gdb-remote tests around QListThreadsInStopReply.
llvm-svn: 210982
2014-06-14 22:00:36 +00:00
Todd Fiala c30281afbb Added gdb-remote expedited register dupe check.
The llgs branch had a bug where register sets were not terminated with
LLDB_INVALID_REGNUM so the expedite register loop was issuing duplicate
registers.  This test was added to catch the problem.

Enhanced the key-val collection method to optionally (and by default)
support capturing duplicate values for a given key.  When that happens
and if permitted, it promotes a single key to a list and appends values
to it.

llvm-svn: 210963
2014-06-14 03:03:23 +00:00
Todd Fiala 8aae4f4312 Sync accumulated minor diffs in llgs branch gdb-remote tests.
I've been making some subtle changes to the gdb-remote tests as I implement
them in the llgs branch.  This check-in rectifies the set of diffs that
have accumulated in the llgs branch that were not present upstream.

llvm-svn: 210957
2014-06-13 23:34:17 +00:00
Todd Fiala e50b2e44ef Added gdb-remote stop packet expedited register tests.
Expedited registers currently checked for are pc, fp and sp.

Also broke out the gdb-remote base test case logic into
class gdbremote_testcase.GdbRemoteTestCaseBase in the new
gdbremote_testcase.py file.

TestGdbRemoteExpeditedRegisters.py is the first gdb-remote area
to be contained in its own test case class file.

The monolithic TestLldbGdbServer.py has been modified to derive
from gdbremote_testcase.GdbRemoteTestCaseBase.  Soon I will
pull out all the gdb-remote functional area tests from that class
into separate classes.

I'm intending to start all GdbRemote test cases with GdbRemote
so it is easy to run them all with a -p pattern match on the
test run infrastructure.

Also scanned and removed all cases of whitespace-only lines in
the files I touched.

llvm-svn: 210931
2014-06-13 19:11:33 +00:00
Todd Fiala b03127d8a0 Fix up extra whitespace from previous commit.
llvm-svn: 210821
2014-06-12 20:50:30 +00:00
Todd Fiala 8895c52a63 Added gdb-remote P/p thread suffix test.
Improved the P writes all GPR register values test.  It now
limits itself to GPR registers that are not containers for
other registers.  Pulled in improvements from the llgs branch.

Note on Linux llgs I'm able to write a much wider range
of registers successfully with $P using the bitflip test than I am able
to write with debugserver.  Might be worth drilling into.

llvm-svn: 210818
2014-06-12 20:38:56 +00:00
Todd Fiala 5cc2417532 Add gdb-remote P register write test.
Added test that attempts to write a value to each general
purpose register that is bit-flipped from the initial read
value.  It then reads it back to see if it takes.

Right now I just assert that at least one register bit flip
write succeeds.  I added a note that on the MacOSX x86_64
debugserver case, the only writes that succeed from the GPR
set are rax thru rdx, rdi, rsi and rbp.  The failures are E32
failure-at-write-attempt issues on the debugserver end.
I'll revisit this after implementing in the llgs linux-x86_64 branch.
The packet log looks good but I may have a subtle mistake in the code.

llvm-svn: 210681
2014-06-11 18:09:01 +00:00
Todd Fiala 712d1557a2 Fixed gdb-remote M test length parameter, added overwrite to test.
Initial check-in provided a nibble count instead of byte count for
the memory to write.  Fixed that.

Enhanced test to check for overwrite past the expected range of
writing to verify the correct amount is written.

llvm-svn: 210602
2014-06-10 23:12:28 +00:00
Todd Fiala 20e8edf5c7 Added gdb-remote test to verify M memory write.
llvm-svn: 210594
2014-06-10 22:15:56 +00:00
Todd Fiala f9763874b7 Added gdb-remote tests around $qSupported.
Right now it just checks that qSupported returns at least
one recognized gdb stub feature.

llvm-svn: 210573
2014-06-10 20:16:31 +00:00
Todd Fiala 697bff9cb7 Added gdb-remote test for s packet, single stepping.
llvm-svn: 210481
2014-06-09 17:46:37 +00:00
Todd Fiala 58f770ffa4 Remove invalid comment from last commit.
llvm-svn: 210376
2014-06-06 21:59:19 +00:00
Todd Fiala e76013c2ad Added gdb-remote program counter check at breakpoint.
Modified the breakpoint stop and start check to verify the program
counter printed immediately after stopping does match the breakpoint
address. This is based on a conversation with Greg Clayton clarifying
that the breakpoint stop handling code on a remote should do any and
all adjusting of the program counter at stop time, not at resume time.

Added a qProcessInfo parser and helper methods to add the collection
send/response elements to the packet flow. Removed the older pid-only
query mechanism. The parser verifies all the keys provided are within
the documented known set of key-value pairs.

Added helper routine to unpack the hex value of a $p-style register
read response according to the endian-ness of the inferior as reported
by qProcessInfo.

Added a test to verify qProcessInfo includes an endian key/value pair.

Refactored several older tests to move to the less verbose test
startup code. Most of these were the tests using the older
qProcessInfo pid-only retrieval code.

llvm-svn: 210374
2014-06-06 21:50:04 +00:00
Todd Fiala f032399bc4 Added gdb-remote test for software breakpoints.
Tests $Z0 and $z0.  Extends test exe get-code-address-hex:
to take a function name.

Enabled for debugserver, disabled for llgs.  Implementing
in llgs branch next.

llvm-svn: 210272
2014-06-05 16:34:13 +00:00
Todd Fiala 11d88bd10a Added gdb-remote $qMemoryRegionInfo tests for heap and stack.
Added two new tests: one to verify that a test exe heap address
returned is readable and writeable, and a similar one to verify
a test exe stack address is readable and writeable.

Ran the main.cpp test exe code through the Xcode re-indenter.
I was using TextMate to edit the test's C++ code alongside the
Python code but last check-in found that it was not handling
tabs/indentation the way I am intending it.

Modified test exe to require C++11.

Refactored gdb remote python code's handling of memory region
info into more re-usable methods.

llvm-svn: 210196
2014-06-04 16:42:12 +00:00
Todd Fiala 0811e71402 Add gdb-remote test for $qMemoryRegionInfo code querying.
Added test stub for collecting a code, heap and stack address.

Added test to verify that the code address returns a readable,
executable memory region and that the memory region range
was indeed the one that the code belonged to.

llvm-svn: 210187
2014-06-04 15:44:33 +00:00
Todd Fiala 99a1f2e95b Add gdb-remote test to ensure $qMemoryRegionInfo is supported.
llvm-svn: 210185
2014-06-04 14:48:22 +00:00
Todd Fiala 68c246aad0 Added gdb-remote memory read ($m) test.
Added set-memory:{content} and get-memory-address-hex: commands
to the test exe for gdb-remote.  Added a test that sets the content
via the inferior command line, then reads it back via gdb-remote
with $m.

Passing on debugserver.  Marked as fail on llgs.  Implementing
in the llgs branch next.

llvm-svn: 210116
2014-06-03 18:09:56 +00:00
Todd Fiala 732215f989 Add support for inspecting enum members.
Change by Russell Harmon.

Xcode project updates (and all errors therein)
by Todd Fiala.

llvm-svn: 210046
2014-06-02 20:55:29 +00:00
Todd Fiala a4ec2fcff9 Add executable extension to debugger name, run dotest via binary.
See http://reviews.llvm.org/D3904 for details.

Change by Scott Graham.

llvm-svn: 210036
2014-06-02 17:49:35 +00:00
Todd Fiala 9c00cf557f gdb-remote signal delivery test cleanup.
Learned that MacOSX only accepts signal delivery on a thread that is
already signal handling.  Reworked the test exe to cause a SIGSEGV
and recover if either nothing intercepts the SIGSEGV handler, or
if a SIGUSR1 is inserted.  The test uses the latter part to test
signal delivery on continue using the SIGUSR1.

I still don't have this working on MacOSX.  I'm seeing the
signal get delivered to a different thread than the one I'm
specifying with $Hc{thread-id} + $C{signo}, or with
$vCont;C{signo}:{thread-id};c.  I'll come back to this
after getting it working on the llgs branch on Linux x86_64.

llvm-svn: 209912
2014-05-30 17:59:47 +00:00
Todd Fiala 0428c97837 gdb-remote testing: new test, cleaned up socket reading.
Added new SocketPacketPump class to decouple gdb remote packet
reading from packet expectations code.  This allowed for cleaner
implementation of the separate $O output streams (non-deterministic
packaging of inferior stdout/stderr) from all the rest of the packets.

Added a packet expectation matcher that can match expected accumulated
output with a timeout.  Use a dictionary with "type":"output_match".
See lldbgdbserverutils.MatchRemoteOutputEntry for details.

Added a gdb remote test to verify that $Hc (continue thread selection)
plus signal delivery ($C{signo}) works.  Having trouble getting this
to pass with debugserver on MacOSX 10.9.  Tried different variants,
including $vCont;C{signo}:{thread-id};c.  In some cases, I get the
test exe's signal handler to run ($vCont variant first time), in others I don't
($vCont second and further times).  $C{signo} doesn't hit the signal
handler code at all in the test exe but delivers a stop.  Further
$Hc and $C{signo} deliver the stop marking the wrong thread.  For now I'm
marking the test as XFAIL on dsym/debugserver.  Will revisit this on
lldb-dev.

Updated the text exe for these tests to support thread:print-ids (each
thread announces its thread id) and provide a SIGUSR1 thread handler
that prints out the thread id on which it was signaled.

llvm-svn: 209845
2014-05-29 20:44:45 +00:00
Todd Fiala 771bb72aa7 Remove some unnecessary comments from previous check-in.
Removed a "done" TODO comment.

Moved some helper methods to the top of the unit test.

Removed some commented out code I was considering implementing
before I came up with a better overall approach.

llvm-svn: 209561
2014-05-23 22:33:42 +00:00
Todd Fiala dee6d286de Added gdb remote tests to verify $Hg{thread-id}.
Added test to check that each thread reported by $q{f,s}ThreadInfo
can be switched to by $Hg, verified by a follow-up $qC.

Modified test exe to accept "thread:new" to create a new thread 
that runs and sleeps for 5 seconds.

@llgs_test/@debugserver_test now buffer output.
   
llgs and debugserver gdbremote protocol tests now collect $O notification
output into the context returned from expect_lldb_gdbserver_replay.
context["O_count"] is an integer indicating the number of $O packets
collected during the replay, and context["O_content"] contains the
accumulated hex-decoded text output by the inferior (stdout and stderr).

Modified the $O check test to check the accumulated output rather than
a direct $O packet.

llvm-svn: 209560
2014-05-23 22:25:29 +00:00
Todd Fiala fbce07ced0 Added gdbremote protocol test for $p and returned data size.
Each register returned by $qRegisterInfo is tested that it's
$p register read returns a representation that is the correct byte size
as indicated by $qRegisterInfo.

Currently enabled for debugserver, disabled for llgs.

The llgs branch will use this to verify $p implementation.

llvm-svn: 209452
2014-05-22 17:18:18 +00:00
Todd Fiala 2b4307d037 Added tests for q{f,s}ThreadInfo for attached processes.
Added helper methods:
prep_debug_monitor_and_inferior(): properly handles
the two cases of running the stub against an inferior process
launched by the stub, and one attached to by the stub.  See
docs for function: simplifies test creation for tests that want
to test the same operations against a launched and attached inferior.

Added the q{f,s}ThreadInfo and $qC response comparison test (verifies
they both return the same thing) when the process is attached rather
than launched by the stub.

Modified the previous two tests added to make use of the new
prep_debug_monitor_and_inferior() facility.

llvm-svn: 209318
2014-05-21 20:12:01 +00:00
Todd Fiala 2954206e56 Added gdb-remote tests for q{f,s}ThreadInfo.
The First test verifies that qThreadInfo queries work for stub-launched processes.

The second test verifies that $qC after stub-launched inferior returns the same
thread as the qThreadInfo queries.

llvm-svn: 209314
2014-05-21 18:12:14 +00:00
Todd Fiala 4e53f9e1fe Change gdb remote test support multi-request format.
The multi request-response test infrastructure support was adding
the optional request suffix iteration index as decimal but it needed
to be hex per spec.  This change fixes that.

llvm-svn: 209234
2014-05-20 20:02:08 +00:00
Todd Fiala 62b2317fd8 Added gdb remote protocol tests across all qRegisterInfo responses.
Added support for gdb remote protocol capture/playback where there is a query/multiple-response
pattern.  The new playback entry supports:

- a general query command (key: next_query or query)
- an optional first-query command if that differs from the subsequent queries (key: first_query)
- an end regex for matching anything that would signify that the query/multi-response
  iteration has come to an end.  An assumption is that the end regex is not a content
  package we care about aside from ending the iteration. (key: end_regex)
- an optional 0-based index appended to the end of the query command 
  (key: append_iteration_suffix), default: False.
- a key used to collect responses from the query.  Any response from the gdb remote
  that doesn't match the end-of-iteration regex is captured in the playback context
  dictionary using the key specified.  That key will be an array, where each array
  entry is one of the responses from the query/multi-response iteration. (key: save_key).
- a runaway response value, defaulting to 10k, where if this many responses is captured,
  assume the ending condition regex is invalid, or the debug monitor is doing something
  goofy that is going to blow out memory or time. (key: runaway_response_count, default: 10000)

See the lldbgdbserverutils.MultiResponseGdbRemoteEntry class for details.

A MultiResponseGdbRemoteEntry is added by adding an element to the GdbRemoteTestSequence
(via GdbRemoteTestSequence.add_log_lines), using a dictionary, where the "type" key
is set to "multi_response", and the rest of the keys in the dictionary entry are
set to the keys documented for MultiResponseGdbRemoteEntry.

Added helper functions to add the required entry to grab all qRegisterInfo responses.
Added another helper to parse the qRegisterInfo response packets into an array of
dictionaries, where each key:value in the dictionary comes from the register info
response packet.

Added a test to verify that a generic register exists for the program counter,
frame pointer, stack pointer and cpu flags across all register info responses.

Added a test to verify that at least one register set exists across all register
info responses.

llvm-svn: 209170
2014-05-19 22:35:24 +00:00
Todd Fiala 76e1bf53b4 Revert r209142.
Need to spend a little more time with suppressing the debugserver 64-to-32 bit warnings.
Will re-submit after I get the warnings properly suppressed.

llvm-svn: 209151
2014-05-19 18:30:48 +00:00
Todd Fiala 06fcbd95e8 Added gdb remote test for one valid qRegisterInfo result.
Checks that at at least qRegisterInfo0 responds with a valid
register info reply packet.  The packet is parsed and validates
that all keys come from the documented set of valid keys.  It
then validates that a minimum set of expected keys
are present in the returned packet.

This test is set to pass on debugserver and fail on llgs TOT.

llvm-svn: 209109
2014-05-19 06:11:41 +00:00
Todd Fiala ff6131a958 Add support for gdb remote $X stop notification.
debugserver now returns $X09 as the immediate response to
a $k kill process request rather than $W09.

ProcessGDBRemote now properly handles X as indication of
a process exit state.

The @debugserver_test and @lldb_test for $k now properly expects
an X notification (signal-caused exit) after killing a just-attached
inferior that was still in the stopped state.

llvm-svn: 209108
2014-05-19 04:57:23 +00:00
Todd Fiala d18b767b04 Added gdbremote tests to verify kill and continue after attach.
llvm-svn: 208804
2014-05-14 19:34:06 +00:00
Todd Fiala 028a43f910 Fix up TestLldbGdbServer C++ test slug exe.
Missing header for Linux, replaces with iostreams.

llvm-svn: 208794
2014-05-14 17:12:02 +00:00
Todd Fiala f05ca45b1e Added debugserver/llgs test for command-line --attach {pid} variant.
Checks that the pid reported by $qProcessInfo matches the pid that was
launched as the attach test subject.

test exe now supports "sleep:{sleep_seconds}" command line argument.

llvm-svn: 208782
2014-05-14 14:51:27 +00:00
Jason Molenda b4892cd266 Add a new SBThread::SafeToCallFunctions API; this calls over to
the SystemRuntime to check if a thread will have any problems 
performing an inferior function call so the driver can skip
making that function call on that thread.  Often the function
call can be executed on another thread instead.
<rdar://problem/16777874> 

llvm-svn: 208732
2014-05-13 22:02:48 +00:00
Todd Fiala 9d03d8a65d Fix broken TestMultithreaded on Linux.
The clean line is failing under Ubuntu 12.04/gcc.  It cleans fine
without it on MacOSX.  It doesn't clean right on Linux but at least
now it doesn't fail the test.

llvm-svn: 208713
2014-05-13 17:20:17 +00:00
Todd Fiala 9f72b3a1ce Modify debugserver to follow gdb remote $qC protocol definition.
$qC from debugserver now returns the current thread's thread-id (and, like $?, will set a current thread if one is not already selected).  Previously it was returning the current process id.

lldb will now query $qProcessInfo to retrieve the process id.  The process id is now cached lazily and reset like other cached values.  Retrieval of the process id will fall back to the old $qC method for vendor==Apple and os==iOS if the qProcessInfo retrieval fails.

Added a gdb remote protocol-level test to verify that $qProcessInfo reports a valid process id after launching a process, while the process is in the initial stopped state.  Verifies the given process id is a currently valid process on host OSes for which we know how to check (MacOSX, Linux, {Free/Net}BSD).  Ignores the live process check for OSes where we don't know how to do this.  (I saw no portable way to do this in stock Python without pulling in other libs).

llvm-svn: 208241
2014-05-07 19:28:21 +00:00
Todd Fiala f9c3c9fe44 gdbremote testing: added regex support to match packets and propagate/test against previously stored matches.
Added a test validating that $qC after an inferior launch via $A
returns a thread id that an immediately followig $? reports for the
active thread. This is currently skipped on debugserver (the thread
ids don't match) and isn't yet implemented in TOT for llgs.

llvm-svn: 208061
2014-05-06 06:15:23 +00:00
Todd Fiala 6764c00687 Refactored gdb remote protocol testing sequence handling.
Pushed gdbremote protocol sequence expectations into a separate
class and defer matching of llgs/debugserver output to the
sequence entry.  Pre-step to adding regex matching and
grouped content collecting.

No longer require anything before the read/send packet
portion of slurped-up log lines used for setting up
gdb remote test sequences.  Several packet logging options
produce a wide range of content before the read/send packet.

Added helpers to TestLldbGdbServer to clean up test setup
and test expectations matching.

llvm-svn: 207998
2014-05-05 20:54:01 +00:00
Todd Fiala 41c60c818f Added gdb remote protocol tests for no output and inferior non-zero exit code.
Tests added for debugserver and lldb-gdbserver.  lldb-gdbserver marked as
XFAIL on top of tree.

Added build_gdbremote_A_packet test helper to construct a gdbremote A
launch packet from a list of args.

llvm-svn: 207568
2014-04-29 18:21:07 +00:00
Ed Maste 993fa0604d Fix interval recalculation in the event that usleep is interrupted
llvm-svn: 207566
2014-04-29 18:09:44 +00:00
Ed Maste 5c4661881b Add decorator for FreeBSD buildbot failure
llvm.org/pr19605

llvm-svn: 207557
2014-04-29 17:00:45 +00:00
Todd Fiala 56b25f74ce Added debugserver/llgs protocol test for output and clean exit.
Tests for $vCont;c program start, $O output and $W status code.
@llgs_test variant currently marked as expected fail.

llvm-svn: 207492
2014-04-29 05:01:01 +00:00
Todd Fiala 9164d9b304 Fixed up lldb-gdbserver to match slightly different debugserver listener host:port message.
Fixed up typo in lldb-gdbserver name missed when working on the OS X side earlier today for debugserver support.

llvm-svn: 207398
2014-04-28 06:04:46 +00:00
Todd Fiala a41d48cac8 Added two new test types: @debugserver_test and @llgs_test.
TestLldbGdbServer now supports both lldb-gdbserver (llgs) and
debugserver tests.  Similar to the dsym/dwarf tests, they allow
running the same underlying gdb remote protocol tests against
lldb-gdbserver and debugserver.  This will help make sure the
protocol-level tests for lldb-gdbserver faithfully represent
what debugserver does on OS X.

Switched back gdb remote protocol test logging to warning
and above (accidentally submitted it at debug level in a
recent commit).

llvm-svn: 207395
2014-04-28 04:49:40 +00:00
Todd Fiala 260323dba6 Added TestLldbGdbServer test for A start exe packet.
Fixed up bug in XFAIL tests where I appended an array when I intended to merge an array.

llvm-svn: 207285
2014-04-25 23:08:24 +00:00
Todd Fiala 98118c38a3 Prevent TestLldbGdbServer shutdown cleanup failures from failing the test.
Adds try/except blocks around clean-up code. Prevents a race between gdb
remote kill command reception by llgs (which leads llgs to shut down)
and the pexpect server kill (which can fail if the kill command handling
completes first). Warnings are emitted on the logger for any clean-up
code that fails.

llvm-svn: 207273
2014-04-25 21:09:28 +00:00