[Lldb-commits] [PATCH] D82835: [lldb] Fix missing characters when autocompleting LLDB commands in REPL

2020-06-29 Thread Martin Svensson via Phabricator via lldb-commits
poya created this revision.
poya added a reviewer: teemperor.
Herald added a project: LLDB.
poya added a comment.

Tests for the Swift REPL in https://github.com/apple/llvm-project/pull/1388


When tabbing to complete LLDB commands in REPL, characters would at best be 
missing but at worst cause the REPL to crash due to out of range string access.
This patch appends the command character to the completion results to fulfill 
the assumption that all matches are prefixed by the request's cursor argument 
prefix.

Bug report for the Swift REPL
https://bugs.swift.org/browse/SR-12867


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82835

Files:
  lldb/source/Expression/REPL.cpp


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -457,6 +457,12 @@
 debugger.GetCommandInterpreter().HandleCompletion(sub_request);
 StringList matches, descriptions;
 sub_result.GetMatches(matches);
+// Prepend command prefix that was excluded in the completion request
+if (request.GetCursorIndex() == 0) {
+  for (auto  : matches) {
+match.insert(0, 1, ':');
+  }
+}
 sub_result.GetDescriptions(descriptions);
 request.AddCompletions(matches, descriptions);
 return;


Index: lldb/source/Expression/REPL.cpp
===
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -457,6 +457,12 @@
 debugger.GetCommandInterpreter().HandleCompletion(sub_request);
 StringList matches, descriptions;
 sub_result.GetMatches(matches);
+// Prepend command prefix that was excluded in the completion request
+if (request.GetCursorIndex() == 0) {
+  for (auto  : matches) {
+match.insert(0, 1, ':');
+  }
+}
 sub_result.GetDescriptions(descriptions);
 request.AddCompletions(matches, descriptions);
 return;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D82835: [lldb] Fix missing characters when autocompleting LLDB commands in REPL

2020-06-29 Thread Martin Svensson via Phabricator via lldb-commits
poya added a comment.

Tests for the Swift REPL in https://github.com/apple/llvm-project/pull/1388


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82835



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


[Lldb-commits] [PATCH] D82813: [Apple Silicon] Rewrite part of the Rosetta support to be confined in Apple specific files

2020-06-29 Thread Davide Italiano via Phabricator via lldb-commits
davide marked an inline comment as done.
davide added inline comments.



Comment at: lldb/include/lldb/Host/Host.h:231
 
+  /// Check whether a process is translated (Rosetta).
+  /// \arg process_info The info structure for the process queried.

aprantl wrote:
> Is this supposed to be a generic function call that, e.g, should fire for 
> debugging a process in QEMU under Linux, or is it meant to specifically check 
> for Rosetta on macOS? The comment makes it sound like it's the latter and the 
> API name hints at the former. It would be nice to clarify this in the comment.
It is meant specifically for Rosetta, but this leaves in `Host`, so I decided 
for a generic name.
Do you have a better suggestion for the name or the comment ? Happy to go with 
it 


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

https://reviews.llvm.org/D82813



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


[Lldb-commits] [PATCH] D82804: Do not set LLDB_DEBUGSERVER_PATH if --out-of-tree-debugserver is passed.

2020-06-29 Thread Davide Italiano via Phabricator via lldb-commits
davide marked an inline comment as done.
davide added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:366
 
-if args.server:
+if args.server and not args.out_of_tree_debugserver:
 os.environ['LLDB_DEBUGSERVER_PATH'] = args.server

aprantl wrote:
> Does this have any surprising interplay with the existing 
> LLDB_USE_SYSTEM_DEBUGSERVER cmake flag?
I don't think so?


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

https://reviews.llvm.org/D82804



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


[Lldb-commits] [PATCH] D82804: Do not set LLDB_DEBUGSERVER_PATH if --out-of-tree-debugserver is passed.

2020-06-29 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:366
 
-if args.server:
+if args.server and not args.out_of_tree_debugserver:
 os.environ['LLDB_DEBUGSERVER_PATH'] = args.server

aprantl wrote:
> davide wrote:
> > aprantl wrote:
> > > Does this have any surprising interplay with the existing 
> > > LLDB_USE_SYSTEM_DEBUGSERVER cmake flag?
> > I don't think so?
> Great. The name made it sound dangerous!
This actually gets rid of some surprising interplay between --server and 
--out-of-tree-debugserver.

That surprising situation arises due to the fact that the Rosetta debugserver 
is not built as part of lldb. I.e. when we need to run tests on Apple Silicon 
under x86_64 emulation, we still build debugserver as arm64 (if at all).

Now, at some point, it was common practice for lldb-dotest to always set 
--server to path/to/native/build/debugserver: this would break testing under 
Rosetta emulation, because the arm64 debugserver couldn't interoperate with the 
emulator.

So that's why it was necessary to prevent --server and 
--out-of-tree-debugserver from both being in effect at the same time.



Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:366
 
-if args.server:
+if args.server and not args.out_of_tree_debugserver:
 os.environ['LLDB_DEBUGSERVER_PATH'] = args.server

vsk wrote:
> aprantl wrote:
> > davide wrote:
> > > aprantl wrote:
> > > > Does this have any surprising interplay with the existing 
> > > > LLDB_USE_SYSTEM_DEBUGSERVER cmake flag?
> > > I don't think so?
> > Great. The name made it sound dangerous!
> This actually gets rid of some surprising interplay between --server and 
> --out-of-tree-debugserver.
> 
> That surprising situation arises due to the fact that the Rosetta debugserver 
> is not built as part of lldb. I.e. when we need to run tests on Apple Silicon 
> under x86_64 emulation, we still build debugserver as arm64 (if at all).
> 
> Now, at some point, it was common practice for lldb-dotest to always set 
> --server to path/to/native/build/debugserver: this would break testing under 
> Rosetta emulation, because the arm64 debugserver couldn't interoperate with 
> the emulator.
> 
> So that's why it was necessary to prevent --server and 
> --out-of-tree-debugserver from both being in effect at the same time.
Now that I think about this a bit more, it could be a good idea to log a 
warning when args.out_of_tree_debugserver and args.server are both set.


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

https://reviews.llvm.org/D82804



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


[Lldb-commits] [PATCH] D82813: [Apple Silicon] Rewrite part of the Rosetta support to be confined in Apple specific files

2020-06-29 Thread Davide Italiano via Phabricator via lldb-commits
davide marked an inline comment as done.
davide added inline comments.



Comment at: lldb/include/lldb/Host/Host.h:231
 
+  /// Run a shell command.
+  /// \arg process_info The info structure for the process queried.

Stale comment, I'll update


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

https://reviews.llvm.org/D82813



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


[Lldb-commits] [PATCH] D82813: [Apple Silicon] Rewrite part of the Rosetta support to be confined in Apple specific files

2020-06-29 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added reviewers: aprantl, jasonmolenda.

Nothing crazy here, just an organizational cleanup.


https://reviews.llvm.org/D82813

Files:
  lldb/include/lldb/Host/Host.h
  lldb/source/Host/common/Host.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -17,9 +17,6 @@
 #include 
 #endif
 #include 
-#if defined(__APPLE__)
-#include 
-#endif
 #include 
 #include 
 
@@ -3420,22 +3417,13 @@
 std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4), false);
 debugserver_launch_info.SetUserID(process_info.GetUserID());
 
-#if defined(__APPLE__)
 // On macOS 11, we need to support x86_64 applications translated to
 // arm64. We check whether a binary is translated and spawn the correct
 // debugserver accordingly.
-int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
-  static_cast(process_info.GetProcessID()) };
-struct kinfo_proc processInfo;
-size_t bufsize = sizeof(processInfo);
-if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), ,
-   , NULL, 0) == 0 && bufsize > 0) {
-  if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
-FileSpec 
rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
-debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
-  }
+if (Host::IsProcessTranslated(process_info)) {
+  FileSpec 
rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
+  debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
 }
-#endif
 
 int communication_fd = -1;
 #ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -1462,3 +1462,14 @@
 ::asl_vlog(NULL, g_aslmsg, asl_level, format, args);
   }
 }
+
+bool Host::IsProcessTranslated(const ProcessInfo _info) {
+  int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
+static_cast(process_info.GetProcessID()) };
+  struct kinfo_proc processInfo;
+  size_t bufsize = sizeof(processInfo);
+  if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), ,
+ , NULL, 0) == 0 && bufsize <= 0)
+return false;
+  return processInfo.kp_proc.p_flag & P_TRANSLATED;
+}
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -414,6 +414,10 @@
 }
 
 bool Host::ResolveExecutableInBundle(FileSpec ) { return false; }
+
+bool Host::IsProcessTranslated(const ProcessInfo _info) {
+  return false;
+}
 #endif
 
 #ifndef _WIN32
Index: lldb/include/lldb/Host/Host.h
===
--- lldb/include/lldb/Host/Host.h
+++ lldb/include/lldb/Host/Host.h
@@ -228,6 +228,10 @@
   static bool OpenFileInExternalEditor(const FileSpec _spec,
uint32_t line_no);
 
+  /// Run a shell command.
+  /// \arg process_info The info structure for the process queried.
+  static bool IsProcessTranslated(const ProcessInfo _info);
+
   static Environment GetEnvironment();
 
   static std::unique_ptr


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -17,9 +17,6 @@
 #include 
 #endif
 #include 
-#if defined(__APPLE__)
-#include 
-#endif
 #include 
 #include 
 
@@ -3420,22 +3417,13 @@
 std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4), false);
 debugserver_launch_info.SetUserID(process_info.GetUserID());
 
-#if defined(__APPLE__)
 // On macOS 11, we need to support x86_64 applications translated to
 // arm64. We check whether a binary is translated and spawn the correct
 // debugserver accordingly.
-int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
-  static_cast(process_info.GetProcessID()) };
-struct kinfo_proc processInfo;
-size_t bufsize = sizeof(processInfo);
-if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), ,
-   , NULL, 0) == 0 && bufsize > 0) {
-  if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
-FileSpec rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
-debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
-  }
+if (Host::IsProcessTranslated(process_info)) {
+  FileSpec 

[Lldb-commits] [PATCH] D82491: [Apple Silicon] Initial support for Rosetta

2020-06-29 Thread Davide Italiano via Phabricator via lldb-commits
davide marked an inline comment as done.
davide added inline comments.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:3444
+size_t bufsize = sizeof(processInfo);
+if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), ,
+   , NULL, 0) == 0 && bufsize > 0) {

echristo wrote:
> JDevlieghere wrote:
> > The `sysctl` call seems like something that would fit into host, we already 
> > have a bunch of those in `Host.mm`. Should we create a function there that 
> > returns whether a given pid runs under Rosetta?
> Agreed. That seems much cleaner.
https://reviews.llvm.org/D82813


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

https://reviews.llvm.org/D82491



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


[Lldb-commits] [PATCH] D82813: [Apple Silicon] Rewrite part of the Rosetta support to be confined in Apple specific files

2020-06-29 Thread Davide Italiano via Phabricator via lldb-commits
davide updated this revision to Diff 274253.

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

https://reviews.llvm.org/D82813

Files:
  lldb/include/lldb/Host/Host.h
  lldb/source/Host/common/Host.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -17,9 +17,6 @@
 #include 
 #endif
 #include 
-#if defined(__APPLE__)
-#include 
-#endif
 #include 
 #include 
 
@@ -3420,22 +3417,13 @@
 std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4), false);
 debugserver_launch_info.SetUserID(process_info.GetUserID());
 
-#if defined(__APPLE__)
 // On macOS 11, we need to support x86_64 applications translated to
 // arm64. We check whether a binary is translated and spawn the correct
 // debugserver accordingly.
-int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
-  static_cast(process_info.GetProcessID()) };
-struct kinfo_proc processInfo;
-size_t bufsize = sizeof(processInfo);
-if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), ,
-   , NULL, 0) == 0 && bufsize > 0) {
-  if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
-FileSpec 
rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
-debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
-  }
+if (Host::IsProcessTranslated(process_info)) {
+  FileSpec 
rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
+  debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
 }
-#endif
 
 int communication_fd = -1;
 #ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -1462,3 +1462,14 @@
 ::asl_vlog(NULL, g_aslmsg, asl_level, format, args);
   }
 }
+
+bool Host::IsProcessTranslated(const ProcessInfo _info) {
+  int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
+static_cast(process_info.GetProcessID()) };
+  struct kinfo_proc processInfo;
+  size_t bufsize = sizeof(processInfo);
+  if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), ,
+ , NULL, 0) == 0 && bufsize <= 0)
+return false;
+  return processInfo.kp_proc.p_flag & P_TRANSLATED;
+}
Index: lldb/source/Host/common/Host.cpp
===
--- lldb/source/Host/common/Host.cpp
+++ lldb/source/Host/common/Host.cpp
@@ -414,6 +414,10 @@
 }
 
 bool Host::ResolveExecutableInBundle(FileSpec ) { return false; }
+
+bool Host::IsProcessTranslated(const ProcessInfo _info) {
+  return false;
+}
 #endif
 
 #ifndef _WIN32
Index: lldb/include/lldb/Host/Host.h
===
--- lldb/include/lldb/Host/Host.h
+++ lldb/include/lldb/Host/Host.h
@@ -228,6 +228,10 @@
   static bool OpenFileInExternalEditor(const FileSpec _spec,
uint32_t line_no);
 
+  /// Check whether a process is translated (Rosetta).
+  /// \arg process_info The info structure for the process queried.
+  static bool IsProcessTranslated(const ProcessInfo _info);
+
   static Environment GetEnvironment();
 
   static std::unique_ptr


Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -17,9 +17,6 @@
 #include 
 #endif
 #include 
-#if defined(__APPLE__)
-#include 
-#endif
 #include 
 #include 
 
@@ -3420,22 +3417,13 @@
 std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4), false);
 debugserver_launch_info.SetUserID(process_info.GetUserID());
 
-#if defined(__APPLE__)
 // On macOS 11, we need to support x86_64 applications translated to
 // arm64. We check whether a binary is translated and spawn the correct
 // debugserver accordingly.
-int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
-  static_cast(process_info.GetProcessID()) };
-struct kinfo_proc processInfo;
-size_t bufsize = sizeof(processInfo);
-if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), ,
-   , NULL, 0) == 0 && bufsize > 0) {
-  if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
-FileSpec rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
-debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
-  }
+if (Host::IsProcessTranslated(process_info)) {
+  FileSpec 

[Lldb-commits] [PATCH] D82804: Do not set LLDB_DEBUGSERVER_PATH if --out-of-tree-debugserver is passed.

2020-06-29 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:366
 
-if args.server:
+if args.server and not args.out_of_tree_debugserver:
 os.environ['LLDB_DEBUGSERVER_PATH'] = args.server

Does this have any surprising interplay with the existing 
LLDB_USE_SYSTEM_DEBUGSERVER cmake flag?


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

https://reviews.llvm.org/D82804



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


[Lldb-commits] [PATCH] D82813: [Apple Silicon] Rewrite part of the Rosetta support to be confined in Apple specific files

2020-06-29 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Host/macosx/objcxx/Host.mm:1471
+  size_t bufsize = sizeof(processInfo);
+  if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), ,
+ , NULL, 0) == 0 && bufsize <= 0)

nit: `static_cast` for consistency with line 1468?



Comment at: lldb/source/Host/macosx/objcxx/Host.mm:1472
+  if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), ,
+ , NULL, 0) == 0 && bufsize <= 0)
+return false;

nit: `nullptr`


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

https://reviews.llvm.org/D82813



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


[Lldb-commits] [PATCH] D82804: Do not set LLDB_DEBUGSERVER_PATH if --out-of-tree-debugserver is passed.

2020-06-29 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/packages/Python/lldbsuite/test/dotest.py:366
 
-if args.server:
+if args.server and not args.out_of_tree_debugserver:
 os.environ['LLDB_DEBUGSERVER_PATH'] = args.server

davide wrote:
> aprantl wrote:
> > Does this have any surprising interplay with the existing 
> > LLDB_USE_SYSTEM_DEBUGSERVER cmake flag?
> I don't think so?
Great. The name made it sound dangerous!


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

https://reviews.llvm.org/D82804



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


[Lldb-commits] [PATCH] D82813: [Apple Silicon] Rewrite part of the Rosetta support to be confined in Apple specific files

2020-06-29 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/include/lldb/Host/Host.h:231
 
+  /// Check whether a process is translated (Rosetta).
+  /// \arg process_info The info structure for the process queried.

Is this supposed to be a generic function call that, e.g, should fire for 
debugging a process in QEMU under Linux, or is it meant to specifically check 
for Rosetta on macOS? The comment makes it sound like it's the latter and the 
API name hints at the former. It would be nice to clarify this in the comment.


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

https://reviews.llvm.org/D82813



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


[Lldb-commits] [PATCH] D82804: Do not set LLDB_DEBUGSERVER_PATH if --out-of-tree-debugserver is passed.

2020-06-29 Thread Davide Italiano via Phabricator via lldb-commits
davide created this revision.
davide added reviewers: vsk, aprantl, jasonmolenda.

Now that there are two implementations of debugserver, one for native and the 
other for Rosetta [on Apple Silicon], this is needed.


https://reviews.llvm.org/D82804

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -363,7 +363,7 @@
 args.executable)
 sys.exit(-1)
 
-if args.server:
+if args.server and not args.out_of_tree_debugserver:
 os.environ['LLDB_DEBUGSERVER_PATH'] = args.server
 
 if args.excluded:


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -363,7 +363,7 @@
 args.executable)
 sys.exit(-1)
 
-if args.server:
+if args.server and not args.out_of_tree_debugserver:
 os.environ['LLDB_DEBUGSERVER_PATH'] = args.server
 
 if args.excluded:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c48ccb6 - Simplify conditionals in DNBArchMachARM64::EnableHardwareSingleStep

2020-06-29 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2020-06-29T14:04:44-07:00
New Revision: c48ccb6b4e513e467b22fab1de57a25c23af4361

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

LOG: Simplify conditionals in DNBArchMachARM64::EnableHardwareSingleStep

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index 3e7bda88e6af..7e1af7a75021 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -590,23 +590,21 @@ kern_return_t 
DNBArchMachARM64::EnableHardwareSingleStep(bool enable) {
 return err.Status();
   }
 
-  if (enable) {
-DNBLogThreadedIf(LOG_STEP,
- "%s: Setting MDSCR_EL1 Single Step bit at pc 0x%llx",
 #if defined(__LP64__)
- __FUNCTION__, (uint64_t)arm_thread_state64_get_pc 
(m_state.context.gpr));
+  uint64_t pc = arm_thread_state64_get_pc (m_state.context.gpr);
 #else
- __FUNCTION__, (uint64_t)m_state.context.gpr.__pc);
+  uint64_t pc = m_state.context.gpr.__pc;
 #endif
+
+  if (enable) {
+DNBLogThreadedIf(LOG_STEP,
+ "%s: Setting MDSCR_EL1 Single Step bit at pc 0x%llx",
+ __FUNCTION__, pc);
 m_state.dbg.__mdscr_el1 |= SS_ENABLE;
   } else {
 DNBLogThreadedIf(LOG_STEP,
  "%s: Clearing MDSCR_EL1 Single Step bit at pc 0x%llx",
-#if defined(__LP64__)
- __FUNCTION__, (uint64_t)arm_thread_state64_get_pc 
(m_state.context.gpr));
-#else
- __FUNCTION__, (uint64_t)m_state.context.gpr.__pc);
-#endif
+ __FUNCTION__, pc);
 m_state.dbg.__mdscr_el1 &= ~(SS_ENABLE);
   }
 



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


[Lldb-commits] [lldb] 300bbbc - [ProcessGDBRemote] Get rid of an unused function.

2020-06-29 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-06-29T12:39:09-07:00
New Revision: 300bbbcb707ad08200543735326982664136d3bc

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

LOG: [ProcessGDBRemote] Get rid of an unused function.

The define was wrong. I could've fixed it, but given this is
unused I decided to drop the function altogether.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 39e97c92e343..ff263fa16258 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -189,21 +189,6 @@ static const ProcessKDPPropertiesSP 
() {
 #define HIGH_PORT (49151u)
 #endif
 
-#if defined(__APPLE__) &&  
\
-(defined(__arm__) || defined(__arm64__) || defined(__aarch64__))
-static bool rand_initialized = false;
-
-static inline uint16_t get_random_port() {
-  if (!rand_initialized) {
-time_t seed = time(NULL);
-
-rand_initialized = true;
-srand(seed);
-  }
-  return (rand() % (HIGH_PORT - LOW_PORT)) + LOW_PORT;
-}
-#endif
-
 ConstString ProcessGDBRemote::GetPluginNameStatic() {
   static ConstString g_name("gdb-remote");
   return g_name;



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


[Lldb-commits] [PATCH] D82772: [lldb] Fix type conversion in the Scalar getters

2020-06-29 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

+ Ismail as he looked at this recently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82772



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


[Lldb-commits] [PATCH] D82759: [lldb/Test] Introduce "assertSuccess"

2020-06-29 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.

Looks like a great improvement!

At some point we should document our custom methods in 
https://lldb.llvm.org/resources/test.html to make them more discoverable, but 
that's orthogonal to this patch.




Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:2537
+def assertSuccess(self, obj, msg=None):
+if not obj.Success():
+error = obj.GetCString()

I'm not actually sure this works for custom types, but should we add an `assert 
isinstance(obj, lldb.SBError)` to avoid misuse?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82759



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


[Lldb-commits] [lldb] 3936b75 - [LLDB] skip TestCreateDuringInstructionStep on aarch64/linux

2020-06-29 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2020-06-29T21:32:48+05:00
New Revision: 3936b753bacc17aae4bb421bd8a27f428a9a4173

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

LOG: [LLDB] skip TestCreateDuringInstructionStep on aarch64/linux

TestCreateDuringInstructionStep have started failing again on
aarch64/linux after moving to new machine. I am going mark it skipped
for aarch64/linux.

Added: 


Modified: 

lldb/test/API/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py

Removed: 




diff  --git 
a/lldb/test/API/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py
 
b/lldb/test/API/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py
index 6e19aa830cd3..92384e1c5078 100644
--- 
a/lldb/test/API/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py
+++ 
b/lldb/test/API/linux/thread/create_during_instruction_step/TestCreateDuringInstructionStep.py
@@ -4,7 +4,6 @@
 """
 
 
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -18,7 +17,7 @@ class CreateDuringInstructionStepTestCase(TestBase):
 
 @skipUnlessPlatform(['linux'])
 @expectedFailureAndroid('llvm.org/pr24737', archs=['arm'])
-@skipIf(oslist=["linux"], archs=["arm"], bugnumber="llvm.org/pr24737")
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"], 
bugnumber="llvm.org/pr24737")
 def test_step_inst(self):
 self.build(dictionary=self.getBuildFlags())
 exe = self.getBuildArtifact("a.out")



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


[Lldb-commits] [PATCH] D82772: [lldb] Fix type conversion in the Scalar getters

2020-06-29 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: teemperor, JDevlieghere.
Herald added a project: LLDB.

The Scalar class claims to follow the C type conversion rules. This is
true for the Promote function, but it is not true for the implicit
conversions done in the getter methods.

These functions had a subtle bug: when extending the type, they used the
signedness of the *target* type in order to determine whether to do
sign-extension or zero-extension. This is not how things work in C,
which uses the signedness of the *source* type. I.e., C does
(sign-)extension before it does signed->unsigned conversion, and not the
other way around.

This means that: (unsigned long)(int)-1

  is equal to (unsigned long)0x
  and not (unsigned long)0x

Unsurprisingly, we have accumulated code which depended on this
inconsistent behavior. It mainly manifested itself as code calling
"ULongLong/SLongLong" as a way to get the value of the Scalar object in
a primitive type that is "large enough". Previously, the ULongLong
conversion did not do sign-extension, but now it does.

This patch makes the Scalar getters consistent with the declared
semantics, and fixes the couple of call sites that were using it
incorrectly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82772

Files:
  lldb/include/lldb/Utility/Scalar.h
  lldb/source/Core/ValueObject.cpp
  lldb/source/Expression/IRInterpreter.cpp
  lldb/source/Utility/Scalar.cpp
  lldb/test/API/commands/expression/ir-interpreter/TestIRInterpreter.py
  lldb/unittests/Utility/ScalarTest.cpp

Index: lldb/unittests/Utility/ScalarTest.cpp
===
--- lldb/unittests/Utility/ScalarTest.cpp
+++ lldb/unittests/Utility/ScalarTest.cpp
@@ -66,6 +66,44 @@
   ASSERT_TRUE(s2 >= s1);
 }
 
+template 
+static T2 ConvertHost(T1 val, T2 (Scalar::*)(T2) const) {
+  return T2(val);
+}
+
+template 
+static T2 ConvertScalar(T1 val, T2 (Scalar::*conv)(T2) const) {
+  return (Scalar(val).*conv)(T2());
+}
+
+template
+static void CheckConversion(T val) {
+  SCOPED_TRACE("val = " + std::to_string(val));
+  EXPECT_EQ((signed char)val, Scalar(val).SChar());
+  EXPECT_EQ((unsigned char)val, Scalar(val).UChar());
+  EXPECT_EQ((short)val, Scalar(val).SShort());
+  EXPECT_EQ((unsigned short)val, Scalar(val).UShort());
+  EXPECT_EQ((int)val, Scalar(val).SInt());
+  EXPECT_EQ((unsigned)val, Scalar(val).UInt());
+  EXPECT_EQ((long)val, Scalar(val).SLong());
+  EXPECT_EQ((unsigned long)val, Scalar(val).ULong());
+  EXPECT_EQ((long long)val, Scalar(val).SLongLong());
+  EXPECT_EQ((unsigned long long)val, Scalar(val).ULongLong());
+  EXPECT_NEAR((float)val, Scalar(val).Float(), std::abs(val/1e6));
+  EXPECT_NEAR((double)val, Scalar(val).Double(), std::abs(val/1e12));
+}
+
+TEST(ScalarTest, Getters) {
+  CheckConversion((int)0x87654321);
+  CheckConversion((unsigned int)0x87654321u);
+  CheckConversion((long)0x87654321l);
+  CheckConversion((unsigned long)0x87654321ul);
+  CheckConversion((long long)0x8765432112345678ll);
+  CheckConversion((unsigned long long)0x8765432112345678ull);
+  CheckConversion((float)42.25f);
+  CheckConversion((double)42.25);
+}
+
 TEST(ScalarTest, RightShiftOperator) {
   int a = 0x1000;
   int b = 0x;
@@ -324,11 +362,11 @@
 TEST(ScalarTest, TruncOrExtendTo) {
   Scalar S(0x);
   S.TruncOrExtendTo(12, true);
-  EXPECT_EQ(S.ULong(), 0xfffu);
+  EXPECT_EQ(S.UInt128(APInt()), APInt(12, 0xfffu));
   S.TruncOrExtendTo(20, true);
-  EXPECT_EQ(S.ULong(), 0xfu);
+  EXPECT_EQ(S.UInt128(APInt()), APInt(20, 0xfu));
   S.TruncOrExtendTo(24, false);
-  EXPECT_EQ(S.ULong(), 0x0fu);
+  EXPECT_EQ(S.UInt128(APInt()), APInt(24, 0x0fu));
   S.TruncOrExtendTo(16, false);
-  EXPECT_EQ(S.ULong(), 0xu);
+  EXPECT_EQ(S.UInt128(APInt()), APInt(16, 0xu));
 }
Index: lldb/test/API/commands/expression/ir-interpreter/TestIRInterpreter.py
===
--- lldb/test/API/commands/expression/ir-interpreter/TestIRInterpreter.py
+++ lldb/test/API/commands/expression/ir-interpreter/TestIRInterpreter.py
@@ -51,7 +51,8 @@
 options = lldb.SBExpressionOptions()
 options.SetLanguage(lldb.eLanguageTypeC_plus_plus)
 
-set_up_expressions = ["int $i = 9", "int $j = 3", "int $k = 5"]
+set_up_expressions = ["int $i = 9", "int $j = 3", "int $k = 5",
+"unsigned long long $ull = -1", "unsigned $u = -1"]
 
 expressions = ["$i + $j",
"$i - $j",
@@ -61,7 +62,8 @@
"$i << $j",
"$i & $j",
"$i | $j",
-   "$i ^ $j"]
+   "$i ^ $j",
+   "($ull & -1) == $u"]
 
 for expression in set_up_expressions:
 self.frame().EvaluateExpression(expression, options)
Index: lldb/source/Utility/Scalar.cpp

[Lldb-commits] [lldb] 6292702 - [lldb/Test] Skip TestVSCode_disconnect on Darwin

2020-06-29 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-06-29T07:48:09-07:00
New Revision: 6292702d1231378f86a0560a68603fd006911f2f

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

LOG: [lldb/Test] Skip TestVSCode_disconnect on Darwin

It's failing on the sanitized bot on GreenDragon.

Added: 


Modified: 
lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py 
b/lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
index 2a4103a344a4..cc001e89196b 100644
--- a/lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
+++ b/lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
@@ -26,6 +26,7 @@ def disconnect_and_assert_no_output_printed(self):
 output = self.get_stdout()
 self.assertTrue(output is None or len(output) == 0)
 
+@skipIfDarwin
 @skipIfWindows
 @skipIfRemote
 def test_launch(self):
@@ -47,6 +48,7 @@ def test_launch(self):
 self.assertFalse(os.path.exists(program + ".side_effect"))
 
 
+@skipIfDarwin
 @skipIfWindows
 @skipIfRemote
 def test_attach(self):



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


[Lldb-commits] [lldb] 48ca155 - [lldb] Deduplicate Scalar integral getters

2020-06-29 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-06-29T15:24:39+02:00
New Revision: 48ca15592f16fb6d8e2cef112f14345738e29cf4

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

LOG: [lldb] Deduplicate Scalar integral getters

These functions all follow the same pattern. Use template functions to
deduplicate.

Added: 


Modified: 
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Scalar.h 
b/lldb/include/lldb/Utility/Scalar.h
index eda7528a9212..566c52c14a8d 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -188,7 +188,7 @@ class Scalar {
 
   unsigned char UChar(unsigned char fail_value = 0) const;
 
-  signed char SChar(char fail_value = 0) const;
+  signed char SChar(signed char fail_value = 0) const;
 
   unsigned short UShort(unsigned short fail_value = 0) const;
 
@@ -204,7 +204,7 @@ class Scalar {
 
   unsigned long long ULongLong(unsigned long long fail_value = 0) const;
 
-  llvm::APInt SInt128(llvm::APInt _value) const;
+  llvm::APInt SInt128(const llvm::APInt _value) const;
 
   llvm::APInt UInt128(const llvm::APInt _value) const;
 
@@ -267,6 +267,9 @@ class Scalar {
   llvm::APInt m_integer;
   llvm::APFloat m_float;
 
+  template  T GetAsSigned(T fail_value) const;
+  template  T GetAsUnsigned(T fail_value) const;
+
 private:
   friend const Scalar operator+(const Scalar , const Scalar );
   friend const Scalar operator-(const Scalar , const Scalar );

diff  --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index e9e4103676b9..610c935409ac 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -644,7 +644,7 @@ bool Scalar::MakeUnsigned() {
   return success;
 }
 
-signed char Scalar::SChar(char fail_value) const {
+template  T Scalar::GetAsSigned(T fail_value) const {
   switch (m_type) {
   case e_void:
 break;
@@ -660,21 +660,21 @@ signed char Scalar::SChar(char fail_value) const {
   case e_uint256:
   case e_sint512:
   case e_uint512:
-return static_cast(
-(m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue());
+return m_integer.sextOrTrunc(sizeof(T) * 8).getSExtValue();
+
   case e_float:
-return static_cast(m_float.convertToFloat());
+return static_cast(m_float.convertToFloat());
   case e_double:
-return static_cast(m_float.convertToDouble());
+return static_cast(m_float.convertToDouble());
   case e_long_double:
 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
-return static_cast(
+return static_cast(
 (ldbl_val.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue());
   }
   return fail_value;
 }
 
-unsigned char Scalar::UChar(unsigned char fail_value) const {
+template  T Scalar::GetAsUnsigned(T fail_value) const {
   switch (m_type) {
   case e_void:
 break;
@@ -690,266 +690,56 @@ unsigned char Scalar::UChar(unsigned char fail_value) 
const {
   case e_uint256:
   case e_sint512:
   case e_uint512:
-return static_cast(
-(m_integer.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue());
+return m_integer.zextOrTrunc(sizeof(T) * 8).getZExtValue();
+
   case e_float:
-return static_cast(m_float.convertToFloat());
+return static_cast(m_float.convertToFloat());
   case e_double:
-return static_cast(m_float.convertToDouble());
+return static_cast(m_float.convertToDouble());
   case e_long_double:
 llvm::APInt ldbl_val = m_float.bitcastToAPInt();
-return static_cast(
-(ldbl_val.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue());
+return static_cast((ldbl_val.zextOrTrunc(sizeof(T) * 
8)).getZExtValue());
   }
   return fail_value;
 }
 
+signed char Scalar::SChar(signed char fail_value) const {
+  return GetAsSigned(fail_value);
+}
+
+unsigned char Scalar::UChar(unsigned char fail_value) const {
+  return GetAsUnsigned(fail_value);
+}
+
 short Scalar::SShort(short fail_value) const {
-  switch (m_type) {
-  case e_void:
-break;
-  case e_sint:
-  case e_uint:
-  case e_slong:
-  case e_ulong:
-  case e_slonglong:
-  case e_ulonglong:
-  case e_sint128:
-  case e_uint128:
-  case e_sint256:
-  case e_uint256:
-  case e_sint512:
-  case e_uint512:
-return static_cast(
-(m_integer.sextOrTrunc(sizeof(sshort_t) * 8)).getSExtValue());
-  case e_float:
-return static_cast(m_float.convertToFloat());
-  case e_double:
-return static_cast(m_float.convertToDouble());
-  case e_long_double:
-llvm::APInt ldbl_val = m_float.bitcastToAPInt();
-return static_cast(
-(ldbl_val.sextOrTrunc(sizeof(sshort_t) * 8)).getSExtValue());
-  }
-  return fail_value;
+  return GetAsSigned(fail_value);
 }
 
 unsigned short Scalar::UShort(unsigned short fail_value) const {
-  switch (m_type) {
-  case 

[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

In D74136#2119549 , @labath wrote:

> At this point I'm getting very lost in this patch,


Me too, as you stated:

In D74136#2020245 , @labath wrote:

> In D74136#1983467 , @kwk wrote:
>
> > I will obviously rename `SearchFilterByModuleListAndCU` but that can come 
> > in a child revision.
>


...

> I think it'd be best to do the rename as a part of this patch.

So I have to always undo the renaming before understanding what the patch does 
now. It would be nice if you could take back the merge of renaming.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136



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


[Lldb-commits] [PATCH] D82759: [lldb/Test] Introduce "assertSuccess"

2020-06-29 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: teemperor, JDevlieghere.
Herald added a subscriber: arphaman.
Herald added a project: LLDB.

A lot of our tests do 'self.assertTrue(error.Success()'. The problem
with that is that when this fails, it produces a completely useless
error message (False is not True) and the most important piece of
information -- the actual error message -- is completely hidden.

Sometimes we mitigate that by including the error message in the "msg"
argument, but this has two additional problems:

- as the msg argument is evaluated unconditionally, one needs to be careful to 
not trigger an exception when the operation was actually successful.
- it requires more typing, which means we often don't do it

assertSuccess solves these problems by taking the entire SBError object
as an argument. If the operation was unsuccessful, it can format a
reasonable error message itself. The function still accepts a "msg"
argument, which can include any additional context, but this context now
does not need to include the error message.

To demonstrate usage, I replace a number of existing assertTrue
assertions with the new function. As this process is not easily
automatable, I have just manually updated a representative sample. In
some cases, I did not update the code to use assertSuccess, but I went
for even higher-level assertion apis (runCmd, expect_expr), as these are
even shorter, and can produce even better failure messages.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82759

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py
  lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py
  lldb/test/API/commands/expression/context-object-objc/TestContextObjectObjc.py
  lldb/test/API/commands/expression/context-object/TestContextObject.py
  lldb/test/API/commands/expression/dont_allow_jit/TestAllowJIT.py
  lldb/test/API/commands/expression/fixits/TestFixIts.py
  lldb/test/API/commands/expression/options/TestExprOptions.py
  lldb/test/API/commands/expression/pr35310/TestExprsBug35310.py
  lldb/test/API/commands/expression/result_numbering/TestResultNumbering.py
  lldb/test/API/commands/expression/scoped_enums/TestScopedEnumType.py
  lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py
  lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py
  lldb/test/API/commands/expression/weak_symbols/TestWeakSymbols.py
  lldb/test/API/commands/register/register/register_command/TestRegisters.py
  
lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
  lldb/test/API/python_api/hello_world/TestHelloWorld.py

Index: lldb/test/API/python_api/hello_world/TestHelloWorld.py
===
--- lldb/test/API/python_api/hello_world/TestHelloWorld.py
+++ lldb/test/API/python_api/hello_world/TestHelloWorld.py
@@ -142,7 +142,8 @@
 target.ConnectRemote(listener, None, None, error)
 
 process = target.AttachToProcessWithName(listener, name, False, error)
-self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
+self.assertSuccess(error)
+self.assertTrue(process, PROCESS_IS_VALID)
 
 # Verify that after attach, our selected target indeed matches name.
 self.expect(
Index: lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
===
--- lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
+++ lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
@@ -57,47 +57,26 @@
 
 new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
 self.dbg.SetSelectedPlatform(new_platform)
-interpreter = self.dbg.GetCommandInterpreter()
 
 connect_url = "%s://%s:%s" % (protocol, hostname, str(hostport+1))
 
-command = "platform connect %s" % (connect_url)
-
-result = lldb.SBCommandReturnObject()
-
 # Test the default setting.
-interpreter.HandleCommand("settings show target.auto-install-main-executable", result)
-self.assertTrue(
-result.Succeeded() and
-"target.auto-install-main-executable (boolean) = true" in result.GetOutput(),
-"Default settings for target.auto-install-main-executable failed.: %s - %s" %
-(result.GetOutput(), result.GetError()))
+self.expect("settings show target.auto-install-main-executable",
+substrs=["target.auto-install-main-executable (boolean) = true"],
+msg="Default settings for target.auto-install-main-executable failed.")
 
 # Disable the auto install.
-interpreter.HandleCommand("settings set target.auto-install-main-executable false", result)
-

[Lldb-commits] [PATCH] D82064: [ARM64] Add QEMU testing environment setup guide for SVE testing

2020-06-29 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

In D82064#2113851 , @rovka wrote:

> Hi Omair,
>
> If this is intended to be more generally useful, I wonder if we should rename 
> it to something else (e.g. lldb-qemu-howto.txt) and only use AArch64 SVE as a 
> case study.
>
> In any case, thanks for writing this up!


Thanks Rovka, I ll generalize this doc and correct the pointed issues in next 
update.


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

https://reviews.llvm.org/D82064



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


[Lldb-commits] [PATCH] D77047: AArch64 SVE register infos and core file support

2020-06-29 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I'm worried about the confusing relationship between 
`RegisterInfos_arm64_sve.h` and `RegisterInfos_arm64.h` and the overlap in the 
register numbers it enforces. when we discussed this last time, my 
understanding was that the sve registers could be inserted _before_ the debug 
registers (similar to what happened with D24255 
). Now I see that may not be possible because 
some of these registers are used in the darwin arm64 register context. However, 
that makes the whole idea much less appealing.

Would it be possible to organize these headers like this:

- create a new header which holds common register definitions: this would be 
register numbers for the gpr and fpr registers (and their respective 
`_contains` arrays).
- have `RegisterInfos_arm64_sve.h` include this header and provide additional 
register definitions, and define its RegisterInfo array to match
- have `RegisterInfos_arm64.h` to the same

What I am hoping to achieve this way is to remove the 
`DECLARE_REGISTER_INFOS_ARM64_SVE_STRUCT` condition macro (dragons (ODR 
violations) lie there), and the duplicate enum values associated with it.


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

https://reviews.llvm.org/D77047



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


[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-29 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

At this point I'm getting very lost in this patch, but here's some of my 
thoughs (the ones I could actually formulate in a coherent manner)...




Comment at: lldb/source/Core/SearchFilter.cpp:713
+  if (!type)
+return SearchFilterByModuleList::FunctionPasses(function);
+

kwk wrote:
> jankratochvil wrote:
> > If we cannot determine which file the function is from then rather ignore 
> > it (the current call returns `true`):
> > ```
> >   return false;
> > ```
> @jankratochvil so far I haven't addressed this on purpose to give @labath and 
> @jingham time to say what they think about this.
Yes, ignoring the function if we cannot determine which file it is in sounds 
reasonable. (though I'm not sure if this type argument can ever be null in 
practice.)



Comment at: 
lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py:124
-file_list.Append(lldb.SBFileSpec("noFileOfThisName.xxx"))
-wrong.append(target.BreakpointCreateFromScript("resolver.Resolver", 
extra_args, module_list, file_list))
-

kwk wrote:
> @jingham can you please let me know if this test serves any purpose with my 
> patch? I mentioned in my last change log 
> (https://reviews.llvm.org/D74136#2113899) that it calls `AddressPasses` and 
> checked for the CU before. But since we're no longer doing this, this test no 
> longer can pass. 
After reading more about it, I'm pretty sure this is not the right solution. 
The scripted breakpoints are documented ([[ 
https://github.com/llvm/llvm-project/blame/master/lldb/docs/use/python-reference.rst#L390
 | here ]]) as accepting filters based on compile units. If we don't want to 
change that, then I guess we need to create a separate filter, so that the 
scripted breakpoints can filter based on compile unit names and the name+file 
breakpoints can filter on definitions file names.

If we want to change that, then we'd also need to update the documentation. 
But, the test should stay anyway, because `noFileOfThisName.xxx` is not a valid 
file nor compile unit name, so the location should not be added regardless of 
what exactly are we choosing to filter on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136



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


[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-29 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D74136#2118983 , @jankratochvil 
wrote:

> The filename should not be checked from `SymbolContext::function` but rather 
> from `SymbolContext::line_entry`.  As that is cheaper.  And when one asks for 
> breakpoint at `1a.h:1` then it is enough to check `.debug_line` (which needs 
> to be checked anyway) and why to look into `.debug_info` for the function 
> name etc. at all?
>  I think there is even a bug due to the Function being involved and not just 
> line_entry:
>
>   tail -n99 1b.c 1b.h;clang -o 1b 1b.c -Wall 
> -g;~/redhat/llvm-monorepo2-clangassert/bin/lldb -batch ./1a -o 'breakpoint 
> set -f 1b.h -l 1' 
>   ==> 1b.c <==
>   static void func(void) {}
>   int main(void) {
>   #include "1b.h"
> return 0;
>   }
>   ==> 1b.h <==
> func();
>   (lldb) target create "./1a"
>   Current executable set to '/home/jkratoch/t/1a' (x86_64).
>   (lldb) breakpoint set -f 1b.h -l 1
>   Breakpoint 1: no locations (pending).
>   WARNING:  Unable to resolve breakpoint to any actual locations.
>


When setting a breakpoint by file+line I would definitely expect this to work 
as you describe.

However, when setting a breakpoint by name+file I think that a more natural 
behavior would be to check the file that the function was defined in. I.e. in 
your example "--name main --file 1b.h" should fail, but "--name main --file 
1b.c" should succeed.

I guess this all goes back to what Jim said earlier about the "--file" argument 
in set-by-name and set-by-line behaving differently even though that's not 
obvious from how the command is structured.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136



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


[Lldb-commits] [PATCH] D82378: [lldb/Unwind] Use eh_frame plan directly when it doesn't need to be augmented

2020-06-29 Thread Pavel Labath via Phabricator via lldb-commits
labath marked an inline comment as done.
labath added inline comments.



Comment at: lldb/test/Shell/Unwind/eh-frame-augment-noop.test:18
+target modules show-unwind -n foo
+# CHECK: Asynchronous (not restricted to call-sites) UnwindPlan is 'eh_frame 
CFI'
+# CHECK: eh_frame augmented UnwindPlan:

JDevlieghere wrote:
> On Darwin this returns 
> ```Asynchronous (not restricted to call-sites) UnwindPlan is 'assembly insn 
> profiling'```
> 
> I've skipped the test in b4180fe477bfe302778aaceee65faf69c5e7be76
Thanks. It looks like what happens here is that when targetting mac, clang 
additionally emits unwind info in the compact unwind form and the linker then 
drops the eh_frame info for these functions. There doesn't seem to be a way to 
prevent the compact unwind generation (besides generating unwind info that 
cannot be translated into the compact format).

So, it seems skipping the test is the right thing to do here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82378



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


[Lldb-commits] [PATCH] D82732: WIP: Use SB APIs in CommandObjects

2020-06-29 Thread Shivam Mittal via Phabricator via lldb-commits
shivammittal99 created this revision.
shivammittal99 added reviewers: jingham, teemperor.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Signed-off-by: Shivam Mittal 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82732

Files:
  lldb/include/lldb/API/SBBreakpoint.h
  lldb/include/lldb/API/SBBreakpointLocation.h
  lldb/source/Commands/CommandObjectBreakpointCommand.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/CommandObjectWatchpoint.cpp
  lldb/source/Commands/CommandObjectWatchpoint.h
  lldb/source/Commands/CommandObjectWatchpointCommand.cpp

Index: lldb/source/Commands/CommandObjectWatchpointCommand.cpp
===
--- lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -19,6 +19,9 @@
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Target/Target.h"
 
+#include "lldb/API/SBTarget.h"
+#include "lldb/API/SBWatchpoint.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -398,10 +401,10 @@
 
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
-Target *target = ();
+TargetSP target_sp = GetDebugger().GetSelectedTarget();
+lldb::SBTarget sb_target(target_sp);
 
-const WatchpointList  = target->GetWatchpointList();
-size_t num_watchpoints = watchpoints.GetSize();
+size_t num_watchpoints = sb_target.GetNumWatchpoints();
 
 if (num_watchpoints == 0) {
   result.AppendError("No watchpoints exist to have commands added");
@@ -417,8 +420,8 @@
 }
 
 std::vector valid_wp_ids;
-if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command,
-   valid_wp_ids)) {
+if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
+target_sp, command, valid_wp_ids)) {
   result.AppendError("Invalid watchpoints specification.");
   result.SetStatus(eReturnStatusFailed);
   return false;
@@ -429,12 +432,12 @@
 for (size_t i = 0; i < count; ++i) {
   uint32_t cur_wp_id = valid_wp_ids.at(i);
   if (cur_wp_id != LLDB_INVALID_WATCH_ID) {
-Watchpoint *wp = target->GetWatchpointList().FindByID(cur_wp_id).get();
+lldb::SBWatchpoint sb_wp = sb_target.FindWatchpointByID(cur_wp_id);
 // Sanity check wp first.
-if (wp == nullptr)
+if (!sb_wp)
   continue;
 
-WatchpointOptions *wp_options = wp->GetOptions();
+WatchpointOptions *wp_options = sb_wp.GetSP()->GetOptions();
 // Skip this watchpoint if wp_options is not good.
 if (wp_options == nullptr)
   continue;
@@ -508,10 +511,10 @@
 
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
-Target *target = ();
+TargetSP target_sp = GetDebugger().GetSelectedTarget();
+lldb::SBTarget sb_target(target_sp);
 
-const WatchpointList  = target->GetWatchpointList();
-size_t num_watchpoints = watchpoints.GetSize();
+size_t num_watchpoints = sb_target.GetNumWatchpoints();
 
 if (num_watchpoints == 0) {
   result.AppendError("No watchpoints exist to have commands deleted");
@@ -527,8 +530,8 @@
 }
 
 std::vector valid_wp_ids;
-if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command,
-   valid_wp_ids)) {
+if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
+target_sp, command, valid_wp_ids)) {
   result.AppendError("Invalid watchpoints specification.");
   result.SetStatus(eReturnStatusFailed);
   return false;
@@ -539,9 +542,9 @@
 for (size_t i = 0; i < count; ++i) {
   uint32_t cur_wp_id = valid_wp_ids.at(i);
   if (cur_wp_id != LLDB_INVALID_WATCH_ID) {
-Watchpoint *wp = target->GetWatchpointList().FindByID(cur_wp_id).get();
-if (wp)
-  wp->ClearCallback();
+SBWatchpoint sb_wp = sb_target.FindWatchpointByID(cur_wp_id);
+if (sb_wp)
+  sb_wp.GetSP()->ClearCallback();
   } else {
 result.AppendErrorWithFormat("Invalid watchpoint ID: %u.\n", cur_wp_id);
 result.SetStatus(eReturnStatusFailed);
@@ -580,10 +583,10 @@
 
 protected:
   bool DoExecute(Args , CommandReturnObject ) override {
-Target *target = ();
+TargetSP target_sp = GetDebugger().GetSelectedTarget();
+lldb::SBTarget sb_target(target_sp);
 
-const WatchpointList  = target->GetWatchpointList();
-size_t num_watchpoints = watchpoints.GetSize();
+size_t num_watchpoints = sb_target.GetNumWatchpoints();
 
 if (num_watchpoints == 0) {
   result.AppendError("No watchpoints exist for which to list commands");
@@ -599,8 +602,8 @@
 }
 
 std::vector valid_wp_ids;
-if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command,
-  

[Lldb-commits] [PATCH] D82723: Add lldbAPI library to be able to invoke SB API from CommandObjects

2020-06-29 Thread Shivam Mittal via Phabricator via lldb-commits
shivammittal99 updated this revision to Diff 273977.
shivammittal99 added a comment.

Rebase on master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82723

Files:
  lldb/source/API/CMakeLists.txt
  lldb/source/Commands/CMakeLists.txt

Index: lldb/source/Commands/CMakeLists.txt
===
--- lldb/source/Commands/CMakeLists.txt
+++ lldb/source/Commands/CMakeLists.txt
@@ -34,6 +34,7 @@
   CommandObjectLanguage.cpp
 
   LINK_LIBS
+lldbAPI
 lldbBase
 lldbBreakpoint
 lldbCore
Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -19,7 +19,7 @@
   set(option_framework FRAMEWORK)
 endif()
 
-add_lldb_library(liblldb SHARED ${option_framework}
+add_lldb_library(lldbAPI
   SBAddress.cpp
   SBAttachInfo.cpp
   SBBlock.cpp
@@ -91,8 +91,6 @@
   SBWatchpoint.cpp
   SBUnixSignals.cpp
   SystemInitializerFull.cpp
-  ${lldb_python_wrapper}
-  ${lldb_lua_wrapper}
 
   LINK_LIBS
 lldbBase
@@ -106,9 +104,89 @@
 lldbSymbol
 lldbTarget
 lldbUtility
-${LLDB_ALL_PLUGINS}
+
   LINK_COMPONENTS
 Support
+)
+
+add_lldb_library(liblldb SHARED ${option_framework}
+  SBAddress.cpp
+  SBAttachInfo.cpp
+  SBBlock.cpp
+  SBBreakpoint.cpp
+  SBBreakpointLocation.cpp
+  SBBreakpointName.cpp
+  SBBreakpointOptionCommon.cpp
+  SBBroadcaster.cpp
+  SBCommandInterpreter.cpp
+  SBCommandInterpreterRunOptions.cpp
+  SBCommandReturnObject.cpp
+  SBCommunication.cpp
+  SBCompileUnit.cpp
+  SBData.cpp
+  SBDebugger.cpp
+  SBDeclaration.cpp
+  SBEnvironment.cpp
+  SBError.cpp
+  SBEvent.cpp
+  SBExecutionContext.cpp
+  SBExpressionOptions.cpp
+  SBFileSpec.cpp
+  SBFile.cpp
+  SBFileSpecList.cpp
+  SBFrame.cpp
+  SBFunction.cpp
+  SBHostOS.cpp
+  SBInstruction.cpp
+  SBInstructionList.cpp
+  SBLanguageRuntime.cpp
+  SBLaunchInfo.cpp
+  SBLineEntry.cpp
+  SBListener.cpp
+  SBMemoryRegionInfo.cpp
+  SBMemoryRegionInfoList.cpp
+  SBModule.cpp
+  SBModuleSpec.cpp
+  SBPlatform.cpp
+  SBProcess.cpp
+  SBProcessInfo.cpp
+  SBQueue.cpp
+  SBQueueItem.cpp
+  SBReproducer.cpp
+  SBSection.cpp
+  SBSourceManager.cpp
+  SBStream.cpp
+  SBStringList.cpp
+  SBStructuredData.cpp
+  SBSymbol.cpp
+  SBSymbolContext.cpp
+  SBSymbolContextList.cpp
+  SBTarget.cpp
+  SBThread.cpp
+  SBThreadCollection.cpp
+  SBThreadPlan.cpp
+  SBTrace.cpp
+  SBTraceOptions.cpp
+  SBType.cpp
+  SBTypeCategory.cpp
+  SBTypeEnumMember.cpp
+  SBTypeFilter.cpp
+  SBTypeFormat.cpp
+  SBTypeNameSpecifier.cpp
+  SBTypeSummary.cpp
+  SBTypeSynthetic.cpp
+  SBValue.cpp
+  SBValueList.cpp
+  SBVariablesOptions.cpp
+  SBWatchpoint.cpp
+  SBUnixSignals.cpp
+  SystemInitializerFull.cpp
+  ${lldb_python_wrapper}
+  ${lldb_lua_wrapper}
+
+  LINK_LIBS
+lldbAPI
+${LLDB_ALL_PLUGINS}
 
   ${option_install_prefix}
 )
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D82723: Add lldbAPI library to be able to invoke SB API from CommandObjects

2020-06-29 Thread Shivam Mittal via Phabricator via lldb-commits
shivammittal99 created this revision.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

Signed-off-by: Shivam Mittal 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82723

Files:
  lldb/source/API/CMakeLists.txt
  lldb/source/Commands/CMakeLists.txt

Index: lldb/source/Commands/CMakeLists.txt
===
--- lldb/source/Commands/CMakeLists.txt
+++ lldb/source/Commands/CMakeLists.txt
@@ -34,6 +34,7 @@
   CommandObjectLanguage.cpp
 
   LINK_LIBS
+lldbAPI
 lldbBase
 lldbBreakpoint
 lldbCore
Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -19,7 +19,7 @@
   set(option_framework FRAMEWORK)
 endif()
 
-add_lldb_library(liblldb SHARED ${option_framework}
+add_lldb_library(lldbAPI
   SBAddress.cpp
   SBAttachInfo.cpp
   SBBlock.cpp
@@ -91,8 +91,6 @@
   SBWatchpoint.cpp
   SBUnixSignals.cpp
   SystemInitializerFull.cpp
-  ${lldb_python_wrapper}
-  ${lldb_lua_wrapper}
 
   LINK_LIBS
 lldbBase
@@ -106,9 +104,89 @@
 lldbSymbol
 lldbTarget
 lldbUtility
-${LLDB_ALL_PLUGINS}
+
   LINK_COMPONENTS
 Support
+)
+
+add_lldb_library(liblldb SHARED ${option_framework}
+  SBAddress.cpp
+  SBAttachInfo.cpp
+  SBBlock.cpp
+  SBBreakpoint.cpp
+  SBBreakpointLocation.cpp
+  SBBreakpointName.cpp
+  SBBreakpointOptionCommon.cpp
+  SBBroadcaster.cpp
+  SBCommandInterpreter.cpp
+  SBCommandInterpreterRunOptions.cpp
+  SBCommandReturnObject.cpp
+  SBCommunication.cpp
+  SBCompileUnit.cpp
+  SBData.cpp
+  SBDebugger.cpp
+  SBDeclaration.cpp
+  SBEnvironment.cpp
+  SBError.cpp
+  SBEvent.cpp
+  SBExecutionContext.cpp
+  SBExpressionOptions.cpp
+  SBFileSpec.cpp
+  SBFile.cpp
+  SBFileSpecList.cpp
+  SBFrame.cpp
+  SBFunction.cpp
+  SBHostOS.cpp
+  SBInstruction.cpp
+  SBInstructionList.cpp
+  SBLanguageRuntime.cpp
+  SBLaunchInfo.cpp
+  SBLineEntry.cpp
+  SBListener.cpp
+  SBMemoryRegionInfo.cpp
+  SBMemoryRegionInfoList.cpp
+  SBModule.cpp
+  SBModuleSpec.cpp
+  SBPlatform.cpp
+  SBProcess.cpp
+  SBProcessInfo.cpp
+  SBQueue.cpp
+  SBQueueItem.cpp
+  SBReproducer.cpp
+  SBSection.cpp
+  SBSourceManager.cpp
+  SBStream.cpp
+  SBStringList.cpp
+  SBStructuredData.cpp
+  SBSymbol.cpp
+  SBSymbolContext.cpp
+  SBSymbolContextList.cpp
+  SBTarget.cpp
+  SBThread.cpp
+  SBThreadCollection.cpp
+  SBThreadPlan.cpp
+  SBTrace.cpp
+  SBTraceOptions.cpp
+  SBType.cpp
+  SBTypeCategory.cpp
+  SBTypeEnumMember.cpp
+  SBTypeFilter.cpp
+  SBTypeFormat.cpp
+  SBTypeNameSpecifier.cpp
+  SBTypeSummary.cpp
+  SBTypeSynthetic.cpp
+  SBValue.cpp
+  SBValueList.cpp
+  SBVariablesOptions.cpp
+  SBWatchpoint.cpp
+  SBUnixSignals.cpp
+  SystemInitializerFull.cpp
+  ${lldb_python_wrapper}
+  ${lldb_lua_wrapper}
+
+  LINK_LIBS
+lldbAPI
+${LLDB_ALL_PLUGINS}
 
   ${option_install_prefix}
 )
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74136: [LLDB] WIP: Follow DW_AT_decl_file when setting breakpoint

2020-06-29 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

The filename should not be checked from `SymbolContext::function` but rather 
from `SymbolContext::line_entry`.  As that is cheaper.  And when one asks for 
breakpoint at `1a.h:1` then it is enough to check `.debug_line` (which needs to 
be checked anyway) and why to look into `.debug_info` for the function name 
etc. at all?
I think there is even a bug due to the Function being involved and not just 
line_entry:

  tail -n99 1b.c 1b.h;clang -o 1b 1b.c -Wall 
-g;~/redhat/llvm-monorepo2-clangassert/bin/lldb -batch ./1a -o 'breakpoint set 
-f 1b.h -l 1' 
  ==> 1b.c <==
  static void func(void) {}
  int main(void) {
  #include "1b.h"
return 0;
  }
  ==> 1b.h <==
func();
  (lldb) target create "./1a"
  Current executable set to '/home/jkratoch/t/1a' (x86_64).
  (lldb) breakpoint set -f 1b.h -l 1
  Breakpoint 1: no locations (pending).
  WARNING:  Unable to resolve breakpoint to any actual locations.

For a practical use case the `1b.h` should be rather called `1b.def`, there are 
such files found in many GNU projects - although usually the `*.def` files are 
included into data `struct`s and not into function code. But still. This 
reproducer should be even a part of the testcase for your patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74136



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