[Lldb-commits] [lldb] 7c89297 - Correct the argument list of command `breakpoint read`

2020-05-15 Thread Raphael Isemann via lldb-commits

Author: Gongyu Deng
Date: 2020-05-15T09:00:05+02:00
New Revision: 7c89297cf7eecd52327915de587df8183793afac

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

LOG: Correct the argument list of command `breakpoint read`

Summary: Command `breakpoint read` should not accept breakpoint ids as
arguments, and in fact, it is not implemented to deal with breakpoint id
arguments either. So this patch is to correct the argument list of this
command so that the help text won't misguide users.

Reviewers: teemperor, JDevlieghere, jingham

Reviewed By: teemperor, JDevlieghere

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectBreakpoint.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp 
b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index fbd96c2c5ef5..be7ef8a1b60b 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -2034,14 +2034,7 @@ class CommandObjectBreakpointRead : public 
CommandObjectParsed {
 "Read and set the breakpoints previously saved to "
 "a file with \"breakpoint write\".  ",
 nullptr),
-m_options() {
-CommandArgumentEntry arg;
-CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID,
-  eArgTypeBreakpointIDRange);
-// Add the entry for the first argument for this command to the object's
-// arguments vector.
-m_arguments.push_back(arg);
-  }
+m_options() {}
 
   ~CommandObjectBreakpointRead() override = default;
 



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


[Lldb-commits] [PATCH] D79554: [lldb/Dataformatter] Add support to CF{Dictionary, Set}Ref types

2020-05-15 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

IMHO this looks good now. Maybe add a comment to the commit that this adds 
support for incomplete types in ValueObjects.

I think @jingham should also take a look at this to make sure this makes sense.




Comment at: lldb/source/Core/ValueObjectSyntheticFilter.cpp:56
   SetName(parent.GetName());
-  CopyValueData(m_parent);
+  if (m_parent->GetCompilerType().IsCompleteType())
+CopyValueData(m_parent);

Maybe comment this line that copying the data of an incomplete type doesn't 
make sense as it has no (byte) size. (Previously this worked as our made-up 
type was empty and had a size of 0 bytes.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79554



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


[Lldb-commits] [PATCH] D79722: Correct the argument list of command `breakpoint read`

2020-05-15 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c89297cf7ee: Correct the argument list of command 
`breakpoint read` (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79722

Files:
  lldb/source/Commands/CommandObjectBreakpoint.cpp


Index: lldb/source/Commands/CommandObjectBreakpoint.cpp
===
--- lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -2034,14 +2034,7 @@
 "Read and set the breakpoints previously saved to "
 "a file with \"breakpoint write\".  ",
 nullptr),
-m_options() {
-CommandArgumentEntry arg;
-CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID,
-  eArgTypeBreakpointIDRange);
-// Add the entry for the first argument for this command to the object's
-// arguments vector.
-m_arguments.push_back(arg);
-  }
+m_options() {}
 
   ~CommandObjectBreakpointRead() override = default;
 


Index: lldb/source/Commands/CommandObjectBreakpoint.cpp
===
--- lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -2034,14 +2034,7 @@
 "Read and set the breakpoints previously saved to "
 "a file with \"breakpoint write\".  ",
 nullptr),
-m_options() {
-CommandArgumentEntry arg;
-CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID,
-  eArgTypeBreakpointIDRange);
-// Add the entry for the first argument for this command to the object's
-// arguments vector.
-m_arguments.push_back(arg);
-  }
+m_options() {}
 
   ~CommandObjectBreakpointRead() override = default;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d48ef7c - [lldb] Print full Clang diagnostics when the ClangModulesDeclVendor fails to compile a module

2020-05-15 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-05-15T10:11:03+02:00
New Revision: d48ef7cab55878fbb598e7a968b6073f9c7aa9ed

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

LOG: [lldb] Print full Clang diagnostics when the ClangModulesDeclVendor fails 
to compile a module

Summary:
When the ClangModulesDeclVendor currently fails it just prints very basic and 
often incomplete diagnostics without any source locations:
```
(lldb) p @import Foundation
error: while importing modules:
'foo/bar.h' file not found
could not build module 'Darwin'
[...]
```
or even just
```
(lldb) p @import Foundation
error: while importing modules:
could not build module 'Darwin'
[...]
```

These diagnostics help neither the user nor us with figuring out what is the 
reason for the failure.

This patch wires up a full TextDiagnosticPrinter in the ClangModulesDeclVendor 
and makes
sure we always return the error stream to the user when we fail to compile our 
modules.

Fixes rdar://63216849

Reviewers: aprantl, jdoerfert

Reviewed By: aprantl

Subscribers: JDevlieghere

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

Added: 
lldb/test/API/lang/objc/modules-compile-error/Makefile
lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
lldb/test/API/lang/objc/modules-compile-error/main.m
lldb/test/API/lang/objc/modules-compile-error/module.h
lldb/test/API/lang/objc/modules-compile-error/module.modulemap

Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 4b0521aff411..e003de519884 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -11,6 +11,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Parse/Parser.h"
@@ -54,10 +55,21 @@ class StoringDiagnosticConsumer : public 
clang::DiagnosticConsumer {
 
   void DumpDiagnostics(Stream &error_stream);
 
+  void BeginSourceFile(const clang::LangOptions &LangOpts,
+   const clang::Preprocessor *PP = nullptr) override;
+  void EndSourceFile() override;
+
 private:
   typedef std::pair
   IDAndDiagnostic;
   std::vector m_diagnostics;
+  /// The DiagnosticPrinter used for creating the full diagnostic messages
+  /// that are stored in m_diagnostics.
+  std::shared_ptr m_diag_printer;
+  /// Output stream of m_diag_printer.
+  std::shared_ptr m_os;
+  /// Output string filled by m_os. Will be reused for 
diff erent diagnostics.
+  std::string m_output;
   Log *m_log;
 };
 
@@ -116,17 +128,21 @@ class ClangModulesDeclVendorImpl : public 
ClangModulesDeclVendor {
 
 StoringDiagnosticConsumer::StoringDiagnosticConsumer() {
   m_log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
+  clang::DiagnosticOptions *m_options = new clang::DiagnosticOptions();
+  m_os.reset(new llvm::raw_string_ostream(m_output));
+  m_diag_printer.reset(new clang::TextDiagnosticPrinter(*m_os, m_options));
 }
 
 void StoringDiagnosticConsumer::HandleDiagnostic(
 clang::DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &info) {
-  llvm::SmallVector diagnostic_string;
+  // Print the diagnostic to m_output.
+  m_output.clear();
+  m_diag_printer->HandleDiagnostic(DiagLevel, info);
+  m_os->flush();
 
-  info.FormatDiagnostic(diagnostic_string);
-
-  m_diagnostics.push_back(
-  IDAndDiagnostic(DiagLevel, std::string(diagnostic_string.data(),
- diagnostic_string.size(;
+  // Store the diagnostic for later.
+  m_diagnostics.push_back(IDAndDiagnostic(DiagLevel, m_output));
 }
 
 void StoringDiagnosticConsumer::ClearDiagnostics() { m_diagnostics.clear(); }
@@ -144,6 +160,15 @@ void StoringDiagnosticConsumer::DumpDiagnostics(Stream 
&error_stream) {
   }
 }
 
+void StoringDiagnosticConsumer::BeginSourceFile(
+const clang::LangOptions &LangOpts, const clang::Preprocessor *PP) {
+  m_diag_printer->BeginSourceFile(LangOpts, PP);
+}
+
+void StoringDiagnosticConsumer::EndSourceFile() {
+  m_diag_printer->EndSourceFile();
+}
+
 ClangModulesDeclVendor::ClangModulesDeclVendor()
 : ClangDeclVendor(eClangModuleDeclVendor) {}
 

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangUse

[Lldb-commits] [PATCH] D79811: WIP: Reenable creation of artificial methods in AddMethodToCXXRecordType(...)

2020-05-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I just realized a different problem with this approach. Since the constructor 
DIE is only emitted when it is actually used, we could run into 
problems/inconsistencies even within a single library. We currently parse only 
one instance of a class description -- assuming all of them to be equivalent. 
This means that if we happen to pick the class description without the 
constructor as *the* definition for the class, then the we would still fall 
back to the (incorrect) constructor that clang generates for us. In this test 
case that could be demonstrated by having another compile unit, which only uses 
`ClassWithImplicitCtor`, but never constructs it, and then arranging it such 
that this file is picked for the class definition (probably involves putting 
this file first on the link line, or ensuring the first breakpoint hit is in 
that file).

Fixing that is going to be tricky. The best I can come up with right now, is 
injecting a constructor declaration into a class even if DWARF does not 
describe one. Then, if the user calls it, we go searching for the constructor 
symbol in the module. If we find one, we use it. If we don't, we bail out of 
the expression.

I think that approach would result in the most correct behavior, and it would 
also solve the structural equivalence issues that Greg is worried about (all 
classes would have the default constructor). However, it does have some serious 
drawbacks: The presence of a user-specified constructor (which is how this will 
appear to clang) disables certain ways of initializing the class. So for 
instance, the user would not be able to do this,

  code:
  struct Simple { int a, b, c; };
  lldb:
  p Simple() # value-initialized to zero
  p Simple{47} # compound initialization, a=47, b=c=0
  p Simple{1, 2, 3} # compount initalization with all members

That is kind of correct, since we're actually not able to differentiate the 
above class, from a class like this `struct SeeminglySimple { int a = random(), 
b = random(), c = random(); };`. However, I have a feeling it would annoy a lot 
of people. The best we could do is make the third expression work by 
synthesizing an `(int, int, int)` constructor initializing all members, as that 
will not use the default initializers (if they existed).

I have also considered the idea of trawling through all definitions of the 
class, in search of the default constructor. However:

- it's possible that no compile unit uses it, but the class still contained 
default initializers. Then, we will still get the initialization wrong.
- it won't help with partial compound initialization (second expression)
- it will slow us down (but maybe not so much with indexes, as we know the 
constructor name)

So, it does seem like some help from the compiler is called for. Maybe the 
compiler could attach a `DW_AT_default_value` with an empty expression to the 
members which have default initializers, as a way of saying "this member has a 
default initializer, but I can't/won't tell you what it is" ? Then we could 
search for this attribute and refuse constructing classes which have it. That 
would enable us to keep `p Simple{}` working, while preventing `p 
SeeminglySimple{}`.

In D79811#2037636 , @dblaikie wrote:

> In D79811#2036112 , @labath wrote:
>
> > This example also demonstrates what I believe *is* a bug in the compiler. 
> > The inherited constructor will get `DW_AT_name(A)`:
> >
> >   0x003f:   DW_TAG_structure_type
> >   DW_AT_calling_convention  (DW_CC_pass_by_value)
> >   DW_AT_name("B")
> >   DW_AT_byte_size   (0x01)
> >   DW_AT_decl_file   ("/home/pavelo/ll/build/opt/")
> >   DW_AT_decl_line   (1)
> >  
> >   0x0048: DW_TAG_inheritance
> > DW_AT_type  (0x005f "A")
> > DW_AT_data_member_location  (0x00)
> >  
> >   0x004e: DW_TAG_subprogram
> > DW_AT_name  ("A")
> > DW_AT_declaration   (true)
> > DW_AT_artificial(true)
> > DW_AT_external  (true)
> >
> >
> > That doesn't sound correct to me. Gcc emits the name as `B`, which seems to 
> > be much better. Looping in @dblaikie for thoughts.
>
>
> Agreed - sounds like a bug/something to fix in Clang there - if you'd like to 
> fix it/file a bug/etc.


Yeah, I guess should do that, before we start needing to work around this bug 
for compatibility purposes. :)


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

https://reviews.llvm.org/D79811



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


[Lldb-commits] [PATCH] D79947: [lldb] Print full Clang diagnostics when the ClangModulesDeclVendor fails to compile a module

2020-05-15 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd48ef7cab558: [lldb] Print full Clang diagnostics when the 
ClangModulesDeclVendor fails to… (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D79947?vs=263928&id=264179#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79947

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/test/API/lang/objc/modules-compile-error/Makefile
  lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
  lldb/test/API/lang/objc/modules-compile-error/main.m
  lldb/test/API/lang/objc/modules-compile-error/module.h
  lldb/test/API/lang/objc/modules-compile-error/module.modulemap

Index: lldb/test/API/lang/objc/modules-compile-error/module.modulemap
===
--- /dev/null
+++ lldb/test/API/lang/objc/modules-compile-error/module.modulemap
@@ -0,0 +1 @@
+module LLDBTestModule { header "module.h" export * }
Index: lldb/test/API/lang/objc/modules-compile-error/module.h
===
--- /dev/null
+++ lldb/test/API/lang/objc/modules-compile-error/module.h
@@ -0,0 +1,5 @@
+int foo() { return 123; }
+
+#ifndef ONLY_CLANG
+syntax_error_for_lldb_to_find // comment that tests source printing
+#endif
Index: lldb/test/API/lang/objc/modules-compile-error/main.m
===
--- /dev/null
+++ lldb/test/API/lang/objc/modules-compile-error/main.m
@@ -0,0 +1,5 @@
+@import LLDBTestModule;
+
+int main() {
+  return foo(); // break here
+}
Index: lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
===
--- /dev/null
+++ lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
@@ -0,0 +1,23 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipUnlessDarwin
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.m"))
+
+# Try importing our custom module. This will fail as LLDB won't define
+# the CLANG_ONLY define when it compiles the module for the expression
+# evaluator.
+# Check that the error message shows file/line/column, prints the relevant
+# line from the source code and mentions the module that failed to build.
+self.expect("expr @import LLDBTestModule", error=True,
+substrs=["module.h:4:1: error: unknown type name 'syntax_error_for_lldb_to_find'",
+ "syntax_error_for_lldb_to_find // comment that tests source printing",
+ "could not build module 'LLDBTestModule'"])
Index: lldb/test/API/lang/objc/modules-compile-error/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/objc/modules-compile-error/Makefile
@@ -0,0 +1,5 @@
+OBJC_SOURCES := main.m
+
+CFLAGS_EXTRAS = $(MANDATORY_MODULE_BUILD_CFLAGS) -I$(BUILDDIR) -DONLY_CLANG=1
+
+include Makefile.rules
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -347,7 +347,8 @@
   return true;
 }
 
-static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target) {
+static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target,
+DiagnosticManager &diagnostic_manager) {
   ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor();
   if (!decl_vendor)
 return;
@@ -377,8 +378,23 @@
 
   ClangModulesDeclVendor::ModuleVector modules_for_macros =
   persistent_state->GetHandLoadedClangModules();
-  decl_vendor->AddModulesForCompileUnit(*sc.comp_unit, modules_for_macros,
-error_stream);
+  if (decl_vendor->AddModulesForCompileUnit(*sc.comp_unit, modules_for_macros,
+error_stream))
+return;
+
+  // Failed to load some modules, so emit the error stream as a diagnostic.
+  if (!error_stream.Empty()) {
+// The error stream already contains several Clang diagnostics that might
+// be either errors or warnings, so just print them all as one remark
+// diagnostic to prevent that the message starts with "error: error:".
+diagnostic_manager.PutSt

[Lldb-commits] [lldb] 8b845ac - Recommit "[lldb] Don't dissasemble large functions by default"

2020-05-15 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-05-15T11:57:48+02:00
New Revision: 8b845ac5edc19524817911d703dd314aac2ca97d

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

LOG: Recommit "[lldb] Don't dissasemble large functions by default"

This recommits f665e80c023 which was reverted in 1cbd1b8f692d for breaking
TestFoundationDisassembly.py. The fix is to use --force in the test to avoid
bailing out on large functions.

I have also doubled the large function limit to 8000 bytes (~~ 2000 insns), as
the foundation library contains a lot of large-ish functions. The intent of this
feature is to prevent accidental disassembling of enormous (multi-megabyte)
"functions", not to get in people's way.

The original commit message follows:

If we have a binary without symbol information (and without
LC_FUNCTION_STARTS, if on a mac), then we have to resort to using
heuristics to determine the function boundaries. However, these don't
always work, and so we can easily end up thinking we have functions
which are several megabytes in size. Attempting to (accidentally)
disassemble these can take a very long time spam the terminal with
thousands of lines of disassembly.

This patch works around that problem by adding a sanity check to the
disassemble command. If we are about to disassemble a function which is
larger than a certain threshold, we will refuse to disassemble such a
function unless the user explicitly specifies the number of instructions
to disassemble, uses start/stop addresses for disassembly, or passes the
(new) --force argument.

The threshold is currently fairly aggressive (4000 bytes ~~ 1000
instructions). If needed, we can increase it, or even make it
configurable.

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

Added: 


Modified: 
lldb/source/Commands/CommandObjectDisassemble.cpp
lldb/source/Commands/CommandObjectDisassemble.h
lldb/source/Commands/Options.td
lldb/test/API/lang/objc/foundation/TestFoundationDisassembly.py
lldb/test/Shell/Commands/Inputs/command-disassemble.lldbinit
lldb/test/Shell/Commands/command-disassemble-process.yaml
lldb/test/Shell/Commands/command-disassemble.s

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectDisassemble.cpp 
b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 511cd6995404..cf4d8ed04f81 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -21,8 +21,9 @@
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Target.h"
 
-#define DEFAULT_DISASM_BYTE_SIZE 32
-#define DEFAULT_DISASM_NUM_INS 4
+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;
@@ -143,6 +144,10 @@ Status 
CommandObjectDisassemble::CommandOptions::SetOptionValue(
 }
   } break;
 
+  case '\x01':
+force = true;
+break;
+
   default:
 llvm_unreachable("Unimplemented option");
   }
@@ -186,6 +191,7 @@ void 
CommandObjectDisassemble::CommandOptions::OptionParsingStarting(
 
   arch.Clear();
   some_location_specified = false;
+  force = false;
 }
 
 Status CommandObjectDisassemble::CommandOptions::OptionParsingFinished(
@@ -214,6 +220,21 @@ CommandObjectDisassemble::CommandObjectDisassemble(
 
 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)
+return llvm::Error::success();
+  StreamString msg;
+  msg << "Not disassembling " << what << " because it is very large ";
+  range.Dump(&msg, &GetSelectedTarget(), Address::DumpStyleLoadAddress,
+ Address::DumpStyleFileAddress);
+  msg << ". To disassemble specify an instruction count limit, start/stop "
+ "addresses or use the --force option.";
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ msg.GetString());
+}
+
 llvm::Expected>
 CommandObjectDisassemble::GetContainingAddressRanges() {
   std::vector ranges;
@@ -254,6 +275,9 @@ CommandObjectDisassemble::GetContainingAddressRanges() {
 "Could not find function bounds for address 0x%" PRIx64,
 m_options.symbol_containing_addr);
   }
+
+  if (llvm::Error err = CheckRangeSize(ranges[0], "the function"))
+return std::move(err);
   return ranges;
 }
 
@@ -273,8 +297,10 @@ CommandObjectDisassemble::GetCurrentFunctionRanges() {
   else if (sc.symbol && sc.symbol->ValueIsAddress()) {
 range = {sc.symbol->

[Lldb-commits] [PATCH] D79554: [lldb/Dataformatter] Add support to CF{Dictionary, Set}Ref types

2020-05-15 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Core/ValueObject.cpp:2839-2861
+// In case of C opaque pointers, use the pointee type and try to
+// recreate a new ValueObjectChild using it.
+if (!m_deref_valobj) {
+  if (Language::LanguageIsCFamily(GetPreferredDisplayLanguage())) {
+if (HasSyntheticValue()) {
+
+  child_compiler_type = compiler_type.GetPointeeType();

Can this be merged with the code above? It seems like the only difference is 
the way it which we get the CompilerType.



Comment at: lldb/source/Core/ValueObject.cpp:2842
+if (!m_deref_valobj) {
+  if (Language::LanguageIsCFamily(GetPreferredDisplayLanguage())) {
+if (HasSyntheticValue()) {

What's the reason for limiting this to the C family? It seems like one could 
want to have a pretty printer for incomplete types in any language...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79554



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


[Lldb-commits] [lldb] 36b9b1e - [lldb] Fixup command-disassemble-process.yaml test

2020-05-15 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-05-15T12:35:44+02:00
New Revision: 36b9b1e6171d438105839aac6f333a1c98fda74c

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

LOG: [lldb] Fixup command-disassemble-process.yaml test

Increase the function size to account for the changed threshold in
8b845ac5edc1.

Added: 


Modified: 
lldb/test/Shell/Commands/command-disassemble-process.yaml

Removed: 




diff  --git a/lldb/test/Shell/Commands/command-disassemble-process.yaml 
b/lldb/test/Shell/Commands/command-disassemble-process.yaml
index e9db8e8e64b2..60c8ac0c569e 100644
--- a/lldb/test/Shell/Commands/command-disassemble-process.yaml
+++ b/lldb/test/Shell/Commands/command-disassemble-process.yaml
@@ -1,7 +1,7 @@
 # REQUIRES: x86
 
 # RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8 %s > 
%T/command-disassemble-process.exe
-# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=4000 %s > 
%T/command-disassemble-process.big.exe
+# RUN: yaml2obj --docnum=1 -DMAIN_SIZE=8000 %s > 
%T/command-disassemble-process.big.exe
 # RUN: yaml2obj --docnum=2 %s > %t
 
 # RUN: %lldb -c %t %T/command-disassemble-process.exe \
@@ -63,7 +63,7 @@
 # CHECK-NEXT: 0x400e:  addb   %cl, (%rcx)
 # CHECK-NEXT: 0x4010:  addb   %cl, (%rdx)
 
-# BIG: error: Not disassembling the current function because it is very large 
[0x4002-0x4fa2). To disassemble specify an instruction 
count limit, start/stop addresses or use the --force option.
+# BIG: error: Not disassembling the current function because it is very large 
[0x4002-0x5f42). To disassemble specify an instruction 
count limit, start/stop addresses or use the --force option.
 
 --- !ELF
 FileHeader:  



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


[Lldb-commits] [PATCH] D79999: [lldb] [Windows] Provide vasprintf only for MSVC

2020-05-15 Thread Mateusz Mikuła via Phabricator via lldb-commits
mati865 created this revision.
mati865 added a project: LLDB.

Mingw-w64 provides this function and it has been causing issues for MSYS2 when 
building lldb.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D7

Files:
  lldb/include/lldb/Host/windows/PosixApi.h
  lldb/source/Host/windows/Windows.cpp


Index: lldb/source/Host/windows/Windows.cpp
===
--- lldb/source/Host/windows/Windows.cpp
+++ lldb/source/Host/windows/Windows.cpp
@@ -42,28 +42,6 @@
 }
 }
 
-int vasprintf(char **ret, const char *fmt, va_list ap) {
-  char *buf;
-  int len;
-  size_t buflen;
-  va_list ap2;
-
-  va_copy(ap2, ap);
-  len = vsnprintf(NULL, 0, fmt, ap2);
-
-  if (len >= 0 &&
-  (buf = (char *)malloc((buflen = (size_t)(len + 1 != NULL) {
-len = vsnprintf(buf, buflen, fmt, ap);
-*ret = buf;
-  } else {
-*ret = NULL;
-len = -1;
-  }
-
-  va_end(ap2);
-  return len;
-}
-
 char *strcasestr(const char *s, const char *find) {
   char c, sc;
   size_t len;
@@ -194,6 +172,28 @@
   return strnicmp(s1, s2, n);
 }
 
+int vasprintf(char **ret, const char *fmt, va_list ap) {
+  char *buf;
+  int len;
+  size_t buflen;
+  va_list ap2;
+
+  va_copy(ap2, ap);
+  len = vsnprintf(NULL, 0, fmt, ap2);
+
+  if (len >= 0 &&
+  (buf = (char *)malloc((buflen = (size_t)(len + 1 != NULL) {
+len = vsnprintf(buf, buflen, fmt, ap);
+*ret = buf;
+  } else {
+*ret = NULL;
+len = -1;
+  }
+
+  va_end(ap2);
+  return len;
+}
+
 #if _MSC_VER < 1900
 namespace lldb_private {
 int vsnprintf(char *buffer, size_t count, const char *format, va_list argptr) {
Index: lldb/include/lldb/Host/windows/PosixApi.h
===
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -96,7 +96,6 @@
 
 // Various useful posix functions that are not present in Windows.  We provide
 // custom implementations.
-int vasprintf(char **ret, const char *fmt, va_list ap);
 char *strcasestr(const char *s, const char *find);
 char *realpath(const char *name, char *resolved);
 
@@ -108,6 +107,8 @@
 int strcasecmp(const char *s1, const char *s2);
 int strncasecmp(const char *s1, const char *s2, size_t n);
 
+int vasprintf(char **ret, const char *fmt, va_list ap);
+
 #endif // _MSC_VER
 
 // empty functions


Index: lldb/source/Host/windows/Windows.cpp
===
--- lldb/source/Host/windows/Windows.cpp
+++ lldb/source/Host/windows/Windows.cpp
@@ -42,28 +42,6 @@
 }
 }
 
-int vasprintf(char **ret, const char *fmt, va_list ap) {
-  char *buf;
-  int len;
-  size_t buflen;
-  va_list ap2;
-
-  va_copy(ap2, ap);
-  len = vsnprintf(NULL, 0, fmt, ap2);
-
-  if (len >= 0 &&
-  (buf = (char *)malloc((buflen = (size_t)(len + 1 != NULL) {
-len = vsnprintf(buf, buflen, fmt, ap);
-*ret = buf;
-  } else {
-*ret = NULL;
-len = -1;
-  }
-
-  va_end(ap2);
-  return len;
-}
-
 char *strcasestr(const char *s, const char *find) {
   char c, sc;
   size_t len;
@@ -194,6 +172,28 @@
   return strnicmp(s1, s2, n);
 }
 
+int vasprintf(char **ret, const char *fmt, va_list ap) {
+  char *buf;
+  int len;
+  size_t buflen;
+  va_list ap2;
+
+  va_copy(ap2, ap);
+  len = vsnprintf(NULL, 0, fmt, ap2);
+
+  if (len >= 0 &&
+  (buf = (char *)malloc((buflen = (size_t)(len + 1 != NULL) {
+len = vsnprintf(buf, buflen, fmt, ap);
+*ret = buf;
+  } else {
+*ret = NULL;
+len = -1;
+  }
+
+  va_end(ap2);
+  return len;
+}
+
 #if _MSC_VER < 1900
 namespace lldb_private {
 int vsnprintf(char *buffer, size_t count, const char *format, va_list argptr) {
Index: lldb/include/lldb/Host/windows/PosixApi.h
===
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -96,7 +96,6 @@
 
 // Various useful posix functions that are not present in Windows.  We provide
 // custom implementations.
-int vasprintf(char **ret, const char *fmt, va_list ap);
 char *strcasestr(const char *s, const char *find);
 char *realpath(const char *name, char *resolved);
 
@@ -108,6 +107,8 @@
 int strcasecmp(const char *s1, const char *s2);
 int strncasecmp(const char *s1, const char *s2, size_t n);
 
+int vasprintf(char **ret, const char *fmt, va_list ap);
+
 #endif // _MSC_VER
 
 // empty functions
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 76c5f27 - Re-land [Debug][CodeView] Emit fully qualified names for globals

2020-05-15 Thread Alexandre Ganea via lldb-commits

Author: Alexandre Ganea
Date: 2020-05-15T10:37:09-04:00
New Revision: 76c5f277f25e334404aa44ea0aafd674a627ab74

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

LOG: Re-land [Debug][CodeView] Emit fully qualified names for globals

Before this patch, S_[L|G][THREAD32|DATA32] records were emitted with a simple 
name, not the fully qualified name (namespace + class scope).

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

Added: 


Modified: 
lldb/test/Shell/SymbolFile/PDB/variables.test
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
llvm/test/DebugInfo/COFF/global-constants.ll
llvm/test/DebugInfo/COFF/global_visibility.ll
llvm/test/DebugInfo/COFF/globals.ll
llvm/test/DebugInfo/COFF/types-array-unsized.ll

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/PDB/variables.test 
b/lldb/test/Shell/SymbolFile/PDB/variables.test
index ae14f02754ce..a6c715360958 100644
--- a/lldb/test/Shell/SymbolFile/PDB/variables.test
+++ b/lldb/test/Shell/SymbolFile/PDB/variables.test
@@ -13,12 +13,12 @@ GLOBALS: SymbolFile pdb ([[MOD]])
 GLOBALS: CompileUnit{{.*}}, language = "c++", file = 
'{{.*}}\VariablesTest.cpp'
 GLOBALS-DAG:   Variable{{.*}}, name = "g_IntVar"
 GLOBALS-SAME:  scope = global, location = {{.*}}, external
-GLOBALS-DAG:   Variable{{.*}}, name = "m_StaticClassMember"
-GLOBALS-SAME:  scope = global, location = {{.*}}, external
 GLOBALS-DAG:   Variable{{.*}}, name = "g_pConst"
 GLOBALS-SAME:  scope = global, location = {{.*}}, external
 GLOBALS-DAG:   Variable{{.*}}, name = "same_name_var"
 GLOBALS-SAME:  scope = global, location = {{.*}}, external
+GLOBALS-DAG:   Variable{{.*}}, name = "Class::m_StaticClassMember"
+GLOBALS-SAME:  scope = global, location = {{.*}}, external
 GLOBALS-DAG:   Variable{{.*}}, name = "g_EnumVar"
 GLOBALS-SAME:  scope = global, location = {{.*}}, external
 GLOBALS-DAG:   Variable{{.*}}, name = "g_tls"

diff  --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index f167cead4e2c..6f75dbd889fe 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -343,18 +343,6 @@ static std::string formatNestedName(ArrayRef 
QualifiedNameComponents,
   return FullyQualifiedName;
 }
 
-std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
- StringRef Name) {
-  SmallVector QualifiedNameComponents;
-  collectParentScopeNames(Scope, QualifiedNameComponents);
-  return formatNestedName(QualifiedNameComponents, Name);
-}
-
-std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Ty) {
-  const DIScope *Scope = Ty->getScope();
-  return getFullyQualifiedName(Scope, getPrettyScopeName(Ty));
-}
-
 struct CodeViewDebug::TypeLoweringScope {
   TypeLoweringScope(CodeViewDebug &CVD) : CVD(CVD) { ++CVD.TypeEmissionLevel; }
   ~TypeLoweringScope() {
@@ -367,6 +355,22 @@ struct CodeViewDebug::TypeLoweringScope {
   CodeViewDebug &CVD;
 };
 
+std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Scope,
+ StringRef Name) {
+  // Ensure types in the scope chain are emitted as soon as possible.
+  // This can create otherwise a situation where S_UDTs are emitted while
+  // looping in emitDebugInfoForUDTs.
+  TypeLoweringScope S(*this);
+  SmallVector QualifiedNameComponents;
+  collectParentScopeNames(Scope, QualifiedNameComponents);
+  return formatNestedName(QualifiedNameComponents, Name);
+}
+
+std::string CodeViewDebug::getFullyQualifiedName(const DIScope *Ty) {
+  const DIScope *Scope = Ty->getScope();
+  return getFullyQualifiedName(Scope, getPrettyScopeName(Ty));
+}
+
 TypeIndex CodeViewDebug::getScopeIndex(const DIScope *Scope) {
   // No scope means global scope and that uses the zero index.
   if (!Scope || isa(Scope))
@@ -2981,10 +2985,16 @@ void CodeViewDebug::emitEndSymbolRecord(SymbolKind 
EndKind) {
 }
 
 void CodeViewDebug::emitDebugInfoForUDTs(
-ArrayRef> UDTs) {
+const std::vector> &UDTs) {
+#ifndef NDEBUG
+  size_t OriginalSize = UDTs.size();
+#endif
   for (const auto &UDT : UDTs) {
 const DIType *T = UDT.second;
 assert(shouldEmitUdt(T));
+// Ensure no new types are discovered when executing the code below.
+// See discussion in https://reviews.llvm.org/D79512
+assert(OriginalSize == UDTs.size());
 
 MCSymbol *UDTRecordEnd = beginSymbolRecord(SymbolKind::S_UDT);
 OS.AddComment("Type");
@@ -3092,6 +3102,14 @@ void 
CodeViewDebug::emitGlobalVariableList(ArrayRef Globals) {
 
 void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) {
   const DIGlobalVariable *DIGV = CVGV.DIGV;
+
+  const DIScope *Scope 

[Lldb-commits] [PATCH] D79447: [Debug][CodeView] Emit fully qualified names for globals

2020-05-15 Thread Alexandre Ganea via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
aganea marked 4 inline comments as done.
Closed by commit rG76c5f277f25e: Re-land [Debug][CodeView] Emit fully qualified 
names for globals (authored by aganea).

Changed prior to commit:
  https://reviews.llvm.org/D79447?vs=263450&id=264248#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79447

Files:
  lldb/test/Shell/SymbolFile/PDB/variables.test
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
  llvm/test/DebugInfo/COFF/global-constants.ll
  llvm/test/DebugInfo/COFF/global_visibility.ll
  llvm/test/DebugInfo/COFF/globals.ll
  llvm/test/DebugInfo/COFF/types-array-unsized.ll

Index: llvm/test/DebugInfo/COFF/types-array-unsized.ll
===
--- llvm/test/DebugInfo/COFF/types-array-unsized.ll
+++ llvm/test/DebugInfo/COFF/types-array-unsized.ll
@@ -4,7 +4,7 @@
 ; We should emit two array types: one used to describe the static data member,
 ; and the other used by the S_GDATA32 for the definition.
 
-; C++ source:
+; // Build with: clang-cl a.cpp /c /Z7 /clang:-S /clang:-emit-llvm
 ; struct Foo {
 ;   static const char str[];
 ; };
@@ -12,13 +12,6 @@
 ; Foo f; // FIXME: only needed to force emit 'Foo'
 
 ; CHECK:  CodeViewTypes [
-; CHECK:Array ([[ARRAY_COMPLETE:0x.*]]) {
-; CHECK-NEXT: TypeLeafKind: LF_ARRAY (0x1503)
-; CHECK-NEXT: ElementType: const char ({{.*}})
-; CHECK-NEXT: IndexType: unsigned __int64 (0x23)
-; CHECK-NEXT: SizeOf: 5
-; CHECK-NEXT: Name: 
-; CHECK-NEXT:   }
 ; CHECK:Array ([[ARRAY_FWD:0x.*]]) {
 ; CHECK-NEXT: TypeLeafKind: LF_ARRAY (0x1503)
 ; CHECK-NEXT: ElementType: const char ({{.*}})
@@ -26,7 +19,7 @@
 ; CHECK-NEXT: SizeOf: 0
 ; CHECK-NEXT: Name: 
 ; CHECK-NEXT:   }
-; CHECK:FieldList (0x1004) {
+; CHECK:FieldList (0x1003) {
 ; CHECK-NEXT: TypeLeafKind: LF_FIELDLIST (0x1203)
 ; CHECK-NEXT: StaticDataMember {
 ; CHECK-NEXT:   TypeLeafKind: LF_STMEMBER (0x150E)
@@ -35,39 +28,47 @@
 ; CHECK-NEXT:   Name: str
 ; CHECK-NEXT: }
 ; CHECK-NEXT:   }
+; CHECK:Array ([[ARRAY_COMPLETE:0x.*]]) {
+; CHECK-NEXT: TypeLeafKind: LF_ARRAY (0x1503)
+; CHECK-NEXT: ElementType: const char ({{.*}})
+; CHECK-NEXT: IndexType: unsigned __int64 (0x23)
+; CHECK-NEXT: SizeOf: 5
+; CHECK-NEXT: Name: 
+; CHECK-NEXT:   }
 ; CHECK:  ]
 
 ; CHECK:  GlobalData {
 ; CHECK-NEXT:   Kind: S_GDATA32 (0x110D)
 ; CHECK-NEXT:   DataOffset: ?str@Foo@@2QBDB+0x0
 ; CHECK-NEXT:   Type: [[ARRAY_COMPLETE]]
-; CHECK-NEXT:   DisplayName: str
+; CHECK-NEXT:   DisplayName: Foo::str
 ; CHECK-NEXT:   LinkageName: ?str@Foo@@2QBDB
 ; CHECK-NEXT: }
 
-; ModuleID = 't.cpp'
-source_filename = "t.cpp"
-target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-windows-msvc19.0.24215"
+; ModuleID = 'a.cpp'
+source_filename = "a.cpp"
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.25.28614"
 
 %struct.Foo = type { i8 }
 
-@"\01?str@Foo@@2QBDB" = constant [5 x i8] c"asdf\00", align 1, !dbg !0
-@"\01?f@@3UFoo@@A" = global %struct.Foo zeroinitializer, align 1, !dbg !6
+@"?str@Foo@@2QBDB" = dso_local constant [5 x i8] c"asdf\00", align 1, !dbg !0
+@"?f@@3UFoo@@A" = dso_local global %struct.Foo zeroinitializer, align 1, !dbg !6
 
 !llvm.dbg.cu = !{!2}
-!llvm.module.flags = !{!19, !20, !21, !22}
-!llvm.ident = !{!23}
+!llvm.linker.options = !{!19, !20}
+!llvm.module.flags = !{!21, !22, !23, !24}
+!llvm.ident = !{!25}
 
 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
-!1 = distinct !DIGlobalVariable(name: "str", linkageName: "\01?str@Foo@@2QBDB", scope: !2, file: !3, line: 4, type: !16, isLocal: false, isDefinition: true, declaration: !10)
-!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 6.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
-!3 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "15aa843c5a80301928caf03e71f87a54")
+!1 = distinct !DIGlobalVariable(name: "str", linkageName: "?str@Foo@@2QBDB", scope: !2, file: !3, line: 4, type: !16, isLocal: false, isDefinition: true, declaration: !10)
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 202f144bffd0be254a829924195e1b8ebabcbb79)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)
+!3 = !DIFile(filename: "a.cpp", directory: "F:\\llvm-project\\__test", checksumkind: CSK_MD5, checksum: "c2b2d28fd8aaa040c4141cea420d0648")
 !4 = !{}
 !5 = !{!0, !6

[Lldb-commits] [PATCH] D79659: [lldb/Commands] Add ability to run shell command on the host.

2020-05-15 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 264270.
mib marked 2 inline comments as done.
mib added a comment.

Merged the `shell` and `platform shell` test as @JDevlieghere suggested it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79659

Files:
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/Options.td
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/test/API/commands/platform/basic/TestPlatformCommand.py

Index: lldb/test/API/commands/platform/basic/TestPlatformCommand.py
===
--- lldb/test/API/commands/platform/basic/TestPlatformCommand.py
+++ lldb/test/API/commands/platform/basic/TestPlatformCommand.py
@@ -18,6 +18,12 @@
 def test_help_platform(self):
 self.runCmd("help platform")
 
+@no_debug_info_test
+def test_help_platform(self):
+self.expect("help shell", substrs=["Run a shell command on the host.",
+   "shell "])
+
+
 @no_debug_info_test
 def test_list(self):
 self.expect("platform list",
@@ -55,6 +61,7 @@
 self.expect(
 "platform shell dir c:\\", substrs=[
 "Windows", "Program Files"])
+self.expect("shell dir c:\\", substrs=["Windows", "Program Files"])
 elif re.match(".*-.*-.*-android", triple):
 self.expect(
 "platform shell ls /",
@@ -62,19 +69,26 @@
 "cache",
 "dev",
 "system"])
+self.expect("shell ls /",
+substrs=["cache", "dev", "system"])
 else:
 self.expect("platform shell ls /", substrs=["dev", "tmp", "usr"])
+self.expect("shell ls /", substrs=["dev", "tmp", "usr"])
 
 @no_debug_info_test
 def test_shell_builtin(self):
 """ Test a shell built-in command (echo) """
 self.expect("platform shell echo hello lldb",
 substrs=["hello lldb"])
+self.expect("shell echo hello lldb",
+substrs=["hello lldb"])
+
 
-# FIXME: re-enable once platform shell -t can specify the desired timeout
 @no_debug_info_test
 def test_shell_timeout(self):
 """ Test a shell built-in command (sleep) that times out """
-self.skipTest("due to taking too long to complete.")
-self.expect("platform shell sleep 15", error=True, substrs=[
+self.skipTest("Alias with option not supported by the command interpreter.")
+self.expect("platform shell -t 1 -- sleep 15", error=True, substrs=[
+"error: timed out waiting for shell command to complete"])
+self.expect("shell -t 1 --  sleep 3", error=True, substrs=[
 "error: timed out waiting for shell command to complete"])
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -381,6 +381,16 @@
 }
   }
 
+  cmd_obj_sp = GetCommandSPExact("platform shell", false);
+  if (cmd_obj_sp) {
+CommandAlias *shell_alias = AddAlias("shell", cmd_obj_sp, " --host --");
+if (shell_alias) {
+  shell_alias->SetHelp("Run a shell command on the host.");
+  shell_alias->SetHelpLong("");
+  shell_alias->SetSyntax("shell ");
+}
+  }
+
   cmd_obj_sp = GetCommandSPExact("process kill", false);
   if (cmd_obj_sp) {
 AddAlias("kill", cmd_obj_sp);
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -622,6 +622,8 @@
 }
 
 let Command = "platform shell" in {
+  def platform_shell_host : Option<"host", "h">,
+Desc<"Run the commands on the host shell when enabled.">;
   def platform_shell_timeout : Option<"timeout", "t">, Arg<"Value">,
 Desc<"Seconds to wait for the remote host to finish running the command.">;
 }
@@ -701,6 +703,7 @@
 Desc<"Set the synchronicity of this command's executions with regard to "
 "LLDB event system.">;
 }
+
 let Command = "source info" in {
   def source_info_count : Option<"count", "c">, Arg<"Count">,
 Desc<"The number of line entries to display.">;
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1567,6 +1567,9 @@
   const char short_option = (char)GetDefinitions()[option_idx].short_option;
 
   switch (short_option) {
+  case 'h':
+m_use_host_platform = true;
+break;
   case 't':
 uint32_t timeout_sec;
 if (option_arg.getAsInteger(10, timeout_sec))
@@ -1574,7 +1577,7 @@
 

[Lldb-commits] [PATCH] D79999: [lldb] [Windows] Provide vasprintf only for MSVC

2020-05-15 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added reviewers: labath, amccarth, mstorsjo.
mstorsjo added a comment.

+1 from me on this, I'm ok with this change. I'm a bit curious as I haven't 
seen any issues regarding this myself though. I wonder if it something very 
MSYS2-specific, or is the difference in building with gcc vs clang?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[Lldb-commits] [PATCH] D79999: [lldb] [Windows] Provide vasprintf only for MSVC

2020-05-15 Thread Mateusz Mikuła via Phabricator via lldb-commits
mati865 added a comment.

Perhaps you are building with Clang?
I don't remember the message but GCC emits error about incompatible definition 
and declaration of `vasprintf`. I can build it without the patch and paste the 
error if you want.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[Lldb-commits] [PATCH] D79999: [lldb] [Windows] Provide vasprintf only for MSVC

2020-05-15 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D7#2039069 , @mati865 wrote:

> Perhaps you are building with Clang?
>  I don't remember the message but GCC emits error about incompatible 
> definition and declaration of `vasprintf`. I can build it without the patch 
> and paste the error if you want.


I took a look now, and I see that the mingw-w64 `vasprintf` only is visible if 
`_GNU_SOURCE` is defined. So apparently something is setting that in your 
build, but not in mine - and thus this patch would actually break my build...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[Lldb-commits] [PATCH] D79999: [lldb] [Windows] Provide vasprintf only for MSVC

2020-05-15 Thread Mateusz Mikuła via Phabricator via lldb-commits
mati865 added a comment.

Indeed, I'll see if I can build all LLVM related packages without 
`_GNU_SOURCE`. Otherwise I'll guard it with `#ifndef _GNU_SOURCE` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[Lldb-commits] [PATCH] D79659: [lldb/Commands] Add ability to run shell command on the host.

2020-05-15 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

LGTM




Comment at: lldb/source/Commands/CommandObjectPlatform.cpp:1590
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  m_use_host_platform = false;
+}

Should we reset the timeout too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79659



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


[Lldb-commits] [lldb] 0eba9de - [lldb/Dataformatter] Add support to CF{Dictionary, Set}Ref types

2020-05-15 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-05-15T22:14:39+02:00
New Revision: 0eba9de71e2add37dce165f3f3c9447772c3f65a

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

LOG: [lldb/Dataformatter] Add support to CF{Dictionary,Set}Ref types

This patch improves data formatting for CFDictionaryRef and CFSetRef.
It uses the same data-formatter as NSCFDictionaries and NSCFSets introduced
previously but did require some adjustments in Core::ValueObject.

Since the "Ref" types are opaque pointers to the actual CF containers, if the
value object has a synthetic value, lldb will use the opaque pointer's pointee
type to create the new ValueObjectChild needed to dereference the ValueObject.
This allows the "Ref" types to behaves the same as CF containers when used with
the `frame variable` command, the SBAPI or in Xcode's variable inspector.

This patch also adds support for incomplete types in ValueObject.

rdar://53104287

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Core/ValueObject.cpp
lldb/source/Core/ValueObjectSyntheticFilter.cpp
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
lldb/source/Plugins/Language/ObjC/NSSet.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m

Removed: 




diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index 59bd0c0209b6..3a6ca522f308 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -687,6 +687,11 @@ ValueObject *ValueObject::CreateChildAtIndex(size_t idx,
 language_flags);
   }
 
+  if (!valobj && synthetic_array_member)
+valobj = GetSyntheticValue()
+ ->GetChildAtIndex(synthetic_index, synthetic_array_member)
+ .get();
+
   return valobj;
 }
 
@@ -2824,6 +2829,27 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
   child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
   language_flags);
 }
+
+// In case of incomplete child compiler type, use the pointee type and try
+// to recreate a new ValueObjectChild using it.
+if (!m_deref_valobj) {
+  if (HasSyntheticValue()) {
+child_compiler_type = compiler_type.GetPointeeType();
+
+if (child_compiler_type) {
+  ConstString child_name;
+  if (!child_name_str.empty())
+child_name.SetCString(child_name_str.c_str());
+
+  m_deref_valobj = new ValueObjectChild(
+  *this, child_compiler_type, child_name, child_byte_size,
+  child_byte_offset, child_bitfield_bit_size,
+  child_bitfield_bit_offset, child_is_base_class,
+  child_is_deref_of_parent, eAddressTypeInvalid, language_flags);
+}
+  }
+}
+
   } else if (HasSyntheticValue()) {
 m_deref_valobj =
 GetSyntheticValue()

diff  --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp 
b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
index 9ca9513aa583..32d1e6ab8368 100644
--- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
@@ -53,7 +53,9 @@ ValueObjectSynthetic::ValueObjectSynthetic(ValueObject 
&parent,
   m_might_have_children(eLazyBoolCalculate),
   m_provides_value(eLazyBoolCalculate) {
   SetName(parent.GetName());
-  CopyValueData(m_parent);
+  // Copying the data of an incomplete type won't work as it has no byte size.
+  if (m_parent->GetCompilerType().IsCompleteType())
+CopyValueData(m_parent);
   CreateSynthFilter();
 }
 
@@ -219,7 +221,9 @@ bool ValueObjectSynthetic::UpdateValue() {
   GetName().AsCString());
 
 m_provides_value = eLazyBoolNo;
-CopyValueData(m_parent);
+// Copying the data of an incomplete type won't work as it has no byte 
size.
+if (m_parent->GetCompilerType().IsCompleteType())
+  CopyValueData(m_parent);
   }
 
   SetValueIsValid(true);

diff  --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp 
b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index 998c72e429e7..e4e51de9ddfc 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -408,7 +408,8 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
   static const ConstString g_DictionaryMImmutable("__NSDictionaryM_Immutable");
   static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI");
   static const ConstString g_Dictionary0("__NSDictionary0");
-  static const ConstString g_DictionaryCF("__NSCFDictionary");
+  stati

[Lldb-commits] [lldb] 4e9e048 - [lldb/Commands] Add ability to run shell command on the host.

2020-05-15 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2020-05-15T22:14:39+02:00
New Revision: 4e9e0488ab67c54be57e303ce3085466fbc8e886

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

LOG: [lldb/Commands] Add ability to run shell command on the host.

This patch introduces the `(-h|--host)` option to the `platform shell`
command. It allows the user to run shell commands from the host platform
(always available) without putting lldb in the background.

Since the default behaviour of `platform shell` is to run the command of
the selected platform, having such a choice can be quite handy when
debugging remote targets, for instances.

This patch also introduces a `shell` alias, to improve the command
discoverability and make it more convenient to use for the user.

rdar://62856024

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Commands/Options.td
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/test/API/commands/platform/basic/TestPlatformCommand.py

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectPlatform.cpp 
b/lldb/source/Commands/CommandObjectPlatform.cpp
index 5a6573307c61..4b19592af75a 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1567,6 +1567,9 @@ class CommandObjectPlatformShell : public 
CommandObjectRaw {
   const char short_option = 
(char)GetDefinitions()[option_idx].short_option;
 
   switch (short_option) {
+  case 'h':
+m_use_host_platform = true;
+break;
   case 't':
 uint32_t timeout_sec;
 if (option_arg.getAsInteger(10, timeout_sec))
@@ -1574,7 +1577,7 @@ class CommandObjectPlatformShell : public 
CommandObjectRaw {
   "could not convert \"%s\" to a numeric value.",
   option_arg.str().c_str());
 else
-  timeout = std::chrono::seconds(timeout_sec);
+  m_timeout = std::chrono::seconds(timeout_sec);
 break;
   default:
 llvm_unreachable("Unimplemented option");
@@ -1583,9 +1586,13 @@ class CommandObjectPlatformShell : public 
CommandObjectRaw {
   return error;
 }
 
-void OptionParsingStarting(ExecutionContext *execution_context) override {}
+void OptionParsingStarting(ExecutionContext *execution_context) override {
+  m_timeout.reset();
+  m_use_host_platform = false;
+}
 
-Timeout timeout = std::chrono::seconds(10);
+Timeout m_timeout = std::chrono::seconds(10);
+bool m_use_host_platform;
   };
 
   CommandObjectPlatformShell(CommandInterpreter &interpreter)
@@ -1609,6 +1616,7 @@ class CommandObjectPlatformShell : public 
CommandObjectRaw {
   return true;
 }
 
+const bool is_alias = !raw_command_line.contains("platform");
 OptionsWithRaw args(raw_command_line);
 const char *expr = args.GetRawPart().c_str();
 
@@ -1616,8 +1624,16 @@ class CommandObjectPlatformShell : public 
CommandObjectRaw {
   if (!ParseOptions(args.GetArgs(), result))
 return false;
 
+if (args.GetRawPart().empty()) {
+  result.GetOutputStream().Printf("%s \n",
+  is_alias ? "shell" : "platform shell");
+  return false;
+}
+
 PlatformSP platform_sp(
-GetDebugger().GetPlatformList().GetSelectedPlatform());
+m_options.m_use_host_platform
+? Platform::GetHostPlatform()
+: GetDebugger().GetPlatformList().GetSelectedPlatform());
 Status error;
 if (platform_sp) {
   FileSpec working_dir{};
@@ -1625,7 +1641,7 @@ class CommandObjectPlatformShell : public 
CommandObjectRaw {
   int status = -1;
   int signo = -1;
   error = (platform_sp->RunShellCommand(expr, working_dir, &status, &signo,
-&output, m_options.timeout));
+&output, m_options.m_timeout));
   if (!output.empty())
 result.GetOutputStream().PutCString(output);
   if (status > 0) {

diff  --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index addfec53b39c..d6f1e0a3c96d 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -624,6 +624,8 @@ let Command = "platform process attach" in {
 }
 
 let Command = "platform shell" in {
+  def platform_shell_host : Option<"host", "h">,
+Desc<"Run the commands on the host shell when enabled.">;
   def platform_shell_timeout : Option<"timeout", "t">, Arg<"Value">,
 Desc<"Seconds to wait for the remote host to finish running the command.">;
 }
@@ -703,6 +705,7 @@ let Command = "script add" in {
 Desc<"Set the synchronicity of this com

[Lldb-commits] [PATCH] D79659: [lldb/Commands] Add ability to run shell command on the host.

2020-05-15 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
mib marked an inline comment as done.
Closed by commit rG4e9e0488ab67: [lldb/Commands] Add ability to run shell 
command on the host. (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D79659?vs=264270&id=264333#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79659

Files:
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/Options.td
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/test/API/commands/platform/basic/TestPlatformCommand.py

Index: lldb/test/API/commands/platform/basic/TestPlatformCommand.py
===
--- lldb/test/API/commands/platform/basic/TestPlatformCommand.py
+++ lldb/test/API/commands/platform/basic/TestPlatformCommand.py
@@ -19,6 +19,12 @@
 self.runCmd("help platform")
 
 @no_debug_info_test
+def test_help_platform(self):
+self.expect("help shell", substrs=["Run a shell command on the host.",
+   "shell "])
+
+
+@no_debug_info_test
 def test_list(self):
 self.expect("platform list",
 patterns=['^Available platforms:'])
@@ -55,6 +61,7 @@
 self.expect(
 "platform shell dir c:\\", substrs=[
 "Windows", "Program Files"])
+self.expect("shell dir c:\\", substrs=["Windows", "Program Files"])
 elif re.match(".*-.*-.*-android", triple):
 self.expect(
 "platform shell ls /",
@@ -62,19 +69,26 @@
 "cache",
 "dev",
 "system"])
+self.expect("shell ls /",
+substrs=["cache", "dev", "system"])
 else:
 self.expect("platform shell ls /", substrs=["dev", "tmp", "usr"])
+self.expect("shell ls /", substrs=["dev", "tmp", "usr"])
 
 @no_debug_info_test
 def test_shell_builtin(self):
 """ Test a shell built-in command (echo) """
 self.expect("platform shell echo hello lldb",
 substrs=["hello lldb"])
+self.expect("shell echo hello lldb",
+substrs=["hello lldb"])
+
 
-# FIXME: re-enable once platform shell -t can specify the desired timeout
 @no_debug_info_test
 def test_shell_timeout(self):
 """ Test a shell built-in command (sleep) that times out """
-self.skipTest("due to taking too long to complete.")
-self.expect("platform shell sleep 15", error=True, substrs=[
+self.skipTest("Alias with option not supported by the command interpreter.")
+self.expect("platform shell -t 1 -- sleep 15", error=True, substrs=[
+"error: timed out waiting for shell command to complete"])
+self.expect("shell -t 1 --  sleep 3", error=True, substrs=[
 "error: timed out waiting for shell command to complete"])
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -381,6 +381,16 @@
 }
   }
 
+  cmd_obj_sp = GetCommandSPExact("platform shell", false);
+  if (cmd_obj_sp) {
+CommandAlias *shell_alias = AddAlias("shell", cmd_obj_sp, " --host --");
+if (shell_alias) {
+  shell_alias->SetHelp("Run a shell command on the host.");
+  shell_alias->SetHelpLong("");
+  shell_alias->SetSyntax("shell ");
+}
+  }
+
   cmd_obj_sp = GetCommandSPExact("process kill", false);
   if (cmd_obj_sp) {
 AddAlias("kill", cmd_obj_sp);
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -624,6 +624,8 @@
 }
 
 let Command = "platform shell" in {
+  def platform_shell_host : Option<"host", "h">,
+Desc<"Run the commands on the host shell when enabled.">;
   def platform_shell_timeout : Option<"timeout", "t">, Arg<"Value">,
 Desc<"Seconds to wait for the remote host to finish running the command.">;
 }
@@ -703,6 +705,7 @@
 Desc<"Set the synchronicity of this command's executions with regard to "
 "LLDB event system.">;
 }
+
 let Command = "source info" in {
   def source_info_count : Option<"count", "c">, Arg<"Count">,
 Desc<"The number of line entries to display.">;
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1567,6 +1567,9 @@
   const char short_option = (char)GetDefinitions()[option_idx].short_option;
 
  

[Lldb-commits] [PATCH] D79554: [lldb/Dataformatter] Add support to CF{Dictionary, Set}Ref types

2020-05-15 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
mib marked 4 inline comments as done.
Closed by commit rG0eba9de71e2a: [lldb/Dataformatter] Add support to 
CF{Dictionary,Set}Ref types (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D79554?vs=264038&id=264334#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79554

Files:
  lldb/source/Core/ValueObject.cpp
  lldb/source/Core/ValueObjectSyntheticFilter.cpp
  lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
  lldb/source/Plugins/Language/ObjC/NSSet.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
  lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m

Index: lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
+++ lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
@@ -482,8 +482,7 @@
   CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 2, nil, nil));
   NSDictionary *nscfDictionary = CFBridgingRelease(
   CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 4, nil, nil));
-  CFDictionaryRef cfDictionaryRef =
-  CFDictionaryCreate(nil, (void *)cfKeys, (void *)cfValues, 3, nil, nil);
+  CFDictionaryRef cfDictionaryRef = (__bridge CFDictionaryRef)nsDictionary;
 
   NSAttributedString *attrString =
   [[NSAttributedString alloc] initWithString:@"hello world from foo"
@@ -542,6 +541,7 @@
   [nsmutableset addObject:str4];
   NSSet *nscfSet =
   CFBridgingRelease(CFSetCreate(nil, (void *)cfValues, 2, nil));
+  CFSetRef cfSetRef = (__bridge CFSetRef)nscfSet;
 
   CFDataRef data_ref =
   CFDataCreate(kCFAllocatorDefault, [immutableData bytes], 5);
Index: lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
@@ -32,7 +32,7 @@
 '(NSDictionary *) nscfDictionary = ',
 ' 4 key/value pairs',
 '(CFDictionaryRef) cfDictionaryRef = ',
-' 3 key/value pairs',
+' 2 key/value pairs',
 '(NSDictionary *) newMutableDictionary = ',
 ' 21 key/value pairs',
 '(CFArrayRef) cfarray_ref = ',
@@ -57,10 +57,23 @@
 
 
 self.expect(
-  'frame var nscfSet',
+'frame variable -d run-target *cfDictionaryRef',
+patterns=[
+'\(const __CFDictionary\) \*cfDictionaryRef =',
+'key = 0x.* @"foo"',
+'value = 0x.* @"foo"',
+'key = 0x.* @"bar"',
+'value = 0x.* @"bar"',
+])
+
+
+self.expect(
+  'frame var nscfSet cfSetRef',
   substrs=[
   '(NSSet *) nscfSet = ',
   '2 elements',
+  '(CFSetRef) cfSetRef = ',
+  '2 elements',
   ])
 
 self.expect(
@@ -72,6 +85,14 @@
 ])
 
 self.expect(
+  'frame variable -d run-target *cfSetRef',
+  patterns=[
+  '\(const __CFSet\) \*cfSetRef =',
+  '\[0\] = 0x.* @".*"',
+  '\[1\] = 0x.* @".*"',
+])
+
+self.expect(
 'frame variable iset1 iset2 imset',
 substrs=['4 indexes', '512 indexes', '10 indexes'])
 
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
===
--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -448,6 +448,10 @@
 appkit_flags);
   AddCXXSummary(objc_category_sp,
 lldb_private::formatters::NSDictionarySummaryProvider,
+"NSDictionary summary provider", ConstString("__CFDictionary"),
+appkit_flags);
+  AddCXXSummary(objc_category_sp,
+lldb_private::formatters::NSDictionarySummaryProvider,
 "NSDictionary summary provider",
 ConstString("CFMutableDictionaryRef"), appkit_flags);
 
@@ -468,6 +472,9 @@
 "__NSCFSet summary", ConstString("__NSCFSet"), appkit_flags);
   AddCXXSummary(objc_category_sp,
 lldb_private::formatters::NSSetSummaryProvider,
+"__CFSet summary", ConstString("__CFSet"), appkit_flags);
+  AddCXXSummary(objc_category_sp,
+lldb_private::formatters::NSSetSummaryProvider,
 "__N

[Lldb-commits] [PATCH] D79999: [lldb] [Windows] Provide vasprintf only for MSVC

2020-05-15 Thread Mateusz Mikuła via Phabricator via lldb-commits
mati865 updated this revision to Diff 264339.
mati865 added a comment.

With `_GNU_SOURCE` removed I was able to successfully build everything without 
this diff.
I cannot test it today but I believe this updated diff would have fixed the 
error.

It's up to you whether this should be considered as user error and not 
supported configuration.


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

https://reviews.llvm.org/D7

Files:
  lldb/include/lldb/Host/windows/PosixApi.h
  lldb/source/Host/windows/Windows.cpp


Index: lldb/source/Host/windows/Windows.cpp
===
--- lldb/source/Host/windows/Windows.cpp
+++ lldb/source/Host/windows/Windows.cpp
@@ -42,6 +42,7 @@
 }
 }
 
+#ifndef _GNU_SOURCE
 int vasprintf(char **ret, const char *fmt, va_list ap) {
   char *buf;
   int len;
@@ -63,6 +64,7 @@
   va_end(ap2);
   return len;
 }
+#endif
 
 char *strcasestr(const char *s, const char *find) {
   char c, sc;
Index: lldb/include/lldb/Host/windows/PosixApi.h
===
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -94,9 +94,11 @@
 
 #endif // _MSC_VER
 
-// Various useful posix functions that are not present in Windows.  We provide
-// custom implementations.
+// Various useful posix functions that are typically not present in Windows.
+// We provide custom implementations.
+#ifndef _GNU_SOURCE
 int vasprintf(char **ret, const char *fmt, va_list ap);
+#endif
 char *strcasestr(const char *s, const char *find);
 char *realpath(const char *name, char *resolved);
 


Index: lldb/source/Host/windows/Windows.cpp
===
--- lldb/source/Host/windows/Windows.cpp
+++ lldb/source/Host/windows/Windows.cpp
@@ -42,6 +42,7 @@
 }
 }
 
+#ifndef _GNU_SOURCE
 int vasprintf(char **ret, const char *fmt, va_list ap) {
   char *buf;
   int len;
@@ -63,6 +64,7 @@
   va_end(ap2);
   return len;
 }
+#endif
 
 char *strcasestr(const char *s, const char *find) {
   char c, sc;
Index: lldb/include/lldb/Host/windows/PosixApi.h
===
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -94,9 +94,11 @@
 
 #endif // _MSC_VER
 
-// Various useful posix functions that are not present in Windows.  We provide
-// custom implementations.
+// Various useful posix functions that are typically not present in Windows.
+// We provide custom implementations.
+#ifndef _GNU_SOURCE
 int vasprintf(char **ret, const char *fmt, va_list ap);
+#endif
 char *strcasestr(const char *s, const char *find);
 char *realpath(const char *name, char *resolved);
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits