[Lldb-commits] [PATCH] D46362: DWARFExpression: Convert file addresses to load addresses early on

2018-05-03 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

One day I'd like us to have a unit testing framework for the dwarf expression 
evaluator. The evaluator looks like a thing that is both complex enough (so 
it's worth doing it) and /ought to be/ self-contained enough (so it is doable). 
Then we could test these, and all other sorts of funny expressions without 
having to tickle a compiler into producing them.




Comment at: source/Core/Value.cpp:672
 
+void Value::ConvertToLoadAddress(SymbolContext sc, Target *target) {
+  if (GetValueType() != eValueTypeFileAddress)

You should be able to get the target out of the symbol context.



Comment at: source/Core/Value.cpp:683-685
+  ObjectFile *objfile = sc.module_sp->GetObjectFile();
+  if (!objfile)
+return;

This is not what the original code was doing, but what do you think about 
getting the section list directly from the `Module`? The two lists aren't 
exactly the same, but this distinction should not matter here.
Besides being shorter, this would also make this code work slightly better with 
object-file-less Modules that Leonard is trying to introduce (D46292 et al.).


https://reviews.llvm.org/D46362



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


[Lldb-commits] [PATCH] D46318: lldb-test symbols: Add ability to do name-based lookup

2018-05-03 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.

A few more nits but otherwise this LGTM.




Comment at: tools/lldb-test/lldb-test.cpp:463
 
   DebuggerLifetime->Terminate();
   return 0;

labath wrote:
> JDevlieghere wrote:
> > If we can wrap this in a RAII object we could have this tool return a 
> > non-zero exit code in case of an error. 
> Done. I've made the individual functions return an `int`, and had `main` 
> forward that. The reason I am not having the functions return an `Error` or 
> like is that the functions generally do the same thing over several inputs, 
> and the errors that happen when processing one of the inputs should be 
> printed next to that input and not deferred until the end. So, the functions 
> just accumulate a flag saying whether they encountered any errors and then 
> return that.
Alright, works for me!



Comment at: tools/lldb-test/lldb-test.cpp:481
+return dumpModules(*Dbg);
+ if (opts::SymbolsSubcommand)
+return opts::symbols::dumpSymbols(*Dbg);

formatting



Comment at: tools/lldb-test/lldb-test.cpp:484
 
-  DebuggerLifetime->Terminate();
-  return 0;
+ errs() << "No command specified.\n";
+ return 1;

`WithColor:error()`? :-) 


https://reviews.llvm.org/D46318



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


[Lldb-commits] [lldb] r331447 - lldb-test symbols: Add ability to do name-based lookup

2018-05-03 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu May  3 03:57:16 2018
New Revision: 331447

URL: http://llvm.org/viewvc/llvm-project?rev=331447&view=rev
Log:
lldb-test symbols: Add ability to do name-based lookup

Summary:
lldb-test already had the ability to dump all symbol information in a
module. This is interesting, but it can be too verbose, and it also does
not use the same APIs that lldb uses to query symbol information. The
last part is interesting to me now, because I am about to add DWARF v5
debug_names support, which needs to implement these APIs.

This patch adds a set of arguments to lldb-test, which modify it's
behavior from dumping all symbols to dumping only the requested
information:
- --find={function,namespace,type,variable} - search for the given
  kind of objects.

- --name - the name to search for.

- --regex - whether to treat the "name" as a regular expression. This is
  not available for all lookup types (we do not have the required APIs
  for namespaces and types).

- --context - specifies the context, which can be used to restrict the
  search. This argument takes a variable name (which must be defined and
  be unique), and we then use the context that this variable is defined
  in as the search context.

- --function-flags={auto,full,base,method,selector} - a set of flags to
  further restrict the search for function symbols.

Together, these flags and their combinations cover the main SymbolFile
entry points which I will need to modify for the accelerator table
support, and so I plan to do most of the regression testing this way.
(I've also found this a useful tool for exploration of what the given
APIs are supposed to do.)

I add a couple of tests to demonstrate the usage of the usage of the
various options, and also an xfailed test which demonstrates a bug I
found while playing with this. The only requirement for these tests is
the presence of lld -- the should run on any platform which is able to
build lldb.

These tests use c++ code as input, but this isn't a requirement. It is also
possible to use IR, assembly or json to create the test module.

Reviewers: davide, zturner, asmith, JDevlieghere, clayborg, alexshap

Subscribers: mgorny, aprantl, lldb-commits

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

Added:
lldb/trunk/lit/SymbolFile/DWARF/
lldb/trunk/lit/SymbolFile/DWARF/find-basic-function.cpp
lldb/trunk/lit/SymbolFile/DWARF/find-basic-namespace.cpp
lldb/trunk/lit/SymbolFile/DWARF/find-basic-type.cpp
lldb/trunk/lit/SymbolFile/DWARF/find-basic-variable.cpp
lldb/trunk/lit/SymbolFile/DWARF/find-type-in-function.cpp
lldb/trunk/lit/SymbolFile/DWARF/lit.local.cfg
Modified:
lldb/trunk/include/lldb/Symbol/VariableList.h
lldb/trunk/lit/CMakeLists.txt
lldb/trunk/lit/lit.cfg
lldb/trunk/lit/lit.site.cfg.in
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/include/lldb/Symbol/VariableList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/VariableList.h?rev=331447&r1=331446&r2=331447&view=diff
==
--- lldb/trunk/include/lldb/Symbol/VariableList.h (original)
+++ lldb/trunk/include/lldb/Symbol/VariableList.h Thu May  3 03:57:16 2018
@@ -66,6 +66,7 @@ public:
   size_t MemorySize() const;
 
   size_t GetSize() const;
+  bool Empty() const { return m_variables.empty(); }
 
 protected:
   typedef std::vector collection;

Modified: lldb/trunk/lit/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/CMakeLists.txt?rev=331447&r1=331446&r2=331447&view=diff
==
--- lldb/trunk/lit/CMakeLists.txt (original)
+++ lldb/trunk/lit/CMakeLists.txt Thu May  3 03:57:16 2018
@@ -18,6 +18,24 @@ endif ()
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR})
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
+set(LLDB_TEST_DEPS
+  LLDBUnitTests
+  dsymutil
+  lldb
+  lldb-test
+  llvm-config
+  llvm-mc
+  llvm-objcopy
+  )
+
+if(TARGET lld)
+  list(APPEND LLDB_TEST_DEPS lld)
+  set(LLDB_HAVE_LLD 1)
+else()
+  set(LLDB_HAVE_LLD 0)
+endif()
+
+
 if(BUILD_SHARED_LIBS)
   set(ENABLE_SHARED 1)
 else()
@@ -36,16 +54,6 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
   )
 
-set(LLDB_TEST_DEPS
-  LLDBUnitTests
-  dsymutil
-  lldb
-  lldb-test
-  llvm-config
-  llvm-mc
-  llvm-objcopy
-  )
-
 if(NOT LLDB_BUILT_STANDALONE)
   list(APPEND LLDB_TEST_DEPS FileCheck not yaml2obj)
 endif()

Added: lldb/trunk/lit/SymbolFile/DWARF/find-basic-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/find-basic-function.cpp?rev=331447&view=auto
==
--- lldb/trunk/lit/SymbolFile/DWARF/find-basic-function.cpp (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/find-basic-f

[Lldb-commits] [PATCH] D46318: lldb-test symbols: Add ability to do name-based lookup

2018-05-03 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
labath marked 2 inline comments as done.
Closed by commit rL331447: lldb-test symbols: Add ability to do name-based 
lookup (authored by labath, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46318?vs=144904&id=144993#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46318

Files:
  lldb/trunk/include/lldb/Symbol/VariableList.h
  lldb/trunk/lit/CMakeLists.txt
  lldb/trunk/lit/SymbolFile/DWARF/find-basic-function.cpp
  lldb/trunk/lit/SymbolFile/DWARF/find-basic-namespace.cpp
  lldb/trunk/lit/SymbolFile/DWARF/find-basic-type.cpp
  lldb/trunk/lit/SymbolFile/DWARF/find-basic-variable.cpp
  lldb/trunk/lit/SymbolFile/DWARF/find-type-in-function.cpp
  lldb/trunk/lit/SymbolFile/DWARF/lit.local.cfg
  lldb/trunk/lit/lit.cfg
  lldb/trunk/lit/lit.site.cfg.in
  lldb/trunk/tools/lldb-test/lldb-test.cpp

Index: lldb/trunk/tools/lldb-test/lldb-test.cpp
===
--- lldb/trunk/tools/lldb-test/lldb-test.cpp
+++ lldb/trunk/tools/lldb-test/lldb-test.cpp
@@ -20,6 +20,10 @@
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangASTImporter.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/TypeList.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Utility/CleanUp.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/StreamString.h"
 
@@ -29,6 +33,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
 #include 
 
 using namespace lldb;
@@ -57,7 +62,7 @@
 static llvm::StringRef plural(uintmax_t value) { return value == 1 ? "" : "s"; }
 static void dumpState(const BreakpointList &List, LinePrinter &P);
 static std::string substitute(StringRef Cmd);
-static void evaluateBreakpoints(Debugger &Dbg);
+static int evaluateBreakpoints(Debugger &Dbg);
 } // namespace breakpoint
 
 namespace module {
@@ -69,12 +74,68 @@
 } // namespace module
 
 namespace symbols {
-cl::list InputFilenames(cl::Positional, cl::desc(""),
- cl::OneOrMore, cl::sub(SymbolsSubcommand));
+static cl::list InputFilenames(cl::Positional,
+cl::desc(""),
+cl::OneOrMore,
+cl::sub(SymbolsSubcommand));
+enum class FindType {
+  None,
+  Function,
+  Namespace,
+  Type,
+  Variable,
+};
+static cl::opt Find(
+"find", cl::desc("Choose search type:"),
+cl::values(
+clEnumValN(FindType::None, "none",
+   "No search, just dump the module."),
+clEnumValN(FindType::Function, "function", "Find functions."),
+clEnumValN(FindType::Namespace, "namespace", "Find namespaces."),
+clEnumValN(FindType::Type, "type", "Find types."),
+clEnumValN(FindType::Variable, "variable", "Find global variables.")),
+cl::sub(SymbolsSubcommand));
+
+static cl::opt Name("name", cl::desc("Name to find."),
+ cl::sub(SymbolsSubcommand));
+static cl::opt
+Regex("regex",
+  cl::desc("Search using regular expressions (avaliable for variables "
+   "and functions only)."),
+  cl::sub(SymbolsSubcommand));
+static cl::opt
+Context("context",
+cl::desc("Restrict search to the context of the given variable."),
+cl::value_desc("variable"), cl::sub(SymbolsSubcommand));
+
+static cl::list FunctionNameFlags(
+"function-flags", cl::desc("Function search flags:"),
+cl::values(clEnumValN(eFunctionNameTypeAuto, "auto",
+  "Automatically deduce flags based on name."),
+   clEnumValN(eFunctionNameTypeFull, "full", "Full function name."),
+   clEnumValN(eFunctionNameTypeBase, "base", "Base name."),
+   clEnumValN(eFunctionNameTypeMethod, "method", "Method name."),
+   clEnumValN(eFunctionNameTypeSelector, "selector",
+  "Selector name.")),
+cl::sub(SymbolsSubcommand));
+static FunctionNameType getFunctionNameFlags() {
+  FunctionNameType Result = FunctionNameType(0);
+  for (FunctionNameType Flag : FunctionNameFlags)
+Result = FunctionNameType(Result | Flag);
+  return Result;
 }
-} // namespace opts
 
-static llvm::ManagedStatic DebuggerLifetime;
+static Expected getDeclContext(SymbolVendor &Vendor);
+
+static Error findFunctions(lldb_private::Module &Module);
+static Error findNamespaces(lldb_private::Module &Module);
+static Error findTypes(lldb_private::Module &Module);
+static Error findVariables(lldb_private::Module &Module);
+static Error dumpModule(lldb_private::Module &Module);
+
+static int dumpSymbols(Debugger &Dbg);
+}
+} // namespace opts
 
 void opts::breakpoint::dumpState(const B

[Lldb-commits] [PATCH] D46362: DWARFExpression: Convert file addresses to load addresses early on

2018-05-03 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

great fix. Just resolve the file address using the module function and this is 
good to go.




Comment at: source/Core/Value.cpp:683-685
+  ObjectFile *objfile = sc.module_sp->GetObjectFile();
+  if (!objfile)
+return;

labath wrote:
> This is not what the original code was doing, but what do you think about 
> getting the section list directly from the `Module`? The two lists aren't 
> exactly the same, but this distinction should not matter here.
> Besides being shorter, this would also make this code work slightly better 
> with object-file-less Modules that Leonard is trying to introduce (D46292 et 
> al.).
Remove these 3 lines



Comment at: source/Core/Value.cpp:687
+
+  Address so_addr(file_addr, objfile->GetSectionList());
+  lldb::addr_t load_addr = so_addr.GetLoadAddress(target);

Let the module resolve the file address for you:

```
Address so_addr;
if (!sc.module_sp->ResolveFileAddress(file_addr, so_addr))
  return;
```



Comment at: source/Expression/DWARFExpression.cpp:1385-1387
+  stack.back().ConvertToLoadAddress(
+  frame->GetSymbolContext(eSymbolContextFunction),
+  frame->CalculateTarget().get());

Be sure there is a test that tests expressions on global variables before we 
run and before we have a section load list. The result of an expression for a 
global variable can end up using the file address and currently can read from 
the object file's data section. Just make sure this still works. Seems like it 
will. 


https://reviews.llvm.org/D46362



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


[Lldb-commits] [lldb] r331458 - Remove the timed_out out-argument from Predicate::WaitForValueEqualTo

2018-05-03 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu May  3 08:33:41 2018
New Revision: 331458

URL: http://llvm.org/viewvc/llvm-project?rev=331458&view=rev
Log:
Remove the timed_out out-argument from Predicate::WaitForValueEqualTo

The function can only return in one of two ways: the Predicate value is
successfully set within the allotted time, or it isn't (the wait times
out). These states can be represented in the return value, and the extra
arg adds no value.

Modified:
lldb/trunk/include/lldb/Core/Event.h
lldb/trunk/include/lldb/Host/Predicate.h
lldb/trunk/source/Host/common/Host.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Core/Event.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Event.h?rev=331458&r1=331457&r2=331458&view=diff
==
--- lldb/trunk/include/lldb/Core/Event.h (original)
+++ lldb/trunk/include/lldb/Core/Event.h Thu May  3 08:33:41 2018
@@ -122,9 +122,8 @@ public:
   const ConstString &GetFlavor() const override { return GetFlavorString(); }
 
   bool WaitForEventReceived(
-  const std::chrono::microseconds &abstime = std::chrono::microseconds(0),
-  bool *timed_out = nullptr) {
-return m_predicate.WaitForValueEqualTo(true, abstime, timed_out);
+  const std::chrono::microseconds &abstime = std::chrono::microseconds(0)) 
{
+return m_predicate.WaitForValueEqualTo(true, abstime);
   }
 
 private:

Modified: lldb/trunk/include/lldb/Host/Predicate.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Predicate.h?rev=331458&r1=331457&r2=331458&view=diff
==
--- lldb/trunk/include/lldb/Host/Predicate.h (original)
+++ lldb/trunk/include/lldb/Host/Predicate.h Thu May  3 08:33:41 2018
@@ -138,17 +138,12 @@ public:
   /// If non-nullptr, the absolute time at which we should stop
   /// waiting, else wait an infinite amount of time.
   ///
-  /// @param[out] timed_out
-  /// If not null, set to true if we return because of a time out,
-  /// and false if the value was set.
-  ///
   /// @return
   /// @li \b true if the \a m_value is equal to \a value
-  /// @li \b false otherwise
+  /// @li \b false otherwise (timeout occurred)
   //--
   bool WaitForValueEqualTo(T value, const std::chrono::microseconds &timeout =
-std::chrono::microseconds(0),
-   bool *timed_out = nullptr) {
+std::chrono::microseconds(0)) {
 // pthread_cond_timedwait() or pthread_cond_wait() will atomically unlock
 // the mutex and wait for the condition to be set. When either function
 // returns, they will re-lock the mutex. We use an auto lock/unlock class
@@ -160,19 +155,13 @@ public:
 printf("%s (value = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n",
__FUNCTION__, value, timeout.count(), m_value);
 #endif
-if (timed_out)
-  *timed_out = false;
-
 while (m_value != value) {
   if (timeout == std::chrono::microseconds(0)) {
 m_condition.wait(lock);
   } else {
 std::cv_status result = m_condition.wait_for(lock, timeout);
-if (result == std::cv_status::timeout) {
-  if (timed_out)
-*timed_out = true;
+if (result == std::cv_status::timeout)
   break;
-}
   }
 }
 

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=331458&r1=331457&r2=331458&view=diff
==
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Thu May  3 08:33:41 2018
@@ -536,18 +536,15 @@ Status Host::RunShellCommand(const Args
 error.SetErrorString("failed to get process ID");
 
   if (error.Success()) {
-bool timed_out = false;
-shell_info_sp->process_reaped.WaitForValueEqualTo(
-true, std::chrono::seconds(timeout_sec), &timed_out);
-if (timed_out) {
+if (!shell_info_sp->process_reaped.WaitForValueEqualTo(
+true, std::chrono::seconds(timeout_sec))) {
   error.SetErrorString("timed out waiting for shell command to complete");
 
   // Kill the process since it didn't complete within the timeout specified
   Kill(pid, SIGKILL);
   // Wait for the monitor callback to get the message
-  timed_out = false;
   shell_info_sp->process_reaped.WaitForValueEqualTo(
-  true, std::chrono::seconds(1), &timed_out);
+  true, std::chrono::seconds(1));
 } else {
   if (status_ptr)
 *status_ptr = shell_info_sp->status;

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel

[Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Is there a way to land a partial version of this patch to un-block the green 
dragon bots and keep iterating on the check-single target separately? Or do 
other bots depend on check-single working correctly? I'm really uneasy about 
the fact that we are loosing signal from the bots while they are red. (This is 
not meant to say that one platform is more important than another, I'm just 
searching for a way to get all the bots functioning again as quickly as 
possible, and "no" is an acceptable answer :-).


https://reviews.llvm.org/D46334



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


[Lldb-commits] [PATCH] D32167: Add support for type units (.debug_types) to LLDB in a way that is compatible with DWARF 5

2018-05-03 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Ping. I would like to get this in. As for testing, the full matrix should be 
run on .debug_types as it is the main form of type uniquing that is defined by 
the DWARF spec. Any formats that are fully accepted and written into the DWARF 
spec should be fully tested to ensure everything works. .debug_types is only 
enabled on linux right now and our build bots are fast on these systems.


https://reviews.llvm.org/D32167



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


[Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

In its current version, the patch won't *break* the windows build (the previous 
change broke the build as well as tests), so if it will unblock the bots, Jonas 
could check it in and then fix check-single in a follow up patch. I think it 
needs to be explicit if this goes in as-is that it IS breaking check-single 
though.


https://reviews.llvm.org/D46334



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


[Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

If that's okay with you I would suggest landing this as is to unblock the bots, 
and we'll keep working on fixing the check-single target ASAP, too.


https://reviews.llvm.org/D46334



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


[Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

If by as-is you mean with a big comment in the config file before the creation 
of check-single that it is broken, then yes, let's get the bots unblocked and 
then fix the issue.


https://reviews.llvm.org/D46334



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


[Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

> If by as-is you mean with a big comment in the config file before the 
> creation of check-single that it is broken, then yes, let's get the bots 
> unblocked and then fix the issue.

Sounds good. Thanks!


https://reviews.llvm.org/D46334



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


[Lldb-commits] [PATCH] D46362: DWARFExpression: Convert file addresses to load addresses early on

2018-05-03 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 145032.
aprantl added a comment.

Thanks for the excellent feedback! Addressed comments.


https://reviews.llvm.org/D46362

Files:
  include/lldb/Core/Value.h
  source/Core/Value.cpp
  source/Core/ValueObjectVariable.cpp
  source/Expression/DWARFExpression.cpp


Index: source/Expression/DWARFExpression.cpp
===
--- source/Expression/DWARFExpression.cpp
+++ source/Expression/DWARFExpression.cpp
@@ -1379,10 +1379,13 @@
 // The DW_OP_addr operation has a single operand that encodes a machine
 // address and whose size is the size of an address on the target machine.
 //--
-case DW_OP_addr:
+case DW_OP_addr: {
   stack.push_back(Scalar(opcodes.GetAddress(&offset)));
   stack.back().SetValueType(Value::eValueTypeFileAddress);
+  auto sc = frame->GetSymbolContext(eSymbolContextFunction);
+  stack.back().ConvertToLoadAddress(sc);
   break;
+}
 
 //--
 // The DW_OP_addr_sect_offset4 is used for any location expressions in
Index: source/Core/ValueObjectVariable.cpp
===
--- source/Core/ValueObjectVariable.cpp
+++ source/Core/ValueObjectVariable.cpp
@@ -234,26 +234,10 @@
 // If this variable is a simple type, we read all data for it into
 // m_data. Make sure this type has a value before we try and read it
 
+SymbolContext var_sc;
+variable->CalculateSymbolContext(&var_sc);
 // If we have a file address, convert it to a load address if we can.
-if (value_type == Value::eValueTypeFileAddress && process_is_alive) {
-  lldb::addr_t file_addr =
-  m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
-  if (file_addr != LLDB_INVALID_ADDRESS) {
-SymbolContext var_sc;
-variable->CalculateSymbolContext(&var_sc);
-if (var_sc.module_sp) {
-  ObjectFile *objfile = var_sc.module_sp->GetObjectFile();
-  if (objfile) {
-Address so_addr(file_addr, objfile->GetSectionList());
-lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
-if (load_addr != LLDB_INVALID_ADDRESS) {
-  m_value.SetValueType(Value::eValueTypeLoadAddress);
-  m_value.GetScalar() = load_addr;
-}
-  }
-}
-  }
-}
+m_value.ConvertToLoadAddress(var_sc);
 
 if (!CanProvideValue()) {
   // this value object represents an aggregate type whose children have
Index: source/Core/Value.cpp
===
--- source/Core/Value.cpp
+++ source/Core/Value.cpp
@@ -669,6 +669,28 @@
   return "???";
 }
 
+void Value::ConvertToLoadAddress(SymbolContext sc) {
+  if (GetValueType() != eValueTypeFileAddress)
+return;
+
+  if (!sc.module_sp)
+return;
+
+  lldb::addr_t file_addr = GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+  if (file_addr == LLDB_INVALID_ADDRESS)
+return;
+
+  Address so_addr;
+  if (!sc.module_sp->ResolveFileAddress(file_addr, so_addr))
+return;
+  lldb::addr_t load_addr = so_addr.GetLoadAddress(sc.target_sp.get());
+  if (load_addr == LLDB_INVALID_ADDRESS)
+return;
+
+  SetValueType(Value::eValueTypeLoadAddress);
+  GetScalar() = load_addr;
+}
+
 ValueList::ValueList(const ValueList &rhs) { m_values = rhs.m_values; }
 
 const ValueList &ValueList::operator=(const ValueList &rhs) {
Index: include/lldb/Core/Value.h
===
--- include/lldb/Core/Value.h
+++ include/lldb/Core/Value.h
@@ -228,6 +228,9 @@
 
   static const char *GetContextTypeAsCString(ContextType context_type);
 
+  /// Convert this value's file address to a load address, if possible.
+  void ConvertToLoadAddress(SymbolContext sc);
+
   bool GetData(DataExtractor &data);
 
   void Clear();


Index: source/Expression/DWARFExpression.cpp
===
--- source/Expression/DWARFExpression.cpp
+++ source/Expression/DWARFExpression.cpp
@@ -1379,10 +1379,13 @@
 // The DW_OP_addr operation has a single operand that encodes a machine
 // address and whose size is the size of an address on the target machine.
 //--
-case DW_OP_addr:
+case DW_OP_addr: {
   stack.push_back(Scalar(opcodes.GetAddress(&offset)));
   stack.back().SetValueType(Value::eValueTypeFileAddress);
+  auto sc = frame->GetSymbolContext(eSymbolContextFunction);
+  stack.back().ConvertToLoadAddress(sc);
   break;
+}
 
 //--
 // The DW_OP_add

[Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

I didn't realize `check-lldb-single` was also broken for ninja/make. Using the 
property indeed fixed it, so we can land this without the caveat.


https://reviews.llvm.org/D46334



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


[Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Pavel Labath via Phabricator via lldb-commits
labath added subscribers: aprantl, davide, JDevlieghere, zturner.
labath added a comment.

I remember hearing some people use the check-lldb-single target, but it had
to do with running the tests against some remote devices/stubs that did not
handle multiple connections very well.

However, the way it seems to me, with the transition to lit, this target
will have to go away sooner or later (it still invokes dotest directly). If
there is a substantial effort involved in making it work, then maybe the
time to drop it is now. It will still be possible to run the tests in this
mode by invoking dotest directly. (and if this is something that we really
need to support in the future, we should identify who these people are, and
what requirements they have).


https://reviews.llvm.org/D46334



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


Re: [Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Pavel Labath via lldb-commits
I remember hearing some people use the check-lldb-single target, but it had
to do with running the tests against some remote devices/stubs that did not
handle multiple connections very well.

However, the way it seems to me, with the transition to lit, this target
will have to go away sooner or later (it still invokes dotest directly). If
there is a substantial effort involved in making it work, then maybe the
time to drop it is now. It will still be possible to run the tests in this
mode by invoking dotest directly. (and if this is something that we really
need to support in the future, we should identify who these people are, and
what requirements they have).
On Thu, 3 May 2018 at 17:35, Adrian Prantl via Phabricator <
revi...@reviews.llvm.org> wrote:

> aprantl added a comment.

> > If by as-is you mean with a big comment in the config file before the
creation of check-single that it is broken, then yes, let's get the bots
unblocked and then fix the issue.

> Sounds good. Thanks!


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


[Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 145033.
JDevlieghere added a comment.
Herald added a reviewer: alexshap.

update diff pro forma


https://reviews.llvm.org/D46334

Files:
  CMakeLists.txt
  lit/CMakeLists.txt
  lit/Suite/lit.site.cfg.in
  test/CMakeLists.txt
  test/lldb-dotest.in
  tools/debugserver/source/CMakeLists.txt
  utils/lldb-dotest/CMakeLists.txt
  utils/lldb-dotest/lldb-dotest.in

Index: utils/lldb-dotest/CMakeLists.txt
===
--- /dev/null
+++ utils/lldb-dotest/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Make lldb-dotest a custom target.
+add_custom_target(lldb-dotest)
+add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
+
+get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
+
+# Generate wrapper for each build mode.
+if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
+  foreach(LLVM_BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
+configure_file(
+  lldb-dotest.in
+  ${LLDB_DOTEST_DIR}/lldb-dotest
+  )
+  endforeach()
+else()
+  configure_file(
+lldb-dotest.in
+${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-dotest
+)
+endif()
Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -77,7 +77,7 @@
   RNBSocket.cpp
   SysSignal.cpp
   TTYState.cpp
-  
+
   MacOSX/CFBundle.cpp
   MacOSX/CFString.cpp
   MacOSX/Genealogy.cpp
@@ -99,7 +99,7 @@
   CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
 
 if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
-  set(DEBUGSERVER_PATH $ CACHE PATH "Path to debugserver.")
+  set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.")
   set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server")
 else()
   execute_process(
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -13,35 +13,6 @@
 )
 endfunction()
 
-set(LLDB_TEST_DEPS lldb)
-
-# darwin-debug is an hard dependency for the testsuite.
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  list(APPEND LLDB_TEST_DEPS darwin-debug)
-endif()
-
-if(TARGET lldb-server)
-  list(APPEND LLDB_TEST_DEPS lldb-server)
-endif()
-
-if(TARGET debugserver)
-  if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
-list(APPEND LLDB_TEST_DEPS debugserver)
-  endif()
-endif()
-
-if(TARGET lldb-mi)
-  list(APPEND LLDB_TEST_DEPS lldb-mi)
-endif()
-
-if(NOT LLDB_BUILT_STANDALONE)
-  list(APPEND LLDB_TEST_DEPS yaml2obj dsymutil)
-endif()
-
-if(TARGET liblldb)
-  list(APPEND LLDB_TEST_DEPS liblldb)
-endif()
-
 # The default architecture with which to compile test executables is the default LLVM target
 # architecture, which itself defaults to the host architecture.
 string(TOLOWER "${LLVM_TARGET_ARCH}" LLDB_DEFAULT_TEST_ARCH)
@@ -75,28 +46,12 @@
   -u CFLAGS
   )
 
-# We need two properties here, because they are used for different purposes. When we are generating
-# one file per configuration for lldb-dotest, we want the paths to be configuration specific. However,
-# when we are generating a single lit file, the file itself should not be per configuration and the paths
-# contained inside should be generic also.
-set(LLDB_EXECUTABLE_PATH_ARGS
-  --executable $
-  --dsymutil $
-  )
-set(LLDB_EXECUTABLE_PATH_ARGS_STR
+list(APPEND LLDB_TEST_COMMON_ARGS
   --executable ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}
   --dsymutil ${LLVM_RUNTIME_OUTPUT_INTDIR}/dsymutil${CMAKE_EXECUTABLE_SUFFIX}
   -C ${LLDB_TEST_C_COMPILER}
   )
 
-# There's an additional complication which is that when the compiler is NOT a custom compiler, we need to
-# make sure to get the configuration specific path as well
-if (NOT LLDB_TEST_USE_CUSTOM_C_COMPILER)
-  list(APPEND LLDB_EXECUTABLE_PATH_ARGS -C $)
-else()
-  list(APPEND LLDB_EXECUTABLE_PATH_ARGS -C ${LLDB_TEST_C_COMPILER})
-endif()
-
 if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
   # All tests are currently flaky on Windows, so rerun them all once when they fail.
   set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --rerun-all-issues)
@@ -122,31 +77,25 @@
   list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY}")
 endif()
 
-# The framework path is passed to the test arguments as $. This won't work in the
-# LLDB_DOTEST_ARGS_STR when using a generator that supports multiple configurations such as Visual Studio,
-# but since the framework is currently confined to Darwin/Apple, we can leave it as is.
 if(LLDB_BUILD_FRAMEWORK)
-  list(APPEND LLDB_TEST_COMMON_ARGS --framework $)
+  list(APPEND LLDB_TEST_COMMON_ARGS --framework ${LLVM_LIBR

[Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova accepted this revision.
stella.stamenova added a comment.
This revision is now accepted and ready to land.

I still need to verify this works with VS on Windows, but feel free to check in 
to unblock the bots


https://reviews.llvm.org/D46334



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


[Lldb-commits] [lldb] r331462 - DWARFExpression: Convert file addresses to load addresses early on.

2018-05-03 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu May  3 09:51:37 2018
New Revision: 331462

URL: http://llvm.org/viewvc/llvm-project?rev=331462&view=rev
Log:
DWARFExpression: Convert file addresses to load addresses early on.

This is a change that only affects Swift and is NFC for the language
plugins on llvm.org. In Swift, we can have global variables with a
location such as DW_OP_addr  DW_OP_deref. The DWARF expression
evaluator doesn't know how to apply a DW_OP_deref to a file address,
but at the very end we convert the file address into a load address.

This patch moves the file->load address conversion to right after the
result of the DW_OP_addr is pushed onto the stack so that a subsequent
DW_OP_deref (and potentially other operations) can be interpreted.

rdar://problem/39767528

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

Modified:
lldb/trunk/include/lldb/Core/Value.h
lldb/trunk/source/Core/Value.cpp
lldb/trunk/source/Core/ValueObjectVariable.cpp
lldb/trunk/source/Expression/DWARFExpression.cpp

Modified: lldb/trunk/include/lldb/Core/Value.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=331462&r1=331461&r2=331462&view=diff
==
--- lldb/trunk/include/lldb/Core/Value.h (original)
+++ lldb/trunk/include/lldb/Core/Value.h Thu May  3 09:51:37 2018
@@ -228,6 +228,9 @@ public:
 
   static const char *GetContextTypeAsCString(ContextType context_type);
 
+  /// Convert this value's file address to a load address, if possible.
+  void ConvertToLoadAddress(SymbolContext sc);
+
   bool GetData(DataExtractor &data);
 
   void Clear();

Modified: lldb/trunk/source/Core/Value.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=331462&r1=331461&r2=331462&view=diff
==
--- lldb/trunk/source/Core/Value.cpp (original)
+++ lldb/trunk/source/Core/Value.cpp Thu May  3 09:51:37 2018
@@ -669,6 +669,28 @@ const char *Value::GetContextTypeAsCStri
   return "???";
 }
 
+void Value::ConvertToLoadAddress(SymbolContext sc) {
+  if (GetValueType() != eValueTypeFileAddress)
+return;
+
+  if (!sc.module_sp)
+return;
+
+  lldb::addr_t file_addr = GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+  if (file_addr == LLDB_INVALID_ADDRESS)
+return;
+
+  Address so_addr;
+  if (!sc.module_sp->ResolveFileAddress(file_addr, so_addr))
+return;
+  lldb::addr_t load_addr = so_addr.GetLoadAddress(sc.target_sp.get());
+  if (load_addr == LLDB_INVALID_ADDRESS)
+return;
+
+  SetValueType(Value::eValueTypeLoadAddress);
+  GetScalar() = load_addr;
+}
+
 ValueList::ValueList(const ValueList &rhs) { m_values = rhs.m_values; }
 
 const ValueList &ValueList::operator=(const ValueList &rhs) {

Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=331462&r1=331461&r2=331462&view=diff
==
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Thu May  3 09:51:37 2018
@@ -234,26 +234,10 @@ bool ValueObjectVariable::UpdateValue()
 // If this variable is a simple type, we read all data for it into
 // m_data. Make sure this type has a value before we try and read it
 
+SymbolContext var_sc;
+variable->CalculateSymbolContext(&var_sc);
 // If we have a file address, convert it to a load address if we can.
-if (value_type == Value::eValueTypeFileAddress && process_is_alive) {
-  lldb::addr_t file_addr =
-  m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
-  if (file_addr != LLDB_INVALID_ADDRESS) {
-SymbolContext var_sc;
-variable->CalculateSymbolContext(&var_sc);
-if (var_sc.module_sp) {
-  ObjectFile *objfile = var_sc.module_sp->GetObjectFile();
-  if (objfile) {
-Address so_addr(file_addr, objfile->GetSectionList());
-lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
-if (load_addr != LLDB_INVALID_ADDRESS) {
-  m_value.SetValueType(Value::eValueTypeLoadAddress);
-  m_value.GetScalar() = load_addr;
-}
-  }
-}
-  }
-}
+m_value.ConvertToLoadAddress(var_sc);
 
 if (!CanProvideValue()) {
   // this value object represents an aggregate type whose children have

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=331462&r1=331461&r2=331462&view=diff
==
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/

[Lldb-commits] [PATCH] D46362: DWARFExpression: Convert file addresses to load addresses early on

2018-05-03 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331462: DWARFExpression: Convert file addresses to load 
addresses early on. (authored by adrian, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46362?vs=145032&id=145034#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46362

Files:
  lldb/trunk/include/lldb/Core/Value.h
  lldb/trunk/source/Core/Value.cpp
  lldb/trunk/source/Core/ValueObjectVariable.cpp
  lldb/trunk/source/Expression/DWARFExpression.cpp


Index: lldb/trunk/include/lldb/Core/Value.h
===
--- lldb/trunk/include/lldb/Core/Value.h
+++ lldb/trunk/include/lldb/Core/Value.h
@@ -228,6 +228,9 @@
 
   static const char *GetContextTypeAsCString(ContextType context_type);
 
+  /// Convert this value's file address to a load address, if possible.
+  void ConvertToLoadAddress(SymbolContext sc);
+
   bool GetData(DataExtractor &data);
 
   void Clear();
Index: lldb/trunk/source/Expression/DWARFExpression.cpp
===
--- lldb/trunk/source/Expression/DWARFExpression.cpp
+++ lldb/trunk/source/Expression/DWARFExpression.cpp
@@ -1379,10 +1379,13 @@
 // The DW_OP_addr operation has a single operand that encodes a machine
 // address and whose size is the size of an address on the target machine.
 //--
-case DW_OP_addr:
+case DW_OP_addr: {
   stack.push_back(Scalar(opcodes.GetAddress(&offset)));
   stack.back().SetValueType(Value::eValueTypeFileAddress);
+  auto sc = frame->GetSymbolContext(eSymbolContextFunction);
+  stack.back().ConvertToLoadAddress(sc);
   break;
+}
 
 //--
 // The DW_OP_addr_sect_offset4 is used for any location expressions in
Index: lldb/trunk/source/Core/Value.cpp
===
--- lldb/trunk/source/Core/Value.cpp
+++ lldb/trunk/source/Core/Value.cpp
@@ -669,6 +669,28 @@
   return "???";
 }
 
+void Value::ConvertToLoadAddress(SymbolContext sc) {
+  if (GetValueType() != eValueTypeFileAddress)
+return;
+
+  if (!sc.module_sp)
+return;
+
+  lldb::addr_t file_addr = GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+  if (file_addr == LLDB_INVALID_ADDRESS)
+return;
+
+  Address so_addr;
+  if (!sc.module_sp->ResolveFileAddress(file_addr, so_addr))
+return;
+  lldb::addr_t load_addr = so_addr.GetLoadAddress(sc.target_sp.get());
+  if (load_addr == LLDB_INVALID_ADDRESS)
+return;
+
+  SetValueType(Value::eValueTypeLoadAddress);
+  GetScalar() = load_addr;
+}
+
 ValueList::ValueList(const ValueList &rhs) { m_values = rhs.m_values; }
 
 const ValueList &ValueList::operator=(const ValueList &rhs) {
Index: lldb/trunk/source/Core/ValueObjectVariable.cpp
===
--- lldb/trunk/source/Core/ValueObjectVariable.cpp
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp
@@ -234,26 +234,10 @@
 // If this variable is a simple type, we read all data for it into
 // m_data. Make sure this type has a value before we try and read it
 
+SymbolContext var_sc;
+variable->CalculateSymbolContext(&var_sc);
 // If we have a file address, convert it to a load address if we can.
-if (value_type == Value::eValueTypeFileAddress && process_is_alive) {
-  lldb::addr_t file_addr =
-  m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
-  if (file_addr != LLDB_INVALID_ADDRESS) {
-SymbolContext var_sc;
-variable->CalculateSymbolContext(&var_sc);
-if (var_sc.module_sp) {
-  ObjectFile *objfile = var_sc.module_sp->GetObjectFile();
-  if (objfile) {
-Address so_addr(file_addr, objfile->GetSectionList());
-lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
-if (load_addr != LLDB_INVALID_ADDRESS) {
-  m_value.SetValueType(Value::eValueTypeLoadAddress);
-  m_value.GetScalar() = load_addr;
-}
-  }
-}
-  }
-}
+m_value.ConvertToLoadAddress(var_sc);
 
 if (!CanProvideValue()) {
   // this value object represents an aggregate type whose children have


Index: lldb/trunk/include/lldb/Core/Value.h
===
--- lldb/trunk/include/lldb/Core/Value.h
+++ lldb/trunk/include/lldb/Core/Value.h
@@ -228,6 +228,9 @@
 
   static const char *GetContextTypeAsCString(ContextType context_type);
 
+  /// Convert this value's file address to a load address, if possible.
+  void ConvertToLoadAddress(SymbolContext sc);
+
   bool GetData(DataExtractor &data);
 
   v

[Lldb-commits] [lldb] r331463 - [CMake] Unify and relayer testing

2018-05-03 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Thu May  3 09:54:10 2018
New Revision: 331463

URL: http://llvm.org/viewvc/llvm-project?rev=331463&view=rev
Log:
[CMake] Unify and relayer testing

This patch restructures part of LLDB's testing configuration:

1. I moved the test dependencies up the chain so every dotest dependency
   becomes a lit dependency as well. It wouldn't make sense for dotest to
   have other dependencies when it's being run by lit. Lit on the other
   hand can still specify extra dependencies.

2. I replaced as much generator expressions with variables as possible.
   This is consistent with the rest of LLVM and doesn't break generators
   that support multiple targets (MSVC, Xcode). This wasn't a problem
   before, but now we need to expand the dotest arguments in the lit
   configuration and there's only one test suite even with multiple
   targets.

3. I moved lldb-dotest into it's own directory under utils since there's
   no need anymore for it to located under `test/`.

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

Added:
lldb/trunk/utils/lldb-dotest/
lldb/trunk/utils/lldb-dotest/CMakeLists.txt
lldb/trunk/utils/lldb-dotest/lldb-dotest.in
  - copied, changed from r331458, lldb/trunk/test/lldb-dotest.in
Removed:
lldb/trunk/test/lldb-dotest.in
Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/lit/CMakeLists.txt
lldb/trunk/lit/Suite/lit.site.cfg.in
lldb/trunk/test/CMakeLists.txt
lldb/trunk/tools/debugserver/source/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=331463&r1=331462&r2=331463&view=diff
==
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Thu May  3 09:54:10 2018
@@ -85,9 +85,43 @@ if(LLDB_INCLUDE_TESTS)
 message(FATAL_ERROR "LLDB test compilers not specified.  Tests will not 
run")
   endif()
 
+  set(LLDB_TEST_DEPS lldb)
+
+  # darwin-debug is an hard dependency for the testsuite.
+  if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+list(APPEND LLDB_TEST_DEPS darwin-debug)
+  endif()
+
+  if(TARGET lldb-server)
+list(APPEND LLDB_TEST_DEPS lldb-server)
+  endif()
+
+  if(TARGET debugserver)
+if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
+  list(APPEND LLDB_TEST_DEPS debugserver)
+endif()
+  endif()
+
+  if(TARGET lldb-mi)
+list(APPEND LLDB_TEST_DEPS lldb-mi)
+  endif()
+
+  if(NOT LLDB_BUILT_STANDALONE)
+list(APPEND LLDB_TEST_DEPS yaml2obj dsymutil)
+  endif()
+
+  if(TARGET liblldb)
+list(APPEND LLDB_TEST_DEPS liblldb)
+  endif()
+
+  if(TARGET clang)
+list(APPEND LLDB_TEST_DEPS clang)
+  endif()
+
   add_subdirectory(test)
   add_subdirectory(unittests)
   add_subdirectory(lit)
+  add_subdirectory(utils/lldb-dotest)
 endif()
 
 if (NOT LLDB_DISABLE_PYTHON)

Modified: lldb/trunk/lit/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/CMakeLists.txt?rev=331463&r1=331462&r2=331463&view=diff
==
--- lldb/trunk/lit/CMakeLists.txt (original)
+++ lldb/trunk/lit/CMakeLists.txt Thu May  3 09:54:10 2018
@@ -15,10 +15,13 @@ if (NOT LLDB_TEST_USE_CUSTOM_CXX_COMPILE
   string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_CXX_COMPILER 
${LLDB_TEST_CXX_COMPILER})
 endif ()
 
+get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
+
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR 
${LLVM_LIBRARY_OUTPUT_INTDIR})
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS 
"${LLDB_DOTEST_ARGS}")
 
-set(LLDB_TEST_DEPS
+list(APPEND LLDB_TEST_DEPS
   LLDBUnitTests
   dsymutil
   lldb
@@ -35,7 +38,6 @@ else()
   set(LLDB_HAVE_LLD 0)
 endif()
 
-
 if(BUILD_SHARED_LIBS)
   set(ENABLE_SHARED 1)
 else()
@@ -51,24 +53,16 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
-  )
+  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/Suite/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/Suite/lit.site.cfg)
 
 if(NOT LLDB_BUILT_STANDALONE)
-  list(APPEND LLDB_TEST_DEPS FileCheck not yaml2obj)
-endif()
-  
-# lldb-server is not built on every platform.
-if (TARGET lldb-server)
-  list(APPEND LLDB_TEST_DEPS lldb-server)
-endif()
-  
-if(APPLE)
-  list(APPEND LLDB_TEST_DEPS debugserver)
-endif()
-
-if(TARGET clang)
-  list(APPEND LLDB_TEST_DEPS clang)
+  list(APPEND LLDB_TEST_DEPS
+FileCheck
+not
+)
 endif()
 
 set(LLDB_TEST_PARAMS

Modified: lldb/trunk/lit/Suite/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Suite/lit.site.cfg.in?rev=331463&r1=331462&r2=331463&view=diff
==

[Lldb-commits] [PATCH] D46334: [CMake] Unify and relayer testing

2018-05-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL331463: [CMake] Unify and relayer testing (authored by 
JDevlieghere, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46334?vs=145033&id=145035#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46334

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/lit/CMakeLists.txt
  lldb/trunk/lit/Suite/lit.site.cfg.in
  lldb/trunk/test/CMakeLists.txt
  lldb/trunk/test/lldb-dotest.in
  lldb/trunk/tools/debugserver/source/CMakeLists.txt
  lldb/trunk/utils/lldb-dotest/CMakeLists.txt
  lldb/trunk/utils/lldb-dotest/lldb-dotest.in

Index: lldb/trunk/utils/lldb-dotest/CMakeLists.txt
===
--- lldb/trunk/utils/lldb-dotest/CMakeLists.txt
+++ lldb/trunk/utils/lldb-dotest/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Make lldb-dotest a custom target.
+add_custom_target(lldb-dotest)
+add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
+
+get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
+
+# Generate wrapper for each build mode.
+if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
+  foreach(LLVM_BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
+configure_file(
+  lldb-dotest.in
+  ${LLDB_DOTEST_DIR}/lldb-dotest
+  )
+  endforeach()
+else()
+  configure_file(
+lldb-dotest.in
+${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-dotest
+)
+endif()
Index: lldb/trunk/utils/lldb-dotest/lldb-dotest.in
===
--- lldb/trunk/utils/lldb-dotest/lldb-dotest.in
+++ lldb/trunk/utils/lldb-dotest/lldb-dotest.in
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+import subprocess
+import sys
+
+dotest_path = '@LLDB_SOURCE_DIR@/test/dotest.py'
+dotest_args_str = '@LLDB_DOTEST_ARGS@'
+
+if __name__ == '__main__':
+wrapper_args = sys.argv[1:]
+dotest_args = dotest_args_str.split(';')
+# Build dotest.py command.
+cmd = [dotest_path, '-q']
+cmd.extend(dotest_args)
+cmd.extend(wrapper_args)
+# Invoke dotest.py and return exit code.
+sys.exit(subprocess.call(cmd))
Index: lldb/trunk/tools/debugserver/source/CMakeLists.txt
===
--- lldb/trunk/tools/debugserver/source/CMakeLists.txt
+++ lldb/trunk/tools/debugserver/source/CMakeLists.txt
@@ -77,7 +77,7 @@
   RNBSocket.cpp
   SysSignal.cpp
   TTYState.cpp
-  
+
   MacOSX/CFBundle.cpp
   MacOSX/CFString.cpp
   MacOSX/Genealogy.cpp
@@ -99,7 +99,7 @@
   CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
 
 if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
-  set(DEBUGSERVER_PATH $ CACHE PATH "Path to debugserver.")
+  set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.")
   set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server")
 else()
   execute_process(
Index: lldb/trunk/lit/CMakeLists.txt
===
--- lldb/trunk/lit/CMakeLists.txt
+++ lldb/trunk/lit/CMakeLists.txt
@@ -15,10 +15,13 @@
   string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TEST_CXX_COMPILER ${LLDB_TEST_CXX_COMPILER})
 endif ()
 
+get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
+
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
 
-set(LLDB_TEST_DEPS
+list(APPEND LLDB_TEST_DEPS
   LLDBUnitTests
   dsymutil
   lldb
@@ -35,7 +38,6 @@
   set(LLDB_HAVE_LLD 0)
 endif()
 
-
 if(BUILD_SHARED_LIBS)
   set(ENABLE_SHARED 1)
 else()
@@ -51,24 +53,16 @@
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
-  )
+  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/Suite/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/Suite/lit.site.cfg)
 
 if(NOT LLDB_BUILT_STANDALONE)
-  list(APPEND LLDB_TEST_DEPS FileCheck not yaml2obj)
-endif()
-  
-# lldb-server is not built on every platform.
-if (TARGET lldb-server)
-  list(APPEND LLDB_TEST_DEPS lldb-server)
-endif()
-  
-if(APPLE)
-  list(APPEND LLDB_TEST_DEPS debugserver)
-endif()
-
-if(TARGET clang)
-  list(APPEND LLDB_TEST_DEPS clang)
+  list(APPEND LLDB_TEST_DEPS
+FileCheck
+not
+)
 endif()
 
 set(LLDB_TEST_PARAMS
Index: lldb/trunk/lit/Suite/lit.site.cfg.in
===
--- lldb/trunk/lit/Suite/lit.si

[Lldb-commits] [PATCH] D46395: Remove Process references from the Host module

2018-05-03 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: jingham, davide.
Herald added a subscriber: emaste.

The Process class was only being referenced because of the last-ditch
effort in the process launchers to set a process exit callback in case
one isn't set already.

Although launching a process for debugging is the most important kind of
"launch" we are doing, it is by far not the only one, so assuming this
particular callback is the one to be used is not a good idea (besides
breaking layering). Instead of assuming a particular exit callback, I
change the launcher code to require the callback to be set by the user (and fix
up the two call sites which did not set the callback already).


https://reviews.llvm.org/D46395

Files:
  source/Host/common/MonitoringProcessLauncher.cpp
  source/Host/common/NativeProcessProtocol.cpp
  source/Host/macosx/Host.mm
  source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  unittests/tools/lldb-server/tests/TestClient.cpp

Index: unittests/tools/lldb-server/tests/TestClient.cpp
===
--- unittests/tools/lldb-server/tests/TestClient.cpp
+++ unittests/tools/lldb-server/tests/TestClient.cpp
@@ -112,6 +112,11 @@
   Info.SetArchitecture(arch_spec);
   Info.SetArguments(args, true);
   Info.GetEnvironment() = Host::GetEnvironment();
+  // TODO: Use this callback to detect botched launches. If lldb-server does not
+  // start, we can print a nice error message here instead of hanging in
+  // Accept().
+  Info.SetMonitorProcessCallback(
+  [](lldb::pid_t, bool, int, int) { return true; }, false);
 
   status = Host::LaunchProcess(Info);
   if (status.Fail())
Index: source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
===
--- source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -866,11 +866,12 @@
 
   if (IsHost()) {
 // We are going to hand this process off to debugserver which will be in
-// charge of setting the exit status. We still need to reap it from lldb
-// but if we let the monitor thread also set the exit status, we set up a
-// race between debugserver & us for who will find out about the debugged
-// process's death.
-launch_info.GetFlags().Set(eLaunchFlagDontSetExitStatus);
+// charge of setting the exit status.  However, we still need to reap it
+// from lldb. So, make sure we use a exit callback which does not set exit
+// status.
+const bool monitor_signals = false;
+launch_info.SetMonitorProcessCallback(
+[](lldb::pid_t, bool, int, int) { return true; }, monitor_signals);
 process_sp = Platform::DebugProcess(launch_info, debugger, target, error);
   } else {
 if (m_remote_platform_sp)
Index: source/Host/macosx/Host.mm
===
--- source/Host/macosx/Host.mm
+++ source/Host/macosx/Host.mm
@@ -1497,15 +1497,9 @@
 launch_info.SetProcessID(pid);
 
 // Make sure we reap any processes we spawn or we will have zombies.
-if (!launch_info.MonitorProcess()) {
-  const bool monitor_signals = false;
-  Host::MonitorChildProcessCallback callback = nullptr;
-
-  if (!launch_info.GetFlags().Test(lldb::eLaunchFlagDontSetExitStatus))
-callback = Process::SetProcessExitStatus;
-
-  StartMonitoringChildProcess(callback, pid, monitor_signals);
-}
+bool monitoring = launch_info.MonitorProcess();
+(void)monitoring;
+assert(monitoring);
   } else {
 // Invalid process ID, something didn't go well
 if (error.Success())
Index: source/Host/common/NativeProcessProtocol.cpp
===
--- source/Host/common/NativeProcessProtocol.cpp
+++ source/Host/common/NativeProcessProtocol.cpp
@@ -13,7 +13,6 @@
 #include "lldb/Host/common/NativeRegisterContext.h"
 #include "lldb/Host/common/NativeThreadProtocol.h"
 #include "lldb/Host/common/SoftwareBreakpoint.h"
-#include "lldb/Target/Process.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/lldb-enumerations.h"
Index: source/Host/common/MonitoringProcessLauncher.cpp
===
--- source/Host/common/MonitoringProcessLauncher.cpp
+++ source/Host/common/MonitoringProcessLauncher.cpp
@@ -9,7 +9,6 @@
 
 #include "lldb/Host/MonitoringProcessLauncher.h"
 #include "lldb/Host/HostProcess.h"
-#include "lldb/Target/Process.h"
 #include "lldb/Target/ProcessLaunchInfo.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Status.h"
@@ -58,18 +57,9 @@
   if (process.GetProcessId() != LLDB_INVALID_PROCESS_ID) {
 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
 
-Host::MonitorChildProcessCallback callback =
-launch_info.GetMonitorProcessCallback();
-
-bool monitor_signals = false;
-if (callback) {
-  // If the Process

[Lldb-commits] [PATCH] D46395: Remove Process references from the Host module

2018-05-03 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

This is a cleaner approach.  Might be worth adding a comment in the 
MonitoringProcessLauncher.h saying that the monitoring callback in the 
ProcessLaunchInfo is required?  You might from the name assume that it was 
doing monitoring for you.


https://reviews.llvm.org/D46395



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


[Lldb-commits] [PATCH] D46395: Remove Process references from the Host module

2018-05-03 Thread Davide Italiano via Phabricator via lldb-commits
davide accepted this revision.
davide added a comment.

lg


https://reviews.llvm.org/D46395



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


[Lldb-commits] [PATCH] D46395: Remove Process references from the Host module

2018-05-03 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: source/Host/macosx/Host.mm:1501
+bool monitoring = launch_info.MonitorProcess();
+(void)monitoring;
+assert(monitoring);

Do we not have a macro for silencing unused variables?



Comment at: source/Plugins/Platform/POSIX/PlatformPOSIX.cpp:873-874
+const bool monitor_signals = false;
+launch_info.SetMonitorProcessCallback(
+[](lldb::pid_t, bool, int, int) { return true; }, monitor_signals);
 process_sp = Platform::DebugProcess(launch_info, debugger, target, error);

Now we won't reap the process from within LLDB or is the comment is wrong? This 
looks wrong. Also, if we truly have places that don't need to reap the process, 
then we should add a "launch_info.SetDefaultDontReapCallback()" or something to 
launch_info that will install a default do nothing callback instead of one or 
more clients doing this



Comment at: unittests/tools/lldb-server/tests/TestClient.cpp:119
+  Info.SetMonitorProcessCallback(
+  [](lldb::pid_t, bool, int, int) { return true; }, false);
 

I know on Mac we still must reap the process from both the process that 
launches (lldb) it **and** the ptrace parent process (lldb-server or 
debugserver). This will create zombies and buildbots will die horribly if this 
is wrong


https://reviews.llvm.org/D46395



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


[Lldb-commits] [lldb] r331479 - Add back condition that was accidentally removed in r331462.

2018-05-03 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu May  3 13:13:58 2018
New Revision: 331479

URL: http://llvm.org/viewvc/llvm-project?rev=331479&view=rev
Log:
Add back condition that was accidentally removed in r331462.

This should make the bots much happier.

Modified:
lldb/trunk/source/Core/ValueObjectVariable.cpp

Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=331479&r1=331478&r2=331479&view=diff
==
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Thu May  3 13:13:58 2018
@@ -234,10 +234,12 @@ bool ValueObjectVariable::UpdateValue()
 // If this variable is a simple type, we read all data for it into
 // m_data. Make sure this type has a value before we try and read it
 
-SymbolContext var_sc;
-variable->CalculateSymbolContext(&var_sc);
 // If we have a file address, convert it to a load address if we can.
-m_value.ConvertToLoadAddress(var_sc);
+if (value_type == Value::eValueTypeFileAddress && process_is_alive) {
+  SymbolContext var_sc;
+  variable->CalculateSymbolContext(&var_sc);
+  m_value.ConvertToLoadAddress(var_sc);
+}
 
 if (!CanProvideValue()) {
   // this value object represents an aggregate type whose children have


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


[Lldb-commits] [PATCH] D46362: DWARFExpression: Convert file addresses to load addresses early on

2018-05-03 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

It looks like this has caused a bunch of tests to crash on linux 
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/22800. 
The crashes seem to be happening during printing of global variables ( 
`HandleCommand(command = "target variable my_global_char")` and such). Can you 
take a look?


Repository:
  rL LLVM

https://reviews.llvm.org/D46362



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


Re: [Lldb-commits] [lldb] r331479 - Add back condition that was accidentally removed in r331462.

2018-05-03 Thread Greg Clayton via lldb-commits
Was this the "please make sure global variable expression can be evaluated when 
not running" issue you ran into?

> On May 3, 2018, at 1:13 PM, Adrian Prantl via lldb-commits 
>  wrote:
> 
> Author: adrian
> Date: Thu May  3 13:13:58 2018
> New Revision: 331479
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=331479&view=rev
> Log:
> Add back condition that was accidentally removed in r331462.
> 
> This should make the bots much happier.
> 
> Modified:
>lldb/trunk/source/Core/ValueObjectVariable.cpp
> 
> Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=331479&r1=331478&r2=331479&view=diff
> ==
> --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
> +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Thu May  3 13:13:58 2018
> @@ -234,10 +234,12 @@ bool ValueObjectVariable::UpdateValue()
> // If this variable is a simple type, we read all data for it into
> // m_data. Make sure this type has a value before we try and read it
> 
> -SymbolContext var_sc;
> -variable->CalculateSymbolContext(&var_sc);
> // If we have a file address, convert it to a load address if we can.
> -m_value.ConvertToLoadAddress(var_sc);
> +if (value_type == Value::eValueTypeFileAddress && process_is_alive) {
> +  SymbolContext var_sc;
> +  variable->CalculateSymbolContext(&var_sc);
> +  m_value.ConvertToLoadAddress(var_sc);
> +}
> 
> if (!CanProvideValue()) {
>   // this value object represents an aggregate type whose children 
> have
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [lldb] r331480 - Revert "DWARFExpression: Convert file addresses to load addresses early on."

2018-05-03 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu May  3 13:19:39 2018
New Revision: 331480

URL: http://llvm.org/viewvc/llvm-project?rev=331480&view=rev
Log:
Revert "DWARFExpression: Convert file addresses to load addresses early on."

This reverts commit 331462 while investigating bot breakage.

Modified:
lldb/trunk/include/lldb/Core/Value.h
lldb/trunk/source/Core/Value.cpp
lldb/trunk/source/Core/ValueObjectVariable.cpp
lldb/trunk/source/Expression/DWARFExpression.cpp

Modified: lldb/trunk/include/lldb/Core/Value.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=331480&r1=331479&r2=331480&view=diff
==
--- lldb/trunk/include/lldb/Core/Value.h (original)
+++ lldb/trunk/include/lldb/Core/Value.h Thu May  3 13:19:39 2018
@@ -228,9 +228,6 @@ public:
 
   static const char *GetContextTypeAsCString(ContextType context_type);
 
-  /// Convert this value's file address to a load address, if possible.
-  void ConvertToLoadAddress(SymbolContext sc);
-
   bool GetData(DataExtractor &data);
 
   void Clear();

Modified: lldb/trunk/source/Core/Value.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=331480&r1=331479&r2=331480&view=diff
==
--- lldb/trunk/source/Core/Value.cpp (original)
+++ lldb/trunk/source/Core/Value.cpp Thu May  3 13:19:39 2018
@@ -669,28 +669,6 @@ const char *Value::GetContextTypeAsCStri
   return "???";
 }
 
-void Value::ConvertToLoadAddress(SymbolContext sc) {
-  if (GetValueType() != eValueTypeFileAddress)
-return;
-
-  if (!sc.module_sp)
-return;
-
-  lldb::addr_t file_addr = GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
-  if (file_addr == LLDB_INVALID_ADDRESS)
-return;
-
-  Address so_addr;
-  if (!sc.module_sp->ResolveFileAddress(file_addr, so_addr))
-return;
-  lldb::addr_t load_addr = so_addr.GetLoadAddress(sc.target_sp.get());
-  if (load_addr == LLDB_INVALID_ADDRESS)
-return;
-
-  SetValueType(Value::eValueTypeLoadAddress);
-  GetScalar() = load_addr;
-}
-
 ValueList::ValueList(const ValueList &rhs) { m_values = rhs.m_values; }
 
 const ValueList &ValueList::operator=(const ValueList &rhs) {

Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=331480&r1=331479&r2=331480&view=diff
==
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Thu May  3 13:19:39 2018
@@ -236,9 +236,23 @@ bool ValueObjectVariable::UpdateValue()
 
 // If we have a file address, convert it to a load address if we can.
 if (value_type == Value::eValueTypeFileAddress && process_is_alive) {
-  SymbolContext var_sc;
-  variable->CalculateSymbolContext(&var_sc);
-  m_value.ConvertToLoadAddress(var_sc);
+  lldb::addr_t file_addr =
+  m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+  if (file_addr != LLDB_INVALID_ADDRESS) {
+SymbolContext var_sc;
+variable->CalculateSymbolContext(&var_sc);
+if (var_sc.module_sp) {
+  ObjectFile *objfile = var_sc.module_sp->GetObjectFile();
+  if (objfile) {
+Address so_addr(file_addr, objfile->GetSectionList());
+lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
+if (load_addr != LLDB_INVALID_ADDRESS) {
+  m_value.SetValueType(Value::eValueTypeLoadAddress);
+  m_value.GetScalar() = load_addr;
+}
+  }
+}
+  }
 }
 
 if (!CanProvideValue()) {

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=331480&r1=331479&r2=331480&view=diff
==
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Thu May  3 13:19:39 2018
@@ -1379,13 +1379,10 @@ bool DWARFExpression::Evaluate(
 // The DW_OP_addr operation has a single operand that encodes a machine
 // address and whose size is the size of an address on the target machine.
 //--
-case DW_OP_addr: {
+case DW_OP_addr:
   stack.push_back(Scalar(opcodes.GetAddress(&offset)));
   stack.back().SetValueType(Value::eValueTypeFileAddress);
-  auto sc = frame->GetSymbolContext(eSymbolContextFunction);
-  stack.back().ConvertToLoadAddress(sc);
   break;
-}
 
 //--
 // The DW_OP_addr_sect_offset4 is used for a

[Lldb-commits] [PATCH] D46362: DWARFExpression: Convert file addresses to load addresses early on

2018-05-03 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Yes, I must have added a mistake in my last edit before landing this. I 
reverted that patch for now.


Repository:
  rL LLVM

https://reviews.llvm.org/D46362



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


Re: [Lldb-commits] [lldb] r331480 - Revert "DWARFExpression: Convert file addresses to load addresses early on."

2018-05-03 Thread Greg Clayton via lldb-commits
One issue after looking closer at the code is you didn't specify you wanted the 
target filled in when calling:

auto sc = frame->GetSymbolContext(eSymbolContextFunction);


It should be:

auto sc = frame->GetSymbolContext(eSymbolContextTarget | eSymbolContextModule | 
eSymbolContextCompUnit | eSymbolContextFunction);

I also doubt that "variable->CalculateSymbolContext(&var_sc);" fills in the 
target correctly. You can manually fill the target and module in if needed.




> On May 3, 2018, at 1:19 PM, Adrian Prantl via lldb-commits 
>  wrote:
> 
> Author: adrian
> Date: Thu May  3 13:19:39 2018
> New Revision: 331480
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=331480&view=rev
> Log:
> Revert "DWARFExpression: Convert file addresses to load addresses early on."
> 
> This reverts commit 331462 while investigating bot breakage.
> 
> Modified:
>lldb/trunk/include/lldb/Core/Value.h
>lldb/trunk/source/Core/Value.cpp
>lldb/trunk/source/Core/ValueObjectVariable.cpp
>lldb/trunk/source/Expression/DWARFExpression.cpp
> 
> Modified: lldb/trunk/include/lldb/Core/Value.h
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=331480&r1=331479&r2=331480&view=diff
> ==
> --- lldb/trunk/include/lldb/Core/Value.h (original)
> +++ lldb/trunk/include/lldb/Core/Value.h Thu May  3 13:19:39 2018
> @@ -228,9 +228,6 @@ public:
> 
>   static const char *GetContextTypeAsCString(ContextType context_type);
> 
> -  /// Convert this value's file address to a load address, if possible.
> -  void ConvertToLoadAddress(SymbolContext sc);
> -
>   bool GetData(DataExtractor &data);
> 
>   void Clear();
> 
> Modified: lldb/trunk/source/Core/Value.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=331480&r1=331479&r2=331480&view=diff
> ==
> --- lldb/trunk/source/Core/Value.cpp (original)
> +++ lldb/trunk/source/Core/Value.cpp Thu May  3 13:19:39 2018
> @@ -669,28 +669,6 @@ const char *Value::GetContextTypeAsCStri
>   return "???";
> }
> 
> -void Value::ConvertToLoadAddress(SymbolContext sc) {
> -  if (GetValueType() != eValueTypeFileAddress)
> -return;
> -
> -  if (!sc.module_sp)
> -return;
> -
> -  lldb::addr_t file_addr = GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
> -  if (file_addr == LLDB_INVALID_ADDRESS)
> -return;
> -
> -  Address so_addr;
> -  if (!sc.module_sp->ResolveFileAddress(file_addr, so_addr))
> -return;
> -  lldb::addr_t load_addr = so_addr.GetLoadAddress(sc.target_sp.get());
> -  if (load_addr == LLDB_INVALID_ADDRESS)
> -return;
> -
> -  SetValueType(Value::eValueTypeLoadAddress);
> -  GetScalar() = load_addr;
> -}
> -
> ValueList::ValueList(const ValueList &rhs) { m_values = rhs.m_values; }
> 
> const ValueList &ValueList::operator=(const ValueList &rhs) {
> 
> Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=331480&r1=331479&r2=331480&view=diff
> ==
> --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
> +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Thu May  3 13:19:39 2018
> @@ -236,9 +236,23 @@ bool ValueObjectVariable::UpdateValue()
> 
> // If we have a file address, convert it to a load address if we can.
> if (value_type == Value::eValueTypeFileAddress && process_is_alive) {
> -  SymbolContext var_sc;
> -  variable->CalculateSymbolContext(&var_sc);
> -  m_value.ConvertToLoadAddress(var_sc);
> +  lldb::addr_t file_addr =
> +  m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
> +  if (file_addr != LLDB_INVALID_ADDRESS) {
> +SymbolContext var_sc;
> +variable->CalculateSymbolContext(&var_sc);
> +if (var_sc.module_sp) {
> +  ObjectFile *objfile = var_sc.module_sp->GetObjectFile();
> +  if (objfile) {
> +Address so_addr(file_addr, objfile->GetSectionList());
> +lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
> +if (load_addr != LLDB_INVALID_ADDRESS) {
> +  m_value.SetValueType(Value::eValueTypeLoadAddress);
> +  m_value.GetScalar() = load_addr;
> +}
> +  }
> +}
> +  }
> }
> 
> if (!CanProvideValue()) {
> 
> Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=331480&r1=331479&r2=331480&view=diff
> ==
> --- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
> +++ lldb/trunk/source/Expression/DWARFExpression.cpp 

Re: [Lldb-commits] [lldb] r331082 - Fix build bots after r331049 broke them.

2018-05-03 Thread Davide Italiano via lldb-commits
On Fri, Apr 27, 2018 at 2:10 PM, Greg Clayton via lldb-commits
 wrote:
> Author: gclayton
> Date: Fri Apr 27 14:10:07 2018
> New Revision: 331082
>
> URL: http://llvm.org/viewvc/llvm-project?rev=331082&view=rev
> Log:
> Fix build bots after r331049 broke them.
>

I would like to apologize for communicating this so late (mainly
because I worked on the swift bits which are a little behind and I
didn't update my checkout) but this commit completely broke debugging
in some cases (on MacOS).

Testcase:

#import 

int main() {
  id keys[1] = { @"abc" };
  id values[1] = { @"def" };
  id d = CFBridgingRelease(CFDictionaryCreate(nil, (void *)keys, (void
*)values, 1, nil, nil));
  NSLog(@"%@", d);
  NSLog(@"x");
}


$ clang patatino.m -framework Foundation -g -o blah


dtdebugger2:bin davide$ ./lldb ./blah
(lldb) target create "./blah"
Current executable set to './blah' (x86_64).
(lldb) b main
Breakpoint 1: where = blah`main + 13 at blah.c:2, address =
0x00010fad
(lldb) r
error: No such file or directory

Reverting yours (and a later change to avoid conflicts):

dtdebugger2:llvm-project-20170507 davide$ git revert 57dce7084e7b
[master 8be66051362] Revert "Fixup r331049 (FileSpec
auto-normalization)"
2 files changed, 11 insertions(+), 5 deletions(-)
dtdebugger2:llvm-project-20170507 davide$ git revert
d5a834a73c0b37c3862daee260c416e7ea3b761c
[master 5bd1fb68a69] Revert "Fix build bots after r331049 broke them."
1 file changed, 10 insertions(+), 10 deletions(-)

works.
I also noticed that if I pass a full path the thing works:

Current executable set to
'/Users/davide/work/llvm-monorepo/build/bin/blah' (x86_64).
(lldb) b main
Breakpoint 1: where = blah`main + 13 at blah.c:2, address = 0x00010fad
(lldb) r
Process 82833 launched:
'/Users/davide/work/llvm-monorepo/build/bin/blah' (x86_64)
Process 82833 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x00010fad blah`main at blah.c:2
   1int main(void) {
-> 2  return 0;
   3}


Do you mind to take a look and add a lit test for this?

Thanks!

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


Re: [Lldb-commits] [lldb] r331082 - Fix build bots after r331049 broke them.

2018-05-03 Thread Davide Italiano via lldb-commits
I would like to apologize for communicating this so late (mainly
because I worked on the swift bits which are a little behind and I
didn't update my checkout) but this commit completely broke debugging
in some cases (on MacOS).

Testcase:

#import 

int main() {
  id keys[1] = { @"abc" };
  id values[1] = { @"def" };
  id d = CFBridgingRelease(CFDictionaryCreate(nil, (void *)keys, (void
*)values, 1, nil, nil));
  NSLog(@"%@", d);
  NSLog(@"x");
}


$ clang patatino.m -framework Foundation -g -o blah


dtdebugger2:bin davide$ ./lldb ./blah
(lldb) target create "./blah"
Current executable set to './blah' (x86_64).
(lldb) b main
Breakpoint 1: where = blah`main + 13 at blah.c:2, address =
0x00010fad
(lldb) r
error: No such file or directory

Reverting yours (and a later change to avoid conflicts):

dtdebugger2:llvm-project-20170507 davide$ git revert 57dce7084e7b
[master 8be66051362] Revert "Fixup r331049 (FileSpec
auto-normalization)"
2 files changed, 11 insertions(+), 5 deletions(-)
dtdebugger2:llvm-project-20170507 davide$ git revert
d5a834a73c0b37c3862daee260c416e7ea3b761c
[master 5bd1fb68a69] Revert "Fix build bots after r331049 broke them."
1 file changed, 10 insertions(+), 10 deletions(-)

works.
I also noticed that if I pass a full path the thing works:

Current executable set to
'/Users/davide/work/llvm-monorepo/build/bin/blah' (x86_64).
(lldb) b main
Breakpoint 1: where = blah`main + 13 at blah.c:2, address = 0x00010fad
(lldb) r
Process 82833 launched:
'/Users/davide/work/llvm-monorepo/build/bin/blah' (x86_64)
Process 82833 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x00010fad blah`main at blah.c:2
   1int main(void) {
-> 2  return 0;
   3}


Do you mind to take a look and add a lit test for this?
(also, I guess you should change your mail address as it's still an @apple one).

Thanks!

--
Davide

On Thu, May 3, 2018 at 3:07 PM, Davide Italiano  wrote:
> On Fri, Apr 27, 2018 at 2:10 PM, Greg Clayton via lldb-commits
>  wrote:
>> Author: gclayton
>> Date: Fri Apr 27 14:10:07 2018
>> New Revision: 331082
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=331082&view=rev
>> Log:
>> Fix build bots after r331049 broke them.
>>
>
> I would like to apologize for communicating this so late (mainly
> because I worked on the swift bits which are a little behind and I
> didn't update my checkout) but this commit completely broke debugging
> in some cases (on MacOS).
>
> Testcase:
>
> #import 
>
> int main() {
>   id keys[1] = { @"abc" };
>   id values[1] = { @"def" };
>   id d = CFBridgingRelease(CFDictionaryCreate(nil, (void *)keys, (void
> *)values, 1, nil, nil));
>   NSLog(@"%@", d);
>   NSLog(@"x");
> }
>
>
> $ clang patatino.m -framework Foundation -g -o blah
>
>
> dtdebugger2:bin davide$ ./lldb ./blah
> (lldb) target create "./blah"
> Current executable set to './blah' (x86_64).
> (lldb) b main
> Breakpoint 1: where = blah`main + 13 at blah.c:2, address =
> 0x00010fad
> (lldb) r
> error: No such file or directory
>
> Reverting yours (and a later change to avoid conflicts):
>
> dtdebugger2:llvm-project-20170507 davide$ git revert 57dce7084e7b
> [master 8be66051362] Revert "Fixup r331049 (FileSpec
> auto-normalization)"
> 2 files changed, 11 insertions(+), 5 deletions(-)
> dtdebugger2:llvm-project-20170507 davide$ git revert
> d5a834a73c0b37c3862daee260c416e7ea3b761c
> [master 5bd1fb68a69] Revert "Fix build bots after r331049 broke them."
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> works.
> I also noticed that if I pass a full path the thing works:
>
> Current executable set to
> '/Users/davide/work/llvm-monorepo/build/bin/blah' (x86_64).
> (lldb) b main
> Breakpoint 1: where = blah`main + 13 at blah.c:2, address = 0x00010fad
> (lldb) r
> Process 82833 launched:
> '/Users/davide/work/llvm-monorepo/build/bin/blah' (x86_64)
> Process 82833 stopped
> * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
> frame #0: 0x00010fad blah`main at blah.c:2
>1int main(void) {
> -> 2  return 0;
>3}
>
>
> Do you mind to take a look and add a lit test for this?
>
> Thanks!
>
> --
> Davide
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r331492 - DWARFExpression: Convert file addresses to load addresses early on.

2018-05-03 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Thu May  3 16:32:47 2018
New Revision: 331492

URL: http://llvm.org/viewvc/llvm-project?rev=331492&view=rev
Log:
DWARFExpression: Convert file addresses to load addresses early on.

This is a change that only affects Swift and is NFC for the language
plugins on llvm.org. In Swift, we can have global variables with a
location such as DW_OP_addr  DW_OP_deref. The DWARF expression
evaluator doesn't know how to apply a DW_OP_deref to a file address,
but at the very end we convert the file address into a load address.

This patch moves the file->load address conversion to right after the
result of the DW_OP_addr is pushed onto the stack so that a subsequent
DW_OP_deref (and potentially other operations) can be interpreted.

rdar://problem/39767528

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

Modified:
lldb/trunk/include/lldb/Core/Value.h
lldb/trunk/source/Core/Value.cpp
lldb/trunk/source/Core/ValueObjectVariable.cpp
lldb/trunk/source/Expression/DWARFExpression.cpp

Modified: lldb/trunk/include/lldb/Core/Value.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=331492&r1=331491&r2=331492&view=diff
==
--- lldb/trunk/include/lldb/Core/Value.h (original)
+++ lldb/trunk/include/lldb/Core/Value.h Thu May  3 16:32:47 2018
@@ -228,6 +228,9 @@ public:
 
   static const char *GetContextTypeAsCString(ContextType context_type);
 
+  /// Convert this value's file address to a load address, if possible.
+  void ConvertToLoadAddress(Module *module, Target *target);
+
   bool GetData(DataExtractor &data);
 
   void Clear();

Modified: lldb/trunk/source/Core/Value.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=331492&r1=331491&r2=331492&view=diff
==
--- lldb/trunk/source/Core/Value.cpp (original)
+++ lldb/trunk/source/Core/Value.cpp Thu May  3 16:32:47 2018
@@ -669,6 +669,25 @@ const char *Value::GetContextTypeAsCStri
   return "???";
 }
 
+void Value::ConvertToLoadAddress(Module *module, Target *target) {
+  if (!module || !target || (GetValueType() != eValueTypeFileAddress))
+return;
+
+  lldb::addr_t file_addr = GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
+  if (file_addr == LLDB_INVALID_ADDRESS)
+return;
+
+  Address so_addr;
+  if (!module->ResolveFileAddress(file_addr, so_addr))
+return;
+  lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
+  if (load_addr == LLDB_INVALID_ADDRESS)
+return;
+
+  SetValueType(Value::eValueTypeLoadAddress);
+  GetScalar() = load_addr;
+}
+
 ValueList::ValueList(const ValueList &rhs) { m_values = rhs.m_values; }
 
 const ValueList &ValueList::operator=(const ValueList &rhs) {

Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=331492&r1=331491&r2=331492&view=diff
==
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Thu May  3 16:32:47 2018
@@ -235,25 +235,8 @@ bool ValueObjectVariable::UpdateValue()
 // m_data. Make sure this type has a value before we try and read it
 
 // If we have a file address, convert it to a load address if we can.
-if (value_type == Value::eValueTypeFileAddress && process_is_alive) {
-  lldb::addr_t file_addr =
-  m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
-  if (file_addr != LLDB_INVALID_ADDRESS) {
-SymbolContext var_sc;
-variable->CalculateSymbolContext(&var_sc);
-if (var_sc.module_sp) {
-  ObjectFile *objfile = var_sc.module_sp->GetObjectFile();
-  if (objfile) {
-Address so_addr(file_addr, objfile->GetSectionList());
-lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
-if (load_addr != LLDB_INVALID_ADDRESS) {
-  m_value.SetValueType(Value::eValueTypeLoadAddress);
-  m_value.GetScalar() = load_addr;
-}
-  }
-}
-  }
-}
+if (value_type == Value::eValueTypeFileAddress && process_is_alive)
+  m_value.ConvertToLoadAddress(GetModule().get(), target);
 
 if (!CanProvideValue()) {
   // this value object represents an aggregate type whose children have

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=331492&r1=331491&r2=331492&view=diff
==
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Thu May  3 16:32:47 2018
@@

[Lldb-commits] [PATCH] D46362: DWARFExpression: Convert file addresses to load addresses early on

2018-05-03 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

As Greg suspected, the problem was that target was null. I rewrote that patch 
to not use a SymbolContext in the first place.


Repository:
  rL LLVM

https://reviews.llvm.org/D46362



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


[Lldb-commits] [lldb] r331497 - The on-ios-device command line lldb has an optimization where

2018-05-03 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Thu May  3 17:59:37 2018
New Revision: 331497

URL: http://llvm.org/viewvc/llvm-project?rev=331497&view=rev
Log:
The on-ios-device command line lldb has an optimization where
when it and the inferior process both have the same shared cache
(a conglomeration of all libraries at the same fixed address for
all processes), lldb will read data out of its own memory to speed
things up.  The shared cache has a UUID, so lldb currently checks
that the UUID of its own shared cache matches that of the inferior.

This change adds one refinement to that -- it checks that the UUID
is the same and that the base address of the shared cache is the
same.  And only uses its local shared cache if they are both identical.

This involved using a different style of SPI with dyld to get lldb's
shared cache load address, but it's not especially difficult.

One unattractive part of the change is that I'm using the real
underlying types of task_t and kern_return_t instead of picking
them up from mach/mach.h.  The defines that get picked up there (a
lot from machine.h but others too) conflict with llvm/Support/MachO.h
even when I have mach.h included before our SafeMachO.h which
undefines most of the defines before including llvm/Support/MachO.h.
I'll need to augment the #undefs in SafeMachO.h to get this to
compile cleanly, but that'll be another day.

 

Modified:
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=331497&r1=331496&r2=331497&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu May  3 
17:59:37 2018
@@ -2280,17 +2280,17 @@ size_t ObjectFileMachO::ParseSymtab() {
   // this by reading the memory for the __LINKEDIT section from this
   // process.
 
-  UUID lldb_shared_cache(GetLLDBSharedCacheUUID());
-  UUID process_shared_cache(GetProcessSharedCacheUUID(process));
+  UUID lldb_shared_cache;
+  addr_t lldb_shared_cache_addr;
+  GetLLDBSharedCacheUUID (lldb_shared_cache_addr, lldb_shared_cache);
+  UUID process_shared_cache;
+  addr_t process_shared_cache_addr;
+  GetProcessSharedCacheUUID(process, process_shared_cache_addr, 
process_shared_cache);
   bool use_lldb_cache = true;
   if (lldb_shared_cache.IsValid() && process_shared_cache.IsValid() &&
-  lldb_shared_cache != process_shared_cache) {
+  (lldb_shared_cache != process_shared_cache
+   || process_shared_cache_addr != lldb_shared_cache_addr)) {
 use_lldb_cache = false;
-ModuleSP module_sp(GetModule());
-if (module_sp)
-  module_sp->ReportWarning("shared cache in process does not match 
"
-   "lldb's own shared cache, startup will "
-   "be slow.");
   }
 
   PlatformSP platform_sp(target.GetPlatform());
@@ -2605,9 +2605,10 @@ size_t ObjectFileMachO::ParseSymtab() {
 
   UUID dsc_uuid;
   UUID process_shared_cache_uuid;
+  addr_t process_shared_cache_base_addr;
 
   if (process) {
-process_shared_cache_uuid = GetProcessSharedCacheUUID(process);
+GetProcessSharedCacheUUID(process, process_shared_cache_base_addr, 
process_shared_cache_uuid);
   }
 
   // First see if we can find an exact match for the inferior process
@@ -5577,24 +5578,40 @@ bool ObjectFileMachO::GetArchitecture(Ar
   return false;
 }
 
-UUID ObjectFileMachO::GetProcessSharedCacheUUID(Process *process) {
-  UUID uuid;
+void ObjectFileMachO::GetProcessSharedCacheUUID(Process *process, addr_t 
&base_addr, UUID &uuid) {
+  uuid.Clear();
+  base_addr = LLDB_INVALID_ADDRESS;
   if (process && process->GetDynamicLoader()) {
 DynamicLoader *dl = process->GetDynamicLoader();
-addr_t load_address;
 LazyBool using_shared_cache;
 LazyBool private_shared_cache;
-dl->GetSharedCacheInformation(load_address, uuid, using_shared_cache,
+dl->GetSharedCacheInformation(base_addr, uuid, using_shared_cache,
   private_shared_cache);
   }
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS | 
LIBLLDB_LOG_PROCESS));
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS | 
LIBLLDB_LOG_PROCESS));
   if (log)
-log->Printf("inferior process shared cache has a UUID of %s", 
uuid.GetAsString().c_str());
-  return uuid;
+log->Printf("inferior process shared cache has a UUID of %s, base address 
0x%" PRIx64 , uuid.GetAsString().c_str(), base_addr);
 }
 
-UUID

[Lldb-commits] [lldb] r331501 - Add children and child[N] properties to SBValue.i.

2018-05-03 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Thu May  3 18:31:47 2018
New Revision: 331501

URL: http://llvm.org/viewvc/llvm-project?rev=331501&view=rev
Log:
Add children and child[N] properties to SBValue.i.

Also fixed some bad formatting in SBValue.i.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
lldb/trunk/scripts/interface/SBValue.i

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py?rev=331501&r1=331500&r2=331501&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py 
Thu May  3 18:31:47 2018
@@ -61,9 +61,23 @@ class ValueAPITestCase(TestBase):
 list = target.FindGlobalVariables('days_of_week', 1)
 days_of_week = list.GetValueAtIndex(0)
 self.assertTrue(days_of_week, VALID_VARIABLE)
-self.assertTrue(days_of_week.GetNumChildren() == 7, VALID_VARIABLE)
+self.assertEqual(days_of_week.GetNumChildren(), 7, VALID_VARIABLE)
 self.DebugSBValue(days_of_week)
 
+# Use this to test the "child" and "children" accessors:
+children = days_of_week.children
+self.assertEqual(len(children), 7, VALID_VARIABLE)
+for i in range(0, len(children)):
+day = days_of_week.child[i]
+list_day = children[i]
+self.assertNotEqual(day, None)
+self.assertNotEqual(list_day, None)
+self.assertEqual(day.GetSummary(), list_day.GetSummary(), 
VALID_VARIABLE)
+
+# Spot check the actual value:
+first_day = days_of_week.child[1]
+self.assertEqual(first_day.GetSummary(), '"Monday"', VALID_VARIABLE)
+
 # Get global variable 'weekdays'.
 list = target.FindGlobalVariables('weekdays', 1)
 weekdays = list.GetValueAtIndex(0)

Modified: lldb/trunk/scripts/interface/SBValue.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBValue.i?rev=331501&r1=331500&r2=331501&view=diff
==
--- lldb/trunk/scripts/interface/SBValue.i (original)
+++ lldb/trunk/scripts/interface/SBValue.i Thu May  3 18:31:47 2018
@@ -265,10 +265,10 @@ public:
 lldb::SBValue
 CreateValueFromAddress(const char* name, lldb::addr_t address, 
lldb::SBType type);
 
-   lldb::SBValue
-   CreateValueFromData (const char* name,
-lldb::SBData data,
-lldb::SBType type);
+  lldb::SBValue
+  CreateValueFromData (const char* name,
+   lldb::SBData data,
+   lldb::SBType type);
 
 lldb::SBType
 GetType();
@@ -391,8 +391,8 @@ public:
 bool
 GetExpressionPath (lldb::SBStream &description);
 
-   %feature("docstring", "
-   //--
+  %feature("docstring", "
+  //--
 /// Get an SBData wrapping what this SBValue points to.
 ///
 /// This method will dereference the current SBValue, if its
@@ -413,13 +413,13 @@ public:
 /// An SBData with the contents of the copied items, on success.
 /// An empty SBData otherwise.
 //--
-   ") GetPointeeData;
-   lldb::SBData
-   GetPointeeData (uint32_t item_idx = 0,
-   uint32_t item_count = 1);
+  ") GetPointeeData;
+  lldb::SBData
+  GetPointeeData (uint32_t item_idx = 0,
+  uint32_t item_count = 1);
 
 %feature("docstring", "
-   //--
+  //--
 /// Get an SBData wrapping the contents of this SBValue.
 ///
 /// This method will read the contents of this object in memory
@@ -429,18 +429,18 @@ public:
 /// An SBData with the contents of this SBValue, on success.
 /// An empty SBData otherwise.
 //--
-   ") GetData;
+  ") GetData;
 lldb::SBData
 GetData ();
  
 bool
 SetData (lldb::SBData &data, lldb::SBError& error);
 
-   lldb::addr_t
-   GetLoadAddress();
+  lldb::addr_t
+  GetLoadAddress();
 
-   lldb::SBAddress
-   GetAddress();
+  lldb::SBAddress
+  GetAddress();
 
 lldb::SBValue
 Persist ();
@@ -455,6 +455,40 @@ public:
 '''Helper function for the "SBValue.dynamic" property.'''
 return self.GetDynamicValue (eDynamicCanRunTarget)
 
+class children_access(object):
+