Commit Graph

8528 Commits

Author SHA1 Message Date
Deepak Panickal 0db9d32ff7 Fix the LLDB prompt for older Editline versions, specifically running on Ubuntu 12.04
llvm-svn: 201521
2014-02-17 17:42:25 +00:00
Deepak Panickal f275d09a34 Remove nativecodegen as it forces the native target libraries to be linked in regardless of whether the target was specified in LLVM_TARGETS_TO_BUILD
llvm-svn: 201519
2014-02-17 17:39:27 +00:00
Ed Maste ff8e5f2587 elf-core: Plug latent memory leak
ProcessElfCore::ParseThreadContextsFromNoteSegment was leaking
ThreadData for each ELF note found in core file.  We now allocate it
only once and use std::unique_ptr to ensure it is always being freed.

While at it make ParseFreeBSDThrMisc and ParseFreeBSDPrStatus take
ThreadData by reference, rather than pointer, since those arguments are
not optional.

Patch by Piotr Rak.

http://llvm-reviews.chandlerc.com/D2813

llvm-svn: 201473
2014-02-16 04:01:54 +00:00
Ed Maste 8b5e46a159 Simplify core file register context handling
This seems like a more straightforward approach for instantiating the
appropriate RegisterContext* class, made possible by Michael Sartain's
cleanup of the POSIX RegisterContext class hierarchy in r190647.

Better (user-facing) error handling is still needed.

llvm-svn: 201457
2014-02-15 02:31:22 +00:00
Enrico Granata 465f4bc287 <rdar://problem/16006373>
Revert the spirit of r199857 - a convincing case can be made that overriding a summary's format markers behind its back is not the right thing to do
This commit reverts the behavior of the code to the previous model, and changes the test case to validate the opposite of what it was validating before

llvm-svn: 201455
2014-02-15 01:24:44 +00:00
Jason Molenda 2a6c252df2 Add some additional logging to the Mac OS X SystemRuntime. Fix a bug where lldb could free an inferior's vm_page.
llvm-svn: 201447
2014-02-15 00:20:40 +00:00
Ed Maste 92b1f7e4f9 Allow FreeBSD/i386 core files to be loaded
llvm-svn: 201435
2014-02-14 21:57:27 +00:00
Ed Maste 8b4a283234 Correct offset calculation for FreeBSD i386 core NT_PRSTATUS
llvm-svn: 201434
2014-02-14 21:29:05 +00:00
Ed Maste 96d7f449b1 Adjust logging test case after r201372
The final "HandleCommand, command succeeded" for "log disable lldb"
doesn't make it to the log file before the command takes effect.

llvm-svn: 201422
2014-02-14 16:06:35 +00:00
Ed Maste 96430645eb Update decorators for tests that still fail with FreeBSD Watchpoint support
llvm.org/pr18832

Reported by John Wolfe

llvm-svn: 201418
2014-02-14 14:52:10 +00:00
Jason Molenda 026f389117 Fix minor build warning on Mac OS X x86_64.
llvm-svn: 201387
2014-02-14 05:16:17 +00:00
Jason Molenda a4bea72ee7 Add a new target setting, trap-handler-names, where a user can
specify a list of functions which should be treated as trap handlers.
This will be primarily useful to people working in non-user-level
process debugging - kernels and other standalone environments.
For most people, the trap handler functions provided by the Platform
plugin will be sufficient.

<rdar://problem/15835846>, <rdar://problem/15982682> 

llvm-svn: 201386
2014-02-14 05:06:49 +00:00
Greg Clayton e98008cc58 Fixed deadlocks that could occur when using python for breakpoints, operating system plugins, and other async python usage.
<rdar://problem/16054348>
<rdar://problem/16040833>

llvm-svn: 201372
2014-02-13 23:34:38 +00:00
Jason Molenda abba74b4ee Revert r201292 which relaxed the stack frame alignment requirements.
This was primarily working around problems where we weren't able
to identify trap handlers for different environments -- but instead,
I'm working to make it easier to specify those trap handler function
names.

llvm-svn: 201366
2014-02-13 23:29:36 +00:00
Jason Molenda 2094dbf4e7 Change the way the m_trap_handlers Platform base class ivar is initialized;
add a new pure virtual CalculateTrapHandlerSymbolNames() that Platform 
subclasses must implement which fills in the function name list with any
trap handlers that are expected on that platform.

llvm-svn: 201364
2014-02-13 23:11:45 +00:00
Todd Fiala 6bb55ba42b Re-enable TestAbbreviations.py on Linux after test fix.
See http://llvm.org/bugs/show_bug.cgi?id=18816.

llvm-svn: 201357
2014-02-13 19:21:13 +00:00
Greg Clayton 8b963bbd07 Fixed a test suite failure on Darwin due to logging issues.
llvm-svn: 201356
2014-02-13 18:30:23 +00:00
Ed Maste 800e12ac81 Avoid undesired variable shadowing
Michael Sartain refactored RegisterContextPOSIX_* in r192332, and I must
have missed the now-shadowed variable when I rebased the FreeBSD MIPS64
register context after that.

llvm-svn: 201334
2014-02-13 15:12:57 +00:00
Jason Molenda 6223db2778 The Platform base class now maintains a list of trap handlers
aka asynchronous signal handlers, which subclasses should fill
in as appropriate.  For most Unix user process environments,
the one entry in this list is _sigtramp.  For bare-board and
kernel environments, there will be different sets of trap 
handlers.

The unwinder needs to know when a frame is a trap handler 
because the rules it enforces for the frame "above" the
trap handler is different from most middle-of-the-stack frames.

<rdar://problem/15835846> 

llvm-svn: 201300
2014-02-13 07:11:08 +00:00
Jason Molenda 9098f1d3d9 Change the ABI CallFrameAddressIsValid methods for i386 and x86_64.
They were enforcing 16-byte alignment on stack frames for Darwin x86 programs.
But we've found that trap handlers typically don't have the stack pointer
aligned correctly when a trap happens and lldb wasn't backtracing all
the way through.  This method is only used as a safety guard to prevent
lldb's unwinder from using a bogus address as a stack frame - we'll still
enforce word-size alignment on stack frames so that should be fine.

Also rolled back akaylor's changes from August 2013 in r188952 which changed
the i386 ABI plugin to relax the CallFrameAddressIsValid offsets for non-Darwin
targets where only 4-byte alignment is enforced.  Now Darwin is the same as
those environments.

<rdar://problem/15982682> 

llvm-svn: 201292
2014-02-13 04:19:32 +00:00
Ed Maste 2a798d9c05 Remove decorator for fixed test
llvm.org/pr18805 fixed by r201270

llvm-svn: 201284
2014-02-13 01:10:20 +00:00
Greg Clayton c7d8885be4 Fixed the TestLogging test.
llvm-svn: 201273
2014-02-12 23:46:08 +00:00
Greg Clayton fdde7ccf37 Fixed the functionalities/abbreviation/TestAbbreviations.py test case.
llvm-svn: 201270
2014-02-12 23:40:31 +00:00
Greg Clayton 7a1bd0baa1 Add support for DW_OP_piece and DW_OP_bit_piece.
llvm-svn: 201268
2014-02-12 23:16:19 +00:00
Todd Fiala 027baff8a0 Change TestAbbreviations test to expected failure on Linux.
See http://llvm.org/bugs/show_bug.cgi?id=18816.
Likely the same issue as http://llvm.org/bugs/show_bug.cgi?id=18805.

llvm-svn: 201244
2014-02-12 17:50:26 +00:00
Todd Fiala 729c001ec3 Fix elf core file VMA-contiguous region collapsing.
Elf core files were collapsing core segments when the virtual memory
addresses were contiguous without checking if the core-file-backed
memory region was the same size as the segment's VMA region. Without
this extra check, any time regions were collapsed but the core-backed
region was smaller (and thus had a zero-filled hole at the end), the
collapse operation would break VMA to core file lookups for subsequent
collapsed regions.

This change fixes the following bug:
http://llvm.org/bugs/show_bug.cgi?id=18769

llvm-svn: 201214
2014-02-12 07:29:44 +00:00
Enrico Granata 67530b694c Avoid leaking namebuf in case of an early exit
llvm-svn: 201206
2014-02-12 03:37:33 +00:00
Filipe Cabecinhas 89372e99ba Fix cmake compilation on Mac OS X.
llvm-svn: 201200
2014-02-12 00:57:20 +00:00
Greg Clayton b6892508a6 When a multiline expression produces output, the multi-line help message is printed twice.
<rdar://problem/16031890> 

llvm-svn: 201171
2014-02-11 19:11:11 +00:00
Ed Maste 197305e916 Remove decorator for llvm.org/pr17233
This test was skipped as it used to segfault on FreeBSD.  It seems
the original issue has since been fixed, so have the test run again.

llvm-svn: 201169
2014-02-11 18:55:19 +00:00
Ed Maste acbfbbb20f Remove FreeBSD decorator for llvm.org/pr17499 (no longer fails)
llvm-svn: 201168
2014-02-11 18:36:26 +00:00
Ed Maste 65edfe3ed1 Remove decorators for llvm.org/pr17920 fixed by r200646
llvm-svn: 201167
2014-02-11 18:34:26 +00:00
Ed Maste 8744d38ee8 Update decorator for FreeBSD failure pr18066
The test expects the inferior to have exited, but it is still stopped.

llvm.org/pr18066

llvm-svn: 201166
2014-02-11 18:28:18 +00:00
Greg Clayton f075824998 Don’t leak memory when reading memory and we do an early return for error conditions.
llvm-svn: 201164
2014-02-11 17:49:50 +00:00
Ed Maste 3fb0a9cc6f Add decorator for llvm.org/pr18805 until root cause is identified
llvm-svn: 201153
2014-02-11 13:50:45 +00:00
Jason Molenda e54a0bfcd3 Change RNBRemote::HandlePacket_m() to store the packet on the heap
instead of on the stack.  Handles larger packet read requests better.

llvm-svn: 201118
2014-02-11 00:48:29 +00:00
Jason Molenda da276f9013 Adjust the calls to __introspection_dispatch_thread_get_item_info to
use a system-wide unique thread ID instead of a pthread_t to identify
the thread we want debug info for.  Also, free some more memory regions
that needed to be freed.

llvm-svn: 201117
2014-02-11 00:36:18 +00:00
Han Ming Ong a6cad47207 <rdar://problem/15996848>
Made sure we pass along the file action paths for stdin/stdout/stderr to the XPC service.
[Reviewed by Greg Clayton]

llvm-svn: 201103
2014-02-10 19:23:28 +00:00
Saleem Abdulrasool 78c135942d Host: unconstify editline paramters
Although the interface to el_push should be a constant parameter (as it is on
Darwin), certain Linux distributions currently ship a header which does not
provide proper const correctness.  This causes compilation failures on Linux.
Strip the constness on the parameter, which whilst incorrect, is mostly
harmless.  The parameter will not be changed by the interface and so it is
acceptable to do this.  When distributions have updated to a more correct
declaration, it would be nice to revert this change.

Addresses PR18784.

llvm-svn: 201092
2014-02-10 16:10:42 +00:00
Jean-Daniel Dupas 3c6774a172 hostname is guarantee to never be null in this branch.
llvm-svn: 201027
2014-02-08 20:29:40 +00:00
Jean-Daniel Dupas ef37711f85 Fix null dereference if address is NULL.
llvm-svn: 201026
2014-02-08 20:22:05 +00:00
Sylvestre Ledru bfc57f8370 Only set EL_PROMPT_ESC when existing - fix typo
llvm-svn: 201024
2014-02-08 13:26:24 +00:00
Sylvestre Ledru 54e7a77690 Only set EL_PROMPT_ESC when existing
llvm-svn: 201023
2014-02-08 13:25:47 +00:00
Sean Callanan c5c3a3c92c Added a test case for variables in registers, with
clang -O1.

<rdar://problem/15767528>

llvm-svn: 201005
2014-02-07 23:04:57 +00:00
Greg Clayton 751caf65c2 Modified ObjectFile::SetLoadAddress() to now be:
ObjectFile::SetLoadAddress (Target &target,
                            lldb::addr_t value,
                            bool value_is_offset);

Now "value" is a slide if "value_is_offset" is true, and "value" is an image base address otherwise. All previous usage of this API was using slides.

Updated the ObjectFileELF and ObjectFileMachO SetLoadAddress methods to do the right thing.

Also updated the ObjectFileMachO::SetLoadAddress() function to not load __LINKEDIT when it isn't needed and to only load sections that belong to the executable object file.

llvm-svn: 201003
2014-02-07 22:54:47 +00:00
Greg Clayton 9b5442aed9 Now that the command interpreter runs in a separate thread in Xcode, we need to lock the target API lock instead of trying to lock it.
What was happening was:
1 - Xcode ran and stopped and was doing work on thread 2
2 - Users would type something in Xcode console on thread 1
3 - thread 3 would be running command interpreter thread and try to execute command but get "failed to get API lock" error for any command that wanted the target API lock (like "expression")

<rdar://problem/15775016>

llvm-svn: 200997
2014-02-07 22:31:20 +00:00
Enrico Granata 41c440fbfe <rdar://problem/12857181>
When a user says

type formatter add ... unsigned int

he most probably means to deal with the "unsigned int" type. However, given how the LLDB command parser works, that command will try to add the formatter to the TWO types 'unsigned' AND 'int'

Since this is unlikely to be what the user wants, warn about it, and suggest they can use quotes to override the debugger's understanding

llvm-svn: 200996
2014-02-07 22:12:55 +00:00
Enrico Granata c1690d0c2b Add conditional breakpoints to our cheat sheet
llvm-svn: 200995
2014-02-07 21:30:02 +00:00
Sean Callanan 3d6ae767a0 When writing data back into a register, accept
values whose size differs from the register's
size.

llvm-svn: 200991
2014-02-07 20:42:44 +00:00
Greg Clayton 4c484ecb31 Fix a bug where we will crash if we have a class "B" that is contained inside a class "A" in the DWARF where "A" is a forward declaration.
<rdar://problem/14673945>
<rdar://problem/15682781>

llvm-svn: 200985
2014-02-07 19:21:56 +00:00
Enrico Granata 1d736c31d6 rdar://15648942
Provide a filter for libc++ std::atomic<T>
This just hides some implementation clutter and promotes the actual content to only child status

llvm-svn: 200984
2014-02-07 19:21:09 +00:00
Sean Callanan 7c435a5ede Lock the JIT before using it.
<rdar://problem/15958296>

llvm-svn: 200951
2014-02-06 22:25:20 +00:00
Sean Callanan d6be7085c2 Removed spurious lookup of the $__lldb_expr
selector when compiling an expression in an
Objective-C context.

<rdar://problem/15797390>

llvm-svn: 200950
2014-02-06 22:24:11 +00:00
Greg Clayton 7524e090e9 Implement ObjectFileMachO::SetLoadAddress().
llvm-svn: 200943
2014-02-06 20:10:16 +00:00
Steve Pucci 9e02dacddf Factor some methods that were in DynamicLoaderPOSIXDYLD.
Move some code that was in DynamicLoaderPOSIXDLYD into the
base class DynamicLoader.  In the case of UpdateLoadedSections(),
the test to see whether a file is loadable (its address is zero)
is not generally applicable so that test is changed to a more
universally applicable check for the SHF_ALLOC flag on the section.

Also make it explicit that the reading of the module_id in
DynamicLoaderPOSIXDYLD::GetThreadLocalData() is using a hardcoded
size (of module_id) of 4, which might not be appropriate on
big-endian 64-bit systems, leaving a FIXME comment in place.

llvm-svn: 200939
2014-02-06 19:02:19 +00:00
Greg Clayton 9c0b64c92d The "-n" and "-p" options to the lldb driver no longer worked after recent IOHandler changes, this is now fixed.
<rdar://problem/15962763>

llvm-svn: 200930
2014-02-06 18:22:44 +00:00
Greg Clayton 8ee673141b Don't print out "script" results twice.
We now properly detect when a result object has an immediate output stream and don't echo the results a second time.

<rdar://problem/15954906>

llvm-svn: 200882
2014-02-05 21:46:20 +00:00
Enrico Granata 9b55aa4e8f An example summary provider for PyObject and the LLDB wrapper PythonObject hierarchy - this would have probably helped track down those refcount bugs..
llvm-svn: 200879
2014-02-05 21:38:50 +00:00
Jim Ingham f0c63b97d6 Fix the --source-quietly option to the driver so that it actually works. Clean up the help
output a bit.

llvm-svn: 200878
2014-02-05 21:35:09 +00:00
Greg Clayton e4e462c42c Fixed output to display correctly for "command source" by fixing the correct flags being set.
Also emit the "Executing commands" message so it properly only comes out when desired and so it comes out in the right place.

<rdar://problem/15992208>

llvm-svn: 200875
2014-02-05 21:03:22 +00:00
Ed Maste f697a1ef94 Enable lldb-gdbserver for FreeBSD in the (g)make build
llvm-svn: 200871
2014-02-05 19:28:47 +00:00
Ed Maste fb29fa3e35 Enable lldb-gdbserver on Linux as well in the cmake build
llvm-svn: 200870
2014-02-05 19:03:18 +00:00
Ed Maste ba7cc706d9 Remove leftover debug printf
llvm-svn: 200866
2014-02-05 18:49:10 +00:00
Ed Maste 29e298a4ce Build lldb-gdbserver on FreeBSD
It passes basic sanity tests so we might as well enable it.

llvm-svn: 200865
2014-02-05 18:37:39 +00:00
Greg Clayton 340b0309b5 Fixed an issue where "command source" would not do the right thing:
- empty lines in init files would repeat previous command and cause errors to be displayed
- all options to control showing the command, its output, if it should stop on error or continue, weren't being obeyed.

llvm-svn: 200860
2014-02-05 17:57:57 +00:00
Greg Clayton 9b8aa38e45 Fixed indentation.
llvm-svn: 200859
2014-02-05 17:51:53 +00:00
Jason Molenda 2fd83355a8 Change the Mac OS X SystemRuntime plugin from using the placeholder
libldi library to collect extended backtrace information; switch
to the libBacktraceRecording library and its APIs.  Complete the
work of adding QueueItems to Queues and allow for the QueueItems
to be interrogated about their extended backtraces in turn.

There's still cleanup and documentation to do on this code but the
code is functional and I it's a good time to get the work-in-progress 
checked in.  
<rdar://problem/15314027> 

llvm-svn: 200822
2014-02-05 05:44:54 +00:00
Enrico Granata 95a9df2c82 <rdar://problem/15936507>
ScriptInterpreterPython caches the lldb.embedded_interpreter module, and since it caches it in a refcounting-safe PythonObject, the refcount will appropriately go down 1 every time a ScriptInterpreterPython is deallocated
However, we were only importing the module once - in InitializePrivate(). In a handful of interpreter creations, the refcount on the run_one_line function would end up at 0, causing LLDB to crash
This fixes it by also importing the module for every interpreter, which ensures correct refcounting

llvm-svn: 200816
2014-02-05 03:19:01 +00:00
Ed Maste 611d8c4361 Update URL for OS X buildbot
llvm-svn: 200799
2014-02-04 21:59:03 +00:00
Ed Maste 441a1beaba If setgid fails for any reason, exit lldb.
This is SVN r191618 by Sylvestre Ledru applied to the FreeBSD
ProcessMonitor.

llvm-svn: 200791
2014-02-04 19:37:15 +00:00
Greg Clayton 0f86e6e711 LLDB exits the command interpreter and thus LLDB when using a pty or file as the input handle and a blank line is entered (like when running under emacs). This is now fixed.
<rdar://problem/15976187>

llvm-svn: 200790
2014-02-04 19:25:11 +00:00
Ed Maste aacfe09867 Avoid accessing an element of an empty vector in a log message
llvm-svn: 200784
2014-02-04 18:51:11 +00:00
Jim Ingham 1c6da87bc9 If we fail to attach, return an error rather than returning the success or failure
of sending the error packet.

llvm-svn: 200732
2014-02-04 01:28:36 +00:00
Jean-Daniel Dupas 36b5eea258 Fix UnwindAssembly memory leak by defining and using a shared UnwindAssemblySP type.
llvm-svn: 200725
2014-02-03 23:49:47 +00:00
Enrico Granata d8e4584cbd <rdar://problem/15154623>
Move a couple formatters from category AppKit to CoreFoundation

llvm-svn: 200713
2014-02-03 19:46:31 +00:00
Ed Maste cc8068f2ac Remove failure decorators for FreeBSD bug
The issue described in llvm.org/pr18065 is actually due to FreeBSD bug
theads/186309 [1], which is now fixed in FreeBSD SVN r261354 [2] and will
be merged to release branches shortly.

Diagnosed and fixed by John Wolfe.

[1] http://www.freebsd.org/cgi/query-pr.cgi?pr=186309
[2] http://svnweb.freebsd.org/base?view=revision&revision=261354

llvm-svn: 200648
2014-02-02 19:29:50 +00:00
Ed Maste 10c82017b6 Update header comment to match filename
llvm-svn: 200647
2014-02-02 19:25:11 +00:00
Ed Maste dbd5950b63 Use libc++ on FreeBSD as on Darwin
This could use some refinement still, but the previous behaviour of adding
-stdlib=libstc++ on FreeBSD w/ Clang is the least likely case to work.

llvm.org/pr17910

llvm-svn: 200646
2014-02-02 19:24:15 +00:00
Jean-Daniel Dupas 59999a32b3 Remove commented includes
llvm-svn: 200637
2014-02-02 14:06:07 +00:00
Todd Fiala 31cb474e2d Fix for failure to unwind Linux stack frames with call in final position.
Fixes http://llvm.org/bugs/show_bug.cgi?id=18656.

Note this exposes a failure on Linux of
TestInferiorAssert.test_inferior_asserting_disassemble, similar to how
it fails on FreeBSD. I'll file a bug for this next. We're now getting
another frame beyond where we used to prior to this fix, so the fix is
exposing failures in previosly not-reachable frames.

Much thanks to Jason Molenda, who had much to do with helping figure
out where unwinding was breaking.

llvm-svn: 200600
2014-02-01 00:48:34 +00:00
Deepak Panickal 914b8d989b Fixing the Windows build for the changes brought in from the iohandler merge.
llvm-svn: 200565
2014-01-31 18:48:46 +00:00
Ed Maste 829839259a Add libs needed by iohandler merge to Makefile for FreeBSD
Copied from the Linux case added in r200263.  Discovered by the FreeBSD
buildbot - I tested the branch with cmake.

llvm-svn: 200548
2014-01-31 14:30:11 +00:00
Jim Ingham 4046a30c73 Check curr_thread is not empty before accessing it.
<rdar://problem/15953271>

llvm-svn: 200504
2014-01-31 01:01:23 +00:00
Greg Clayton 10c0ef7b8a Pressing ^D in a non-empty input terminates LLDB. This was due to the fact that we stack more than one editline instance on top of each other and we still expect CTRL+D to exit the editline instance, but it should only do so when the line is empty. Otherwise it should (and does) delete the character at the cursor.
<rdar://problem/15944703>

llvm-svn: 200489
2014-01-30 20:59:18 +00:00
Todd Fiala 3452df6723 Fixed b18655: cleaned up script interpreter file reference handling.
This change addresses shutdown crashes in the python lldb module when
the script interpreter was hanging on to saved file references after
leaving a session.  It also gets rid of extra references to the
stdin/stdout/stderr python file objects that are created when entering
the session.

This change also moves the bundled pyexpect 2.4 library to the front
of the python library path so that a python distribution default
pyexpect (2.3 in Ubuntu 12.04) is not picked up first.

llvm-svn: 200486
2014-01-30 20:19:22 +00:00
Greg Clayton 590426029b Missing files for previous checkin that fixed: "script help (lldb.SBThread)" output stops after 2048 bytes are printed.
<rdar://problem/15942977>

llvm-svn: 200478
2014-01-30 18:52:57 +00:00
Greg Clayton 31480e64ee "script help (lldb.SBThread)" output stops before all output is displayed. Fixed now.
<rdar://problem/15942977>

llvm-svn: 200476
2014-01-30 18:17:31 +00:00
Enrico Granata 1ba7305974 <rdar://problem/15936507>
PyTuple_SetItem steals a reference to the item it inserts in the tuple
This, plus the Py_XDECREF of the tuple a few lines below, causes our session dictionary to go away after the first time a SWIG layer function is called - with disastrous effects for the first subsequent attempt to use any functionality in ScriptInterpreterPython
This fixes it

llvm-svn: 200429
2014-01-29 23:18:58 +00:00
Greg Clayton 99dcbe1e50 Don't crash when trying to auto complete 'breakpoint set -n "_'
<rdar://problem/15921898>

llvm-svn: 200402
2014-01-29 18:25:07 +00:00
Greg Clayton 5fdb09bb76 Show help dialog the first time the "gui" is run to help users find their way.
llvm-svn: 200326
2014-01-28 18:41:35 +00:00
Greg Clayton c809cbcf4d Fixed a crasher when handling process events that is due to a translation from the public API to the private API.
llvm-svn: 200267
2014-01-28 00:36:31 +00:00
Todd Fiala b8b49ec92b Modified GDBProcessCommunicationServer to launch via the platform.
GDBProcessCommunicationServer now optionally takes a PlatformSP that
defaults to the default platform for the host.
GDBProcessCommunicationServer::LaunchProcess () now uses the platform
to launch the process.

lldb-gdbserver now takes an optional --platform={platform_plugin_name}
or -p {platform_plugin_name} command line option. If no platform is
specified, the default platform for the host is used; otherwise, if
the platform_plugin_name matches a registered platform plugin or
matches the default platform's name (which is not necessarily
registered by name in the case of 'host'), that platform is used. If
the platform name cannot be resolved, lldb-gdbserver exits after
printing all the available platform plugin names and the default
platform plugin name.

llvm-svn: 200266
2014-01-28 00:34:23 +00:00
Greg Clayton 44d937820b Merging the iohandler branch back into main.
The many many benefits include:
1 - Input/Output/Error streams are now handled as real streams not a push style input
2 - auto completion in python embedded interpreter
3 - multi-line input for "script" and "expression" commands now allow you to edit previous/next lines using up and down arrow keys and this makes multi-line input actually a viable thing to use
4 - it is now possible to use curses to drive LLDB (please try the "gui" command)

We will need to deal with and fix any buildbot failures and tests and arise now that input/output and error are correctly hooked up in all cases.

llvm-svn: 200263
2014-01-27 23:43:24 +00:00
Jason Molenda 89c37499dd Change DecodeProcessInfoResponse to set the ProcessInfo's architecture
if the remote stub provided enough information to identify it in the
qProcessInfo packet response.  (e.g. for an Apple device where we know 
it is Mach-O, the cpu type & cpu sub type).
<rdar://problem/15847901> 

llvm-svn: 200253
2014-01-27 22:23:20 +00:00
Enrico Granata 5000ee16f6 <rdar://problem/15776874>
ValueObjectPrinter could enter an infinite loop while trying to display an aptly formed ValueObject: a reference, with a child of some pointer type, such that the pointees chain ended up pointing back to some part of itself - a pointer to itself being the simplest such case

Fixed here by only setting a pointer depth when needed, and ensuring that we won't overflow and wrap the pointer depth when it's zero.

llvm-svn: 200247
2014-01-27 21:31:26 +00:00
Todd Fiala 9f37737311 convert gdb-remote 'A' launch to use LaunchProcess ()
This change modifies the 'A' command handler's launch code to launch
with LaunchProcess (). The net effect is that the default process
monitoring that LaunchProcess () adds will kick in, allowing the
GDBRemoteCommunicationServer to be able to reap processes started with
this facility correctly. Later, in the case of lldb-gdbserver, we'll
also have the proper process monitoring going on to really debug the
inferior process.

llvm-svn: 200246
2014-01-27 20:44:50 +00:00
Todd Fiala 1b0539c7f6 Fix group stop signal handling issue on Linux.
This patch addresses a bug where in a multi-threaded program a new
signal from the inferior may be received before all group-stop
messages from an earlier signal have been handled.

Patch by Andrew MacPherson

llvm-svn: 200226
2014-01-27 17:03:57 +00:00
Ed Maste 1e8f163709 Remove FIXME comments about tids on FreeBSD that no longer apply
Spotted by John Wolfe.

llvm-svn: 200092
2014-01-25 18:45:40 +00:00
Alp Toker 6a6ff05b57 Track clang changes from r200082
llvm-svn: 200085
2014-01-25 16:57:13 +00:00
Steve Pucci 5ae54ae6cd Support for debugging against a remote stock gdbserver.
There are a couple of pieces:
 * some lazy-evaluation members that store info listed in a qSupported response
 * new method SendPacketsAndConcatenateResponses which is used for
   fetching fixed-size objects from the remote gdbserver by using multiple
   packets if necessary (first use will be to fetch shared-library XML files).

llvm-svn: 200072
2014-01-25 05:46:51 +00:00
Jason Molenda bbef401896 Change DataExtractor's ReadInt* and ReadSwapInt* routines, as well as
GetU32 and GetU64, to use memcpy to copy bytes into a local buffer instead
of having a (uint64_t *) etc local variable, pointing to the address, and
dereferencing it.  If compiled on a CPU where data alignment is required 
(e.g. the LDM instruction on armv7) and we try to GetU64 out of a mmap'ed 
DWARF file, that 8 byte quantity may not be world aligned and the program
can get an unaligned memory access fault.

<rdar://problem/15849231> 

llvm-svn: 200069
2014-01-25 05:12:35 +00:00
Jason Molenda 4411528461 Note that qHostInfo prints the cputype and cpusubtype in base10;
qProcessInfo prints the cputype and cpusubtype in base16.

llvm-svn: 200068
2014-01-25 04:44:34 +00:00
Jason Molenda 6e20554ea8 Initialize the named_pipe_path in GDBRemoteCommunication::StartDebugserverProcess
right after the space for it is allocated on the stack, instead of trying
to initialize it in all the different places in this method.  It's too easy
for another uninitialized code path to sneak in as it is written right now.

llvm-svn: 200066
2014-01-25 03:57:13 +00:00
Todd Fiala 8ce3dee45f Fix crash on Linux if sem_wait() is interrupted.
Patch by Andrew MacPherson.

llvm-svn: 200049
2014-01-24 22:59:22 +00:00
Jason Molenda ffa674e6d7 Terminate an unused char* buffer correctly so we don't try to open
it later in GDBRemoteCommunication::StartDebugserverProcess and report
an error.
<rdar://problem/15820813> 

llvm-svn: 200047
2014-01-24 22:49:32 +00:00
Todd Fiala 3e92a2b013 Added reaper for commandline-launched processes.
GDBRemoteCommunicationServer::LaunchProcess () now uses the built-up
ProcessLaunchArgs rather than clearing and setting items from the
function arguments. I added setters for the arguments and launch
flags, which lldb-gdbserver uses for its specification of the
commandline-specified startup app (if one is specified).

LaunchProcess () also adds a new reaper monitor that it applies to
the launched process if no process monitor has already been applied.

This addresses an issue where the 'k' command would generate (possibly
false) warnings about not being able to positively state whether a
killed process actually terminated. GDBRemoteCommunicationServer now
definitely knows the disposition of its children.

llvm-svn: 199959
2014-01-24 00:52:53 +00:00
Greg Clayton 1e3be5ba2c Don't copy entire value into m_data unless we need to. If we did this and the entire variable failed to be read, we wouldn't be able to display any actual values that were in good memory. This will also make things more efficient by not have every struct/union/class/array copy its entire value into a ValueObject.m_data even though no one was using it.
llvm-svn: 199953
2014-01-23 22:55:05 +00:00
Greg Clayton bc8911807c Fixed a test suite exception that was cause by bad python (sys.unlink instead of os.unlink).
llvm-svn: 199952
2014-01-23 22:53:05 +00:00
Greg Clayton 146b7b1230 Updated to latest and greatest demangler sources.
<rdar://problem/15736085>

llvm-svn: 199946
2014-01-23 22:12:54 +00:00
Todd Fiala 403edc5c57 Move process launching into GDBRemoteCommunicationServer.
lldb-gdbserver was launching the commandline-specified launch process
directly, without GDBRemoteCommunicationServer knowing anything about
it.  As GDBRemoteCommunicationServer is the piece that manages and
knows about processes that the gdb remote protocol discusses with
the client end, it is important that it know about launched processes.

This change also implements the k gdb remote protocol message, having it
kill all known spawned processes when it is received.

(Note: in lldb-gdbserver, the spawned processes are not properly
monitored yet. The response to the k packet will complain that
spawned processes do not really appear to be getting killed even if
they are. This will get addressed soon.)

llvm-svn: 199945
2014-01-23 22:05:44 +00:00
Jim Ingham a786e53903 Don't need to figure out the frame's module if we don't have any libraries
in the step-avoid-libraries list.

llvm-svn: 199944
2014-01-23 21:57:53 +00:00
Jim Ingham 4da6206d75 Add a "step-avoid-libraries" setting to complement the "step-avoid-regexp" setting.
llvm-svn: 199943
2014-01-23 21:52:47 +00:00
Greg Clayton 1f4db7da8f Added the ability to get the type that a typedef points to via:
SBType SBType::GetTypedefedType();

Also added the ability to get a type by type ID from a SBModule:

SBType SBModule::GetTypeByID (lldb::user_id_t uid);

llvm-svn: 199939
2014-01-23 21:38:34 +00:00
Greg Clayton 09effdacda Added a new lldb command that can parse all struct and class types for one or more shared libraries.
llvm-svn: 199937
2014-01-23 21:26:30 +00:00
Todd Fiala 571768caa6 Candidate fix for bug 18592.
This reverts Host.cpp LaunchProcess spawn behavior on FreeBSD to be
like Linux (and unlike OS X) with regards to how default signal
handlers and setup on the spawned process. FreeBSD does not reset
default signal handlers on the spawned process after this change.

llvm-svn: 199908
2014-01-23 17:07:54 +00:00
Enrico Granata 90890bba04 If a user specifies a format option to frame variable or expression, that format should prevail over whatever format(s) a summary specifies
(see test case for an example)

llvm-svn: 199857
2014-01-23 01:21:18 +00:00
Todd Fiala 76747120ca Unify OS X/POSIX/Linux Host spawn support.
This fixes a bug under Linux where spawning a process via
Host::LaunchProcess was disabling all blockable signals on the
launched process.  This caused strange behavior when attempting
to kill the lldb-gdbserver process, as the child generally would
not die unless killed with a non-blockable signal (e.g. 'kill -9').

This change moves several functions out of macosx/Host.mm into
common/Host.cpp.  In addition, two functions that needed to work
across common/Host.cpp and macosx/Host.mm were moved into the Host.h
header file.

llvm-svn: 199856
2014-01-23 00:52:28 +00:00
Greg Clayton a86dc43371 Add support for Haswell on x86_64.
<rdar://problem/15312873>

llvm-svn: 199854
2014-01-22 23:42:03 +00:00
Todd Fiala 4bd862206a Add --lldb-command command-line option to lldb-gdbserver
lldb-gdbserver now takes zero or more --lldb-command {command} options
that get executed by the command interpreter prior to starting up
a child debuggee process.  The short form is -c {command}.  This is
similar to how lldb-platform works.

This command can be used to enable logging in more than just the
gdb-remote log channel.  Here is an example startup sequence that allows
logging of lldb host and process log categories to one file and
gdb-remote packets to another file:

lldb-gdbserver -c 'log enable -f lgs.log lldb process host' \
  -c 'log enable -f lgs_packets.log gdb-remote packets' \
  localhost:5432 ./some_exe

llvm-svn: 199761
2014-01-21 18:46:22 +00:00
Sean Callanan 4f2c198617 Better logging for the IRExecutionUnit so that
we can see exactly what data was put where.

llvm-svn: 199701
2014-01-21 00:54:48 +00:00
Alp Toker f747ff1f54 Build fix following clang r199686
llvm-svn: 199689
2014-01-20 21:14:57 +00:00
Ed Maste e108405aaf Relax alias test for failing command
The alias test "exprf x 1234" expands to "expr -f x 1234" and is
expected to fail: it ends up trying to evaluate the invalid expression

    void
    $__lldb_expr(void *$__lldb_arg)
    {
        -f x 1234;
    }

On FreeBSD LLDB ends up finding a static function f() in a math library,
and thus the error produced does not include "use of undeclared
identifier 'f'".

We will report failure to parse the expression in any case, so require
only that error message.

llvm-svn: 199623
2014-01-20 03:45:47 +00:00
Ed Maste c5efc526c8 Remove decorators for now-fixed pr18191
llvm-svn: 199557
2014-01-18 17:03:41 +00:00
Ed Maste f170add239 Add decorator for failing FreeBSD test
llvm-svn: 199551
2014-01-18 16:23:30 +00:00
Ed Maste c787822545 Add decorator for FreeBSD test failure pr18522
llvm-svn: 199550
2014-01-18 14:29:57 +00:00
Ed Maste e8b2ef56e1 Handle LLDB_LIB_DIR on FreeBSD as on Linux
Diagnosed and tested by Mike Ma.
http://llvm.org/pr18191

llvm-svn: 199549
2014-01-18 14:22:28 +00:00
Todd Fiala 5000e28a5e Make lldb build with Makefiles on OS X.
This change does the following:

* Adds Makefile build scripts to debug server.

* Fixes a few small mistakes in the other makefiles.

* Modifies generate-vers.pl slightly to also work for debugserver.

* Changes the OS X, non-framework python search path from libdir to
  libdir/python2.X/site-packages where it is installed by the build
  system (also where it is installed on other operating systems).

Patch by Keno Fischer.

llvm-svn: 199543
2014-01-18 08:05:32 +00:00
Todd Fiala 5b9e5b5961 Fixed a piece of documentation on a setter from last check-in.
llvm-svn: 199540
2014-01-18 03:08:37 +00:00
Todd Fiala a9ddb0e14f Added distribution info to ArchSpec and qHostInfo message.
ArchSpec now contains an optional distribution_id, with getters and
setters. Host::GetArchitecture () sets it on non-Apple platforms using
Host::GetDistributionId (). The distribution_id is ignored during
ArchSpec comparisons.

The gdb remote qHostInfo message transmits it, if set, via the
distribution_id={id-value} key/value pair. Updated gdb remote docs to
reflect this change.

As before, GetDistributionId () returns nothing on non-Linux platforms
at this time. On Linux, it is returned only if the lsb_platform
command is installed (in /bin or /usr/bin), and only if the
distributor id key is returned by 'lsb_platform -i'. This id is
lowercased, and whitespace is replaced with underscores.

llvm-svn: 199539
2014-01-18 03:02:39 +00:00
Sean Callanan 6826d22784 Made sure that ValueObjectVariable actually
updates itself before it tries to set its own
data.  Otherwise it has no idea where to put the
data value.

<rdar://problem/15846476>

llvm-svn: 199533
2014-01-18 01:13:50 +00:00
Todd Fiala e28f1d7f07 Undo change to triple behavior from r199510.
The Linux distribution will be added to the ArchSpec class in an
upcoming change. This change only undoes the change to the triple. The
distribution retrieval logic and enabling of lldb-gdbserver for linux
x86_64 builds is still in place.

llvm-svn: 199520
2014-01-17 22:21:22 +00:00
Jason Molenda be1261a1ab Add -stdlib=c++ to the LDFLAGS when configuring llvm. The lldb
xcode project file sets the MACOSX_DEPLOYMENT_TARGET to 10.7.
llvm/configure (as of r199313) tries to compile a .cpp file which
includes <atomic> with -std=c++0x.  If the deployment target is set
to earlier than 10.9 and no C++ library is specified, clang will
error out at this point.

Fixes xcode building of lldb on Mac OS X.  If this change causes
problems for any of the other build workflows, please let me know
and I'll fix it.

llvm-svn: 199511
2014-01-17 20:59:32 +00:00
Todd Fiala f3d61de532 Enable Linux distribution in vendor portion of host triple.
This change does the following:

* enables building lldb-gdbserver on linux_x86-64 platforms.

  Note - it builds but it has several run-time issues where many gdb
  remote protocol features are not properly implemented yet. I'm
  working on these one at a time.

* lldb-gdbserver: does not enable the eLaunchFlagDebug launch flag on
  Linux. Currently the POSIX launch routine will assert if that flag
  is passed in, presumably because that launch mode is not yet
  available.  This prevents lldb-gdbserver from asserting the moment
  it launches the debuggee process.

* Adds ConstString& Host::GetDistributionId ()

  This method is defined to return an empty result on all platforms
  except for Linux.  On Linux, it makes one attempt to execute
  'lsb_release -i' (both /usr/bin/lsb_release, where it appears
  on ubuntu, and /bin/lsb_release, where it appears on fedora
  if the redhat-lsb package is installed).  If lsb_release is not
  found in either of those locations, or if 'lsb_release -i' does
  not return the first line starting with "Distributor ID:\t",
  then the distribution id is empty.  The method will lower-case
  the id and replace whitespace with underscores.

* Modify Host::GetArchitecture () so that linux replaces an unknown
  vendor portion with the results of GetDistributionId () if that
  is non-empty.  This shows up now in qHostInfo remote packet
  responses and on the lldb host side.  Tested with ubuntu and
  fedora (the latter both with the default of not having lsb_release
  installed, and with having lsb_release installed via the redhat-lsb
  package).

  Examples of triples on Linux after this change:

    # x86_64 Unbuntu 12.04 LTS:
    x86_64-ubuntu-linux-gnu

    # x86_64 Fedora 20 Desktop with redhat-lsb package installed
    x86_64-fedora-linux-gnu

    # x86_64 Fedora 20 Desktop without redhat-lsb-core installed
    # (i.e. no /bin/lsb_release available)
    # same as before the change
    x86_64--linux-gnu

  Note I intend to have Android respond with:

    {arch}-android-linux

  when I get to implementing Android lldb-gdbserver support.

llvm-svn: 199510
2014-01-17 20:18:59 +00:00
Jim Ingham 6f78f3869d The default timeout for EvaluateExpressionOptions is not 0, so if no timeout is provided, we have to set the option timeout to 0 by hand.
<rdar://problem/15846781>

llvm-svn: 199509
2014-01-17 20:09:23 +00:00
Steve Pucci 7489cc98f7 Fix gcc warnings about casting away constness
llvm-svn: 199506
2014-01-17 18:29:08 +00:00
Steve Pucci aa71cd8d26 Avoid the gcc warning -Wno-non-template-friend
To avoid this warning, friend declarations inside template classes
must be declared as templates:
http://stackoverflow.com/questions/4039817/friend-declaration-declares-a-non-template-function

llvm-svn: 199505
2014-01-17 18:25:25 +00:00
Steve Pucci fc99572540 Rename Platform::GetFile (3-arg version) to GetFileWithUUID
This rename was suggested by gclayton as a way to silence gcc
warnings; the warning is emitted when there is an overloaded function
in a base class (Platform) for which a derived class redefines one of
the overloads but not the other (because doing so hides the other
overload from users of the derived class).  By giving the two methods
different names, the situation is avoided.

llvm-svn: 199504
2014-01-17 18:18:31 +00:00
Ed Maste 21afbe034e Correct logic checking for the first stop ID
llvm-svn: 199503
2014-01-17 17:31:06 +00:00
Ed Maste cbcf8ac51a Undo r199448, already implemented in r199426
llvm-svn: 199449
2014-01-17 00:53:01 +00:00
Ed Maste 1318b854a4 Link thread-specific breakpoint test against libpthread
llvm-svn: 199448
2014-01-17 00:48:11 +00:00
Steve Pucci 5ec012d4de Test new committer permission with one-line trailing whitespace removal.
llvm-svn: 199432
2014-01-16 22:18:14 +00:00
Todd Fiala a475693947 Fix bug in Linux remote dynamic loader setup and fix test.
Part 1 changes PlatformLinux::CreateInstance to always create with
is_host=false; that method is only used as the plug-in creator method
associated with the remote-linux platform plugin, and should therefore
always be remote.

Part 1 patch by Steve Pucci.

Part 2: fix a test break on linux.

In test/functionalities/thread/thread_specific_break, when using gcc,
either C99 mode would need to be enabled, or the code would need to
change.  I changed a couple loop variable definitions to conform
to pre-C99 to simplify testing the fix.  The second issue was
the necessity to include -lpthread as a linker option in the Makefile.

Any issues with that part are due to me (Todd Fiala).

llvm-svn: 199426
2014-01-16 21:22:11 +00:00
Sean Callanan 79fde96b6a Fixed some API drift by making "used" attributes
in a better way.

llvm-svn: 199408
2014-01-16 18:47:07 +00:00
Greg Clayton baf2c2211d If a library has no N_FUN symbols we don't succeed in finding resolver symbols, now we do.
<rdar://problem/15831334>

llvm-svn: 199345
2014-01-16 01:48:44 +00:00
Greg Clayton d81088c540 Make sure we correctly merge all N_FUN symbols with non-stab entries even if there are multiple symbols with the same name.
<rdar://problem/15831292>

llvm-svn: 199344
2014-01-16 01:38:29 +00:00
Jim Ingham 39fdae7f6a Fix a bug where if we stop but nobody says there was a reason for the stop, we would return
control to the user anyway.  This was put in to handle monitors that would say there was no
stop reason when you first attached to them.  But it broke the case where you hit a thread specific
breakpoint on many threads, but NOT the one specified in the breakpoint.  I work around this
by only doing the junky override when the StopID is 0 - i.e. on first attach.

This commit also adds a test for thread specific breakpoints.

llvm-svn: 199290
2014-01-15 03:32:42 +00:00
Jim Ingham a8b99ca4bb Add a little more logging to the StopInfoBreakpoint::PerformAction.
llvm-svn: 199289
2014-01-15 03:30:04 +00:00
Jim Ingham 4746a90d66 Change the name of the test class for this test (was copy/paste value...)
llvm-svn: 199251
2014-01-14 19:48:23 +00:00
Jim Ingham 0f7e294d65 Remove a compilation warning in the test case main.c file.
llvm-svn: 199243
2014-01-14 18:46:15 +00:00
Jason Molenda 303eb178a9 Fix typeo on memory read command example.
llvm-svn: 199228
2014-01-14 17:41:13 +00:00