Commit Graph

10625 Commits

Author SHA1 Message Date
Shafik Yaghmour f4babefdf1 Undoing first commit which added a space to a comment
llvm-svn: 341881
2018-09-10 23:18:32 +00:00
Shafik Yaghmour 3875643928 First test commit into svn, adding space to comment
llvm-svn: 341879
2018-09-10 23:12:29 +00:00
Davide Italiano ae3f793e9e Rollback "Fix raw address breakpoints not resolving".
It broke a bunch of bots. Ted confirmed, but can't revert for
now so I'm reverting on his behalf.

llvm-svn: 341878
2018-09-10 23:09:09 +00:00
Ted Woodward 860bafa07d Fix raw address breakpoints not resolving
Summary: An address breakpoint of the form "b 0x1000" won't resolve if it's created while the process isn't running. This patch deletes Address::SectionWasDeleted, renames Address::SectionWasDeletedPrivate to SectionWasDeleted (and makes it public), and changes the section check in Breakpoint::ModulesChanged back to its original form

Reviewers: jingham, #lldb

Reviewed By: jingham

Subscribers: davide, lldb-commits

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

llvm-svn: 341849
2018-09-10 18:19:01 +00:00
Aleksandr Urakov 709426b33a [PDB] Restore AST from PDB symbols
Summary:
This patch adds an implementation of retrieving of declarations and declaration
contexts based on PDB symbols.

PDB has different type symbols for const-qualified types, and this
implementation ensures that only one declaration was created for both const
and non-const types, but creates different compiler types for them.

The implementation also processes the case when there are two symbols
corresponding to a variable. It's possible e.g. for class static variables,
they has one global symbol and one symbol belonging to a class.

PDB has no info about namespaces, so this implementation parses the full symbol
name and tries to figure out if the symbol belongs to namespace or not,
and then creates nested namespaces if necessary.

Reviewers: asmith, zturner, labath

Reviewed By: asmith

Subscribers: aleksandr.urakov, teemperor, lldb-commits, stella.stamenova

Tags: #lldb

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

llvm-svn: 341782
2018-09-10 08:08:43 +00:00
Pavel Labath 4f5450742e Speculative fix for NetBSD bot for r341758
llvm-svn: 341759
2018-09-09 08:42:00 +00:00
Pavel Labath f8b825f689 Re-commit "Modernize NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode"
This recommits r341487, which was reverted due to failing tests with
clang. It turned out I had incorrectly expected that the literal arrays
passed to ArrayRef constructor will have static (permanent) storage.
This was only the case with gcc, while clang was constructing them on
stack, leading to dangling pointers when the function returns.

The fix is to explicitly assign static storage duration to the opcode
arrays.

llvm-svn: 341758
2018-09-09 06:01:12 +00:00
Pavel Labath 12286a2739 Revert "Modernize NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode"
This reverts commit r341487. Jan Kratochvil reports it breaks LLDB when
compiling with clang.

llvm-svn: 341747
2018-09-08 10:33:14 +00:00
David Bolvansky 85dacd1116 Check if a terminal supports colors on Windows properly
Summary:
Previously we SetUseColor(true) wrongly when output was not a terminal so it broken some (not public) bots.

Thanks for issue report, @stella.stamenova

Reviewers: stella.stamenova, zturner

Reviewed By: stella.stamenova

Subscribers: abidh, lldb-commits, stella.stamenova

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

llvm-svn: 341746
2018-09-08 07:15:56 +00:00
Jim Ingham 4911d36aa6 NFC: Move Searcher::Depth into lldb-enumerations as SearchDepth.
In a subsequent commit, I will need to expose the search depth
to the SB API's, so I'm moving this define into lldb-enumerations
where it will get added to the lldb module.

llvm-svn: 341690
2018-09-07 18:43:04 +00:00
Davide Italiano f06ffeee21 [Scalar] Commit the correct patch, forgot `git add`.
<rdar://problem/44229924>

llvm-svn: 341685
2018-09-07 18:22:27 +00:00
Davide Italiano 5ccc9df843 [Scalar] Fix undefined behaviour when converting double to long.
This showed up in an Ubsan build of lldb (inside the CFAbsoluteTime
data formatter). As we only care about the bit pattern, we just
round to the nearest double, and truncate to a size that fits
in ulonglong_t.

<rdar://problem/44229924>

llvm-svn: 341682
2018-09-07 18:03:43 +00:00
Alexander Polyakov 469304e8fb [ARC] Make char unsigned by default
Summary: This patch specifies 'char' default sign on ARC.

Reviewers: tatyana-krasnukha, clayborg

Reviewed By: tatyana-krasnukha, clayborg

Subscribers: clayborg, lldb-commits

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

llvm-svn: 341667
2018-09-07 14:45:32 +00:00
Jason Molenda 0dfb84ce9b Enable the fp-armv8 disassembler feature when disassembling Cortex-M
code.  This will enable disassembly of the optional subset of
neon that some Cortex cores support.  Add a unit test to check
that a few of these instructions disassemble as expected.

<rdar://problem/26674303> 

llvm-svn: 341623
2018-09-07 01:28:48 +00:00
Raphael Isemann ee65d57321 Reland [ClangUserExpression][NFC] Removed unused code
The GetLanguageForExpr has side effects, so we can't remove this
call without breaking the completion mechanism. However, we can
keep the change that gets rid of this unnecessary variable.

llvm-svn: 341535
2018-09-06 10:24:11 +00:00
Raphael Isemann 20c88ebf57 Revert "[ClangUserExpression][NFC] Removed unused code"
GetLanguageForExpr has side effects, so this actually breaks
the completion. Should fix TestExprCompletion.

llvm-svn: 341532
2018-09-06 09:42:44 +00:00
Jason Molenda b0d33e9b3c Re-instate a bit of code that was commented out in r188246 which
reads an ObjectFileMachO's string table in one chunk.  Originally
this was commented out because binaries in the system's shared cache
all share a mega-string table and so reading the entire mega-strtab
for each binary was a performance problem.

In the reinstated code, I add a check that the binary we're reading
from memory is not in the shared cache (there isn't a constant in
<mach-o/loader.h> for this bit yet; we hardcode the value in one
other place in ObjectFileMachO alread).  For binaries that we're
reading out of memory that are NOT in the shared cache, reading 
the string table in one chunk is a big performance improvement.

Also have debugserver send up the flags value for binaries in its
response to the jGetLoadedDynamicLibrariesInfos request.

NFC.

<rdar://problem/33604496> 

llvm-svn: 341511
2018-09-06 00:55:27 +00:00
Adrian Prantl 4954f6a565 Print column info in backtraces et al. if available
This patch allows LLDB to print column info in backtraces et al. if
available, which is useful when the backtrace contains a frame like
the following:

  f(can_crash(0), can_crash(1));

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

llvm-svn: 341506
2018-09-05 23:52:08 +00:00
David Bolvansky 8aa23614af Set Windows console mode to enable support for ansi escape codes
Summary:
Windows console now supports supports ANSI escape codes, but we need to enable it using SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_PROCESSING flag.

https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences.

Syntax hightlighting now works fine on Windows:
https://i.imgur.com/P0i04A7.png

Reviewers: JDevlieghere, teemperor, zturner

Reviewed By: zturner

Subscribers: abidh, lldb-commits

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

llvm-svn: 341497
2018-09-05 22:06:58 +00:00
Pavel Labath ef1b1b5d17 Modernize NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode
return the opcode as a Expected<ArrayRef> instead of a
Status+pointer+size combo.

I also move the linux implementation to the base class, as the trap
opcodes are likely to be the same for all/most implementations of the
class (except the arm one, where linux chooses a different opcode than
what the arm spec recommends, which I keep linux-specific).

llvm-svn: 341487
2018-09-05 18:08:56 +00:00
David Bolvansky 4d46fde679 Terminate debugger if an assert was hit
Reviewers: JDevlieghere, teemperor, #lldb

Reviewed By: JDevlieghere

Subscribers: clayborg, lemo, lldb-commits

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

llvm-svn: 341387
2018-09-04 17:19:15 +00:00
David Bolvansky 52cadf0d2d [NFC] Fixed enum constant in boolean context error
Summary:
/home/xbolva00/LLVM/llvm/tools/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:656:59: warning: enum constant in boolean context [-Wint-in-bool-context]
     if (mh.magic == llvm::MachO::MH_CIGAM || llvm::MachO::MH_MAGIC)
                                                           ^~~~~~~~
/home/xbolva00/LLVM/llvm/tools/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp:658:62: warning: enum constant in boolean context [-Wint-in-bool-context]
     if (mh.magic == llvm::MachO::MH_CIGAM_64 || llvm::MachO::MH_MAGIC_64)

Reviewers: JDevlieghere, teemperor

Reviewed By: teemperor

Subscribers: abidh, lldb-commits

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

llvm-svn: 341340
2018-09-03 22:09:08 +00:00
David Bolvansky 122441d8fd [NFC] Use llvm_unreachable instead of lldb::assert
Summary: Fixes implicit fall through warnings

Reviewers: JDevlieghere, teemperor

Reviewed By: teemperor

Subscribers: lldb-commits

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

llvm-svn: 341339
2018-09-03 22:08:30 +00:00
David Bolvansky 7a213d2f9b [ClangUserExpression][NFC] Removed unused code
llvm-svn: 341334
2018-09-03 18:21:21 +00:00
David Bolvansky 26e97995c4 [PseudoTerminal][NFC] Use llvm errno helpers
Summary:
LLVM provide (str)errno helpers, so convert code to use it.

Also fixes warning:
/home/xbolva00/LLVM/llvm/tools/lldb/source/Host/common/PseudoTerminal.cpp:248:25: warning: ignoring return value of ‘char* strerror_r(int, char*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
             ::strerror_r(errno, error_str, error_len);

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: abidh, lldb-commits

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

llvm-svn: 341320
2018-09-03 14:59:57 +00:00
David Bolvansky aa75dd128c [Symtab][NFC] Added llvm_unreachable to supress compiler warning
Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

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

llvm-svn: 341315
2018-09-03 12:57:54 +00:00
Frederic Riss 78a10a7a9b File completion bugfix
If you tried to complete somwthing like ~/., lldb would come up with a lot
of non-existent filenames by concatenating every exisitng file in the directory
with an initial '.'.

This was due to a workaround for an llvm::fs::path::filename behavior that
was not applied selectively enough.

llvm-svn: 341268
2018-08-31 23:03:28 +00:00
Pavel Labath e7ec083f19 Increase qHostInfo packet timeout
Host info computation can involve DNS traffic (to compute the remote
host name). On very unreliable networks (such as free WiFi on trains),
this can take several seconds to complete or timeout. Increase the
qHostInfo timeout to account for this.

llvm-svn: 341164
2018-08-31 05:34:03 +00:00
Pavel Labath d5fa57eb19 Silence some "control reaches end of non-void function" warnings with gcc
llvm-svn: 341163
2018-08-31 05:18:11 +00:00
Raphael Isemann c11a780ed6 Use a CompletionRequest in the expression command completion [NFC]
The patch was originally written before we had a CompletionRequest,
so it still used a StringList to pass back the completions to
the request.

llvm-svn: 341124
2018-08-30 21:26:32 +00:00
Raphael Isemann d424c2a8a1 Move NoBuiltin=true closer to the other LangOpts code [NFC]
llvm-svn: 341121
2018-08-30 20:56:58 +00:00
Raphael Isemann 20892fb4b0 Adjusting some comments in ClangExpressionParser.cpp
llvm-svn: 341112
2018-08-30 20:19:57 +00:00
Raphael Isemann b83f914b6e Added missing include to <cctype> for 'std::isalnum'
Should fix the failing Windows bots.

llvm-svn: 341109
2018-08-30 20:14:22 +00:00
Raphael Isemann 39ec6e7049 Fixed code style for the CodeCompletion members [NFC]
This code is in LLDB, so it should also follow the LLDB code style
and use the m_ prefix for members.

llvm-svn: 341105
2018-08-30 19:47:53 +00:00
Raphael Isemann 7fae4932ad Move Predicate.h from Host to Utility
Summary:
This class was initially in Host because its implementation used to be
very OS-specific. However, with C++11, it has become a very simple
std::condition_variable wrapper, with no host-specific code.

It is also a general purpose utility class, so it makes sense for it to
live in a place where it can be used by everyone.

This has no effect on the layering right now, but it enables me to later
move the Listener+Broadcaster+Event combo to a lower layer, which is
important, as these are used in a lot of places (notably for launching a
process in Host code).

Reviewers: jingham, zturner, teemperor

Reviewed By: zturner

Subscribers: xiaobai, mgorny, lldb-commits

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

llvm-svn: 341089
2018-08-30 17:51:10 +00:00
Raphael Isemann 7482973411 Added initial code completion support for the `expr` command
Summary:
This patch adds initial code completion support for the `expr` command.

We now have a completion handler in the expression CommandObject that
essentially just attempts to parse the given user expression with Clang with
an attached code completion consumer. We filter and prepare the
code completions provided by Clang and send them back to the completion
API.

The current completion is limited to variables that are in the current scope.
This includes local variables and all types used by local variables. We however
don't do any completion of symbols that are not used in the local scope (or
in some other way already in the ASTContext).

This is partly because there is not yet any code that manually searches for additiona
information in the debug information. Another cause is that for some reason the existing
code for loading these additional symbols when requested by Clang doesn't seem to work.
This will be fixed in a future patch.

Reviewers: jingham, teemperor

Reviewed By: teemperor

Subscribers: labath, aprantl, JDevlieghere, friss, lldb-commits

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

llvm-svn: 341086
2018-08-30 17:29:37 +00:00
Adrian Prantl 2305c049a3 Remove redundant initialization
llvm-svn: 341080
2018-08-30 15:39:08 +00:00
Adrian Prantl 431b158400 Support setting a breakpoint by FileSpec+Line+Column in the SBAPI.
This patch extends the SBAPI to allow for setting a breakpoint not
only at a specific line, but also at a specific (minimum) column. When
a column is specified, it will try to find an exact match or the
closest match on the same line that comes after the specified
location.

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

llvm-svn: 341078
2018-08-30 15:11:00 +00:00
Frederic Riss 0d0a5960a5 Provide a default implementation of TypeSystem::GetNumTemplateArguments
... and remove the dummy implementations from the languages that do not
support it.

llvm-svn: 341006
2018-08-30 00:37:23 +00:00
Raphael Isemann 207863261c Move the column marking functionality to the Highlighter framework
Summary:
The syntax highlighting feature so far is mutually exclusive with the lldb feature
that marks the current column in the line by underlining it via an ANSI color code.
Meaning that if you enable one, the other is automatically disabled by LLDB.

This was caused by the fact that both features inserted color codes into the the
source code and were likely to interfere with each other (which would result
in a broken source code printout to the user).

This patch moves the cursor code into the highlighting framework, which provides
the same feature to the user in normal non-C source code. For any source code
that is highlighted by Clang, we now also have cursor marking for the whole token
that is under the current source location. E.g., before we underlined only the '!' in the
expression '1 != 2', but now the whole token '!=' is underlined. The same for function
calls and so on. Below you can see two examples where we before only underlined
the first character of the token, but now underline the whole token.

{F7075400}
{F7075414}

It also simplifies the DisplaySourceLines method in the SourceManager as most of
the code in there was essentially just for getting this column marker to work as
a FormatEntity.

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: lldb-commits

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

llvm-svn: 341003
2018-08-30 00:09:21 +00:00
Adrian Prantl 3dec0684c5 Refactor BreakpointResolver::SetSCMatchesByLine() to make it easier to
read/understand/maintain.

As a side-effect, this should also improve the performance by avoiding
costly vector element removals and switching from a std::map to a
SmallDenseSet.

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

llvm-svn: 340994
2018-08-29 23:16:42 +00:00
Raphael Isemann c01783a892 Don't cancel the current IOHandler when we push a handler for an utility function run.
Summary:
D48465 is currently blocked by the fact that tab-completing the first expression is deadlocking LLDB.

The reason for this deadlock is that when we push the ProcessIO handler for reading the Objective-C runtime
information from the executable (which is triggered when we parse the an expression for the first time),
the IOHandler can't be pushed as the Editline::Cancel method is deadlocking.

The deadlock in Editline is coming from the m_output_mutex, which is locked before we go into tab completion.
Even without this lock, calling Cancel on Editline will mean that Editline cleans up behind itself and deletes the
current user-input, which is screws up the console when we are tab-completing at the same time.

I think for now the most reasonable way of fixing this is to just not call Cancel on the current IOHandler when we push
the IOHandler for running an internal utility function.

As we can't really write unit tests for IOHandler itself (due to the hard dependency on an initialized Debugger including
all its global state) and Editline completion is currently also not really testable in an automatic fashion, the test for this has
to be that the expression command completion in D48465 doesn't fail when requesting completion the first time.

A more precise test plan for this is:

1. Apply D48465.
2. Start lldb and break in some function.
3. Type `expr foo` and press tab to request completion.
4. Without this patch, we deadlock and LLDB stops responding.

I'll provide an actual unit test for this once I got around and made the IOHandler code testable,
but for now unblocking D48465 is more critical.

Thanks to Jim for helping me debugging this.

Reviewers: jingham

Reviewed By: jingham

Subscribers: emaste, clayborg, abidh, lldb-commits

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

llvm-svn: 340988
2018-08-29 22:50:54 +00:00
Greg Clayton 77c57200f8 Don't include the Age in the UUID for CvRecordPdb70 UUID records in minidump files for Apple vendors.
The CvRecordPdb70 structure looks like:

struct CvRecordPdb70 {
  uint8_t Uuid[16];
  llvm::support::ulittle32_t Age;
  // char PDBFileName[];
};
We were including the "Age" in the UUID for Apple vedors which caused us to not be able to match the UUID to built binaries. The "Age" field is set to zero in breakpad minidump files for Apple targets. 

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

llvm-svn: 340966
2018-08-29 20:34:08 +00:00
Aleksandr Urakov 398f81b3b4 [PDB] Resolve a symbol context block info correctly
Summary:
This patch allows to resolve a symbol context block info even if a function
info was not requested. Also it adds the correct resolving of nested blocks
(the previous implementation used function blocks instead of them).

Reviewers: zturner, asmith, labath

Reviewed By: asmith

Subscribers: lldb-commits, stella.stamenova

Tags: #lldb

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

llvm-svn: 340901
2018-08-29 07:26:11 +00:00
Frederic Riss ae6ca2fc3f Allow IRInterpreter to deal with non-power-of-2 sized types to support some bitfield accesses.
Summary:
For some bitfield patterns (like the one added by this commit), Clang will
generate non-regular data types like i24 or i48. This patch follows a
pretty naive approach of just bumping the type size to the next power of 2.
DataExtractor know how to deal with weird sizes. The operations on Scalar
do not know how to deal with those types though, so we have to legalize the
size when creating a Scalar.

Reviewers: jingham, clayborg

Subscribers: lldb-commits

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

llvm-svn: 340880
2018-08-28 22:50:01 +00:00
Raphael Isemann 691e92b573 [lldb] Fix lldb build on musl
Summary: limits.h is needed for getting PATH_MAX definition, this comes to fore
with musl libc where limits.h is not included indirectly via other system headers.

Patch by Khem Raj, thanks!

Reviewers: compnerd

Reviewed By: compnerd

Subscribers: llvm-commits

Tags: #lldb

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

llvm-svn: 340876
2018-08-28 22:17:28 +00:00
Pavel Labath 1f8639afa6 Respect platform sysroot when loading core files
Patch by Eugene Birukov <eugenebi@microsoft.com>
Differential Revision: https://reviews.llvm.org/D49685

llvm-svn: 340841
2018-08-28 16:32:46 +00:00
Raphael Isemann 4925421c00 Use a RAII guard to control access to DisassemblerLLVMC.
Summary:
This patch replaces the manual lock/unlock calls for gaining exclusive access to the disassembler with
a RAII-powered access scope. This should prevent that we somehow skip over these trailing Unlock calls
(e.g. with early returns).

We also have a second `GetDisasmToUse` method now that takes an already constructed access scope to
prevent deadlocks when we call this from other methods.

Reviewers: #lldb, davide, vsk

Reviewed By: #lldb, davide, vsk

Subscribers: davide, vsk, lldb-commits

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

llvm-svn: 340835
2018-08-28 15:31:01 +00:00
Raphael Isemann 596709d8a8 Let the CompilerInstance create our clang ASTContext
Summary:
Now that we moved the BuiltinContext and SelectorTable to the
CompilerInstance, we can also get rid of manually creating our
own ASTContext, but just use the one from the CompilerInstance
(which will be created with the same settings).

Reviewers: vsk, aprantl, davide

Reviewed By: davide

Subscribers: lldb-commits

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

llvm-svn: 340748
2018-08-27 15:18:33 +00:00
Raphael Isemann eca9ce14d6 Disable use-color if the output stream is not a terminal with color support.
Summary:
LLDB currently only checks the output terminal for color support by looking
at the `TERM` environment variable and comparing it to `"dumb"`. This causes that
when running LLDB on a CI node, the syntax highlighter will not be deactivated by
LLDB and the output log is filled with color codes (unless the terminal emulator
actually exposes itself as dumb).

This patch now relies on the LLVM code for detecting color support which is more
reliable. We now also correctly actually initialize the `m_supports_colors` variable in `File`.
`m_supports_colors` was so far uninitialized, but the code path that uses `m_supports_colors`
was also dead so the sanitizers didn't sound an alarm.

The old check that compares `TERM` is not removed by this patch as the new LLVM code
doesn't seem to handle this case (and it's a good thing to check for "dumb" terminals).

Reviewers: aprantl, javed.absar

Reviewed By: aprantl

Subscribers: kristof.beyls, abidh, lldb-commits

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

llvm-svn: 340747
2018-08-27 15:16:25 +00:00