[Lldb-commits] [PATCH] D120718: Fix DataExtractor symbol conflict

2022-03-03 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay updated this revision to Diff 412621.
emrekultursay added a comment.

Reverted the changes to the header file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120718

Files:
  lldb/source/Core/DataFileCache.cpp

Index: lldb/source/Core/DataFileCache.cpp
===
--- lldb/source/Core/DataFileCache.cpp
+++ lldb/source/Core/DataFileCache.cpp
@@ -17,17 +17,16 @@
 #include "llvm/Support/CachePruning.h"
 #include "llvm/Support/MemoryBuffer.h"
 
-using namespace llvm;
 using namespace lldb_private;
 
-DataFileCache::DataFileCache(StringRef path) {
+DataFileCache::DataFileCache(llvm::StringRef path) {
   m_cache_dir.SetPath(path);
 
   // Prune the cache based off of the LLDB settings each time we create a cache
   // object.
   ModuleListProperties &properties =
   ModuleList::GetGlobalModuleListProperties();
-  CachePruningPolicy policy;
+  llvm::CachePruningPolicy policy;
   // Only scan once an hour. If we have lots of debug sessions we don't want
   // to scan this directory too often. A timestamp file is written to the
   // directory to ensure different processes don't scan the directory too often.
@@ -52,7 +51,7 @@
 if (m_take_ownership)
   m_mem_buff_up = std::move(m);
   };
-  Expected cache_or_err =
+  llvm::Expected cache_or_err =
   llvm::localCache("LLDBModuleCache", "lldb-module", path, add_buffer);
   if (cache_or_err)
 m_cache_callback = std::move(*cache_or_err);
@@ -64,7 +63,7 @@
 }
 
 std::unique_ptr
-DataFileCache::GetCachedData(StringRef key) {
+DataFileCache::GetCachedData(llvm::StringRef key) {
   std::lock_guard guard(m_mutex);
 
   const unsigned task = 1;
@@ -73,13 +72,13 @@
   // call the "add_buffer" lambda function from the constructor which will in
   // turn take ownership of the member buffer that is passed to the callback and
   // put it into a member variable.
-  Expected add_stream_or_err = m_cache_callback(task, key);
+  llvm::Expected add_stream_or_err = m_cache_callback(task, key);
   m_take_ownership = false;
   // At this point we either already called the "add_buffer" lambda with
   // the data or we haven't. We can tell if we got the cached data by checking
   // the add_stream function pointer value below.
   if (add_stream_or_err) {
-AddStreamFn &add_stream = *add_stream_or_err;
+llvm::AddStreamFn &add_stream = *add_stream_or_err;
 // If the "add_stream" is nullptr, then the data was cached and we already
 // called the "add_buffer" lambda. If it is valid, then if we were to call
 // the add_stream function it would cause a cache file to get generated
@@ -97,18 +96,18 @@
   return std::unique_ptr();
 }
 
-bool DataFileCache::SetCachedData(StringRef key, llvm::ArrayRef data) {
+bool DataFileCache::SetCachedData(llvm::StringRef key, llvm::ArrayRef data) {
   std::lock_guard guard(m_mutex);
   const unsigned task = 2;
   // If we call this function and the data is cached, it will call the
   // add_buffer lambda function from the constructor which will ignore the
   // data.
-  Expected add_stream_or_err = m_cache_callback(task, key);
+  llvm::Expected add_stream_or_err = m_cache_callback(task, key);
   // If we reach this code then we either already called the callback with
   // the data or we haven't. We can tell if we had the cached data by checking
   // the CacheAddStream function pointer value below.
   if (add_stream_or_err) {
-AddStreamFn &add_stream = *add_stream_or_err;
+llvm::AddStreamFn &add_stream = *add_stream_or_err;
 // If the "add_stream" is nullptr, then the data was cached. If it is
 // valid, then if we call the add_stream function with a task it will
 // cause the file to get generated, but we only want to check if the data
@@ -117,10 +116,10 @@
 // provided, but we won't take ownership of the memory buffer as we just
 // want to write the data.
 if (add_stream) {
-  Expected> file_or_err =
+  llvm::Expected> file_or_err =
   add_stream(task);
   if (file_or_err) {
-CachedFileStream *cfs = file_or_err->get();
+llvm::CachedFileStream *cfs = file_or_err->get();
 cfs->OS->write((const char *)data.data(), data.size());
 return true;
   } else {
@@ -219,7 +218,7 @@
   return true;
 }
 
-bool CacheSignature::Decode(const DataExtractor &data,
+bool CacheSignature::Decode(const lldb_private::DataExtractor &data,
 lldb::offset_t *offset_ptr) {
   Clear();
   while (uint8_t sig_encoding = data.GetU8(offset_ptr)) {
@@ -284,7 +283,7 @@
   return true;
 }
 
-bool StringTableReader::Decode(const DataExtractor &data,
+bool StringTableReader::Decode(const lldb_private::DataExtractor &data,
lldb::offset_t *offset_ptr) {
   llvm::StringRef identifier((const char *)data.GetData(offset_ptr, 4), 4);
   if (identifier != kStringTabl

[Lldb-commits] [PATCH] D120718: Fix DataExtractor symbol conflict

2022-03-03 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay marked an inline comment as done.
emrekultursay added a comment.

Thanks. PTAL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120718

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


[Lldb-commits] [PATCH] D120836: [LLDB] Remove cases of using namespace llvm:: from header file

2022-03-03 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp:19
 using namespace lldb;
+using namespace dwarf;
 

JDevlieghere wrote:
> shafik wrote:
> > JDevlieghere wrote:
> > > Wouldn't it be more consistent to use `lldb_private::dwarf` everywhere? 
> > Yeah, I was trying to match the style of  how it was done for minidump, see 
> > `source/Plugins/Process/minidump/MinidumpParser.cpp`.
> > 
> > Since we need access to both namespaces but in files that did already have 
> > `using namespace lldb_private;` I just used the less verbose version.
> > 
> > I can see arguments for just being verbose everywhere.
> Maybe it's just preference? Curious to hear from @labath why he did it that 
> way. Personally I prefer the slightly more verbose one because it's self 
> contained. 
Actually, I totally agree with you here. I think I did not personally write 
that using directive. I recall noticing it (during review, or during subsequent 
edits), but not considering it worth the trouble of changing it.

So +1 to verbose using directives.


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

https://reviews.llvm.org/D120836

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


[Lldb-commits] [lldb] 6b3b3ef - [lldb] Correct case in description of breakpoint --on-catch/throw

2022-03-03 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2022-03-03T10:06:11Z
New Revision: 6b3b3ef344504334f43afe76c805d2e6e7b587e9

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

LOG: [lldb] Correct case in description of breakpoint --on-catch/throw

Somehow we ended up with catcH/throW.

Added: 


Modified: 
lldb/source/Commands/Options.td
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index a1548cb6b443f..470f4bc471c3e 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -176,9 +176,9 @@ let Command = "breakpoint set" in {
 Desc<"Set the breakpoint on exceptions thrown by the specified language "
 "(without options, on throw but not catch.)">;
   def breakpoint_set_on_throw : Option<"on-throw", "w">, Group<10>,
-Arg<"Boolean">, Desc<"Set the breakpoint on exception throW.">;
+Arg<"Boolean">, Desc<"Set the breakpoint on exception throw.">;
   def breakpoint_set_on_catch : Option<"on-catch", "h">, Group<10>,
-Arg<"Boolean">, Desc<"Set the breakpoint on exception catcH.">;
+Arg<"Boolean">, Desc<"Set the breakpoint on exception catch.">;
   def breakpoint_set_language : Option<"language", "L">, GroupRange<3, 8>,
 Arg<"Language">,
 Desc<"Specifies the Language to use when interpreting the breakpoint's "

diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index ed901890f7dfe..e858e38035c86 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -539,20 +539,20 @@ def test_completion_description_command_options(self):
 """Test descriptions of command options"""
 # Short options
 self.check_completion_with_desc("breakpoint set -", [
-["-h", "Set the breakpoint on exception catcH."],
-["-w", "Set the breakpoint on exception throW."]
+["-h", "Set the breakpoint on exception catch."],
+["-w", "Set the breakpoint on exception throw."]
 ])
 
 # Long options.
 self.check_completion_with_desc("breakpoint set --", [
-["--on-catch", "Set the breakpoint on exception catcH."],
-["--on-throw", "Set the breakpoint on exception throW."]
+["--on-catch", "Set the breakpoint on exception catch."],
+["--on-throw", "Set the breakpoint on exception throw."]
 ])
 
 # Ambiguous long options.
 self.check_completion_with_desc("breakpoint set --on-", [
-["--on-catch", "Set the breakpoint on exception catcH."],
-["--on-throw", "Set the breakpoint on exception throW."]
+["--on-catch", "Set the breakpoint on exception catch."],
+["--on-throw", "Set the breakpoint on exception throw."]
 ])
 
 # Unknown long option.



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


[Lldb-commits] [PATCH] D120320: [lldb/driver] Fix SIGTSTP handling

2022-03-03 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 412643.
labath marked 3 inline comments as done.
labath added a comment.

Address mgorny's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120320

Files:
  lldb/packages/Python/lldbsuite/test/lldbpexpect.py
  lldb/test/API/driver/job_control/TestJobControl.py
  lldb/test/API/driver/job_control/shell.py
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -671,23 +671,30 @@
   _exit(signo);
 }
 
-void sigtstp_handler(int signo) {
+#ifndef _WIN32
+static void sigtstp_handler(int signo) {
   if (g_driver != nullptr)
 g_driver->GetDebugger().SaveInputTerminalState();
 
+  // Unblock the signal and remove our handler.
+  sigset_t set;
+  sigemptyset(&set);
+  sigaddset(&set, signo);
+  pthread_sigmask(SIG_UNBLOCK, &set, nullptr);
   signal(signo, SIG_DFL);
-  kill(getpid(), signo);
+
+  // Now re-raise the signal. We will immediately suspend...
+  raise(signo);
+  // ... and resume after a SIGCONT.
+
+  // Now undo the modifications.
+  pthread_sigmask(SIG_BLOCK, &set, nullptr);
   signal(signo, sigtstp_handler);
-}
 
-void sigcont_handler(int signo) {
   if (g_driver != nullptr)
 g_driver->GetDebugger().RestoreInputTerminalState();
-
-  signal(signo, SIG_DFL);
-  kill(getpid(), signo);
-  signal(signo, sigcont_handler);
 }
+#endif
 
 void reproducer_handler(void *finalize_cmd) {
   if (SBReproducer::Generate()) {
@@ -834,7 +841,6 @@
   signal(SIGPIPE, SIG_IGN);
   signal(SIGWINCH, sigwinch_handler);
   signal(SIGTSTP, sigtstp_handler);
-  signal(SIGCONT, sigcont_handler);
 #endif
 
   int exit_code = 0;
Index: lldb/test/API/driver/job_control/shell.py
===
--- /dev/null
+++ lldb/test/API/driver/job_control/shell.py
@@ -0,0 +1,34 @@
+"""
+Launch a process (given through argv) similar to how a shell would do it.
+"""
+
+import signal
+import subprocess
+import sys
+import os
+
+
+def preexec_fn():
+# Block SIGTTOU generated by the tcsetpgrp call
+orig_mask = signal.pthread_sigmask(signal.SIG_BLOCK, [signal.SIGTTOU])
+
+# Put us in a new process group.
+os.setpgid(0, 0)
+
+# And put it in the foreground.
+fd = os.open("/dev/tty", os.O_RDONLY)
+os.tcsetpgrp(fd, os.getpgid(0))
+os.close(fd)
+
+signal.pthread_sigmask(signal.SIG_SETMASK, orig_mask)
+
+
+if __name__ == "__main__":
+child = subprocess.Popen(sys.argv[1:], preexec_fn=preexec_fn)
+print("PID=%d" % child.pid)
+
+_, status = os.waitpid(child.pid, os.WUNTRACED)
+print("STATUS=%d" % status)
+
+returncode = child.wait()
+print("RETURNCODE=%d" % returncode)
Index: lldb/test/API/driver/job_control/TestJobControl.py
===
--- /dev/null
+++ lldb/test/API/driver/job_control/TestJobControl.py
@@ -0,0 +1,32 @@
+"""
+Test lldb's handling of job control signals (SIGTSTP, SIGCONT).
+"""
+
+
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class JobControlTest(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_job_control(self):
+def post_spawn():
+self.child.expect("PID=([0-9]+)")
+self.lldb_pid = int(self.child.match[1])
+
+run_under = [sys.executable, self.getSourcePath('shell.py')]
+self.launch(run_under=run_under, post_spawn=post_spawn)
+
+os.kill(self.lldb_pid, signal.SIGTSTP)
+self.child.expect("STATUS=([0-9]+)")
+status = int(self.child.match[1])
+
+self.assertTrue(os.WIFSTOPPED(status))
+self.assertEquals(os.WSTOPSIG(status), signal.SIGTSTP)
+
+os.kill(self.lldb_pid, signal.SIGCONT)
+
+self.child.sendline("quit")
+self.child.expect("RETURNCODE=0")
Index: lldb/packages/Python/lldbsuite/test/lldbpexpect.py
===
--- lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -23,11 +23,15 @@
 def expect_prompt(self):
 self.child.expect_exact(self.PROMPT)
 
-def launch(self, executable=None, extra_args=None, timeout=60, dimensions=None):
+def launch(self, executable=None, extra_args=None, timeout=60,
+   dimensions=None, run_under=None, post_spawn=None):
 logfile = getattr(sys.stdout, 'buffer',
 sys.stdout) if self.TraceOn() else None
 
-args = ['--no-lldbinit', '--no-use-colors']
+args = []
+if run_under is not None:
+args += run_under
+args += [lldbtest_config.lldbExec, '--no-lldbinit', '--no-use-colors']
 for cmd in self.setUpCommands():
 args += ['-O', cmd]
 if ex

[Lldb-commits] [PATCH] D120320: [lldb/driver] Fix SIGTSTP handling

2022-03-03 Thread Michał Górny via Phabricator via lldb-commits
mgorny accepted this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

LGTM (but I cannot test)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120320

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


[Lldb-commits] [PATCH] D120892: [lldb] Warn when we fail to find dwo/dwp files

2022-03-03 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added a reviewer: JDevlieghere.
Herald added a project: All.
labath requested review of this revision.
Herald added a project: LLDB.

This ensures that the user is aware that many commands will not work
correctly.

We print the warning only once (per module) to avoid spamming the user
with potentially thousands of error messages.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120892

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp


Index: lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang --target=x86_64-pc-linux -g -gsplit-dwarf -c %s -o %t.o
+// RUN: rm %t.dwo
+// RUN: %lldb %t.o -o "br set -n main" -o exit 2>&1 | FileCheck %s
+
+// CHECK: warning: {{.*}} unable to locate separate debug file (dwo, dwp). 
Debugging will be degraded.
+
+int main() { return 47; }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -538,6 +538,7 @@
   ExternalTypeModuleMap m_external_type_modules;
   std::unique_ptr m_index;
   bool m_fetched_external_modules : 1;
+  bool m_dwo_warning_issued : 1;
   lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type;
 
   typedef std::set DIERefSet;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -412,7 +412,7 @@
   // contain the .o file index/ID
   m_debug_map_module_wp(), m_debug_map_symfile(nullptr),
   m_context(m_objfile_sp->GetModule()->GetSectionList(), dwo_section_list),
-  m_fetched_external_modules(false),
+  m_fetched_external_modules(false), m_dwo_warning_issued(false),
   m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate) {}
 
 SymbolFileDWARF::~SymbolFileDWARF() = default;
@@ -1745,8 +1745,15 @@
 dwo_file.AppendPathComponent(dwo_name);
   }
 
-  if (!FileSystem::Instance().Exists(dwo_file))
+  if (!FileSystem::Instance().Exists(dwo_file)) {
+if (!m_dwo_warning_issued) {
+  m_dwo_warning_issued = true;
+  GetObjectFile()->GetModule()->ReportWarning(
+  "unable to locate separate debug file (dwo, dwp). Debugging will be "
+  "degraded.");
+}
 return nullptr;
+  }
 
   const lldb::offset_t file_offset = 0;
   DataBufferSP dwo_file_data_sp;


Index: lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang --target=x86_64-pc-linux -g -gsplit-dwarf -c %s -o %t.o
+// RUN: rm %t.dwo
+// RUN: %lldb %t.o -o "br set -n main" -o exit 2>&1 | FileCheck %s
+
+// CHECK: warning: {{.*}} unable to locate separate debug file (dwo, dwp). Debugging will be degraded.
+
+int main() { return 47; }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -538,6 +538,7 @@
   ExternalTypeModuleMap m_external_type_modules;
   std::unique_ptr m_index;
   bool m_fetched_external_modules : 1;
+  bool m_dwo_warning_issued : 1;
   lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type;
 
   typedef std::set DIERefSet;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -412,7 +412,7 @@
   // contain the .o file index/ID
   m_debug_map_module_wp(), m_debug_map_symfile(nullptr),
   m_context(m_objfile_sp->GetModule()->GetSectionList(), dwo_section_list),
-  m_fetched_external_modules(false),
+  m_fetched_external_modules(false), m_dwo_warning_issued(false),
   m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate) {}
 
 SymbolFileDWARF::~SymbolFileDWARF() = default;
@@ -1745,8 +1745,15 @@
 dwo_file.AppendPathComponent(dwo_name);
   }
 
-  if (!FileSystem::Instance().Exists(dwo_file))
+  if (!FileSystem::Instance().Exists(dwo_file)) {
+if (!m_dwo_warning_issued) {
+  m_dwo_warning_issued = true;
+  GetObjectFile()->GetModule()->ReportWarning(
+  "

[Lldb-commits] [PATCH] D120718: Fix DataExtractor symbol conflict

2022-03-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

Thank you! LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120718

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


[Lldb-commits] [PATCH] D120718: Fix DataExtractor symbol conflict

2022-03-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71e278805a72: [lldb] Fix DataExtractor symbol conflict 
(authored by emrekultursay, committed by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D120718?vs=412621&id=412740#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120718

Files:
  lldb/source/Core/DataFileCache.cpp

Index: lldb/source/Core/DataFileCache.cpp
===
--- lldb/source/Core/DataFileCache.cpp
+++ lldb/source/Core/DataFileCache.cpp
@@ -17,17 +17,16 @@
 #include "llvm/Support/CachePruning.h"
 #include "llvm/Support/MemoryBuffer.h"
 
-using namespace llvm;
 using namespace lldb_private;
 
-DataFileCache::DataFileCache(StringRef path) {
+DataFileCache::DataFileCache(llvm::StringRef path) {
   m_cache_dir.SetPath(path);
 
   // Prune the cache based off of the LLDB settings each time we create a cache
   // object.
   ModuleListProperties &properties =
   ModuleList::GetGlobalModuleListProperties();
-  CachePruningPolicy policy;
+  llvm::CachePruningPolicy policy;
   // Only scan once an hour. If we have lots of debug sessions we don't want
   // to scan this directory too often. A timestamp file is written to the
   // directory to ensure different processes don't scan the directory too often.
@@ -52,7 +51,7 @@
 if (m_take_ownership)
   m_mem_buff_up = std::move(m);
   };
-  Expected cache_or_err =
+  llvm::Expected cache_or_err =
   llvm::localCache("LLDBModuleCache", "lldb-module", path, add_buffer);
   if (cache_or_err)
 m_cache_callback = std::move(*cache_or_err);
@@ -64,7 +63,7 @@
 }
 
 std::unique_ptr
-DataFileCache::GetCachedData(StringRef key) {
+DataFileCache::GetCachedData(llvm::StringRef key) {
   std::lock_guard guard(m_mutex);
 
   const unsigned task = 1;
@@ -73,13 +72,14 @@
   // call the "add_buffer" lambda function from the constructor which will in
   // turn take ownership of the member buffer that is passed to the callback and
   // put it into a member variable.
-  Expected add_stream_or_err = m_cache_callback(task, key);
+  llvm::Expected add_stream_or_err =
+  m_cache_callback(task, key);
   m_take_ownership = false;
   // At this point we either already called the "add_buffer" lambda with
   // the data or we haven't. We can tell if we got the cached data by checking
   // the add_stream function pointer value below.
   if (add_stream_or_err) {
-AddStreamFn &add_stream = *add_stream_or_err;
+llvm::AddStreamFn &add_stream = *add_stream_or_err;
 // If the "add_stream" is nullptr, then the data was cached and we already
 // called the "add_buffer" lambda. If it is valid, then if we were to call
 // the add_stream function it would cause a cache file to get generated
@@ -97,18 +97,20 @@
   return std::unique_ptr();
 }
 
-bool DataFileCache::SetCachedData(StringRef key, llvm::ArrayRef data) {
+bool DataFileCache::SetCachedData(llvm::StringRef key,
+  llvm::ArrayRef data) {
   std::lock_guard guard(m_mutex);
   const unsigned task = 2;
   // If we call this function and the data is cached, it will call the
   // add_buffer lambda function from the constructor which will ignore the
   // data.
-  Expected add_stream_or_err = m_cache_callback(task, key);
+  llvm::Expected add_stream_or_err =
+  m_cache_callback(task, key);
   // If we reach this code then we either already called the callback with
   // the data or we haven't. We can tell if we had the cached data by checking
   // the CacheAddStream function pointer value below.
   if (add_stream_or_err) {
-AddStreamFn &add_stream = *add_stream_or_err;
+llvm::AddStreamFn &add_stream = *add_stream_or_err;
 // If the "add_stream" is nullptr, then the data was cached. If it is
 // valid, then if we call the add_stream function with a task it will
 // cause the file to get generated, but we only want to check if the data
@@ -117,10 +119,10 @@
 // provided, but we won't take ownership of the memory buffer as we just
 // want to write the data.
 if (add_stream) {
-  Expected> file_or_err =
+  llvm::Expected> file_or_err =
   add_stream(task);
   if (file_or_err) {
-CachedFileStream *cfs = file_or_err->get();
+llvm::CachedFileStream *cfs = file_or_err->get();
 cfs->OS->write((const char *)data.data(), data.size());
 return true;
   } else {
@@ -219,7 +221,7 @@
   return true;
 }
 
-bool CacheSignature::Decode(const DataExtractor &data,
+bool CacheSignature::Decode(const lldb_private::DataExtractor &data,
 lldb::offset_t *offset_ptr) {
   Clear();
   while (uint8_t sig_encoding = data.GetU8(offset_ptr)) {
@@ -284,7 +286,7 @@
   return true;
 }
 
-bool StringTableReader::Decode(const DataExtractor &data,
+bool StringTableReader::Decode

[Lldb-commits] [lldb] 71e2788 - [lldb] Fix DataExtractor symbol conflict

2022-03-03 Thread Jonas Devlieghere via lldb-commits

Author: Emre Kultursay
Date: 2022-03-03T08:48:16-08:00
New Revision: 71e278805a7232826f27be081d036ca3f1c85d65

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

LOG: [lldb] Fix DataExtractor symbol conflict

There are two DataExtractors in scope: one from the llvm namespace and
one from the lldb_private namespace. Some Microsoft Visual C++ compilers
(I tested with MSVC 14.23 specifically) cannot handle this situation,
and generate ambiguous symbol errors. This change fixes this compile
error.

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

Added: 


Modified: 
lldb/source/Core/DataFileCache.cpp

Removed: 




diff  --git a/lldb/source/Core/DataFileCache.cpp 
b/lldb/source/Core/DataFileCache.cpp
index 84f787e6184e1..f9b632f34e417 100644
--- a/lldb/source/Core/DataFileCache.cpp
+++ b/lldb/source/Core/DataFileCache.cpp
@@ -17,17 +17,16 @@
 #include "llvm/Support/CachePruning.h"
 #include "llvm/Support/MemoryBuffer.h"
 
-using namespace llvm;
 using namespace lldb_private;
 
-DataFileCache::DataFileCache(StringRef path) {
+DataFileCache::DataFileCache(llvm::StringRef path) {
   m_cache_dir.SetPath(path);
 
   // Prune the cache based off of the LLDB settings each time we create a cache
   // object.
   ModuleListProperties &properties =
   ModuleList::GetGlobalModuleListProperties();
-  CachePruningPolicy policy;
+  llvm::CachePruningPolicy policy;
   // Only scan once an hour. If we have lots of debug sessions we don't want
   // to scan this directory too often. A timestamp file is written to the
   // directory to ensure 
diff erent processes don't scan the directory too often.
@@ -52,7 +51,7 @@ DataFileCache::DataFileCache(StringRef path) {
 if (m_take_ownership)
   m_mem_buff_up = std::move(m);
   };
-  Expected cache_or_err =
+  llvm::Expected cache_or_err =
   llvm::localCache("LLDBModuleCache", "lldb-module", path, add_buffer);
   if (cache_or_err)
 m_cache_callback = std::move(*cache_or_err);
@@ -64,7 +63,7 @@ DataFileCache::DataFileCache(StringRef path) {
 }
 
 std::unique_ptr
-DataFileCache::GetCachedData(StringRef key) {
+DataFileCache::GetCachedData(llvm::StringRef key) {
   std::lock_guard guard(m_mutex);
 
   const unsigned task = 1;
@@ -73,13 +72,14 @@ DataFileCache::GetCachedData(StringRef key) {
   // call the "add_buffer" lambda function from the constructor which will in
   // turn take ownership of the member buffer that is passed to the callback 
and
   // put it into a member variable.
-  Expected add_stream_or_err = m_cache_callback(task, key);
+  llvm::Expected add_stream_or_err =
+  m_cache_callback(task, key);
   m_take_ownership = false;
   // At this point we either already called the "add_buffer" lambda with
   // the data or we haven't. We can tell if we got the cached data by checking
   // the add_stream function pointer value below.
   if (add_stream_or_err) {
-AddStreamFn &add_stream = *add_stream_or_err;
+llvm::AddStreamFn &add_stream = *add_stream_or_err;
 // If the "add_stream" is nullptr, then the data was cached and we already
 // called the "add_buffer" lambda. If it is valid, then if we were to call
 // the add_stream function it would cause a cache file to get generated
@@ -97,18 +97,20 @@ DataFileCache::GetCachedData(StringRef key) {
   return std::unique_ptr();
 }
 
-bool DataFileCache::SetCachedData(StringRef key, llvm::ArrayRef data) 
{
+bool DataFileCache::SetCachedData(llvm::StringRef key,
+  llvm::ArrayRef data) {
   std::lock_guard guard(m_mutex);
   const unsigned task = 2;
   // If we call this function and the data is cached, it will call the
   // add_buffer lambda function from the constructor which will ignore the
   // data.
-  Expected add_stream_or_err = m_cache_callback(task, key);
+  llvm::Expected add_stream_or_err =
+  m_cache_callback(task, key);
   // If we reach this code then we either already called the callback with
   // the data or we haven't. We can tell if we had the cached data by checking
   // the CacheAddStream function pointer value below.
   if (add_stream_or_err) {
-AddStreamFn &add_stream = *add_stream_or_err;
+llvm::AddStreamFn &add_stream = *add_stream_or_err;
 // If the "add_stream" is nullptr, then the data was cached. If it is
 // valid, then if we call the add_stream function with a task it will
 // cause the file to get generated, but we only want to check if the data
@@ -117,10 +119,10 @@ bool DataFileCache::SetCachedData(StringRef key, 
llvm::ArrayRef data) {
 // provided, but we won't take ownership of the memory buffer as we just
 // want to write the data.
 if (add_stream) {
-  Expected> file_or_err =
+  llvm::Expected> file_or_err =
   add_stream(task);

[Lldb-commits] [PATCH] D120892: [lldb] Warn when we fail to find dwo/dwp files

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

LGTM.

FWIW I'm planning some changes to the error reporting "soonish". The gist is 
using error/warning events which Xcode (or VSCode) can subscribe to. I'll send 
out an RFC with more details as I get closer to working on this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120892

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


Re: [Lldb-commits] [lldb] 6b3b3ef - [lldb] Correct case in description of breakpoint --on-catch/throw

2022-03-03 Thread Jim Ingham via lldb-commits
This was on purpose - I do it whenever the short option isn't the first letter 
of the long option as an aid to memorization.  Some people catch this and it 
helps, others correct the spelling in checkins without noticing what they are 
for.

I thought it was helpful, but maybe it only annoys people who see the oddity 
w/o noticing what it is for, in which case we should remove them wholesale 
rather than one by one.

Jim


> On Mar 3, 2022, at 2:06 AM, David Spickett via lldb-commits 
>  wrote:
> 
> 
> Author: David Spickett
> Date: 2022-03-03T10:06:11Z
> New Revision: 6b3b3ef344504334f43afe76c805d2e6e7b587e9
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/6b3b3ef344504334f43afe76c805d2e6e7b587e9
> DIFF: 
> https://github.com/llvm/llvm-project/commit/6b3b3ef344504334f43afe76c805d2e6e7b587e9.diff
> 
> LOG: [lldb] Correct case in description of breakpoint --on-catch/throw
> 
> Somehow we ended up with catcH/throW.
> 
> Added: 
> 
> 
> Modified: 
>lldb/source/Commands/Options.td
>lldb/test/API/functionalities/completion/TestCompletion.py
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/source/Commands/Options.td 
> b/lldb/source/Commands/Options.td
> index a1548cb6b443f..470f4bc471c3e 100644
> --- a/lldb/source/Commands/Options.td
> +++ b/lldb/source/Commands/Options.td
> @@ -176,9 +176,9 @@ let Command = "breakpoint set" in {
> Desc<"Set the breakpoint on exceptions thrown by the specified language "
> "(without options, on throw but not catch.)">;
>   def breakpoint_set_on_throw : Option<"on-throw", "w">, Group<10>,
> -Arg<"Boolean">, Desc<"Set the breakpoint on exception throW.">;
> +Arg<"Boolean">, Desc<"Set the breakpoint on exception throw.">;
>   def breakpoint_set_on_catch : Option<"on-catch", "h">, Group<10>,
> -Arg<"Boolean">, Desc<"Set the breakpoint on exception catcH.">;
> +Arg<"Boolean">, Desc<"Set the breakpoint on exception catch.">;
>   def breakpoint_set_language : Option<"language", "L">, GroupRange<3, 8>,
> Arg<"Language">,
> Desc<"Specifies the Language to use when interpreting the breakpoint's "
> 
> diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
> b/lldb/test/API/functionalities/completion/TestCompletion.py
> index ed901890f7dfe..e858e38035c86 100644
> --- a/lldb/test/API/functionalities/completion/TestCompletion.py
> +++ b/lldb/test/API/functionalities/completion/TestCompletion.py
> @@ -539,20 +539,20 @@ def test_completion_description_command_options(self):
> """Test descriptions of command options"""
> # Short options
> self.check_completion_with_desc("breakpoint set -", [
> -["-h", "Set the breakpoint on exception catcH."],
> -["-w", "Set the breakpoint on exception throW."]
> +["-h", "Set the breakpoint on exception catch."],
> +["-w", "Set the breakpoint on exception throw."]
> ])
> 
> # Long options.
> self.check_completion_with_desc("breakpoint set --", [
> -["--on-catch", "Set the breakpoint on exception catcH."],
> -["--on-throw", "Set the breakpoint on exception throW."]
> +["--on-catch", "Set the breakpoint on exception catch."],
> +["--on-throw", "Set the breakpoint on exception throw."]
> ])
> 
> # Ambiguous long options.
> self.check_completion_with_desc("breakpoint set --on-", [
> -["--on-catch", "Set the breakpoint on exception catcH."],
> -["--on-throw", "Set the breakpoint on exception throW."]
> +["--on-catch", "Set the breakpoint on exception catch."],
> +["--on-throw", "Set the breakpoint on exception throw."]
> ])
> 
> # Unknown long option.
> 
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [lldb] 742fb13 - Revert "[lldb] Correct case in description of breakpoint --on-catch/throw"

2022-03-03 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2022-03-03T17:20:31Z
New Revision: 742fb134753b62f827677be92c48699d02f7f458

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

LOG: Revert "[lldb] Correct case in description of breakpoint --on-catch/throw"

This reverts commit 6b3b3ef344504334f43afe76c805d2e6e7b587e9.

Jim Ingham informed me that the upper case is a hint to the option
name, like you might see in a menu to show you what the shortcut is.

Added: 


Modified: 
lldb/source/Commands/Options.td
lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 




diff  --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 470f4bc471c3e..a1548cb6b443f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -176,9 +176,9 @@ let Command = "breakpoint set" in {
 Desc<"Set the breakpoint on exceptions thrown by the specified language "
 "(without options, on throw but not catch.)">;
   def breakpoint_set_on_throw : Option<"on-throw", "w">, Group<10>,
-Arg<"Boolean">, Desc<"Set the breakpoint on exception throw.">;
+Arg<"Boolean">, Desc<"Set the breakpoint on exception throW.">;
   def breakpoint_set_on_catch : Option<"on-catch", "h">, Group<10>,
-Arg<"Boolean">, Desc<"Set the breakpoint on exception catch.">;
+Arg<"Boolean">, Desc<"Set the breakpoint on exception catcH.">;
   def breakpoint_set_language : Option<"language", "L">, GroupRange<3, 8>,
 Arg<"Language">,
 Desc<"Specifies the Language to use when interpreting the breakpoint's "

diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index e858e38035c86..ed901890f7dfe 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -539,20 +539,20 @@ def test_completion_description_command_options(self):
 """Test descriptions of command options"""
 # Short options
 self.check_completion_with_desc("breakpoint set -", [
-["-h", "Set the breakpoint on exception catch."],
-["-w", "Set the breakpoint on exception throw."]
+["-h", "Set the breakpoint on exception catcH."],
+["-w", "Set the breakpoint on exception throW."]
 ])
 
 # Long options.
 self.check_completion_with_desc("breakpoint set --", [
-["--on-catch", "Set the breakpoint on exception catch."],
-["--on-throw", "Set the breakpoint on exception throw."]
+["--on-catch", "Set the breakpoint on exception catcH."],
+["--on-throw", "Set the breakpoint on exception throW."]
 ])
 
 # Ambiguous long options.
 self.check_completion_with_desc("breakpoint set --on-", [
-["--on-catch", "Set the breakpoint on exception catch."],
-["--on-throw", "Set the breakpoint on exception throw."]
+["--on-catch", "Set the breakpoint on exception catcH."],
+["--on-throw", "Set the breakpoint on exception throW."]
 ])
 
 # Unknown long option.



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


Re: [Lldb-commits] [lldb] 6b3b3ef - [lldb] Correct case in description of breakpoint --on-catch/throw

2022-03-03 Thread David Spickett via lldb-commits
My apologies. I see now, like a menu where it highlights the shortcut character.

Reverted. First time I've noticed this, the hint seems more useful
than the minor confusion at the case.

On Thu, 3 Mar 2022 at 17:14, Jim Ingham  wrote:
>
> This was on purpose - I do it whenever the short option isn't the first 
> letter of the long option as an aid to memorization.  Some people catch this 
> and it helps, others correct the spelling in checkins without noticing what 
> they are for.
>
> I thought it was helpful, but maybe it only annoys people who see the oddity 
> w/o noticing what it is for, in which case we should remove them wholesale 
> rather than one by one.
>
> Jim
>
>
> > On Mar 3, 2022, at 2:06 AM, David Spickett via lldb-commits 
> >  wrote:
> >
> >
> > Author: David Spickett
> > Date: 2022-03-03T10:06:11Z
> > New Revision: 6b3b3ef344504334f43afe76c805d2e6e7b587e9
> >
> > URL: 
> > https://github.com/llvm/llvm-project/commit/6b3b3ef344504334f43afe76c805d2e6e7b587e9
> > DIFF: 
> > https://github.com/llvm/llvm-project/commit/6b3b3ef344504334f43afe76c805d2e6e7b587e9.diff
> >
> > LOG: [lldb] Correct case in description of breakpoint --on-catch/throw
> >
> > Somehow we ended up with catcH/throW.
> >
> > Added:
> >
> >
> > Modified:
> >lldb/source/Commands/Options.td
> >lldb/test/API/functionalities/completion/TestCompletion.py
> >
> > Removed:
> >
> >
> >
> > 
> > diff  --git a/lldb/source/Commands/Options.td 
> > b/lldb/source/Commands/Options.td
> > index a1548cb6b443f..470f4bc471c3e 100644
> > --- a/lldb/source/Commands/Options.td
> > +++ b/lldb/source/Commands/Options.td
> > @@ -176,9 +176,9 @@ let Command = "breakpoint set" in {
> > Desc<"Set the breakpoint on exceptions thrown by the specified language 
> > "
> > "(without options, on throw but not catch.)">;
> >   def breakpoint_set_on_throw : Option<"on-throw", "w">, Group<10>,
> > -Arg<"Boolean">, Desc<"Set the breakpoint on exception throW.">;
> > +Arg<"Boolean">, Desc<"Set the breakpoint on exception throw.">;
> >   def breakpoint_set_on_catch : Option<"on-catch", "h">, Group<10>,
> > -Arg<"Boolean">, Desc<"Set the breakpoint on exception catcH.">;
> > +Arg<"Boolean">, Desc<"Set the breakpoint on exception catch.">;
> >   def breakpoint_set_language : Option<"language", "L">, GroupRange<3, 8>,
> > Arg<"Language">,
> > Desc<"Specifies the Language to use when interpreting the breakpoint's "
> >
> > diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
> > b/lldb/test/API/functionalities/completion/TestCompletion.py
> > index ed901890f7dfe..e858e38035c86 100644
> > --- a/lldb/test/API/functionalities/completion/TestCompletion.py
> > +++ b/lldb/test/API/functionalities/completion/TestCompletion.py
> > @@ -539,20 +539,20 @@ def test_completion_description_command_options(self):
> > """Test descriptions of command options"""
> > # Short options
> > self.check_completion_with_desc("breakpoint set -", [
> > -["-h", "Set the breakpoint on exception catcH."],
> > -["-w", "Set the breakpoint on exception throW."]
> > +["-h", "Set the breakpoint on exception catch."],
> > +["-w", "Set the breakpoint on exception throw."]
> > ])
> >
> > # Long options.
> > self.check_completion_with_desc("breakpoint set --", [
> > -["--on-catch", "Set the breakpoint on exception catcH."],
> > -["--on-throw", "Set the breakpoint on exception throW."]
> > +["--on-catch", "Set the breakpoint on exception catch."],
> > +["--on-throw", "Set the breakpoint on exception throw."]
> > ])
> >
> > # Ambiguous long options.
> > self.check_completion_with_desc("breakpoint set --on-", [
> > -["--on-catch", "Set the breakpoint on exception catcH."],
> > -["--on-throw", "Set the breakpoint on exception throW."]
> > +["--on-catch", "Set the breakpoint on exception catch."],
> > +["--on-throw", "Set the breakpoint on exception throw."]
> > ])
> >
> > # Unknown long option.
> >
> >
> >
> > ___
> > lldb-commits mailing list
> > lldb-commits@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D120836: [LLDB] Remove cases of using namespace llvm:: from header file

2022-03-03 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 412751.
shafik marked 6 inline comments as done.
shafik added a comment.

Moved to `using namespace lldb_private::dwarf` everywhere since the consensus 
is that being verbose is preferred.


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

https://reviews.llvm.org/D120836

Files:
  lldb/include/lldb/Core/dwarf.h
  lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Symbol/DWARFCallFrameInfo.cpp
  lldb/source/Symbol/PostfixExpression.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -39,6 +39,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::dwarf;
 
 class SymbolFileDWARFTests : public testing::Test {
   SubsystemRAII Evaluate(llvm::ArrayRef expr,
lldb::ModuleSP module_sp = {},
Index: lldb/source/Symbol/PostfixExpression.cpp
===
--- lldb/source/Symbol/PostfixExpression.cpp
+++ lldb/source/Symbol/PostfixExpression.cpp
@@ -18,6 +18,7 @@
 
 using namespace lldb_private;
 using namespace lldb_private::postfix;
+using namespace lldb_private::dwarf;
 
 static llvm::Optional
 GetBinaryOpType(llvm::StringRef token) {
Index: lldb/source/Symbol/DWARFCallFrameInfo.cpp
===
--- lldb/source/Symbol/DWARFCallFrameInfo.cpp
+++ lldb/source/Symbol/DWARFCallFrameInfo.cpp
@@ -24,6 +24,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::dwarf;
 
 // GetDwarfEHPtr
 //
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -80,6 +80,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::dwarf;
 using namespace clang;
 using llvm::StringSwitch;
 
Index: lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
@@ -25,6 +25,7 @@
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::npdb;
+using namespace lldb_private::dwarf;
 using namespace llvm::pdb;
 
 static std::unique_ptr
Index: lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
@@ -10,6 +10,8 @@
 
 #include "lldb/Core/Declaration.h"
 
+using namespace lldb_private::dwarf;
+
 bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die,
   const lldb_private::Declaration &decl,
   const int32_t byte_size,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -96,6 +96,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::dwarf;
 
 LLDB_PLUGIN_DEFINE(SymbolFileDWARF)
 
Index: lldb/source/Plugins/SymbolFile/DWARF

[Lldb-commits] [PATCH] D120917: Make the breakpoint log channel more useful

2022-03-03 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added reviewers: labath, JDevlieghere.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

I was trying to figure out a problem with how a client was seeing the 
breakpoint events, and was impeded by two things:

1. The BreakpointEventData::Dump did nothing
2. In order to see the breakpoint events you had to turn on the event log 
stream, and that's really noisy.

I fixed (1) straightforwardly by printing the breakpoint ID and event type.  
More than that is probably overkill

I fixed (2) by adding a backstop in the "event" log channel printing where the 
EventData for the event can provide a Log channel.  Then I made the 
BreakpointEventData return the breakpoint log (if it's on of course), so you 
can see breakpoint event logging & break logging but not all the other event 
logging.

I didn't go through and make the other EventData subclasses implement this 
method.  It's not guaranteed that having the event data come out along with the 
regular log traffic is helpful rather than noisy.  For the breakpoints it is 
clearly helpful since there aren't that many events sent by the system.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120917

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Utility/Event.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Utility/Broadcaster.cpp

Index: lldb/source/Utility/Broadcaster.cpp
===
--- lldb/source/Utility/Broadcaster.cpp
+++ lldb/source/Utility/Broadcaster.cpp
@@ -208,7 +208,11 @@
   hijacking_listener_sp.reset();
   }
 
-  if (Log *log = GetLog(LLDBLog::Events)) {
+  Log *log = GetLog(LLDBLog::Events);
+  if (!log && event_sp->GetData())
+log = event_sp->GetData()->GetLogChannel();
+
+  if (log) {
 StreamString event_description;
 event_sp->Dump(&event_description);
 LLDB_LOGF(log,
Index: lldb/source/Breakpoint/Breakpoint.cpp
===
--- lldb/source/Breakpoint/Breakpoint.cpp
+++ lldb/source/Breakpoint/Breakpoint.cpp
@@ -1010,6 +1010,28 @@
 delete data;
 }
 
+const char *Breakpoint::BreakpointEventTypeAsCString(BreakpointEventType type) {
+  switch (type) {
+case eBreakpointEventTypeInvalidType: return "invalid";
+case eBreakpointEventTypeAdded: return "breakpoint added";
+case eBreakpointEventTypeRemoved: return "breakpoint removed";
+case eBreakpointEventTypeLocationsAdded: return "locations added";
+case eBreakpointEventTypeLocationsRemoved: return "locations removed";
+case eBreakpointEventTypeLocationsResolved: return "locations resolved";
+case eBreakpointEventTypeEnabled: return "breakpoint enabled";
+case eBreakpointEventTypeDisabled: return "breakpoint disabled";
+case eBreakpointEventTypeCommandChanged: return "command changed";
+case eBreakpointEventTypeConditionChanged: return "condition changed";
+case eBreakpointEventTypeIgnoreChanged: return "ignore count changed";
+case eBreakpointEventTypeThreadChanged: return "thread changed";
+case eBreakpointEventTypeAutoContinueChanged: return "autocontinue changed";
+  };
+}
+
+Log *Breakpoint::BreakpointEventData::GetLogChannel() {
+  return GetLog(LLDBLog::Breakpoints);
+}
+
 Breakpoint::BreakpointEventData::BreakpointEventData(
 BreakpointEventType sub_type, const BreakpointSP &new_breakpoint_sp)
 : m_breakpoint_event(sub_type), m_new_breakpoint_sp(new_breakpoint_sp) {}
@@ -1025,7 +1047,7 @@
   return BreakpointEventData::GetFlavorString();
 }
 
-BreakpointSP &Breakpoint::BreakpointEventData::GetBreakpoint() {
+BreakpointSP Breakpoint::BreakpointEventData::GetBreakpoint() const {
   return m_new_breakpoint_sp;
 }
 
@@ -1034,7 +1056,14 @@
   return m_breakpoint_event;
 }
 
-void Breakpoint::BreakpointEventData::Dump(Stream *s) const {}
+void Breakpoint::BreakpointEventData::Dump(Stream *s) const {
+  if (!s)
+return;
+  BreakpointEventType event_type = GetBreakpointEventType();
+  break_id_t bkpt_id = GetBreakpoint()->GetID();
+  s->Format("bkpt: {0} type: {1}", bkpt_id,
+  BreakpointEventTypeAsCString(event_type));
+}
 
 const Breakpoint::BreakpointEventData *
 Breakpoint::BreakpointEventData::GetEventDataFromEvent(const Event *event) {
Index: lldb/include/lldb/Utility/Event.h
===
--- lldb/include/lldb/Utility/Event.h
+++ lldb/include/lldb/Utility/Event.h
@@ -42,7 +42,9 @@
   virtual ~EventData();
 
   virtual ConstString GetFlavor() const = 0;
-
+  
+  virtual Log *GetLogChannel() { return nullptr; }
+  
   virtual void Dump(Stream *s) const;
 
 private:
Index: lldb/include/lldb/Breakpoint/Breakpoint.h
===
--- lldb/include/lldb/Breakpoint/Breakpoint.h
+++ lldb/include/lldb/Breakpoint/Breakpoint

[Lldb-commits] [PATCH] D120917: Make the breakpoint log channel more useful

2022-03-03 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

For instance, one of the other EventData types might want the events too, but 
only when the verbose flag for their relevant log channel is on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120917

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


[Lldb-commits] [PATCH] D120919: Reverse the order of modules-loaded/unloaded & breakpoint-changed events

2022-03-03 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added reviewers: clayborg, JDevlieghere, labath.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Currently, when a new module is loaded/unloaded and it causes new breakpoint 
locations to be created or resolved, you get two events, an modules-loaded 
event and a breakpoint-changed event.  But they come out in the order:

breakpoint-changed
modules-loaded

which doesn't make much sense.  This patch reverses the order.

This should be uncontroversial, but I put the patch up to check that vscode or 
other clients haven't coded around this odd behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120919

Files:
  lldb/source/Target/Target.cpp


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1642,11 +1642,11 @@
 void Target::ModulesDidUnload(ModuleList &module_list, bool delete_locations) {
   if (m_valid && module_list.GetSize()) {
 UnloadModuleSections(module_list);
+BroadcastEvent(eBroadcastBitModulesUnloaded,
+   new TargetEventData(this->shared_from_this(), module_list));
 m_breakpoint_list.UpdateBreakpoints(module_list, false, delete_locations);
 m_internal_breakpoint_list.UpdateBreakpoints(module_list, false,
  delete_locations);
-BroadcastEvent(eBroadcastBitModulesUnloaded,
-   new TargetEventData(this->shared_from_this(), module_list));
   }
 }
 


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1642,11 +1642,11 @@
 void Target::ModulesDidUnload(ModuleList &module_list, bool delete_locations) {
   if (m_valid && module_list.GetSize()) {
 UnloadModuleSections(module_list);
+BroadcastEvent(eBroadcastBitModulesUnloaded,
+   new TargetEventData(this->shared_from_this(), module_list));
 m_breakpoint_list.UpdateBreakpoints(module_list, false, delete_locations);
 m_internal_breakpoint_list.UpdateBreakpoints(module_list, false,
  delete_locations);
-BroadcastEvent(eBroadcastBitModulesUnloaded,
-   new TargetEventData(this->shared_from_this(), module_list));
   }
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D120917: Make the breakpoint log channel more useful

2022-03-03 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/source/Utility/Broadcaster.cpp:211-215
+  Log *log = GetLog(LLDBLog::Events);
+  if (!log && event_sp->GetData())
+log = event_sp->GetData()->GetLogChannel();
+
+  if (log) {

should this log to both channels? I find it slightly unexpected that an event 
wouldn't be printed to the events channel.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120917

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


[Lldb-commits] [PATCH] D120917: Make the breakpoint log channel more useful

2022-03-03 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/source/Breakpoint/Breakpoint.cpp:1063-1065
+  break_id_t bkpt_id = GetBreakpoint()->GetID();
+  s->Format("bkpt: {0} type: {1}", bkpt_id,
+  BreakpointEventTypeAsCString(event_type));

For the location event types, should the location IDs be included?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120917

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


[Lldb-commits] [PATCH] D120919: Reverse the order of modules-loaded/unloaded & breakpoint-changed events

2022-03-03 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.

lldb-vscode will be just fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120919

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


[Lldb-commits] [lldb] ae869d4 - [LLDB] Remove cases of using namespace llvm:: from header file

2022-03-03 Thread Shafik Yaghmour via lldb-commits

Author: Shafik Yaghmour
Date: 2022-03-03T10:39:06-08:00
New Revision: ae869d448499327a2e6435fafb0ac6ed0f205e66

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

LOG: [LLDB] Remove cases of using namespace llvm:: from header file

We have using namespace llvm::dwarf in dwarf.h header globally. Replacing that
with a using namespace within lldb_private::dwarf and moving to a
using namespace lldb_private::dwarf in .cpp files and fully qualified names
in the few header files.

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

Added: 


Modified: 
lldb/include/lldb/Core/dwarf.h
lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Symbol/DWARFCallFrameInfo.cpp
lldb/source/Symbol/PostfixExpression.cpp
lldb/unittests/Expression/DWARFExpressionTest.cpp
lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h
index 968418e71c2f3..60fbdec40beed 100644
--- a/lldb/include/lldb/Core/dwarf.h
+++ b/lldb/include/lldb/Core/dwarf.h
@@ -15,8 +15,11 @@
 // Get the DWARF constant definitions from llvm
 #include "llvm/BinaryFormat/Dwarf.h"
 
-// and stuff them in our default namespace
-using namespace llvm::dwarf;
+namespace lldb_private {
+namespace dwarf {
+  using namespace llvm::dwarf;
+}
+}
 
 typedef uint32_t dw_uleb128_t;
 typedef int32_t dw_sleb128_t;

diff  --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h 
b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
index 43baf4dd39a1d..199d23eff9b60 100644
--- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
+++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
@@ -106,7 +106,8 @@ class DWARFCallFrameInfo {
 CIE(dw_offset_t offset)
 : cie_offset(offset), version(-1), code_align(0), data_align(0),
   return_addr_reg_num(LLDB_INVALID_REGNUM), inst_offset(0),
-  inst_length(0), ptr_encoding(0), lsda_addr_encoding(DW_EH_PE_omit),
+  inst_length(0), ptr_encoding(0),
+  lsda_addr_encoding(llvm::dwarf::DW_EH_PE_omit),
   personality_loc(LLDB_INVALID_ADDRESS) {}
   };
 

diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 572c3488311c7..7c99743b260ba 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -43,6 +43,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::dwarf;
 
 static lldb::addr_t
 ReadAddressFromDebugAddrSection(const DWARFUnit *dwarf_cu,

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index ec4057efbbc54..4877169b32132 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -16,6 +16,7 @@
 
 using namespace lldb_private;
 using namespace lldb;
+using namespace lldb_private::dwarf;
 
 std::unique_ptr AppleDWARFIndex::Create(
 Module &module, DWARFDataExtractor apple_names,

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 2daffecee58e9..07842ce01593f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -57,6 +57,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::dwarf;
 DWARFASTParserClang::DWARFASTParserClang(TypeSystemClang &ast)

[Lldb-commits] [PATCH] D120836: [LLDB] Remove cases of using namespace llvm:: from header file

2022-03-03 Thread Shafik Yaghmour via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae869d448499: [LLDB] Remove cases of using namespace llvm:: 
from header file (authored by shafik).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120836

Files:
  lldb/include/lldb/Core/dwarf.h
  lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Symbol/DWARFCallFrameInfo.cpp
  lldb/source/Symbol/PostfixExpression.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -39,6 +39,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::dwarf;
 
 class SymbolFileDWARFTests : public testing::Test {
   SubsystemRAII Evaluate(llvm::ArrayRef expr,
lldb::ModuleSP module_sp = {},
Index: lldb/source/Symbol/PostfixExpression.cpp
===
--- lldb/source/Symbol/PostfixExpression.cpp
+++ lldb/source/Symbol/PostfixExpression.cpp
@@ -18,6 +18,7 @@
 
 using namespace lldb_private;
 using namespace lldb_private::postfix;
+using namespace lldb_private::dwarf;
 
 static llvm::Optional
 GetBinaryOpType(llvm::StringRef token) {
Index: lldb/source/Symbol/DWARFCallFrameInfo.cpp
===
--- lldb/source/Symbol/DWARFCallFrameInfo.cpp
+++ lldb/source/Symbol/DWARFCallFrameInfo.cpp
@@ -24,6 +24,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::dwarf;
 
 // GetDwarfEHPtr
 //
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -80,6 +80,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::dwarf;
 using namespace clang;
 using llvm::StringSwitch;
 
Index: lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
@@ -25,6 +25,7 @@
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::npdb;
+using namespace lldb_private::dwarf;
 using namespace llvm::pdb;
 
 static std::unique_ptr
Index: lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
@@ -10,6 +10,8 @@
 
 #include "lldb/Core/Declaration.h"
 
+using namespace lldb_private::dwarf;
+
 bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die,
   const lldb_private::Declaration &decl,
   const int32_t byte_size,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -96,6 +96,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace lldb_private::dwarf;
 
 LLDB_PLUGIN_DEFINE(SymbolFileDWARF)
 
Index: l

[Lldb-commits] [PATCH] D120892: [lldb] Warn when we fail to find dwo/dwp files

2022-03-03 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 412774.
labath added a comment.

This code can be invoked concurrently (during indexing). Use atomic test-and-set
to ensure correctness.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120892

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp


Index: lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang --target=x86_64-pc-linux -g -gsplit-dwarf -c %s -o %t.o
+// RUN: rm %t.dwo
+// RUN: %lldb %t.o -o "br set -n main" -o exit 2>&1 | FileCheck %s
+
+// CHECK: warning: {{.*}} unable to locate separate debug file (dwo, dwp). 
Debugging will be degraded.
+
+int main() { return 47; }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -560,6 +560,7 @@
   /// address in the module.
   lldb::addr_t m_first_code_address = LLDB_INVALID_ADDRESS;
   lldb_private::StatsDuration m_parse_time;
+  std::atomic_flag m_dwo_warning_issued = ATOMIC_FLAG_INIT;
 };
 
 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARF_H
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1745,8 +1745,14 @@
 dwo_file.AppendPathComponent(dwo_name);
   }
 
-  if (!FileSystem::Instance().Exists(dwo_file))
+  if (!FileSystem::Instance().Exists(dwo_file)) {
+if (m_dwo_warning_issued.test_and_set(std::memory_order_relaxed) == false) 
{
+  GetObjectFile()->GetModule()->ReportWarning(
+  "unable to locate separate debug file (dwo, dwp). Debugging will be "
+  "degraded.");
+}
 return nullptr;
+  }
 
   const lldb::offset_t file_offset = 0;
   DataBufferSP dwo_file_data_sp;


Index: lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/x86/dwo-not-found-warning.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang --target=x86_64-pc-linux -g -gsplit-dwarf -c %s -o %t.o
+// RUN: rm %t.dwo
+// RUN: %lldb %t.o -o "br set -n main" -o exit 2>&1 | FileCheck %s
+
+// CHECK: warning: {{.*}} unable to locate separate debug file (dwo, dwp). Debugging will be degraded.
+
+int main() { return 47; }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -560,6 +560,7 @@
   /// address in the module.
   lldb::addr_t m_first_code_address = LLDB_INVALID_ADDRESS;
   lldb_private::StatsDuration m_parse_time;
+  std::atomic_flag m_dwo_warning_issued = ATOMIC_FLAG_INIT;
 };
 
 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARF_H
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1745,8 +1745,14 @@
 dwo_file.AppendPathComponent(dwo_name);
   }
 
-  if (!FileSystem::Instance().Exists(dwo_file))
+  if (!FileSystem::Instance().Exists(dwo_file)) {
+if (m_dwo_warning_issued.test_and_set(std::memory_order_relaxed) == false) {
+  GetObjectFile()->GetModule()->ReportWarning(
+  "unable to locate separate debug file (dwo, dwp). Debugging will be "
+  "degraded.");
+}
 return nullptr;
+  }
 
   const lldb::offset_t file_offset = 0;
   DataBufferSP dwo_file_data_sp;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D120923: [lldb] Remove FileSystem::Initialize from VFS mapping

2022-03-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: bnbarham, mib, labath.
Herald added a project: All.
JDevlieghere requested review of this revision.

This patch removes the ability to instantiate the LLDB FileSystem class based 
on a VFS overlay. This also removes the "hack" where we cast the VFS to a 
RedirectingFileSystem to obtain the external path. You can still instantiate a 
FileSystem with a VFS, but with the caveat that operations that rely on the 
external path won't work.


https://reviews.llvm.org/D120923

Files:
  lldb/include/lldb/Host/FileSystem.h
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Initialization/SystemInitializerCommon.cpp

Index: lldb/source/Initialization/SystemInitializerCommon.cpp
===
--- lldb/source/Initialization/SystemInitializerCommon.cpp
+++ lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -43,36 +43,6 @@
 /// Initialize the FileSystem based on the current reproducer mode.
 static llvm::Error InitializeFileSystem() {
   auto &r = repro::Reproducer::Instance();
-  if (repro::Loader *loader = r.GetLoader()) {
-FileSpec vfs_mapping = loader->GetFile();
-if (vfs_mapping) {
-  if (llvm::Error e = FileSystem::Initialize(vfs_mapping))
-return e;
-} else {
-  FileSystem::Initialize();
-}
-
-// Set the current working directory form the reproducer.
-llvm::Expected working_dir =
-repro::GetDirectoryFrom(loader);
-if (!working_dir)
-  return working_dir.takeError();
-if (std::error_code ec = FileSystem::Instance()
- .GetVirtualFileSystem()
- ->setCurrentWorkingDirectory(*working_dir)) {
-  return llvm::errorCodeToError(ec);
-}
-
-// Set the home directory from the reproducer.
-llvm::Expected home_dir =
-repro::GetDirectoryFrom(loader);
-if (!home_dir)
-  return home_dir.takeError();
-FileSystem::Instance().SetHomeDirectory(*home_dir);
-
-return llvm::Error::success();
-  }
-
   if (repro::Generator *g = r.GetGenerator()) {
 repro::VersionProvider &vp = g->GetOrCreate();
 vp.SetVersion(lldb_private::GetVersion());
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -1305,15 +1305,12 @@
 
   lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
 
-  // From now on we'll deal with the external (devirtualized) path.
-  auto exe_path = fs.GetExternalPath(exe_spec);
-  if (!exe_path)
-return Status(exe_path.getError());
+  auto exe_path = exe_spec.GetPath();
 
   if (ShouldLaunchUsingXPC(launch_info))
-error = LaunchProcessXPC(exe_path->c_str(), launch_info, pid);
+error = LaunchProcessXPC(exe_path.c_str(), launch_info, pid);
   else
-error = LaunchProcessPosixSpawn(exe_path->c_str(), launch_info, pid);
+error = LaunchProcessPosixSpawn(exe_path.c_str(), launch_info, pid);
 
   if (pid != LLDB_INVALID_PROCESS_ID) {
 // If all went well, then set the process ID into the launch info
Index: lldb/source/Host/common/FileSystem.cpp
===
--- lldb/source/Host/common/FileSystem.cpp
+++ lldb/source/Host/common/FileSystem.cpp
@@ -54,22 +54,6 @@
   InstanceImpl().emplace(collector);
 }
 
-llvm::Error FileSystem::Initialize(const FileSpec &mapping) {
-  lldbassert(!InstanceImpl() && "Already initialized.");
-
-  llvm::ErrorOr> buffer =
-  llvm::vfs::getRealFileSystem()->getBufferForFile(mapping.GetPath());
-
-  if (!buffer)
-return llvm::errorCodeToError(buffer.getError());
-
-  InstanceImpl().emplace(llvm::vfs::getVFSFromYAML(std::move(buffer.get()),
-   nullptr, mapping.GetPath()),
- true);
-
-  return llvm::Error::success();
-}
-
 void FileSystem::Initialize(IntrusiveRefCntPtr fs) {
   lldbassert(!InstanceImpl() && "Already initialized.");
   InstanceImpl().emplace(fs);
@@ -300,21 +284,16 @@
   Collect(path);
 
   const bool is_volatile = !IsLocal(path);
-  const ErrorOr external_path = GetExternalPath(path);
-
-  if (!external_path)
-return nullptr;
-
   std::unique_ptr buffer;
   if (size == 0) {
 auto buffer_or_error =
-llvm::WritableMemoryBuffer::getFile(*external_path, is_volatile);
+llvm::WritableMemoryBuffer::getFile(path, is_volatile);
 if (!buffer_or_error)
   return nullptr;
 buffer = std::move(*buffer_or_error);
   } else {
 auto buffer_or_error = llvm::WritableMemoryBuffer::getFileSlice(
-*external_path, size, offset, is_volatile);
+path, size, offset, is_volatile);
 if (!buffer_or_error)
   return nullptr;
 buffer = std::move(*buffer_or_error);
@@ -457,12 +436,10 @@
   const mode_t open_mode =
   (open_flags 

[Lldb-commits] [PATCH] D120892: [lldb] Warn when we fail to find dwo/dwp files

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

Might a `llvm::once_flag` + `llvm::call_once` be simpler?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120892

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


[Lldb-commits] [PATCH] D120917: Make the breakpoint log channel more useful

2022-03-03 Thread Jim Ingham via Phabricator via lldb-commits
jingham added inline comments.



Comment at: lldb/source/Breakpoint/Breakpoint.cpp:1063-1065
+  break_id_t bkpt_id = GetBreakpoint()->GetID();
+  s->Format("bkpt: {0} type: {1}", bkpt_id,
+  BreakpointEventTypeAsCString(event_type));

kastiglione wrote:
> For the location event types, should the location IDs be included?
Could be, or the number changed, etc.  I didn't need that so I didn't add it.



Comment at: lldb/source/Utility/Broadcaster.cpp:211-215
+  Log *log = GetLog(LLDBLog::Events);
+  if (!log && event_sp->GetData())
+log = event_sp->GetData()->GetLogChannel();
+
+  if (log) {

kastiglione wrote:
> should this log to both channels? I find it slightly unexpected that an event 
> wouldn't be printed to the events channel.
If the events log category is on, then you will get a non-null log and log to 
the events Log.  You only get another log if Events is off.  And if the event 
data returns a Log in the lldb channel it won't matter anyway, in that case 
this is just a fancy way of doing LogIfAnyCategory...

The only slight oddity here is that if an EventData chose to provide a Log not 
in the lldb channel (e.g. the gdb-remote channel), then if you did:

log enable -f /tmp/remote-log.txt gdb-remote packets

the events would go to the remote-log.txt, but then if you did:

log enable lldb event

the event traces would stop going to that log file.

Since the main point of this change is to be able to log X-type events when the 
X log channel/category is on, but the Events log is NOT on, I don't think 
that's a real problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120917

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


[Lldb-commits] [PATCH] D120892: [lldb] Warn when we fail to find dwo/dwp files

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

In D120892#3357424 , @JDevlieghere 
wrote:

> FWIW I'm planning some changes to the error reporting "soonish". The gist is 
> using error/warning events which Xcode (or VSCode) can subscribe to. I'll 
> send out an RFC with more details as I get closer to working on this.

Sounds like a good idea.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120892

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


[Lldb-commits] [lldb] 59eb705 - [lldb] Remove FileSystem::Initialize from VFS mapping

2022-03-03 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-03-03T11:02:11-08:00
New Revision: 59eb70527741594fe3c92d0a1b6704ed45111437

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

LOG: [lldb] Remove FileSystem::Initialize from VFS mapping

This patch removes the ability to instantiate the LLDB FileSystem class
based on a VFS overlay. This also removes the "hack" where we cast the
VFS to a RedirectingFileSystem to obtain the external path. You can
still instantiate a FileSystem with a VFS, but with the caveat that
operations that rely on the external path won't work.

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

Added: 


Modified: 
lldb/include/lldb/Host/FileSystem.h
lldb/source/Host/common/FileSystem.cpp
lldb/source/Host/macosx/objcxx/Host.mm
lldb/source/Initialization/SystemInitializerCommon.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/FileSystem.h 
b/lldb/include/lldb/Host/FileSystem.h
index 9f863e8a9d7e2..50c48648fecda 100644
--- a/lldb/include/lldb/Host/FileSystem.h
+++ b/lldb/include/lldb/Host/FileSystem.h
@@ -33,11 +33,10 @@ class FileSystem {
 
   FileSystem() : m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr) {}
   FileSystem(std::shared_ptr collector)
-  : m_fs(llvm::vfs::getRealFileSystem()), 
m_collector(std::move(collector)),
-m_mapped(false) {}
-  FileSystem(llvm::IntrusiveRefCntPtr fs,
- bool mapped = false)
-  : m_fs(std::move(fs)), m_collector(nullptr), m_mapped(mapped) {}
+  : m_fs(llvm::vfs::getRealFileSystem()),
+m_collector(std::move(collector)) {}
+  FileSystem(llvm::IntrusiveRefCntPtr fs)
+  : m_fs(std::move(fs)), m_collector(nullptr) {}
 
   FileSystem(const FileSystem &fs) = delete;
   FileSystem &operator=(const FileSystem &fs) = delete;
@@ -46,7 +45,6 @@ class FileSystem {
 
   static void Initialize();
   static void Initialize(std::shared_ptr collector);
-  static llvm::Error Initialize(const FileSpec &mapping);
   static void Initialize(llvm::IntrusiveRefCntPtr fs);
   static void Terminate();
 
@@ -189,9 +187,6 @@ class FileSystem {
   std::error_code GetRealPath(const llvm::Twine &path,
   llvm::SmallVectorImpl &output) const;
 
-  llvm::ErrorOr GetExternalPath(const llvm::Twine &path);
-  llvm::ErrorOr GetExternalPath(const FileSpec &file_spec);
-
   llvm::IntrusiveRefCntPtr GetVirtualFileSystem() {
 return m_fs;
   }
@@ -206,7 +201,6 @@ class FileSystem {
   llvm::IntrusiveRefCntPtr m_fs;
   std::shared_ptr m_collector;
   std::string m_home_directory;
-  bool m_mapped = false;
 };
 } // namespace lldb_private
 

diff  --git a/lldb/source/Host/common/FileSystem.cpp 
b/lldb/source/Host/common/FileSystem.cpp
index 26a98fa0a4ec4..4a8cc3a21ea43 100644
--- a/lldb/source/Host/common/FileSystem.cpp
+++ b/lldb/source/Host/common/FileSystem.cpp
@@ -54,22 +54,6 @@ void 
FileSystem::Initialize(std::shared_ptr collector) {
   InstanceImpl().emplace(collector);
 }
 
-llvm::Error FileSystem::Initialize(const FileSpec &mapping) {
-  lldbassert(!InstanceImpl() && "Already initialized.");
-
-  llvm::ErrorOr> buffer =
-  llvm::vfs::getRealFileSystem()->getBufferForFile(mapping.GetPath());
-
-  if (!buffer)
-return llvm::errorCodeToError(buffer.getError());
-
-  InstanceImpl().emplace(llvm::vfs::getVFSFromYAML(std::move(buffer.get()),
-   nullptr, mapping.GetPath()),
- true);
-
-  return llvm::Error::success();
-}
-
 void FileSystem::Initialize(IntrusiveRefCntPtr fs) {
   lldbassert(!InstanceImpl() && "Already initialized.");
   InstanceImpl().emplace(fs);
@@ -300,21 +284,16 @@ FileSystem::CreateDataBuffer(const llvm::Twine &path, 
uint64_t size,
   Collect(path);
 
   const bool is_volatile = !IsLocal(path);
-  const ErrorOr external_path = GetExternalPath(path);
-
-  if (!external_path)
-return nullptr;
-
   std::unique_ptr buffer;
   if (size == 0) {
 auto buffer_or_error =
-llvm::WritableMemoryBuffer::getFile(*external_path, is_volatile);
+llvm::WritableMemoryBuffer::getFile(path, is_volatile);
 if (!buffer_or_error)
   return nullptr;
 buffer = std::move(*buffer_or_error);
   } else {
 auto buffer_or_error = llvm::WritableMemoryBuffer::getFileSlice(
-*external_path, size, offset, is_volatile);
+path, size, offset, is_volatile);
 if (!buffer_or_error)
   return nullptr;
 buffer = std::move(*buffer_or_error);
@@ -457,12 +436,10 @@ Expected FileSystem::Open(const FileSpec 
&file_spec,
   const mode_t open_mode =
   (open_flags & O_CREAT) ? GetOpenMode(permissions) : 0;
 
-  auto path = GetExternalPath(file_spec);
-  if (!path)
-return errorCodeToError(path.getError());
+  auto path = file_spec.GetPath();
 

[Lldb-commits] [PATCH] D120923: [lldb] Remove FileSystem::Initialize from VFS mapping

2022-03-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG59eb70527741: [lldb] Remove FileSystem::Initialize from VFS 
mapping (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120923

Files:
  lldb/include/lldb/Host/FileSystem.h
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Initialization/SystemInitializerCommon.cpp

Index: lldb/source/Initialization/SystemInitializerCommon.cpp
===
--- lldb/source/Initialization/SystemInitializerCommon.cpp
+++ lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -43,36 +43,6 @@
 /// Initialize the FileSystem based on the current reproducer mode.
 static llvm::Error InitializeFileSystem() {
   auto &r = repro::Reproducer::Instance();
-  if (repro::Loader *loader = r.GetLoader()) {
-FileSpec vfs_mapping = loader->GetFile();
-if (vfs_mapping) {
-  if (llvm::Error e = FileSystem::Initialize(vfs_mapping))
-return e;
-} else {
-  FileSystem::Initialize();
-}
-
-// Set the current working directory form the reproducer.
-llvm::Expected working_dir =
-repro::GetDirectoryFrom(loader);
-if (!working_dir)
-  return working_dir.takeError();
-if (std::error_code ec = FileSystem::Instance()
- .GetVirtualFileSystem()
- ->setCurrentWorkingDirectory(*working_dir)) {
-  return llvm::errorCodeToError(ec);
-}
-
-// Set the home directory from the reproducer.
-llvm::Expected home_dir =
-repro::GetDirectoryFrom(loader);
-if (!home_dir)
-  return home_dir.takeError();
-FileSystem::Instance().SetHomeDirectory(*home_dir);
-
-return llvm::Error::success();
-  }
-
   if (repro::Generator *g = r.GetGenerator()) {
 repro::VersionProvider &vp = g->GetOrCreate();
 vp.SetVersion(lldb_private::GetVersion());
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -1305,15 +1305,12 @@
 
   lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
 
-  // From now on we'll deal with the external (devirtualized) path.
-  auto exe_path = fs.GetExternalPath(exe_spec);
-  if (!exe_path)
-return Status(exe_path.getError());
+  auto exe_path = exe_spec.GetPath();
 
   if (ShouldLaunchUsingXPC(launch_info))
-error = LaunchProcessXPC(exe_path->c_str(), launch_info, pid);
+error = LaunchProcessXPC(exe_path.c_str(), launch_info, pid);
   else
-error = LaunchProcessPosixSpawn(exe_path->c_str(), launch_info, pid);
+error = LaunchProcessPosixSpawn(exe_path.c_str(), launch_info, pid);
 
   if (pid != LLDB_INVALID_PROCESS_ID) {
 // If all went well, then set the process ID into the launch info
Index: lldb/source/Host/common/FileSystem.cpp
===
--- lldb/source/Host/common/FileSystem.cpp
+++ lldb/source/Host/common/FileSystem.cpp
@@ -54,22 +54,6 @@
   InstanceImpl().emplace(collector);
 }
 
-llvm::Error FileSystem::Initialize(const FileSpec &mapping) {
-  lldbassert(!InstanceImpl() && "Already initialized.");
-
-  llvm::ErrorOr> buffer =
-  llvm::vfs::getRealFileSystem()->getBufferForFile(mapping.GetPath());
-
-  if (!buffer)
-return llvm::errorCodeToError(buffer.getError());
-
-  InstanceImpl().emplace(llvm::vfs::getVFSFromYAML(std::move(buffer.get()),
-   nullptr, mapping.GetPath()),
- true);
-
-  return llvm::Error::success();
-}
-
 void FileSystem::Initialize(IntrusiveRefCntPtr fs) {
   lldbassert(!InstanceImpl() && "Already initialized.");
   InstanceImpl().emplace(fs);
@@ -300,21 +284,16 @@
   Collect(path);
 
   const bool is_volatile = !IsLocal(path);
-  const ErrorOr external_path = GetExternalPath(path);
-
-  if (!external_path)
-return nullptr;
-
   std::unique_ptr buffer;
   if (size == 0) {
 auto buffer_or_error =
-llvm::WritableMemoryBuffer::getFile(*external_path, is_volatile);
+llvm::WritableMemoryBuffer::getFile(path, is_volatile);
 if (!buffer_or_error)
   return nullptr;
 buffer = std::move(*buffer_or_error);
   } else {
 auto buffer_or_error = llvm::WritableMemoryBuffer::getFileSlice(
-*external_path, size, offset, is_volatile);
+path, size, offset, is_volatile);
 if (!buffer_or_error)
   return nullptr;
 buffer = std::move(*buffer_or_error);
@@ -457,12 +436,10 @@
   const mode_t open_mode =
   (open_flags & O_CREAT) ? GetOpenMode(permissions) : 0;
 
-  auto path = GetExternalPath(file_spec);
-  if (!path)
-return errorCodeToError(path.getError());
+  auto path = file_spec.GetPa

[Lldb-commits] [PATCH] D120917: Make the breakpoint log channel more useful

2022-03-03 Thread Dave Lee via Phabricator via lldb-commits
kastiglione accepted this revision.
kastiglione added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/Utility/Broadcaster.cpp:211-215
+  Log *log = GetLog(LLDBLog::Events);
+  if (!log && event_sp->GetData())
+log = event_sp->GetData()->GetLogChannel();
+
+  if (log) {

jingham wrote:
> kastiglione wrote:
> > should this log to both channels? I find it slightly unexpected that an 
> > event wouldn't be printed to the events channel.
> If the events log category is on, then you will get a non-null log and log to 
> the events Log.  You only get another log if Events is off.  And if the event 
> data returns a Log in the lldb channel it won't matter anyway, in that case 
> this is just a fancy way of doing LogIfAnyCategory...
> 
> The only slight oddity here is that if an EventData chose to provide a Log 
> not in the lldb channel (e.g. the gdb-remote channel), then if you did:
> 
> log enable -f /tmp/remote-log.txt gdb-remote packets
> 
> the events would go to the remote-log.txt, but then if you did:
> 
> log enable lldb event
> 
> the event traces would stop going to that log file.
> 
> Since the main point of this change is to be able to log X-type events when 
> the X log channel/category is on, but the Events log is NOT on, I don't think 
> that's a real problem.
thanks for correcting my misunderstanding


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120917

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


[Lldb-commits] [PATCH] D120917: Make the breakpoint log channel more useful

2022-03-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/include/lldb/Breakpoint/Breakpoint.h:84
   static ConstString GetEventIdentifier();
+  static const char *
+  BreakpointEventTypeAsCString(lldb::BreakpointEventType type);

Why not a llvm::StringRef?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120917

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


[Lldb-commits] [PATCH] D120892: [lldb] Warn when we fail to find dwo/dwp files

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

In D120892#3357780 , @JDevlieghere 
wrote:

> Might a `llvm::once_flag` + `llvm::call_once` be simpler?

Simpler... maybe.. depends how you look at it.

But, synchronization-wise, it is overkill. once_flag ensures that none of the 
racing threads can make progress until the action terminates. Most of the time, 
that's exactly what we want, but here the correct operation of the other 
threads is not affected by this action, so it is sufficient that the warning 
gets printed "eventually".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120892

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


[Lldb-commits] [PATCH] D120892: [lldb] Warn when we fail to find dwo/dwp files

2022-03-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

Cool, thanks for the explanation. Ship it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120892

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


[Lldb-commits] [lldb] 34eb15b - [lldb] Remove reproducer verifier and corresponding command

2022-03-03 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-03-03T11:21:00-08:00
New Revision: 34eb15b5c30601085acb0921f5410aafc0389232

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

LOG: [lldb] Remove reproducer verifier and corresponding command

This removes the reproducer verifier and the corresponding `reproducer
verify` subcommand.

Added: 


Modified: 
lldb/include/lldb/Utility/Reproducer.h
lldb/source/Commands/CommandObjectReproducer.cpp
lldb/source/Utility/Reproducer.cpp
lldb/test/Shell/Reproducer/TestDebugSymbols.test

Removed: 
lldb/test/Shell/Reproducer/TestVerify.test



diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
b/lldb/include/lldb/Utility/Reproducer.h
index 35043d6885111..672f82fcb9565 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -220,17 +220,6 @@ class Reproducer {
   mutable std::mutex m_mutex;
 };
 
-class Verifier {
-public:
-  Verifier(Loader *loader) : m_loader(loader) {}
-  void Verify(llvm::function_ref error_callback,
-  llvm::function_ref warning_callback,
-  llvm::function_ref note_callback) const;
-
-private:
-  Loader *m_loader;
-};
-
 struct ReplayOptions {
   bool verify = true;
   bool check_version = true;

diff  --git a/lldb/source/Commands/CommandObjectReproducer.cpp 
b/lldb/source/Commands/CommandObjectReproducer.cpp
index 7e0ea65e148ee..8b67b27c10f95 100644
--- a/lldb/source/Commands/CommandObjectReproducer.cpp
+++ b/lldb/source/Commands/CommandObjectReproducer.cpp
@@ -587,101 +587,6 @@ class CommandObjectReproducerDump : public 
CommandObjectParsed {
   CommandOptions m_options;
 };
 
-class CommandObjectReproducerVerify : public CommandObjectParsed {
-public:
-  CommandObjectReproducerVerify(CommandInterpreter &interpreter)
-  : CommandObjectParsed(interpreter, "reproducer verify",
-"Verify the contents of a reproducer. "
-"If no reproducer is specified during replay, it "
-"verifies the content of the current reproducer.",
-nullptr) {}
-
-  ~CommandObjectReproducerVerify() override = default;
-
-  Options *GetOptions() override { return &m_options; }
-
-  class CommandOptions : public Options {
-  public:
-CommandOptions() {}
-
-~CommandOptions() override = default;
-
-Status SetOptionValue(uint32_t option_idx, StringRef option_arg,
-  ExecutionContext *execution_context) override {
-  Status error;
-  const int short_option = m_getopt_table[option_idx].val;
-
-  switch (short_option) {
-  case 'f':
-file.SetFile(option_arg, FileSpec::Style::native);
-FileSystem::Instance().Resolve(file);
-break;
-  default:
-llvm_unreachable("Unimplemented option");
-  }
-
-  return error;
-}
-
-void OptionParsingStarting(ExecutionContext *execution_context) override {
-  file.Clear();
-}
-
-ArrayRef GetDefinitions() override {
-  return makeArrayRef(g_reproducer_verify_options);
-}
-
-FileSpec file;
-  };
-
-protected:
-  bool DoExecute(Args &command, CommandReturnObject &result) override {
-if (!command.empty()) {
-  result.AppendErrorWithFormat("'%s' takes no arguments",
-   m_cmd_name.c_str());
-  return false;
-}
-
-llvm::Optional loader_storage;
-Loader *loader =
-GetLoaderFromPathOrCurrent(loader_storage, result, m_options.file);
-if (!loader)
-  return false;
-
-bool errors = false;
-auto error_callback = [&](llvm::StringRef error) {
-  errors = true;
-  result.AppendError(error);
-};
-
-bool warnings = false;
-auto warning_callback = [&](llvm::StringRef warning) {
-  warnings = true;
-  result.AppendWarning(warning);
-};
-
-auto note_callback = [&](llvm::StringRef warning) {
-  result.AppendMessage(warning);
-};
-
-Verifier verifier(loader);
-verifier.Verify(error_callback, warning_callback, note_callback);
-
-if (warnings || errors) {
-  result.AppendMessage("reproducer verification failed");
-  result.SetStatus(eReturnStatusFailed);
-} else {
-  result.AppendMessage("reproducer verification succeeded");
-  result.SetStatus(eReturnStatusSuccessFinishResult);
-}
-
-return result.Succeeded();
-  }
-
-private:
-  CommandOptions m_options;
-};
-
 CommandObjectReproducer::CommandObjectReproducer(
 CommandInterpreter &interpreter)
 : CommandObjectMultiword(
@@ -704,8 +609,6 @@ CommandObjectReproducer::CommandObjectReproducer(
new 
CommandObjectReproducerStatus(interpreter)));
   LoadSubCommand("dump",
  CommandObjec

[Lldb-commits] [PATCH] D120917: Make the breakpoint log channel more useful

2022-03-03 Thread Jim Ingham via Phabricator via lldb-commits
jingham added inline comments.



Comment at: lldb/include/lldb/Breakpoint/Breakpoint.h:84
   static ConstString GetEventIdentifier();
+  static const char *
+  BreakpointEventTypeAsCString(lldb::BreakpointEventType type);

JDevlieghere wrote:
> Why not a llvm::StringRef?
This is returning a null terminated C-string.  What would be gained by passing 
it out as a StringRef so that clients had to call c_str on it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120917

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


[Lldb-commits] [lldb] 3f43818 - Fix up the "lldb log break" channel output.

2022-03-03 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2022-03-03T12:10:39-08:00
New Revision: 3f438185a68af4ca99d018d94f4732fd53433674

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

LOG: Fix up the "lldb log break" channel output.

1) Make the BreakpointEventData::Dump actually do something useful.
2) Make the Breakpoint events print when the break log channel is on
without having to turn on the events channel.

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

Added: 


Modified: 
lldb/include/lldb/Breakpoint/Breakpoint.h
lldb/include/lldb/Utility/Event.h
lldb/source/Breakpoint/Breakpoint.cpp
lldb/source/Utility/Broadcaster.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/Breakpoint.h 
b/lldb/include/lldb/Breakpoint/Breakpoint.h
index 113f8c4905e1f..39c6d0b7f3a77 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -81,6 +81,8 @@ class Breakpoint : public 
std::enable_shared_from_this,
public Stoppoint {
 public:
   static ConstString GetEventIdentifier();
+  static const char *
+  BreakpointEventTypeAsCString(lldb::BreakpointEventType type);
 
   /// An enum specifying the match style for breakpoint settings.  At present
   /// only used for function name style breakpoints.
@@ -105,12 +107,14 @@ class Breakpoint : public 
std::enable_shared_from_this,
 ~BreakpointEventData() override;
 
 static ConstString GetFlavorString();
+
+Log *GetLogChannel() override;
 
 ConstString GetFlavor() const override;
 
 lldb::BreakpointEventType GetBreakpointEventType() const;
 
-lldb::BreakpointSP &GetBreakpoint();
+lldb::BreakpointSP GetBreakpoint() const;
 
 BreakpointLocationCollection &GetBreakpointLocationCollection() {
   return m_locations;

diff  --git a/lldb/include/lldb/Utility/Event.h 
b/lldb/include/lldb/Utility/Event.h
index d3176216115a6..f533fc5c47fa5 100644
--- a/lldb/include/lldb/Utility/Event.h
+++ b/lldb/include/lldb/Utility/Event.h
@@ -42,7 +42,9 @@ class EventData {
   virtual ~EventData();
 
   virtual ConstString GetFlavor() const = 0;
-
+  
+  virtual Log *GetLogChannel() { return nullptr; }
+  
   virtual void Dump(Stream *s) const;
 
 private:

diff  --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 050457986eba6..afadf81e32c8c 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -1010,6 +1010,28 @@ void 
Breakpoint::SendBreakpointChangedEvent(BreakpointEventData *data) {
 delete data;
 }
 
+const char *Breakpoint::BreakpointEventTypeAsCString(BreakpointEventType type) 
{
+  switch (type) {
+case eBreakpointEventTypeInvalidType: return "invalid";
+case eBreakpointEventTypeAdded: return "breakpoint added";
+case eBreakpointEventTypeRemoved: return "breakpoint removed";
+case eBreakpointEventTypeLocationsAdded: return "locations added";
+case eBreakpointEventTypeLocationsRemoved: return "locations removed";
+case eBreakpointEventTypeLocationsResolved: return "locations resolved";
+case eBreakpointEventTypeEnabled: return "breakpoint enabled";
+case eBreakpointEventTypeDisabled: return "breakpoint disabled";
+case eBreakpointEventTypeCommandChanged: return "command changed";
+case eBreakpointEventTypeConditionChanged: return "condition changed";
+case eBreakpointEventTypeIgnoreChanged: return "ignore count changed";
+case eBreakpointEventTypeThreadChanged: return "thread changed";
+case eBreakpointEventTypeAutoContinueChanged: return "autocontinue 
changed";
+  };
+}
+
+Log *Breakpoint::BreakpointEventData::GetLogChannel() {
+  return GetLog(LLDBLog::Breakpoints);
+}
+
 Breakpoint::BreakpointEventData::BreakpointEventData(
 BreakpointEventType sub_type, const BreakpointSP &new_breakpoint_sp)
 : m_breakpoint_event(sub_type), m_new_breakpoint_sp(new_breakpoint_sp) {}
@@ -1025,7 +1047,7 @@ ConstString Breakpoint::BreakpointEventData::GetFlavor() 
const {
   return BreakpointEventData::GetFlavorString();
 }
 
-BreakpointSP &Breakpoint::BreakpointEventData::GetBreakpoint() {
+BreakpointSP Breakpoint::BreakpointEventData::GetBreakpoint() const {
   return m_new_breakpoint_sp;
 }
 
@@ -1034,7 +1056,14 @@ 
Breakpoint::BreakpointEventData::GetBreakpointEventType() const {
   return m_breakpoint_event;
 }
 
-void Breakpoint::BreakpointEventData::Dump(Stream *s) const {}
+void Breakpoint::BreakpointEventData::Dump(Stream *s) const {
+  if (!s)
+return;
+  BreakpointEventType event_type = GetBreakpointEventType();
+  break_id_t bkpt_id = GetBreakpoint()->GetID();
+  s->Format("bkpt: {0} type: {1}", bkpt_id,
+  BreakpointEventTypeAsCString(event_type));
+}
 
 const Breakpoint::BreakpointEventData *
 Brea

[Lldb-commits] [PATCH] D120917: Make the breakpoint log channel more useful

2022-03-03 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f438185a68a: Fix up the "lldb log break" channel 
output. (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120917

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Utility/Event.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Utility/Broadcaster.cpp

Index: lldb/source/Utility/Broadcaster.cpp
===
--- lldb/source/Utility/Broadcaster.cpp
+++ lldb/source/Utility/Broadcaster.cpp
@@ -208,7 +208,11 @@
   hijacking_listener_sp.reset();
   }
 
-  if (Log *log = GetLog(LLDBLog::Events)) {
+  Log *log = GetLog(LLDBLog::Events);
+  if (!log && event_sp->GetData())
+log = event_sp->GetData()->GetLogChannel();
+
+  if (log) {
 StreamString event_description;
 event_sp->Dump(&event_description);
 LLDB_LOGF(log,
Index: lldb/source/Breakpoint/Breakpoint.cpp
===
--- lldb/source/Breakpoint/Breakpoint.cpp
+++ lldb/source/Breakpoint/Breakpoint.cpp
@@ -1010,6 +1010,28 @@
 delete data;
 }
 
+const char *Breakpoint::BreakpointEventTypeAsCString(BreakpointEventType type) {
+  switch (type) {
+case eBreakpointEventTypeInvalidType: return "invalid";
+case eBreakpointEventTypeAdded: return "breakpoint added";
+case eBreakpointEventTypeRemoved: return "breakpoint removed";
+case eBreakpointEventTypeLocationsAdded: return "locations added";
+case eBreakpointEventTypeLocationsRemoved: return "locations removed";
+case eBreakpointEventTypeLocationsResolved: return "locations resolved";
+case eBreakpointEventTypeEnabled: return "breakpoint enabled";
+case eBreakpointEventTypeDisabled: return "breakpoint disabled";
+case eBreakpointEventTypeCommandChanged: return "command changed";
+case eBreakpointEventTypeConditionChanged: return "condition changed";
+case eBreakpointEventTypeIgnoreChanged: return "ignore count changed";
+case eBreakpointEventTypeThreadChanged: return "thread changed";
+case eBreakpointEventTypeAutoContinueChanged: return "autocontinue changed";
+  };
+}
+
+Log *Breakpoint::BreakpointEventData::GetLogChannel() {
+  return GetLog(LLDBLog::Breakpoints);
+}
+
 Breakpoint::BreakpointEventData::BreakpointEventData(
 BreakpointEventType sub_type, const BreakpointSP &new_breakpoint_sp)
 : m_breakpoint_event(sub_type), m_new_breakpoint_sp(new_breakpoint_sp) {}
@@ -1025,7 +1047,7 @@
   return BreakpointEventData::GetFlavorString();
 }
 
-BreakpointSP &Breakpoint::BreakpointEventData::GetBreakpoint() {
+BreakpointSP Breakpoint::BreakpointEventData::GetBreakpoint() const {
   return m_new_breakpoint_sp;
 }
 
@@ -1034,7 +1056,14 @@
   return m_breakpoint_event;
 }
 
-void Breakpoint::BreakpointEventData::Dump(Stream *s) const {}
+void Breakpoint::BreakpointEventData::Dump(Stream *s) const {
+  if (!s)
+return;
+  BreakpointEventType event_type = GetBreakpointEventType();
+  break_id_t bkpt_id = GetBreakpoint()->GetID();
+  s->Format("bkpt: {0} type: {1}", bkpt_id,
+  BreakpointEventTypeAsCString(event_type));
+}
 
 const Breakpoint::BreakpointEventData *
 Breakpoint::BreakpointEventData::GetEventDataFromEvent(const Event *event) {
Index: lldb/include/lldb/Utility/Event.h
===
--- lldb/include/lldb/Utility/Event.h
+++ lldb/include/lldb/Utility/Event.h
@@ -42,7 +42,9 @@
   virtual ~EventData();
 
   virtual ConstString GetFlavor() const = 0;
-
+  
+  virtual Log *GetLogChannel() { return nullptr; }
+  
   virtual void Dump(Stream *s) const;
 
 private:
Index: lldb/include/lldb/Breakpoint/Breakpoint.h
===
--- lldb/include/lldb/Breakpoint/Breakpoint.h
+++ lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -81,6 +81,8 @@
public Stoppoint {
 public:
   static ConstString GetEventIdentifier();
+  static const char *
+  BreakpointEventTypeAsCString(lldb::BreakpointEventType type);
 
   /// An enum specifying the match style for breakpoint settings.  At present
   /// only used for function name style breakpoints.
@@ -105,12 +107,14 @@
 ~BreakpointEventData() override;
 
 static ConstString GetFlavorString();
+
+Log *GetLogChannel() override;
 
 ConstString GetFlavor() const override;
 
 lldb::BreakpointEventType GetBreakpointEventType() const;
 
-lldb::BreakpointSP &GetBreakpoint();
+lldb::BreakpointSP GetBreakpoint() const;
 
 BreakpointLocationCollection &GetBreakpointLocationCollection() {
   return m_locations;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D120919: Reverse the order of modules-loaded/unloaded & breakpoint-changed events

2022-03-03 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc697a1f06b62: Fix the order of modules-loaded event and the 
resultant breakpoint-changed… (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120919

Files:
  lldb/source/Target/Target.cpp


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1642,11 +1642,11 @@
 void Target::ModulesDidUnload(ModuleList &module_list, bool delete_locations) {
   if (m_valid && module_list.GetSize()) {
 UnloadModuleSections(module_list);
+BroadcastEvent(eBroadcastBitModulesUnloaded,
+   new TargetEventData(this->shared_from_this(), module_list));
 m_breakpoint_list.UpdateBreakpoints(module_list, false, delete_locations);
 m_internal_breakpoint_list.UpdateBreakpoints(module_list, false,
  delete_locations);
-BroadcastEvent(eBroadcastBitModulesUnloaded,
-   new TargetEventData(this->shared_from_this(), module_list));
   }
 }
 


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1642,11 +1642,11 @@
 void Target::ModulesDidUnload(ModuleList &module_list, bool delete_locations) {
   if (m_valid && module_list.GetSize()) {
 UnloadModuleSections(module_list);
+BroadcastEvent(eBroadcastBitModulesUnloaded,
+   new TargetEventData(this->shared_from_this(), module_list));
 m_breakpoint_list.UpdateBreakpoints(module_list, false, delete_locations);
 m_internal_breakpoint_list.UpdateBreakpoints(module_list, false,
  delete_locations);
-BroadcastEvent(eBroadcastBitModulesUnloaded,
-   new TargetEventData(this->shared_from_this(), module_list));
   }
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c697a1f - Fix the order of modules-loaded event and the resultant breakpoint-changed event.

2022-03-03 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2022-03-03T12:10:54-08:00
New Revision: c697a1f06b6240d62eec8890ac1314728906d707

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

LOG: Fix the order of modules-loaded event and the resultant breakpoint-changed 
event.

The order used to be breakpoint-changed first, which didn't make much sense.

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

Added: 


Modified: 
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 298db3bca6803..14b5ecfacf384 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1642,11 +1642,11 @@ void Target::SymbolsDidLoad(ModuleList &module_list) {
 void Target::ModulesDidUnload(ModuleList &module_list, bool delete_locations) {
   if (m_valid && module_list.GetSize()) {
 UnloadModuleSections(module_list);
+BroadcastEvent(eBroadcastBitModulesUnloaded,
+   new TargetEventData(this->shared_from_this(), module_list));
 m_breakpoint_list.UpdateBreakpoints(module_list, false, delete_locations);
 m_internal_breakpoint_list.UpdateBreakpoints(module_list, false,
  delete_locations);
-BroadcastEvent(eBroadcastBitModulesUnloaded,
-   new TargetEventData(this->shared_from_this(), module_list));
   }
 }
 



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


[Lldb-commits] [lldb] 8b3b66e - [lldb] Remove FileSystem::Initialize from FileCollector

2022-03-03 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-03-03T13:22:38-08:00
New Revision: 8b3b66ea63d6469e5a3842627d538805173bda05

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

LOG: [lldb] Remove FileSystem::Initialize from FileCollector

This patch removes the ability to instantiate the LLDB FileSystem class
with a FileCollector. It keeps the ability to collect files, but uses
the FileCollectorFileSystem to do that transparently.

Because the two are intertwined, this patch also removes the
finalization logic which copied the files over out of process.

Added: 


Modified: 
lldb/include/lldb/Host/FileSystem.h
lldb/include/lldb/Utility/Reproducer.h
lldb/include/lldb/Utility/ReproducerProvider.h
lldb/source/API/SBReproducer.cpp
lldb/source/Commands/CommandObjectReproducer.cpp
lldb/source/Host/common/FileSystem.cpp
lldb/source/Host/posix/FileSystemPosix.cpp
lldb/source/Initialization/SystemInitializerCommon.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Utility/Reproducer.cpp
lldb/source/Utility/ReproducerProvider.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/FileSystem.h 
b/lldb/include/lldb/Host/FileSystem.h
index 50c48648fecda..efa77cbbbcb96 100644
--- a/lldb/include/lldb/Host/FileSystem.h
+++ b/lldb/include/lldb/Host/FileSystem.h
@@ -16,7 +16,6 @@
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/Chrono.h"
-#include "llvm/Support/FileCollector.h"
 #include "llvm/Support/VirtualFileSystem.h"
 
 #include "lldb/lldb-types.h"
@@ -31,12 +30,9 @@ class FileSystem {
   static const char *DEV_NULL;
   static const char *PATH_CONVERSION_ERROR;
 
-  FileSystem() : m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr) {}
-  FileSystem(std::shared_ptr collector)
-  : m_fs(llvm::vfs::getRealFileSystem()),
-m_collector(std::move(collector)) {}
+  FileSystem() : m_fs(llvm::vfs::getRealFileSystem()) {}
   FileSystem(llvm::IntrusiveRefCntPtr fs)
-  : m_fs(std::move(fs)), m_collector(nullptr) {}
+  : m_fs(std::move(fs)) {}
 
   FileSystem(const FileSystem &fs) = delete;
   FileSystem &operator=(const FileSystem &fs) = delete;
@@ -44,7 +40,6 @@ class FileSystem {
   static FileSystem &Instance();
 
   static void Initialize();
-  static void Initialize(std::shared_ptr collector);
   static void Initialize(llvm::IntrusiveRefCntPtr fs);
   static void Terminate();
 
@@ -191,15 +186,11 @@ class FileSystem {
 return m_fs;
   }
 
-  void Collect(const FileSpec &file_spec);
-  void Collect(const llvm::Twine &file);
-
   void SetHomeDirectory(std::string home_directory);
 
 private:
   static llvm::Optional &InstanceImpl();
   llvm::IntrusiveRefCntPtr m_fs;
-  std::shared_ptr m_collector;
   std::string m_home_directory;
 };
 } // namespace lldb_private

diff  --git a/lldb/include/lldb/Utility/Reproducer.h 
b/lldb/include/lldb/Utility/Reproducer.h
index 672f82fcb9565..e81abad2ec320 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -225,9 +225,6 @@ struct ReplayOptions {
   bool check_version = true;
 };
 
-llvm::Error Finalize(Loader *loader);
-llvm::Error Finalize(const FileSpec &root);
-
 } // namespace repro
 } // namespace lldb_private
 

diff  --git a/lldb/include/lldb/Utility/ReproducerProvider.h 
b/lldb/include/lldb/Utility/ReproducerProvider.h
index 56aadf92369e2..72ddf64f7ebc1 100644
--- a/lldb/include/lldb/Utility/ReproducerProvider.h
+++ b/lldb/include/lldb/Utility/ReproducerProvider.h
@@ -91,23 +91,6 @@ class YamlRecorder : public AbstractRecorder {
   }
 };
 
-class FlushingFileCollector : public llvm::FileCollectorBase {
-public:
-  FlushingFileCollector(llvm::StringRef files_path, llvm::StringRef dirs_path,
-std::error_code &ec);
-
-protected:
-  void addFileImpl(llvm::StringRef file) override;
-
-  llvm::vfs::directory_iterator
-  addDirectoryImpl(const llvm::Twine &dir,
-   llvm::IntrusiveRefCntPtr vfs,
-   std::error_code &dir_ec) override;
-
-  llvm::Optional m_files_os;
-  llvm::Optional m_dirs_os;
-};
-
 class FileProvider : public Provider {
 public:
   struct Info {
@@ -116,25 +99,24 @@ class FileProvider : public Provider {
   };
 
   FileProvider(const FileSpec &directory) : Provider(directory) {
-std::error_code ec;
-m_collector = std::make_shared(
-directory.CopyByAppendingPathComponent("files.txt").GetPath(),
-directory.CopyByAppendingPathComponent("dirs.txt").GetPath(), ec);
-if (ec)
-  m_collector.reset();
+m_collector = std::make_shared(
+directory.CopyByAppendingPathComponent("root").GetPath(),
+directory.GetPath());
   }
 
-  std::sh

[Lldb-commits] [lldb] 4212a57 - [lldb] Remove reproducer_handler from the driver

2022-03-03 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-03-03T13:22:39-08:00
New Revision: 4212a57a54d99c339c11448efda4991ea150b027

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

LOG: [lldb] Remove reproducer_handler from the driver

Added: 


Modified: 
lldb/tools/driver/Driver.cpp

Removed: 




diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 4540f06bebdb4..80c2ec67314b9 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -689,14 +689,6 @@ void sigcont_handler(int signo) {
   signal(signo, sigcont_handler);
 }
 
-void reproducer_handler(void *finalize_cmd) {
-  if (SBReproducer::Generate()) {
-int result = std::system(static_cast(finalize_cmd));
-(void)result;
-fflush(stdout);
-  }
-}
-
 static void printHelp(LLDBOptTable &table, llvm::StringRef tool_name) {
   std::string usage_str = tool_name.str() + " [options]";
   table.printHelp(llvm::outs(), usage_str.c_str(), "LLDB", false);



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


[Lldb-commits] [lldb] bf414cf - [lldb] Fix the build after 8b3b66ea63d6

2022-03-03 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-03-03T13:57:33-08:00
New Revision: bf414cfbf70570eaba282ae0561324794269d2d1

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

LOG: [lldb] Fix the build after 8b3b66ea63d6

Remove remaining calls to FileSystem::Collect.

Added: 


Modified: 
lldb/source/Host/windows/FileSystem.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp

Removed: 




diff  --git a/lldb/source/Host/windows/FileSystem.cpp 
b/lldb/source/Host/windows/FileSystem.cpp
index 94872c99b15ec..cbd1915bdb448 100644
--- a/lldb/source/Host/windows/FileSystem.cpp
+++ b/lldb/source/Host/windows/FileSystem.cpp
@@ -86,7 +86,6 @@ Status FileSystem::ResolveSymbolicLink(const FileSpec &src, 
FileSpec &dst) {
 }
 
 FILE *FileSystem::Fopen(const char *path, const char *mode) {
-  Collect(path);
   std::wstring wpath, wmode;
   if (!llvm::ConvertUTF8toWide(path, wpath))
 return nullptr;
@@ -99,7 +98,6 @@ FILE *FileSystem::Fopen(const char *path, const char *mode) {
 }
 
 int FileSystem::Open(const char *path, int flags, int mode) {
-  Collect(path);
   std::wstring wpath;
   if (!llvm::ConvertUTF8toWide(path, wpath))
 return -1;

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
index c677abfaa5f20..5b9d1b7c1520f 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -217,7 +217,6 @@ bool ScriptInterpreterLua::LoadScriptingModule(
 lldb_private::Status &error, StructuredData::ObjectSP *module_sp,
 FileSpec extra_search_dir) {
 
-  FileSystem::Instance().Collect(filename);
   if (llvm::Error e = m_lua->LoadModule(filename)) {
 error.SetErrorStringWithFormatv("lua failed to import '{0}': {1}\n",
 filename, llvm::toString(std::move(e)));



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


[Lldb-commits] [PATCH] D120755: Fix race condition when launching and attaching.This is a modified version of a previous patch that was reverted: https://reviews.llvm.org/D119797This version only wait

2022-03-03 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG63e512100ac6: Fix race condition when launching and 
attaching. (authored by clayborg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120755

Files:
  lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -215,7 +215,7 @@
 			},
 			"launchCommands": {
 "type": "array",
-"description": "Custom commands that are executed instead of launching a process. A target will be created with the launch arguments prior to executing these commands. The commands may optionally create a new target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail.",
+"description": "Custom commands that are executed instead of launching a process. A target will be created with the launch arguments prior to executing these commands. The commands may optionally create a new target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail. Launch the process with \"process launch -s\" to make the process to at the entry point since lldb-vscode will auto resume if necessary.",
 "default": []
 			},
 			"stopCommands": {
@@ -232,6 +232,10 @@
 "type": "boolean",
 "description": "Launch the program inside an integrated terminal in the IDE. Useful for debugging interactive command line programs",
 "default": false
+			},
+			"timeout": {
+"type": "string",
+"description": "The time in seconds to wait for a program to stop at entry point when launching with \"launchCommands\". Defaults to 30 seconds."
 			}
 		}
 	},
@@ -307,6 +311,10 @@
 			"coreFile": {
 "type": "string",
 "description": "Path to the core file to debug."
+			},
+			"timeout": {
+"type": "string",
+"description": "The time in seconds to wait for a program to stop when attaching using \"attachCommands\". Defaults to 30 seconds."
 			}
 		}
 	}
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -449,10 +449,18 @@
   case lldb::eStateSuspended:
 break;
   case lldb::eStateStopped:
-// Only report a stopped event if the process was not restarted.
-if (!lldb::SBProcess::GetRestartedFromEvent(event)) {
-  SendStdOutStdErr(process);
-  SendThreadStoppedEvent();
+// We launch and attach in synchronous mode then the first stop
+// event will not be delivered. If we use "launchCommands" during a
+// launch or "attachCommands" during an attach we might some process
+// stop events which we do not want to send an event for. We will
+// manually send a stopped event in request_configurationDone(...)
+// so don't send any before then.
+if (g_vsc.configuration_done_sent) {
+  // Only report a stopped event if the process was not restarted.
+  if (!lldb::SBProcess::GetRestartedFromEvent(event)) {
+SendStdOutStdErr(process);
+SendThreadStoppedEvent();
+  }
 }
 break;
   case lldb::eStateRunning:
@@ -600,6 +608,7 @@
   g_vsc.terminate_commands = GetStrings(arguments, "terminateCommands");
   auto attachCommands = GetStrings(arguments, "attachCommands");
   llvm::StringRef core_file = GetString(arguments, "coreFile");
+  const uint64_t timeout_seconds = GetUnsigned(arguments, "timeout", 30);
   g_vsc.stop_at_entry =
   core_file.empty() ? GetBoolean(arguments, "stopOnEntry", false) : true;
   std::vector postRunCommands =
@@ -657,6 +666,10 @@
 // The custom commands might have created a new target so we should use the
 // selected target after these commands are run.
 g_vsc.target = g_vsc.debugger.GetSelectedTarget();
+
+// Make sure the process is attached and stopped before proceeding as the
+// the launch commands are not run using the synchronous mode.
+error = g_vsc.WaitForProcessToStop(timeout_seconds);
   }
 
   if (error.Success() && core_file.empty()) {
@@ -787,6 +800,7 @@
   llvm::json::Object response;
   FillResponse(request, response);
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
+  g_vsc.configuration_done_sent = true;
   if (g_vsc.stop_at_entr

[Lldb-commits] [lldb] 63e5121 - Fix race condition when launching and attaching.

2022-03-03 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2022-03-03T16:20:27-08:00
New Revision: 63e512100ac62efd5f009c6b490194e973a9d1ce

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

LOG: Fix race condition when launching and attaching.

This is a modified version of a previous patch that was reverted: 
https://reviews.llvm.org/D119797
This version only waits for the process to stop when using "launchCommands" or 
"attachCommands"...

...and doesn't play with the async mode when doing normal launch/attach.

We discovered that when using "launchCommands" or "attachCommands" that there 
was an issue where these commands were not being run synchronously. There were 
further problems in this case where we would get thread events for the process 
that was just launched or attached before the IDE was ready, which is after 
"configurationDone" was sent to lldb-vscode.

This fix introduces the ability to wait for the process to stop after 
"launchCommands" or "attachCommands" are run to ensure that we have a stopped 
process point that is ready for the debug session to proceed. We spin up the 
thread that listens for process events before we start the launch or attach, 
but we don't want stop events being delivered through the DAP protocol until 
the "configurationDone" packet is received. We now always ignore the stop event 
with a stop ID of 1, which is the first stop. All normal launch and attach 
scenarios use the synchronous mode, and "launchCommands and "attachCommands" 
run an array of LLDB commands in async mode.

This should make our launch with "launchCommands" and attach with 
"attachCommands" avoid a race condition when the process is being launched or 
attached.

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

Added: 


Modified: 
lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
lldb/tools/lldb-vscode/VSCode.cpp
lldb/tools/lldb-vscode/VSCode.h
lldb/tools/lldb-vscode/lldb-vscode.cpp
lldb/tools/lldb-vscode/package.json

Removed: 




diff  --git a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py 
b/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
index ff798364c9573..8cbdb1546 100644
--- a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
+++ b/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
@@ -374,7 +374,7 @@ def test_commands(self):
 @skipIfRemote
 def test_extra_launch_commands(self):
 '''
-Tests the "luanchCommands" with extra launching settings
+Tests the "launchCommands" with extra launching settings
 '''
 self.build_and_create_debug_adaptor()
 program = self.getBuildArtifact("a.out")

diff  --git a/lldb/tools/lldb-vscode/VSCode.cpp 
b/lldb/tools/lldb-vscode/VSCode.cpp
index 8e43ea3b771e6..adc4549f7c25d 100644
--- a/lldb/tools/lldb-vscode/VSCode.cpp
+++ b/lldb/tools/lldb-vscode/VSCode.cpp
@@ -39,8 +39,8 @@ VSCode::VSCode()
{"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
{"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
   focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false),
-  stop_at_entry(false), is_attach(false), reverse_request_seq(0),
-  waiting_for_run_in_terminal(false),
+  stop_at_entry(false), is_attach(false), configuration_done_sent(false),
+  reverse_request_seq(0), waiting_for_run_in_terminal(false),
   progress_event_reporter(
   [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }) {
   const char *log_file_path = getenv("LLDBVSCODE_LOG");
@@ -528,6 +528,46 @@ void VSCode::RegisterRequestCallback(std::string request,
   request_handlers[request] = callback;
 }
 
+lldb::SBError VSCode::WaitForProcessToStop(uint32_t seconds) {
+  lldb::SBError error;
+  lldb::SBProcess process = target.GetProcess();
+  if (!process.IsValid()) {
+error.SetErrorString("invalid process");
+return error;
+  }
+  auto timeout_time =
+  std::chrono::steady_clock::now() + std::chrono::seconds(seconds);
+  while (std::chrono::steady_clock::now() < timeout_time) {
+const auto state = process.GetState();
+switch (state) {
+  case lldb::eStateAttaching:
+  case lldb::eStateConnected:
+  case lldb::eStateInvalid:
+  case lldb::eStateLaunching:
+  case lldb::eStateRunning:
+  case lldb::eStateStepping:
+  case lldb::eStateSuspended:
+break;
+  case lldb::eStateDetached:
+error.SetErrorString("process detached during launch or attach");
+return error;
+  case lldb::eStateExited:
+error.SetErrorString("process exited during launch or attach");
+return error;
+  case lldb::eStateUnloaded:
+error.SetErrorString("process unloaded during launch or attach");
+re

[Lldb-commits] [PATCH] D120948: Disable LLDB index cache for .o files with no UUID.

2022-03-03 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: labath, JDevlieghere, jingham, aadsm, wallace, 
yinghuitan.
Herald added a subscriber: arphaman.
Herald added a project: All.
clayborg requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

After enabling the LLDB index cache in production we discovered that some 
distributed build systems play with the modification times of any .o files that 
were downloaded from the build cache. This was causing the LLDB index cache to 
read the wrong cache file for files that didn't have a UUID as all of the 
modfication times were set to the same value by the build system. When new .o 
files were downloaded, the only unique identifier was the mod time which were 
all the same, and we would load an older cache for the updated .o file. So 
disabling caching of files that have no UUIDs for now until we can create a 
more solid solution.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120948

Files:
  lldb/include/lldb/Core/DataFileCache.h
  lldb/test/API/functionalities/module_cache/bsd/TestModuleCacheBSD.py


Index: lldb/test/API/functionalities/module_cache/bsd/TestModuleCacheBSD.py
===
--- lldb/test/API/functionalities/module_cache/bsd/TestModuleCacheBSD.py
+++ lldb/test/API/functionalities/module_cache/bsd/TestModuleCacheBSD.py
@@ -41,6 +41,25 @@
 @skipUnlessDarwin
 def test(self):
 """
+This test has been modified to make sure .o files that don't have
+UUIDs are not cached after discovering build systems that play with
+modification times of .o files that the modification times are not
+unique enough to ensure the .o file within the .a file are the 
right
+files as this was causing older cache files to be accepted for new
+updated .o files.
+
+ELF .o files do calculate a UUID from the contents of the file,
+which is expensive, but no one loads .o files into a debug sessions
+when using ELF files. Mach-o .o files do not have UUID values and 
do
+no calculate one as they _are_ used during debug sessions when no
+dSYM file is generated. If we can find a way to uniquely and 
cheaply
+create UUID values for mach-o .o files in the future, this test 
will
+be updated to test this functionality. This test will now make sure
+there are no cache entries for any .o files in BSD archives.
+
+The old test case description is below in case we enable caching 
for
+.o files again:
+
 Test module cache functionality for bsd archive object files.
 
 This will test that if we enable the module cache, we have a
@@ -76,10 +95,20 @@
 main_module.GetNumSymbols()
 a_o_cache_files = self.get_module_cache_files("libfoo.a(a.o)")
 b_o_cache_files = self.get_module_cache_files("libfoo.a(b.o)")
+
+
 # We expect the directory for a.o to have two cache directories:
 # - 1 for the a.o with a earlier mod time
 # - 1 for the a.o that was renamed from c.o that should be 2 seconds 
older
-self.assertEqual(len(a_o_cache_files), 2,
-"make sure there are two files in the module cache directory 
(%s) for libfoo.a(a.o)" % (self.cache_dir))
-self.assertEqual(len(b_o_cache_files), 1,
-"make sure there are two files in the module cache directory 
(%s) for libfoo.a(b.o)" % (self.cache_dir))
+# self.assertEqual(len(a_o_cache_files), 2,
+# "make sure there are two files in the module cache directory 
(%s) for libfoo.a(a.o)" % (self.cache_dir))
+# self.assertEqual(len(b_o_cache_files), 1,
+# "make sure there are two files in the module cache directory 
(%s) for libfoo.a(b.o)" % (self.cache_dir))
+
+# We are no longer caching .o files in the lldb index cache. If we ever
+# re-enable this functionality, we can uncomment out the above lines of
+# code.
+self.assertEqual(len(a_o_cache_files), 0,
+"make sure there are no files in the module cache directory 
(%s) for libfoo.a(a.o)" % (self.cache_dir))
+self.assertEqual(len(b_o_cache_files), 0,
+"make sure there are no files in the module cache directory 
(%s) for libfoo.a(b.o)" % (self.cache_dir))
Index: lldb/include/lldb/Core/DataFileCache.h
===
--- lldb/include/lldb/Core/DataFileCache.h
+++ lldb/include/lldb/Core/DataFileCache.h
@@ -118,11 +118,13 @@
 m_obj_mod_time = llvm::None;
   }
 
-  /// Return true if any of the signature member variables have valid values.
-  bool IsValid() const {
-return m_uuid.hasValue() || m_mod_time.hasValue() ||
-   m_obj_mod_time.hasValue();
-  }
+  /// Return true only if the Cac

[Lldb-commits] [PATCH] D120961: [LLDB] Flush stream at the end of PrintCommandOutput

2022-03-03 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu created this revision.
zequanwu added a reviewer: labath.
Herald added a project: All.
zequanwu requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

On Windows, lldb doesn't print any error message until exit. This fixes it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120961

Files:
  lldb/source/Interpreter/CommandInterpreter.cpp


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2997,6 +2997,7 @@
   if (size > 0) {
 stream.Printf("\n... Interrupted.\n");
   }
+  stream.Flush();
 }
 
 bool CommandInterpreter::EchoCommandNonInteractive(


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -2997,6 +2997,7 @@
   if (size > 0) {
 stream.Printf("\n... Interrupted.\n");
   }
+  stream.Flush();
 }
 
 bool CommandInterpreter::EchoCommandNonInteractive(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D120966: Remove cases of using namespace std

2022-03-03 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik created this revision.
shafik added reviewers: labath, aprantl, JDevlieghere.
Herald added a project: All.
shafik requested review of this revision.

We had `using namespace std;`  sprinkled around several source files and tests.

This also follows the LLVM coding standard 
.


https://reviews.llvm.org/D120966

Files:
  lldb/source/Core/FileSpecList.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/test/API/api/multithreaded/inferior.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/main.cpp
  lldb/test/API/functionalities/process_save_core_minidump/main.cpp
  lldb/test/API/functionalities/thread/concurrent_events/main.cpp
  lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp

Index: lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp
===
--- lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp
+++ lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp
@@ -2,8 +2,6 @@
 // Link with "link test-pdb-types.obj /debug /nodefaultlib /entry:main
 // /out:test-pdb-types.exe"
 
-using namespace std;
-
 // Sizes of builtin types
 static const int sizeof_char = sizeof(char);
 static const int sizeof_uchar = sizeof(unsigned char);
Index: lldb/test/API/functionalities/thread/concurrent_events/main.cpp
===
--- lldb/test/API/functionalities/thread/concurrent_events/main.cpp
+++ lldb/test/API/functionalities/thread/concurrent_events/main.cpp
@@ -6,7 +6,6 @@
 
 #include "pseudo_barrier.h"
 #include 
-using namespace std;
 
 #include 
 
Index: lldb/test/API/functionalities/process_save_core_minidump/main.cpp
===
--- lldb/test/API/functionalities/process_save_core_minidump/main.cpp
+++ lldb/test/API/functionalities/process_save_core_minidump/main.cpp
@@ -2,8 +2,6 @@
 #include 
 #include 
 
-using namespace std;
-
 void g() { assert(false); }
 
 void f() { g(); }
@@ -19,12 +17,12 @@
 }
 
 int main() {
-  thread t1(f);
+  std::thread t1(f);
 
   size_t x = h();
 
   t1.join();
 
-  cout << "X is " << x << "\n";
+  std::cout << "X is " << x << "\n";
   return 0;
-}
\ No newline at end of file
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/main.cpp
@@ -1,11 +1,9 @@
 #include 
 #include 
 
-using namespace std;
-
 int main() {
-  tuple<> empty;
-  tuple one_elt{47};
-  tuple three_elts{1, 47l, "foo"};
+  std::tuple<> empty;
+  std::tuple one_elt{47};
+  std::tuple three_elts{1, 47l, "foo"};
   return 0; // break here
 }
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/main.cpp
@@ -1,11 +1,9 @@
 #include 
 #include 
 
-using namespace std;
-
 int main() {
-  queue q1{{1,2,3,4,5}};
-  queue> q2{{1,2,3,4,5}};
+  std::queue q1{{1,2,3,4,5}};
+  std::queue> q2{{1,2,3,4,5}};
   int ret = q1.size() + q2.size(); // break here
   return ret;
 }
Index: lldb/test/API/api/multithreaded/inferior.cpp
===
--- lldb/test/API/api/multithreaded/inferior.cpp
+++ lldb/test/API/api/multithreaded/inferior.cpp
@@ -1,11 +1,11 @@
 
 #include 
 
-using namespace std;
+
 
 int next() {
   static int i = 0;
-  cout << "incrementing " << i << endl;
+  std::cout << "incrementing " << i << std::endl;
   return ++i;
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -26,7 +26,6 @@
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::dwarf;
-using namespace std;
 
 extern int g_verbose;
 
@@ -449,7 +448,7 @@
 
   uint64_t HeaderSize = llvm::DWARFListTableHeader::getHeaderSize(format);
   if (offset < HeaderSize)
-return llvm::createStringError(errc::invalid_argument,
+return llvm::createStringError(std::errc::invalid_argument,
"did not detect a valid"
  

[Lldb-commits] [PATCH] D120966: Remove cases of using namespace std

2022-03-03 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

As a side note, I noticed that we don't prefix typedefs from `cstdint` with 
`std::` e.g. `size_t`. These typedefs are not guaranteed to be in the global 
namespace.


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

https://reviews.llvm.org/D120966

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


[Lldb-commits] [PATCH] D120966: Remove cases of using namespace std

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

LGTM


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

https://reviews.llvm.org/D120966

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


[Lldb-commits] [PATCH] D120969: [lldb/Plugins] Add ability to load modules to Scripted Processes

2022-03-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: JDevlieghere, jasonmolenda.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch introduces a new way to load modules programatically with
Scripted Processes. To do so, the scripted process blueprint holds a
list of dictionary describing the modules to load, which their path or
uuid, load address and eventually a slide offset.

LLDB will fetch that list after launching the ScriptedProcess, and
iterate over each entry to create the module that will be loaded in the
Scripted Process' target.

The patch also refactors the StackCoreScriptedProcess test to stop
inside the `libbaz` module and make sure it's loaded correctly and that
we can fetch some variables from it.

rdar://74520238

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120969

Files:
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/test/API/functionalities/scripted_process/Makefile
  lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
  lldb/test/API/functionalities/scripted_process/baz.c
  lldb/test/API/functionalities/scripted_process/baz.h
  lldb/test/API/functionalities/scripted_process/main.cpp
  lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py

Index: lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
===
--- lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
+++ lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
@@ -10,10 +10,10 @@
 def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
 super().__init__(target, args)
 
-self.backing_target_idx = args.GetValueForKey("backing_target_idx")
-
 self.corefile_target = None
 self.corefile_process = None
+
+self.backing_target_idx = args.GetValueForKey("backing_target_idx")
 if (self.backing_target_idx and self.backing_target_idx.IsValid()):
 if self.backing_target_idx.GetType() == lldb.eStructuredDataTypeInteger:
 idx = self.backing_target_idx.GetIntegerValue(42)
@@ -30,9 +30,22 @@
 
 self.threads[corefile_thread.GetThreadID()] = StackCoreScriptedThread(self, structured_data)
 
-if len(self.threads) == 3:
+if len(self.threads) == 2:
 self.threads[len(self.threads) - 1].is_stopped = True
 
+lib_path = args.GetValueForKey("libbaz_path")
+if not (lib_path and lib_path.IsValid()) \
+or lib_path.GetType() != lldb.eStructuredDataTypeString:
+return
+
+self.lib_path = lib_path.GetStringValue(256)
+if not os.path.exists(self.lib_path):
+return
+
+lib_load_addr = 0x0001001e
+self.loaded_images.append({"path": self.lib_path,
+   "load_addr": lib_load_addr})
+
 def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
 mem_region = lldb.SBMemoryRegionInfo()
 error = self.corefile_process.GetMemoryRegionInfo(addr, mem_region)
Index: lldb/test/API/functionalities/scripted_process/main.cpp
===
--- lldb/test/API/functionalities/scripted_process/main.cpp
+++ lldb/test/API/functionalities/scripted_process/main.cpp
@@ -2,16 +2,20 @@
 #include 
 #include 
 
+extern "C" {
+int baz(int);
+}
+
 int bar(int i) {
   int j = i * i;
-  return j; // break here
+  return j;
 }
 
 int foo(int i) { return bar(i); }
 
 void call_and_wait(int &n) {
   std::cout << "waiting for computation!" << std::endl;
-  while (n != 42 * 42)
+  while (baz(n) != 42)
 ;
   std::cout << "finished computation!" << std::endl;
 }
Index: lldb/test/API/functionalities/scripted_process/baz.h
===
--- /dev/null
+++ lldb/test/API/functionalities/scripted_process/baz.h
@@ -0,0 +1,3 @@
+#pragma once
+
+int baz(int j);
Index: lldb/test/API/functionalities/scripted_process/baz.c
===
--- /dev/null
+++ lldb/test/API/functionalities/scripted_process/baz.c
@@ -0,0 +1,8 @@
+#include "baz.h"
+
+#include 
+
+int baz(int j) {
+  int k = sqrt(j);
+  return k; // break here
+}
Index: lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
===

[Lldb-commits] [PATCH] D120969: [lldb/Plugins] Add ability to load modules to Scripted Processes

2022-03-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 412923.
mib added a comment.

Re-format


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

https://reviews.llvm.org/D120969

Files:
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/test/API/functionalities/scripted_process/Makefile
  lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
  lldb/test/API/functionalities/scripted_process/baz.c
  lldb/test/API/functionalities/scripted_process/baz.h
  lldb/test/API/functionalities/scripted_process/main.cpp
  lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py

Index: lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
===
--- lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
+++ lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
@@ -10,10 +10,10 @@
 def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
 super().__init__(target, args)
 
-self.backing_target_idx = args.GetValueForKey("backing_target_idx")
-
 self.corefile_target = None
 self.corefile_process = None
+
+self.backing_target_idx = args.GetValueForKey("backing_target_idx")
 if (self.backing_target_idx and self.backing_target_idx.IsValid()):
 if self.backing_target_idx.GetType() == lldb.eStructuredDataTypeInteger:
 idx = self.backing_target_idx.GetIntegerValue(42)
@@ -30,9 +30,22 @@
 
 self.threads[corefile_thread.GetThreadID()] = StackCoreScriptedThread(self, structured_data)
 
-if len(self.threads) == 3:
+if len(self.threads) == 2:
 self.threads[len(self.threads) - 1].is_stopped = True
 
+lib_path = args.GetValueForKey("libbaz_path")
+if not (lib_path and lib_path.IsValid()) \
+or lib_path.GetType() != lldb.eStructuredDataTypeString:
+return
+
+self.lib_path = lib_path.GetStringValue(256)
+if not os.path.exists(self.lib_path):
+return
+
+lib_load_addr = 0x0001001e
+self.loaded_images.append({"path": self.lib_path,
+   "load_addr": lib_load_addr})
+
 def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
 mem_region = lldb.SBMemoryRegionInfo()
 error = self.corefile_process.GetMemoryRegionInfo(addr, mem_region)
Index: lldb/test/API/functionalities/scripted_process/main.cpp
===
--- lldb/test/API/functionalities/scripted_process/main.cpp
+++ lldb/test/API/functionalities/scripted_process/main.cpp
@@ -2,16 +2,20 @@
 #include 
 #include 
 
+extern "C" {
+int baz(int);
+}
+
 int bar(int i) {
   int j = i * i;
-  return j; // break here
+  return j;
 }
 
 int foo(int i) { return bar(i); }
 
 void call_and_wait(int &n) {
   std::cout << "waiting for computation!" << std::endl;
-  while (n != 42 * 42)
+  while (baz(n) != 42)
 ;
   std::cout << "finished computation!" << std::endl;
 }
Index: lldb/test/API/functionalities/scripted_process/baz.h
===
--- /dev/null
+++ lldb/test/API/functionalities/scripted_process/baz.h
@@ -0,0 +1,3 @@
+#pragma once
+
+int baz(int j);
Index: lldb/test/API/functionalities/scripted_process/baz.c
===
--- /dev/null
+++ lldb/test/API/functionalities/scripted_process/baz.c
@@ -0,0 +1,8 @@
+#include "baz.h"
+
+#include 
+
+int baz(int j) {
+  int k = sqrt(j);
+  return k; // break here
+}
Index: lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
===
--- lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
+++ lldb/test/API/functionalities/scripted_process/TestStackCoreScriptedProcess.py
@@ -25,13 +25,19 @@
 def create_stack_skinny_corefile(self, file):
 self.build()
 target, process, thread, _ = lldbutil.run_to_source_breakpoint(self, "// break here",
-   lldb.SBFileSpec("main.cpp"))
+   lldb.SBFileSpec("baz.c"))
 self.assertTrue(process.IsValid(), "Process is invalid.")
 # FIXME: Use SBAPI to save the process corefile.
 self.runCmd("process save-core -s stack  " + file)
 self.assertTru

[Lldb-commits] [PATCH] D120972: [lldb] Show progress events in the command line driver

2022-03-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, clayborg, mib, aprantl, kastiglione.
Herald added a project: All.
JDevlieghere requested review of this revision.

This patch adds support for showing progress events when using lldb on the 
command line. It spawns a separate thread that listens for progress events and 
prints them to the debugger's output stream.

It's nothing fancy (yet), for now it just prints the progress message. If we 
know the total number of items being processed, we prefix the message with 
something like  [1/100], similar to ninja's output. It doesn't use any fancy 
terminal manipulation: it uses a simple carriage return (`\r`) to bring the 
cursor to the front of the line. If we support ANSI escape codes, we use a 
vt100 escape code to clear the current line when a progress event is complete. 
Otherwise we just overwrite it with as many spaces as the current terminal is 
wide.

Here's a recording of what this looks like in practice: 
https://asciinema.org/a/HBMDelpb9XDKccXZ09mgfuJ8R


https://reviews.llvm.org/D120972

Files:
  lldb/include/lldb/API/SBCommandInterpreterRunOptions.h
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreterRunOptions.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Symbol/LocateSymbolFile.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -565,6 +565,7 @@
 m_debugger.SetAsync(false);
 
 SBCommandInterpreterRunOptions options;
+options.SetShowProgress(true);
 options.SetAutoHandleEvents(true);
 options.SetSpawnThread(false);
 options.SetStopOnError(true);
Index: lldb/source/Symbol/LocateSymbolFile.cpp
===
--- lldb/source/Symbol/LocateSymbolFile.cpp
+++ lldb/source/Symbol/LocateSymbolFile.cpp
@@ -10,6 +10,7 @@
 
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Progress.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -257,6 +258,10 @@
 FileSpec
 Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec,
 const FileSpecList &default_search_paths) {
+
+  Progress progress(llvm::formatv(
+  "Locating external symbol file for {0}",
+  module_spec.GetFileSpec().GetFilename().AsCString("")));
   FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
   if (symbol_file_spec.IsAbsolute() &&
   FileSystem::Instance().Exists(symbol_file_spec))
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3283,6 +3283,9 @@
 
 CommandInterpreterRunResult CommandInterpreter::RunCommandInterpreter(
 CommandInterpreterRunOptions &options) {
+  if (options.GetShowProgress())
+m_debugger.StartProgressHandlerThread();
+
   // Always re-create the command interpreter when we run it in case any file
   // handles have changed.
   bool force_create = true;
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1719,6 +1719,68 @@
   return {};
 }
 
+lldb::thread_result_t Debugger::ProgressHandlerThread() {
+  // Only report progress for real terminals.
+  if (!GetOutputFile().GetIsRealTerminal())
+return {};
+
+  // Only report progress is nobody else is listening for it.
+  if (GetBroadcaster().EventTypeHasListeners(Debugger::eBroadcastBitProgress))
+return {};
+
+  ListenerSP listener_sp = Listener::MakeListener("lldb.progress.listener");
+  listener_sp->StartListeningForEvents(&m_broadcaster,
+   Debugger::eBroadcastBitProgress);
+
+  // Only handle one kind of event at the same time. Ignore events that come in
+  // in while the current event hasn't completed
+  llvm::Optional CurrentEventID;
+
+  // Assume that the if the terminal supports colors (ANSI escape codes) it
+  // also supports vt100 escape codes.
+  const bool use_vt100_escapes = GetOutputFile().GetIsTerminalWithColors();
+
+  while (true) {
+lldb::EventSP event_sp;
+if (listener_sp->GetEvent(event_sp, llvm::None)) {
+  if (!event_sp)
+continue;
+  if (auto *data = Debugger::ProgressEventData::GetEventDataFromEvent(
+  event_sp.get())) {
+
+uint64_t id = data->GetID();
+if (CurrentEventID) {
+  if (id != *CurrentEventID)
+continue;
+} else {
+  CurrentEventID = id;
+}
+
+std::string message = data->GetMessage();
+i

[Lldb-commits] [PATCH] D120972: [lldb] Show progress events in the command line driver

2022-03-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 412926.
JDevlieghere added a comment.

Remove unrelated formatting changes


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

https://reviews.llvm.org/D120972

Files:
  lldb/include/lldb/API/SBCommandInterpreterRunOptions.h
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreterRunOptions.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Symbol/LocateSymbolFile.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -565,6 +565,7 @@
 m_debugger.SetAsync(false);
 
 SBCommandInterpreterRunOptions options;
+options.SetShowProgress(true);
 options.SetAutoHandleEvents(true);
 options.SetSpawnThread(false);
 options.SetStopOnError(true);
Index: lldb/source/Symbol/LocateSymbolFile.cpp
===
--- lldb/source/Symbol/LocateSymbolFile.cpp
+++ lldb/source/Symbol/LocateSymbolFile.cpp
@@ -10,6 +10,7 @@
 
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Progress.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -257,6 +258,10 @@
 FileSpec
 Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec,
 const FileSpecList &default_search_paths) {
+
+  Progress progress(llvm::formatv(
+  "Locating external symbol file for {0}",
+  module_spec.GetFileSpec().GetFilename().AsCString("")));
   FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
   if (symbol_file_spec.IsAbsolute() &&
   FileSystem::Instance().Exists(symbol_file_spec))
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3283,6 +3283,9 @@
 
 CommandInterpreterRunResult CommandInterpreter::RunCommandInterpreter(
 CommandInterpreterRunOptions &options) {
+  if (options.GetShowProgress())
+m_debugger.StartProgressHandlerThread();
+
   // Always re-create the command interpreter when we run it in case any file
   // handles have changed.
   bool force_create = true;
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1719,6 +1719,68 @@
   return {};
 }
 
+lldb::thread_result_t Debugger::ProgressHandlerThread() {
+  // Only report progress for real terminals.
+  if (!GetOutputFile().GetIsRealTerminal())
+return {};
+
+  // Only report progress is nobody else is listening for it.
+  if (GetBroadcaster().EventTypeHasListeners(Debugger::eBroadcastBitProgress))
+return {};
+
+  ListenerSP listener_sp = Listener::MakeListener("lldb.progress.listener");
+  listener_sp->StartListeningForEvents(&m_broadcaster,
+   Debugger::eBroadcastBitProgress);
+
+  // Only handle one kind of event at the same time. Ignore events that come in
+  // in while the current event hasn't completed
+  llvm::Optional CurrentEventID;
+
+  // Assume that the if the terminal supports colors (ANSI escape codes) it
+  // also supports vt100 escape codes.
+  const bool use_vt100_escapes = GetOutputFile().GetIsTerminalWithColors();
+
+  while (true) {
+lldb::EventSP event_sp;
+if (listener_sp->GetEvent(event_sp, llvm::None)) {
+  if (!event_sp)
+continue;
+  if (auto *data = Debugger::ProgressEventData::GetEventDataFromEvent(
+  event_sp.get())) {
+
+uint64_t id = data->GetID();
+if (CurrentEventID) {
+  if (id != *CurrentEventID)
+continue;
+} else {
+  CurrentEventID = id;
+}
+
+std::string message = data->GetMessage();
+if (data->GetTotal() != UINT64_MAX) {
+  GetOutputFile().Printf("[%llu/%llu] %s\r", data->GetCompleted(),
+ data->GetTotal(), message.c_str());
+} else {
+  GetOutputFile().Printf("%s\r", message.c_str());
+}
+
+if (data->GetCompleted()) {
+  CurrentEventID.reset();
+  // Clear the current line. Use an escape character if supported,
+  // otherwise overwrite the line with a sequence of spaces.
+  if (use_vt100_escapes) {
+GetOutputFile().Printf("\33[2K\r");
+  } else {
+std::string clear(GetTerminalWidth(), ' ');
+GetOutputFile().Printf("%s\r", clear.c_str());
+  }
+}
+  }
+}
+  }
+  return {};
+}
+
 bool Debugger::HasIOHandlerThread() { return m_io_handler_thread.IsJoinable(); }
 
 b

[Lldb-commits] [PATCH] D120972: [lldb] Show progress events in the command line driver

2022-03-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

Awesome! I could see this getting improved in the future by stacking each 
progress event in the output with their completion amount and popping the ones 
that are completed.




Comment at: lldb/source/Core/Debugger.cpp:1727
+
+  // Only report progress is nobody else is listening for it.
+  if (GetBroadcaster().EventTypeHasListeners(Debugger::eBroadcastBitProgress))





Comment at: lldb/source/Core/Debugger.cpp:1822
+[this] { return ProgressHandlerThread(); },
+8 * 1024 * 1024); // Use larger 8MB stack for this thread
+if (progress_handler_thread) {

Why ?


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

https://reviews.llvm.org/D120972

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


[Lldb-commits] [PATCH] D120972: [lldb] Show progress events in the command line driver

2022-03-03 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/source/Core/Debugger.cpp:1727
+
+  // Only report progress is nobody else is listening for it.
+  if (GetBroadcaster().EventTypeHasListeners(Debugger::eBroadcastBitProgress))

mib wrote:
> 
typo


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

https://reviews.llvm.org/D120972

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


[Lldb-commits] [PATCH] D120948: Disable LLDB index cache for .o files with no UUID.

2022-03-03 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan accepted this revision.
yinghuitan added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/include/lldb/Core/DataFileCache.h:127
+  /// unique idenifier like the UUID being valid.
+  bool IsValid() const { return m_uuid.hasValue(); }
 

Do we plan to ship with this design (no caching for module .o file without 
uuid)? If so, I wonder if we should emit reason information for module not 
loaded from cache (like signature mismatch/changed vs uuid unavailable)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120948

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


[Lldb-commits] [PATCH] D120948: Disable LLDB index cache for .o files with no UUID.

2022-03-03 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan added inline comments.



Comment at: lldb/include/lldb/Core/DataFileCache.h:127
+  /// unique idenifier like the UUID being valid.
+  bool IsValid() const { return m_uuid.hasValue(); }
 

yinghuitan wrote:
> Do we plan to ship with this design (no caching for module .o file without 
> uuid)? If so, I wonder if we should emit reason information for module not 
> loaded from cache (like signature mismatch/changed vs uuid unavailable)?
I mean emit not-load-from-cache reason in "statistics dump".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120948

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


[Lldb-commits] [PATCH] D120972: [lldb] Show progress events in the command line driver

2022-03-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 412937.
JDevlieghere marked 3 inline comments as done.
JDevlieghere added a comment.

- Fix typo
- Reduce stack size


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

https://reviews.llvm.org/D120972

Files:
  lldb/include/lldb/API/SBCommandInterpreterRunOptions.h
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/source/API/SBCommandInterpreterRunOptions.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Symbol/LocateSymbolFile.cpp
  lldb/tools/driver/Driver.cpp

Index: lldb/tools/driver/Driver.cpp
===
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -565,6 +565,7 @@
 m_debugger.SetAsync(false);
 
 SBCommandInterpreterRunOptions options;
+options.SetShowProgress(true);
 options.SetAutoHandleEvents(true);
 options.SetSpawnThread(false);
 options.SetStopOnError(true);
Index: lldb/source/Symbol/LocateSymbolFile.cpp
===
--- lldb/source/Symbol/LocateSymbolFile.cpp
+++ lldb/source/Symbol/LocateSymbolFile.cpp
@@ -10,6 +10,7 @@
 
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Progress.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -262,6 +263,10 @@
   FileSystem::Instance().Exists(symbol_file_spec))
 return symbol_file_spec;
 
+  Progress progress(llvm::formatv(
+  "Locating external symbol file for {0}",
+  module_spec.GetFileSpec().GetFilename().AsCString("")));
+
   FileSpecList debug_file_search_paths = default_search_paths;
 
   // Add module directory.
Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3283,6 +3283,9 @@
 
 CommandInterpreterRunResult CommandInterpreter::RunCommandInterpreter(
 CommandInterpreterRunOptions &options) {
+  if (options.GetShowProgress())
+m_debugger.StartProgressHandlerThread();
+
   // Always re-create the command interpreter when we run it in case any file
   // handles have changed.
   bool force_create = true;
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1719,6 +1719,68 @@
   return {};
 }
 
+lldb::thread_result_t Debugger::ProgressHandlerThread() {
+  // Only report progress for real terminals.
+  if (!GetOutputFile().GetIsRealTerminal())
+return {};
+
+  // Only report progress if nobody else is listening for it.
+  if (GetBroadcaster().EventTypeHasListeners(Debugger::eBroadcastBitProgress))
+return {};
+
+  ListenerSP listener_sp = Listener::MakeListener("lldb.progress.listener");
+  listener_sp->StartListeningForEvents(&m_broadcaster,
+   Debugger::eBroadcastBitProgress);
+
+  // Only handle one kind of event at the same time. Ignore events that come in
+  // in while the current event hasn't completed
+  llvm::Optional CurrentEventID;
+
+  // Assume that the if the terminal supports colors (ANSI escape codes) it
+  // also supports vt100 escape codes.
+  const bool use_vt100_escapes = GetOutputFile().GetIsTerminalWithColors();
+
+  while (true) {
+lldb::EventSP event_sp;
+if (listener_sp->GetEvent(event_sp, llvm::None)) {
+  if (!event_sp)
+continue;
+  if (auto *data = Debugger::ProgressEventData::GetEventDataFromEvent(
+  event_sp.get())) {
+
+uint64_t id = data->GetID();
+if (CurrentEventID) {
+  if (id != *CurrentEventID)
+continue;
+} else {
+  CurrentEventID = id;
+}
+
+std::string message = data->GetMessage();
+if (data->GetTotal() != UINT64_MAX) {
+  GetOutputFile().Printf("[%llu/%llu] %s\r", data->GetCompleted(),
+ data->GetTotal(), message.c_str());
+} else {
+  GetOutputFile().Printf("%s\r", message.c_str());
+}
+
+if (data->GetCompleted()) {
+  CurrentEventID.reset();
+  // Clear the current line. Use an escape character if supported,
+  // otherwise overwrite the line with a sequence of spaces.
+  if (use_vt100_escapes) {
+GetOutputFile().Printf("\33[2K\r");
+  } else {
+std::string clear(GetTerminalWidth(), ' ');
+GetOutputFile().Printf("%s\r", clear.c_str());
+  }
+}
+  }
+}
+  }
+  return {};
+}
+
 bool Debugger::HasIOHandlerThread() { return m_io_handler_thread.IsJoinable(); }
 
 bool Debugger::StartIOHandlerThread() {
@@ -1751,6 +1813,29 @@
   }
 }
 
+bool Debugger::StartPr

[Lldb-commits] [PATCH] D120972: [lldb] Show progress events in the command line driver

2022-03-03 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Core/Debugger.cpp:1822
+[this] { return ProgressHandlerThread(); },
+8 * 1024 * 1024); // Use larger 8MB stack for this thread
+if (progress_handler_thread) {

mib wrote:
> Why ?
I copied this from `StartIOHandlerThread`, but you're absolutely right, we 
don't need that big of stack to handle events.


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

https://reviews.llvm.org/D120972

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


[Lldb-commits] [PATCH] D120595: [WIP][trace][intelpt] Add TSC to Nanosecond conversion for IntelPT traces

2022-03-03 Thread David Carrillo Cisneros via Phabricator via lldb-commits
davidca added inline comments.
Herald added a project: All.



Comment at: lldb/docs/lldb-gdb-remote.txt:469
+//
+//tsc_rate: {
+//  kind: "perf",

why is all this called tsc rate? there is also offset in this conversion. What 
about something like tsc_conversion_params or tsc_conv



Comment at: lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h:44
+/// TSC to nanosecond conversion.
+class TimestampCounterRate {
+  public:

nit, Intel documentation and kernel refers this as TSC, not TimestampCounter, 
in order to differentiate this awful name from everywhere else that "Timestamp" 
and "Counter" is used. Perhaps embrace TSC to make it easier to google info?



Comment at: lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h:47
+virtual ~TimestampCounterRate() = default;
+/// Convert TSC value to nanoseconds. This represents the number of 
nanoseconds since
+/// the TSC register's reset.

wallace wrote:
> 
To be precise, it's number of nanoseconds since boot. You should also add that 
this nanoseconds clock is sched_clock 
https://www.kernel.org/doc/html/latest/timers/timekeeping.html

In fact, you may want to use sched_clock as the name for this clock, rather 
than Nanos as in the next lines.



Comment at: lldb/include/lldb/Utility/TraceIntelPTGDBRemotePackets.h:78-80
+bool fromJSON(const llvm::json::Value &value, TimestampCounterRateSP 
&tsc_converter, llvm::json::Path path);
+
+bool fromJSON(const llvm::json::Value &value, TraceIntelPTGetStateResponse 
&packet, llvm::json::Path path);

should this two be static factory methods?



Comment at: lldb/source/Plugins/Process/Linux/IntelPTManager.cpp:257
 
+  IntelPTManager::GetPerfTscRate(*m_mmap_meta);
+

wallace wrote:
> sadly you can't put this here. If you do this, then GetState() will only work 
> correctly if StartTrace() was invoked first. What if in the future we have a 
> different flow in which lldb-server uses an additional tracing function 
> besides StartTrace() and that new function forgets to set the tsc_rate?
> This is called coupling and should be avoided.
> 
> What you should do instead is to create a new static function called 
> `llvm::OptionalGetTscRate()` that will perform the 
> perf_event request or reuse a previously saved value. It should work 
> regardless of when it's invoked.
1) this is not a Get* method. This is populating a global. Get* are inexpensive 
methods that return a value.

2) if the TSC conversion parameters will be stored in a global, why not to use 
the Singleton pattern?

3) TSC parameters change over time. I really think that should be stored within 
IntelPTManager. Obtaining this parameters is a ~10 microseconds operation, so 
it's fine if they need to be read next time an IntelPTManager is created.



Comment at: lldb/source/Plugins/Process/Linux/IntelPTManager.h:211
   static bool IsSupported();
+  static void GetPerfTscRate(perf_event_mmap_page &mmap_meta);
+

wallace wrote:
> don't forget to add documentation here
how is ti


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

https://reviews.llvm.org/D120595

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