[Lldb-commits] [PATCH] D78421: Fix out of sync source code/executable when debugging

2020-05-04 Thread Martin Schmidt via Phabricator via lldb-commits
n1tram1 updated this revision to Diff 261742.
n1tram1 added a comment.

Have the File first check if it is the current stack frame being displayed and 
check if it needs an update that way.
Else, iteratively look for it's belonging module and check if it needs an 
update.

Also fix the SourceCache::AddSourceFile function by using the input file as a 
key (Before the key was always the default constructor of FileSpec).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78421

Files:
  lldb/include/lldb/Core/SourceManager.h
  lldb/source/Core/SourceManager.cpp
  lldb/test/API/source-manager/TestSourceManager.py

Index: lldb/test/API/source-manager/TestSourceManager.py
===
--- lldb/test/API/source-manager/TestSourceManager.py
+++ lldb/test/API/source-manager/TestSourceManager.py
@@ -230,12 +230,14 @@
 "os.path.getmtime() after writing new content:",
 os.path.getmtime(self.file))
 
-# Display the source code again.  We should see the updated line.
+# Display the source code again.
+# We should not see the updated line or there would be an incoherence
+# with the module being ran.
 self.expect(
 "source list -f main-copy.c -l %d" %
 self.line,
 SOURCE_DISPLAYED_CORRECTLY,
-substrs=['Hello lldb'])
+substrs=['Hello world'])
 
 def test_set_breakpoint_with_absolute_path(self):
 self.build()
Index: lldb/source/Core/SourceManager.cpp
===
--- lldb/source/Core/SourceManager.cpp
+++ lldb/source/Core/SourceManager.cpp
@@ -21,7 +21,10 @@
 #include "lldb/Symbol/LineEntry.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/PathMappingList.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
 #include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/DataBuffer.h"
@@ -30,6 +33,8 @@
 #include "lldb/Utility/Stream.h"
 #include "lldb/lldb-enumerations.h"
 
+#include "lldb/Utility/Log.h"
+
 #include "llvm/ADT/Twine.h"
 
 #include 
@@ -436,7 +441,8 @@
 sc_list.GetContextAtIndex(0, sc);
 if (sc.comp_unit)
   m_file_spec = sc.comp_unit->GetPrimaryFile();
-m_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec);
+m_mod_time =
+FileSystem::Instance().GetModificationTime(m_file_spec);
   }
 }
   }
@@ -531,12 +537,107 @@
   // For now we check each time we want to display info for the file.
   auto curr_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec);
 
+  // If the source file is newer than the module don't update,
+  // otherwise the source file being displayed will be different from
+  // the module being ran.
+  // (We only want to update if the module has been recompiled)
+  if (IsCurrentModuleAndNewer(curr_mod_time) ||
+  IsNewerThanItsModule(curr_mod_time))
+// TODO: maybe issue a:
+// 'warning: Source file is more recent than executable.' ?
+return;
+
   if (curr_mod_time != llvm::sys::TimePoint<>() &&
   m_mod_time != curr_mod_time) {
-m_mod_time = curr_mod_time;
-m_data_sp = FileSystem::Instance().CreateDataBuffer(m_file_spec);
-m_offsets.clear();
+Update(curr_mod_time);
+  }
+}
+
+bool SourceManager::File::IsCurrentModuleAndNewer(llvm::sys::TimePoint<> time) {
+  DebuggerSP debugger_sp(m_debugger_wp.lock());
+  if (!debugger_sp)
+return false;
+
+  lldb::TargetSP target_sp(debugger_sp->GetSelectedTarget());
+  if (!target_sp)
+return false;
+
+  lldb::ProcessSP process_sp(target_sp->CalculateProcess());
+  if (!process_sp)
+return false;
+
+  ThreadList &thread_list(process_sp->GetThreadList());
+
+  lldb::ThreadSP thread_sp(thread_list.GetSelectedThread());
+  if (!thread_sp)
+return false;
+
+  lldb::StackFrameSP stackframe_sp(thread_sp->GetSelectedFrame());
+  if (!stackframe_sp)
+return false;
+
+  const Address pc_addr(stackframe_sp->GetFrameCodeAddress());
+
+  lldb::ModuleSP current_module(pc_addr.GetModule());
+  if (!current_module)
+return false;
+
+  SymbolContextList sc_list;
+  auto num_matches = current_module->ResolveSymbolContextsForFileSpec(
+  m_file_spec, 0, false, eSymbolContextModule | eSymbolContextCompUnit,
+  sc_list);
+
+  if (!num_matches)
+return false;
+
+  // FIXME: We need to get the timestamp from the filesystem because the Module
+  // doesn't properly update its m_mod_time.
+  auto current_module_mod_time =
+  FileSystem::Instance().GetModificationTime(current_module->GetFileSpec());
+
+  return time > current_module_mod_time;
+}
+
+bool SourceManager::File::IsNewerThanItsModule(llvm::sys::TimeP

[Lldb-commits] [PATCH] D79251: Fix overloaded operator new cases in TestCppOperators.py which currently work by accident

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

LGTM, thanks!




Comment at: lldb/test/API/lang/cpp/operators/main.cpp:12
 
   bool custom_new = false;
   B b;

This can also go as it's now unused.


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

https://reviews.llvm.org/D79251



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


[Lldb-commits] [PATCH] D78712: [lldb/Host] Improve error messages on unowned read files

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

I'm not sure this new version is for the better :(.

Error and Expected objects have a contract where you're supposed to "consume" 
each object before you destroy or reassign it. The complex control flow in that 
function makes it very hard to see that this is really the case. I marked the 
cases where I believe you didn't do that, but I can't be sure I found all of 
them. For this kind of pattern to work there'd need to be more refactoring of 
the function in order to make the lifetime and state of the expected object 
more obvious. That's why I wasn't pushing for this direction in my previous 
comment...




Comment at: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp:96
 
-if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
-  error.Clear();
-else {
-  const uint32_t permissions = FileSystem::Instance().GetPermissions(
-  resolved_module_spec.GetFileSpec());
-  if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
-error.SetErrorStringWithFormat(
-"executable '%s' is not readable",
-resolved_module_spec.GetFileSpec().GetPath().c_str());
-  else
-error.SetErrorStringWithFormat(
-"unable to find executable for '%s'",
-resolved_module_spec.GetFileSpec().GetPath().c_str());
+resolved_module =
+FileSystem::Instance().Open(resolved_module_spec.GetFileSpec(),

here you'll need to do a `consumeError(resolved_module.takeError())` before you 
can reuse the object.



Comment at: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp:124
+exe_path);
+return error;
+  }

error not consumed here



Comment at: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp:197
+  else
+error.SetErrorStringWithFormatv(
+"'{0}' doesn't contain any '{1}' platform architectures: {2}",

error not consumed here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78712



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


[Lldb-commits] [PATCH] D77843: [lldb/DataFormatters] Delete GetStringPrinterEscapingHelper

2020-05-04 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.

Yeah, I think this looks good too.




Comment at: lldb/source/DataFormatters/StringPrinter.cpp:42-43
+  llvm_unreachable("unsupported length");
+memcpy(reinterpret_cast(m_data),
+   reinterpret_cast(bytes), size);
+  }

What's up with all the `reinterpret_cast`ing? `T*` is implicitly convertible to 
a `void*`...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77843



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


[Lldb-commits] [PATCH] D78825: [lldb/Driver] Exit with a non-zero exit code in batch mode when stopping because of an error.

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

In D78825#2015326 , @JDevlieghere 
wrote:

> Greg, you requested changes to this revision, I guess because of the 
> dependencies. Anything here you'd like to see changed?


I'm guessing the answer is no, but it would certainly help of you rebased the 
patch to see how the patch looks like after the changes in the previous patches.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D78825



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


[Lldb-commits] [PATCH] D78712: [lldb/Host] Improve error messages on unowned read files

2020-05-04 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 261775.
mib added a comment.

Add error "consumption" following @labath  comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78712

Files:
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/test/API/commands/target/basic/TestTargetCommand.py

Index: lldb/test/API/commands/target/basic/TestTargetCommand.py
===
--- lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -326,7 +326,7 @@
 @no_debug_info_test
 def test_target_create_nonexistent_core_file(self):
 self.expect("target create -c doesntexist", error=True,
-substrs=["core file 'doesntexist' doesn't exist"])
+substrs=["Cannot open 'doesntexist': No such file or directory"])
 
 # Write only files don't seem to be supported on Windows.
 @skipIfWindows
@@ -335,12 +335,12 @@
 tf = tempfile.NamedTemporaryFile()
 os.chmod(tf.name, stat.S_IWRITE)
 self.expect("target create -c '" + tf.name + "'", error=True,
-substrs=["core file '", "' is not readable"])
+substrs=["Cannot open '", "': Permission denied"])
 
 @no_debug_info_test
 def test_target_create_nonexistent_sym_file(self):
 self.expect("target create -s doesntexist doesntexisteither", error=True,
-substrs=["invalid symbol file path 'doesntexist'"])
+substrs=["Cannot open '", "': No such file or directory"])
 
 @skipIfWindows
 @no_debug_info_test
@@ -357,7 +357,7 @@
 tf = tempfile.NamedTemporaryFile()
 os.chmod(tf.name, stat.S_IWRITE)
 self.expect("target create -s '" + tf.name + "' no_exe", error=True,
-substrs=["symbol file '", "' is not readable"])
+substrs=["Cannot open '", "': Permission denied"])
 
 @no_debug_info_test
 def test_target_delete_all(self):
Index: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
===
--- lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -71,14 +71,16 @@
   Status error;
   // Nothing special to do here, just use the actual file and architecture
 
-  char exe_path[PATH_MAX];
+  std::string exe_path;
   ModuleSpec resolved_module_spec(module_spec);
+  auto resolved_module = FileSystem::Instance().Open(
+  resolved_module_spec.GetFileSpec(), lldb_private::File::eOpenOptionRead);
 
   if (IsHost()) {
 // If we have "ls" as the exe_file, resolve the executable location based
 // on the current path variables
-if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
-  resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+if (!resolved_module) {
+  exe_path = resolved_module_spec.GetFileSpec().GetPath();
   resolved_module_spec.GetFileSpec().SetFile(exe_path,
  FileSpec::Style::native);
   FileSystem::Instance().Resolve(resolved_module_spec.GetFileSpec());
@@ -91,20 +93,18 @@
 // Resolve any executable within a bundle on MacOSX
 Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
 
-if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
-  error.Clear();
-else {
-  const uint32_t permissions = FileSystem::Instance().GetPermissions(
-  resolved_module_spec.GetFileSpec());
-  if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
-error.SetErrorStringWithFormat(
-"executable '%s' is not readable",
-resolved_module_spec.GetFileSpec().GetPath().c_str());
-  else
-error.SetErrorStringWithFormat(
-"unable to find executable for '%s'",
-resolved_module_spec.GetFileSpec().GetPath().c_str());
+llvm::consumeError(resolved_module.takeError());
+resolved_module =
+FileSystem::Instance().Open(resolved_module_spec.GetFileSpec(),
+lldb_private::File::eOpenOptionRead);
+
+if (!resolved_module) {
+  error.SetErrorStringWithFormatv(
+  "Cannot open '{0}': {1}.", resolved_module_spec.GetFileSpec(),
+  llvm::toString(resolved_module.takeError()));
+  return error;
 }
+
   } else {
 if (m_remote_platform_sp) {
   error =
@@ -117,88 +117,90 @@
   // Resolve any executable within a bundle on MacOSX
   Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
 
-  if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
-error.Clear();
-  else
-error.SetErrorStringWithFormat("the platform is not

[Lldb-commits] [PATCH] D79308: [lldb-server] Reset stop reason of all threads when resuming

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

The test setup here seems unnecessarily complex. Wouldn't an inferior like this 
work better?

  void thread1() {
pseudo_barrier_wait(g_barrier); // See other tests how this works.
g_foo = 0; // break_here
  }
  int main() {
pseudo_barrier_init(g_barrier1, 2);
std::thread t1(thread1);
pseudo_barrier_wait(g_barrier);
for (int i = 0; i<1; ++i) g_bar = i; // empty loop to have something to 
step over
t1.join();
  }

That way you always know only one thread will hit a breakpoint, and and you can 
just pick the "other" thread as the target for stepping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79308



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


[Lldb-commits] [PATCH] D79308: [lldb-server] Reset stop reason of all threads when resuming

2020-05-04 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin added a comment.

In D79308#2017348 , @labath wrote:

> The test setup here seems unnecessarily complex. Wouldn't an inferior like 
> this work better?
>
>   void thread1() {
> pseudo_barrier_wait(g_barrier); // See other tests how this works.
> g_foo = 0; // break_here
>   }
>   int main() {
> pseudo_barrier_init(g_barrier1, 2);
> std::thread t1(thread1);
> pseudo_barrier_wait(g_barrier);
> for (int i = 0; i<1; ++i) g_bar = i; // empty loop to have something 
> to step over
> t1.join();
>   }
>
>
> That way you always know only one thread will hit a breakpoint, and and you 
> can just pick the "other" thread as the target for stepping.


Yeah, I considered something like that, but then I thought it would be better 
if the "other" thread only runs code that we completely control. In my patch, 
the "other" thread is guaranteed to be in thread_func after we hit the 
breakpoint. In your suggested inferior, it could be still in 
pseudo_barrier_wait. If you feel stepping in external code is safe, I am happy 
to rewrite the test to the simpler version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79308



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


[Lldb-commits] [lldb] 283658c - [lldb/DWARF] Remove dead code in DWARFDebugInfoEntry

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

Author: Pavel Labath
Date: 2020-05-04T15:37:22+02:00
New Revision: 283658c978bbac433b41c3d0ca2a3290bd7da0a4

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

LOG: [lldb/DWARF] Remove dead code in DWARFDebugInfoEntry

The dumping code is not used by anyone, and is a source of
inconsistencies with the llvm dwarf parser, as dumping is implemented at
a different level (DWARFDie) there.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 3b5224cae7b2..7b96c15bf3f9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -395,145 +395,6 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
   return !ranges.IsEmpty();
 }
 
-// Dump
-//
-// Dumps a debug information entry and all of it's attributes to the specified
-// stream.
-void DWARFDebugInfoEntry::Dump(const DWARFUnit *cu, Stream &s,
-   uint32_t recurse_depth) const {
-  const DWARFDataExtractor &data = cu->GetData();
-  lldb::offset_t offset = m_offset;
-
-  if (data.ValidOffset(offset)) {
-dw_uleb128_t abbrCode = data.GetULEB128(&offset);
-
-s.Printf("\n0x%8.8x: ", m_offset);
-s.Indent();
-if (abbrCode != m_abbr_idx) {
-  s.Printf("error: DWARF has been modified\n");
-} else if (abbrCode) {
-  const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
-  if (abbrevDecl) {
-s.PutCString(DW_TAG_value_to_name(abbrevDecl->Tag()));
-s.Printf(" [%u] %c\n", abbrCode, abbrevDecl->HasChildren() ? '*' : ' 
');
-
-// Dump all data in the .debug_info/.debug_types for the attributes
-const uint32_t numAttributes = abbrevDecl->NumAttributes();
-for (uint32_t i = 0; i < numAttributes; ++i) {
-  DWARFFormValue form_value(cu);
-  dw_attr_t attr;
-  abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
-
-  DumpAttribute(cu, data, &offset, s, attr, form_value);
-}
-
-const DWARFDebugInfoEntry *child = GetFirstChild();
-if (recurse_depth > 0 && child) {
-  s.IndentMore();
-
-  while (child) {
-child->Dump(cu, s, recurse_depth - 1);
-child = child->GetSibling();
-  }
-  s.IndentLess();
-}
-  } else
-s.Printf("Abbreviation code note found in 'debug_abbrev' class for "
- "code: %u\n",
- abbrCode);
-} else {
-  s.Printf("NULL\n");
-}
-  }
-}
-
-// DumpAttribute
-//
-// Dumps a debug information entry attribute along with it's form. Any special
-// display of attributes is done (disassemble location lists, show enumeration
-// values for attributes, etc).
-void DWARFDebugInfoEntry::DumpAttribute(
-const DWARFUnit *cu, const DWARFDataExtractor &data,
-lldb::offset_t *offset_ptr, Stream &s, dw_attr_t attr,
-DWARFFormValue &form_value) {
-  bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm);
-
-  s.Printf("");
-  s.Indent(DW_AT_value_to_name(attr));
-
-  if (show_form) {
-s.Printf("[%s", DW_FORM_value_to_name(form_value.Form()));
-  }
-
-  if (!form_value.ExtractValue(data, offset_ptr))
-return;
-
-  if (show_form) {
-if (form_value.Form() == DW_FORM_indirect) {
-  s.Printf(" [%s]", DW_FORM_value_to_name(form_value.Form()));
-}
-
-s.PutCString("] ");
-  }
-
-  s.PutCString("( ");
-
-  // Check to see if we have any special attribute formatters
-  switch (attr) {
-  case DW_AT_stmt_list:
-s.Printf("0x%8.8" PRIx64, form_value.Unsigned());
-break;
-
-  case DW_AT_language:
-s.PutCString(DW_LANG_value_to_name(form_value.Unsigned()));
-break;
-
-  case DW_AT_encoding:
-s.PutCString(DW_ATE_value_to_name(form_value.Unsigned()));
-break;
-
-  case DW_AT_frame_base:
-  case DW_AT_location:
-  case DW_AT_data_member_location: {
-const uint8_t *blockData = form_value.BlockData();
-if (blockData) {
-  // Location description is inlined in data in the form value
-  DWARFDataExtractor locationData(data,
-  (*offset_ptr) - form_value.Unsigned(),
-  form_value.Unsigned());
-  DWARFExpression::PrintDWARFExpression(
-  s, locationData, DWARFUnit::GetAddressByteSize(cu), 4, false);
-} else {
-  // We have a location list offset as the value that is the offset into
-  // the .debug_loc section that describes the value over it's lifetime
-  uint64_t debug_loc

[Lldb-commits] [PATCH] D79308: [lldb-server] Reset stop reason of all threads when resuming

2020-05-04 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin updated this revision to Diff 261805.
jarin added a comment.

Simplify the test based on the suggestion from labath@.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79308

Files:
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
  lldb/test/API/functionalities/thread/break_step_other/Makefile
  
lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
  lldb/test/API/functionalities/thread/break_step_other/main.cpp

Index: lldb/test/API/functionalities/thread/break_step_other/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/thread/break_step_other/main.cpp
@@ -0,0 +1,27 @@
+#include 
+#include "pseudo_barrier.h"
+
+// Barrier for starting the thread and reaching the loop in main.
+pseudo_barrier_t g_barrier;
+volatile int g_foo = 0;
+
+void thread_func() {
+  // Wait until all the threads are running
+  pseudo_barrier_wait(g_barrier);
+  g_foo = 0; // thread break here
+}
+
+int main() {
+  g_foo = 0; // main break here
+
+  pseudo_barrier_init(g_barrier, 2);
+  std::thread t(thread_func);
+  pseudo_barrier_wait(g_barrier);
+
+  // A dummy loop to have something to step through.
+  unsigned int i = 0;
+  while (true) {
+g_foo = ++i;
+  }
+  return 0;
+}
Index: lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
===
--- /dev/null
+++ lldb/test/API/functionalities/thread/break_step_other/TestThreadBreakStepOther.py
@@ -0,0 +1,62 @@
+"""
+Test stop reasons after hitting and deleting a breakpoint and
+stepping another thread. Scenario:
+  - run a thread
+  - stop the thread at a breakpoint
+  - delete the breakpoint
+  - single step on the main thread
+The thread stopped at the deleted breakpoint should have stop reason
+'none'.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ThreadBreakStepOtherTestCase(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def test_hit_breakpoint_delete_step_other_thread(self):
+main_source_file = lldb.SBFileSpec("main.cpp")
+self.build()
+(target, process, main_thread, _) = lldbutil.run_to_source_breakpoint(
+self, "// main break here", main_source_file, only_one_thread = False)
+
+# Run until the breakpoint in the thread.
+thread_breakpoint = target.BreakpointCreateBySourceRegex(
+"// thread break here", main_source_file)
+self.assertGreater(
+thread_breakpoint.GetNumLocations(),
+0,
+"thread breakpoint has no locations associated with it.")
+process.Continue()
+stopped_threads = lldbutil.get_threads_stopped_at_breakpoint(
+process, thread_breakpoint)
+self.assertEquals(
+1,
+len(stopped_threads),
+"only one thread expected stopped at the thread breakpoint")
+breakpoint_thread = stopped_threads[0]
+
+# Delete the breakpint in the thread and do a step in the main thread.
+target.BreakpointDelete(thread_breakpoint.GetID())
+main_thread.StepInstruction(False)
+
+# Check the stop reasons.
+reason = main_thread.GetStopReason()
+self.assertEqual(
+lldb.eStopReasonPlanComplete,
+reason,
+"Expected thread stop reason 'plancomplete', but got '%s'" %
+lldbutil.stop_reason_to_str(reason))
+
+reason = breakpoint_thread.GetStopReason()
+self.assertEqual(
+lldb.eStopReasonNone,
+reason,
+"Expected thread stop reason 'none', but got '%s'" %
+lldbutil.stop_reason_to_str(reason))
Index: lldb/test/API/functionalities/thread/break_step_other/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/thread/break_step_other/Makefile
@@ -0,0 +1,4 @@
+CXX_SOURCES := main.cpp
+ENABLE_THREADS := YES
+
+include Makefile.rules
Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
===
--- lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
@@ -94,6 +94,8 @@
 
   void SetStopped();
 
+  void ResetStopReason();
+
   // Member Variables
   lldb::StateType m_state;
   ThreadStopInfo m_stop_info;
Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -396,7 

[Lldb-commits] [PATCH] D78712: [lldb/Host] Improve error messages on unowned read files

2020-05-04 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 261815.
mib added a comment.

As agreed on IRC with @labath, the changes done to 
`PlatformPOSIX::ResolveExecutable` will be removed from this patch and 
submitted separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78712

Files:
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/test/API/commands/target/basic/TestTargetCommand.py

Index: lldb/test/API/commands/target/basic/TestTargetCommand.py
===
--- lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -326,7 +326,7 @@
 @no_debug_info_test
 def test_target_create_nonexistent_core_file(self):
 self.expect("target create -c doesntexist", error=True,
-substrs=["core file 'doesntexist' doesn't exist"])
+substrs=["Cannot open 'doesntexist': No such file or directory"])
 
 # Write only files don't seem to be supported on Windows.
 @skipIfWindows
@@ -335,12 +335,12 @@
 tf = tempfile.NamedTemporaryFile()
 os.chmod(tf.name, stat.S_IWRITE)
 self.expect("target create -c '" + tf.name + "'", error=True,
-substrs=["core file '", "' is not readable"])
+substrs=["Cannot open '", "': Permission denied"])
 
 @no_debug_info_test
 def test_target_create_nonexistent_sym_file(self):
 self.expect("target create -s doesntexist doesntexisteither", error=True,
-substrs=["invalid symbol file path 'doesntexist'"])
+substrs=["Cannot open '", "': No such file or directory"])
 
 @skipIfWindows
 @no_debug_info_test
@@ -357,7 +357,7 @@
 tf = tempfile.NamedTemporaryFile()
 os.chmod(tf.name, stat.S_IWRITE)
 self.expect("target create -s '" + tf.name + "' no_exe", error=True,
-substrs=["symbol file '", "' is not readable"])
+substrs=["Cannot open '", "': Permission denied"])
 
 @no_debug_info_test
 def test_target_delete_all(self):
Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -271,15 +271,13 @@
 FileSpec remote_file(m_remote_file.GetOptionValue().GetCurrentValue());
 
 if (core_file) {
-  if (!FileSystem::Instance().Exists(core_file)) {
-result.AppendErrorWithFormat("core file '%s' doesn't exist",
- core_file.GetPath().c_str());
-result.SetStatus(eReturnStatusFailed);
-return false;
-  }
-  if (!FileSystem::Instance().Readable(core_file)) {
-result.AppendErrorWithFormat("core file '%s' is not readable",
- core_file.GetPath().c_str());
+  auto file = FileSystem::Instance().Open(
+  core_file, lldb_private::File::eOpenOptionRead);
+
+  if (!file) {
+result.AppendErrorWithFormatv("Cannot open '{0}': {1}.",
+  core_file.GetPath(),
+  llvm::toString(file.takeError()));
 result.SetStatus(eReturnStatusFailed);
 return false;
   }
@@ -288,18 +286,13 @@
 if (argc == 1 || core_file || remote_file) {
   FileSpec symfile(m_symbol_file.GetOptionValue().GetCurrentValue());
   if (symfile) {
-if (FileSystem::Instance().Exists(symfile)) {
-  if (!FileSystem::Instance().Readable(symfile)) {
-result.AppendErrorWithFormat("symbol file '%s' is not readable",
- symfile.GetPath().c_str());
-result.SetStatus(eReturnStatusFailed);
-return false;
-  }
-} else {
-  char symfile_path[PATH_MAX];
-  symfile.GetPath(symfile_path, sizeof(symfile_path));
-  result.AppendErrorWithFormat("invalid symbol file path '%s'",
-   symfile_path);
+auto file = FileSystem::Instance().Open(
+symfile, lldb_private::File::eOpenOptionRead);
+
+if (!file) {
+  result.AppendErrorWithFormatv("Cannot open '{0}': {1}.",
+symfile.GetPath(),
+llvm::toString(file.takeError()));
   result.SetStatus(eReturnStatusFailed);
   return false;
 }
@@ -401,48 +394,35 @@
   if (module_sp)
 module_sp->SetPlatformFileSpec(remote_file);
 }
+
 if (core_file) {
-  char core_path[PATH_MAX];
-  core_file.GetPath(core_path, sizeof(core_path));
-  if (FileSystem::Instance().Exists(core_file)) {
-if (!FileSystem::Instance().Readable(core_file)) {
-

[Lldb-commits] [PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-05-04 Thread Petr Hosek via Phabricator via lldb-commits
phosek created this revision.
phosek added reviewers: smeenai, compnerd.
Herald added subscribers: llvm-commits, lldb-commits, Sanitizers, cfe-commits, 
hiraditya, mgorny.
Herald added projects: clang, Sanitizers, LLDB, LLVM.

Rather than handling zlib handling manually, use `find_package` from CMake
to find zlib properly. Use this to normalize the `LLVM_ENABLE_ZLIB`,
`HAVE_ZLIB`, `HAVE_ZLIB_H`. Furthermore, require zlib if `LLVM_ENABLE_ZLIB` is
set to `YES`, which requires the distributor to explicitly select whether
zlib is enabled or not. This simplifies the CMake handling and usage in
the rest of the tooling.

This is a reland of rGabb0075 
 with all 
followup changes and fixes that should address
issues that were reported in PR44780.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79219

Files:
  clang/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/test/lit.common.configured.in
  lld/CMakeLists.txt
  lld/test/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  llvm/cmake/config-ix.cmake
  llvm/include/llvm/Config/config.h.cmake
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CRC.cpp
  llvm/lib/Support/Compression.cpp
  llvm/test/CMakeLists.txt
  llvm/test/lit.site.cfg.py.in
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
+#if LLVM_ENABLE_ZLIB
 
 void TestZlibCompression(StringRef Input, int Level) {
   SmallString<32> Compressed;
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -33,7 +33,7 @@
 config.host_ldflags = '@HOST_LDFLAGS@'
 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @HAVE_LIBZ@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.have_libxar = @HAVE_LIBXAR@
 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
 config.enable_ffi = @LLVM_ENABLE_FFI@
Index: llvm/test/CMakeLists.txt
===
--- llvm/test/CMakeLists.txt
+++ llvm/test/CMakeLists.txt
@@ -1,12 +1,12 @@
 llvm_canonicalize_cmake_booleans(
   BUILD_SHARED_LIBS
   HAVE_LIBXAR
-  HAVE_LIBZ
   HAVE_OCAMLOPT
   HAVE_OCAML_OUNIT
   LLVM_ENABLE_DIA_SDK
   LLVM_ENABLE_FFI
   LLVM_ENABLE_THREADS
+  LLVM_ENABLE_ZLIB
   LLVM_INCLUDE_GO_TESTS
   LLVM_LIBXML2_ENABLED
   LLVM_LINK_LLVM_DYLIB
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -17,13 +17,13 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_ZLIB_H
+#if LLVM_ENABLE_ZLIB
 #include 
 #endif
 
 using namespace llvm;
 
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
+#if LLVM_ENABLE_ZLIB
 static Error createError(StringRef Err) {
   return make_error(Err, inconvertibleErrorCode());
 }
Index: llvm/lib/Support/CRC.cpp
===
--- llvm/lib/Support/CRC.cpp
+++ llvm/lib/Support/CRC.cpp
@@ -25,7 +25,7 @@
 
 using namespace llvm;
 
-#if LLVM_ENABLE_ZLIB == 0 || !HAVE_ZLIB_H
+#if !LLVM_ENABLE_ZLIB
 
 static const uint32_t CRCTable[256] = {
 0x, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -1,7 +1,7 @@
-set(system_libs)
-if ( LLVM_ENABLE_ZLIB AND HAVE_LIBZ )
-  set(system_libs ${system_libs} ${ZLIB_LIBRARIES})
+if(LLVM_ENABLE_ZLIB)
+  set(imported_libs ZLIB::ZLIB)
 endif()
+
 if( MSVC OR MINGW )
   # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
   # advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
@@ -192,10 +192,31 @@
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/ADT
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support
   ${Backtrace_INCLUDE_DIRS}
-  LINK_LIBS ${system_libs} ${delayload_flags} ${Z3_LINK_FILES}
+  LINK_LIBS ${system_libs} ${imported_libs} ${delayload_flags} ${Z3_LINK_FILES}
   )
 
-set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${system_libs}")
+set(llvm_system_libs ${system_libs})
+
+if(LLVM_ENABLE_ZLIB)
+  string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
+  get_property(zlib_library TARGET ZLIB::ZLIB PROPERTY LOCATION_${build_type})
+  if(NOT zlib_libra

[Lldb-commits] [PATCH] D78712: [lldb/Host] Improve error messages on unowned read files

2020-05-04 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.

Yeah, as I said, I think this is already an improvement, which I am not sure 
that could be said of the other version, because of the expected-handling 
complexities. LGTM, modulo the overzealous conversion to AppendError.




Comment at: lldb/source/Commands/CommandObjectTarget.cpp:417
+} else {
+  result.AppendErrorWithFormatv(
+  "Core file '{0}' ({1}) was loaded.\n", core_file.GetPath(),

I guess this should stay as Append**Message**


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78712



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


[Lldb-commits] [lldb] 0151174 - [lldb/Host] Improve error messages on unowned read files

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

Author: Med Ismail Bennani
Date: 2020-05-04T17:33:55+02:00
New Revision: 015117411e11458f9816ba4359246132164a4297

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

LOG: [lldb/Host] Improve error messages on unowned read files

When trying to read a core file that is not owned by the user running lldb
and that doesn't have read permission on the file, lldb shows a misleading
error message:

```
Unable to find process plug-in for core file
```

This is due to the fact that currently, lldb doesn't check the file
ownership. And when trying to to open and read a core file, the syscall
fails, which prevents a process to be created.

Since lldb already have a portable `open` syscall interface, lets take
advantage of that and delegate the error handling to the syscall
itself. This way, no matter if the file exists or if the user has proper
ownership, lldb will always try to open the file, and behave accordingly
to the error code returned.

rdar://42630030

https://reviews.llvm.org/D78712

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Commands/CommandObjectTarget.cpp
lldb/test/API/commands/target/basic/TestTargetCommand.py

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index decdd9c53de2..8db0eef31163 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -271,15 +271,13 @@ class CommandObjectTargetCreate : public 
CommandObjectParsed {
 FileSpec remote_file(m_remote_file.GetOptionValue().GetCurrentValue());
 
 if (core_file) {
-  if (!FileSystem::Instance().Exists(core_file)) {
-result.AppendErrorWithFormat("core file '%s' doesn't exist",
- core_file.GetPath().c_str());
-result.SetStatus(eReturnStatusFailed);
-return false;
-  }
-  if (!FileSystem::Instance().Readable(core_file)) {
-result.AppendErrorWithFormat("core file '%s' is not readable",
- core_file.GetPath().c_str());
+  auto file = FileSystem::Instance().Open(
+  core_file, lldb_private::File::eOpenOptionRead);
+
+  if (!file) {
+result.AppendErrorWithFormatv("Cannot open '{0}': {1}.",
+  core_file.GetPath(),
+  llvm::toString(file.takeError()));
 result.SetStatus(eReturnStatusFailed);
 return false;
   }
@@ -288,18 +286,13 @@ class CommandObjectTargetCreate : public 
CommandObjectParsed {
 if (argc == 1 || core_file || remote_file) {
   FileSpec symfile(m_symbol_file.GetOptionValue().GetCurrentValue());
   if (symfile) {
-if (FileSystem::Instance().Exists(symfile)) {
-  if (!FileSystem::Instance().Readable(symfile)) {
-result.AppendErrorWithFormat("symbol file '%s' is not readable",
- symfile.GetPath().c_str());
-result.SetStatus(eReturnStatusFailed);
-return false;
-  }
-} else {
-  char symfile_path[PATH_MAX];
-  symfile.GetPath(symfile_path, sizeof(symfile_path));
-  result.AppendErrorWithFormat("invalid symbol file path '%s'",
-   symfile_path);
+auto file = FileSystem::Instance().Open(
+symfile, lldb_private::File::eOpenOptionRead);
+
+if (!file) {
+  result.AppendErrorWithFormatv("Cannot open '{0}': {1}.",
+symfile.GetPath(),
+llvm::toString(file.takeError()));
   result.SetStatus(eReturnStatusFailed);
   return false;
 }
@@ -401,48 +394,34 @@ class CommandObjectTargetCreate : public 
CommandObjectParsed {
   if (module_sp)
 module_sp->SetPlatformFileSpec(remote_file);
 }
+
 if (core_file) {
-  char core_path[PATH_MAX];
-  core_file.GetPath(core_path, sizeof(core_path));
-  if (FileSystem::Instance().Exists(core_file)) {
-if (!FileSystem::Instance().Readable(core_file)) {
-  result.AppendMessageWithFormat(
-  "Core file '%s' is not readable.\n", core_path);
-  result.SetStatus(eReturnStatusFailed);
-  return false;
-}
-FileSpec core_file_dir;
-core_file_dir.GetDirectory() = core_file.GetDirectory();
-target_sp->AppendExecutableSearchPaths(core_file_dir);
+  FileSpec core_file_dir;
+  core_file_dir.GetDirectory() = core_file.GetDirectory();
+  target_sp->AppendExecutableSearchPaths(core_file_dir);
 
-ProcessSP p

[Lldb-commits] [PATCH] D78825: [lldb/Driver] Exit with a non-zero exit code in batch mode when stopping because of an error.

2020-05-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D78825#2017204 , @labath wrote:

> In D78825#2015326 , @JDevlieghere 
> wrote:
>
> > Greg, you requested changes to this revision, I guess because of the 
> > dependencies. Anything here you'd like to see changed?
>
>
> I'm guessing the answer is no, but it would certainly help of you rebased the 
> patch to see how the patch looks like after the changes in the previous 
> patches.


Thanks, I thought I had.


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

https://reviews.llvm.org/D78825



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


[Lldb-commits] [PATCH] D78825: [lldb/Driver] Exit with a non-zero exit code in batch mode when stopping because of an error.

2020-05-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 261844.

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

https://reviews.llvm.org/D78825

Files:
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/test/Shell/Commands/command-source.test
  lldb/test/Shell/Driver/TestProcessAttach.test
  lldb/test/Shell/Host/TestCustomShell.test
  lldb/test/Shell/Quit/TestQuitExitCodeNonInt.test
  lldb/test/Shell/Quit/TestQuitExitCodeTooManyArgs.test
  lldb/test/Shell/Reproducer/TestDiscard.test
  lldb/test/Shell/Reproducer/TestDump.test
  lldb/test/Shell/Settings/TestSettingsSet.test
  lldb/test/Shell/Settings/TestStopCommandSourceOnError.test
  lldb/test/Shell/SymbolFile/DWARF/debug-types-missing-signature.test
  lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -619,6 +619,12 @@
 results.GetResult() != lldb::eCommandInterpreterResultInferiorCrash)
   go_interactive = false;
 
+// When running in batch mode and stopped because of an error, exit with a
+// non-zero exit status.
+if (m_option_data.m_batch &&
+results.GetResult() == lldb::eCommandInterpreterResultCommandError)
+  exit(1);
+
 if (m_option_data.m_batch &&
 results.GetResult() == lldb::eCommandInterpreterResultInferiorCrash &&
 !m_option_data.m_after_crash_commands.empty()) {
@@ -636,6 +642,13 @@
 if (local_results.GetResult() ==
 lldb::eCommandInterpreterResultQuitRequested)
   go_interactive = false;
+
+// When running in batch mode and an error occurred while sourcing
+// the crash commands, exit with a non-zero exit status.
+if (m_option_data.m_batch &&
+local_results.GetResult() ==
+lldb::eCommandInterpreterResultCommandError)
+  exit(1);
   }
 }
 m_debugger.SetAsync(old_async);
Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -5,7 +5,7 @@
 # UNSUPPORTED: system-windows
 
 # RUN: %clang_host %p/Inputs/call-asm.c -x assembler-with-cpp %p/Inputs/thread-step-out-ret-addr-check.s -o %t
-# RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
+# RUN: not %lldb %t -s %s -b 2>&1 | FileCheck %s
 
 breakpoint set -n nonstandard_stub
 # CHECK: Breakpoint 1: where = {{.*}}`nonstandard_stub
Index: lldb/test/Shell/SymbolFile/DWARF/debug-types-missing-signature.test
===
--- lldb/test/Shell/SymbolFile/DWARF/debug-types-missing-signature.test
+++ lldb/test/Shell/SymbolFile/DWARF/debug-types-missing-signature.test
@@ -14,10 +14,10 @@
 RUN: %lldb %t -b -o "type lookup EC" | FileCheck --check-prefix=LOOKUPEC %s
 LOOKUPEC: no type was found matching 'EC'
 
-RUN: %lldb %t -b -o "print (E) 1" 2>&1 | FileCheck --check-prefix=PRINTE %s
+RUN: not %lldb %t -b -o "print (E) 1" 2>&1 | FileCheck --check-prefix=PRINTE %s
 PRINTE: use of undeclared identifier 'E'
 
-RUN: %lldb %t -b -o "print (EC) 1" 2>&1 | FileCheck --check-prefix=PRINTEC %s
+RUN: not %lldb %t -b -o "print (EC) 1" 2>&1 | FileCheck --check-prefix=PRINTEC %s
 PRINTEC: use of undeclared identifier 'EC'
 
 RUN: %lldb %t -b -o "target variable a e ec" | FileCheck --check-prefix=VARS %s
Index: lldb/test/Shell/Settings/TestStopCommandSourceOnError.test
===
--- lldb/test/Shell/Settings/TestStopCommandSourceOnError.test
+++ lldb/test/Shell/Settings/TestStopCommandSourceOnError.test
@@ -12,13 +12,13 @@
 # RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -s %S/Inputs/StopCommandSource.in | FileCheck %s --check-prefix CONTINUE
 
 # FIXME: Should continue
-# RUN: %lldb -b -s %S/Inputs/DontStopCommandSource.in -o 'bogus' -o 'print 0 + 1' | FileCheck %s --check-prefix STOP
+# RUN: not %lldb -b -s %S/Inputs/DontStopCommandSource.in -o 'bogus' -o 'print 0 + 1' | FileCheck %s --check-prefix STOP
 
 # FIXME: Should continue
-# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -o 'bogus' -o 'print 12340 + 56789'  | FileCheck %s --check-prefix STOP
+# RUN: not %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -o 'bogus' -o 'print 12340 + 56789'  | FileCheck %s --check-prefix STOP
 
 # FIXME: Should continue
-# RUN: %lldb -b -s %S/Inputs/DontStopCommandSource.in | FileCheck %s --check-prefix STOP
+# RUN: not %lldb -b -s %S/Inputs/DontStopCommandSource.in | FileCheck %s --check-prefix STOP
 
 # FIXME: Should continue
-# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error true' -s %S/Inputs/DontStopCommandS

[Lldb-commits] [PATCH] D78712: [lldb/Host] Improve error messages on unowned read files

2020-05-04 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib closed this revision.
mib added a comment.

Landed in 015117411e11 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78712



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


[Lldb-commits] [lldb] 6b8d6f4 - [lldb/test] Fix wrong target command failure message on Windows

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

Author: Med Ismail Bennani
Date: 2020-05-04T19:22:34+02:00
New Revision: 6b8d6f44592cd975919d535483c2aca7cd7857b8

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

LOG: [lldb/test] Fix wrong target command failure message on Windows

This patch fixes the test failure happening on Windows introduced by
`015117411e11458f9816ba4359246132164a4297`.

Since the failure message comes from the OS, the test needs to support both
UNIX and Windows messages.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/test/API/commands/target/basic/TestTargetCommand.py

Removed: 




diff  --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py 
b/lldb/test/API/commands/target/basic/TestTargetCommand.py
index 8335753c78af..2704e0ed25ad 100644
--- a/lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -326,7 +326,7 @@ def test_target_create_multiple_args(self):
 @no_debug_info_test
 def test_target_create_nonexistent_core_file(self):
 self.expect("target create -c doesntexist", error=True,
-substrs=["Cannot open 'doesntexist': No such file or 
directory"])
+patterns=["Cannot open 'doesntexist'", ": (No such file or 
directory|The system cannot find the file specified)"])
 
 # Write only files don't seem to be supported on Windows.
 @skipIfWindows
@@ -340,7 +340,7 @@ def test_target_create_unreadable_core_file(self):
 @no_debug_info_test
 def test_target_create_nonexistent_sym_file(self):
 self.expect("target create -s doesntexist doesntexisteither", 
error=True,
-substrs=["Cannot open '", "': No such file or directory"])
+patterns=["Cannot open '", ": (No such file or 
directory|The system cannot find the file specified)"])
 
 @skipIfWindows
 @no_debug_info_test



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


[Lldb-commits] [PATCH] D78421: Fix out of sync source code/executable when debugging

2020-05-04 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added inline comments.



Comment at: lldb/source/Core/SourceManager.cpp:579
+
+  const Address pc_addr(stackframe_sp->GetFrameCodeAddress());
+

Please do not consider this as some requirement for LLDB project.
But I do not like much this guessing what module it really belongs to.
Couldn't we save the Module where `m_file_spec` came from? For example 
`DisplaySourceLinesWithLineNumbers` would then have another `Module &` 
parameter that it would save with `m_last_file_spec`. Then 
`ModuleList::FindSourceFile` could be replaced+simplified.
Another possibility would be to return `Module &` from 
`ModuleList::FindSourceFile` which is already being used in `SourceManager.cpp`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78421



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


[Lldb-commits] [lldb] 4ad5317 - [LLDB] Fix overloaded operator new cases in TestCppOperators.py which currently work by accident

2020-05-04 Thread via lldb-commits

Author: shafik
Date: 2020-05-04T13:57:42-07:00
New Revision: 4ad53177db756849d0be70643aee77fed13a00e1

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

LOG: [LLDB] Fix overloaded operator new cases in TestCppOperators.py which 
currently work by accident

The overloaded new operator in TestCppOperators.py are working by accident 
because of how
we currently deal with artificial methods.

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

Added: 


Modified: 
lldb/test/API/lang/cpp/operators/main.cpp

Removed: 




diff  --git a/lldb/test/API/lang/cpp/operators/main.cpp 
b/lldb/test/API/lang/cpp/operators/main.cpp
index 7afea1e957ce..c52ef1c8cac4 100644
--- a/lldb/test/API/lang/cpp/operators/main.cpp
+++ b/lldb/test/API/lang/cpp/operators/main.cpp
@@ -4,12 +4,11 @@ int side_effect = 0;
 
 struct B { int dummy = 2324; };
 struct C {
-  void *operator new(std::size_t size) { C* r = ::new C; r->custom_new = true; 
return r; }
-  void *operator new[](std::size_t size) { C* r = 
static_cast(std::malloc(size)); r->custom_new = true; return r; }
+  void *operator new(std::size_t size) { void *p = ::operator new(size); 
side_effect = 3; return p; }
+  void *operator new[](std::size_t size) { void *p = ::operator new(size); 
side_effect = 4; return p; }
   void operator delete(void *p) { std::free(p); side_effect = 1; }
   void operator delete[](void *p) { std::free(p); side_effect = 2; }
 
-  bool custom_new = false;
   B b;
   B* operator->() { return &b; }
   int operator->*(int) { return 2; }
@@ -171,8 +170,8 @@ int main(int argc, char **argv) {
   //% self.expect("expr static_cast(c)", endstr=" 12\n")
   //% self.expect("expr c.operatorint()", endstr=" 13\n")
   //% self.expect("expr c.operatornew()", endstr=" 14\n")
-  //% self.expect("expr (new struct C)->custom_new", endstr=" true\n")
-  //% self.expect("expr (new struct C[1])->custom_new", endstr=" true\n")
+  //% self.expect("expr (new struct C); side_effect", endstr=" = 3\n")
+  //% self.expect("expr (new struct C[1]); side_effect", endstr=" = 4\n")
   //% self.expect("expr delete c2; side_effect", endstr=" = 1\n")
   //% self.expect("expr delete[] c3; side_effect", endstr=" = 2\n")
   delete c2;



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


[Lldb-commits] [PATCH] D79251: Fix overloaded operator new cases in TestCppOperators.py which currently work by accident

2020-05-04 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 261920.
shafik marked an inline comment as done.
shafik added a comment.

Removing `custom_new` since it is now unused.


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

https://reviews.llvm.org/D79251

Files:
  lldb/test/API/lang/cpp/operators/main.cpp


Index: lldb/test/API/lang/cpp/operators/main.cpp
===
--- lldb/test/API/lang/cpp/operators/main.cpp
+++ lldb/test/API/lang/cpp/operators/main.cpp
@@ -4,12 +4,11 @@
 
 struct B { int dummy = 2324; };
 struct C {
-  void *operator new(std::size_t size) { C* r = ::new C; r->custom_new = true; 
return r; }
-  void *operator new[](std::size_t size) { C* r = 
static_cast(std::malloc(size)); r->custom_new = true; return r; }
+  void *operator new(std::size_t size) { void *p = ::operator new(size); 
side_effect = 3; return p; }
+  void *operator new[](std::size_t size) { void *p = ::operator new(size); 
side_effect = 4; return p; }
   void operator delete(void *p) { std::free(p); side_effect = 1; }
   void operator delete[](void *p) { std::free(p); side_effect = 2; }
 
-  bool custom_new = false;
   B b;
   B* operator->() { return &b; }
   int operator->*(int) { return 2; }
@@ -171,8 +170,8 @@
   //% self.expect("expr static_cast(c)", endstr=" 12\n")
   //% self.expect("expr c.operatorint()", endstr=" 13\n")
   //% self.expect("expr c.operatornew()", endstr=" 14\n")
-  //% self.expect("expr (new struct C)->custom_new", endstr=" true\n")
-  //% self.expect("expr (new struct C[1])->custom_new", endstr=" true\n")
+  //% self.expect("expr (new struct C); side_effect", endstr=" = 3\n")
+  //% self.expect("expr (new struct C[1]); side_effect", endstr=" = 4\n")
   //% self.expect("expr delete c2; side_effect", endstr=" = 1\n")
   //% self.expect("expr delete[] c3; side_effect", endstr=" = 2\n")
   delete c2;


Index: lldb/test/API/lang/cpp/operators/main.cpp
===
--- lldb/test/API/lang/cpp/operators/main.cpp
+++ lldb/test/API/lang/cpp/operators/main.cpp
@@ -4,12 +4,11 @@
 
 struct B { int dummy = 2324; };
 struct C {
-  void *operator new(std::size_t size) { C* r = ::new C; r->custom_new = true; return r; }
-  void *operator new[](std::size_t size) { C* r = static_cast(std::malloc(size)); r->custom_new = true; return r; }
+  void *operator new(std::size_t size) { void *p = ::operator new(size); side_effect = 3; return p; }
+  void *operator new[](std::size_t size) { void *p = ::operator new(size); side_effect = 4; return p; }
   void operator delete(void *p) { std::free(p); side_effect = 1; }
   void operator delete[](void *p) { std::free(p); side_effect = 2; }
 
-  bool custom_new = false;
   B b;
   B* operator->() { return &b; }
   int operator->*(int) { return 2; }
@@ -171,8 +170,8 @@
   //% self.expect("expr static_cast(c)", endstr=" 12\n")
   //% self.expect("expr c.operatorint()", endstr=" 13\n")
   //% self.expect("expr c.operatornew()", endstr=" 14\n")
-  //% self.expect("expr (new struct C)->custom_new", endstr=" true\n")
-  //% self.expect("expr (new struct C[1])->custom_new", endstr=" true\n")
+  //% self.expect("expr (new struct C); side_effect", endstr=" = 3\n")
+  //% self.expect("expr (new struct C[1]); side_effect", endstr=" = 4\n")
   //% self.expect("expr delete c2; side_effect", endstr=" = 1\n")
   //% self.expect("expr delete[] c3; side_effect", endstr=" = 2\n")
   delete c2;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D79364: Move the Xcode SDK path caching to HostInfo

2020-05-04 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: friss, JDevlieghere.
Herald added a subscriber: fedor.sergeev.
aprantl added a parent revision: D79273: Add an explicit API to read the Xcode 
SDK DWARF attribute from compile units.

When debugging a remote platform, the platform you get from
GetPlatformForArchitecture doesn't inherit from PlatformDarwin.
HostInfoMacOSX seems like the right place to have a global store of
local paths.


https://reviews.llvm.org/D79364

Files:
  lldb/include/lldb/Host/HostInfoBase.h
  lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
  lldb/source/Core/Module.cpp
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
  lldb/unittests/Host/HostInfoTest.cpp

Index: lldb/unittests/Host/HostInfoTest.cpp
===
--- lldb/unittests/Host/HostInfoTest.cpp
+++ lldb/unittests/Host/HostInfoTest.cpp
@@ -53,10 +53,10 @@
 
 #if defined(__APPLE__)
 TEST_F(HostInfoTest, GetXcodeSDK) {
-  EXPECT_FALSE(HostInfo::GetXcodeSDK(XcodeSDK("MacOSX.sdk")).empty());
+  EXPECT_FALSE(HostInfo::GetXcodeSDKPath(XcodeSDK("MacOSX.sdk")).empty());
   // These are expected to fall back to an available version.
-  EXPECT_FALSE(HostInfo::GetXcodeSDK(XcodeSDK("MacOSX.sdk")).empty());
+  EXPECT_FALSE(HostInfo::GetXcodeSDKPath(XcodeSDK("MacOSX.sdk")).empty());
   // This is expected to fail.
-  EXPECT_TRUE(HostInfo::GetXcodeSDK(XcodeSDK("CeciNestPasUnOS.sdk")).empty());
+  EXPECT_TRUE(HostInfo::GetXcodeSDKPath(XcodeSDK("CeciNestPasUnOS.sdk")).empty());
 }
 #endif
Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -208,7 +208,8 @@
   }
 
   // Use the default SDK as a fallback.
-  FileSpec fspec(HostInfo::GetXcodeSDK(lldb_private::XcodeSDK::GetAnyMacOS()));
+  FileSpec fspec(
+  HostInfo::GetXcodeSDKPath(lldb_private::XcodeSDK::GetAnyMacOS()));
   if (fspec) {
 if (FileSystem::Instance().Exists(fspec))
   return ConstString(fspec.GetPath());
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1762,11 +1762,7 @@
 }
 
 llvm::StringRef PlatformDarwin::GetSDKPath(XcodeSDK sdk) {
-  std::lock_guard guard(m_sdk_path_mutex);
-  std::string &path = m_sdk_path[sdk.GetString()];
-  if (path.empty())
-path = HostInfo::GetXcodeSDK(sdk);
-  return path;
+ return HostInfo::GetXcodeSDKPath(sdk);
 }
 
 FileSpec PlatformDarwin::GetXcodeContentsDirectory() {
@@ -1797,7 +1793,7 @@
   }
 }
 
-FileSpec fspec(HostInfo::GetXcodeSDK(XcodeSDK::GetAnyMacOS()));
+FileSpec fspec(HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMacOS()));
 if (fspec) {
   if (FileSystem::Instance().Exists(fspec)) {
 std::string xcode_contents_dir =
Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -297,7 +297,7 @@
   }
 }
 
-std::string HostInfoMacOSX::GetXcodeSDK(XcodeSDK sdk) {
+static std::string GetXcodeSDK(XcodeSDK sdk) {
   XcodeSDK::Info info = sdk.Parse();
   std::string sdk_name = XcodeSDK::GetCanonicalName(info);
   auto find_sdk = [](std::string sdk_name) -> std::string {
@@ -361,3 +361,14 @@
 return {};
   return path;
 }
+
+llvm::StringRef HostInfoMacOSX::GetXcodeSDKPath(XcodeSDK sdk) {
+  static llvm::StringMap g_sdk_path;
+  static std::mutex g_sdk_path_mutex;
+
+  std::lock_guard guard(g_sdk_path_mutex);
+  std::string &path = g_sdk_path[sdk.GetString()];
+  if (path.empty())
+path = GetXcodeSDK(sdk);
+  return path;
+}
Index: lldb/source/Core/Module.cpp
===
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -1598,9 +1598,7 @@
 
 void Module::RegisterXcodeSDK(llvm::StringRef sdk_name, llvm::StringRef sysroot) {
   XcodeSDK sdk(sdk_name.str());
-  PlatformSP module_platform =
-  Platform::GetPlatformForArchitecture(GetArchitecture(), nullptr);
-  ConstString sdk_path(module_platform->GetSDKPath(sdk));
+  ConstString sdk_path(Platform::GetHostPlatform()->GetSDKPath(sdk));
   if (!sdk_path)
 return;
   // If merged SDK changed for a previously registered source path, update it.
Index: lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
===
--- lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -35,7 +35,7 @@
   static std::string FindXcodeContentsDirectory

[Lldb-commits] [PATCH] D79364: Move the Xcode SDK path caching to HostInfo

2020-05-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM modulo the inline comment.




Comment at: lldb/include/lldb/Host/HostInfoBase.h:96
   /// Return the directory containing a specific Xcode SDK.
-  static std::string GetXcodeSDK(XcodeSDK sdk) { return {}; }
+  static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk) { return {}; }
 

This should probably be named `GetXcodeSDKDirectory` for consistency with the 
other methods. 


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

https://reviews.llvm.org/D79364



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


[Lldb-commits] [PATCH] D79251: Fix overloaded operator new cases in TestCppOperators.py which currently work by accident

2020-05-04 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4ad53177db75: [LLDB] Fix overloaded operator new cases in 
TestCppOperators.py which currently… (authored by shafik).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79251

Files:
  lldb/test/API/lang/cpp/operators/main.cpp


Index: lldb/test/API/lang/cpp/operators/main.cpp
===
--- lldb/test/API/lang/cpp/operators/main.cpp
+++ lldb/test/API/lang/cpp/operators/main.cpp
@@ -4,12 +4,11 @@
 
 struct B { int dummy = 2324; };
 struct C {
-  void *operator new(std::size_t size) { C* r = ::new C; r->custom_new = true; 
return r; }
-  void *operator new[](std::size_t size) { C* r = 
static_cast(std::malloc(size)); r->custom_new = true; return r; }
+  void *operator new(std::size_t size) { void *p = ::operator new(size); 
side_effect = 3; return p; }
+  void *operator new[](std::size_t size) { void *p = ::operator new(size); 
side_effect = 4; return p; }
   void operator delete(void *p) { std::free(p); side_effect = 1; }
   void operator delete[](void *p) { std::free(p); side_effect = 2; }
 
-  bool custom_new = false;
   B b;
   B* operator->() { return &b; }
   int operator->*(int) { return 2; }
@@ -171,8 +170,8 @@
   //% self.expect("expr static_cast(c)", endstr=" 12\n")
   //% self.expect("expr c.operatorint()", endstr=" 13\n")
   //% self.expect("expr c.operatornew()", endstr=" 14\n")
-  //% self.expect("expr (new struct C)->custom_new", endstr=" true\n")
-  //% self.expect("expr (new struct C[1])->custom_new", endstr=" true\n")
+  //% self.expect("expr (new struct C); side_effect", endstr=" = 3\n")
+  //% self.expect("expr (new struct C[1]); side_effect", endstr=" = 4\n")
   //% self.expect("expr delete c2; side_effect", endstr=" = 1\n")
   //% self.expect("expr delete[] c3; side_effect", endstr=" = 2\n")
   delete c2;


Index: lldb/test/API/lang/cpp/operators/main.cpp
===
--- lldb/test/API/lang/cpp/operators/main.cpp
+++ lldb/test/API/lang/cpp/operators/main.cpp
@@ -4,12 +4,11 @@
 
 struct B { int dummy = 2324; };
 struct C {
-  void *operator new(std::size_t size) { C* r = ::new C; r->custom_new = true; return r; }
-  void *operator new[](std::size_t size) { C* r = static_cast(std::malloc(size)); r->custom_new = true; return r; }
+  void *operator new(std::size_t size) { void *p = ::operator new(size); side_effect = 3; return p; }
+  void *operator new[](std::size_t size) { void *p = ::operator new(size); side_effect = 4; return p; }
   void operator delete(void *p) { std::free(p); side_effect = 1; }
   void operator delete[](void *p) { std::free(p); side_effect = 2; }
 
-  bool custom_new = false;
   B b;
   B* operator->() { return &b; }
   int operator->*(int) { return 2; }
@@ -171,8 +170,8 @@
   //% self.expect("expr static_cast(c)", endstr=" 12\n")
   //% self.expect("expr c.operatorint()", endstr=" 13\n")
   //% self.expect("expr c.operatornew()", endstr=" 14\n")
-  //% self.expect("expr (new struct C)->custom_new", endstr=" true\n")
-  //% self.expect("expr (new struct C[1])->custom_new", endstr=" true\n")
+  //% self.expect("expr (new struct C); side_effect", endstr=" = 3\n")
+  //% self.expect("expr (new struct C[1]); side_effect", endstr=" = 4\n")
   //% self.expect("expr delete c2; side_effect", endstr=" = 1\n")
   //% self.expect("expr delete[] c3; side_effect", endstr=" = 2\n")
   delete c2;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D79273: Add an explicit API to read the Xcode SDK DWARF attribute from compile units

2020-05-04 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

ping.


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

https://reviews.llvm.org/D79273



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


[Lldb-commits] [lldb] 88d9e43 - [lldb/Expression] Make Language() const, NFC

2020-05-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-04T14:02:43-07:00
New Revision: 88d9e4326f48041056c4db3506d30574c6e1d83c

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

LOG: [lldb/Expression] Make Language() const, NFC

Allow Language() to be called from const methods within UserExpression.

Added: 


Modified: 
lldb/include/lldb/Expression/Expression.h
lldb/include/lldb/Expression/UserExpression.h

Removed: 




diff  --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 1e4453de04ff..aaac889e6ed2 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -51,7 +51,9 @@ class Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
+  virtual lldb::LanguageType Language() const {
+return lldb::eLanguageTypeUnknown;
+  }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.

diff  --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index 8f3a505addea..8236c417f73a 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -194,7 +194,7 @@ class UserExpression : public Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  lldb::LanguageType Language() override { return m_language; }
+  lldb::LanguageType Language() const override { return m_language; }
 
   /// Return the desired result type of the function, or eResultTypeAny if
   /// in
diff erent.



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


[Lldb-commits] [lldb] 47e9fd4 - Revert "[lldb/Expression] Make Language() const, NFC"

2020-05-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-04T14:03:22-07:00
New Revision: 47e9fd47c71830e7a8987ef633f827cf4aff38fc

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

LOG: Revert "[lldb/Expression] Make Language() const, NFC"

This reverts commit 88d9e4326f48041056c4db3506d30574c6e1d83c. Revert an
accidental commit.

Added: 


Modified: 
lldb/include/lldb/Expression/Expression.h
lldb/include/lldb/Expression/UserExpression.h

Removed: 




diff  --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index aaac889e6ed2..1e4453de04ff 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -51,9 +51,7 @@ class Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.

diff  --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index 8236c417f73a..8f3a505addea 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -194,7 +194,7 @@ class UserExpression : public Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  lldb::LanguageType Language() const override { return m_language; }
+  lldb::LanguageType Language() override { return m_language; }
 
   /// Return the desired result type of the function, or eResultTypeAny if
   /// in
diff erent.



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


[Lldb-commits] [lldb] a37caeb - [lldb/DataFormatters] Delete GetStringPrinterEscapingHelper

2020-05-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-04T14:06:55-07:00
New Revision: a37caebc2d2d93573075633493e104e8664cf9e9

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

LOG: [lldb/DataFormatters] Delete GetStringPrinterEscapingHelper

Summary:
Languages can have different ways of formatting special characters.
E.g. when debugging C++ code a string might look like "\b", but when
debugging Swift code the same string would look like "\u{8}".

To make this work, plugins override GetStringPrinterEscapingHelper.
However, because there's a large amount of subtly divergent work done in
each override, we end up with large amounts of duplicated code. And all
the memory smashers fixed in one copy of the logic (see D73860) don't
get fixed in the others.

IMO the GetStringPrinterEscapingHelper is overly general and hard to
use. I propose deleting it and replacing it with an EscapeStyle enum,
which can be set as needed by each plugin.

A fix for some swift-lldb memory smashers falls out fairly naturally
from this deletion (https://github.com/apple/llvm-project/pull/1046). As
the swift logic becomes really tiny, I propose moving it upstream as
part of this change. I've added unit tests to cover it.

rdar://61419673

Reviewers: JDevlieghere, davide

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

Added: 
lldb/unittests/DataFormatter/StringPrinterTests.cpp

Modified: 
lldb/include/lldb/DataFormatters/StringPrinter.h
lldb/include/lldb/Target/Language.h
lldb/source/DataFormatters/StringPrinter.cpp
lldb/source/Plugins/Language/ObjC/NSString.cpp
lldb/source/Target/Language.cpp
lldb/unittests/DataFormatter/CMakeLists.txt

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/StringPrinter.h 
b/lldb/include/lldb/DataFormatters/StringPrinter.h
index 5842cde893d8..17c645f8637a 100644
--- a/lldb/include/lldb/DataFormatters/StringPrinter.h
+++ b/lldb/include/lldb/DataFormatters/StringPrinter.h
@@ -24,6 +24,8 @@ class StringPrinter {
 
   enum class GetPrintableElementType { ASCII, UTF8 };
 
+  enum class EscapeStyle { CXX, Swift };
+
   class DumpToStreamOptions {
   public:
 DumpToStreamOptions() = default;
@@ -68,9 +70,9 @@ class StringPrinter {
 
 bool GetIgnoreMaxLength() const { return m_ignore_max_length; }
 
-void SetLanguage(lldb::LanguageType l) { m_language_type = l; }
+void SetEscapeStyle(EscapeStyle style) { m_escape_style = style; }
 
-lldb::LanguageType GetLanguage() const { return m_language_type; }
+EscapeStyle GetEscapeStyle() const { return m_escape_style; }
 
   private:
 /// The used output stream.
@@ -93,12 +95,8 @@ class StringPrinter {
 /// True iff a zero bytes ('\0') should terminate the memory region that
 /// is being dumped.
 bool m_zero_is_terminator = true;
-/// The language that the generated string literal is supposed to be valid
-/// for. This changes for example what and how certain characters are
-/// escaped.
-/// For example, printing the a string containing only a quote (") char
-/// with eLanguageTypeC would escape the quote character.
-lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
+/// The language-specific style for escaping special characters.
+EscapeStyle m_escape_style = EscapeStyle::CXX;
   };
 
   class ReadStringAndDumpToStreamOptions : public DumpToStreamOptions {
@@ -147,71 +145,6 @@ class StringPrinter {
 bool m_is_truncated = false;
   };
 
-  // I can't use a std::unique_ptr for this because the Deleter is a template
-  // argument there
-  // and I want the same type to represent both pointers I want to free and
-  // pointers I don't need to free - which is what this class essentially is
-  // It's very specialized to the needs of this file, and not suggested for
-  // general use
-  struct StringPrinterBufferPointer {
-  public:
-typedef std::function Deleter;
-
-StringPrinterBufferPointer(std::nullptr_t ptr)
-: m_data(nullptr), m_size(0), m_deleter() {}
-
-StringPrinterBufferPointer(const uint8_t *bytes, size_t size,
-   Deleter deleter = nullptr)
-: m_data(bytes), m_size(size), m_deleter(deleter) {}
-
-StringPrinterBufferPointer(const char *bytes, size_t size,
-   Deleter deleter = nullptr)
-: m_data(reinterpret_cast(bytes)), m_size(size),
-  m_deleter(deleter) {}
-
-StringPrinterBufferPointer(StringPrinterBufferPointer &&rhs)
-: m_data(rhs.m_data), m_size(rhs.m_size), m_deleter(rhs.m_deleter) {
-  rhs.m_data = nullptr;
-}
-
-~StringPrinterBufferPointer() {
-  if (m_data && m_deleter)
-m_deleter(m_data);
-  m_data = nullptr;
-}
-
-cons

[Lldb-commits] [lldb] 6951fe3 - [arm64] Remove an old special case that's not needed anymore.

2020-05-04 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-05-04T14:18:51-07:00
New Revision: 6951fe3989343c6605c397ac427acea4e39d2132

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

LOG: [arm64] Remove an old special case that's not needed anymore.

Debug info generation & codegen now steps onto the correct line.

Added: 


Modified: 
lldb/test/API/functionalities/thread/step_out/TestThreadStepOut.py
lldb/test/API/functionalities/thread/step_out/main.cpp

Removed: 




diff  --git 
a/lldb/test/API/functionalities/thread/step_out/TestThreadStepOut.py 
b/lldb/test/API/functionalities/thread/step_out/TestThreadStepOut.py
index 2d9632eb2dd6..eb2d264ec2e3 100644
--- a/lldb/test/API/functionalities/thread/step_out/TestThreadStepOut.py
+++ b/lldb/test/API/functionalities/thread/step_out/TestThreadStepOut.py
@@ -70,9 +70,9 @@ def setUp(self):
 self.bkpt_string = '// Set breakpoint here'
 self.breakpoint = line_number('main.cpp', self.bkpt_string)   
 
-if "gcc" in self.getCompiler() or self.isIntelCompiler() or 
self.getArchitecture() in ['arm64', 'arm64e']:
+if "gcc" in self.getCompiler() or self.isIntelCompiler():
 self.step_out_destination = line_number(
-'main.cpp', '// Expect to stop here after step-out (icc and 
gcc; arm64)')
+'main.cpp', '// Expect to stop here after step-out (icc and 
gcc)')
 else:
 self.step_out_destination = line_number(
 'main.cpp', '// Expect to stop here after step-out (clang)')

diff  --git a/lldb/test/API/functionalities/thread/step_out/main.cpp 
b/lldb/test/API/functionalities/thread/step_out/main.cpp
index 76818fff925a..14d84010de8a 100644
--- a/lldb/test/API/functionalities/thread/step_out/main.cpp
+++ b/lldb/test/API/functionalities/thread/step_out/main.cpp
@@ -22,7 +22,7 @@ thread_func ()
 step_out_of_here(); // Expect to stop here after step-out (clang)
 
 // Return
-return NULL;  // Expect to stop here after step-out (icc and gcc; arm64)
+return NULL;  // Expect to stop here after step-out (icc and gcc)
 }
 
 int main ()



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


[Lldb-commits] [PATCH] D77843: [lldb/DataFormatters] Delete GetStringPrinterEscapingHelper

2020-05-04 Thread Vedant Kumar via Phabricator via lldb-commits
vsk marked an inline comment as done.
vsk added inline comments.



Comment at: lldb/source/DataFormatters/StringPrinter.cpp:42-43
+  llvm_unreachable("unsupported length");
+memcpy(reinterpret_cast(m_data),
+   reinterpret_cast(bytes), size);
+  }

labath wrote:
> What's up with all the `reinterpret_cast`ing? `T*` is implicitly convertible 
> to a `void*`...
Ah thanks for catching this, I'll get rid of the redundant casts before 
committing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77843



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


[Lldb-commits] [PATCH] D77843: [lldb/DataFormatters] Delete GetStringPrinterEscapingHelper

2020-05-04 Thread Vedant Kumar via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa37caebc2d2d: [lldb/DataFormatters] Delete 
GetStringPrinterEscapingHelper (authored by vsk).

Changed prior to commit:
  https://reviews.llvm.org/D77843?vs=261558&id=261934#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77843

Files:
  lldb/include/lldb/DataFormatters/StringPrinter.h
  lldb/include/lldb/Target/Language.h
  lldb/source/DataFormatters/StringPrinter.cpp
  lldb/source/Plugins/Language/ObjC/NSString.cpp
  lldb/source/Target/Language.cpp
  lldb/unittests/DataFormatter/CMakeLists.txt
  lldb/unittests/DataFormatter/StringPrinterTests.cpp

Index: lldb/unittests/DataFormatter/StringPrinterTests.cpp
===
--- /dev/null
+++ lldb/unittests/DataFormatter/StringPrinterTests.cpp
@@ -0,0 +1,159 @@
+//===-- StringPrinterTests.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/StreamString.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+using lldb_private::formatters::StringPrinter;
+using llvm::Optional;
+using llvm::StringRef;
+
+#define QUOTE(x) std::string("\"" x "\"")
+
+/// Format \p input according to the specified string encoding and special char
+/// escape style.
+template 
+static Optional format(StringRef input,
+StringPrinter::EscapeStyle escape_style) {
+  StreamString out;
+  StringPrinter::ReadBufferAndDumpToStreamOptions opts;
+  opts.SetStream(&out);
+  opts.SetSourceSize(input.size());
+  opts.SetNeedsZeroTermination(true);
+  opts.SetEscapeNonPrintables(true);
+  opts.SetIgnoreMaxLength(false);
+  opts.SetEscapeStyle(escape_style);
+  DataExtractor extractor(input.data(), input.size(),
+  endian::InlHostByteOrder(), sizeof(void *));
+  opts.SetData(extractor);
+  const bool success = StringPrinter::ReadBufferAndDumpToStream(opts);
+  if (!success)
+return llvm::None;
+  return out.GetString().str();
+}
+
+// Test ASCII formatting for C++. This behaves exactly like UTF8 formatting for
+// C++, although that's questionable (see FIXME in StringPrinter.cpp).
+TEST(StringPrinterTests, CxxASCII) {
+  auto fmt = [](StringRef str) {
+return format(
+str, StringPrinter::EscapeStyle::CXX);
+  };
+
+  // Special escapes.
+  EXPECT_EQ(fmt({"\0", 1}), QUOTE(""));
+  EXPECT_EQ(fmt("\a"), QUOTE(R"(\a)"));
+  EXPECT_EQ(fmt("\b"), QUOTE(R"(\b)"));
+  EXPECT_EQ(fmt("\f"), QUOTE(R"(\f)"));
+  EXPECT_EQ(fmt("\n"), QUOTE(R"(\n)"));
+  EXPECT_EQ(fmt("\r"), QUOTE(R"(\r)"));
+  EXPECT_EQ(fmt("\t"), QUOTE(R"(\t)"));
+  EXPECT_EQ(fmt("\v"), QUOTE(R"(\v)"));
+  EXPECT_EQ(fmt("\""), QUOTE(R"(\")"));
+  EXPECT_EQ(fmt("\'"), QUOTE(R"(')"));
+  EXPECT_EQ(fmt("\\"), QUOTE(R"(\\)"));
+
+  // Printable characters.
+  EXPECT_EQ(fmt("'"), QUOTE("'"));
+  EXPECT_EQ(fmt("a"), QUOTE("a"));
+  EXPECT_EQ(fmt("Z"), QUOTE("Z"));
+  EXPECT_EQ(fmt("🥑"), QUOTE("🥑"));
+
+  // Octal (\nnn), hex (\xnn), extended octal (\u or \U).
+  EXPECT_EQ(fmt("\uD55C"), QUOTE("한"));
+  EXPECT_EQ(fmt("\U00010348"), QUOTE("𐍈"));
+
+  // FIXME: These strings are all rejected, but shouldn't be AFAICT. LLDB finds
+  // that these are not valid utf8 sequences, but that's OK, the raw values
+  // should still be printed out.
+  EXPECT_NE(fmt("\376"), QUOTE(R"(\xfe)")); // \376 is 254 in decimal.
+  EXPECT_NE(fmt("\xfe"), QUOTE(R"(\xfe)")); // \xfe is 254 in decimal.
+}
+
+// Test UTF8 formatting for C++.
+TEST(StringPrinterTests, CxxUTF8) {
+  auto fmt = [](StringRef str) {
+return format(
+str, StringPrinter::EscapeStyle::CXX);
+  };
+
+  // Special escapes.
+  EXPECT_EQ(fmt({"\0", 1}), QUOTE(""));
+  EXPECT_EQ(fmt("\a"), QUOTE(R"(\a)"));
+  EXPECT_EQ(fmt("\b"), QUOTE(R"(\b)"));
+  EXPECT_EQ(fmt("\f"), QUOTE(R"(\f)"));
+  EXPECT_EQ(fmt("\n"), QUOTE(R"(\n)"));
+  EXPECT_EQ(fmt("\r"), QUOTE(R"(\r)"));
+  EXPECT_EQ(fmt("\t"), QUOTE(R"(\t)"));
+  EXPECT_EQ(fmt("\v"), QUOTE(R"(\v)"));
+  EXPECT_EQ(fmt("\""), QUOTE(R"(\")"));
+  EXPECT_EQ(fmt("\'"), QUOTE(R"(')"));
+  EXPECT_EQ(fmt("\\"), QUOTE(R"(\\)"));
+
+  // Printable characters.
+  EXPECT_EQ(fmt("'"), QUOTE("'"));
+  EXPECT_EQ(fmt("a"), QUOTE("a"));
+  EXPECT_EQ(fmt("Z"), QUOTE("Z"));
+  EXPECT_EQ(fmt("🥑"), QUOTE("🥑"));
+
+  // Octal (\nnn), hex (\xnn), extended octal (\u or 

[Lldb-commits] [lldb] 97db238 - [lldb] Fix -Wdtor-name warnings

2020-05-04 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-05-04T14:32:28-07:00
New Revision: 97db238c17020678c61d7874fb92729c7c9d3cab

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

LOG: [lldb] Fix -Wdtor-name warnings

Fix warning: ISO C++ requires the name after '::~' to be found in the
same scope as the name before '::~' [-Wdtor-name]

Added: 


Modified: 
lldb/source/Plugins/Language/ObjC/NSArray.cpp
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
lldb/source/Plugins/Language/ObjC/NSSet.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp 
b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 8c889927b936..e1c789ce26d8 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -529,7 +529,7 @@ 
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName
 template 
 lldb_private::formatters::
   GenericNSArrayMSyntheticFrontEnd::
-~GenericNSArrayMSyntheticFrontEnd() {
+~GenericNSArrayMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;
@@ -596,7 +596,7 @@ 
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
 
 template 
 lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
-  ~GenericNSArrayISyntheticFrontEnd() {
+  ~GenericNSArrayISyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;

diff  --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp 
b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index 995b8751ec55..998c72e429e7 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -900,7 +900,7 @@ 
lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd::
 
 template 
 lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd::
-~GenericNSDictionaryMSyntheticFrontEnd() {
+~GenericNSDictionaryMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;

diff  --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp 
b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
index 3a24aa6059ca..543a1c5978e0 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
@@ -682,7 +682,7 @@ lldb_private::formatters::
 
 template 
 lldb_private::formatters::
-  GenericNSSetMSyntheticFrontEnd::~GenericNSSetMSyntheticFrontEnd() {
+  GenericNSSetMSyntheticFrontEnd::~GenericNSSetMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;



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


[Lldb-commits] [lldb] 9e35498 - [lldb/Expression] Make Language() const, NFC

2020-05-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-04T14:42:01-07:00
New Revision: 9e3549804672c79d64eececab39019f4dfd2b7ea

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

LOG: [lldb/Expression] Make Language() const, NFC

Allow Language() to be called from const methods within UserExpression.

Added: 


Modified: 
lldb/include/lldb/Expression/Expression.h
lldb/include/lldb/Expression/UserExpression.h

Removed: 




diff  --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 1e4453de04ff..aaac889e6ed2 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -51,7 +51,9 @@ class Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
+  virtual lldb::LanguageType Language() const {
+return lldb::eLanguageTypeUnknown;
+  }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.

diff  --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index 8f3a505addea..8236c417f73a 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -194,7 +194,7 @@ class UserExpression : public Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  lldb::LanguageType Language() override { return m_language; }
+  lldb::LanguageType Language() const override { return m_language; }
 
   /// Return the desired result type of the function, or eResultTypeAny if
   /// in
diff erent.



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


[Lldb-commits] [lldb] 58c7bf2 - Update LLDB filespec tests for remove_dots change

2020-05-04 Thread Reid Kleckner via lldb-commits

Author: Reid Kleckner
Date: 2020-05-04T17:27:16-07:00
New Revision: 58c7bf246ec4056ca40ea37f16cb3314161863f7

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

LOG: Update LLDB filespec tests for remove_dots change

It looks like the new implementation is correct, since there were TODOs
here about getting the new behavior.

I am not sure if "C:..\.." should become "C:" or "C:\", though. The new
output doesn't precisely match the TODO message, but it seems
appropriate given the specification of remove_dots and how .. traversals
work at the root directory.

Added: 


Modified: 
lldb/unittests/Utility/FileSpecTest.cpp

Removed: 




diff  --git a/lldb/unittests/Utility/FileSpecTest.cpp 
b/lldb/unittests/Utility/FileSpecTest.cpp
index 690c5ae331ee..ad2e328ce82f 100644
--- a/lldb/unittests/Utility/FileSpecTest.cpp
+++ b/lldb/unittests/Utility/FileSpecTest.cpp
@@ -246,13 +246,11 @@ TEST(FileSpecTest, GetPath) {
   {R"(\\net)", R"(\\net)"},
   {R"(c:\..)", R"(c:\)"},
   {R"(c:\.)", R"(c:\)"},
-  // TODO: fix llvm::sys::path::remove_dots() to return "\" below.
-  {R"(\..)", R"(\..)"},
+  {R"(\..)", R"(\)"},
   //  {R"(c:..)", R"(c:..)"},
   {R"(..)", R"(..)"},
   {R"(.)", R"(.)"},
-  // TODO: fix llvm::sys::path::remove_dots() to return "c:\" below.
-  {R"(c:..\..)", R"(c:\..\..)"},
+  {R"(c:..\..)", R"(c:)"},
   {R"(..\..)", R"(..\..)"},
   {R"(foo\..)", R"(.)"},
   {R"(foo\..\bar)", R"(bar)"},



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


[Lldb-commits] [lldb] 3618381 - Clarify comment

2020-05-04 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2020-05-04T18:15:30-07:00
New Revision: 36183811fb5455ea18cf7d9cd03748076f20573b

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

LOG: Clarify comment

Added: 


Modified: 
lldb/include/lldb/Symbol/SymbolFile.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index bc2b6b8f212e..86c8af665d32 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -136,12 +136,16 @@ class SymbolFile : public PluginInterface {
   /// \p comp_unit. Recursively also descends into the referenced external
   /// modules of any encountered compilation unit.
   ///
+  /// This function can be used to traverse Clang -gmodules debug
+  /// information, which is stored in DWARF files separate from the
+  /// object files.
+  ///
   /// \param comp_unit
   /// When this SymbolFile consists of multiple auxilliary
   /// SymbolFiles, for example, a Darwin debug map that references
   /// multiple .o files, comp_unit helps choose the auxilliary
   /// file. In most other cases comp_unit's symbol file is
-  /// identiacal with *this.
+  /// identical with *this.
   ///
   /// \param[in] lambda
   /// The lambda that should be applied to every function. The lambda can



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


[Lldb-commits] [PATCH] D79384: RFC: Add an API that allows iterating over a debug map's OSO's Modules

2020-05-04 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: jingham, jasonmolenda, teemperor, friss.
Herald added a reviewer: jdoerfert.

For Swift LLDB (but potentially also for module support in Clang-land) I need a 
way to accumulate the path remappings produced by `Module::RegisterXcodeSDK()`. 
 Unfortunately there is no way to go from an executable's Module to the 
auxiliary modules that represent the individual OSO object files of a 
SymbolFileDWARFDebugMap.

Here is a proposed API that would allow me to do this. Does this look 
reasonable?


https://reviews.llvm.org/D79384

Files:
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -67,6 +67,8 @@
   bool ForEachExternalModule(
   lldb_private::CompileUnit &, llvm::DenseSet 
&,
   llvm::function_ref) override;
+  bool ForEachAuxiliaryModule(
+  llvm::function_ref) override;
 
   bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit,
  lldb_private::FileSpecList &support_files) override;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -663,6 +663,19 @@
   return false;
 }
 
+bool SymbolFileDWARFDebugMap::ForEachAuxiliaryModule(
+llvm::function_ref f) {
+  std::lock_guard guard(GetModuleMutex());
+  ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+if (oso_dwarf)
+  if (auto *obj = oso_dwarf->GetObjectFile())
+if (ModuleSP module_sp = obj->GetModule())
+  return f(*module_sp);
+return false;
+  });
+  return false;
+}
+
 bool SymbolFileDWARFDebugMap::ParseSupportFiles(CompileUnit &comp_unit,
 FileSpecList &support_files) {
   std::lock_guard guard(GetModuleMutex());
Index: lldb/include/lldb/Symbol/SymbolFile.h
===
--- lldb/include/lldb/Symbol/SymbolFile.h
+++ lldb/include/lldb/Symbol/SymbolFile.h
@@ -164,6 +164,25 @@
   llvm::function_ref lambda) {
 return false;
   }
+
+  /// Apply a lambda to each auxiliary lldb::Module referenced by this
+  /// \p comp_unit.
+  ///
+  /// This function can be used to traverse all OSO modules in a
+  /// SymbolFileDWARFDebugMap.
+  ///
+  /// \param[in] lambda
+  /// The lambda that should be applied to every function. The lambda can
+  /// return true if the iteration should be aborted earlier.
+  ///
+  /// \return
+  /// If the lambda early-exited, this function returns true to
+  /// propagate the early exit.
+  virtual bool
+  ForEachAuxiliaryModule(llvm::function_ref lambda) {
+return false;
+  }
+
   virtual bool ParseSupportFiles(CompileUnit &comp_unit,
  FileSpecList &support_files) = 0;
   virtual size_t ParseTypes(CompileUnit &comp_unit) = 0;


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -67,6 +67,8 @@
   bool ForEachExternalModule(
   lldb_private::CompileUnit &, llvm::DenseSet &,
   llvm::function_ref) override;
+  bool ForEachAuxiliaryModule(
+  llvm::function_ref) override;
 
   bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit,
  lldb_private::FileSpecList &support_files) override;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -663,6 +663,19 @@
   return false;
 }
 
+bool SymbolFileDWARFDebugMap::ForEachAuxiliaryModule(
+llvm::function_ref f) {
+  std::lock_guard guard(GetModuleMutex());
+  ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+if (oso_dwarf)
+  if (auto *obj = oso_dwarf->GetObjectFile())
+if (ModuleSP module_sp = obj->GetModule())
+  return f(*module_sp);
+return false;
+  });
+  return false;
+}
+
 bool SymbolFileDWARFDebugMap::ParseSupportFiles(CompileUnit &comp_unit,
 FileSpecList &support_files) {
   std::lock_guard guard(GetModuleMutex());
Index: lldb/include/lldb/Symbol/SymbolFile.h
===

[Lldb-commits] [PATCH] D78825: [lldb/Driver] Exit with a non-zero exit code in batch mode when stopping because of an error.

2020-05-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

LGTM now. Pavel?


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

https://reviews.llvm.org/D78825



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


[Lldb-commits] [PATCH] D78801: [LLDB] Add class WasmProcess for WebAssembly debugging

2020-05-04 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Interesting approach to DWARF expression evaluation, though it might be simpler 
to leave the DWARFExpression as it is, and have the plug-in part only handle 
unknown opcodes. Right now if you want to add just one opcode, you must 
subclass and make a plug-in instance where 99% of opcodes get forwarded to the 
original implementation and the one new opcode gets handled by the plug-in. 
What if the DWARFExpression class was passed to a plug-in that only handles 
unknown opcodes? Might be fewer code changes and be a bit cleaner. The plug-in 
would handle only the DW_OP_WASM_location and would still be found/detected if 
and only if one is encountered?

As for unwinding, I still don't think we need the UnwindWASM class. See my 
inline comment in "Unwind &Thread::GetUnwinder()" for a bit of reasoning. It is 
very common for runtimes for languages to support supplying the stack frames 
for a thread, so this should be built into the 
lldb_private::Process/lldb_private::Thread classes. For stack unwindind I would 
suggest adding functions to lldb_private::Thread:

  class Thread {
/// Check if the runtime supports unwinding call stacks and return true if 
so.
///
/// If the language runs in a runtime that knows how to unwind the call 
stack
/// for a thread, then this function should return true.
///
/// If true is returned, unwinding will use a RuntimeUnwind class that will 
call
/// into this class' Thread::GetRuntimeFrame* functions to do the unwinding.
/// If false is returned, the standard UnwindLLDB will be used where 
unwinding
/// will be done using registers, unwind info and other debug info.
virtual bool HasRuntimeUnwindSupport() {
  return false; // Default to using UnwindLLDB()
}
virtual uint32_t GetRuntimeFrameCount() {
  return 0;
   }
   virtual bool GetRuntimeFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t 
&cfa, lldb::addr_t &pc, bool &behaves_like_zeroth_frame) {
return false;
   }
   virtual lldb::RegisterContextSP GetRuntimeFrameRegisterContext(uint32_t 
frame_idx) {
return lldb::RegisterContextSP();
   } 

Then either ThreadGDBRemote, or possibly a subclass like ThreadWasm will 
implement these virtual functions.

For the GetWasmLocal, GetWasmGlobal, GetWasmStackValue, I still think 
abstracting this into the lldb_private::Process/lldb_private::Thread is the 
right way to do this. The way you have this right now, there is not way to tell 
how big the buffer needs to be to fetch any of these local/global/stack values. 
They all assume 16 bytes is enough.

If we have a runtime that knows about information in a stack frame, function or 
global, then we should have a way to fetch that  from a process/thread. For 
example:

  class Process {
/// Fetch a global variable from the process runtime if this is supported.
///
/// \param var_id A 64 bit value that needs to encode all of the data 
needed to fetch a
///  global variable and should uniquely identify a global 
variable in a module.
/// \param buf A buffer that will get the bytes from the global variable. 
If buf is NULL, then
/// size will be returned so the client knows how large the 
variable is.
/// \param size The size of the buffer pointed to by "buf". If buf is NULL, 
this value can be 
///  zero to indicate the function should return the actual 
size of the global variable.
///
   /// \returns The actual size of the variable which might be larger that the 
"size" parameter.
virtual size_t GetRuntimeGlobalValue(lldb::user_id_t var_id, void *buf, 
size_t buffer_size) {
  return 0;
}

We would need to do something similar on the Thread class for locals and stack 
values:

  class Thread {
virtual size_t GetRuntimeLocalValue(uint32_t frame_idx, lldb::user_id_t 
var_id, void *buf, size_t buffer_size) {
  return 0;
}
virtual size_t GetRuntimeStackValue(uint32_t frame_idx, lldb::user_id_t 
var_id, void *buf, size_t buffer_size) {
  return 0;
}






Comment at: lldb/source/Expression/DWARFEvaluator.cpp:327-329
+  case DW_OP_WASM_location:
+assert(false);
+break;

This shouldn't be in here. Remove DW_OP_WASM_location as it is custom.



Comment at: lldb/source/Plugins/Process/wasm/WasmProcess.cpp:71-76
+  if (vm_addr < 0x1) {
+if (WasmReadMemory(0 /*frame_index*/, vm_addr, buf, size)) {
+  return size;
+}
+return 0;
+  } else

This seems flaky to me. How are you ever going to get the frame index right 
unless we encode it into the "vm_addr" using bitfields like we spoke about 
before. And if we encode it all into the 64 bit address, then we don't need 
this special read. Seems like we need to figure out if we are going to encode 
everything into an uint64_t or not. That will be the easiest way to integrate 
this into LLDB as all memory reads take a "ll