Commit Graph

373 Commits

Author SHA1 Message Date
Adrian Prantl 771d464f49 Simplify condition (NFC)
llvm-svn: 373352
2019-10-01 17:08:38 +00:00
Jan Kratochvil 5aa1d81969 Code cleanup: Change FormattersContainer::KeyType from SP to rvalue
There is now std::shared_ptr passed around which is expensive for manycore
CPUs. Most of the times (except for 3 cases) it is now just std::moved with no
CPU locks needed. It also makes it possible to sort the keys (which is now not
needed much after D66398).

Differential revision: https://reviews.llvm.org/D67049

llvm-svn: 370863
2019-09-04 09:47:18 +00:00
Jonas Devlieghere 2621f7bdb4 [FormatManage] Fix the format info order
The format info entries need to match the order of the enum entries.
This should fix the two failing data-formatter tests.

llvm-svn: 369617
2019-08-22 03:12:25 +00:00
Jonas Devlieghere 12002fbd21 [FormatManager] Add static_assert to keep formats in sync.
This adds a static assert that ensures that there's a format info entry
for every format enum value. This should prevent others from making the
same mistake I made and Jason kindly fixed in r369611. (Thanks!)

llvm-svn: 369614
2019-08-22 02:56:00 +00:00
Jason Molenda ca4409b4dc The g_format_infos table needs to be updated in concert with the
enum Format entries; else we can crash in a place like
FormatManager::GetFormatAsCString().  We should add  bounds checks
to prevent this more reliably, but for tonight I'm just adding this
entry to keep an address-sanitizer test run working.

llvm-svn: 369611
2019-08-22 02:06:03 +00:00
Jonas Devlieghere dc333e6398 [NFC] Simplify code
This simplifies the code and updates the comments.

llvm-svn: 369491
2019-08-21 04:55:50 +00:00
Davide Italiano 78f05d3599 Revert "[CompilerType] Simplify the interface a bit more.."
There's actually a test downstream that fails with this.
I think we can still get rid of it, but I need to do some work
there first.

llvm-svn: 367963
2019-08-06 00:42:11 +00:00
Davide Italiano b31f60b9c2 [CompilerType] Simplify the interface a bit more..
Summary:
.. removing IsMeaninglessWithoutTypeResolution(). I'm fairly
confident this was introduced to support swift, where
static types [without dynamic counterpart] don't carry a lot
of value. Since then, the formatters and dynamic type resolution
has been rewritten, and we employ different solutions. This function
is unused here too, so let's get read of it.

<rdar://problem/36377967>

Reviewers: shafik, JDevlieghere, alex, compnerd, teemperor

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 367957
2019-08-06 00:01:52 +00:00
Alex Langford 0e252e38ef [Symbol] Use llvm::Expected when getting TypeSystems
Summary:
This commit achieves the following:
- Functions used to return a `TypeSystem *` return an
  `llvm::Expected<TypeSystem *>` now. This means that the result of a call
  is always checked, forcing clients to move more carefully.
- `TypeSystemMap::GetTypeSystemForLanguage` will either return an Error or a
  non-null pointer to a TypeSystem.

Reviewers: JDevlieghere, davide, compnerd

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 367360
2019-07-30 22:12:34 +00:00
Jonas Devlieghere 63e5fb76ec [Logging] Replace Log::Printf with LLDB_LOG macro (NFC)
This patch replaces explicit calls to log::Printf with the new LLDB_LOGF
macro. The macro is similar to LLDB_LOG but supports printf-style format
strings, instead of formatv-style format strings.

So instead of writing:

  if (log)
    log->Printf("%s\n", str);

You'd write:

  LLDB_LOG(log, "%s\n", str);

This change was done mechanically with the command below. I replaced the
spurious if-checks with vim, since I know how to do multi-line
replacements with it.

  find . -type f -name '*.cpp' -exec \
  sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" +

Differential revision: https://reviews.llvm.org/D65128

llvm-svn: 366936
2019-07-24 17:56:10 +00:00
Konrad Kleine 248a13057a [lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]

This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.

This is the command I ran and I to fix and format the code base:

```
run-clang-tidy.py \
	-header-filter='.*' \
	-checks='-*,modernize-use-nullptr' \
	-fix ~/dev/llvm-project/lldb/.* \
	-format \
	-style LLVM \
	-p ~/llvm-builds/debug-ninja-gcc
```

NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.

NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.

Reviewers: martong, espindola, shafik, #lldb, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits

Tags: #lldb, #llvm

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

llvm-svn: 361484
2019-05-23 11:14:47 +00:00
Fangrui Song 71a44224e5 Delete unnecessary copy ctors/copy assignment operators
It's the simplest and gives the cleanest semantics.

llvm-svn: 360762
2019-05-15 11:23:54 +00:00
Jonas Devlieghere 2b29b432d2 [ScriptInterpreter] Move ownership into debugger (NFC)
This is part two of the change started in r359330. This patch moves the
ownership of the script interpreter from the command interpreter into
the debugger. I would've preferred to remove the lazy initialization,
however the fact that the scripting language is set after the debugger
is created makes that tricky. So for now this does exactly the same
thing as when it was under the command interpreter. The result is that
this patch is fully NFC.

Differential revision: https://reviews.llvm.org/D61211

llvm-svn: 359354
2019-04-26 22:43:16 +00:00
Davide Italiano bbcda82e21 [DataFormatters] Remove LLDB_DISABLE_PYTHON from TypeCategory.
llvm-svn: 356271
2019-03-15 16:55:51 +00:00
Davide Italiano 71560b5e2b [DataFormatters] Remove LLDB_DISABLE_PYTHON from FormatManager.
And DataVisualization. One step closer.

llvm-svn: 356225
2019-03-15 00:45:57 +00:00
Davide Italiano 1dbbf2de33 [DataFormatters] Delete unused code. Not even exposed in the API.
I stumbled upon this while removing LLDB_DISABLE_PYTHON when
not needed.

llvm-svn: 356176
2019-03-14 17:41:29 +00:00
Davide Italiano f6a84ed30b [Python] Start eradicating unneeded LLDB_DISABLE_PYTHON guards.
While we don't have a bot, I'm testing by hand that this configuration
compiles. We'll probably set up one once I'm done flensing.

llvm-svn: 356171
2019-03-14 17:23:08 +00:00
Adrian Prantl 0e4c482124 Pass ConstString by value (NFC)
My apologies for the large patch. With the exception of ConstString.h
itself it was entirely produced by sed.

ConstString has exactly one const char * data member, so passing a
ConstString by reference is not any more efficient than copying it by
value. In both cases a single pointer is passed. But passing it by
value makes it harder to accidentally return the address of a local
object.

(This fixes rdar://problem/48640859 for the Apple folks)

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

llvm-svn: 355553
2019-03-06 21:22:25 +00:00
Jonas Devlieghere 70355ace3f Remove redundant ::get() for smart pointer. (NFC)
This commit removes redundant calls to smart pointer’s ::get() method.

https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-smartptr-get.html

llvm-svn: 353795
2019-02-12 03:47:39 +00:00
Jonas Devlieghere 796ac80b86 Use std::make_shared in LLDB (NFC)
Unlike std::make_unique, which is only available since C++14,
std::make_shared is available since C++11. Not only is std::make_shared
a lot more readable compared to ::reset(new), it also performs a single
heap allocation for the object and control block.

Differential revision: https://reviews.llvm.org/D57990

llvm-svn: 353764
2019-02-11 23:13:08 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Adrian Prantl d6a9bbf68e Replace auto -> llvm::Optional<uint64_t>
This addresses post-commit feedback for https://reviews.llvm.org/D56688

llvm-svn: 351237
2019-01-15 20:33:58 +00:00
Adrian Prantl d963a7c398 Make CompilerType::getBitSize() / getByteSize() return an optional result. NFC
The code in LLDB assumes that CompilerType and friends use the size 0
as a sentinel value to signal an error. This works for C++, where no
zero-sized type exists, but in many other programming languages
(including I believe C) types of size zero are possible and even
common. This is a particular pain point in swift-lldb, where extra
code exists to double-check that a type is *really* of size zero and
not an error at various locations.

To remedy this situation, this patch starts by converting
CompilerType::getBitSize() and getByteSize() to return an optional
result. To avoid wasting space, I hand-rolled my own optional data
type assuming that no type is larger than what fits into 63
bits. Follow-up patches would make similar changes to the ValueObject
hierarchy.

rdar://problem/47178964

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

llvm-svn: 351214
2019-01-15 18:07:52 +00:00
Zachary Turner 576495e67b [SymbolFile] Remove SymbolContext parameter from FindTypes.
This parameter was only ever used with the Module set, and
since a SymbolFile is tied to a module, the parameter turns
out to be entirely unnecessary.  Furthermore, it doesn't make
a lot of sense to ask a caller to ask SymbolFile which is tied
to Module X to find types for Module Y, but that possibility
was open with the previous interface.  By removing this
parameter from the API, it makes it harder to use incorrectly
as well as easier for an implementor to understand what it
needs to do.

llvm-svn: 351133
2019-01-14 22:41:21 +00:00
Jonas Devlieghere a6682a413d Simplify Boolean expressions
This patch simplifies boolean expressions acorss LLDB. It was generated
using clang-tidy with the following command:

run-clang-tidy.py -checks='-*,readability-simplify-boolean-expr' -format -fix $PWD

Differential revision: https://reviews.llvm.org/D55584

llvm-svn: 349215
2018-12-15 00:15:33 +00:00
Jonas Devlieghere ceff6644bb Remove header grouping comments.
This patch removes the comments grouping header includes. They were
added after running IWYU over the LLDB codebase. However they add little
value, are often outdates and burdensome to maintain.

llvm-svn: 346626
2018-11-11 23:17:06 +00:00
Adrian Prantl 05097246f3 Reflow paragraphs in comments.
This is intended as a clean up after the big clang-format commit
(r280751), which unfortunately resulted in many of the comment
paragraphs in LLDB being very hard to read.

FYI, the script I used was:

import textwrap
import commands
import os
import sys
import re
tmp = "%s.tmp"%sys.argv[1]
out = open(tmp, "w+")
with open(sys.argv[1], "r") as f:
  header = ""
  text = ""
  comment = re.compile(r'^( *//) ([^ ].*)$')
  special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$')
  for line in f:
      match = comment.match(line)
      if match and not special.match(match.group(2)):
          # skip intentionally short comments.
          if not text and len(match.group(2)) < 40:
              out.write(line)
              continue

          if text:
              text += " " + match.group(2)
          else:
              header = match.group(1)
              text = match.group(2)

          continue

      if text:
          filled = textwrap.wrap(text, width=(78-len(header)),
                                 break_long_words=False)
          for l in filled:
              out.write(header+" "+l+'\n')
              text = ""

      out.write(line)

os.rename(tmp, sys.argv[1])

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

llvm-svn: 331197
2018-04-30 16:49:04 +00:00
Vadim Chugunov 98e3e6003d Use exact equality for category language matching, for all languages, except those specifically mentioned.
llvm-svn: 304832
2017-06-06 20:40:24 +00:00
Zachary Turner 97206d5727 Rename Error -> Status.
This renames the LLDB error class to Status, as discussed
on the lldb-dev mailing list.

A change of this magnitude cannot easily be done without
find and replace, but that has potential to catch unwanted
occurrences of common strings such as "Error".  Every effort
was made to find all the obvious things such as the word "Error"
appearing in a string, etc, but it's possible there are still
some lingering occurences left around.  Hopefully nothing too
serious.

llvm-svn: 302872
2017-05-12 04:51:55 +00:00
Tamas Berghammer 4fbb55b7b1 Stop calling ValueObject::SetName from synthetic child providers
Summary:
Calling ValueObject::SetName from a sythetic child provider would change
the underying value object used for the non-synthetic child as well what
is clearly unintentional.

Reviewers: jingham, labath

Subscribers: lldb-commits

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

llvm-svn: 299259
2017-03-31 20:48:00 +00:00
Jim Ingham b9923589aa Don't add a newline if the object description already has one.
<rdar://problem/25755431>

llvm-svn: 299147
2017-03-31 01:32:57 +00:00
Tamas Berghammer e4e17b8ce4 Remove some dead code from DumpValueObjectOptions::PointerDepth
llvm-svn: 298189
2017-03-18 17:33:00 +00:00
Zachary Turner 666cc0b291 Move DataBuffer / DataExtractor and friends from Core -> Utility.
llvm-svn: 296943
2017-03-04 01:30:05 +00:00
Zachary Turner 29cb868aa4 Isolate Target-specific functionality of DataExtractor.
In an effort to move the various DataBuffer / DataExtractor
classes from Core -> Utility, we have to separate the low-level
functionality from the higher level functionality.  Only a
few functions required anything other than reading/writing
raw bytes, so those functions are separated out into a
more appropriate area.  Specifically, Dump() and DumpHexBytes()
are moved into free functions in Core/DumpDataExtractor.cpp,
and GetGNUEHPointer is moved into a static function in the
only file that it's referenced from.

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

llvm-svn: 296910
2017-03-03 20:57:05 +00:00
Zachary Turner 6f9e690199 Move Log from Core -> Utility.
All references to Host and Core have been removed, so this
class can now safely be lowered into Utility.

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

llvm-svn: 296909
2017-03-03 20:56:28 +00:00
Pavel Labath 6302bf6a26 Clean up debug logging
Summary:
We've had two ways to print a "debug" log message.
- Log::GetDebug() was testing a Stream flag which was never set.
- Log::Debug() was checking for the presence of "log enable --debug"
flag.

Given that these two were used very rarely and we already have a
different way to specify "I want a more verbose log", I propose to remove
these two functions and migrate the callers to LLDB_LOGV. This commit
does that.

Reviewers: clayborg, zturner

Subscribers: lldb-commits

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

llvm-svn: 294939
2017-02-13 11:03:17 +00:00
Zachary Turner bf9a77305f Move classes from Core -> Utility.
This moves the following classes from Core -> Utility.

ConstString
Error
RegularExpression
Stream
StreamString

The goal here is to get lldbUtility into a state where it has
no dependendencies except on itself and LLVM, so it can be the
starting point at which to start untangling LLDB's dependencies.
These are all low level and very widely used classes, and
previously lldbUtility had dependencies up to lldbCore in order
to use these classes.  So moving then down to lldbUtility makes
sense from both the short term and long term perspective in
solving this problem.

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

llvm-svn: 293941
2017-02-02 21:39:50 +00:00
Chris Bieneman 494f277af5 [CMake] Add accurate dependency specifications
Summary:
This patch adds accurate dependency specifications to the mail LLDB libraries and tools.

In all cases except lldb-server, these dependencies are added in addition to existing dependencies (making this low risk), and I performed some code cleanup along the way.

For lldb-server I've cleaned up the LLVM dependencies down to just the minimum actually required. This is more than lldb-server actually directly references, and I've left a todo in the code to clean that up.

Reviewers: labath, zturner

Subscribers: lldb-commits, danalbert, srhines, ki.stfu, mgorny, jgosnell

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

llvm-svn: 293686
2017-01-31 20:43:05 +00:00
Alexander Shaposhnikov 696bd63550 [lldb] Fix typos in file headers
This diff fixes typos in file headers (incorrect file names).

Test plan:

Under llvm/tools/lldb/source:
find ./* -type f | grep -e '\(cpp\|h\)$' | while read F; do B=$(basename $F); echo $F head -n 1 $F | grep -v $B | wc -l ; done

Differential revision: https://reviews.llvm.org/D27115

llvm-svn: 287966
2016-11-26 05:23:44 +00:00
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
Zachary Turner aa5611f56d Change ValueObject creation functions to take StringRefs.
llvm-svn: 286744
2016-11-13 03:29:46 +00:00
Enrico Granata 65d86e4fa5 Simplify the PrintableRepresentationSpecialCases code; we never used the ePrintableRepresentationSpecialCasesOnly value and with enum classes the names doesn't need to be that long
llvm-svn: 286176
2016-11-07 23:32:20 +00:00
Enrico Granata 9ac0dac1a6 Preliminary plumbing work to make 'parray' able to take offset and stride options
llvm-svn: 286003
2016-11-04 18:15:39 +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 5a8ad4591b Make lldb -Werror clean on Windows.
Differential Revision: https://reviews.llvm.org/D25247

llvm-svn: 283344
2016-10-05 17:07:34 +00:00
Justin Lebar 9091055efa Move UTF functions into namespace llvm.
Summary:
This lets people link against LLVM and their own version of the UTF
library.

I determined this only affects llvm, clang, lld, and lldb by running

$ git grep -wl 'UTF[0-9]\+\|\bConvertUTF\bisLegalUTF\|getNumBytesFor' | cut -f 1 -d '/' | sort | uniq
  clang
  lld
  lldb
  llvm

Tested with

  ninja lldb
  ninja check-clang check-llvm check-lld

(ninja check-lldb doesn't complete for me with or without this patch.)

Reviewers: rnk

Subscribers: klimek, beanz, mgorny, llvm-commits

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

llvm-svn: 282822
2016-09-30 00:38:45 +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
Enrico Granata 9b6d4cf9bd Fix an issue where a synthetic child provider could only provide a value of the same size as the containing type
llvm-svn: 280294
2016-08-31 21:46:21 +00:00
Zachary Turner 6c978aa9da Remove unused variables.
Patch by Taras Tsugrii

llvm-svn: 280283
2016-08-31 20:03:14 +00:00