This change brings in lldb-gdbserver (llgs) specifically for Linux x86_64.
(More architectures coming soon).
Not every debugserver option is covered yet. Currently
the lldb-gdbserver command line can start unattached,
start attached to a pid (process-name attach not supported yet),
or accept lldb attaching and launching a process or connecting
by process id.
The history of this large change can be found here:
https://github.com/tfiala/lldb/tree/dev-tfiala-native-protocol-linux-x86_64
Until mid/late April, I was not sharing the work and continued
to rebase it off of head (developed via id tfiala@google.com). I switched over to
user todd.fiala@gmail.com in the middle, and once I went to github, I did
merges rather than rebasing so I could share with others.
llvm-svn: 212069
Also added tests for presence of vCont;c, vCont;C, vCont;s, vCont;S as
returned by vCont? query.
Broke out single step functionality from TestLldbGdbServer into base class.
Used by new TestGdbRemoteSingleStep (using $s) and TestGdbRemote_vCont.
Also part of llgs wrap-up, see:
https://github.com/tfiala/lldb/issues/12
llvm-svn: 211965
Removed the distribution EXEs from FreeBSD and Ubuntu.
Added a hello-world .cpp file, and compiled it for
several platform/compiler variants:
Ubuntu 14.04 x86_64, clang 3.5 (the ubuntu1 3.5 pre variant)
Ubuntu 14.04 x86_64, gcc 4.8.2
FreeBSD 10.0 x86_64, clang 3.3
FreeBSD 10.0 x86_64, gcc 4.7.3
NetBSD 6.1 x86_64, gcc 4.5.3
I also added the NetBSD expected architecture and triple.
Note I have NetBSD not appending the version info to the
OS name, in contrast to FreeBSD.
llvm-svn: 211954
Previously ObjectFileELF was simplifying and assuming the object file it was
looking at was the same as the host architecture/triple. This would break
attempts to run, say, lldb on MacOSX against lldb-gdbserver on Linux since
the MacOSX lldb would say that the linux elf file was really an Apple MacOSX
architecture. Chaos would ensue.
This change allows the elf file to parse ELF notes for Linux, FreeBSD and
NetBSD, and determine the OS appropriately from them. It also initializes
the OS type from the ELF header OSABI if it is set (which it is for FreeBSD
but not for Linux).
Added a test with freebsd and linux images that verify that
'(lldb) image list -t -A' prints out the expected architecture for each.
llvm-svn: 211907
I missed adding a few new files to the change list.
The build is broken from r211526 without this fix.
(And Ed Maste caught it before I did, so this is
the remainder - the test methods).
llvm-svn: 211535
Tests for both thread suffix and no thread suffix execution.
Moved some bit-flipping helper methods from TestLldbGdbServer
into the base GdbRemoteTestCaseBase class.
llvm-svn: 211381
Fixes two causes for https://github.com/tfiala/lldb/issues/7.
1. Ensures the inferior program has started executing, by printing
a message on output first thing (per the "message:" command line arg)
and waiting for that text to arrive before doing any checks related
to auxv support.
2. Fixes up auxv-related regex patterns to be compiled with the Python
re.MULTILINE and re.DOTALL options. The multiline is needed because
the binary data can include what look like newlines when interpreted
as text, and the DOTALL is needed to have the (.*) content portion match
newlines.
Added interrupt packet helper methods to add interrupt test sequence
packets and parse the results from them.
llvm-svn: 211283
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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