Commit Graph

1854 Commits

Author SHA1 Message Date
Jason Molenda 6b3e6d5487 Disassembler::DisassembleRange() currently calls Target::ReadMemory
with prefer_file_cache == false.  This is what we want to do when
the user is doing a disassemble command -- show the actual memory
contents in case the memory has been corrupted or something -- but
when we're profiling functions for stepping or unwinding
(ThreadPlanStepRange::GetInstructionsForAddress,
UnwindAssemblyInstEmulation::GetNonCallSiteUnwindP) we can read
__TEXT instructions directly out of the file, if it exists.
<rdar://problem/14397491> 

llvm-svn: 190638
2013-09-12 23:23:35 +00:00
Richard Mitton f86248d9ba Added a 'jump' command, similar to GDBs.
This allows the PC to be directly changed to a different line.
It's similar to the example python script in examples/python/jump.py, except implemented as a builtin.

Also this version will track the current function correctly even if the target line resolves to multiple addresses. (e.g. debugging a templated function)

llvm-svn: 190572
2013-09-12 02:20:34 +00:00
Enrico Granata e2e220a805 <rdar://problem/14071463>
SVN r189964 provided a sample Python script to inspect unordered(multi){set|map} with synthetic children, contribued by Jared Grubb
This checkin converts that sample script to a C++ provider built into LLDB
A test case is also provided

llvm-svn: 190564
2013-09-12 00:48:47 +00:00
Jim Ingham d39907935c Turns out the number of times you need to resume the process for /bin/sh depends on the
setting of the environment variable COMMAND_MODE.  Changed the Platform::GetResumeCountForShell
to Platform::GetResumeCountForLaunchInfo, and check both the shell and in the case of
/bin/sh the environment as well.

llvm-svn: 190538
2013-09-11 18:23:22 +00:00
Jim Ingham df0ae22f92 Changing the default shell to /bin/sh brought up a long-standing bug on OS X,
that /bin/sh re-exec's itself to /bin/bash, so it needs one more resume when you
are using it as the shell than /bin/bash did or you will stop at the start of your
program, rather than running it.

So I added a Platform API to get the number of resumes needed when launching with
a particular shell, and set the right values for Mac OS X.

<rdar://problem/14935282>

llvm-svn: 190381
2013-09-10 02:09:47 +00:00
Virgile Bello d87fc157d2 Added some MSVC required functions in Windows.cpp. Moved MSVC specific getopt code inside its own folder.
llvm-svn: 190238
2013-09-07 05:05:49 +00:00
Jim Ingham de34488f87 Include file cleanup. SymbolContext doesn’t need ClangASTType.h, Block.h did, and was getting it under the table from SymbolContext.h.
llvm-svn: 190083
2013-09-05 18:55:21 +00:00
Virgile Bello 228444b7bf Added MSVC config file and makefile support.
llvm-svn: 190068
2013-09-05 16:56:12 +00:00
Virgile Bello ee9da22b02 MinGW: avoid many warnings due to FAR/NEAR defines.
llvm-svn: 190065
2013-09-05 16:51:17 +00:00
Virgile Bello e2607b50ea Add OptionParser.h
llvm-svn: 190063
2013-09-05 16:42:23 +00:00
Virgile Bello f792acb20f Use <atomic> instead of "llvm/Support/Atomic.h". Removed unused RefCounter class.
llvm-svn: 190062
2013-09-05 16:38:02 +00:00
Sylvestre Ledru c86dfdd01e GNU HURD can be considered (for now?) like a GNU/Linux
llvm-svn: 190056
2013-09-05 15:37:36 +00:00
Jim Ingham 018c8278c2 Remove an unused ivar.
llvm-svn: 190026
2013-09-05 01:51:57 +00:00
Virgile Bello 0a3b151fdf Remove <windows.h> from lldb-types.h.
llvm-svn: 189934
2013-09-04 13:56:11 +00:00
Ed Maste b8ca4a2c1a Switch '/bin/bash' to '/bin/sh'
/bin/sh is more portable, and all systems with /bin/bash are expected to
have /bin/sh as well, even if only a link to bash.

Review: http://llvm-reviews.chandlerc.com/D1576
llvm-svn: 189879
2013-09-03 23:04:53 +00:00
Hafiz Abid Qadeer 4fe4a999a4 Fix a few typos in the comments.
llvm-svn: 189803
2013-09-03 13:28:01 +00:00
Jason Molenda 744608596a Make the default shell /bin/sh on all platforms. I think any system with /bin/bash
will at least have it linked to /bin/sh for shell script compatibility.

llvm-svn: 189703
2013-08-30 23:02:56 +00:00
Ed Maste 9b05d80632 Use /bin/sh on FreeBSD
llvm-svn: 189684
2013-08-30 17:53:18 +00:00
Virgile Bello bdae3787ef Cleanup/rearrange includes:
- factorize unistd.h and stdbool.h in lldb-types.h.
- Add <functional> and <string> where required.

llvm-svn: 189477
2013-08-28 12:14:27 +00:00
Virgile Bello ae12a3640d Fix MinGW build after lldb-platform-work merge:
- mode_t is defined in <sys/types.h>
- reorganized S_* user rights into win32.h
- Use Host::Kill instead of kill
- Currently #ifdef functions using pread/pwrite.

llvm-svn: 189364
2013-08-27 16:21:49 +00:00
Ashok Thirumurthi 03520b7fc7 Fixed a few typos.
llvm-svn: 189355
2013-08-27 14:56:58 +00:00
Charles Davis 510938e528 Fix some names in the wake of my Mach-O changes to LLVM.
llvm-svn: 189317
2013-08-27 05:04:57 +00:00
Charles Davis 237ad9741a Plugins/ObjectFile/PECOFF: Use enums from LLVM, and don't use Mach-O definitions.
Since I renamed most of the LLVM Mach-O enums in r189314, I had to go fix
LLDB to use the new names. While I was here, I decided that a COFF
plugin really shouldn't be using Mach-O enums.

llvm-svn: 189316
2013-08-27 05:04:33 +00:00
Daniel Malea e0f8f574c7 merge lldb-platform-work branch (and assorted fixes) into trunk
Summary:
    This merge brings in the improved 'platform' command that knows how to
    interface with remote machines; that is, query OS/kernel information, push
    and pull files, run shell commands, etc... and implementation for the new
    communication packets that back that interface, at least on Darwin based
    operating systems via the POSIXPlatform class. Linux support is coming soon.

    Verified the test suite runs cleanly on Linux (x86_64), build OK on Mac OS
    X Mountain Lion.

    Additional improvements (not in the source SVN branch 'lldb-platform-work'):
    - cmake build scripts for lldb-platform
    - cleanup test suite
    - documentation stub for qPlatform_RunCommand
    - use log class instead of printf() directly
    - reverted work-in-progress-looking changes from test/types/TestAbstract.py that work towards running the test suite remotely.
    - add new logging category 'platform'

    Reviewers: Matt Kopec, Greg Clayton

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

llvm-svn: 189295
2013-08-26 23:57:52 +00:00
Virgile Bello b2f1fb2943 MingW compilation (windows). Includes various refactoring to improve portability.
llvm-svn: 189107
2013-08-23 12:44:05 +00:00
Jason Molenda 20eb31b907 Add a new Section::SetFileAddress method to change a Section's file
address.

When loading a dSYM, and the file addresses of the dSYM Sections are
different than the executable binary Sections' file addresses, the
debug info won't be remapped to the actual load addresses correctly.
This only happens with binaries on the in-memory shared cache binaries
where their File addresses have been set to their actual load address
(outside an offset value) whereas the original executable and dSYM
have 0-based File addresses.

I think this patch will not be activated for other cases -- this is
the only case we know of where the dSYM and the executable's File
addresses differ -- but if this causes other problems we can restrict
it more carefully.

<rdar://problem/12335086> 

llvm-svn: 188532
2013-08-16 03:20:42 +00:00
Greg Clayton fd814c5a64 <rdar://problem/14717184>
LLDB needs in memory module load level settings to control how much information is read from memory when loading in memory modules. This change adds a new setting:

(lldb) settings set target.memory-module-load-level [minimal|partial|complete]

minimal will load only sections (no symbols, or function bounds via function starts or EH frame)
partial will load sections + bounds
complete will load sections + bounds + symbols

llvm-svn: 188246
2013-08-13 01:42:25 +00:00
Daniel Malea d79ae05080 New settings: target.use-hex-immediates and target.hex-immediates-style
- Immediates can be shown as hex (either Intel or MASM style)
- See TestSettings.py for usage examples
- Verified to cause no regressions on Linux x86_64 (Ubuntu 12.10)

Patch by Richard Mitton!

llvm-svn: 187921
2013-08-07 21:54:09 +00:00
Greg Clayton 6e10f149c4 <rdar://problem/14526890>
Fixed a crasher when using memory threads where a thread is sticking around too long and was causing problems when it didn't have a thread plan. 

llvm-svn: 187395
2013-07-30 00:23:06 +00:00
Ed Maste 64fad60e34 Use flag instead of rwlock state to track process running state
LLDB requires that the inferior process be stopped before, and remain
stopped during, certain accesses to process state.

Previously this was achieved with a POSIX rwlock which had a write lock
taken for the duration that the process was running, and released when
the process was stopped.  Any access to process state was performed with
a read lock held.

However, POSIX requires that pthread_rwlock_unlock() be called from the
same thread as pthread_rwlock_wrlock(), and lldb needs to stop and start
the process from different threads.  Violating this constraint is
technically undefined behaviour, although as it happens Linux and Darwin
result in the unlock proceeding in this case.  FreeBSD follows POSIX
more strictly, and the unlock would fail, resulting in a hang later upon
the next attempt to take the lock.

All read lock consumers use ReadTryLock() and handle failure to obtain
the lock (typically by logging an error "process is running").  Thus,
instead of using the lock state itself to track the running state, this
change adds an explicit m_running flag.  ReadTryLock tests the flag, and
if the process is not running it returns with the read lock held.

WriteLock and WriteTryLock are renamed to SetRunning and TrySetRunning,
and (if successful) they set m_running with the lock held.  This way,
read consumers can determine if the process is running and act
appropriately, and write consumers are still held off from starting the
process if read consumers are active.

Note that with this change there are still some curious access patterns,
such as calling WriteUnlock / SetStopped twice in a row, and there's no
protection from multiple threads trying to simultaneously start the
process.  In practice this does not seem to be a problem, and was
exposing other undefined POSIX behaviour prior to this change.

llvm-svn: 187377
2013-07-29 20:58:06 +00:00
Jason Molenda ad9a53c510 Add an SBFrame::FindRegister() method to make it a little
easier to retrieve a register value.

llvm-svn: 187184
2013-07-26 02:08:48 +00:00
Jim Ingham a7d4822c75 Refine the fix in r187094 to only distrust the StackID comparision when we are starting from an address with no symbols.
If we don't do that "nexti" will stop too soon when stepping past a tail call jump.

rdar://problem/14516227

llvm-svn: 187173
2013-07-26 00:27:57 +00:00
Ed Maste 02983be252 Set thread names on FreeBSD
Also move the logic to shorten thread names from linux/Host.cpp to a new
SetShortThreadName as both FreeBSD and Linux need the functionality.

llvm-svn: 187149
2013-07-25 19:10:32 +00:00
Ed Maste e4dd89f020 Remove unused code
- ReadLocker constructors that take a lock
- Unconditional Lock::ReadLock and ReadLocker::Lock
  (all consumers use TryLock)
- Make Unlock protected, as it has no external consumers

llvm-svn: 187147
2013-07-25 19:02:57 +00:00
Jim Ingham 886a3e2cdf Handle the case where we are stepping through code with no symbols, so we can't really find the function start PC
and so the StackID changes with every step.  Do so by checking the parent frame ID, and if it hasn't changed,
then we haven't stepped in.

rdar://problem/14516227

llvm-svn: 187094
2013-07-25 00:59:01 +00:00
Ed Maste 76859d6cb2 elf-core: Parse vendor-specific notes
ELF notes contain a 'name' field, which specifies a vendor who defines
the format of the note.  Examples are 'FreeBSD' or 'GNU', or it may be
empty for generic notes.

Add a case for FreeBSD-specific notes, leaving Linux and GNU notes,
other vendor-specific notes, and generic notes to be handled by the
existing code for now.

Thanks to Samuel Jacob for reviewing and suggesting improvements.

llvm-svn: 186973
2013-07-23 18:22:17 +00:00
Jim Ingham 4d56e9c1cb This commit does two things. One, it converts the return value of the QueueThreadPlanXXX
plan providers from a "ThreadPlan *" to a "lldb::ThreadPlanSP".  That was needed to fix
a bug where the ThreadPlanStepInRange wasn't checking with its sub-plans to make sure they
succeed before trying to proceed further.  If the sub-plan failed and as a result didn't make
any progress, you could end up retrying the same failing algorithm in an infinite loop.

<rdar://problem/14043602>

llvm-svn: 186618
2013-07-18 21:48:26 +00:00
Ed Maste d591a24b86 Remove unused RunLocker and related code
RunLocker was not used anywhere, and was the only instance of the
WriteLocker class.  Remove both.

llvm-svn: 186361
2013-07-15 22:59:08 +00:00
Greg Clayton 7f98240df6 <rdar://problem/13793059>
Added a setting to control timeout for kdp response packets. While I was at it, I also added a way to control the response timeout for gdb-remote packets.

KDP defaults to 5 seconds, and GDB defaults to 1 second. These were the default values that were in the code prior to adding these settings.

(lldb) settings set plugin.process.gdb-remote.packet-timeout 10
(lldb) settings set plugin.process.kdp-remote.packet-timeout 10

llvm-svn: 186360
2013-07-15 22:54:20 +00:00
Greg Clayton 2540a8a7bc Fixed GetModuleSpecifications() to work better overall:
- MachO files now correctly extract the UUID all the time
- More file size and offset verification done for universal mach-o files to watch for truncated files
- ObjectContainerBSDArchive now supports enumerating all objects in BSD archives (.a files)
- lldb_private::Module() can not be properly constructed using a ModuleSpec for a .o file in a .a file
- The BSD archive plug-in shares its cache for GetModuleSpecifications() and the create callback
- Improved printing for ModuleSpec objects

llvm-svn: 186211
2013-07-12 22:07:46 +00:00
Enrico Granata b8b0bf9b81 Added Repr() and Str() member functions to our PythonObject class to allow easy conversion to-string of every PythonObject
llvm-svn: 186205
2013-07-12 21:11:02 +00:00
Jim Ingham 41eec7e475 The correct max value for size_t variables is SIZE_MAX not UINT64_MAX. Removes lots of warnings when building on 32 bit hosts.
llvm-svn: 186168
2013-07-12 16:16:44 +00:00
Greg Clayton 57ee306789 Huge change to clean up types.
A long time ago we start with clang types that were created by the symbol files and there were many functions in lldb_private::ClangASTContext that helped. Later we create ClangASTType which contains a clang::ASTContext and an opauque QualType, but we didn't switch over to fully using it. There were a lot of places where we would pass around a raw clang_type_t and also pass along a clang::ASTContext separately. This left room for error.

This checkin change all type code over to use ClangASTType everywhere and I cleaned up the interfaces quite a bit. Any code that was in ClangASTContext that was type related, was moved over into ClangASTType. All code that used these types was switched over to use all of the new goodness.

llvm-svn: 186130
2013-07-11 22:46:58 +00:00
Michael Sartain cc791bbfab Fix "source list -n printf" on Linux (printf is symbol alias for __printf)
Differential Revision: http://llvm-reviews.chandlerc.com/D1109

llvm-svn: 186104
2013-07-11 16:40:56 +00:00
Greg Clayton 3046e66830 Cleanup on the unified section list changes. Main changes are:
- ObjectFile::GetSymtab() and ObjectFile::ClearSymtab() no longer takes any flags
- Module coordinates with the object files and contain a unified section list so that object file and symbol file can share sections when they need to, yet contain their own sections.

Other cleanups:
- Fixed Symbol::GetByteSize() to not have the symbol table compute the byte sizes on the fly
- Modified the ObjectFileMachO class to compute symbol sizes all at once efficiently
- Modified the Symtab class to store a file address lookup table for more efficient lookups
- Removed Section::Finalize() and SectionList::Finalize() as they did nothing
- Improved performance of the detection of symbol files that have debug maps by excluding stripped files and core files, debug files, object files and stubs
- Added the ability to tell if an ObjectFile has been stripped with ObjectFile::IsStripped() (used this for the above performance improvement)

llvm-svn: 185990
2013-07-10 01:23:25 +00:00
Enrico Granata eff81a471a Second attempt at getting the PyCallable changes in trunk
Thanks to Daniel Malea for helping test this patch for Linux happiness!

llvm-svn: 185965
2013-07-09 20:14:26 +00:00
Greg Clayton 226cce2511 Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:

lldb::SBModuleSpec
lldb::SBModuleSpecList

The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.

llvm-svn: 185877
2013-07-08 22:22:41 +00:00
Daniel Malea 9a71a7d81b Revert commits that cause broken builds on GCC buildbots
- build fails due to PyCallable template definition inside an extern "C" scope

This commit reverts 185240, 184893 and 184608.

llvm-svn: 185560
2013-07-03 17:58:31 +00:00
Jason Molenda 45f6b1f935 Remove lldb's custom copy of the C++ demangler, used only on Mac
OS X.  Testsuite shows no change in results using the system runtime's
demangler.
<rdar://problem/12029914> 

llvm-svn: 185510
2013-07-03 04:52:51 +00:00
Michael Sartain a7499c9830 Split symbol support for ELF and Linux.
llvm-svn: 185366
2013-07-01 19:45:50 +00:00