Commit Graph

5578 Commits

Author SHA1 Message Date
Enrico Granata 8a2a0dfba5 Restore the ability of SBFrame::FindValue() to look for file global variables
This should clean up the new test failures caused by r201614

llvm-svn: 201710
2014-02-19 19:35:13 +00:00
Ed Maste a4be2c5dcd FreeBSD hardware watchpoint implementation
Implement x86_64 debug register read/write in support of hardware
watchpoints. Hoist LinuxThread::TraceNotify code back into
POSIXThread::TraceNotify()

Patch by John Wolfe.

We still need to rework this later to avoid the #ifdef FreeBSD.

llvm-reviews.chandlerc.com/D2572
llvm.org/pr16706

llvm-svn: 201706
2014-02-19 18:34:06 +00:00
Ed Maste 954e4b9259 Track Clang virtualFileSystem change (r201618)
Clang now requires calling CompilerInstance::createVirtualFileSystem
before CompilerInstance::createFileManager.

llvm-svn: 201671
2014-02-19 13:00:08 +00:00
Deepak Panickal 6d3df420d2 Initial patch for supporting Hexagon DSP
llvm-svn: 201665
2014-02-19 11:16:46 +00:00
Jason Molenda 9c37cbdb86 Re-apply r201292. We're not going to enforce proper stack frame alignment on i386/x86_64
because there are too many trap handlers that will have an improperly aligned caller sp 
and this will cause the unwinder to stop too early.  

llvm-svn: 201637
2014-02-19 03:42:19 +00:00
Enrico Granata bdab3dee8f <rdar://problem/15906684>
The way in which we were determining whether a python module had already been imported in the current session stopped working due to the IOHandler changes
As a result, importing in a new debug session a module which had been imported in a previous session did not work
This commit restores that functionality by checking for the module's presence in the session dictionary (which should be more correct anyway)

llvm-svn: 201623
2014-02-19 01:45:22 +00:00
Enrico Granata 08a04327a9 <rdar://problem/15960553>
Fix a bug where calling SBFrame::FindValue() would cause a copy of all variables in the block to be inserted in the frame's variable list, regardless of whether those same variables were there or not - which means one could end up with a frame with lots of duplicate copies of the same variables

llvm-svn: 201614
2014-02-18 23:48:11 +00:00
Jason Molenda 7b535d5453 Also recognize interrupt as a possible trap handler name.
llvm-svn: 201611
2014-02-18 22:48:27 +00:00
Jason Molenda 33489c1678 Add two additional trap handler names for PlatformDarwinKernel.
<rdar://problem/15246793> 

llvm-svn: 201609
2014-02-18 22:35:38 +00:00
Ed Maste 330fd535f8 elf-core: support 32- and 64-bit x86 registers
This way the same RegisterContext class can support i386 and
amd64/x86_64 core files.

With some further refinement we should be able to merge all of the
processor-specific RegisterContextPOSIX_* classes into a single shared
one.

llvm-svn: 201577
2014-02-18 15:12:35 +00:00
Sean Callanan 11e32d3db4 Properly report when a struct is anonymous.
<rdar://problem/16071066>

llvm-svn: 201539
2014-02-18 00:31:38 +00:00
Deepak Panickal ff4ac8a6e7 Replaced custom variable arguments to standard library for correcting 64 bit Windows build
llvm-svn: 201523
2014-02-17 17:52:22 +00:00
Deepak Panickal 94667bcf70 Fix Windows build, broken by the inclusion of sys/ioctl.h and isatty()
llvm-svn: 201522
2014-02-17 17:43:39 +00:00
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
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
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
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 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
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
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
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 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
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
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
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 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
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 10c82017b6 Update header comment to match filename
llvm-svn: 200647
2014-02-02 19:25:11 +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
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
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 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 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
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
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
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 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
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 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
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
Deepak Panickal 263fde068f Fix return type for Windows
llvm-svn: 199202
2014-01-14 11:34:44 +00:00
Sean Callanan 22ac610c4f Harden the Materializer logic against types that
don't know their bit alignment.

llvm-svn: 199173
2014-01-14 01:14:40 +00:00
Deepak Panickal b36da43dc3 Fixed the Visual Studio Windows build
llvm-svn: 199111
2014-01-13 14:55:15 +00:00
Ed Maste 9344787636 Avoid LLDB crash upon DW_OP_deref* with empty stack
As done in other DW_OP_* cases, return an error if the stack is empty
rather than eventually crashing elsewhere.  Encountered on big-endian
MIPS, where LLVM bugs currently result in invalid .debug_loc data.

llvm-svn: 199110
2014-01-13 14:53:09 +00:00
Jim Ingham 55d3a0c3d4 Sometimes the trampoline refers directly to the indirect symbol. Handle that too.
llvm-svn: 198990
2014-01-11 01:21:50 +00:00
Jason Molenda 7f6d84b9c1 Add the offset for cfa+offset log messages in the unwind channel, to aid in debugging.
llvm-svn: 198977
2014-01-10 23:53:32 +00:00
Jim Ingham 1460e4bf0e Get the breakpoint setting, and the Mac OS X DYLD trampolines and expression evaluator to handle Indirect
symbols correctly.  There were a couple of pieces to this.

1) When a breakpoint location finds itself pointing to an Indirect symbol, when the site for it is created
   it needs to resolve the symbol and actually set the site at its target.
2) Not all breakpoints want to do this (i.e. a straight address breakpoint should always set itself on the
   specified address, so somem machinery was needed to specify that.
3) I added some info to the break list output for indirect symbols so you could see what was happening. 
   Also I made it clear when we re-route through re-exported symbols.
4) I moved ResolveIndirectFunction from ProcessPosix to Process since it works the exact same way on Mac OS X
   and the other posix systems.  If we find a platform that doesn't do it this way, they can override the
   call in Process.
5) Fixed one bug in RunThreadPlan, if you were trying to run a thread plan after a "running" event had
   been broadcast, the event coalescing would cause you to miss the ThreadPlan running event.  So I added
   a way to override the coalescing.
6) Made DynamicLoaderMacOSXDYLD::GetStepThroughTrampolinePlan handle Indirect & Re-exported symbols.

<rdar://problem/15280639>

llvm-svn: 198976
2014-01-10 23:46:59 +00:00
Jim Ingham ea3ac27029 The actual indirect symbol is not the one at the address of the Trie entry marked with the EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER, it is given in the address in the “other” field in that entry.
llvm-svn: 198967
2014-01-10 22:55:37 +00:00
Greg Clayton fda4fab505 Revert to getting a random port and sending that down to debugserver for iOS. The sandboxing is not letting debugserver reverse connect back to lldb.
<rdar://problem/15789865>

llvm-svn: 198963
2014-01-10 22:24:11 +00:00
Jason Molenda 5f36c4beec Update the lldb version number in the xcode project files from 310.99.0 to 320.99.0.
llvm-svn: 198917
2014-01-10 06:12:10 +00:00
Greg Clayton 99e384c85f Fixed an issue with the byte order of ports in KDP packets.
I previously fixed a bug in the SocketAddress class where SocketAddress::GetPort() wasn't using ntohs() on the port number in the structures.

After fixing this, it broke places where we weren't using ntohs() and htons() correctly.

<rdar://problem/15767514>

llvm-svn: 198902
2014-01-10 00:31:10 +00:00
Jason Molenda 25f3961caf Roll back r198729; it seems to be causing two testsuite failures if llvm is built with asserts -
210: test_with_dsym_and_run_command (Test-rdar-10642615.Radar10642615DataFormatterTestCase)
     Test data formatter commands. ... Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file llvm/include/llvm/Support/Casting.h, line 239.

     226: test_with_dsym_and_run_command (Test-rdar-13338477.Radar13338477DataFormatterTestCase)
         Test that LLDB handles the clang typeclass Paren correctly. ... Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file llvm/include/llvm/Support/Casting.h, line 239.

llvm-svn: 198811
2014-01-09 00:02:17 +00:00
Jason Molenda 491caa14d5 Roll back my change to r198729; I'm going to revert it entirely.
llvm-svn: 198810
2014-01-09 00:00:53 +00:00
Jason Molenda 5005de4bac Revert the vector part of Enrico's change in r198729;
it is causing an llvm assert when run against
test/functionalities/data-formatter/rdar-10642615,

Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file llvm/include/llvm/Support/Casting.h, line 239.

llvm-svn: 198809
2014-01-08 23:35:54 +00:00
Greg Clayton 76af996df8 Only check os version for POSIX_SPAWN_CLOEXEC_DEFAULT on desktop builds of LLDB.
llvm-svn: 198800
2014-01-08 22:12:52 +00:00
Greg Clayton 2210624d86 Fixed a kernel panic that would occur if you debug anything on MacOSX 10.7 or earlier due to the use of the POSIX_SPAWN_CLOEXEC_DEFAULT attribute flag that closes all file descriptors on exec. We now dyamically detect the OS version and do the right thing.
llvm-svn: 198776
2014-01-08 18:02:51 +00:00
Todd Fiala 1a63440953 Fixes a bug preventing reading of the python register file.
This change fixes a bug recently introduced in ProcessGDBRemote that
prevented the Python register definition file from getting loaded when
the qRegisterInfo0 response returned $00#.

Patch by Steve Pucci.

llvm-svn: 198742
2014-01-08 07:52:40 +00:00
Enrico Granata af76481caf <rdar://problem/15453076>
When determining the type of array members, do not see-through typedefs
For instance, in BOOL arr[4], we want the elements to be typed as BOOL, not signed char

llvm-svn: 198729
2014-01-08 03:02:33 +00:00
Enrico Granata 6b6ea7ac17 __CFString should also format as an NSString
llvm-svn: 198727
2014-01-08 02:34:42 +00:00
Enrico Granata 0dba9b33f0 New and improved data formatter for std::shared_ptr<> and std::weak_ptr<>
llvm-svn: 198724
2014-01-08 01:36:59 +00:00
Sean Callanan 65b320f783 Fixed a bug where the expression parser doesn't
materialize a variable in a register correctly
if the variable is a pointer.  This fixes a
regression introduced by my commit of Oct. 22nd
(r193191).

llvm-svn: 198718
2014-01-07 23:15:26 +00:00
Greg Clayton 3d5bb3266f Fixed an issue when attaching to a process without specifying a file where we wouldn't set the dyld gdb image notifier breakpoint correctly.
<rdar://problem/15720040>

llvm-svn: 198717
2014-01-07 23:15:02 +00:00
Jason Molenda 5a87c0fb37 Update the checks in EmulateInstructionARM::GetFramePointerRegisterNumber
and EmulateInstructionARM::GetFramePointerDWARFRegisterNumber to recognize
the Apple arm convention (of using r7 for the frame pointer, regardless of
thumb or arm) even if the OS does not match Darwin/MacOSX/iOS.  Also 
corrects the behavior for thumb code on non-Apple platforms.
<rdar://problem/14661537> 

llvm-svn: 198648
2014-01-06 23:39:35 +00:00
Todd Fiala fb10118bfa Fix lldb build break due to TypedefNameDecl member signature change.
Patch by Steve Pucci.

llvm-svn: 198635
2014-01-06 20:25:42 +00:00
Jason Molenda 83f1149b30 Use Address::SetLoadAddress() instead of SectionLoadList::ResolveLoadAddress().
The former will set the Address object's offset to the load address value if
it is not present in any section; the latter will only set the Address object
if the load addr is contained in one of its sections.
<rdar://problem/15135987> 

llvm-svn: 198469
2014-01-04 01:37:52 +00:00
Jason Molenda 4b79247750 Don't enforce ABI stack alignment rules on the sigtramp frame --
its stack frame is a constructed, fake thing that may not conform
correctly to these rules.  This fixes a problem where lldb couldn't
backtrace past an asynchronous signal handler (_sigtramp) frame on
a stack on Mac OS X.
<rdar://problem/15035673> 

llvm-svn: 198450
2014-01-03 22:06:25 +00:00
Jason Molenda 1b101ef364 Fix a mistake in the last change I made to ProcessMachCore.cpp.
<rdar://problem/15745397> 

llvm-svn: 198447
2014-01-03 20:46:16 +00:00
Jean-Daniel Dupas de5094ba00 Fix a couple of memory leaks.
llvm-svn: 198178
2013-12-29 20:18:15 +00:00
Jean-Daniel Dupas c6f26f8542 Stop leaking MCRegisterInfo.
llvm-svn: 198177
2013-12-29 20:17:26 +00:00
Enrico Granata 30f287fde5 Add a new way to bind a format to a type: by enum type
The "type format add" command gets a new flag --type (-t). If you pass -t <sometype>, upon fetching the value for an object of your type,
LLDB will display it as-if it was of enumeration type <sometype>
This is useful in cases of non-contiguous enums where there are empty gaps of unspecified values, and as such one cannot type their variables as the enum type,
but users would still like to see them as-if they were of the enum type (e.g. DWARF field types with their user-reserved ranges)

The SB API has also been improved to handle both types of formats, and a test case is added

llvm-svn: 198105
2013-12-28 08:44:02 +00:00
Jason Molenda 703a45616c Add a new setting (currently fixed) for how to
interpret core files that contain both a user
process dyld and a kernel executable in them.
Fix an additional method that needs to be 
adjusted depending on this preference as well.
<rdar://problem/15721409> 

llvm-svn: 197931
2013-12-24 02:57:50 +00:00
Jean-Daniel Dupas 9c517c0dd9 Remove wait_for_launch parameter from DoAttachToProcessWithName(). This parameter is redundant as this information is already provided by the ProcessAttachInfo parameter.
CC: lldb-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2463

llvm-svn: 197923
2013-12-23 22:32:54 +00:00
Enrico Granata 4939b98a2c Centralize the code for GetValueAsCString() in TypeFormatImpl (the implementing class of "type format ...")
TypeFormatImpl used to just wrap a Format (and Flags for matching), and then ValueObject itself would do the printing deed
With this checkin, the responsibility of generating a value string is centralized in the data formatter (as it should, and already is for summaries) 

This change is good practice per se, and should also enable us to extend the type format mechanism in a cleaner way

llvm-svn: 197874
2013-12-22 09:24:22 +00:00
Enrico Granata 16f35ea9bb <rdar://problem/14822563> - Do not attempt to use a null VariableList or crashes will ensue
llvm-svn: 197862
2013-12-21 08:44:28 +00:00
Enrico Granata 0c0f9dcd91 Add a new-line
llvm-svn: 197860
2013-12-21 08:24:28 +00:00
Enrico Granata 473316f4ea There is no need to use the expression parser to generate true and false - writing in a buffer is good enough
llvm-svn: 197858
2013-12-21 08:09:49 +00:00
Jason Molenda c62bd7bd24 Any time ProcessGDBRemote tries to get the remote's ProcessArchitecture,
it needs to fall back to using the HostArchitecture if a valid one is not
returned.  When doing low-level system debugging we may not have a process
(or the remote stub may not support the qProcessInfo packet) in which case
we should fall back to the architecture we determined via qHostInfo.
<rdar://problem/15713180> 

llvm-svn: 197857
2013-12-21 05:20:36 +00:00
Sean Callanan fd1ca95331 Harden the Objective-C runtime against weird method
signatures.

<rdar://problem/15631996>

llvm-svn: 197843
2013-12-20 23:07:12 +00:00
Sean Callanan 439dcae4a2 Updated our IR processing to reflect best practices
for making pointer-valued constants.

llvm-svn: 197829
2013-12-20 19:55:02 +00:00
Enrico Granata cbbaf7585f All data formatters come in "match exact" and "match regex" styles
This refactoring makes it less error-prone to define formatter types with the correct match schemes

llvm-svn: 197800
2013-12-20 11:32:26 +00:00
Enrico Granata b72a501d86 FormatNavigator has long stopped navigating anything - the generation of possible formatters matches is now done elsewhere
So, rename the class for what it truly is: a FormattersContainer
Also do a bunch of related text substitutions in the interest of overall naming clarity

llvm-svn: 197795
2013-12-20 09:38:13 +00:00
Sean Callanan f4c0a221bc Fixed the AST importer to ensure that base classes
of Objective-C classes are completed, and that
variables of Objective-C types have their types
completed when the variables are reported.

This fixes a long-standing issue where ivars did
not show up correctly on 32-bit OS X.

<rdar://problem/12184093> 

llvm-svn: 197775
2013-12-20 04:09:05 +00:00
Sean Callanan 090e11975d Adjust to the new way LLVM emits modules: it doesn't
specify a pointer size until code gen.  So we just
make all our pointer-sized integer literals 64-bit.
That doesn't seem to hurt anything.

llvm-svn: 197774
2013-12-20 04:07:43 +00:00
Jason Molenda 3d21975a44 Partially revert a patch from Ashok Thirumurthi in r191430.
The original code was not completely correct, but a form of
this check is necessary to avoid an infinite recursion on
some unwind cases where a function unwinds to itself with the
same CFA.  Ashok thought the recursion would be caught in
RegisterContextLLDB but this one isn't - we still need it here.
<rdar://problem/15664282> 

llvm-svn: 197761
2013-12-20 01:05:11 +00:00
Jason Molenda 91e428bc90 Revert one part of Ashok Thirumurthi's patch from September 16, r190812.
In those set of patches, Ashok changed Module::ResolveSymbolContextForAddress 
so that if it failed to find a symbol for a pc, it could back up
the pc value by 1 and re-search for a symbol.

His change to RegisterContextLLDB.cpp partially duplicates that
behavior but it also removes the separate case where we find a
Symbol for the pc address but it's the wrong symbol -- we need to
handle this as well as the lookup-by-pc-finds-no-symbol case.

The most obvious fallout from this regression was that lldb on
Mac OS X couldn't backtrace past __assert_rtn() which tail-calls 
abort().  e.g.

(lldb) bt
* thread #1: tid = 0x5d6ea1, 0x00007fff8ee80866 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff8ee80866 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff8eb5835c libsystem_pthread.dylib`pthread_kill + 92
    frame #2: 0x00007fff8852ab1a libsystem_c.dylib`abort + 125
    frame #3: 0x00007fff884f49bf libsystem_c.dylib`__assert_rtn + 321
    frame #4: 0x0000000100000f2c a.out`main + 124

(lldb) dis -c 3 -s 0x7fff884f49b3
libsystem_c.dylib`__assert_rtn + 309:
   0x7fff884f49b3:  movq   %rax, -0x11b96242(%rip)   ; gCRAnnotations + 8
   0x7fff884f49ba:  callq  0x7fff8854fd2c            ; symbol stub for: abort

libsystem_c.dylib`basename:
   0x7fff884f49bf:  pushq  %rbp
(lldb) 

in this case, __assert_rtn() is immediately followed by basename() and 
the changes in r190812 didn't back up the pc value to get the correct
function name / unwind info.

<rdar://problem/15367233> 

llvm-svn: 197655
2013-12-19 04:32:42 +00:00
Han Ming Ong 4b5a63cd54 <rdar://problem/15639995>
Allow the root XPC launcher to launch any target as root.

llvm-svn: 197634
2013-12-19 00:35:40 +00:00
Jason Molenda 23f2fcaed8 Fix return type of ReadLibdispatchOffsetsAddress.
llvm-svn: 197632
2013-12-19 00:10:23 +00:00
Jason Molenda 4a5ec88f0d Fix std::string initialization in Queue ctor.
<rdar://problem/15694319> 

llvm-svn: 197631
2013-12-19 00:09:13 +00:00
Jason Molenda 64de91522f Code reorganization in PlatformDarwin for how the libdispatch
offsets structure is read & saved in the platform object -- soon
we'll be getting more than the queue name offset out of this
structure so we'll need to reuse the information in other methods.

llvm-svn: 197620
2013-12-18 22:52:34 +00:00
Ed Maste 48f986faee Workaround QEMU GDB server issue.
During testing I observed QEMU send "$T02thread:01;#04" upon connection,
before any command from LLDB.  This change from gclayton accepts (and
discards) a packet immediately after sending the initial ack, to flush
the GDB remote pipeline.

llvm-svn: 197579
2013-12-18 15:31:45 +00:00
Greg Clayton 6b32f1ec18 <rdar://problem/15668743>
Fixed a crasher that would only occur if Xcode attaches to a remote process first, then launches. 

llvm-svn: 197546
2013-12-18 02:06:45 +00:00
Jason Molenda eadd2cb459 When ProcessMachCore::DoLoadCore() finds *BOTH* a user process dyld and a mach kernel
binary, change to prefer the mach kernel binary by default.

llvm-svn: 197545
2013-12-18 01:56:30 +00:00
Jim Ingham a6195b732d Fix a bug introduced in asynchronous packet sends. We were not setting the packet result, and so
it looked like the async packet send always failed.

<rdar://problem/15657157>

llvm-svn: 197543
2013-12-18 01:24:33 +00:00
Jason Molenda b97f44d9ef Fix how Queue/QueueItem weak pointers are initialized in the ctors.
llvm-svn: 197541
2013-12-18 00:58:23 +00:00
Jason Molenda c8064ac626 Move the ivars / logic of SBQueue into a QueueImpl class and
change SBQueue to have a shared pointer to its corresponding
QueueImpl object for binary compatibility.
<rdar://problem/15657926> 

llvm-svn: 197300
2013-12-14 01:14:45 +00:00
Greg Clayton b09c5384b0 Centralized the launching of a process into Target::Launch()
While investigating test suite failures when running the test suite remotely, I noticed we had 3 copies of code that launched a process:
1 - in "process launch" command 
2 - SBTarget::Launch() with args
3 - SBTarget::Launch() with SBLaunchInfo

"process launch" was launching through the platform if it was supported (this is needed for remote debugging) and the 2 and 3 were not.

Now all code is in one place.

llvm-svn: 197247
2013-12-13 17:20:18 +00:00
Sylvestre Ledru a4cc7dec70 Fixes an issue where a signum => name mapping function has multiple case statements that define to the same integral value on my Linux (Ubuntu 12.04, x86_64). It's for SIGIO and SIGPOLL.
In the case that they are both defined the same.
Patch by Todd Fiala (but typos are mine)

llvm-svn: 197221
2013-12-13 09:51:39 +00:00
Jason Molenda 5e8dce4dbf Add new Queue, QueueItem, Queuelist, SBQueue, SBQueueItem classes to represent
libdispatch aka Grand Central Dispatch (GCD) queues.  Still fleshing out the
documentation and testing of these but the overall API is settling down so it's
a good time to check it in.
<rdar://problem/15600370> 

llvm-svn: 197190
2013-12-13 00:29:16 +00:00
Han Ming Ong 3a7c3d1bf8 <rdar://problem/15639995>
debugserver's launch info was cleared unnecessarily. It has important user ID set. Reviewed by Greg Clayton.

llvm-svn: 197182
2013-12-12 22:14:52 +00:00
Jean-Daniel Dupas 13698b2714 Don't try to guess sys header conditions, and simply check if each signal is defined.
CC: lldb-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2394

llvm-svn: 197173
2013-12-12 18:12:16 +00:00
Greg Clayton b73a31efe6 Pickup fixes for demangling crashers.
<rdar://problem/15600471>

llvm-svn: 197171
2013-12-12 17:39:39 +00:00
Sylvestre Ledru 6215685ab9 sin_len is not available in the structure sockaddr_in under GNU/Linux. Fix the build failure. Patch by Todd Fiala (and many other who proposed similar patches)
llvm-svn: 197155
2013-12-12 13:45:47 +00:00
Jean-Daniel Dupas b2065ecdd6 Remove useless includes
llvm-svn: 197147
2013-12-12 11:52:05 +00:00
Greg Clayton 4705f8d842 LLDB can crash if given DWARF debug info for a class that has a base class which isn't a complete definition.
<rdar://problem/15594781>

We need to not crash at any cost. We currently detect if any base classes are forward declarations, emit an error string that directs the use to file a compiler bug, and continues by completing the class with no contents. This avoids a clang crash that would usually follow when we call setBase().

llvm-svn: 197108
2013-12-12 01:54:04 +00:00
Greg Clayton 78f4d95d09 Fixed parsing the DW_TAG_member children for structs, unions and classes to not alway treat every member as a bitfield.
The previous fix for bitfields made us always search for anonymous bitfields regardless of the member (bitfield or normal field).

llvm-svn: 197088
2013-12-11 23:10:39 +00:00
Ed Maste 30df85e67f Fix Linux by partially reverting 196787
llvm-svn: 197065
2013-12-11 20:43:27 +00:00
Greg Clayton eeb15653c6 Fix the test suite after the changes made in revision 196616 exposed issues in the test suite.
We must make sure that all ValueObject objects always contain a valid target.

llvm-svn: 196983
2013-12-10 23:16:40 +00:00
Greg Clayton d30ed41c13 Revert change I didn't mean to check in.
llvm-svn: 196956
2013-12-10 19:44:41 +00:00
Greg Clayton 765d2e234c Fix autocompletion for multi-word commands.
<rdar://problem/14183288>

llvm-svn: 196949
2013-12-10 19:14:04 +00:00
Jean-Daniel Dupas 7782de923e Remove 'const' constraint on ProcessLaunchInfo parameter in Process::DoLaunch().
This 'const' is not required and prevent us to defer the launch to the Host layer.

llvm-svn: 196837
2013-12-09 22:52:50 +00:00
Ed Maste 8958af36c1 Fix Linux build after r196787
Patch from Xavier de Gaye

llvm-svn: 196830
2013-12-09 22:34:49 +00:00
Ed Maste 90359963ab Handle endianness in the Opcode class
Previously, an opcode set via SetOpcode32 (for example) was later
extracted via GetData() as a byte sequence in host order rather than
target order.

Review: http://llvm-reviews.chandlerc.com/D1838
llvm-svn: 196808
2013-12-09 19:45:33 +00:00
Jean-Daniel Dupas e5f4780d9b Replace 'mkdir' shell invocation by native function call.
Summary: Now that Host provide a MakeDirectory function, we can use it instead of relying on command line tool to create a directory.

CC: lldb-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2356

llvm-svn: 196801
2013-12-09 19:16:14 +00:00
Ed Maste 10565b61d5 FreeBSD and NetBSD have sa_len in struct sockaddr
llvm-svn: 196790
2013-12-09 16:07:11 +00:00
Ed Maste 7fd845cc9d Threaded inferior support for FreeBSD
Modelled in part on GDBRemoteCommunicationClient.

Review: http://llvm-reviews.chandlerc.com/D2267
llvm-svn: 196787
2013-12-09 15:51:17 +00:00
Ed Maste 991fe6c701 Fix Debian GNU/kFreeBSD build
Use the same LaunchProcessPosixSpawn as on FreeBSD and Linux.

llvm-svn: 196742
2013-12-09 01:35:42 +00:00
Jim Ingham b44af8ff25 If the StepThrough plan makes it back to the frame in which it started, it should say
it succeeded, since the plan that was using it can figure out what to do from there.
It should only say it failed if it truely went off into the weeds.

<rdar://problem/15597807>

llvm-svn: 196631
2013-12-07 01:17:30 +00:00
Jean-Daniel Dupas 870c011de5 Replace the last auto_ptr by unique_ptr
llvm-svn: 196625
2013-12-06 23:38:05 +00:00
Sylvestre Ledru c061cceed2 Fixed Makefile-based install to place python packages in the LLDB install tree.
Failure to install python packages now fails the make install.
This patch properly handles the optional DESTDIR variable.

Patch by Todd Fiala

llvm-svn: 196624
2013-12-06 23:16:23 +00:00
Jim Ingham 793d8d9c00 Do a little more prevention against SBValues getting used after the world has been torn down around them.
llvm-svn: 196616
2013-12-06 22:21:04 +00:00
Greg Clayton fb6621ef4b Add a setting to allow users to enable expressions that crash LLDB to show up in crash logs.
<rdar://problem/11549320> 

llvm-svn: 196613
2013-12-06 21:59:52 +00:00
Greg Clayton 3dedae12b5 Fixed the GDBRemoteCommuncation to return a new GDBRemoteCommuncation::PacketResult enum for all packet sends/receives.
<rdar://problem/15600045>

Due to other recent changes, all connections to GDB servers that didn't support the "QStartNoAckMode" packet would cause us to fail to attach to the remote GDB server.

The problem was that SendPacket* and WaitForResponse* packets would return a size_t indicating the number of bytes sent/received. The other issue was WaitForResponse* packets would strip the leading '$' and the trailing "#CC" (checksum) bytes, so the unimplemented response packet of "$#00" would get stripped and the WaitForResponse* packets would return 0.

These new error codes give us flexibility to to more intelligent things in response to what is returned. 

llvm-svn: 196610
2013-12-06 21:45:27 +00:00
Greg Clayton d629980ab3 Replace all in_port_t with uint16_t to avoid compilation issues on different systems.
llvm-svn: 196586
2013-12-06 17:46:35 +00:00
Jean-Daniel Dupas 3cfa8e217e Typo in comments
llvm-svn: 196577
2013-12-06 09:35:53 +00:00
Jean-Daniel Dupas 89d910c397 Tell CMake about the SystemRuntime plugin.
This fixes CMake build on Darwin.

llvm-svn: 196575
2013-12-06 09:32:46 +00:00
Arnaud A. de Grandmaison 223bda22f4 Tell CMake about recently added SectionLoadHistory.cpp
llvm-svn: 196566
2013-12-06 08:49:14 +00:00
Greg Clayton d5944cd118 For logical backtrace work, lldb needs to track Module unloads etc & symoblicate an address based on a point in time
<rdar://problem/15314403> 

This patch adds a new lldb_private::SectionLoadHistory class that tracks what shared libraries were loaded given a process stop ID. This allows us to keep a history of the sections that were loaded for a time T. Many items in history objects will rely upon the process stop ID in the future.

llvm-svn: 196557
2013-12-06 01:12:00 +00:00
Greg Clayton 00fe87b488 Modified local spawning in debugserver processes to use a new --reverse-connect option so that debugserver actually connects back to LLDB instead of LLDB connecting to debugserver.
This gets rid of our hacky "get_random_port()" which would grab a random port and tell debugserver to open that port. Now LLDB creates, binds, listens and accepts a connection by binding to port zero and sending the correctly bound port down as the host:port to connect back to.

Fixed the "ConnectionFileDescriptor" to be able to correctly listen for connections from a specified host, localhost, or any host. Prior to this fix "listen://" only accepted the following format:

listen://<port>

But now it can accept:

listen://<port>         // Listen for connection from localhost on port <port>
listen://<host>:<port>  // Listen for connection from <host> and <port>    
listen://*:<port>       // Listen for connection from any host on port <port>

llvm-svn: 196547
2013-12-05 22:58:22 +00:00
Jean-Daniel Dupas 0fefa67606 Extends StringExtractorGDBRemote to support debugger packets.
CC: lldb-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2337

llvm-svn: 196525
2013-12-05 19:25:45 +00:00
Sylvestre Ledru 13b0fba48b Revert: "Patch from Todd Fiala that install the lldb.py module in the prefix directory and also makes install fail if the prefix directory can't be accessed"
Does not respect the prefix

llvm-svn: 196499
2013-12-05 12:51:47 +00:00
Sylvestre Ledru 34efb6aee1 Fix the build failure of lldb wrt clang recent change. Patch by Todd Fiala
llvm-svn: 196483
2013-12-05 07:55:40 +00:00
Greg Clayton 8fbbb5b421 Patch from Todd Fiala that install the lldb.py module in the prefix directory and also makes install fail if the prefix directory can't be accessed
llvm-svn: 196413
2013-12-04 21:27:40 +00:00
Greg Clayton dbf0457a7b Allow the hostname to be specified when asking a platform to launch another debugserver in case you want to change it.
The GDB server remote platform how has the debugserver that are launched on iOS devices to use localhost due to the use of a USB mux.

llvm-svn: 196405
2013-12-04 19:40:33 +00:00
Greg Clayton c8b38d3389 Enable POSIX_SPAWN_CLOEXEC_DEFAULT (a darwin specific flag) when available when using posix_spawn to spawn processes to close all file handles.
llvm-svn: 196404
2013-12-04 19:38:57 +00:00
Greg Clayton 91a9b247d4 Switch local launching of debugserver over to always use a FIFO in order to handshake with the launched debugserver.
This helps ensure that the launched debugserver is ready and listening for a connection. Prior to this we had a race condition.

Consolidate the launching of debugserver into a single place: a static function in GDBRemoteCommunication.

llvm-svn: 196401
2013-12-04 19:19:12 +00:00
Greg Clayton c6931fcf49 Added a new directory type for the "bool Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)" function: ePathTypeLLDBTempSystemDir
This will get the temporary directory on the current system.

Removed a call to tmpnam() and replaced it with a call to mktemp() using a template that will be in the temp directory.

llvm-svn: 196397
2013-12-04 18:53:50 +00:00
Ed Maste ea66007938 Correct header guard #endif comments
llvm-svn: 196381
2013-12-04 13:41:18 +00:00
Jason Molenda 135e55f8f3 Fix log message for new invalidation checks in PlanValidAtAddress().
Thanks to Ed and Greg for catching the incorrect logging statements.

llvm-svn: 196322
2013-12-03 21:59:39 +00:00
Greg Clayton c6b26f0545 <rdar://problem/15566148>
Fix use of std::lower_bound to check for equality if a match is found to ensure we don't return the next breakpoint with an ID greater than the break_id that was asked for.

llvm-svn: 196298
2013-12-03 17:50:20 +00:00
Jason Molenda 61cd0729bb Build up UnwindPlan::PlanValidAtAddress to recognize some general
indications that the UnwindPlan is invalid -- for instance, a
complete lack of rows, or a row that fails to define a register to
base the CFA off of.
<rdar://problem/15246247> 

llvm-svn: 196201
2013-12-03 04:46:27 +00:00
Jim Ingham 177553e4c0 Remove the bad assumption that breakpoint locations won't get deleted in BreakpointLocationList::FindByID.
<rdar://problem/15566148>

llvm-svn: 196197
2013-12-03 02:31:17 +00:00
Ed Maste f44e3cd7f1 Ensure parsed debug arange data is sorted
llvm.org/pr18114

llvm-svn: 196146
2013-12-02 20:16:30 +00:00
Greg Clayton 5fb8f79738 Fixed internal code to not link against and code from "lldb/API/*".
lldb_private::Debugger was #including some "lldb/API" header files which causes tools (lldb-platform and lldb-gdbserver) that link against the internals only (no API layer) to fail to link depending on which calls were being used.

Also fixed the current working directory so that it gets set correctly for remote test suite runs. Now the remote working directory is set to: "ARCH/TESTNUM/..." where ARCH is the current architecture name and "TESTNUM" is the current test number. 

Fixed the "lldb-platform" and "lldb-gdbserver" to not warn about mismatched visibility settings by having each have their own exports file which contains nothing. This forces all symbols to not be exported, and also quiets the linker warnings.

llvm-svn: 196141
2013-12-02 19:35:49 +00:00
Ed Maste c113ff8cba elf: Move elf note parsing to ObjectFileELF.cpp
Separate ELF note implementations were introduced for core files and
GNU build-id.  Move the more general one from elf-core to ObjectFileELF
and use it for build-id as well.

Review: http://llvm-reviews.chandlerc.com/D1902
llvm-svn: 196125
2013-12-02 17:49:13 +00:00
Sylvestre Ledru 3b5b16cdff Also silent -Wno-cast-qual in the SWIG Python wrapper. Remove a huge number of warnings
llvm-svn: 195930
2013-11-28 18:11:34 +00:00
Colin Riley 909bb7a3f4 Fix MSVC build
Added _WIN32 guards to new platform features. Using correct SetErrorStringWithFormat within Host when LLDB_DISABLE_POSIX is defined. Also fixed an if defined block.

llvm-svn: 195766
2013-11-26 15:10:46 +00:00
Ed Maste 82a0005b21 Fix compile warnings
llvm-svn: 195685
2013-11-25 21:15:53 +00:00
Ed Maste 426285bfad Remove unused variable
llvm-svn: 195683
2013-11-25 20:48:07 +00:00
Ed Maste ac7270b56b Correct a standalone debug file path
For a file /bin/ls with a .gnu_debuglink entry of "ls.debug" the path
should be /usr/lib/debug/bin/ls.debug, not /usr/lib/debug/bin/ls.

ref: https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html

llvm.org/pr17903
http://llvm-reviews.chandlerc.com/D2169

llvm-svn: 195681
2013-11-25 20:33:56 +00:00
Ed Maste 3fe7186a1b Remove redundant assignment
llvm-svn: 195664
2013-11-25 17:16:34 +00:00
Ed Maste 6cf5b8f18c Fix issue from r166732 found by Andrew Kaylor
From Jim Ingham's email:
  It does look like ThreadPlanStepInRange test is some kind of thinko.
  In practice, in this case it is probably safe to run only one thread
  when doing the "step through" since that generally involved running
  from a shared library stub to its target.  That could deadlock if the
  dynamic loader has to fix up the symbol, and another thread is in the
  middle of doing that.  But that doesn't seem to be very common, or at
  least the code is clearly wrong but I haven't had any reports of this
  causing deadlocks...

llvm-svn: 195657
2013-11-25 16:36:47 +00:00
Ed Maste 502f9020a7 PT_CONTINUE and PT_STEP are process-scope on FreeBSD
Although ptrace() can be passed a PID or TID for PT_CONTINUE and PT_STEP,
the kernel operates on all threads in the process in both cases.  (See
the FOREACH_THREAD_IN_PROC in FreeBSD's sys_process.c:kern_ptrace.)

Make this clear by using the PID from the ProcessMonitor instance.

llvm-svn: 195656
2013-11-25 16:31:23 +00:00
Jason Molenda 906f329724 Change lldb from building against a Python framework out of
the installed SDK to using the current OS installed headers/libraries.
This change is to address the removal of the Python framework
from the Mac OS X 10.9 (Mavericks) SDK, and is the recommended
workaround via https://developer.apple.com/library/mac/technotes/tn2328/_index.html

llvm-svn: 195557
2013-11-23 20:07:29 +00:00
Greg Clayton 5c6eab21eb Removed printf and puts calls that were left in accidentally.
llvm-svn: 195542
2013-11-23 02:01:06 +00:00
Greg Clayton fb90931b60 Improved platform support.
Improved the detection of a valid GDB server where we actually can connect to a socket, but then it doesn't read or write anything (which happens with some USB mux software).

Host::MakeDirectory() now can make as many intermediate directories as needed.

The testsuite now has very initial support for remote test suite running. When running on a remote platform, the setUp function for the test will make a new directory and select it as the working directory on the remote host. 

Added a common function that can be used to create the short option string for getopt_long calls.

llvm-svn: 195541
2013-11-23 01:58:15 +00:00
Greg Clayton ec6829eac0 Patch from Todd Fiala: lldb will seg fault if for some reason there is no unwinder when StackFrameList::GetFramesUpTo() is called.
Mainly patched to stop LLDB from crashing. This can easily happen if you debug to a remote gdbserver that doesn't have any dynamic register info and you don't have a target definition file specified.

llvm-svn: 195499
2013-11-22 21:03:42 +00:00
Greg Clayton 2b98c56996 Fixed functions to always reply to packets and added a port offset.
Fixed a bunch of issues with many functions that were added for the platform host IO calls where they might not reply to the packet if the packet was malformed.

Cleaned up error codes.

Added a port offset to allow for connections across a USB mux.

llvm-svn: 195485
2013-11-22 18:53:12 +00:00
Greg Clayton 3bd19fb07d Fix ePathTypeSupportExecutableDir for shallow bundle Darwin targets and add "host" logging for the different paths.
llvm-svn: 195484
2013-11-22 18:48:24 +00:00
Greg Clayton 8c8018d36f Only use a PTY master/slave when launching for local processes.
llvm-svn: 195483
2013-11-22 18:47:24 +00:00
Greg Clayton c029382690 Fix File::GetPermissions() to only return the permission bits.
llvm-svn: 195482
2013-11-22 18:46:55 +00:00
Greg Clayton 6d4130e7d9 Fix indentation.
llvm-svn: 195481
2013-11-22 18:46:16 +00:00
Colin Riley 6c97042044 Fix for PECOFF GetArchitecture
0 as CPU subtype never matches anything (at least, it doesn't match x86_64 windows binaries, of which there are correct arch definitions for). It should be created with LLDB_INVALID_CPUTYPE. 

llvm-svn: 195435
2013-11-22 09:35:12 +00:00
Jim Ingham 1a7ee7044a #include <AvailabilityMacros.h> if you want to use them. This was causing us to skip
the code that should have set thread names on Mac OS X.

<rdar://problem/15517264>

llvm-svn: 195403
2013-11-22 00:51:36 +00:00
Enrico Granata de61cecd1c <rdar://problem/15530080>
Rework data formatters matching algorithm
What happens now is that, for each category, the FormatNavigator generates all possible matches, and checks them one by one
Since the possible matches do not actually depend on the category (whether a match is accepted or not does, but that check can be shifted at a more convenient time),
it is actually feasible to generate every possible match upfront and then let individual categories just scan through those

This commit changes things by introducing a notion of formatters match candidate, and shifting responsibility for generating all of them given a (ValueObject,DynamicValueType) pair
from the FormatNavigator back to the FormatManager
A list of these candidates is then passed down to each category for matching
Candidates also need to remember whether they were generated by stripping pointers, references, typedefs, since this is something that individual formatters can choose to reject
This check, however, is conveniently only done once a "textual" match has been found, so that the list of candidates is truly category-independent

While the performance benefit is small (mostly, due to caching), this is much cleaner from a design perspective

llvm-svn: 195395
2013-11-22 00:02:13 +00:00
Ed Maste 5341404258 Update cmake for SBPlatform.cpp added in r195273
llvm-svn: 195362
2013-11-21 14:38:22 +00:00
Jason Molenda 4a4b5dcb7d sys/stat.h needed for mkdir, chmod, stat.
llvm-svn: 195305
2013-11-21 02:45:55 +00:00
Greg Clayton 29b8fc4da9 Added new options to lldb-platform:
--gdbserver-port PORT
    --min-gdbserver-port PORT
    --max-gdbserver-port PORT
    
The --gdbserver-port option can be specified multiple times to tell lldb-platform which ports it can use when launching child GDB server processes.
The --min-gdbserver-port and --max-gdbserver-port options allow a range of ports to be specified for use when launching child GDB server processes.

Fixed the code to manage these ports correctly in GDBRemoteCommunicationServer.

Also changed GDBRemoteCommunicationClient to not set a port when sending the "qLaunchGDBServer" packet so that the remote lldb-platform can decide which ports to use. If the lldb-platform was launched with no --gdbserver-port or --min-gdbserver-port/--max-gdbserver-port options, then port 0 is always used and a unix socket is used between the lldb-platform and child GDB server process to coordinate the use of valid port.

llvm-svn: 195300
2013-11-21 01:44:58 +00:00
Enrico Granata 5383e81a7f <rdar://problem/15449837>
Change the NSSet data formatter to not use the expression parser to produce synthetic children
In small-scale experimentation with lldb-perf, this improves our performance by around 25%

llvm-svn: 195294
2013-11-21 01:08:05 +00:00
Greg Clayton fbb7634934 Expose SBPlatform through the public API.
Example code:

remote_platform = lldb.SBPlatform("remote-macosx"); 
remote_platform.SetWorkingDirectory("/private/tmp")
debugger.SetSelectedPlatform(remote_platform)

connect_options = lldb.SBPlatformConnectOptions("connect://localhost:1111"); 
err = remote_platform.ConnectRemote(connect_options)
if err.Success():
    print >> result, 'Connected to remote platform:'
    print >> result, 'hostname: %s' % (remote_platform.GetHostname())
    src = lldb.SBFileSpec("/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework", False)
    dst = lldb.SBFileSpec()
    # copy src to platform working directory since "dst" is empty
    err = remote_platform.Install(src, dst);
    if err.Success():
        print >> result, '%s installed successfully' % (src)
    else:
        print >> result, 'error: failed to install "%s": %s' % (src, err)


Implemented many calls needed in lldb-platform to be able to install a directory that contains symlinks, file and directories.

The remote lldb-platform can now launch GDB servers on the remote system so that remote debugging can be spawned through the remote platform when connected to a remote platform.

The API in SBPlatform is subject to change and will be getting many new functions.

llvm-svn: 195273
2013-11-20 21:07:01 +00:00
Colin Riley 61979ccad6 Fix MSVC build
The demangler added in r193708 from cxa_demangle.cpp uses language features which are not supported by the latest visual studio. In order to preserve the msvc build, this patch restores the previous (non)functionality in windows under msvc by disabling the demangler. 

llvm-svn: 195254
2013-11-20 15:19:08 +00:00
Jason Molenda 4ff132610a Flush the Process' cache of extended threads every time the
natural stop id is updated.
<rdar://problem/15496603> 

llvm-svn: 195177
2013-11-20 00:31:38 +00:00
Jason Molenda a6e9130d52 Add logging for the SB API which creates extended
threads.

Take a stab at fixing the too-soon freeing of the extended
backtrace thread list in Process.
<rdar://problem/15496603> 

llvm-svn: 195104
2013-11-19 05:44:41 +00:00
Jason Molenda 8ee9cb5891 Add a new SBThread::GetExtendedBacktraceOriginatingIndexID() method
(and same thing to Thread base class) which can be used when looking
at an ExtendedBacktrace thread; it will try to find the IndexID() of
the original thread that was executing this backtrace when it was
recorded.  If lldb can't find a record of that thread, it will return
the same value as IndexID() for the ExtendedBacktrace thread.

llvm-svn: 194912
2013-11-16 01:24:22 +00:00
Sylvestre Ledru f0f2d58086 Improve the set of the Python libraries during the cmake build.
Thanks to Kal Conley for the patch

llvm-svn: 194815
2013-11-15 14:15:10 +00:00
Jason Molenda a7b5afa91b Commit a work-in-progress system runtime for Mac OS X which won't
do anything right now.  Add a few new methods to the Thread base
class which HistoryThread needs.  I think I updated all the 
CMakeLists files correctly for the new plugin.

llvm-svn: 194756
2013-11-15 00:17:32 +00:00
Greg Clayton f74cf86bc5 <rdar://problem/15172417>
Added two new GDB server packets to debugserver: "QSaveRegisterState" and "QRestoreRegiterState".

"QSaveRegisterState" makes the remote GDB server save all register values and it returns a save identifier as an unsigned integer. This packet can be used prior to running expressions to save all registers.

All registers can them we later restored with "QRestoreRegiterState:SAVEID" what SAVEID is the integer identifier that was returned from the call to QSaveRegisterState.

Cleaned up redundant code in lldb_private::Thread, lldb_private::ThreadPlanCallFunction.
Moved the lldb_private::Thread::RegisterCheckpoint into its own header file and it is now in the lldb_private namespace. Trimmed down the RegisterCheckpoint class to omit stuff that wasn't used (the stack ID).

Added a few new virtual methods to lldb_private::RegisterContext that allow subclasses to efficiently save/restore register states and changed the RegisterContextGDBRemote to take advantage of these new calls.

llvm-svn: 194621
2013-11-13 23:28:31 +00:00
Enrico Granata 8d81a843fa Minor improvement to the "memory find" command
Remove the --do-read option, and always provide a small dump of memory at each match spot
Add a --dump-offset (-o) option, to specify a byte offset from which to start dumping relative to the matching address

The real solution is to actually provide the format options found on "memory read" and use those as the key to actually printing memory upon each find
That, however, requires a little refactoring work, so put this in for now until I get a chance to do the required shuffling around of moving parts

llvm-svn: 194600
2013-11-13 20:08:30 +00:00
Greg Clayton 3ebae49748 Fixed printf warnings. The GetByteSize() results return uint64_t values, not size_t values.
llvm-svn: 194587
2013-11-13 18:01:16 +00:00
Enrico Granata 6e49c48f97 Small typos in previous commit
llvm-svn: 194546
2013-11-13 02:22:24 +00:00
Enrico Granata 534684372d <rdar://problem/14322677>
Implement a "memory find" command for LLDB

This is still fairly rough around the edges but works well enough for simple scenarios where a chunk of text or a number are to be found within a certain range of memory, as in
mem find `buffer` `buffer+0x1000` -s "me" -c 5 -r

llvm-svn: 194544
2013-11-13 02:18:44 +00:00
Jason Molenda 008c45f1a1 Change SBThread::GetExtendedBacktrace to
SBThread::GetExtendedBacktraceThread to make it more clear what is
being returned.

llvm-svn: 194531
2013-11-12 23:33:32 +00:00
Ed Maste 7b24e95e69 Log failure to restore thread state in ThreadPlanCallFunction::DoTakedown
In order to help track down llvm.org/pr17226.

llvm-svn: 194487
2013-11-12 16:47:08 +00:00
Jason Molenda 750ea692e8 Add initial --extended / -e support to thread backtrace.
llvm-svn: 194455
2013-11-12 07:02:07 +00:00
Jason Molenda ee87e75090 Add object logging to HistoryThread. Call the DoDestroy() method from
the HistoryThread dtor.

llvm-svn: 194436
2013-11-12 00:09:58 +00:00
Ed Maste d23dcbfb53 Increase log detail for size mismatch in EntityVariable::Materialize
llvm-svn: 194413
2013-11-11 19:40:51 +00:00
Ed Maste eefd43f331 Fix header comment line length
llvm-svn: 194397
2013-11-11 18:30:28 +00:00
Ed Maste 2138d18a08 Add generic ARGn register IDs for FreeBSD and Linux x86
These were previously missing in g_register_infos_x86_64 and so arg
lookup failed on FreeBSD and Linux after r194035.

llvm-svn: 194392
2013-11-11 17:02:33 +00:00
Jason Molenda 864f1cc065 The Threads created when requesting extended backtraces need to be owned by
something; add a new ExtendedThreadList to Process where they can be retained
for the duration of a public stop.
<rdar://problem/15314068> 

llvm-svn: 194367
2013-11-11 05:20:44 +00:00
Jason Molenda 7a2f7904bf The Threads created when requesting extended backtraces need to be owned by
something; add a new ExtendedThreadList to Process where they can be retained
for the duration of a public stop.
<rdar://problem/15314068> 

llvm-svn: 194366
2013-11-11 05:19:34 +00:00
Peter Collingbourne 19676ac58f Fix CMake standalone build.
llvm-svn: 194363
2013-11-11 04:46:09 +00:00
Greg Clayton b35db6399d Fixed the the breakpoint test case failures.
There were 6 on darwin. All of these were related to the recent changes for exec.

llvm-svn: 194298
2013-11-09 00:03:31 +00:00
Greg Clayton c28ce7828b Fixed a build warning for a missing switch case.
llvm-svn: 194295
2013-11-08 23:38:26 +00:00
Jason Molenda 02706c3216 Add History subclasses for Thread, Unwind, RegisterContext.
Still working out some of the details of these classes but 
I wanted to get the overall structure checked in.
<rdar://problem/15314068> 

llvm-svn: 194245
2013-11-08 04:59:54 +00:00
Sean Callanan a464f3d43a Changed the ABIs and ClangFunction to take a
llvm::ArrayRef of arguments rather than taking
a fixed number of possibly-NULL pointers to
arguments.

Also changed ClangFunction::GetThreadPlanToCallFunction
to take the address of the argument struct by value
instead of by reference, since it doesn't actually
modify the value passed into it.

llvm-svn: 194232
2013-11-08 01:14:26 +00:00
Jim Ingham 6fbc48bc42 This patch does a couple of things.
It completes the job of using EvaluateExpressionOptions consistently throughout
the inferior function calling mechanism in lldb begun in Greg's patch r194009. 

It removes a handful of alternate calls into the ClangUserExpression/ClangFunction/ThreadPlanCallFunction which
were there for convenience.  Using the EvaluateExpressionOptions removes the need for them.

Using that it gets the --debug option from Greg's patch to work cleanly.

It also adds another EvaluateExpressionOption to not trap exceptions when running expressions.  You shouldn't
use this option unless you KNOW your expression can't throw beyond itself.  This is:

<rdar://problem/15374885>

At present this is only available through the SB API's or python.

It fixes a bug where function calls would unset the ObjC & C++ exception breakpoints without checking whether
they were set by somebody else already.

llvm-svn: 194182
2013-11-07 00:11:47 +00:00
Sean Callanan 2a0e663fbd Spelling fix.
llvm-svn: 194163
2013-11-06 19:56:05 +00:00
Sean Callanan 5c19eac1c8 Added Iterable, a class that vends standard C++
iterators for LLDB's container data structures.
Iterable abstracts over the backing data structure,
ignoring keys for maps for example.  It also provides
locking as a service so that the code

for (ThreadSP thread_sp : process->Threads())
{
  // ... use thread_sp
}

takes the appropriate locks once, without having to
do anything else.

The salient advantages of this system are:

- Much simpler and idiomatic loop code
- Lock once instead of each time an element is fetched
- Less boilerplate to produce the iterators

The intent is that Iterable will replace Get...AtIndex
in most places, and that ForEach(), which solves the
same problem in a less-idiomatic way, be phased out in
favor of this approach.

I've added Iterables to ThreadList, TypeList, and
Process (which is really just forwarding to ThreadList).

llvm-svn: 194159
2013-11-06 19:28:40 +00:00
Jason Molenda 95d005c789 Rename extended backtrace methods to take out the "ThreadOrigin"
bit from the method names.
<rdar://problem/15314369> 

llvm-svn: 194122
2013-11-06 03:07:33 +00:00
Greg Clayton cae5652838 Improve lldb_private::Address to detect when section was deleted and not return bogus values for GetLoadAddress() and GetFileAddress().
llvm-svn: 194120
2013-11-06 02:29:13 +00:00
Jason Molenda 5dd4916f63 Add a new GetThreadOriginExtendedBacktrace method to the
SystemRuntime and SBThread classes.
<rdar://problem/15314369> 

llvm-svn: 194111
2013-11-06 00:04:44 +00:00
Greg Clayton 095eeaa025 <rdar://problem/15367122>
Fixed the test case for "test/functionalities/exec/TestExec.py" on Darwin.

The issue was breakpoints were persisting and causing problems. When we exec, we need to clear out the process and target and start fresh with nothing and let the breakpoints populate themselves again. This patch correctly clears out the breakpoints and also flushes the process so that the objects (process/thread/frame) give out valid information.

llvm-svn: 194106
2013-11-05 23:28:00 +00:00
Jim Ingham afbb0af827 Give a better error when the index argument for “frame select” can’t be parsed.
<rdar://problem/15390829>

llvm-svn: 194087
2013-11-05 18:25:23 +00:00
Jason Molenda 8c71337abc Add the GetNumThreadOriginExtendedBacktraceTypes and
GetThreadOriginExtendedBacktraceTypeAtIndex methods to
SBProcess.

Add documentation for the GetQueueName and GetQueueID methods
to SBThread.
<rdar://problem/15314369> 

llvm-svn: 194063
2013-11-05 11:00:35 +00:00
Jason Molenda b4db43fad6 Add a GetThreadOriginExtendedBacktraceTypes method to the
SystemRuntime class.
<rdar://problem/15314369> 

llvm-svn: 194045
2013-11-05 04:25:57 +00:00
Jason Molenda eef510667b Add a new system runtime plugin type - just the top level
class, not any actual plugin implementation yet.
<rdar://problem/15314068> 

llvm-svn: 194044
2013-11-05 03:57:19 +00:00
Greg Clayton bb3a9b74e7 Update ABISysV_x86_64.cpp to use more efficient register finding calls.
Instead of looking up registers by name, we use the generic ID when we can.

Also added code that creates an extra frame when running expressions by pushing the current PC and FP and then hooking up the FP backchain. This code is "#if 0" out for now until we can pair it with unwinder fixes.

llvm-svn: 194035
2013-11-05 01:24:05 +00:00
Jason Molenda 8065867ff7 Fix the architectural default unwind plan's settings for restoring
the stack pointer.

llvm-svn: 194029
2013-11-05 00:19:09 +00:00
Jason Molenda 00ec491fc6 Fix a bug in the x86_64 architectural default unwindplan
where it was using the wrong register numbering scheme
to express where the rbp could be retrieved from.

llvm-svn: 194023
2013-11-04 22:57:40 +00:00
Greg Clayton bc3122ead3 <rdar://problem/15367406>
Fixed a case where on darwin, after recent compiler changes a few months ago, we could not execute dlopen() in an expression, or use "process load".

The issue was some compiler option default values changed. We now override these settings to get the old behavior back.

llvm-svn: 194012
2013-11-04 19:50:49 +00:00
Greg Clayton 62afb9f663 Added a "--debug" option to the "expression" command.
Cleaned up ClangUserExpression::Evaluate() to have only one variant that takes a "const EvaluateExpressionOptions& options" instead of taking many arguments.

The "--debug" option is designed to allow you to debug your expression by stopping at the first instruction (it enables --ignore-breakpoints=true and --unwind-on-error=false) and allowing you to step through your JIT code. It needs to be more integrated with the thread plan, so I am checking this in so Jim Ingham can make it happen.

llvm-svn: 194009
2013-11-04 19:35:17 +00:00
Jason Molenda 99618476ad Add new ivars to StackFrame so it can represent a stack collected
at some point in the past.  We may have nothing more than a pc value
for this type of stack frame -- hopefully we'll have a pc and a
stop_id so we can track module loads and unloads over time and
symbolicate the pc at the correct point in time.

Also add a flag to indicate if the CFA for the frame is available
(a bit different from a CFA of LLDB_INVALID_ADDRESS) and also an
overall setting to indicate whether this is a history stack frame
or not.  A history stack frame may not have a CFA, it may not have
a register context, it may not have variables, it may not have a
frame pointer or a stack pointer.

<rdar://problem/15314068>

llvm-svn: 193987
2013-11-04 11:02:52 +00:00
Jason Molenda b57e4a1bc6 Roll back the changes I made in r193907 which created a new Frame
pure virtual base class and made StackFrame a subclass of that.  As
I started to build on top of that arrangement today, I found that it
wasn't working out like I intended.  Instead I'll try sticking with
the single StackFrame class -- there's too much code duplication to
make a more complicated class hierarchy sensible I think.

llvm-svn: 193983
2013-11-04 09:33:30 +00:00
Filip Pizlo 8677577395 It is no longer necessary to opt out of pretty stack traces.
llvm-svn: 193972
2013-11-04 02:25:07 +00:00
Jason Molenda f23bf7432c Add a new base class, Frame. It is a pure virtual function which
defines a protocol that all subclasses will implement.  StackFrame
is currently the only subclass and the methods that Frame vends are
nearly identical to StackFrame's old methods.

Update all callers to use Frame*/Frame& instead of pointers to
StackFrames.

This is almost entirely a mechanical change that touches a lot of
the code base so I'm committing it alone.  No new functionality is
added with this patch, no new subclasses of Frame exist yet.

I'll probably need to tweak some of the separation, possibly moving
some of StackFrame's methods up in to Frame, but this is a good
starting point.

<rdar://problem/15314068>

llvm-svn: 193907
2013-11-02 02:23:02 +00:00
Sylvestre Ledru 779f921311 Fix the format warnings.
In almost all cases, the misuse is about "%lu" being used instead of the correct "%zu" (even though these are compatible on 64-bit platforms in practice). There are even a couple of cases where "%ld" (ie., signed int) is used instead of "%zu", and one where "%lu" is used instead of "%" PRIu64.

Fixes bug #17551.

Patch by "/dev/humancontroller"

llvm-svn: 193832
2013-10-31 23:55:19 +00:00
Enrico Granata fcf0c4e31a Further fixes to the dynamic type system prompted by ObjCDataFormatterTestCase.test_nserror_with_dsym_and_run_command
llvm-svn: 193818
2013-10-31 22:42:00 +00:00
Enrico Granata 90a8db30de Renaming the setting to enable/disable automatic one-lining of summaries as auto-one-line-summaries
llvm-svn: 193801
2013-10-31 21:01:07 +00:00
Ed Maste 1c09d4a537 Migrate DWARFDebugLine to DWARFDataExtractor 64-bit DWARF support
llvm-svn: 193794
2013-10-31 19:51:53 +00:00
Ed Maste d8f57278b8 Remove unused DWARFDebugLine length functions
llvm-svn: 193792
2013-10-31 19:31:16 +00:00
Enrico Granata d7373f69cf SBValue::GetValueAsUnsigned()/GetValueAsSigned() should not replicate the Scalar manipulation logic found in ValueObject, but rather just call down to it
llvm-svn: 193786
2013-10-31 18:57:50 +00:00
Greg Clayton a1e0318c42 Added more details on the exact version of the cxa_demangle.cpp file for the built in demangler. This will help us track when we need to update this file.
llvm-svn: 193784
2013-10-31 18:41:50 +00:00
Ed Maste 3606da2614 Use inlined demangler on FreeBSD
FreeBSD includes the elftoolchain project's demangler in the base system.
It does not handle some unusual mangled names, so use the inlined
libcxxabi one.

llvm-svn: 193776
2013-10-31 17:42:32 +00:00
Greg Clayton dc25a0bc64 <rdar://problem/14496092>
Fixes from code review by Jim Ingham that reinstate preferring an external vs non-external symbol when finding function addresses.

llvm-svn: 193761
2013-10-31 16:59:47 +00:00
Enrico Granata 686f3deb44 This checkin introduces the notion of hardcoded formatters, which LLDB can bind to a ValueObject internally depending on any criteria
User-vended by-type formatters still would prevail on these hardcoded ones

For the time being, while the infrastructure is there, no such formatters exist

This can be useful for cases such as expanding vtables for C++ class pointers, when there is no clear cut notion of a typename matching, and the feature is low-level enough that it makes sense for the debugger core to be vending it

llvm-svn: 193724
2013-10-30 23:46:27 +00:00
Greg Clayton f32db51c50 <rdar://problem/14496092>
Fixed the expression parser to be able to iterate across all function name matches that it finds when it is looking for the address of a function that the IR is looking for. Also taught it to deal with reexported symbols.

llvm-svn: 193716
2013-10-30 21:37:46 +00:00
Greg Clayton 19c8e78b86 <rdar://problem/15201312>
Inlined a copy of cxa_demangle.cpp from:

http://llvm.org/svn/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp

For systems that don't have demangling built into the system, and for systems that don't want to use the version that is installed. Defining LLDB_USE_BUILTIN_DEMANGLER in your build system allows you to use the built in demangler. This setting is curently automatically enabled for Windows builds.

llvm-svn: 193708
2013-10-30 18:42:59 +00:00
Greg Clayton c1ae724757 Fixed a warning in PlatformiOSSimulator where GetSDKDirectory was hiding recently added virtual function. Renamed GetSDKDirectory to GetSDKsDirectory to fix the issue. GetSDKsDirectory is a better fit because it finds the directory that contains all SDKs, not the current one.
llvm-svn: 193707
2013-10-30 18:40:41 +00:00
Enrico Granata 5e1480c5dc <rdar://problem/13308704>
Fixing a problem where ValueObject::GetPointeeData() would not accept "partial" valid reads (i.e. asking for 10 items and getting only 5 back)
While suboptimal, this situation is not a flat-out failure and could well be caused by legit scenarios, such as hitting a page boundary

Among others, this allows data formatters to print char* buffers allocated under libgmalloc

llvm-svn: 193704
2013-10-30 17:52:44 +00:00
Enrico Granata 34b6671ca3 <rdar://problem/15143022>
CFNumberRef is toll-free bridged to NSNumber
We can use the same summary formatter for both types

llvm-svn: 193666
2013-10-30 00:17:52 +00:00
Enrico Granata 38c546320c <rdar://problem/15045059>
One of the things that dynamic typing affects is the count of children a type has
Clear out the flag that makes us blindly believe the children count when a dynamic type change is detected

llvm-svn: 193663
2013-10-30 00:04:29 +00:00
Enrico Granata 0947a6e93b <rdar://problem/15296388>
Fix a crasher that would occur if one tried to read memory as characters of some size != 1, e.g.
x -f c -s 10  buffer

This commit tries to do the right thing and uses the byte-size as the number of elements, unless both are specified and the number of elements is != 1
In this latter case (e.g. x -f c -s 10 -c 3  buffer) one could multiply the two and read 30 characters, but it seems a stretch in mind reading.

llvm-svn: 193659
2013-10-29 23:04:29 +00:00
Enrico Granata df7c7f99ba Fixing an issue in yesterday's dynamic type changes where we would not craft a valid SBType given debug information
Added a test case to help us detect regression in this realm

llvm-svn: 193631
2013-10-29 17:42:02 +00:00
Enrico Granata dc4db5a6eb <rdar://problem/15144376>
This commit reimplements the TypeImpl class (the class that backs SBType) in terms of a static,dynamic type pair

This is useful for those cases when the dynamic type of an ObjC variable can only be obtained in terms of an "hollow" type with no ivars
In that case, we could either go with the static type (+iVar information) or with the dynamic type (+inheritance chain)

With the new TypeImpl implementation, we try to combine these two sources of information in order to extract as much information as possible
This should improve the functionality of tools that are using the SBType API to do extensive dynamic type inspection

llvm-svn: 193564
2013-10-29 00:28:35 +00:00
Jim Ingham 4396b8e618 Change the default handling for SIGALRM and SIGCHLD to not notify.
<rdar://problem/15208799>

llvm-svn: 193530
2013-10-28 19:00:42 +00:00
Jason Molenda 6a8658ad61 Fix the signed-ness of a few log printf directives in Process::RunThreadPlan.
llvm-svn: 193488
2013-10-27 02:32:23 +00:00
Enrico Granata 553fad5c9a <rdar://problem/15319880>
Introduce a new boolean setting enable-auto-oneliner
This setting if set to false will force LLDB to not use the new compact one-line display

By default, one-line mode stays on, at least until we can be confident it works.
But now if it seriously impedes your workflow while it evolves/it works wonders but you still hate it, there's a way to turn it off

llvm-svn: 193450
2013-10-25 23:09:40 +00:00
Greg Clayton 9ac6d2db73 <rdar://problem/15263540>
Added a new key that we understand for the "qHostInfo" packet: "default_packet_timeout:T;" where T is a default packet timeout in seconds.

This allows GDB servers with known slow packet response times to increase the default timeout to a value that makes sense for the connection.

llvm-svn: 193425
2013-10-25 18:13:17 +00:00
Ed Maste 9204e6d8f5 Update DWARFDebugPubnamesSet 64-bit DWARF to use new DWARFDataExtractor
llvm-svn: 193407
2013-10-25 13:18:17 +00:00
Greg Clayton 9b2349888f Added the ability to get the SDK path for a target using the platform plugins. If LLDB lives inside an Xcode.app bundle, it will select the SDK in the Xcode bundle, else it will use the currently selected Xcode.
Also added the DWARFDataExtractor classes to the Xcode project file.

llvm-svn: 193380
2013-10-24 22:54:08 +00:00
Ed Maste eeae72184b Introduce DWARFDataExtractor for 64-Bit DWARF parsing
Review: http://llvm-reviews.chandlerc.com/D2007
llvm-svn: 193368
2013-10-24 20:43:47 +00:00
Greg Clayton 4598907ff8 Fixed format strings as they still must specicy a '%' prior to using PRI*64 macros.
llvm-svn: 193260
2013-10-23 18:24:30 +00:00
Ed Maste 2ea0f2cdae 64-Bit DWARF support for .debug_aranges and .debug_pubnames
llvm-svn: 193250
2013-10-23 17:24:15 +00:00
Ed Maste 726a591482 Initial DWARF64 support for .debug_line
Some versions of the GNU MIPS toolchain generate 64-Bit DWARF (even though
it isn't really necessary).  This change adds support for the 64-Bit DWARF
format, but is not actually tested with >4GB of debug data.

Similar changes are in progress for llvm's version of DWARFDebugLine, in
review D1988.

llvm-svn: 193242
2013-10-23 14:18:41 +00:00
Enrico Granata c89e4ca3c1 One should actually not do one-line printing of nested aggregates even if they are not the base class
This check was overly strict. Relax it.
While one could conceivably want nested one-lining:
(Foo) aFoo = (x = 1, y = (t = 3, q = “Hello), z = 3.14)
the spirit of this feature is mostly to make *SMALL LINEAR* structs come out more compact.
Aggregates with children and no summary for now just disable the one-lining. Define a one-liner summary to override :)

llvm-svn: 193218
2013-10-23 01:34:31 +00:00
Enrico Granata 106260c574 Improvements to the ValueObjectPrinter to behave correctly in more dynamic value cases
llvm-svn: 193204
2013-10-22 22:42:14 +00:00
Sean Callanan 13b4ef2dba Simplified the code that materializes a variable,
obviating the need to create a new ValueObject.

llvm-svn: 193191
2013-10-22 20:01:17 +00:00
Deepak Panickal d66b50c96c Fixes to get LLDB building on Windows again.
llvm-svn: 193159
2013-10-22 12:27:43 +00:00
Jason Molenda 12075f71f9 Update ResolveFunctionPointers to build after the changes
of llvm r193091.  Thanks to Ed Maste for narrowing it down.

llvm-svn: 193140
2013-10-22 03:11:55 +00:00
Jason Molenda 4fdb5863b9 Expose the Thread::GetQueueID() method through the SBThread API, similar to
the existing SBThread::GetQueueName() method.

llvm-svn: 193132
2013-10-21 23:52:54 +00:00
Greg Clayton d65ef14df3 Fixed breakpoints to be able to be set on eSymbolTypeReExported symbols and resolve to the correct function. This allows setting a breakpoint on "memset" for iOS simulator binaries and the correct breakpoint will be set on "__platform_memset".
llvm-svn: 193114
2013-10-21 20:04:47 +00:00
Greg Clayton 9191db47da <rdar://problem/14496092>
Fixed an issue with reexported symbols on MacOSX by adding support for symbols re-exporting symbols. There is now a new symbol type eSymbolTypeReExported which contains a new name for the re-exported symbol and the new shared library. These symbols are only used when a symbol is re-exported as a symbol under a different name.

Modified the expression parser to be able to deal with finding the re-exported symbols and track down the actual symbol it refers to.

llvm-svn: 193101
2013-10-21 18:40:51 +00:00
Enrico Granata aff6565f85 Get rid of the FooStructSynth, it was a testing thing I put in and forgot to remove
Hopefully nobody had a struct Foo in their app:-)

llvm-svn: 193092
2013-10-21 17:29:51 +00:00
Joerg Sonnenberger e77b0424fd Fix python-free build.
llvm-svn: 193053
2013-10-20 17:36:05 +00:00
Joerg Sonnenberger c5e53bd14a Make sure switch covers all values.
llvm-svn: 193052
2013-10-20 17:35:46 +00:00
Jim Ingham be40554915 ValueObject and SBValue's GetChildMemberWithName should look through anonymous structs
and unions the same way that C would.

<rdar://problem/11987906>

llvm-svn: 193016
2013-10-18 23:53:55 +00:00
Ed Maste f7920c8798 Fix build failure on FreeBSD/clang by using auto iterator type
llvm-svn: 192999
2013-10-18 20:32:25 +00:00
Ed Maste 68f517938a Add stub FreeBSD ProcessMonitor::ReadThreadPointer
llvm-svn: 192994
2013-10-18 19:16:44 +00:00
Enrico Granata fcb37ae365 <rdar://problem/15182550>
Removing Host/Atomic.h
This header file was not being copied as part of our public API headers and this in turn was causing any plugin to link against LLDB.framework, since SharingPtr.h depends on it

Out of several possible options to fix this issue, the cleanest one is to revert LLDB to use std::atomic<>, as we are a C++11 project and should take advantage of it

The original rationale for going from std::atomic to Host/Atomic.h was that MSVC++ fails to link in CLR mode when std::atomic is used
This is a very Visual Studio/.net specific issue, which hopefully will be fixed
Until them, to allow Windows development to proceed, we are going with a targeted solution where we #ifdef include the Windows specific calls, and let everyone else use the
proper atomic support, as should be

If there is an unavoidable need for a LLDB-specific atomic header, the right way to go at it would be to make an API/lldb-atomic.h header and #ifdef the Windows dependency there

The FormatManager should not need to conditionalize use of std::atomic<>, as other parts of the LLDB internals are successfully using atomic (Address and IRExecutionUnit), so this
Win-specific hack is limited to SharingPtr

llvm-svn: 192993
2013-10-18 18:57:49 +00:00
Jim Ingham 8ec10efc5d Mark the selected frame of the selected thread in backtraces.
<rdar://problem/15252474>

llvm-svn: 192989
2013-10-18 17:38:31 +00:00
Jim Ingham b1499243f3 Make sure the CallFunction Thread plans don't try to do DoTakedown if their thread
has gone  away by the time they get around to doing it.

<rdar://problem/15245544>

llvm-svn: 192987
2013-10-18 17:11:02 +00:00
Hafiz Abid Qadeer 85a4daf4f6 Adjust PC after hitting breakpoint on remote target.
This commit adds an example python file that can be used with 'target-definition-file' setting for Linux gdbserver.
This file has an extra key 'breakpoint-pc-offset' that LLDB uses to determine how much to change the PC
after hitting the breakpoint.

llvm-svn: 192962
2013-10-18 10:04:33 +00:00
Jason Molenda 3dc4f44e71 Move the code which translates a dispatch_qaddr into a
queue name out of ProcessGDBRemote and in to the Platform
plugin, specifically PlatformDarwin.

Also add a Platform method to translate a dispatch_quaddr
to a QueueID, and a Thread::GetQueueID().

I'll add an SBThread::GetQueueID() next.

llvm-svn: 192949
2013-10-18 05:55:24 +00:00
Richard Mitton 665068b379 Removed unnecessary call to OpenFirstAvailableMaster.
::Fork already does this internally, so this was simply leaking file handles.

This fixes the problem where the test suite would occasionally run out of file handles.

llvm-svn: 192929
2013-10-17 22:36:28 +00:00
Enrico Granata 52b4b6cddc This is the last piece of work for "formats in categories": we now cache formats as well as summaries and synthetics
llvm-svn: 192928
2013-10-17 22:27:19 +00:00
Richard Mitton 0a55835755 Added support for reading thread-local storage variables, as defined using the __thread modifier.
To make this work this patch extends LLDB to:

- Explicitly track the link_map address for each module. This is effectively the module handle, not sure why it wasn't already being stored off anywhere. As an extension later, it would be nice if someone were to add support for printing this as part of the modules list.

- Allow reading the per-thread data pointer via ptrace. I have added support for Linux here. I'll be happy to add support for FreeBSD once this is reviewed. OS X does not appear to have __thread variables, so maybe we don't need it there. Windows support should eventually be workable along the same lines.

- Make DWARF expressions track which module they originated from.

- Add support for the DW_OP_GNU_push_tls_address DWARF opcode, as generated by gcc and recent versions of clang. Earlier versions of clang (such as 3.2, which is default on Ubuntu right now) do not generate TLS debug info correctly so can not be supported here.

- Understand the format of the pthread DTV block. This is where it gets tricky. We have three basic options here:

  1) Call "dlinfo" or "__tls_get_addr" on the inferior and ask it directly. However this won't work on core dumps, and generally speaking it's not a good idea for the debugger to call functions itself, as it has the potential to not work depending on the state of the target.

  2) Use libthread_db. This is what GDB does. However this option requires having a version of libthread_db on the host cross-compiled for each potential target. This places a large burden on the user, and would make it very hard to cross-debug from Windows to Linux, for example. Trying to build a library intended exclusively for one OS on a different one is not pleasant. GDB sidesteps the problem and asks the user to figure it out.

  3) Parse the DTV structure ourselves. On initial inspection this seems to be a bad option, as the DTV structure (the format used by the runtime to manage TLS data) is not in fact a kernel data structure, it is implemented entirely in useerland in libc. Therefore the layout of it's fields are version and OS dependent, and are not standardized.

  However, it turns out not to be such a problem. All OSes use basically the same algorithm (a per-module lookup table) as detailed in Ulrich Drepper's TLS ELF ABI document, so we can easily write code to decode it ourselves. The only question therefore is the exact field layouts required. Happily, the implementors of libpthread expose the structure of the DTV via metadata exported as symbols from the .so itself, designed exactly for this kind of thing. So this patch simply reads that metadata in, and re-implements libthread_db's algorithm itself. We thereby get cross-platform TLS lookup without either requiring third-party libraries, while still being independent of the version of libpthread being used.

Test case included.

llvm-svn: 192922
2013-10-17 21:14:00 +00:00
Ed Maste a0191d1101 Fix building with ENABLE_DEBUG_PRINTF
Clang tells me that "token pasting of ',' and __VA_ARGS__ is a GNU
extension".  Also catch up with changes in function args.

llvm-svn: 192920
2013-10-17 20:42:56 +00:00
Ed Maste 4c24b1264a Whitespace: replace 4-space-tabs with spaces
llvm-svn: 192918
2013-10-17 20:13:14 +00:00
Ed Maste 4a1c279795 Correct log message typo: ended ad -> ended at
llvm-svn: 192897
2013-10-17 14:03:07 +00:00
Ed Maste 737e92b036 Remove unused DWARFCompileUnit::Extract variant
llvm-svn: 192893
2013-10-17 13:23:03 +00:00
Greg Clayton 312bcbe8b4 <rdar://problem/14972424>
- Made the dynamic register context for the GDB remote plug-in inherit from the generic DynamicRegisterInfo to avoid code duplication
- Finished up the target definition python setting stuff.
- Added a new "slice" key/value pair that can specify that a register is part of another register:
    { 'name':'eax', 'set':0, 'bitsize':32, 'encoding':eEncodingUint, 'format':eFormatHex, 'slice': 'rax[31:0]' },
- Added a new "composite" key/value pair that can specify that a register is made up of two or more registers:
    { 'name':'d0', 'set':0, 'bitsize':64 , 'encoding':eEncodingIEEE754, 'format':eFormatFloat, 'composite': ['s1', 's0'] },
- Added a new "invalidate-regs" key/value pair for when a register is modified, it can invalidate other registers:
    { 'name':'cpsr', 'set':0, 'bitsize':32 , 'encoding':eEncodingUint, 'format':eFormatHex, 'invalidate-regs': ['r8', 'r9', 'r10', 'r11', 'r12', 'r13', 'r14', 'r15']},
    
This now completes the feature that allows a GDB remote target to completely describe itself.

llvm-svn: 192858
2013-10-17 01:10:23 +00:00
Greg Clayton 8afa543737 Fixed the MacOSX non "Debug" builds so that "lldb-platform" doesn't fail to link.
llvm-svn: 192857
2013-10-17 00:27:14 +00:00
Sylvestre Ledru 7a05000f18 Unbreak the gcc build (complain about duplicate definition of Initialize/Terminate (done in the cpp code)
llvm-svn: 192780
2013-10-16 09:12:15 +00:00
Enrico Granata ce451cc300 <rdar://problem/15235492>
Extend DummySyntheticProvider to actually use debug-info vended children as the source of information
Make Python synthetic children either be valid, or fallback to the dummy, like their C++ counterparts

This allows LLDB to actually stop bailing out upon encountering an invalid synthetic children provider front-end, and still displaying the non synthetized ivar info

llvm-svn: 192741
2013-10-15 22:42:14 +00:00
Enrico Granata 7dc67a16a4 string.h and clang headers are apparently no longer necessary for SBType to compile
llvm-svn: 192725
2013-10-15 18:14:34 +00:00
Enrico Granata 0e6004b5c9 Unbreak the build on OSX by defining Initialize() and Terminate() for the Windows platform plugin
llvm-svn: 192724
2013-10-15 18:11:29 +00:00
Deepak Panickal e3eadf0f3b Update makefiles to build PlatformWindows
llvm-svn: 192702
2013-10-15 13:52:20 +00:00
Deepak Panickal a0154f98db Patch to add PlatformWindows, based on Carlo Kok's version from the Windows branch.
llvm-svn: 192693
2013-10-15 12:32:12 +00:00
Greg Clayton ef8180a3f6 <rdar://problem/14972424>
When debugging with the GDB remote in LLDB, LLDB uses special packets to discover the
registers on the remote server. When those packets aren't supported, LLDB doesn't
know what the registers look like. This checkin implements a setting that can be used
to specify a python file that contains the registers definitions. The setting is:

(lldb) settings set plugin.process.gdb-remote.target-definition-file /path/to/module.py

Inside module there should be a function:

def get_dynamic_setting(target, setting_name):

This dynamic setting function is handed the "target" which is a SBTarget, and the 
"setting_name", which is the name of the dynamic setting to retrieve. For the GDB
remote target definition the setting name is 'gdb-server-target-definition'. The
return value is a dictionary that follows the same format as the OperatingSystem
plugins follow. I have checked in an example file that implements the x86_64 GDB
register set for people to see:

    examples/python/x86_64_target_definition.py
    
This allows LLDB to debug to any archticture that is support and allows users to
define the registers contexts when the discovery packets (qRegisterInfo, qHostInfo)
are not supported by the remote GDB server.

A few benefits of doing this in Python:
1 - The dynamic register context was already supported in the OperatingSystem plug-in
2 - Register contexts can use all of the LLDB enumerations and definitions for things
    like lldb::Format, lldb::Encoding, generic register numbers, invalid registers 
    numbers, etc.
3 - The code that generates the register context can use the program to calculate the
    register context contents (like offsets, register numbers, and more)
4 - True dynamic detection could be used where variables and types could be read from 
    the target program itself in order to determine which registers are available since
    the target is passed into the python function.
    
This is designed to be used instead of XML since it is more dynamic and code flow and
functions can be used to make the dictionary.

llvm-svn: 192646
2013-10-15 00:14:28 +00:00
Enrico Granata c0f8ca0e74 Add the capability for LLDB to query an arbitrary Python module (passed in as a file path) for target-specific settings
This is implemented by means of a get_dynamic_setting(target, setting_name) function vended by the Python module, which can respond to arbitrary string names with dynamically constructed
settings objects (most likely, some of those that PythonDataObjects supports) for LLDB to parse

This needs to be hooked up to the debugger via some setting to allow users to specify which module will vend the information they want to supply

llvm-svn: 192628
2013-10-14 21:39:38 +00:00
Sylvestre Ledru 6e2c7cbb26 Revert my commit 191617. It added a clang warning (Thanks to Ed Maste). Add a comment
llvm-svn: 192595
2013-10-14 14:06:28 +00:00
Andy Gibbs 7f14630f4a Suppress "using extended field designator is an extension" warning in use of offsetof.
llvm-svn: 192578
2013-10-14 10:00:11 +00:00
Carlo Kok 7438912fb8 Set the architecture from the remote executable when it's not set so the register info can be loaded properly (and thus the callstacks work)
llvm-svn: 192571
2013-10-14 07:09:13 +00:00
Jim Ingham 05d7084ce9 Report the summed hit count in the breakpoint line.
<rdar://problem/15183226>

llvm-svn: 192518
2013-10-12 00:40:02 +00:00
Enrico Granata 98f134835f <rdar://problem/15192088>
gdb-format a (as in p/a) would fail as it needed to set a byte size (unsurprisingly enough)
This should be acknowledged by the condition check and not cause a failure

llvm-svn: 192511
2013-10-11 22:09:26 +00:00
Greg Clayton 93e2861b81 <rdar://problem/15191078>
Fixed Module::ResolveSymbolContextForAddress() to be able to also look in the SymbolVendor's SymbolFile's ObjectFile for a more meaningful symbol when a symbol lookup finds a synthetic symbol from the main object file. This will help lookups on MacOSX as the main executable might be stripped, but the dSYM file always has a full symbol table.

llvm-svn: 192510
2013-10-11 22:03:48 +00:00
Greg Clayton eb023e75dc <rdar://problem/13635174>
Added a way to set hardware breakpoints from the "breakpoint set" command with the new "--hardware" option. Hardware breakpoints are not a request, they currently are a requirement. So when breakpoints are specified as hardware breakpoints, they might fail to be set when they are able to be resolved and should be used sparingly. This is currently hooked up for GDB remote debugging. 

Linux and FreeBSD should quickly enable this feature if possible, or return an error for any breakpoints that are hardware breakpoint sites in the "virtual Error Process::EnableBreakpointSite (BreakpointSite *bp_site);" function.

llvm-svn: 192491
2013-10-11 19:48:25 +00:00
Sean Callanan 8c46baca65 Implemented TruncInst in the IRInterpreter.
<rdar://problem/15188389>

llvm-svn: 192489
2013-10-11 19:45:00 +00:00
Richard Mitton 00dec20f7d This reverts r192484, which I really shouldn't have checked in. Apologies.
llvm-svn: 192488
2013-10-11 19:44:23 +00:00
Ed Maste 52b6e8dac0 Use existing llvm::RoundUpToAlignment in ELF note parsing
llvm-svn: 192486
2013-10-11 19:39:42 +00:00
Richard Mitton b5637b62f2 Fixed bad return code, which would cause invalid expressions to silently fail.
llvm-svn: 192484
2013-10-11 19:16:28 +00:00
Ed Maste 5480365b25 Simplify indirect rld_map for mips (rework r192408).
Just pass a Target* into ObjectFileELF::GetImageInfoAddress so that
it can do the extra dereference necessary on MIPS, instead of passing
a flag back to the caller.

Review: http://llvm-reviews.chandlerc.com/D1899
llvm-svn: 192469
2013-10-11 17:39:07 +00:00
Ed Maste 27738bec75 Eliminate integer sign comparison warning
llvm-svn: 192462
2013-10-11 16:30:20 +00:00
Ed Maste 04a8bab047 Support mips shared object debug info
MIPS's .dyanamic section is read-only.  Instead of using DT_DEBUG for
the pointer to dyld information it uses a separate tag DT_MIPS_RLD_MAP
which points to storage in the read-write .rld_map section, which in
turn points to the dyld information.

Review: http://llvm-reviews.chandlerc.com/D1890
llvm-svn: 192408
2013-10-11 01:16:08 +00:00
Ed Maste d616c97a81 Update comment (MIPS also has 32-bit opcodes)
llvm-svn: 192388
2013-10-10 19:17:07 +00:00
Ed Maste 1b475f1691 Initial FreeBSD mips64 ProcessMonitor support
Committing early to ease tracking other ongoing POSIX changes.

Review: http://llvm-reviews.chandlerc.com/D1886
llvm-svn: 192387
2013-10-10 19:14:55 +00:00
Greg Clayton 896005804d <rdar://problem/14146606>
Fixed an issue where environment variables that contained special characters '$' and '#' would hose up the GDB server packet. We now use the QEnvironmentHexEncoded packet that has existed for a long time when we need to. Also added code that will stop sending the QEnvironmentHexEncoded and QEnvironment packets if they aren't supported.

llvm-svn: 192373
2013-10-10 17:53:50 +00:00
Ed Maste bb59e049ba POSIX dyld: handle extra MIPS link map field
On at least FreeBSD and NetBSD there is an extra field in the dyld link
map struct.  I've left an assert for other OSes (i.e., Linux/mips) until
it's determined if they do the same.

llvm-svn: 192358
2013-10-10 16:09:31 +00:00
Ed Maste d8cc39e653 POSIX RegisterContext for mips64
Based on the POSIX x86_64 register context.  This is sufficient for opening
a mips64 (big endian) core file.  Subsequent changes will connect the
disassembler, dynamic loader support, ABI, etc.

Review: http://llvm-reviews.chandlerc.com/D1873

(Missed "svn add" on this file in r192335)

llvm-svn: 192336
2013-10-10 01:04:21 +00:00
Ed Maste b73f844be3 POSIX RegisterContext for mips64
Based on the POSIX x86_64 register context.  This is sufficient for opening
a mips64 (big endian) core file.  Subsequent changes will connect the
disassembler, dynamic loader support, ABI, etc.

Review: http://llvm-reviews.chandlerc.com/D1873
llvm-svn: 192335
2013-10-10 00:59:47 +00:00
Sean Callanan 394e36dc81 Fixed a leak of ASTStructExtractors and also
made sure we don't keep around no-longer-valid
ASTTransformers.

<rdar://problem/15182379>

llvm-svn: 192333
2013-10-10 00:39:23 +00:00
Michael Sartain 762df1f139 Merge RegisterContextPOSIX_x86_64 and RegisterContextPOSIX_i386 into RegisterContextPOSIX_x86
llvm-svn: 192332
2013-10-10 00:16:10 +00:00
Sean Callanan 931a0def9e Implemented the reverse-lookup API in the AST
importer to avoid duplicate imports of anonymous
structs.

<rdar://problem/14421722>

llvm-svn: 192327
2013-10-09 22:33:34 +00:00
Ed Maste b0e33d4165 Fix endianness in ObjectFile::CopyData
ObjectFile::CopyData is used to copy a block of target memory to the
caller's buffer (e.g. for "memory read").  This should be a straight
memcpy, and not byte-swapped if the target and host have different
endianness.

Add a new DataExtractor::CopyData() method that performs this straight
copy and use it in ObjectFile::CopyData().

llvm-svn: 192323
2013-10-09 20:34:25 +00:00
Ed Maste 9715936d9e Add logging for POSIX DYLD failures
llvm-svn: 192322
2013-10-09 19:57:11 +00:00
Matt Kopec 718be877f8 Add exec support for Linux including common support for POSIX.
llvm-svn: 192319
2013-10-09 19:39:55 +00:00
Matt Kopec dc7c73c604 Add error checking to 'cmd' buffer as it may not be available (ie. in the case of exec).
llvm-svn: 192318
2013-10-09 19:23:34 +00:00
Ed Maste 63de98b0a0 Add missing space between words in comment
llvm-svn: 192307
2013-10-09 18:03:24 +00:00
Michael Sartain 15c07b90c0 Re-enable test_convenience_registers_16bit_with_process_attach test for Linux.
Remove 32-bit POSIX register hack in ConvertBetweenRegisterKinds.

llvm-svn: 192306
2013-10-09 17:44:52 +00:00
Daniel Malea 9e9919f043 Allow Process::WaitForProcessToStop to return immediately if process is already in the stopped state
- By default, the above function will wait for at least one event
- Set wait_always=false to make the function return immediately if the process is already stopped

llvm-svn: 192301
2013-10-09 16:56:28 +00:00
Ed Maste 76a3c33d41 Fix filenames in header comment blocks
llvm-svn: 192296
2013-10-09 14:18:45 +00:00
Jason Molenda a3a542ff21 Handle the case where completing variables in a frame
with no source-level debug information correctly.
<rdar://problem/15182936> 

llvm-svn: 192268
2013-10-09 02:39:26 +00:00
Sean Callanan c707f32fbe Fixed a bug where variables' byte sizes would not
respect their Clang types if the variables' values
were represented by DWARF constu values.

<rdar://problem/14636499>

llvm-svn: 192267
2013-10-09 02:32:37 +00:00
Sean Callanan 3e68903e58 Fixed a bug in the Materializer where we sent the
wrong information to ValueObjectConstResult.

<rdar://problem/15101795>

llvm-svn: 192264
2013-10-09 02:04:57 +00:00
Michael Sartain 704bf8912e Clean up RegisterContextPOSIX i386 code.
Use 32-bit register enums without gaps on 64-bit hosts.
Don't show 64-bit registers when debugging 32-bit targets.
Add psuedo gpr registers (ax, ah, al, etc.)
Add mmx registers.
Fix TestRegisters.py to not read ymm15 register on 32-bit targets.
Fill out and move gcc/dwarf/gdb register enums to RegisterContext_x86.h

llvm-svn: 192263
2013-10-09 01:28:57 +00:00
Enrico Granata b1c6c489ca <rdar://problem/14923930>
Constant ValueObjects should clear their description as well as their summary. Rationale being that both can depend on deeper-than-constified data
so both are subject to changes in "unpredictable" ways
To see this consider repeatedly po'ing a persistent variable of a type whose -description result changes at each invocation

llvm-svn: 192259
2013-10-09 00:33:55 +00:00
Enrico Granata 99c8f7ae79 <rdar://problem/15180638>
Making GetNumberOfDirectBaseClasses() work for ObjC pointers, and for classes for which we don't have full debug info

llvm-svn: 192255
2013-10-09 00:13:17 +00:00
Enrico Granata 347c2aa3e3 <rdar://problem/14028923>
Implement SBTarget::CreateValueFromAddress() with a behavior equivalent to SBValue::CreateValueFromAddress()
(but without the need to grab an SBValue first just as a starting point to make up another SBValue out of whole cloth)

llvm-svn: 192239
2013-10-08 21:49:02 +00:00
Enrico Granata 4cc21772f3 <rdar://problem/12632394>
Add a format for FourCharCode

This is now safe to do thanks to the "formats in categories" feature

llvm-svn: 192233
2013-10-08 20:59:02 +00:00
Enrico Granata 852cc954db <rdar://problem/11778815>
Formats (as in "type format") are now included in categories
The only bit missing is caching formats along with synthetic children and summaries, which might be now desirable

llvm-svn: 192217
2013-10-08 19:03:22 +00:00
Jason Molenda 64a11733c9 Add entries for arm6m to ArchSpec's g_macho_arch_entries.
<rdar://problem/15099306>

llvm-svn: 192161
2013-10-08 03:01:08 +00:00
Richard Smith 8e45293b6d Fix build break: clang no longer supports -ast-dump-xml.
llvm-svn: 192155
2013-10-08 02:19:45 +00:00
Enrico Granata 41b1653350 --raw was not always doing the right thing w.r.t. one-lining children. This checkin fixes that
llvm-svn: 192116
2013-10-07 17:59:03 +00:00
Sylvestre Ledru fd654c406e Value stored to 'pid' was never read. Found by scan-build http://buildd-clang.debian.net/scan-build/
llvm-svn: 192060
2013-10-06 09:51:02 +00:00
Enrico Granata 938d1d67e8 Cleaner way to work around the lack of delegating constructors on some versions of GCC
llvm-svn: 192013
2013-10-05 00:20:27 +00:00
Enrico Granata 1c127dfbbe <rdar://problem/15154623>
Several CF* data formatters were in the AppKit category
This puts them back where they belong, i.e. in category CoreFoundation

llvm-svn: 192008
2013-10-05 00:03:07 +00:00
Enrico Granata a29cb0bada <rdar://problem/12042982>
This radar extends the notion of one-liner summaries to automagically apply in a few interesting cases

More specifically, this checkin changes the printout of ValueObjects to print on one-line (as if type summary add -c had been applied) iff:
this ValueObject does not have a summary
its children have no synthetic children
its children are not a non-empty base class without a summary
its children do not have a summary that asks for children to show up
the aggregate length of all the names of all the children is <= 50 characters
you did not ask to see the types during a printout
your pointer depth is 0

This is meant to simplify the way LLDB shows data on screen for small structs and similarly compact data types (e.g. std::pair<int,int> anyone?)

Feedback is especially welcome on how the feature feels and corner cases where we should apply this printout and don't (or viceversa, we are applying it when we shouldn't be)

llvm-svn: 191996
2013-10-04 23:14:13 +00:00
Sean Callanan 9076c0fffb Made all other "operator bool"s explicit and ensured
that all clients use them explicitly.  This will hopefully
prevent any future confusion where things get cast to types
we don't expect.

<rdar://problem/15146458>

llvm-svn: 191984
2013-10-04 21:35:29 +00:00
Michael Sartain ec2c9b8eba Remove unused local variable.
llvm-svn: 191974
2013-10-04 19:17:40 +00:00
Ed Maste d45f88b4d0 Correct typo: Intructions -> Instructions
llvm-svn: 191972
2013-10-04 19:01:18 +00:00
Ed Maste db3c60e388 Remove EOL whitespace and redundant break statement
llvm-svn: 191960
2013-10-04 15:29:20 +00:00
Sean Callanan ddd7a2a65b Changed the bool conversion operator on ConstString
to be explicit, to prevent horrid things like

std::string a = ConstString("foo")

from taking the path ConstString -> bool -> char
-> std::string.

This fixes, among other things, ClangFunction.

<rdar://problem/15137989>

llvm-svn: 191934
2013-10-03 22:27:29 +00:00
Enrico Granata 245b3caa57 A more thorough fix for the newlines issue
llvm-svn: 191919
2013-10-03 18:11:24 +00:00
Jason Molenda 82f5930db4 Change two new logging messages from verbose-only to non-verbose
in the unwinder - they're important to flag when debugging an
unwind problem.

llvm-svn: 191882
2013-10-03 07:58:37 +00:00
Enrico Granata 39938938cf <rdar://problem/15118409>
Fix an issue with the new ValueObjectPrinter where in some cases spurious \n would be printed

llvm-svn: 191869
2013-10-03 02:06:02 +00:00
Jason Molenda 5bbc354edf Tweak logging messages from Ed's prev commit to make it a little more
clear what is happening in this case.

llvm-svn: 191860
2013-10-02 22:11:59 +00:00
Ed Maste 4ae2299b18 Avoid crash in unwinder if ABI isn't available
llvm-svn: 191837
2013-10-02 15:52:33 +00:00
Ed Maste 34f4be1ce6 Fix endianness issue with POSIX dyld plugin
To support cross-endian and big-endian debugging avoid copying target
memory directly into host variables.

llvm-svn: 191826
2013-10-02 14:14:05 +00:00
Filip Pizlo bfcff68516 Fix build after LLVM memory management API changes.
llvm-svn: 191806
2013-10-02 01:43:46 +00:00
Daniel Malea 73435afda7 Fix build with GCC 4.6.2 (non-c++11 compilant compiler)
- delegating c'tors not supported

llvm-svn: 191709
2013-09-30 23:12:05 +00:00
Daniel Malea dfc637b9de Fix CMake build by including ValueObjectPrinter.cpp in list of sources
llvm-svn: 191703
2013-09-30 21:30:44 +00:00
Enrico Granata 4d93b8cdf3 <rdar://problem/14393032>
DumpValueObject() 2.0

This checkin restores pre-Xcode5 functionality to the "po" (expr -O) command:
- expr now has a new --description-verbosity (-v) argument, which takes either compact or full as a value (-v is the same as -vfull)
 When the full mode is on, "po" will show the extended output with type name, persistent variable name and value, as in
(lldb) expr -O -v -- foo
(id) $0 = 0x000000010010baf0 {
    1 = 2;
    2 = 3;
}

 When -v is omitted, or -vcompact is passed, the Xcode5-style output will be shown, as in
(lldb) expr -O -- foo
{
    1 = 2;
    2 = 3;
}

- for a non-ObjectiveC object, LLDB will still try to retrieve a summary and/or value to display
(lldb) po 5
5
-v also works in this mode
(lldb) expr -O -vfull -- 5
(int) $4 = 5 

On top of that, this is a major refactoring of the ValueObject printing code. The functionality is now factored into a ValueObjectPrinter class for easier maintenance in the future
DumpValueObject() was turned into an instance method ValueObject::Dump() which simply calls through to the printer code, Dump_Impl has been removed

Test case to follow

llvm-svn: 191694
2013-09-30 19:11:51 +00:00
Sylvestre Ledru 789cefb83c Display the errno error message instead of the id
llvm-svn: 191621
2013-09-28 16:01:26 +00:00
Sylvestre Ledru faa63ce2a2 * Improve the wording (thanks to Ed Maste for the suggestion)
* Add a TODO item

llvm-svn: 191620
2013-09-28 15:57:37 +00:00
Sylvestre Ledru 6c9530b808 Fix a memory leak. Found by both scan-build and coverity. Close CID 1096442
llvm-svn: 191619
2013-09-28 15:50:23 +00:00
Sylvestre Ledru 77c87c0510 If setgid fails for any reason, exit lldb.
scan-build was complaining about:
The return value from the call to 'setgid' is not checked. If an error occurs in 'setgid', the following code may execute with unexpected privileges

llvm-svn: 191618
2013-09-28 15:47:38 +00:00
Sylvestre Ledru 30eff98e7e Remove useless declaration. If match_type == eNameMatchIgnore, we already left this function at the beginning of the method. Found by coverity. Fixes CID 1094188
llvm-svn: 191617
2013-09-28 15:35:02 +00:00
Sylvestre Ledru d28b99374f * mktemp is insecure as it always creates or uses insecure temporary file.
Switch to mkstemp.

* Get and display the error message when an error occurs while creating the temporary file

llvm-svn: 191616
2013-09-28 15:23:41 +00:00
Sylvestre Ledru b027bd212b Remove trailing spaces
llvm-svn: 191613
2013-09-28 14:35:00 +00:00
Jason Molenda c7cda27f79 Mark armv6m as "compatible" with armv7 - that's the
closest ISA.  armv6 wouldn't have the handful of
T32 instructions that the Cortex-M0 ISA specifies.
<rdar://problem/15099306> 

llvm-svn: 191588
2013-09-27 23:29:10 +00:00
Jason Molenda a3a0452831 Add definitions for "armv6m", which indicates a Cortex-M0 processor.
It uses the T16 and a few T32 instructions from the ARMv7-A ISA.
<rdar://problem/15099306> 

llvm-svn: 191587
2013-09-27 23:21:54 +00:00
Daniel Malea db52f34d7d Fix OS Version reporting bug detected by TestPlatform for some Linux 3.x kernels that do not report the update version
- should resolve the current failure on the Linux clang buildbot

llvm-svn: 191568
2013-09-27 21:34:03 +00:00
Jim Ingham fb6fc0dd90 Convert ClangASTType::GetTypeName over to return a ConstString to be consistent with
the other "Get*TypeName" functions.

llvm-svn: 191556
2013-09-27 20:59:37 +00:00
Jim Ingham 6dafc4203d If you erase while iterating, remember to update the iterator. Bug found by Carlo Kok.
llvm-svn: 191555
2013-09-27 20:58:17 +00:00
Jim Ingham f642373cd5 Factor the code that was eliminating redundant breakpoint locations and moving
line breakpoints past the prologue of functions so it can be shared between the
file & line breakpoint resolver, and the source pattern breakpoint resolver,
and then share it.

llvm-svn: 191478
2013-09-27 01:16:58 +00:00
Jim Ingham 2b89a53181 DWARF says line number 0 is a valid line number - used to indicate a source line that should
not have breakpoints set on it inserted into code that does have a valid line number.  So allow
that line number, and the ThreadPlanStepRange should just continue stepping over 0 line ranges
as if they had the same line number as whatever we were previously stepping through.

llvm-svn: 191477
2013-09-27 01:15:46 +00:00
Jim Ingham e4483cf959 Remove unnecessary checks for thread_plan_sp (we check for this at the top of the function.)
llvm-svn: 191476
2013-09-27 01:13:01 +00:00
Carlo Kok bb5c5f8289 missed one Close () call in 191446 overload fix for Posix only code.
llvm-svn: 191455
2013-09-26 20:22:28 +00:00
Ben Langmuir edb3b21792 Fix the command name in the syntax text for _regexp-list
llvm-svn: 191454
2013-09-26 20:00:01 +00:00
Ben Langmuir bcf81ea4bf Fix a couple of typos in the help text for disassemble
llvm-svn: 191452
2013-09-26 19:53:03 +00:00
Carlo Kok b1a63bdf55 On Windows MapViewOfFile requires the offset to be aligned on the system dwAllocationGranularity
llvm-svn: 191447
2013-09-26 18:52:08 +00:00
Carlo Kok a46964f1bb On windows a socket and file descriptor aren't the same kind of handle, pass the type to Close so it uses the right api to close it.
llvm-svn: 191446
2013-09-26 18:49:53 +00:00
Ashok Thirumurthi 8b5773053b Fix the partial backtrace in a recursive inferior compiled with -fomit-frame-pointer.
- Removes the block in UnwindLLDB::AddOneMoreFrame that tests for a bad stack setup,
since it is neither correct (tests the FP GPR), complete (doesn't consider multi-frame
cycles), nor reachable (the construction of RegisterContextLLDB will fail in the case 
where either of the two (why just two?) previous frames have the same canonical frame
address as the frame that we propose adding to the stack).

llvm-svn: 191430
2013-09-26 14:35:59 +00:00
Joerg Sonnenberger ca965885e5 si_errno and friends are macros on NetBSD, so #undef them first.
llvm-svn: 191388
2013-09-25 17:56:48 +00:00
Joerg Sonnenberger 34ea0f8a34 NetBSD also has a size field in socket addresses.
llvm-svn: 191387
2013-09-25 17:56:00 +00:00
Joerg Sonnenberger 1e0621cea2 arpa/inet.h is the canonical source of htons and friends.
At least on NetBSD, none of the already included headers pulls it in.

llvm-svn: 191386
2013-09-25 17:53:34 +00:00
Joerg Sonnenberger c75987637b Handle ePathTypePythonDir even in the case of LLDB_DISABLE_PYTHON,
otherwise -Werror builds may fail.

llvm-svn: 191385
2013-09-25 17:52:18 +00:00
Joerg Sonnenberger 340a17595e Convert to UNIX line endings.
llvm-svn: 191367
2013-09-25 10:37:32 +00:00
Enrico Granata 5d5f60c391 Target::m_suppress_synthetic_value was a hack required to disable synthetic values while passing an SBValue to a synthetic child provider, or incur an endless recursion
Now that SBValues can be setup to ignore synthetic values, this is no longer necessary, and so m_suppress_synthetic_value can go away

Another Hack Bites the Dust

llvm-svn: 191338
2013-09-24 22:58:37 +00:00
Ashok Thirumurthi 35729bb1f8 Adds an option to resolve a symbol from an address that can be used
to build out the symbol table as addresses are used, and implements
the mechanism for ELF to add stripped symbols from eh_frame.

Uses this mechanism to allow disassembly for addresses corresponding
to stripped symbols for ELF, and provide hooks to implement this for
PE COFF.

Also removes eSymbolContextTailCall in favor of an option for
ResolveSymbolContextForAddress for consistency with the documentation
for eSymbolContextEverything.  Essentially, this is just an option for
interpreting the so_addr.
                  

llvm-svn: 191307
2013-09-24 15:34:13 +00:00
Jason Molenda 378a462c1a Fix a bug where the x86 assembly instruction profiler would not correctly adjust
the CFA instructions when it was profiling an -fomit-frame-pointer function
and a "volatile" register was saved on the stack (e.g. an argument register).
<rdar://problem/15036546>

llvm-svn: 191267
2013-09-24 03:28:54 +00:00
Jason Molenda 2cd21b87cd Update RegisterContextLLDB::GetFullUnwindPlanForFrame() to use the architectural-
default-at-first-instruction UnwindPlan if we're at the beginning of a function and
the ABI can provide us with an UnwindPlan to get out of there before falling back
to the generic architectural default UnwindPlan (which usually assumes that the stack
has already been set up.)

Update the FuncUnwinders methods to gracefully handle the case where an assembly
profiler may not be available.

Fix a bug where FuncUnwinders::GetUnwindPlanArchitectureDefaultAtFunctionEntry was
returning the wrong UnwindPlan to its caller.

llvm-svn: 191262
2013-09-24 02:42:54 +00:00
Han Ming Ong d60982a01b <rdar://problem/14701270>
When logged in as root, just launch debugserver regularly.

llvm-svn: 191230
2013-09-23 22:09:17 +00:00
Virgile Bello 6957195ae5 Various small changes for build of LLDB on Visual Studio 2013 RC (MSVC12)
llvm-svn: 191116
2013-09-20 22:35:22 +00:00
Virgile Bello 1fd7ec75fc Add backslash as path separator for Win32.
llvm-svn: 191115
2013-09-20 22:31:10 +00:00
Matt Kopec 2f98353099 Change posix thread so that it creates a breakpoint stop reason if the breakpoint isn't valid for the current thread but specify should stop to false. Also remove selecting a thread on a breakpoint hit.
llvm-svn: 191110
2013-09-20 21:28:39 +00:00