[Lldb-commits] [PATCH] D95119: Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

2021-02-25 Thread Harmen Stoppels via Phabricator via lldb-commits
haampie added a comment.

Should this be merged?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95119/new/

https://reviews.llvm.org/D95119

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D95119: Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

2021-02-25 Thread Harmen Stoppels via Phabricator via lldb-commits
haampie added a comment.

I don't have commit access, would be great if you could do that for me!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95119/new/

https://reviews.llvm.org/D95119

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing

2021-02-25 Thread Yuanfang Chen via Phabricator via lldb-commits
ychen created this revision.
ychen added reviewers: MaskRay, rnk, tejohnson, qcolombet, anemet.
Herald added subscribers: dexonsmith, kerbowa, hiraditya, nhaehnle, jvesely.
ychen requested review of this revision.
Herald added projects: clang, LLDB, LLVM.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits.

The situation with inline asm/MC error reporting is kind of messy at the
moment. The errors from MC layout are not reliably propagated(D96931 
) and users
have to specify an inlineasm handler separately to get inlineasm
diagnose. The latter issue is not a correctness issue but could be improved.

- Kill LLVMContext inlineasm diagnose handler and migrate it to use

DiagnoseInfo/DiagnoseHandler.

- Introduce `DiagnoseInfoSrcMgr` to diagnose SourceMgr backed errors.

This covers use cases like inline asm, MC and any clients using
SourceMgr.

- Move AsmPrinter::SrcMgrDiagInfo and its instance to MCContext. The

next step is to combine MCContext::SrcMgr and MCContext::InlineSrcMgr
because in all use cases, only one of them is used.

- If LLVMContext is available, let MCContext uses LLVMContext's diagnose

handler; if LLVMContext is not available, MCContext uses its own default
diagnose handler which just print SMDiagnostic.

- Change a few clients(Clang, llc, lldb) to use new way of reporting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97449

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/test/CodeGen/AMDGPU/lds-initializer.ll
  llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
  llvm/test/CodeGen/XCore/section-name.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -290,6 +290,22 @@
   bool *HasError;
   LLCDiagnosticHandler(bool *HasErrorPtr) : HasError(HasErrorPtr) {}
   bool handleDiagnostics(const DiagnosticInfo &DI) override {
+if (DI.getKind() == llvm::DK_SrcMgr) {
+  const auto &DISM = cast(DI);
+  const SMDiagnostic &SMD = DISM.getSMDiag();
+
+  if (SMD.getKind() == SourceMgr::DK_Error)
+*HasError = true;
+
+  SMD.print(nullptr, errs());
+
+  // For testing purposes, we print the LocCookie here.
+  if (DISM.isInlineAsmDiag() && DISM.getLocCookie())
+WithColor::note() << "!srcloc = " << DISM.getLocCookie() << "\n";
+
+  return true;
+}
+
 if (DI.getSeverity() == DS_Error)
   *HasError = true;
 
@@ -305,19 +321,6 @@
   }
 };
 
-static void InlineAsmDiagHandler(const SMDiagnostic &SMD, void *Context,
- unsigned LocCookie) {
-  bool *HasError = static_cast(Context);
-  if (SMD.getKind() == SourceMgr::DK_Error)
-*HasError = true;
-
-  SMD.print(nullptr, errs());
-
-  // For testing purposes, we print the LocCookie here.
-  if (LocCookie)
-WithColor::note() << "!srcloc = " << LocCookie << "\n";
-}
-
 // main - Entry point for the llc compiler.
 //
 int main(int argc, char **argv) {
@@ -367,7 +370,6 @@
   bool HasError = false;
   Context.setDiagnosticHandler(
   std::make_unique(&HasError));
-  Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, &HasError);
 
   Expected> RemarksFileOrErr =
   setupLLVMOptimizationRemarks(Context, RemarksFilename, RemarksPasses,
Index: llvm/test/CodeGen/XCore/section-name.ll
===
--- llvm/test/CodeGen/XCore/section-name.ll
+++ llvm/test/CodeGen/XCore/section-name.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=xcore -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc < %s -march=xcore -o /dev/null 2>&1 | FileCheck %s
 
 @bar = internal global i32 zeroinitializer
 
Index: llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
===
--- llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
+++ llvm/test/CodeGen/AMDGPU/lds-zero-initializer.ll
@@ -1,5 +1,5 @@
-; RUN: llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
-; RUN: llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tahiti < %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -march=amdgcn -mcpu=tonga < %s -o /dev/null 2>&1 | FileCheck %s
 
 ; CHECK: lds: unsupported initializer for address space
 
Index: llvm/test/CodeGen/AMDGPU/lds-initializer.ll
===
--- llvm/test/CodeGen/AMDGPU/lds-initializer.ll
+++ llvm/test/CodeGen/AMDGPU/lds-initializer.ll
@@ 

[Lldb-commits] [PATCH] D95119: Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

2021-02-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D95119#2584709 , @haampie wrote:

> Should this be merged?

Do you have commit access? If not I can land this for you.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95119/new/

https://reviews.llvm.org/D95119

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a54f160 - Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

2021-02-25 Thread Raphael Isemann via lldb-commits

Author: Harmen Stoppels
Date: 2021-02-25T11:32:27+01:00
New Revision: a54f160b3a98b91cd241a555d904a6b6453affc4

URL: 
https://github.com/llvm/llvm-project/commit/a54f160b3a98b91cd241a555d904a6b6453affc4
DIFF: 
https://github.com/llvm/llvm-project/commit/a54f160b3a98b91cd241a555d904a6b6453affc4.diff

LOG: Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

Allow users to use a non-system version of perl, python and awk, which is useful
in certain package managers.

Reviewed By: JDevlieghere, MaskRay

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

Added: 


Modified: 
clang/test/make_test_dirs.pl
clang/tools/scan-build/bin/set-xcode-analyzer
clang/utils/TestUtils/pch-test.pl
clang/utils/analyzer/reducer.pl
clang/utils/analyzer/update_plist_test.pl
clang/www/demo/index.cgi
debuginfo-tests/llgdb-tests/test_debuginfo.pl
lldb/docs/use/python-reference.rst
lldb/scripts/disasm-gdb-remote.pl
llvm/utils/GenLibDeps.pl
llvm/utils/codegen-diff
llvm/utils/findsym.pl
llvm/utils/llvm-compilers-check
llvm/utils/llvm-native-gxx
openmp/runtime/tools/check-execstack.pl
openmp/runtime/tools/check-instruction-set.pl
openmp/runtime/tools/message-converter.pl
polly/lib/External/isl/doc/mypod2latex

Removed: 




diff  --git a/clang/test/make_test_dirs.pl b/clang/test/make_test_dirs.pl
index 3a524d2adb1b..c2af9c485f93 100755
--- a/clang/test/make_test_dirs.pl
+++ b/clang/test/make_test_dirs.pl
@@ -1,9 +1,10 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # Simple little Perl script that takes the cxx-sections.data file as
 # input and generates a directory structure that mimics the standard's
 # structure.
 use English;
+use warnings;
 
 $current_indent_level = -4;
 while ($line = ) {

diff  --git a/clang/tools/scan-build/bin/set-xcode-analyzer 
b/clang/tools/scan-build/bin/set-xcode-analyzer
index 9faaec1e8e6e..f8c3f775ef7d 100755
--- a/clang/tools/scan-build/bin/set-xcode-analyzer
+++ b/clang/tools/scan-build/bin/set-xcode-analyzer
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
 # [PR 11661] Note that we hardwire to /usr/bin/python because we
 # want to the use the system version of Python on Mac OS X.

diff  --git a/clang/utils/TestUtils/pch-test.pl 
b/clang/utils/TestUtils/pch-test.pl
index e4311e965bb7..cff8255b85a3 100755
--- a/clang/utils/TestUtils/pch-test.pl
+++ b/clang/utils/TestUtils/pch-test.pl
@@ -1,10 +1,11 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 
 # This tiny little script, which should be run from the clang
 # directory (with clang in your patch), tries to take each
 # compilable Clang test and build a PCH file from that test, then read
 # and dump the contents of the PCH file just created.
 use POSIX;
+use warnings;
 
 $exitcode = 0;
 sub testfiles($$) {

diff  --git a/clang/utils/analyzer/reducer.pl b/clang/utils/analyzer/reducer.pl
index 872f61b33a77..75c0bf6ce7a6 100755
--- a/clang/utils/analyzer/reducer.pl
+++ b/clang/utils/analyzer/reducer.pl
@@ -1,5 +1,6 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 use strict;
+use warnings;
 use File::Temp qw/ tempdir /;
 my $prog = "reducer";
 
@@ -31,8 +32,9 @@
 my $commandStr = "@$command";
 
 print OUT < 
 #
 
+use warnings;
+
 # Give first option a name.
 my $Directory = $ARGV[0];
 my $Symbol = $ARGV[1];

diff  --git a/llvm/utils/llvm-compilers-check b/llvm/utils/llvm-compilers-check
index 1fd0b93b..3b132454d20b 100755
--- a/llvm/utils/llvm-compilers-check
+++ b/llvm/utils/llvm-compilers-check
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 ##===- utils/llvmbuild - Build the LLVM project 
*-python-*-===##
 #
 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

diff  --git a/llvm/utils/llvm-native-gxx b/llvm/utils/llvm-native-gxx
index db547f654e2f..3c8a703b5b63 100755
--- a/llvm/utils/llvm-native-gxx
+++ b/llvm/utils/llvm-native-gxx
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Wrapper around LLVM tools to generate a native .o from llvm-gxx using an
 # LLVM back-end (CBE by default).
 

diff  --git a/openmp/runtime/tools/check-execstack.pl 
b/openmp/runtime/tools/check-execstack.pl
index e4a8e7c883ab..7a710072f972 100755
--- a/openmp/runtime/tools/check-execstack.pl
+++ b/openmp/runtime/tools/check-execstack.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 
#//===--===//

diff  --git a/openmp/runtime/tools/check-instruction-set.pl 
b/openmp/runtime/tools/check-instruction-set.pl
index 65c315d59236..6edfb55e99ff 100755
--- a/openmp/runtime/tools/check-instruction-set.pl
+++ b/openmp/runtime/tools/check-instruction-set.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 
#//===--===//

diff  --git a/openmp/runtime/tools/message-converte

[Lldb-commits] [lldb] 7cfa6e1 - [lldb] Let ClangASTImporter assert that the target AST has an external source

2021-02-25 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-02-25T11:42:14+01:00
New Revision: 7cfa6e1cc64bc41e644cfc4a43bc122790896569

URL: 
https://github.com/llvm/llvm-project/commit/7cfa6e1cc64bc41e644cfc4a43bc122790896569
DIFF: 
https://github.com/llvm/llvm-project/commit/7cfa6e1cc64bc41e644cfc4a43bc122790896569.diff

LOG: [lldb] Let ClangASTImporter assert that the target AST has an external 
source

This prevents people from accidentially using this code outside the
intended setup.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
index f4ea3af8d9b9..79465316dbc2 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -198,6 +198,12 @@ class ClangASTImporter {
   // nodes within the same AST doesn't make any sense as the whole idea
   // is to import them to a 
diff erent AST.
   lldbassert(target_ctx != source_ctx && "Can't import into itself");
+  // This is always doing a minimal import of any declarations. This means
+  // that there has to be an ExternalASTSource in the target ASTContext
+  // (that should implement the callbacks that complete any declarations
+  // on demand). Without an ExternalASTSource, this ASTImporter will just
+  // do a minimal import and the imported declarations won't be completed.
+  assert(target_ctx->getExternalSource() && "Missing ExternalSource");
   setODRHandling(clang::ASTImporter::ODRHandlingType::Liberal);
 }
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 2d6b767 - [lldb][NFC] Remove some obsolete comments in ClangASTImporter.cpp

2021-02-25 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-02-25T11:44:19+01:00
New Revision: 2d6b767c1d15ec736b409370da33009de57de7f2

URL: 
https://github.com/llvm/llvm-project/commit/2d6b767c1d15ec736b409370da33009de57de7f2
DIFF: 
https://github.com/llvm/llvm-project/commit/2d6b767c1d15ec736b409370da33009de57de7f2.diff

LOG: [lldb][NFC] Remove some obsolete comments in ClangASTImporter.cpp

The first two comments are incomplete and reference obsolete code. The
last one is just commented out code (that also doesn't look correct).

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index c1c115c1fe74..ad72f01f4060 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -359,9 +359,6 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
   if (!ClangUtil::IsClangType(type))
 return false;
 
-  // TODO: remove external completion BOOL
-  // CompleteAndFetchChildren should get the Decl out and check for the
-
   clang::QualType qual_type(
   ClangUtil::GetCanonicalQualType(ClangUtil::RemoveFastQualifiers(type)));
 
@@ -435,8 +432,6 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
 bool ClangASTImporter::Import(const CompilerType &type) {
   if (!ClangUtil::IsClangType(type))
 return false;
-  // TODO: remove external completion BOOL
-  // CompleteAndFetchChildren should get the Decl out and check for the
 
   clang::QualType qual_type(
   ClangUtil::GetCanonicalQualType(ClangUtil::RemoveFastQualifiers(type)));
@@ -908,16 +903,6 @@ void 
ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(
   MapImported(from, to);
   ASTImporter::Imported(from, to);
 
-  /*
-  if (to_objc_interface)
-  to_objc_interface->startDefinition();
-
-  CXXRecordDecl *to_cxx_record = dyn_cast(to);
-
-  if (to_cxx_record)
-  to_cxx_record->startDefinition();
-  */
-
   Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
 
   if (llvm::Error err = ImportDefinition(from)) {



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 86c2672 - [lldb][NFC] Document ClangASTImporter

2021-02-25 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-02-25T13:25:34+01:00
New Revision: 86c267233f51c36d71c12a93d661c4195f150f05

URL: 
https://github.com/llvm/llvm-project/commit/86c267233f51c36d71c12a93d661c4195f150f05
DIFF: 
https://github.com/llvm/llvm-project/commit/86c267233f51c36d71c12a93d661c4195f150f05.diff

LOG: [lldb][NFC] Document ClangASTImporter

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
index 79465316dbc2..274b1215eb21 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -35,6 +35,32 @@ namespace lldb_private {
 class ClangASTMetadata;
 class TypeSystemClang;
 
+/// Manages and observes all Clang AST node importing in LLDB.
+///
+/// The ClangASTImporter takes care of two things:
+///
+/// 1. Keeps track of all ASTImporter instances in LLDB.
+///
+/// Clang's ASTImporter takes care of importing types from one ASTContext to
+/// another. This class expands this concept by allowing copying from several
+/// ASTContext instances to several other ASTContext instances. Instead of
+/// constructing a new ASTImporter manually to copy over a type/decl, this 
class
+/// can be asked to do this. It will construct a ASTImporter for the caller 
(and
+/// will cache the ASTImporter instance for later use) and then perform the
+/// import.
+///
+/// This mainly prevents that a caller might construct several ASTImporter
+/// instances for the same source/target ASTContext combination. As the
+/// ASTImporter has an internal state that keeps track of already imported
+/// declarations and so on, using only one ASTImporter instance is more
+/// efficient and less error-prone than using multiple.
+///
+/// 2. Keeps track of from where declarations were imported (origin-tracking).
+/// The ASTImporter instances in this class usually only performa a minimal
+/// import, i.e., only a shallow copy is made that is filled out on demand
+/// when more information is requested later on. This requires record-keeping
+/// of where any shallow clone originally came from so that the right original
+/// declaration can be found and used as the source of any missing information.
 class ClangASTImporter {
 public:
   struct LayoutInfo {
@@ -53,12 +79,34 @@ class ClangASTImporter {
   : m_file_manager(clang::FileSystemOptions(),
FileSystem::Instance().GetVirtualFileSystem()) {}
 
+  /// Copies the given type and the respective declarations to the destination
+  /// type system.
+  ///
+  /// This function does a shallow copy and requires that the target AST
+  /// has an ExternalASTSource which queries this ClangASTImporter instance
+  /// for any additional information that is maybe lacking in the shallow copy.
+  /// This also means that the type system of src_type can *not* be deleted
+  /// after this function has been called. If you need to delete the source
+  /// type system you either need to delete the destination type system first
+  /// or use \ref ClangASTImporter::DeportType.
+  ///
+  /// \see ClangASTImporter::DeportType
   CompilerType CopyType(TypeSystemClang &dst, const CompilerType &src_type);
 
+  /// \see ClangASTImporter::CopyType
   clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);
 
+  /// Copies the given type and the respective declarations to the destination
+  /// type system.
+  ///
+  /// Unlike CopyType this function ensures that types/declarations which are
+  /// originally from the AST of src_type are fully copied over. The type
+  /// system of src_type can safely be deleted after calling this function.
+  /// \see ClangASTImporter::CopyType
   CompilerType DeportType(TypeSystemClang &dst, const CompilerType &src_type);
 
+  /// Copies the given decl to the destination type system.
+  /// \see ClangASTImporter::DeportType
   clang::Decl *DeportDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);
 
   /// Sets the layout for the given RecordDecl. The layout will later be
@@ -79,8 +127,22 @@ class ClangASTImporter {
   llvm::DenseMap
   &vbase_offsets);
 
+  /// Returns true iff the given type was copied from another TypeSystemClang
+  /// and the original type in this other TypeSystemClang might contain
+  /// additional information (e.g., the definition of a 'class' type) that 
could
+  /// be imported.
+  ///
+  /// \see ClangASTImporter::Import
   bool CanImport(const CompilerType &type);
 
+  /// If the given type was copied from another TypeSystemClang then copy over
+  /// all missing information (e.g., the definition of a 'class' type).
+  ///
+  /// \return True iff an original type in another TypeSystemClang was found.
+  /// Note: Does *not* return false if

[Lldb-commits] [PATCH] D97486: [lldb/Core] Change large function threshold variable into a setting.

2021-02-25 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: teemperor, JDevlieghere.
mib added a project: LLDB.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch replaces the static large function threshold variable by a
global debugger setting.

The default threshold is now set to 32KB (instead of 8KB) and can be modified.

rdar://74726362

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97486

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/source/Commands/CommandObjectDisassemble.cpp
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/test/Shell/Commands/command-disassemble-process.yaml
  lldb/test/Shell/Commands/command-disassemble.s


Index: lldb/test/Shell/Commands/command-disassemble.s
===
--- lldb/test/Shell/Commands/command-disassemble.s
+++ lldb/test/Shell/Commands/command-disassemble.s
@@ -2,6 +2,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
 # RUN: %lldb %t -o "settings set interpreter.stop-command-source-on-error 
false" \
+# RUN:   -o "settings set large-function-threshold 8000" \
 # RUN:   -s %S/Inputs/command-disassemble.lldbinit -o exit 2>&1 | FileCheck %s
 
 # CHECK:  (lldb) disassemble
Index: lldb/test/Shell/Commands/command-disassemble-process.yaml
===
--- lldb/test/Shell/Commands/command-disassemble-process.yaml
+++ lldb/test/Shell/Commands/command-disassemble-process.yaml
@@ -10,6 +10,7 @@
 # RUN:   | FileCheck %s
 
 # RUN: %lldb -c %t %T/command-disassemble-process.big.exe \
+# RUN:   -o "settings set large-function-threshold 8000" \
 # RUN:   -o disassemble -o exit 2>&1 | FileCheck %s --check-prefix=BIG
 
 # CHECK:   (lldb) disassemble
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -258,6 +258,12 @@
   return m_collection_sp->GetPropertyAtIndexAsFormatEntity(nullptr, idx);
 }
 
+uint32_t Debugger::GetLargeFunctionThreshold() const {
+  const uint32_t idx = ePropertyLargeFunctionThreshold;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_debugger_properties[idx].default_uint_value);
+}
+
 bool Debugger::GetNotifyVoid() const {
   const uint32_t idx = ePropertyNotiftVoid;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
Index: lldb/source/Core/CoreProperties.td
===
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -28,6 +28,10 @@
 Global,
 DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.yellow}${frame.pc}${ansi.normal}{ 
${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
 Desc<"The default frame format string to use when displaying stack frame 
information for threads.">;
+  def LargeFunctionThreshold: Property<"large-function-threshold", "UInt64">,
+Global,
+DefaultUnsignedValue<32000>,
+Desc<"The size limit to use when disassembling large functions (default: 
32KB).">;
   def NotiftVoid: Property<"notify-void", "Boolean">,
 Global,
 DefaultFalse,
Index: lldb/source/Commands/CommandObjectDisassemble.cpp
===
--- lldb/source/Commands/CommandObjectDisassemble.cpp
+++ lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -23,7 +23,6 @@
 
 static constexpr unsigned default_disasm_byte_size = 32;
 static constexpr unsigned default_disasm_num_ins = 4;
-static constexpr unsigned large_function_threshold = 8000;
 
 using namespace lldb;
 using namespace lldb_private;
@@ -223,7 +222,7 @@
 llvm::Error CommandObjectDisassemble::CheckRangeSize(const AddressRange &range,
  llvm::StringRef what) {
   if (m_options.num_instructions > 0 || m_options.force ||
-  range.GetByteSize() < large_function_threshold)
+  range.GetByteSize() < GetDebugger().GetLargeFunctionThreshold())
 return llvm::Error::success();
   StreamString msg;
   msg << "Not disassembling " << what << " because it is very large ";
Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -246,6 +246,8 @@
 
   const FormatEntity::Entry *GetFrameFormatUnique() const;
 
+  uint32_t GetLargeFunctionThreshold() const;
+
   const FormatEntity::Entry *GetThreadFormat() const;
 
   const FormatEntity::Entry *GetThreadStopFormat() const;


Index: lldb/test/Shell/Com

[Lldb-commits] [PATCH] D97486: [lldb/Core] Change large function threshold variable into a setting.

2021-02-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/include/lldb/Core/Debugger.h:249
 
+  uint32_t GetLargeFunctionThreshold() const;
+

This seems like it could have a better name, how about `DisassemblyTreshold`? 
If this only used when stopped (like `StopDisassemblyCount`) then maybe add the 
`Stop` prefix here too. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97486/new/

https://reviews.llvm.org/D97486

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D97486: [lldb/Core] Change large function threshold variable into a setting.

2021-02-25 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 326450.
mib added a comment.

Renamed setting to `stop-disassembly-size`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97486/new/

https://reviews.llvm.org/D97486

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/source/Commands/CommandObjectDisassemble.cpp
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/test/Shell/Commands/command-disassemble-process.yaml
  lldb/test/Shell/Commands/command-disassemble.s


Index: lldb/test/Shell/Commands/command-disassemble.s
===
--- lldb/test/Shell/Commands/command-disassemble.s
+++ lldb/test/Shell/Commands/command-disassemble.s
@@ -2,6 +2,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
 # RUN: %lldb %t -o "settings set interpreter.stop-command-source-on-error 
false" \
+# RUN:   -o "settings set stop-disassembly-size 8000" \
 # RUN:   -s %S/Inputs/command-disassemble.lldbinit -o exit 2>&1 | FileCheck %s
 
 # CHECK:  (lldb) disassemble
Index: lldb/test/Shell/Commands/command-disassemble-process.yaml
===
--- lldb/test/Shell/Commands/command-disassemble-process.yaml
+++ lldb/test/Shell/Commands/command-disassemble-process.yaml
@@ -10,6 +10,7 @@
 # RUN:   | FileCheck %s
 
 # RUN: %lldb -c %t %T/command-disassemble-process.big.exe \
+# RUN:   -o "settings set stop-disassembly-size 8000" \
 # RUN:   -o disassemble -o exit 2>&1 | FileCheck %s --check-prefix=BIG
 
 # CHECK:   (lldb) disassemble
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -258,6 +258,12 @@
   return m_collection_sp->GetPropertyAtIndexAsFormatEntity(nullptr, idx);
 }
 
+uint32_t Debugger::GetStopDisassemblySize() const {
+  const uint32_t idx = ePropertyStopDisassemblySize;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_debugger_properties[idx].default_uint_value);
+}
+
 bool Debugger::GetNotifyVoid() const {
   const uint32_t idx = ePropertyNotiftVoid;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
Index: lldb/source/Core/CoreProperties.td
===
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -28,6 +28,10 @@
 Global,
 DefaultStringValue<"frame #${frame.index}: 
${ansi.fg.yellow}${frame.pc}${ansi.normal}{ 
${module.file.basename}{`${function.name-with-args}{${frame.no-debug}${function.pc-offset{
 at 
${ansi.fg.cyan}${line.file.basename}${ansi.normal}:${ansi.fg.yellow}${line.number}${ansi.normal}{:${ansi.fg.yellow}${line.column}${ansi.normal}}}{${function.is-optimized}
 [opt]}{${frame.is-artificial} [artificial]}n">,
 Desc<"The default frame format string to use when displaying stack frame 
information for threads.">;
+  def StopDisassemblySize: Property<"stop-disassembly-size", "UInt64">,
+Global,
+DefaultUnsignedValue<32000>,
+Desc<"The size limit to use when disassembling large functions (default: 
32KB).">;
   def NotiftVoid: Property<"notify-void", "Boolean">,
 Global,
 DefaultFalse,
Index: lldb/source/Commands/CommandObjectDisassemble.cpp
===
--- lldb/source/Commands/CommandObjectDisassemble.cpp
+++ lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -23,7 +23,6 @@
 
 static constexpr unsigned default_disasm_byte_size = 32;
 static constexpr unsigned default_disasm_num_ins = 4;
-static constexpr unsigned large_function_threshold = 8000;
 
 using namespace lldb;
 using namespace lldb_private;
@@ -223,7 +222,7 @@
 llvm::Error CommandObjectDisassemble::CheckRangeSize(const AddressRange &range,
  llvm::StringRef what) {
   if (m_options.num_instructions > 0 || m_options.force ||
-  range.GetByteSize() < large_function_threshold)
+  range.GetByteSize() < GetDebugger().GetStopDisassemblySize())
 return llvm::Error::success();
   StreamString msg;
   msg << "Not disassembling " << what << " because it is very large ";
Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -246,6 +246,8 @@
 
   const FormatEntity::Entry *GetFrameFormatUnique() const;
 
+  uint32_t GetStopDisassemblySize() const;
+
   const FormatEntity::Entry *GetThreadFormat() const;
 
   const FormatEntity::Entry *GetThreadStopFormat() const;


Index: lldb/test/Shell/Commands/command-disassemble.s
===
--- lldb/test/Shell/Commands/command-disassemble.s
+++ lldb/test/Shell/Commands/command-disassemble.s
@@ -2,6 +2,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_6

[Lldb-commits] [PATCH] D97486: [lldb/Core] Change large function threshold variable into a setting.

2021-02-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Core/CoreProperties.td:31
 Desc<"The default frame format string to use when displaying stack frame 
information for threads.">;
+  def StopDisassemblySize: Property<"stop-disassembly-size", "UInt64">,
+Global,

Nit, let's move this next to `StopDisassemblyCount` and 
`StopDisassemblyDisplay`. 



Comment at: lldb/source/Core/CoreProperties.td:31
 Desc<"The default frame format string to use when displaying stack frame 
information for threads.">;
+  def StopDisassemblySize: Property<"stop-disassembly-size", "UInt64">,
+Global,

JDevlieghere wrote:
> Nit, let's move this next to `StopDisassemblyCount` and 
> `StopDisassemblyDisplay`. 
Sorry to go on about this but now it doesn't convey that it's the maximum size. 
Maybe `stop-disassembly-max-size` or `stop-disassembly-size-threshold`. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97486/new/

https://reviews.llvm.org/D97486

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D97486: [lldb/Core] Change large function threshold variable into a setting.

2021-02-25 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 326478.
mib edited the summary of this revision.
mib added a comment.

Address @JDevlieghere comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97486/new/

https://reviews.llvm.org/D97486

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/source/Commands/CommandObjectDisassemble.cpp
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/test/Shell/Commands/command-disassemble-process.yaml
  lldb/test/Shell/Commands/command-disassemble.s


Index: lldb/test/Shell/Commands/command-disassemble.s
===
--- lldb/test/Shell/Commands/command-disassemble.s
+++ lldb/test/Shell/Commands/command-disassemble.s
@@ -2,6 +2,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
 # RUN: %lldb %t -o "settings set interpreter.stop-command-source-on-error 
false" \
+# RUN:   -o "settings set stop-disassembly-max-size 8000" \
 # RUN:   -s %S/Inputs/command-disassemble.lldbinit -o exit 2>&1 | FileCheck %s
 
 # CHECK:  (lldb) disassemble
Index: lldb/test/Shell/Commands/command-disassemble-process.yaml
===
--- lldb/test/Shell/Commands/command-disassemble-process.yaml
+++ lldb/test/Shell/Commands/command-disassemble-process.yaml
@@ -10,6 +10,7 @@
 # RUN:   | FileCheck %s
 
 # RUN: %lldb -c %t %T/command-disassemble-process.big.exe \
+# RUN:   -o "settings set stop-disassembly-max-size 8000" \
 # RUN:   -o disassemble -o exit 2>&1 | FileCheck %s --check-prefix=BIG
 
 # CHECK:   (lldb) disassemble
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -258,6 +258,12 @@
   return m_collection_sp->GetPropertyAtIndexAsFormatEntity(nullptr, idx);
 }
 
+uint32_t Debugger::GetStopDisassemblyMaxSize() const {
+  const uint32_t idx = ePropertyStopDisassemblyMaxSize;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_debugger_properties[idx].default_uint_value);
+}
+
 bool Debugger::GetNotifyVoid() const {
   const uint32_t idx = ePropertyNotiftVoid;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
Index: lldb/source/Core/CoreProperties.td
===
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -51,6 +51,10 @@
 DefaultEnumValue<"Debugger::eStopDisassemblyTypeNoDebugInfo">,
 EnumValues<"OptionEnumValues(g_show_disassembly_enum_values)">,
 Desc<"Control when to display disassembly when displaying a stopped 
context.">;
+  def StopDisassemblyMaxSize: Property<"stop-disassembly-max-size", "UInt64">,
+Global,
+DefaultUnsignedValue<32000>,
+Desc<"The size limit to use when disassembling large functions (default: 
32KB).">;
   def StopLineCountAfter: Property<"stop-line-count-after", "SInt64">,
 Global,
 DefaultUnsignedValue<3>,
Index: lldb/source/Commands/CommandObjectDisassemble.cpp
===
--- lldb/source/Commands/CommandObjectDisassemble.cpp
+++ lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -23,7 +23,6 @@
 
 static constexpr unsigned default_disasm_byte_size = 32;
 static constexpr unsigned default_disasm_num_ins = 4;
-static constexpr unsigned large_function_threshold = 8000;
 
 using namespace lldb;
 using namespace lldb_private;
@@ -223,7 +222,7 @@
 llvm::Error CommandObjectDisassemble::CheckRangeSize(const AddressRange &range,
  llvm::StringRef what) {
   if (m_options.num_instructions > 0 || m_options.force ||
-  range.GetByteSize() < large_function_threshold)
+  range.GetByteSize() < GetDebugger().GetStopDisassemblyMaxSize())
 return llvm::Error::success();
   StreamString msg;
   msg << "Not disassembling " << what << " because it is very large ";
Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -246,6 +246,8 @@
 
   const FormatEntity::Entry *GetFrameFormatUnique() const;
 
+  uint32_t GetStopDisassemblyMaxSize() const;
+
   const FormatEntity::Entry *GetThreadFormat() const;
 
   const FormatEntity::Entry *GetThreadStopFormat() const;


Index: lldb/test/Shell/Commands/command-disassemble.s
===
--- lldb/test/Shell/Commands/command-disassemble.s
+++ lldb/test/Shell/Commands/command-disassemble.s
@@ -2,6 +2,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
 # RUN: %lldb %t -o "settings set interpreter.stop-command-source-on-error false" \
+# RUN:   -o "settings set stop-disassembly-max-size 8000" \
 # RUN:   -s %S/Inputs/command-disassemble.lldbinit -o exit 2>&1 |

[Lldb-commits] [PATCH] D97486: [lldb/Core] Change large function threshold variable into a setting.

2021-02-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for bearing with me!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97486/new/

https://reviews.llvm.org/D97486

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] b889ef4 - [lldb/Core] Change large function threshold variable into a setting.

2021-02-25 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2021-02-25T22:35:04+01:00
New Revision: b889ef4214bc6dc8880fdd4badc0dcd9a3197753

URL: 
https://github.com/llvm/llvm-project/commit/b889ef4214bc6dc8880fdd4badc0dcd9a3197753
DIFF: 
https://github.com/llvm/llvm-project/commit/b889ef4214bc6dc8880fdd4badc0dcd9a3197753.diff

LOG: [lldb/Core] Change large function threshold variable into a setting.

This patch replaces the static large function threshold variable with a
global debugger setting (`stop-disassembly-max-size`).

The default threshold is now set to 32KB (instead of 8KB) and can be modified.

rdar://74726362

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/include/lldb/Core/Debugger.h
lldb/source/Commands/CommandObjectDisassemble.cpp
lldb/source/Core/CoreProperties.td
lldb/source/Core/Debugger.cpp
lldb/test/Shell/Commands/command-disassemble-process.yaml
lldb/test/Shell/Commands/command-disassemble.s

Removed: 




diff  --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 68daae1a3710..02ff683a3b62 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -246,6 +246,8 @@ class Debugger : public 
std::enable_shared_from_this,
 
   const FormatEntity::Entry *GetFrameFormatUnique() const;
 
+  uint32_t GetStopDisassemblyMaxSize() const;
+
   const FormatEntity::Entry *GetThreadFormat() const;
 
   const FormatEntity::Entry *GetThreadStopFormat() const;

diff  --git a/lldb/source/Commands/CommandObjectDisassemble.cpp 
b/lldb/source/Commands/CommandObjectDisassemble.cpp
index cf4d8ed04f81..8d2b13a5a4c0 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -23,7 +23,6 @@
 
 static constexpr unsigned default_disasm_byte_size = 32;
 static constexpr unsigned default_disasm_num_ins = 4;
-static constexpr unsigned large_function_threshold = 8000;
 
 using namespace lldb;
 using namespace lldb_private;
@@ -223,7 +222,7 @@ CommandObjectDisassemble::~CommandObjectDisassemble() = 
default;
 llvm::Error CommandObjectDisassemble::CheckRangeSize(const AddressRange &range,
  llvm::StringRef what) {
   if (m_options.num_instructions > 0 || m_options.force ||
-  range.GetByteSize() < large_function_threshold)
+  range.GetByteSize() < GetDebugger().GetStopDisassemblyMaxSize())
 return llvm::Error::success();
   StreamString msg;
   msg << "Not disassembling " << what << " because it is very large ";

diff  --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 96f67801553b..ccd6f7b97a5f 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -51,6 +51,10 @@ let Definition = "debugger" in {
 DefaultEnumValue<"Debugger::eStopDisassemblyTypeNoDebugInfo">,
 EnumValues<"OptionEnumValues(g_show_disassembly_enum_values)">,
 Desc<"Control when to display disassembly when displaying a stopped 
context.">;
+  def StopDisassemblyMaxSize: Property<"stop-disassembly-max-size", "UInt64">,
+Global,
+DefaultUnsignedValue<32000>,
+Desc<"The size limit to use when disassembling large functions (default: 
32KB).">;
   def StopLineCountAfter: Property<"stop-line-count-after", "SInt64">,
 Global,
 DefaultUnsignedValue<3>,

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 1294b600c611..a9a5c7445976 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -258,6 +258,12 @@ const FormatEntity::Entry 
*Debugger::GetFrameFormatUnique() const {
   return m_collection_sp->GetPropertyAtIndexAsFormatEntity(nullptr, idx);
 }
 
+uint32_t Debugger::GetStopDisassemblyMaxSize() const {
+  const uint32_t idx = ePropertyStopDisassemblyMaxSize;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_debugger_properties[idx].default_uint_value);
+}
+
 bool Debugger::GetNotifyVoid() const {
   const uint32_t idx = ePropertyNotiftVoid;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(

diff  --git a/lldb/test/Shell/Commands/command-disassemble-process.yaml 
b/lldb/test/Shell/Commands/command-disassemble-process.yaml
index e87c4761981a..f08792f867c0 100644
--- a/lldb/test/Shell/Commands/command-disassemble-process.yaml
+++ b/lldb/test/Shell/Commands/command-disassemble-process.yaml
@@ -10,6 +10,7 @@
 # RUN:   | FileCheck %s
 
 # RUN: %lldb -c %t %T/command-disassemble-process.big.exe \
+# RUN:   -o "settings set stop-disassembly-max-size 8000" \
 # RUN:   -o disassemble -o exit 2>&1 | FileCheck %s --check-prefix=BIG
 
 # CHECK:   (lldb) disassemble

diff  --git a/lldb/test/Shell/Commands/command-disassemble.s 
b/lldb/test/Shell/Commands/command-disassemble.s
index e59edd05dbaa..1feff0b878c8 100644
--- a/lldb/test/Shell/C

[Lldb-commits] [PATCH] D97486: [lldb/Core] Change large function threshold variable into a setting.

2021-02-25 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb889ef4214bc: [lldb/Core] Change large function threshold 
variable into a setting. (authored by mib).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97486/new/

https://reviews.llvm.org/D97486

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/source/Commands/CommandObjectDisassemble.cpp
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/test/Shell/Commands/command-disassemble-process.yaml
  lldb/test/Shell/Commands/command-disassemble.s


Index: lldb/test/Shell/Commands/command-disassemble.s
===
--- lldb/test/Shell/Commands/command-disassemble.s
+++ lldb/test/Shell/Commands/command-disassemble.s
@@ -2,6 +2,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
 # RUN: %lldb %t -o "settings set interpreter.stop-command-source-on-error 
false" \
+# RUN:   -o "settings set stop-disassembly-max-size 8000" \
 # RUN:   -s %S/Inputs/command-disassemble.lldbinit -o exit 2>&1 | FileCheck %s
 
 # CHECK:  (lldb) disassemble
Index: lldb/test/Shell/Commands/command-disassemble-process.yaml
===
--- lldb/test/Shell/Commands/command-disassemble-process.yaml
+++ lldb/test/Shell/Commands/command-disassemble-process.yaml
@@ -10,6 +10,7 @@
 # RUN:   | FileCheck %s
 
 # RUN: %lldb -c %t %T/command-disassemble-process.big.exe \
+# RUN:   -o "settings set stop-disassembly-max-size 8000" \
 # RUN:   -o disassemble -o exit 2>&1 | FileCheck %s --check-prefix=BIG
 
 # CHECK:   (lldb) disassemble
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -258,6 +258,12 @@
   return m_collection_sp->GetPropertyAtIndexAsFormatEntity(nullptr, idx);
 }
 
+uint32_t Debugger::GetStopDisassemblyMaxSize() const {
+  const uint32_t idx = ePropertyStopDisassemblyMaxSize;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_debugger_properties[idx].default_uint_value);
+}
+
 bool Debugger::GetNotifyVoid() const {
   const uint32_t idx = ePropertyNotiftVoid;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
Index: lldb/source/Core/CoreProperties.td
===
--- lldb/source/Core/CoreProperties.td
+++ lldb/source/Core/CoreProperties.td
@@ -51,6 +51,10 @@
 DefaultEnumValue<"Debugger::eStopDisassemblyTypeNoDebugInfo">,
 EnumValues<"OptionEnumValues(g_show_disassembly_enum_values)">,
 Desc<"Control when to display disassembly when displaying a stopped 
context.">;
+  def StopDisassemblyMaxSize: Property<"stop-disassembly-max-size", "UInt64">,
+Global,
+DefaultUnsignedValue<32000>,
+Desc<"The size limit to use when disassembling large functions (default: 
32KB).">;
   def StopLineCountAfter: Property<"stop-line-count-after", "SInt64">,
 Global,
 DefaultUnsignedValue<3>,
Index: lldb/source/Commands/CommandObjectDisassemble.cpp
===
--- lldb/source/Commands/CommandObjectDisassemble.cpp
+++ lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -23,7 +23,6 @@
 
 static constexpr unsigned default_disasm_byte_size = 32;
 static constexpr unsigned default_disasm_num_ins = 4;
-static constexpr unsigned large_function_threshold = 8000;
 
 using namespace lldb;
 using namespace lldb_private;
@@ -223,7 +222,7 @@
 llvm::Error CommandObjectDisassemble::CheckRangeSize(const AddressRange &range,
  llvm::StringRef what) {
   if (m_options.num_instructions > 0 || m_options.force ||
-  range.GetByteSize() < large_function_threshold)
+  range.GetByteSize() < GetDebugger().GetStopDisassemblyMaxSize())
 return llvm::Error::success();
   StreamString msg;
   msg << "Not disassembling " << what << " because it is very large ";
Index: lldb/include/lldb/Core/Debugger.h
===
--- lldb/include/lldb/Core/Debugger.h
+++ lldb/include/lldb/Core/Debugger.h
@@ -246,6 +246,8 @@
 
   const FormatEntity::Entry *GetFrameFormatUnique() const;
 
+  uint32_t GetStopDisassemblyMaxSize() const;
+
   const FormatEntity::Entry *GetThreadFormat() const;
 
   const FormatEntity::Entry *GetThreadStopFormat() const;


Index: lldb/test/Shell/Commands/command-disassemble.s
===
--- lldb/test/Shell/Commands/command-disassemble.s
+++ lldb/test/Shell/Commands/command-disassemble.s
@@ -2,6 +2,7 @@
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t
 # RUN: %lldb %t -o "settings set interpreter.stop-command-source-on-error false" \
+# RUN:   -o 

[Lldb-commits] [PATCH] D97498: [LLDB] Support GDB remote g packet partial read

2021-02-25 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid created this revision.
omjavaid added a reviewer: labath.
omjavaid requested review of this revision.

GDB remote protocol does not specify length of g packet for register read. It 
depends on remote to include all or exclude certain registers from g packet. In 
case a register or set of registers is not included as part of g packet then we 
should fall back to p packet for reading all registers excluded from g packet 
by remote. This patch adds support for above feature and adds a test-case for 
the same.


https://reviews.llvm.org/D97498

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/test/API/functionalities/gdb_remote_client/TestPartialGPacket.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestPartialGPacket.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestPartialGPacket.py
@@ -0,0 +1,106 @@
+from __future__ import print_function
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPartialGPacket(GDBRemoteTestBase):
+
+@skipIfXmlSupportMissing
+@skipIfRemote
+def test(self):
+"""
+Test GDB remote fallback to 'p' packet when 'g' packet does not include all registers.
+"""
+class MyResponder(MockGDBServerResponder):
+
+def qXferRead(self, obj, annex, offset, length):
+if annex == "target.xml":
+return """
+
+
+arm
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+""", False
+else:
+return None, False
+
+def readRegister(self, regnum):
+if regnum == 31:
+return "cdcc8c3f"
+return "E01"
+
+def readRegisters(self):
+return "2000f836002000102fcb0008f8360020a0360020200c0020b87f0120b7d100082ed200080001"
+
+def haltReason(self):
+return "S05"
+
+def qfThreadInfo(self):
+return "mdead"
+
+def qC(self):
+return ""
+
+def qSupported(self, client_supported):
+return "PacketSize=4000;qXfer:memory-map:read-;QStartNoAckMode+;qXfer:threads:read+;hwbreak+;qXfer:features:read+"
+
+def QThreadSuffixSupported(self):
+return "OK"
+
+def QListThreadsInStopReply(self):
+return "OK"
+
+self.server.responder = MyResponder()
+if self.TraceOn():
+self.runCmd("log enable gdb-remote packets")
+self.addTearDownHook(
+lambda: self.runCmd("log disable gdb-remote packets"))
+
+self.dbg.SetDefaultArchitecture("armv7em")
+target = self.dbg.CreateTargetWithFileAndArch(None, None)
+
+process = self.connect(target)
+
+if self.TraceOn():
+interp = self.dbg.GetCommandInterpreter()
+result = lldb.SBCommandReturnObject()
+interp.HandleCommand("target list", result)
+print(result.GetOutput())
+
+r0_valobj = process.GetThreadAtIndex(
+0).GetFrameAtIndex(0).FindRegister("r0")
+self.assertEqual(r0_valobj.GetValueAsUnsigned(), 0x20)
+
+pc_valobj = process.GetThreadAtIndex(
+0).GetFrameAtIndex(0).FindRegister("pc")
+self.assertEqual(pc_valobj.GetValueAsUnsigned(), 0x0800d22e)
+
+pc_valobj = process.GetThreadAtIndex(
+0).GetFrameAtIndex(0).FindRegister("CONTROL")
+self.assertEqual(pc_valobj.GetValueAsUnsigned(), 0x3f8d)
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -118,6 +118,7 @@
   DataExtractor m_reg_data;
   bool m_read_all_at_once;
   bool m_write_all_at_once;
+  bool m_gpacket_cached;
 
 private:
   // Helper function for ReadRegisterBytes().
Index: lldb/source/Pl

[Lldb-commits] [PATCH] D50299: Migrate to llvm::unique_function instead of static member functions for callbacks

2021-02-25 Thread Neal via Phabricator via lldb-commits
nealsid updated this revision to Diff 326553.
nealsid added a comment.
Herald added a project: LLDB.

I'm updating this very old patch that I forgot about in 2018.  This one removes 
the use of batons in the edit line callbacks, replaces typedefs with using 
declarations, and uses unique_function instead of callbacks.  
Thanks,
Neal


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50299/new/

https://reviews.llvm.org/D50299

Files:
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb/Host/Editline.h
  lldb/source/Core/IOHandler.cpp
  lldb/source/Host/common/Editline.cpp
  lldb/unittests/Editline/EditlineTest.cpp

Index: lldb/unittests/Editline/EditlineTest.cpp
===
--- lldb/unittests/Editline/EditlineTest.cpp
+++ lldb/unittests/Editline/EditlineTest.cpp
@@ -81,8 +81,8 @@
   void ConsumeAllOutput();
 
 private:
-  static bool IsInputComplete(lldb_private::Editline *editline,
-  lldb_private::StringList &lines, void *baton);
+  bool IsInputComplete(lldb_private::Editline *editline,
+   lldb_private::StringList &lines);
 
   std::unique_ptr _editline_sp;
 
@@ -122,7 +122,10 @@
   _editline_sp->SetPrompt("> ");
 
   // Hookup our input complete callback.
-  _editline_sp->SetIsInputCompleteCallback(IsInputComplete, this);
+  auto input_complete_cb = [this](Editline *editline, StringList &lines) {
+return this->IsInputComplete(editline, lines);
+  };
+  _editline_sp->SetIsInputCompleteCallback(input_complete_cb);
 }
 
 void EditlineAdapter::CloseInput() {
@@ -183,8 +186,7 @@
 }
 
 bool EditlineAdapter::IsInputComplete(lldb_private::Editline *editline,
-  lldb_private::StringList &lines,
-  void *baton) {
+  lldb_private::StringList &lines) {
   // We'll call ourselves complete if we've received a balanced set of braces.
   int start_block_count = 0;
   int brace_balance = 0;
Index: lldb/source/Host/common/Editline.cpp
===
--- lldb/source/Host/common/Editline.cpp
+++ lldb/source/Host/common/Editline.cpp
@@ -641,8 +641,7 @@
   lines.AppendString(new_line_fragment);
 #endif
 
-  int indent_correction = m_fix_indentation_callback(
-  this, lines, 0, m_fix_indentation_callback_baton);
+  int indent_correction = m_fix_indentation_callback(this, lines, 0);
   new_line_fragment = FixIndentation(new_line_fragment, indent_correction);
   m_revert_cursor_index = GetIndentation(new_line_fragment);
 }
@@ -677,8 +676,7 @@
   info->cursor == info->lastchar) {
 if (m_is_input_complete_callback) {
   auto lines = GetInputAsStringList();
-  if (!m_is_input_complete_callback(this, lines,
-m_is_input_complete_callback_baton)) {
+  if (!m_is_input_complete_callback(this, lines)) {
 return BreakLineCommand(ch);
   }
 
@@ -811,8 +809,7 @@
 if (m_fix_indentation_callback) {
   StringList lines = GetInputAsStringList();
   lines.AppendString("");
-  indentation = m_fix_indentation_callback(
-  this, lines, 0, m_fix_indentation_callback_baton);
+  indentation = m_fix_indentation_callback(this, lines, 0);
 }
 m_input_lines.insert(
 m_input_lines.end(),
@@ -857,8 +854,8 @@
   // Save the edits and determine the correct indentation level
   SaveEditedLine();
   StringList lines = GetInputAsStringList(m_current_line_index + 1);
-  int indent_correction = m_fix_indentation_callback(
-  this, lines, cursor_position, m_fix_indentation_callback_baton);
+  int indent_correction =
+  m_fix_indentation_callback(this, lines, cursor_position);
 
   // If it is already correct no special work is needed
   if (indent_correction == 0)
@@ -977,7 +974,7 @@
 }
 
 unsigned char Editline::TabCommand(int ch) {
-  if (m_completion_callback == nullptr)
+  if (!m_completion_callback)
 return CC_ERROR;
 
   const LineInfo *line_info = el_line(m_editline);
@@ -988,7 +985,7 @@
   CompletionResult result;
   CompletionRequest request(line, cursor_index, result);
 
-  m_completion_callback(request, m_completion_callback_baton);
+  m_completion_callback(request);
 
   llvm::ArrayRef results = result.GetResults();
 
@@ -1052,7 +1049,7 @@
line_info->lastchar - line_info->buffer);
 
   if (llvm::Optional to_add =
-  m_suggestion_callback(line, m_suggestion_callback_baton))
+  m_suggestion_callback(line))
 el_insertstr(m_editline, to_add->c_str());
 
   return CC_REDISPLAY;
@@ -1066,7 +1063,7 @@
line_info->lastchar - line_info->buffer);
 
   if (llvm::Optional to_add =
-  m_suggestion_callback(line, m_suggestion_callback_baton)) {
+  m_suggestion_callback(line)) {
 std::string to_add_color = ANSI_FAINT

[Lldb-commits] [PATCH] D50299: Migrate to llvm::unique_function instead of static member functions for callbacks

2021-02-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Thanks Neal. Can you run clang-format again and upload the diff with context 
(`git diff -U`). Overall this looks pretty good.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50299/new/

https://reviews.llvm.org/D50299

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D97524: [lldb] Add deref support to libc++ unique_ptr synthetic

2021-02-25 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: teemperor, jingham, JDevlieghere.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add frame variable dereference suppport to libc++ `std::unique_ptr`.

This change allows for commands like `v *thing_up` and `v thing_up->m_id`. 
These commands now work the same way they would with raw pointers, and as they 
would with expression. This is done by adding an unaccounted for child member 
named `$$dereference$$`.

Without this change, the command would have to be written as `v 
*thing_up.__value_` or v thing_up.__value_->m_id` which exposes internal 
structure and is more clumsy to type.

Additionally, the existing tests were updated. See also 
https://reviews.llvm.org/D97165 which added deref support for `std::shared_ptr`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97524

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
@@ -1,13 +1,18 @@
-#include 
 #include 
 #include 
 
+struct User {
+  int id = 30;
+  std::string name = "steph";
+};
+
 int main() {
   std::unique_ptr up_empty;
   std::unique_ptr up_int = std::make_unique(10);
   std::unique_ptr up_str = std::make_unique("hello");
   std::unique_ptr &up_int_ref = up_int;
   std::unique_ptr &&up_int_ref_ref = std::make_unique(10);
+  std::unique_ptr up_user = std::make_unique();
 
   return 0; // break here
 }
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
@@ -3,45 +3,85 @@
 """
 
 
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
-class LibcxUniquePtrDataFormatterTestCase(TestBase):
+
+class TestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
 @add_test_categories(["libc++"])
-def test_with_run_command(self):
-"""Test that that file and class static variables display correctly."""
+def test_unique_ptr_variables(self):
+"""Test `frame variable` output for `std::unique_ptr` types."""
 self.build()
 
-(self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, '// break here',
-lldb.SBFileSpec("main.cpp", False))
+lldbutil.run_to_source_breakpoint(
+self, "// break here", lldb.SBFileSpec("main.cpp")
+)
 
-self.expect("frame variable up_empty",
-substrs=['(std::unique_ptr >) up_empty = nullptr {',
-   '__value_ = ',
-   '}'])
+valobj = self.expect_var_path(
+"up_empty",
+type="std::unique_ptr >",
+summary="nullptr",
+children=[ValueCheck(name="__value_")],
+)
+self.assertEqual(
+valobj.child[0].GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS), 0
+)
 
-self.expect("frame variable up_int",
-substrs=['(std::unique_ptr >) up_int = 10 {',
-   '__value_ = ',
-   '}'])
+self.expect(
+"frame variable *up_empty", substrs=["(int) *up_empty = "]
+)
 
-self.expect("frame variable up_int_ref",
-substrs=['(std::unique_ptr > &) up_int_ref = 10: {',
-   '__value_ = ',
-   '}'])
+valobj = self.expect_var_path(
+"up_int",
+type="std::unique_ptr >",
+summary="10",
+children=[ValueCheck(name="__value_")],
+)
+self.assertNotEqual(valobj.child[0].unsigned, 0)
 
-self.expect("frame variable up_int_ref_ref",
-substrs=['(std::unique_ptr > &&) up_int_ref_ref = 10: {',
-   '__value_ = ',
-   '}'])
+valobj = self.expect_var_path(
+"up_int_ref",
+type="std::unique_ptr > &",
+summary="10",
+ 

[Lldb-commits] [PATCH] D97524: [lldb] Add deref support to libc++ unique_ptr synthetic

2021-02-25 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

There's pretty much nothing new here compared D97165 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97524/new/

https://reviews.llvm.org/D97524

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D97524: [lldb] Add deref support to libc++ unique_ptr synthetic

2021-02-25 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97524/new/

https://reviews.llvm.org/D97524

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits