Commit Graph

153 Commits

Author SHA1 Message Date
Zachary Turner c156427ded Don't allow direct access to StreamString's internal buffer.
This is a large API change that removes the two functions from
StreamString that return a std::string& and a const std::string&,
and instead provide one function which returns a StringRef.

Direct access to the underlying buffer violates the concept of
a "stream" which is intended to provide forward only access,
and makes porting to llvm::raw_ostream more difficult in the
future.

Differential Revision: https://reviews.llvm.org/D26698

llvm-svn: 287152
2016-11-16 21:15:24 +00:00
Malcolm Parsons 771ef6d4f1 Fix Clang-tidy readability-redundant-string-cstr warnings
Reviewers: zturner, labath

Subscribers: tberghammer, danalbert, lldb-commits
    
Differential Revision: https://reviews.llvm.org/D26233

llvm-svn: 285855
2016-11-02 20:34:10 +00:00
Zachary Turner 95eae4235d Make lldb::Regex use StringRef.
This updates getters and setters to use StringRef instead of
const char *.  I tested the build on Linux, Windows, and OSX
and saw no build or test failures.  I cannot test any BSD
or Android variants, however I expect the required changes
to be minimal or non-existant.

llvm-svn: 282079
2016-09-21 16:01:28 +00:00
Kate Stone b9c1b51e45 *** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style.  This kind of mass change has
*** two obvious implications:

Firstly, merging this particular commit into a downstream fork may be a huge
effort.  Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit.  The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):

    find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
    find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;

The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.

Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit.  There are alternatives available that will attempt
to look through this change and find the appropriate prior commit.  YMMV.

llvm-svn: 280751
2016-09-06 20:57:50 +00:00
Pavel Labath de970cfb0c Second round of fixups for r280692
Android targets don't have std::to_string and std::stoul. Use llvm::to_string and strtoul
instead.

llvm-svn: 280704
2016-09-06 11:08:02 +00:00
Sean Callanan 4740a734bb Added the "frame diagnose" command and use its output to make crash info better.
When a process stops due to a crash, we get the crashing instruction and the
crashing memory location (if there is one).  From the user's perspective it is
often unclear what the reason for the crash is in a symbolic sense.

To address this, I have added new fuctionality to StackFrame to parse the 
disassembly and reconstruct the sequence of dereferneces and offsets that were
applied to a known variable (or fuction retrn value) to obtain the invalid
pointer.

This makes use of enhancements in the disassembler, as well as new information
provided by the DWARF expression infrastructure, and is exposed through a
"frame diagnose" command.  It is also used to provide symbolic information, when
available, in the event of a crash.

The algorithm is very rudimentary, and it needs a bunch of work, including
  - better parsing for assembly, preferably with help from LLVM
  - support for non-Apple platforms
  - cleanup of the algorithm core, preferably to make it all work in terms of
    Operands instead of register/offset pairs
  - improvement of the GetExpressioPath() logic to make prettier expression
    paths, and
  - better handling of vtables.
I welcome all suggestios, improvements, and testcases.

llvm-svn: 280692
2016-09-06 04:48:36 +00:00
Greg Clayton 4a9d83a55e Fix a memory leak in InstructionLLVMC where it held onto a strong reference to the DisassemblerLLVMC which in turn had a vector of InstructionSP causing the strong cycle. This is fixed now.
Rules are as follows for internal code using lldb::DisassemblerSP and lldb::InstructionSP:
1 - The disassembler needs to stay around as long as instructions do as the Instruction subclass now has a weak pointer to the disassembler
2 - The public API has been fixed so that if you get a SBInstruction, it will hold onto a strong reference to the disassembler in a new InstructionImpl class

This will keep code like like: 

inst = lldb.target.ReadInstructions(frame.GetPCAddress(), 1).GetInstructionAtIndex(0)
inst.GetMnemonic()

Working as expected (not the SBInstructionList() that was returned by SBTarget.ReadInstructions() is gone, but "inst" has a strong reference inside of it to the disassembler and the instruction.
                                                     
All code inside the LLDB shared library was verified to correctly hold onto the disassembler instance in all places.

<rdar://problem/24585496>

llvm-svn: 272069
2016-06-07 22:56:40 +00:00
Saleem Abdulrasool 16ff860469 remove use of Mutex in favour of std::{,recursive_}mutex
This is a pretty straightforward first pass over removing a number of uses of
Mutex in favor of std::mutex or std::recursive_mutex. The problem is that there
are interfaces which take Mutex::Locker & to lock internal locks. This patch
cleans up most of the easy cases. The only non-trivial change is in
CommandObjectTarget.cpp where a Mutex::Locker was split into two.

llvm-svn: 269877
2016-05-18 01:59:10 +00:00
Jason Molenda 583b1a8a1b Consolidate the knowledge of what arm cores are always executing
in thumb mode into one method in ArchSpec, replace checks for
specific cores in the disassembler with calls to this.  Also call
this from the arm instruction emulation code.

The determination of whether a given ArchSpec is thumb-only is still
a bit of a hack, but at least the hack is consolidated into a single
place.  In my original version of this patch http://reviews.llvm.org/D13578
I was calling into llvm's feature arm feature tables to make this
determination, like

#include "llvm/Support/TargetRegistry.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/../../lib/Target/ARM/ARMGenRegisterInfo.inc"
#include "llvm/../../lib/Target/ARM/ARMFeatures.h"

[...]

        std::string triple (GetTriple().getTriple());
        const char *cpu = "";
        const char *features_str = "";
        const llvm::Target *curr_target = llvm::TargetRegistry::lookupTarget(triple.c_str(), Error);
        std::unique_ptr<llvm::MCSubtargetInfo> subtarget_info_up (curr_target->createMCSubtargetInfo(triple.c_str(), cpu, features_str));
        if (subtarget_info_up->getFeatureBits()[llvm::ARM::FeatureNoARM])
        {
            return true;
        }

but those tables are post-llvm-build generated and linking against them
for all of our different build system methods was a big hiccup that I
haven't had time to revisit convincingly.

I'll keep that reviews.llvm.org patch around to remind myself that I
need to take another run at linking against the necessary tables 
again in llvm.

<rdar://problem/23022803> 

llvm-svn: 265377
2016-04-05 05:01:30 +00:00
Tamas Berghammer 45dbfa1f83 Upgrade the arm/thumb architecture used by the disassembler
Previously we were using thumbv7 and armv8.1a what ended up showing a
few undefined instruction when disassembling code. This CL update the
architectures used to armv8.2a and thumbv8.2a (newest available) so we
display all instruction in the disassambly.

llvm-svn: 262482
2016-03-02 12:42:43 +00:00
Eugene Zelenko c33088f41e Remove autoconf support from source directories.
Differential revision: http://reviews.llvm.org/D16662

llvm-svn: 259098
2016-01-28 22:05:24 +00:00
Benjamin Kramer 79dad1d056 Update for LLVM change
llvm-svn: 258819
2016-01-26 16:45:00 +00:00
Sean Callanan d38f4d288f DisassemblerLLVMC now gets the disassembler comments for an instruction
and appends them to our list of comments (which can additionally include
things like decoded addresses).

llvm-svn: 255358
2015-12-11 19:10:04 +00:00
Eugene Zelenko 45a4014a50 Fix Clang-tidy modernize-use-override warnings in include/lldb/Disassembler and OperatingSystem; other minor fixes.
Second attempt which should work for MSVC.

llvm-svn: 251066
2015-10-22 21:24:37 +00:00
Eugene Zelenko 8dd3fdbf43 Revert r250872 in source/Plugins/Disassembler to fix MSVC builds failures.
llvm-svn: 250874
2015-10-21 01:42:15 +00:00
Eugene Zelenko 4c3f2b9446 Fix Clang-tidy modernize-use-override warnings in some files in source/Plugins; other minor fixes.
Differential Revision: http://reviews.llvm.org/D13916

llvm-svn: 250872
2015-10-21 01:03:30 +00:00
Jason Molenda 8825c5c9b4 Re-commit the (fixed) changes from r248985 which were reverted by Pavel
when they introduced android testsuite regressions.  Pavel has run the
testsuite against the updated patch and it completes cleanly now.

The original commit message:


Fixing a subtle issue on Mac OS X systems with dSYMs (possibly
introduced by r235737 but I didn't look into it too closely).

A dSYM can have a per-UUID plist in it which tells lldb where
to find an executable binary for the dSYM (DBGSymbolRichExecutable)
- other information can be included in this plist, like how to
remap the source file paths from their build pathnames to their
long-term storage pathnames.

This per-UUID plist is a unusual; it is used probably exclusively
inside apple with our build system.  It is not created by default
in normal dSYMs.

The problem was like this:

  1. lldb wants to find an executable, given only a UUID
     (this happens when lldb is doing cross-host debugging
      and doesn't have a copy of the target system's binaries)

  2. It eventually calls LocateMacOSXFilesUsingDebugSymbols
     which does a spotlight search for the dSYM on the local
     system, and failing that, tries the DBGShellCommands
     command to find the dSYM.

  3. It gets a dSYM.  It reads the per-UUID plist in the dSYM.
     The dSYM has a DBGSymbolRichExecutable kv pair pointing to
     the binary on a network filesystem.

  4. Using the binary on the network filesystem, lldb now goes
     to find the dSYM.

  5. It starts by looking for a dSYM next to the binary it found.

  6. lldb is now reading the dSYM over a network filesystem,
     ignoring the one it found on its local filesystem earlier.

Everything still *works* but it's much slower.

This would be a tricky one to write up in a testsuite case;
you really need the binary to not exist on the local system.
And LocateMacOSXFilesUsingDebugSymbols will only compile on
Mac OS X - even if I found a way to write up a test case, it
would not run anywhere but on a mac.

One change Greg wanted while I was touching this code was to
have LocateMacOSXFilesUsingDebugSymbols (which could be asked
to find a binary OR find a dSYM) to instead return a ModuleSpec
with the sum total of everything it could find.  This
change of passing around a ModuleSpec instead of a FileSpec
was percolated up into ModuleList::GetSharedModule.

The changes to LocateMacOSXFilesUsingDebugSymbols look larger
than they really are - there's a lot of simple whitespace changes
in there.

I ran the testsuites on mac, no new regressions introduced

<rdar://problem/21993813> 

llvm-svn: 249755
2015-10-08 21:48:35 +00:00
Jaydeep Patil 44d07fcc7c [LLDB][MIPS] microMIPS breakpoints, disassembly and compressed addresses
SUMMARY:
    This patch detects microMIPS symbols, sets breakpoints using un-compressed address and 
    display disassembly in mixed mode for microMIPS applications (running on bare-iron targets).

    Reviewers: clayborg
    Subscribers: nitesh.jain, mohit.bhakkad, sagar, bhushan and lldb-commits
    Differential Revision: http://reviews.llvm.org/D12079

llvm-svn: 248248
2015-09-22 06:36:56 +00:00
Daniel Sanders 32764b5917 Fix build after llvm r247683 was reverted.
llvm-svn: 247703
2015-09-15 16:33:17 +00:00
Pavel Labath 360a543d04 Fix build after llvm r247683
llvm-svn: 247687
2015-09-15 13:49:10 +00:00
Greg Clayton 51c63e3b30 Remove a call to deleted function.
llvm-svn: 247193
2015-09-09 21:34:32 +00:00
Greg Clayton aa61a1563b Make sure to flush the stream to make sure the string is up to date when we query its size.
llvm-svn: 247175
2015-09-09 18:41:50 +00:00
Bruce Mitchener db25a7a245 [cmake] Remove LLVM_NO_RTTI.
Summary:
This doesn't exist in other LLVM projects any longer and doesn't
do anything.

Reviewers: chaoren, labath

Subscribers: emaste, tberghammer, lldb-commits, danalbert

Differential Revision: http://reviews.llvm.org/D12586

llvm-svn: 246749
2015-09-03 08:46:55 +00:00
Tamas Berghammer c17469bb88 Only create alternative thumb disassembler if the main one is arm
This fixes a regression caused by r245645 where creating alternative
thumb disassembler was enabled even when the main disassembler is
already thumb.

llvm-svn: 246649
2015-09-02 13:31:18 +00:00
Tamas Berghammer ff417efa1d Fix arm disassambler with specifying armv8.1a architecture
If no architecture is defined for the disassambler command then it uses
the architecture of the target. In case of arm it will be "arm" what is
treated as the oldest arm version by the LLVM disassambler causing a lot
of invalid opcode in the output.

This change forces the use of "armv8.1a" (the newest arm architecture) if
no sub architecure was specified (either by the user or by the target) to
disassamble all instruction.

Differential revision: http://reviews.llvm.org/D12553

llvm-svn: 246648
2015-09-02 13:24:50 +00:00
Bhushan D. Attarde 7f3daeda9a [MIPS] Avoid breakpoint in delay slot
SUMMARY:
    This patch implements Target::GetBreakableLoadAddress() method that takes an address
    and checks for any reason there is a better address than this to put a breakpoint on.
    If there is then return that address.
    MIPS uses this method to avoid breakpoint in delay slot.
    
    Reviewers: clayborg, jingham
    Subscribers: jingham, mohit.bhakkad, sagar, jaydeep, nitesh.jain, lldb-commits
    Differential Revision: http://http://reviews.llvm.org/D12184

llvm-svn: 246015
2015-08-26 06:04:54 +00:00
Jason Molenda 6d9fe8c156 The llvm Triple for an armv6m now comes back as llvm::Triple::thumb.
This was breaking disassembly for arm machines that we force to be
thumb mode all the time because we were only checking for llvm::Triple::arm.
i.e.

armv6m (ARM Cortex-M0)
armv7m (ARM Cortex-M3)
armv7em (ARM Cortex-M4)

<rdar://problem/22334522>

llvm-svn: 245645
2015-08-21 00:13:37 +00:00
Yaron Keren 65270736c7 Remove more uses of raw_svector_ostream::flush() call following r244928.
llvm-svn: 244936
2015-08-13 18:48:44 +00:00
Jaydeep Patil 501a781998 [LLDB][MIPS] Detect MIPS application specific extensions like micromips
SUMMARY:
    The patch detects MIPS application specific extensions (ASE) like micromips by reading 
    ELF header.e_flags and SHT_MIPS_ABIFLAGS section. MIPS triple does not contain ASE 
    information like micromips, mips16, DSP, MSA etc. These can be read from header.e_flags 
    or SHT_MIPS_ABIFLAGS section.
    
    Reviewers: clayborg
    Subscribers: mohit.bhakkad, sagar, lldb-commits
    Differential Revision: http://reviews.llvm.org/D11133

llvm-svn: 242381
2015-07-16 03:51:55 +00:00
Tamas Berghammer fbd72d1606 Fix test regression TestDisassemble_VST1_64 (caused by r239996)
llvm-svn: 240029
2015-06-18 17:03:25 +00:00
Mohit K. Bhakkad 276a930eda [LLDB][MIPS] Emulation of MIPS64 floating-point branch instructions
Patch by Jaydeep Patil

SUMMARY:
1. Added emulation of MIPS64 floating-point branch instructions
2. Updated GetRegisterInfo to recognize floating-point registers
3. Provided CPU information while creating createMCSubtargetInfo in disassembler
4. Bug fix in emulation of JIC and JIALC
5. Correct identification of breakpoint when set in a delay slot of a branch instruction

Reviewers: clayborg
Subscribers: bhushan, mohit.bhakkad, sagar, nitesh.jain, lldb-commits.
Differential Revision: http://reviews.llvm.org/D10355

llvm-svn: 239996
2015-06-18 06:03:27 +00:00
Oleksiy Vyalov 37ff6c4207 Switch from setPrintImmHex to setPrintHexStyle to follow changes from r239263.
llvm-svn: 239310
2015-06-08 17:10:27 +00:00
Chaoren Lin 2d6105cc68 Fix call to llvm::Target::createMCInstPrinter.
llvm-svn: 233655
2015-03-31 00:59:13 +00:00
Akira Hatanaka afbac28bb3 Fix call to MCInstPrinter::printInst to pass MCSubtargetInfo.
The interface of this function was changed in r233411.

llvm-svn: 233429
2015-03-27 21:45:58 +00:00
Jason Molenda c980fa92eb Change the default disassembly format again. First attempt at
changing it was in r219544 - after living on that for a few 
months, I wanted to take another crack at this.

The disassembly-format setting still exists and the old format
can be user specified with a setting like

${current-pc-arrow}${addr-file-or-load}{ <${function.name-without-args}${function.concrete-only-addr-offset-no-padding}>}: 

This patch was discussed in http://reviews.llvm.org/D7578

<rdar://problem/19726421>

llvm-svn: 229186
2015-02-13 23:24:21 +00:00
Greg Clayton 7bd4c60043 Abstract the details from regex.h a bit more by not allowing people to specify compile and execute flags for regular expressions. Also enable better regular expressions if they are available by check if the REG_ENHANCED is available and using it if it is.
Since REG_ENHANCED is available on MacOSX, this allow the use of \d (digits) \b (word boundaries) and much more without affecting other systems.

<rdar://problem/12082562>

llvm-svn: 226704
2015-01-21 21:51:02 +00:00
Chandler Carruth 215d939ada Update to reflect the API change to createMCSymbolizer in LLVM r226416.
This should fix the LLDB build since that change.

llvm-svn: 226427
2015-01-19 03:07:25 +00:00
Rafael Espindola 434df0a18c Update for llvm API change.
llvm-svn: 221752
2014-11-12 02:04:31 +00:00
Rafael Espindola 97ae14e166 Use llvm::StringRefMemoryObject NFC.
llvm-svn: 221509
2014-11-07 04:24:12 +00:00
Jason Molenda aff1b357b0 Add a new disassembly-format specification so that the disassembler
output style can be customized.  Change the built-in default to be
more similar to gdb's disassembly formatting.

The disassembly-format for a gdb-like output is

${addr-file-or-load} <${function.name-without-args}${function.concrete-only-addr-offset-no-padding}>: 

The disassembly-format for the lldb style output is

{${function.initial-function}{${module.file.basename}`}{${function.name-without-args}}:\n}{${function.changed}\n{${module.file.basename}`}{${function.name-without-args}}:\n}{${current-pc-arrow} }{${addr-file-or-load}}: 

The two backticks in the lldb style formatter triggers the sub-expression evaluation in
CommandInterpreter::PreprocessCommand() so you can't use that one as-is ... changing to
use ' characters instead of ` would work around that.

<rdar://problem/9885398> 

llvm-svn: 219544
2014-10-10 23:07:36 +00:00
Jason Molenda 64a68d6157 Update how we create our MCSymbolizer to keep working correctly
on arm64 binaries after the llvm r206063 changes.  
Patch written by Jim Ingham and Lang Hames.
<rdar://problem/16935671> 

llvm-svn: 209051
2014-05-17 00:27:44 +00:00
Sylvestre Ledru a3e4cebd96 Remove trailing spaces
llvm-svn: 206278
2014-04-15 12:08:57 +00:00
Sylvestre Ledru 5ac35ae6f7 Make LLDB builds against the current LLVM sources (modification on createMCDisassembler introduced by r206241)
llvm-svn: 206277
2014-04-15 12:07:25 +00:00
Greg Clayton 3434b578be Fix LLDB to build with top of tree LLVM/Clang.
Patch from Michael Tao.

llvm-svn: 206213
2014-04-14 21:33:38 +00:00
Jason Molenda a332978b2a lldb arm64 import.
These changes were written by Greg Clayton, Jim Ingham, Jason Molenda.

It builds cleanly against TOT llvm with xcodebuild.  I updated the
cmake files by visual inspection but did not try a build.  I haven't
built these sources on any non-Mac platforms - I don't think this
patch adds any code that requires darwin, but please let me know if
I missed something.

In debugserver, MachProcess.cpp and MachTask.cpp were renamed to
MachProcess.mm and MachTask.mm as they picked up some new Objective-C
code needed to launch processes when running on iOS.

llvm-svn: 205113
2014-03-29 18:54:20 +00:00
Ahmed Charles 8f926ad0d9 Replace uses of OwningPtr<T> with std::unique_ptr<T>.
llvm-svn: 203200
2014-03-07 04:45:22 +00:00
Jean-Daniel Dupas c6f26f8542 Stop leaking MCRegisterInfo.
llvm-svn: 198177
2013-12-29 20:17:26 +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
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
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