[Lldb-commits] [PATCH] D152494: [lldb][Android] Fix adb shell cat

2023-06-12 Thread Nathan Lanza via Phabricator via lldb-commits
lanza accepted this revision.
lanza added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: JDevlieghere.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152494

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


[Lldb-commits] [PATCH] D114491: WIP -- add CLI to lldb-vscode

2022-06-07 Thread Nathan Lanza via Phabricator via lldb-commits
lanza abandoned this revision.
lanza added a comment.
Herald added a project: All.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114491

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


[Lldb-commits] [PATCH] D124429: [lldb] Remove Python 2 support from the ScriptInterpreter plugin

2022-04-26 Thread Nathan Lanza via Phabricator via lldb-commits
lanza accepted this revision.
lanza added a comment.

Yay, thanks Jonas!


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

https://reviews.llvm.org/D124429

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


[Lldb-commits] [PATCH] D114491: lldb-vscode plugin

2021-11-23 Thread Nathan Lanza via Phabricator via lldb-commits
lanza created this revision.
lanza requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Just uploading this incase I want to look at it again at some point in the 
future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114491

Files:
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #if defined(_WIN32)
 // We need to #define NOMINMAX in order to skip `min()` and `max()` macro
 // definitions that conflict with other system headers.
@@ -552,6 +553,34 @@
   }
 }
 
+static void reset_stdin_termios();
+static bool g_old_stdin_termios_is_valid = false;
+static struct termios g_old_stdin_termios;
+
+// In the Driver::MainLoop, we change the terminal settings.  This function is
+// added as an atexit handler to make sure we clean them up.
+static void reset_stdin_termios() {
+  if (g_old_stdin_termios_is_valid) {
+g_old_stdin_termios_is_valid = false;
+::tcsetattr(STDIN_FILENO, TCSANOW, _old_stdin_termios);
+  }
+}
+
+void CommandInterpreterThreadFunction() {
+  if (::tcgetattr(STDIN_FILENO, _old_stdin_termios) == 0) {
+g_old_stdin_termios_is_valid = true;
+atexit(reset_stdin_termios);
+  }
+#ifndef _MSC_VER
+  // Disabling stdin buffering with MSVC's 2015 CRT exposes a bug in fgets
+  // which causes it to miss newlines depending on whether there have been an
+  // odd or even number of characters.  Bug has been reported to MS via Connect.
+ ::setbuf(stdin, nullptr);
+#endif
+  ::setbuf(stdout, nullptr);
+  g_vsc.debugger.RunCommandInterpreter(false, false);
+}
+
 // "AttachRequest": {
 //   "allOf": [ { "$ref": "#/definitions/Request" }, {
 // "type": "object",
@@ -878,6 +907,9 @@
 g_vsc.broadcaster.BroadcastEventByType(eBroadcastBitStopProgressThread);
 g_vsc.progress_event_thread.join();
   }
+
+  if (g_vsc.command_interpreter_thread.joinable())
+g_vsc.event_thread.join();
 }
 
 void request_exceptionInfo(const llvm::json::Object ) {
@@ -1415,6 +1447,11 @@
 // "supportsRunInTerminalRequest": {
 //   "type": "boolean",
 //   "description": "Client supports the runInTerminal request."
+// },
+// "supportsCommandInterpreter": {
+//   "type": "boolean",
+//   "description": "Client launches lldb-vscode in a terminal and thus
+//   supports attaching the CommandInterpreter."
 // }
 //   },
 //   "required": [ "adapterID" ]
@@ -1439,6 +1476,38 @@
   // before we are given an executable to launch in a "launch" request, or a
   // executable when attaching to a process by process ID in a "attach"
   // request.
+  //
+  // Start our event thread so we can receive events from the debugger, target,
+  // process and more.
+  g_vsc.event_thread = std::thread(EventThreadFunction);
+
+// Set the output and error file handles to redirect into nothing iff the
+  // input and output are set to stdin and stdout. If we are receiving DAP
+  // packets over a socket then keep them up. Otherwise if any code in LLDB
+  // prints to the debugger file handles, the output and error file handles are
+  // initialized to STDOUT and STDERR and any output will kill our debug
+  // session.
+  if (!g_vsc.input.descriptor.m_is_socket) {
+FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
+if (out) {
+  g_vsc.debugger.SetOutputFileHandle(out, true);
+  g_vsc.debugger.SetErrorFileHandle(out, false);
+}
+  }
+
+  // We can't attach the command interpreter if the DAP packets are being sent
+  // via stdin/stdout. We would require extra sockets. So only attach the CI iff
+  // we are communicating via a socket.
+  if (g_vsc.input.descriptor.m_is_socket) {
+auto arguments = request.getObject("arguments");
+auto supports_ci =
+GetBoolean(arguments, "supportsCommandInterpreter", false);
+if (supports_ci) {
+  g_vsc.command_interpreter_thread =
+  std::thread(CommandInterpreterThreadFunction);
+}
+  }
+
   FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
   if (out) {
 // Set the output and error file handles to redirect into nothing otherwise
@@ -1449,9 +1518,6 @@
 g_vsc.debugger.SetErrorFileHandle(out, false);
   }
 
-  // Start our event thread so we can receive events from the debugger, target,
-  // process and more.
-  g_vsc.event_thread = std::thread(EventThreadFunction);
 
   llvm::json::Object response;
   FillResponse(request, response);
Index: lldb/tools/lldb-vscode/VSCode.h
===
--- lldb/tools/lldb-vscode/VSCode.h
+++ lldb/tools/lldb-vscode/VSCode.h
@@ -130,6 +130,7 @@
   lldb::SBBroadcaster broadcaster;
   

[Lldb-commits] [PATCH] D96096: [lldb] Emit type annotation in SWIG generated Python code.

2021-02-05 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

Thanks, Jonas! What's the status for your downstream repos? This generates 
bindings but they aren't entirely functional as it generates type annotations 
like `"lldb::SBDebugger"` which Python LSPs can't figure out. I ended up adding 
`-py3` and then running some sed post-processing to convert `"lldb::\(.*\)"` to 
`\1` etc: https://github.com/lanza/lldbpybind. That `lldb.py` works pretty well 
with pyright getting type info. Figuring out how to teach the build system + 
swig to generate proper type annotations might require a similar post 
processing step.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96096

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


[Lldb-commits] [PATCH] D96060: [lldb-vscode] correctly use Windows macros

2021-02-04 Thread Nathan Lanza via Phabricator via lldb-commits
lanza accepted this revision.
lanza added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: JDevlieghere.

LGTM, I had to do this to fix it locally and can confirm it works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96060

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


[Lldb-commits] [PATCH] D93926: [lldb] Don't remove the lldb.debugger var after exiting the interpreter

2021-01-07 Thread Nathan Lanza via Phabricator via lldb-commits
lanza abandoned this revision.
lanza added a comment.

Great, that does indeed seem to work properly. Thanks, Jonas!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93926

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


[Lldb-commits] [PATCH] D93926: [lldb] Don't remove the lldb.debugger var after exiting the interpreter

2021-01-07 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

I guess if the intention of that is maintain the debugger instance around it 
should work, but at the moment it segfaults pretty quick with Xcode's lldb 
using:

  import threading
  import lldb
  import time
  
  def background(debugger: lldb.SBDebugger):
  while True:
  time.sleep(1)
  print(debugger)
  
  def __lldb_init_module(
debugger: lldb.SBDebugger,
internal_dict: dict
  ):
  threading.Thread()
  threading.Thread(target=background, args=(debugger,)).start()

and

  $ lldb a.out
  (lldb) command script import test.py
  (lldb) // do a few things
  0  lldb0x0001058d8575 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
  1  lldb0x0001058d7b55 
llvm::sys::RunSignalHandlers() + 85
  2  lldb0x0001058d8dd6 
SignalHandler(int) + 262
  3  libsystem_platform.dylib0x7fff20394d7d _sigtramp + 
29
  4  libsystem_platform.dylib0x00010762d680 _sigtramp + 
18446603344394422560
  5  liblldbPluginScriptInterpreterPython3.dylib 0x0001059f1802 
_wrap_SBDebugger___str__(_object*, _object*) + 130
  6  Python3 0x000105bf6453 
cfunction_call_varargs + 323
  7  Python3 0x000105bf5dd6 
_PyObject_MakeTpCall + 374
  8  Python3 0x000105cd613c 
call_function + 652
  9  Python3 0x000105cd26d6 
_PyEval_EvalFrameDefault + 29782
  10 Python3 0x000105bf678d 
function_code_fastcall + 237
  11 Python3 0x000105bf7192 
_PyObject_FastCall_Prepend + 178
  12 Python3 0x000105c4e527 slot_tp_str 
+ 183
  13 Python3 0x000105c37a62 
PyObject_Str + 146
  14 Python3 0x000105c09b95 
PyFile_WriteObject + 149
  15 Python3 0x000105cc96f2 
builtin_print + 450
  16 Python3 0x000105c34a82 
cfunction_vectorcall_FASTCALL_KEYWORDS + 130
  17 Python3 0x000105cd6012 
call_function + 354
  18 Python3 0x000105cd278a 
_PyEval_EvalFrameDefault + 29962
  19 Python3 0x000105bf678d 
function_code_fastcall + 237
  20 Python3 0x000105bf6124 
PyVectorcall_Call + 100
  21 Python3 0x000105cd2a34 
_PyEval_EvalFrameDefault + 30644
  22 Python3 0x000105bf678d 
function_code_fastcall + 237
  23 Python3 0x000105cd6012 
call_function + 354
  24 Python3 0x000105cd26b9 
_PyEval_EvalFrameDefault + 29753
  25 Python3 0x000105bf678d 
function_code_fastcall + 237
  26 Python3 0x000105cd6012 
call_function + 354
  27 Python3 0x000105cd26b9 
_PyEval_EvalFrameDefault + 29753
  28 Python3 0x000105bf678d 
function_code_fastcall + 237
  29 Python3 0x000105bf91e2 
method_vectorcall + 322
  30 Python3 0x000105bf6124 
PyVectorcall_Call + 100
  31 Python3 0x000105d7800a t_bootstrap 
+ 74
  32 Python3 0x000105d29829 
pythread_wrapper + 25
  33 libsystem_pthread.dylib 0x7fff20350950 
_pthread_start + 224
  34 libsystem_pthread.dylib 0x7fff2034c47b 
thread_start + 15
  fish: 'lldb' terminated by signal SIGSEGV (Address boundary error)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93926

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


[Lldb-commits] [PATCH] D93926: [lldb] Don't remove the lldb.debugger var after exiting the interpreter

2021-01-07 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

What's the boundaries of the stable API, then? This was a public API that was 
removed and broke a plugin I used for vim (and I'll be this isn't the only 
case, just I'm maybe the only one who has worked on lldb before whose tool 
broke). The author used `threading.Thread(someFunc, (debugger,))` to listen on 
a socket for fetch requests from lldb outside of the prompt. Not the most 
beautiful of implementations, but it worked for years on top of a promised 
public stable API.

As far as I know, the only other ways to do this would be to use the 
listener/event forwarding mechanism Greg used to set up the curses based GUI in 
`Debugger::HandleProcessEvent` or to write an entire new frontend analogous to 
the lldb tool itself. The latter implementation is a couple orders of magnitude 
more work to implement for a simple plugin author like this. The former isn't 
exposed in the SBAPI.

Maybe the SBAPI needs access to the `Debugger::m_forward_listener_sp` for GUI 
based usages? Something like:

  class SBForwardEventListener:
  // called for process events
  def HandleProcessEvent(self, event: lldb.SBEvent):
  // called for thread events
  def HandleThreadEvent(self, event: lldb.SBEvent):
  // called for breakpoint events
  def HandleBreakpointEvent(self, event: lldb.SBEvent):

for the developer can invoke

  def __lldb_init_module(...):
  debugger.RegisterForwardEventListener(MyListener())

and be informed for the same whenever the curses GUI would be.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93926

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


[Lldb-commits] [PATCH] D93926: [lldb] Don't remove the lldb.debugger var after exiting the interpreter

2020-12-29 Thread Nathan Lanza via Phabricator via lldb-commits
lanza updated this revision to Diff 314037.
lanza added a comment.
Herald added a subscriber: JDevlieghere.

did it backwards


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93926

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -670,8 +670,8 @@
 log->PutCString("ScriptInterpreterPythonImpl::LeaveSession()");
 
   // Unset the LLDB global variables.
-  PyRun_SimpleString("lldb.debugger = None; lldb.target = None; lldb.process "
- "= None; lldb.thread = None; lldb.frame = None");
+  PyRun_SimpleString("lldb.target = None; lldb.process = None;"
+ "lldb.thread = None; lldb.frame = None");
 
   // checking that we have a valid thread state - since we use our own
   // threading and locking in some (rare) cases during cleanup Python may end


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -670,8 +670,8 @@
 log->PutCString("ScriptInterpreterPythonImpl::LeaveSession()");
 
   // Unset the LLDB global variables.
-  PyRun_SimpleString("lldb.debugger = None; lldb.target = None; lldb.process "
- "= None; lldb.thread = None; lldb.frame = None");
+  PyRun_SimpleString("lldb.target = None; lldb.process = None;"
+ "lldb.thread = None; lldb.frame = None");
 
   // checking that we have a valid thread state - since we use our own
   // threading and locking in some (rare) cases during cleanup Python may end
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D93926: [lldb] Don't remove the lldb.debugger var after exiting the interpreter

2020-12-29 Thread Nathan Lanza via Phabricator via lldb-commits
lanza created this revision.
lanza requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The debugger itself doesn't get stale between script prompt usages.
Setting this to `None` also breaks users of the scripting API that used
this property in the background.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93926

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -670,8 +670,7 @@
 log->PutCString("ScriptInterpreterPythonImpl::LeaveSession()");
 
   // Unset the LLDB global variables.
-  PyRun_SimpleString("lldb.debugger = None; lldb.target = None; lldb.process "
- "= None; lldb.thread = None; lldb.frame = None");
+  PyRun_SimpleString("lldb.debugger = None;");
 
   // checking that we have a valid thread state - since we use our own
   // threading and locking in some (rare) cases during cleanup Python may end


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -670,8 +670,7 @@
 log->PutCString("ScriptInterpreterPythonImpl::LeaveSession()");
 
   // Unset the LLDB global variables.
-  PyRun_SimpleString("lldb.debugger = None; lldb.target = None; lldb.process "
- "= None; lldb.thread = None; lldb.frame = None");
+  PyRun_SimpleString("lldb.debugger = None;");
 
   // checking that we have a valid thread state - since we use our own
   // threading and locking in some (rare) cases during cleanup Python may end
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D90857: [lldb] add a missing dependency on intrinsics_gen

2020-11-06 Thread Nathan Lanza via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG137ff7331705: [lldb] add a missing dependency on 
intrinsics_gen (authored by rmaz, committed by lanza).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D90857?vs=303468=303496#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90857

Files:
  lldb/source/Symbol/CMakeLists.txt


Index: lldb/source/Symbol/CMakeLists.txt
===
--- lldb/source/Symbol/CMakeLists.txt
+++ lldb/source/Symbol/CMakeLists.txt
@@ -39,6 +39,9 @@
 
   ${PLATFORM_SOURCES}
 
+  DEPENDS
+intrinsics_gen
+
   LINK_LIBS
 lldbCore
 lldbExpression


Index: lldb/source/Symbol/CMakeLists.txt
===
--- lldb/source/Symbol/CMakeLists.txt
+++ lldb/source/Symbol/CMakeLists.txt
@@ -39,6 +39,9 @@
 
   ${PLATFORM_SOURCES}
 
+  DEPENDS
+intrinsics_gen
+
   LINK_LIBS
 lldbCore
 lldbExpression
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D84269: [lldb] Add some example type anotations to python.swig

2020-08-03 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.
Herald added a subscriber: JDevlieghere.

Sounds good, just sent out a message to the mailing list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84269

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


[Lldb-commits] [PATCH] D84269: [lldb] Add some example type anotations to python.swig

2020-07-21 Thread Nathan Lanza via Phabricator via lldb-commits
lanza created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Python3.5 (3.4?) added type annotations to the python language. This
lets tools such as LSPs provide useful IDE-like completion when writing
python.

Add type annotations throughout the python swig API would make writing
lldb python tooling much more approachable for users. This diff is a
first demonstration of the idea.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84269

Files:
  lldb/bindings/python.swig


Index: lldb/bindings/python.swig
===
--- lldb/bindings/python.swig
+++ lldb/bindings/python.swig
@@ -137,9 +137,9 @@
 debugger_unique_id = 0
 if _initialize:
SBDebugger.Initialize()
-debugger = None
-target = None
-process = None
-thread = None
-frame = None
+debugger: lldb.SBDebugger = None
+target: lldb.SBTarget = None
+process: lldb.SBProcess = None
+thread: lldb.SBThread = None
+frame: lldb.SBFrame = None
 %}


Index: lldb/bindings/python.swig
===
--- lldb/bindings/python.swig
+++ lldb/bindings/python.swig
@@ -137,9 +137,9 @@
 debugger_unique_id = 0
 if _initialize:
SBDebugger.Initialize()
-debugger = None
-target = None
-process = None
-thread = None
-frame = None
+debugger: lldb.SBDebugger = None
+target: lldb.SBTarget = None
+process: lldb.SBProcess = None
+thread: lldb.SBThread = None
+frame: lldb.SBFrame = None
 %}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D70885: [lldb] Use explicit lldb commands on tests

2020-04-30 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

Sorry for bump to this old diff, but I agree with both Jim and Greg -- we 
shouldn't be importing your `~/.lldbinit`, but tests shouldn't depend on there 
never being another `br s`. This change should land as `breakpoint set`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70885



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


[Lldb-commits] [PATCH] D71633: [lldb-vscode] Only close the debuggers in/out when DAP is over stdin/out

2019-12-18 Thread Nathan Lanza via Phabricator via lldb-commits
lanza updated this revision to Diff 234586.
lanza added a comment.

fixup according to Greg's requests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71633

Files:
  lldb/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1199,14 +1199,18 @@
   // before we are given an executable to launch in a "launch" request, or a
   // executable when attaching to a process by process ID in a "attach"
   // request.
-  FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
-  if (out) {
-// Set the output and error file handles to redirect into nothing otherwise
-// if any code in LLDB prints to the debugger file handles, the output and
-// error file handles are initialized to STDOUT and STDERR and any output
-// will kill our debug session.
-g_vsc.debugger.SetOutputFileHandle(out, true);
-g_vsc.debugger.SetErrorFileHandle(out, false);
+  if (!g_vsc.input.descriptor.m_is_socket) {
+FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, 
"w");
+if (out) {
+  // If the input and output descriptors are STDIN and STDOUT then we need
+  // to set the output and error file handles to redirect into nothing
+  // otherwise if any code in LLDB prints to the debugger file handles, the
+  // output and error file handles are initialized to STDOUT and STDERR and
+  // any output will kill our debug session. However, if the communication
+  // is via sockets then we can leave these open.
+  g_vsc.debugger.SetOutputFileHandle(out, true);
+  g_vsc.debugger.SetErrorFileHandle(out, false);
+}
   }
 
   g_vsc.target = g_vsc.debugger.CreateTarget(nullptr);


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1199,14 +1199,18 @@
   // before we are given an executable to launch in a "launch" request, or a
   // executable when attaching to a process by process ID in a "attach"
   // request.
-  FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
-  if (out) {
-// Set the output and error file handles to redirect into nothing otherwise
-// if any code in LLDB prints to the debugger file handles, the output and
-// error file handles are initialized to STDOUT and STDERR and any output
-// will kill our debug session.
-g_vsc.debugger.SetOutputFileHandle(out, true);
-g_vsc.debugger.SetErrorFileHandle(out, false);
+  if (!g_vsc.input.descriptor.m_is_socket) {
+FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
+if (out) {
+  // If the input and output descriptors are STDIN and STDOUT then we need
+  // to set the output and error file handles to redirect into nothing
+  // otherwise if any code in LLDB prints to the debugger file handles, the
+  // output and error file handles are initialized to STDOUT and STDERR and
+  // any output will kill our debug session. However, if the communication
+  // is via sockets then we can leave these open.
+  g_vsc.debugger.SetOutputFileHandle(out, true);
+  g_vsc.debugger.SetErrorFileHandle(out, false);
+}
   }
 
   g_vsc.target = g_vsc.debugger.CreateTarget(nullptr);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71633: [lldb-vscode] Only close the debuggers in/out when DAP is over stdin/out

2019-12-18 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

Great point! Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71633



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


[Lldb-commits] [PATCH] D71633: [lldb-vscode] Only close the debuggers in/out when DAP is over stdin/out

2019-12-17 Thread Nathan Lanza via Phabricator via lldb-commits
lanza created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The DAP is usually communicated over STDIN and STDOUT and thus lldb's
Debugger instance printing and reading from these files can cause
conflicts. However, if the DAP communication was set up to be done via
a socket then we can leave these files open as they can provide
valueable logging and feedback to the user.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71633

Files:
  lldb/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1200,11 +1200,13 @@
   // executable when attaching to a process by process ID in a "attach"
   // request.
   FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
-  if (out) {
-// Set the output and error file handles to redirect into nothing otherwise
+  if (out && !g_vsc.input.descriptor.m_is_socket) {
+// If the input and output descriptors are STDIN and STDOUT then we need to
+// set the output and error file handles to redirect into nothing otherwise
 // if any code in LLDB prints to the debugger file handles, the output and
 // error file handles are initialized to STDOUT and STDERR and any output
-// will kill our debug session.
+// will kill our debug session. However, if the communication is via 
sockets
+// then we can leave these open.
 g_vsc.debugger.SetOutputFileHandle(out, true);
 g_vsc.debugger.SetErrorFileHandle(out, false);
   }


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1200,11 +1200,13 @@
   // executable when attaching to a process by process ID in a "attach"
   // request.
   FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
-  if (out) {
-// Set the output and error file handles to redirect into nothing otherwise
+  if (out && !g_vsc.input.descriptor.m_is_socket) {
+// If the input and output descriptors are STDIN and STDOUT then we need to
+// set the output and error file handles to redirect into nothing otherwise
 // if any code in LLDB prints to the debugger file handles, the output and
 // error file handles are initialized to STDOUT and STDERR and any output
-// will kill our debug session.
+// will kill our debug session. However, if the communication is via sockets
+// then we can leave these open.
 g_vsc.debugger.SetOutputFileHandle(out, true);
 g_vsc.debugger.SetErrorFileHandle(out, false);
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65155: [lldb] Remove Xcode project legacy

2019-07-23 Thread Nathan Lanza via Phabricator via lldb-commits
lanza accepted this revision.
lanza added a comment.

utils/sync-source
misc/grep-svn-log.py


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65155



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


[Lldb-commits] [PATCH] D65109: [LLDB] Remove the Xcode project

2019-07-22 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added inline comments.



Comment at: lldb/utils/xcode.py:1
+#!/usr/bin/env python
+

This could probably be just a 10 line `make` file that you just `make -f 
lldb/utils/xcode.mk`. Not sure if you guys are a fan of this method, but we 
tend to find it to be much more manageable than custom python scripts. 

lldb-build:
cmake -E make_directory lldb-build
lldb-build/lldb.xcodeproj: llvm-build/build.ninja
 cmake -GXcode -Slldb -Blldb-build -C 
cmake/caches/Apple-lldb-Xcode.cmake 
 llvm-build:
 make -E make_directory llvm-build 
 llvm-build/build.ninja: llvm-build
 cmake -GNinja -Sllvm -Bllvm-build 
-DLLVM_ENABLE_PROJECTS='clang;libcxx;libcxxabi'


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D65109



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


[Lldb-commits] [PATCH] D58678: Improve step over performance by not stopping at branches that are function calls and stepping into and them out of each one

2019-06-04 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

@clayborg Seems like this still steps into the `call` if the call is the last 
instruction in the range. `ThreadPlanStepRange::SetNextBranchBreakpoint` checks 
`if (last_index - pc_index > 1)` before setting the breakpoint. So if 
`last_index == pc_index` and `pc` points to `call` then the thread plan will 
resort to single stepping and thus go through all the same machinery. 
Obviously, this isn't a problem as this just leads to using the same 
functionality that it used prior to this patch, but you miss out on the 
optimization you're aiming for.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D58678



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


[Lldb-commits] [PATCH] D62547: (lldb-vscode) Evaluate expressions as LLDB commands when in REPL mode.

2019-05-29 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

Yup, clayborg and I talked about the solution I discuss in that request. The 
hopeful eventual goal is for this communication:

- DAP host:  can you support attaching to a pty?
- lldb-vscode: yes
- DAP host: okay, use `/dev/pty123`
- lldb-vscode: `Debugger:RunCommandInterpreter(/dev/pty123)`

and then all of this nonsense goes away.

I do think, however, that it would be reasonable to swap the backtick usage for 
the current command prompt. e.g. `target list` in the `Debug Console` pane 
would run the lldb command `target list` and `'someVaraible` would instead 
evaluate the variable. Then  you could submit the completion PR. Why do you 
think, @clayborg? I think you'd have to handle the `hover` sub-request 
differently, though.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62547



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


[Lldb-commits] [PATCH] D62547: (lldb-vscode) Evaluate expressions as LLDB commands when in REPL mode.

2019-05-28 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

Any reason why the backtick method is insufficient? I don't like the idea of 
the behavior of typing `q` or `c` being dependent upon the frame you're in.

On a similar note, I'm arguing for a better command prompt implementation in 
the DAP & VSCode. I'm trying to get a pty to attach the `CommandInterpreter` to 
and thus get the full editline completion and history as an officially 
supported feature. 
https://github.com/microsoft/debug-adapter-protocol/issues/45. If and when that 
goes in then this would be redundant.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D62547



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


[Lldb-commits] [PATCH] D53753: [Windows] Define generic arguments registers for Windows x64

2019-05-16 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

So the ABI plugin for Windows x64 seems to be necessary for proper unwinding. 
(Also, proper parsing of xdata and pdata sections might be necessary, too.) I 
suspect that this could be related to 
https://bugs.llvm.org/show_bug.cgi?id=32343, but would need to look more into 
this.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D53753



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


[Lldb-commits] [PATCH] D59804: Kill unused variable m_tu_decl_up in SymbolFilePDB

2019-03-27 Thread Nathan Lanza via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB357113: Kill unused variable m_tu_decl_up in 
SymbolFilePDB (authored by lanza, committed by ).
Herald added subscribers: lldb-commits, teemperor.
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D59804?vs=192493=192494#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59804

Files:
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.h


Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -252,7 +252,6 @@
   std::unique_ptr m_session_up;
   std::unique_ptr m_global_scope_up;
   uint32_t m_cached_compile_unit_count;
-  std::unique_ptr m_tu_decl_ctx_up;
 
   lldb_private::UniqueCStringMap m_func_full_names;
   lldb_private::UniqueCStringMap m_func_base_names;
Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -124,7 +124,7 @@
 
 SymbolFilePDB::SymbolFilePDB(lldb_private::ObjectFile *object_file)
 : SymbolFile(object_file), m_session_up(), m_global_scope_up(),
-  m_cached_compile_unit_count(0), m_tu_decl_ctx_up() {}
+  m_cached_compile_unit_count(0) {}
 
 SymbolFilePDB::~SymbolFilePDB() {}
 
@@ -189,14 +189,6 @@
   if (!m_global_scope_up)
 m_global_scope_up = m_session_up->getGlobalScope();
   lldbassert(m_global_scope_up.get());
-
-  TypeSystem *type_system =
-  GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
-  ClangASTContext *clang_type_system =
-  llvm::dyn_cast_or_null(type_system);
-  lldbassert(clang_type_system);
-  m_tu_decl_ctx_up = llvm::make_unique(
-  type_system, clang_type_system->GetTranslationUnitDecl());
 }
 
 uint32_t SymbolFilePDB::GetNumCompileUnits() {


Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -252,7 +252,6 @@
   std::unique_ptr m_session_up;
   std::unique_ptr m_global_scope_up;
   uint32_t m_cached_compile_unit_count;
-  std::unique_ptr m_tu_decl_ctx_up;
 
   lldb_private::UniqueCStringMap m_func_full_names;
   lldb_private::UniqueCStringMap m_func_base_names;
Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -124,7 +124,7 @@
 
 SymbolFilePDB::SymbolFilePDB(lldb_private::ObjectFile *object_file)
 : SymbolFile(object_file), m_session_up(), m_global_scope_up(),
-  m_cached_compile_unit_count(0), m_tu_decl_ctx_up() {}
+  m_cached_compile_unit_count(0) {}
 
 SymbolFilePDB::~SymbolFilePDB() {}
 
@@ -189,14 +189,6 @@
   if (!m_global_scope_up)
 m_global_scope_up = m_session_up->getGlobalScope();
   lldbassert(m_global_scope_up.get());
-
-  TypeSystem *type_system =
-  GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
-  ClangASTContext *clang_type_system =
-  llvm::dyn_cast_or_null(type_system);
-  lldbassert(clang_type_system);
-  m_tu_decl_ctx_up = llvm::make_unique(
-  type_system, clang_type_system->GetTranslationUnitDecl());
 }
 
 uint32_t SymbolFilePDB::GetNumCompileUnits() {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D59230: Add a case in SymbolFile{Native, }PDB::TranslateLanguage for Swift

2019-03-11 Thread Nathan Lanza via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB355883: Add a case in 
SymbolFile{Native,}PDB::TranslateLanguage for Swift (authored by lanza, 
committed by ).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59230?vs=190183=190184#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D59230

Files:
  source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp


Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -64,6 +64,8 @@
 return lldb::LanguageType::eLanguageTypeC_plus_plus;
   case PDB_Lang::C:
 return lldb::LanguageType::eLanguageTypeC;
+  case PDB_Lang::Swift:
+return lldb::LanguageType::eLanguageTypeSwift;
   default:
 return lldb::LanguageType::eLanguageTypeUnknown;
   }
Index: source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===
--- source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -73,6 +73,8 @@
 return lldb::LanguageType::eLanguageTypeC_plus_plus;
   case PDB_Lang::C:
 return lldb::LanguageType::eLanguageTypeC;
+  case PDB_Lang::Swift:
+return lldb::LanguageType::eLanguageTypeSwift;
   default:
 return lldb::LanguageType::eLanguageTypeUnknown;
   }


Index: source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -64,6 +64,8 @@
 return lldb::LanguageType::eLanguageTypeC_plus_plus;
   case PDB_Lang::C:
 return lldb::LanguageType::eLanguageTypeC;
+  case PDB_Lang::Swift:
+return lldb::LanguageType::eLanguageTypeSwift;
   default:
 return lldb::LanguageType::eLanguageTypeUnknown;
   }
Index: source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
===
--- source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -73,6 +73,8 @@
 return lldb::LanguageType::eLanguageTypeC_plus_plus;
   case PDB_Lang::C:
 return lldb::LanguageType::eLanguageTypeC;
+  case PDB_Lang::Swift:
+return lldb::LanguageType::eLanguageTypeSwift;
   default:
 return lldb::LanguageType::eLanguageTypeUnknown;
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D55383: Implement basic DidAttach for DynamicLoaderWindowsDYLD for use with ds2

2018-12-07 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

@zturner and I spoke about it before landing

@labath - correct. Dll loading needs handled. This was to upstream hello world 
functionality without DLLs. I need to figure out where and when to synchronize 
between ds2 and lldb for the `LOAD_DLL_DEBUG_EVENT`. I'll probably get to this 
early next week.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55383



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


[Lldb-commits] [PATCH] D55383: Implement basic DidAttach for DynamicLoaderWindowsDYLD for use with ds2

2018-12-06 Thread Nathan Lanza via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB348526: Implement WindowsDYLD::DidAttach for use with 
gdb-server attach (authored by lanza, committed by ).
Herald added subscribers: lldb-commits, abidh.

Changed prior to commit:
  https://reviews.llvm.org/D55383?vs=177028=177033#toc

Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D55383

Files:
  source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp


Index: source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
===
--- source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -10,12 +10,14 @@
 
 #include "DynamicLoaderWindowsDYLD.h"
 
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/ThreadPlanStepInstruction.h"
+#include "lldb/Utility/Log.h"
 
 #include "llvm/ADT/Triple.h"
 
@@ -60,7 +62,39 @@
   return nullptr;
 }
 
-void DynamicLoaderWindowsDYLD::DidAttach() {}
+void DynamicLoaderWindowsDYLD::DidAttach() {
+Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+  if (log)
+log->Printf("DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
+
+  ModuleSP executable = GetTargetExecutable();
+
+  if (!executable.get())
+return;
+
+  // Try to fetch the load address of the file from the process, since there
+  // could be randomization of the load address.
+
+  // It might happen that the remote has a different dir for the file, so we
+  // only send the basename of the executable in the query. I think this is 
safe
+  // because I doubt that two executables with the same basenames are loaded in
+  // memory...
+  FileSpec file_spec(
+  executable->GetPlatformFileSpec().GetFilename().GetCString());
+  bool is_loaded;
+  addr_t base_addr = 0;
+  lldb::addr_t load_addr;
+  Status error = m_process->GetFileLoadAddress(file_spec, is_loaded, 
load_addr);
+  if (error.Success() && is_loaded) {
+base_addr = load_addr;
+UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, base_addr, false);
+  }
+
+  ModuleList module_list;
+  module_list.Append(executable);
+  m_process->GetTarget().ModulesDidLoad(module_list);
+  m_process->LoadModules();
+}
 
 void DynamicLoaderWindowsDYLD::DidLaunch() {}
 


Index: source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
===
--- source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -10,12 +10,14 @@
 
 #include "DynamicLoaderWindowsDYLD.h"
 
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/ThreadPlanStepInstruction.h"
+#include "lldb/Utility/Log.h"
 
 #include "llvm/ADT/Triple.h"
 
@@ -60,7 +62,39 @@
   return nullptr;
 }
 
-void DynamicLoaderWindowsDYLD::DidAttach() {}
+void DynamicLoaderWindowsDYLD::DidAttach() {
+Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+  if (log)
+log->Printf("DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
+
+  ModuleSP executable = GetTargetExecutable();
+
+  if (!executable.get())
+return;
+
+  // Try to fetch the load address of the file from the process, since there
+  // could be randomization of the load address.
+
+  // It might happen that the remote has a different dir for the file, so we
+  // only send the basename of the executable in the query. I think this is safe
+  // because I doubt that two executables with the same basenames are loaded in
+  // memory...
+  FileSpec file_spec(
+  executable->GetPlatformFileSpec().GetFilename().GetCString());
+  bool is_loaded;
+  addr_t base_addr = 0;
+  lldb::addr_t load_addr;
+  Status error = m_process->GetFileLoadAddress(file_spec, is_loaded, load_addr);
+  if (error.Success() && is_loaded) {
+base_addr = load_addr;
+UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, base_addr, false);
+  }
+
+  ModuleList module_list;
+  module_list.Append(executable);
+  m_process->GetTarget().ModulesDidLoad(module_list);
+  m_process->LoadModules();
+}
 
 void DynamicLoaderWindowsDYLD::DidLaunch() {}
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54544: Implement basic DidAttach and DidLaunch for DynamicLoaderWindowsDYLD

2018-11-15 Thread Nathan Lanza via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346994: Implement basic DidAttach and DidLaunch for 
DynamicLoaderWindowsDYLD (authored by lanza, committed by ).
Herald added subscribers: lldb-commits, abidh.

Changed prior to commit:
  https://reviews.llvm.org/D54544?vs=174097=174272#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54544

Files:
  packages/Python/lldbsuite/test/functionalities/windows_dyld/Makefile
  packages/Python/lldbsuite/test/functionalities/windows_dyld/TestWindowsDYLD.py
  packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.c
  packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.mk
  packages/Python/lldbsuite/test/functionalities/windows_dyld/main.c
  packages/Python/lldbsuite/test/make/Makefile.rules
  source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp

Index: packages/Python/lldbsuite/test/make/Makefile.rules
===
--- packages/Python/lldbsuite/test/make/Makefile.rules
+++ packages/Python/lldbsuite/test/make/Makefile.rules
@@ -525,7 +525,7 @@
 endif
 else
 $(EXE) : $(OBJECTS) $(ARCHIVE_NAME)
-	$(LD) $(OBJECTS) $(LDFLAGS) $(ARCHIVE_NAME) -o "$(EXE)"
+	"$(LD)" $(OBJECTS) $(LDFLAGS) $(ARCHIVE_NAME) -o "$(EXE)"
 ifneq "$(CODESIGN)" ""
 	$(CODESIGN) -s - "$(EXE)"
 endif
@@ -582,7 +582,7 @@
 endif
 endif
 else
-	$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
+	"$(LD)" $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
 	$(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug"
 	$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"
Index: packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.mk
===
--- packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.mk
+++ packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.mk
@@ -0,0 +1,7 @@
+LEVEL := ../../make
+
+DYLIB_NAME := dllfunc
+DYLIB_C_SOURCES := dllfunc.c
+DYLIB_ONLY := YES
+
+include $(LEVEL)/Makefile.rules
Index: packages/Python/lldbsuite/test/functionalities/windows_dyld/Makefile
===
--- packages/Python/lldbsuite/test/functionalities/windows_dyld/Makefile
+++ packages/Python/lldbsuite/test/functionalities/windows_dyld/Makefile
@@ -0,0 +1,14 @@
+LEVEL := ../../make
+
+LD_EXTRAS := -ldllfunc
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
+
+a.out: dllfunc
+
+dllfunc:
+	$(MAKE) VERBOSE=1 VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dllfunc.mk
+
+clean::
+	$(MAKE) -f $(SRCDIR)/dllfunc.mk clean
Index: packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.c
===
--- packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.c
+++ packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.c
@@ -0,0 +1,19 @@
+//===-- a.c -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include 
+
+BOOL WINAPI DllMain(HINSTANCE h, DWORD reason, void* reserved) {
+  return TRUE;
+}
+
+int __declspec(dllexport) DllFunc(int n) {
+  int x = n * n;  
+  return x;  // set breakpoint here
+}
Index: packages/Python/lldbsuite/test/functionalities/windows_dyld/main.c
===
--- packages/Python/lldbsuite/test/functionalities/windows_dyld/main.c
+++ packages/Python/lldbsuite/test/functionalities/windows_dyld/main.c
@@ -0,0 +1,19 @@
+//===-- main.c --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include 
+
+int __declspec(dllimport) DllFunc(int n);
+
+int main(int argc, char ** argv) {
+  int x = DllFunc(4);
+  int y = DllFunc(8);   // set breakpoint here
+  int z = DllFunc(16);
+  return x + y + z;
+}
Index: packages/Python/lldbsuite/test/functionalities/windows_dyld/TestWindowsDYLD.py
===
--- packages/Python/lldbsuite/test/functionalities/windows_dyld/TestWindowsDYLD.py
+++ packages/Python/lldbsuite/test/functionalities/windows_dyld/TestWindowsDYLD.py
@@ -0,0 +1,42 @@
+"""
+Test that breakpoints work in a DLL
+"""
+
+from __future__ import print_function
+
+import lldb
+from lldbsuite.test.decorators import 

[Lldb-commits] [PATCH] D54510: Force SHELL to be cmd.exe on Windows for the test suite

2018-11-15 Thread Nathan Lanza via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346993: Force SHELL to be cmd.exe on Windows for the test 
suite (authored by lanza, committed by ).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54510?vs=173984=174271#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54510

Files:
  packages/Python/lldbsuite/test/make/Makefile.rules


Index: packages/Python/lldbsuite/test/make/Makefile.rules
===
--- packages/Python/lldbsuite/test/make/Makefile.rules
+++ packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,6 +51,17 @@
 endif
 
 #--
+# If OS is Windows, force SHELL to be cmd
+#
+# Some versions of make on Windows will search for other shells such as
+# C:\cygwin\bin\sh.exe. This shell fails for numerous different reasons
+# so default to using cmd.exe.
+#--
+ifeq "$(OS)" "Windows_NT"
+   SHELL = $(WINDIR)\system32\cmd.exe
+endif
+
+#--
 # If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more
 # from the triple alone
 #--


Index: packages/Python/lldbsuite/test/make/Makefile.rules
===
--- packages/Python/lldbsuite/test/make/Makefile.rules
+++ packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,6 +51,17 @@
 endif
 
 #--
+# If OS is Windows, force SHELL to be cmd
+#
+# Some versions of make on Windows will search for other shells such as
+# C:\cygwin\bin\sh.exe. This shell fails for numerous different reasons
+# so default to using cmd.exe.
+#--
+ifeq "$(OS)" "Windows_NT"
+	SHELL = $(WINDIR)\system32\cmd.exe
+endif
+
+#--
 # If TRIPLE is not defined try to set the ARCH, CC, CFLAGS, and more
 # from the triple alone
 #--
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D53008: Add a check whether or not a str is utf8 prior to emplacing

2018-11-15 Thread Nathan Lanza via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346988: Add a check whether or not a str is utf8 prior to 
emplacing (authored by lanza, committed by ).
Herald added subscribers: lldb-commits, abidh.

Changed prior to commit:
  https://reviews.llvm.org/D53008?vs=174134=174264#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53008

Files:
  tools/lldb-vscode/JSONUtils.cpp
  tools/lldb-vscode/JSONUtils.h
  tools/lldb-vscode/VSCode.cpp
  tools/lldb-vscode/lldb-vscode.cpp

Index: tools/lldb-vscode/JSONUtils.h
===
--- tools/lldb-vscode/JSONUtils.h
+++ tools/lldb-vscode/JSONUtils.h
@@ -16,7 +16,24 @@
 #include "VSCodeForward.h"
 
 namespace lldb_vscode {
-  
+
+//--
+/// Emplace a StringRef in a json::Object after enusring that the
+/// string is valid UTF8. If not, first call llvm::json::fixUTF8
+/// before emplacing.
+///
+/// @param[in] obj
+/// A JSON object that we will attempt to emplace the value in
+///
+/// @param[in] key
+/// The key to use when emplacing the value
+///
+/// @param[in] str
+/// The string to emplace
+//--
+void EmplaceSafeString(llvm::json::Object , llvm::StringRef key,
+   llvm::StringRef str);
+
 //--
 /// Extract simple values as a string.
 ///
Index: tools/lldb-vscode/lldb-vscode.cpp
===
--- tools/lldb-vscode/lldb-vscode.cpp
+++ tools/lldb-vscode/lldb-vscode.cpp
@@ -289,7 +289,7 @@
   exe_fspec.GetPath(exe_path, sizeof(exe_path));
   llvm::json::Object event(CreateEventObject("process"));
   llvm::json::Object body;
-  body.try_emplace("name", std::string(exe_path));
+  EmplaceSafeString(body, "name", std::string(exe_path));
   const auto pid = g_vsc.target.GetProcess().GetProcessID();
   body.try_emplace("systemProcessId", (int64_t)pid);
   body.try_emplace("isLocalProcess", true);
@@ -539,7 +539,7 @@
 g_vsc.target.AddModule(program.data(), target_triple, uuid_cstr, symfile);
 if (error.Fail()) {
   response.try_emplace("success", false);
-  response.try_emplace("message", std::string(error.GetCString()));
+  EmplaceSafeString(response, "message", std::string(error.GetCString()));
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
   return;
 }
@@ -591,7 +591,7 @@
 
   if (error.Fail()) {
 response.try_emplace("success", false);
-response.try_emplace("message", std::string(error.GetCString()));
+EmplaceSafeString(response, "message", std::string(error.GetCString()));
   }
   g_vsc.SendJSON(llvm::json::Value(std::move(response)));
   if (error.Success()) {
@@ -813,8 +813,8 @@
 else if (stopReason == lldb::eStopReasonBreakpoint) {
   ExceptionBreakpoint *exc_bp = g_vsc.GetExceptionBPFromStopReason(thread);
   if (exc_bp) {
-body.try_emplace("exceptionId", exc_bp->filter);
-body.try_emplace("description", exc_bp->label);
+EmplaceSafeString(body, "exceptionId", exc_bp->filter);
+EmplaceSafeString(body, "description", exc_bp->label);
   } else {
 body.try_emplace("exceptionId", "exception");
   }
@@ -824,7 +824,7 @@
 if (!ObjectContainsKey(body, "description")) {
   char description[1024];
   if (thread.GetStopDescription(description, sizeof(description))) {
-body.try_emplace("description", std::string(description));
+EmplaceSafeString(body, "description", std::string(description));
   }
 }
 body.try_emplace("breakMode", "always");
@@ -951,9 +951,9 @@
   const auto expression = GetString(arguments, "expression");
 
   if (!expression.empty() && expression[0] == '`') {
-body.try_emplace("result",
- RunLLDBCommands(llvm::StringRef(),
- {expression.substr(1)}));
+auto result = RunLLDBCommands(llvm::StringRef(),
+ {expression.substr(1)});
+EmplaceSafeString(body, "result", result);
 body.try_emplace("variablesReference", (int64_t)0);
   } else {
 // Always try to get the answer from the local variables if possible. If
@@ -968,13 +968,13 @@
   response.try_emplace("success", false);
   const char *error_cstr = value.GetError().GetCString();
   if (error_cstr && error_cstr[0])
-response.try_emplace("message", std::string(error_cstr));
+EmplaceSafeString(response, "message", std::string(error_cstr));
   else
-response.try_emplace("message", "evaluate failed");
+EmplaceSafeString(response, "message", "evaluate failed");
 } else {
   SetValueForKey(value, body, "result");
   auto value_typename = value.GetType().GetDisplayTypeName();
-  body.try_emplace("type", 

[Lldb-commits] [PATCH] D53959: Remove working directory for debugserver code signing target

2018-11-06 Thread Nathan Lanza via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346281: Remove working directory for debugserver code 
signing target (authored by lanza, committed by ).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53959?vs=172815=172876#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53959

Files:
  tools/debugserver/source/CMakeLists.txt


Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -239,16 +239,14 @@
 codesign --force --sign ${LLDB_CODESIGN_IDENTITY}
 ${entitlements_flags}
 $
-WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
   )
   if(IOS)
 add_custom_command(TARGET debugserver-nonui
   POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E env CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE}
   codesign --force --sign ${LLDB_CODESIGN_IDENTITY}
   ${entitlements_flags}
   $
-  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
 )
   endif()
 endif()


Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -239,16 +239,14 @@
 codesign --force --sign ${LLDB_CODESIGN_IDENTITY}
 ${entitlements_flags}
 $
-WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
   )
   if(IOS)
 add_custom_command(TARGET debugserver-nonui
   POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E env CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE}
   codesign --force --sign ${LLDB_CODESIGN_IDENTITY}
   ${entitlements_flags}
   $
-  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
 )
   endif()
 endif()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51566: Add a relocation to ObjectFileELF::ApplyRelocations and a test

2018-11-06 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

LGTM and the test case passes. Thanks a lot, Davide!


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51566



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


[Lldb-commits] [PATCH] D52672: Set stdout/stdin to binary mode on Windows

2018-11-05 Thread Nathan Lanza via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346174: Set stdout/stdin to binary mode on Windows 
(authored by lanza, committed by ).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52672?vs=168705=172656#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D52672

Files:
  tools/lldb-vscode/VSCode.cpp


Index: tools/lldb-vscode/VSCode.cpp
===
--- tools/lldb-vscode/VSCode.cpp
+++ tools/lldb-vscode/VSCode.cpp
@@ -14,6 +14,11 @@
 #include "VSCode.h"
 #include "LLDBUtils.h"
 
+#if defined(_WIN32)
+#include 
+#include 
+#endif
+
 using namespace lldb_vscode;
 
 namespace {
@@ -39,6 +44,13 @@
   focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false),
   stop_at_entry(false) {
   const char *log_file_path = getenv("LLDBVSCODE_LOG");
+#if defined(_WIN32)
+// Windows opens stdout and stdin in text mode which converts \n to 13,10
+// while the value is just 10 on Darwin/Linux. Setting the file mode to binary
+// fixes this.
+  assert(_setmode(fileno(stdout), _O_BINARY));
+  assert(_setmode(fileno(stdin), _O_BINARY));
+#endif
   if (log_file_path)
 log.reset(new std::ofstream(log_file_path));
 }


Index: tools/lldb-vscode/VSCode.cpp
===
--- tools/lldb-vscode/VSCode.cpp
+++ tools/lldb-vscode/VSCode.cpp
@@ -14,6 +14,11 @@
 #include "VSCode.h"
 #include "LLDBUtils.h"
 
+#if defined(_WIN32)
+#include 
+#include 
+#endif
+
 using namespace lldb_vscode;
 
 namespace {
@@ -39,6 +44,13 @@
   focus_tid(LLDB_INVALID_THREAD_ID), sent_terminated_event(false),
   stop_at_entry(false) {
   const char *log_file_path = getenv("LLDBVSCODE_LOG");
+#if defined(_WIN32)
+// Windows opens stdout and stdin in text mode which converts \n to 13,10
+// while the value is just 10 on Darwin/Linux. Setting the file mode to binary
+// fixes this.
+  assert(_setmode(fileno(stdout), _O_BINARY));
+  assert(_setmode(fileno(stdin), _O_BINARY));
+#endif
   if (log_file_path)
 log.reset(new std::ofstream(log_file_path));
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D51566: Add a relocation to ObjectFileELF::ApplyRelocations and a test

2018-11-05 Thread Nathan Lanza via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346171: Add a relocation to 
ObjectFileELF::ApplyRelocations and a test (authored by lanza, committed by ).
Herald added a subscriber: lldb-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51566?vs=163617=172654#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51566

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  unittests/ObjectFile/ELF/CMakeLists.txt
  unittests/ObjectFile/ELF/Inputs/debug-info-relocations.pcm.yaml
  unittests/ObjectFile/ELF/TestObjectFileELF.cpp

Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2703,6 +2703,7 @@
   }
 } else {
   switch (reloc_type(rel)) {
+  case R_AARCH64_ABS64:
   case R_X86_64_64: {
 symbol = symtab->FindSymbolByID(reloc_symbol(rel));
 if (symbol) {
@@ -2722,13 +2723,15 @@
 if (symbol) {
   addr_t value = symbol->GetAddressRef().GetFileAddress();
   value += ELFRelocation::RelocAddend32(rel);
-  if ((reloc_type(rel) == R_X86_64_32 && (value <= UINT32_MAX)) ||
+  if ((reloc_type(rel) == R_X86_64_32 && (value > UINT32_MAX)) ||
   (reloc_type(rel) == R_X86_64_32S &&
-   ((int64_t)value <= INT32_MAX && (int64_t)value >= INT32_MIN)) ||
-  (reloc_type(rel) == R_AARCH64_ABS32 && (value <= UINT32_MAX))) {
+   ((int64_t)value > INT32_MAX && (int64_t)value < INT32_MIN)) ||
+  (reloc_type(rel) == R_AARCH64_ABS32 &&
+   ((int64_t)value > INT32_MAX && (int64_t)value < INT32_MIN))) {
 Log *log =
 lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES);
 log->Printf("Failed to apply debug info relocations");
+break;
   }
   uint32_t truncated_addr = (value & 0x);
   DataBufferSP _buffer_sp = debug_data.GetSharedDataBuffer();
Index: unittests/ObjectFile/ELF/TestObjectFileELF.cpp
===
--- unittests/ObjectFile/ELF/TestObjectFileELF.cpp
+++ unittests/ObjectFile/ELF/TestObjectFileELF.cpp
@@ -16,6 +16,7 @@
 #include "lldb/Core/Section.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/DataBufferHeap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/FileUtilities.h"
@@ -141,3 +142,64 @@
   Uuid.SetFromStringRef("1b8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9", 20);
   EXPECT_EQ(Spec.GetUUID(), Uuid);
 }
+
+#define CHECK_ABS32(offset, addend)\
+  ASSERT_EQ((uint32_t)addend, *(uint32_t *)(bytes + offset))
+#define CHECK_ABS64(offset, addend)\
+  ASSERT_EQ((uint64_t)addend, *(uint64_t *)(bytes + offset))
+
+TEST_F(ObjectFileELFTest, TestAARCH64Relocations) {
+  std::string yaml = GetInputFilePath("debug-info-relocations.pcm.yaml");
+  llvm::SmallString<128> obj;
+  ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile(
+  "debug-info-relocations-%%", "obj", obj));
+
+  llvm::FileRemover remover(obj);
+  llvm::StringRef args[] = {YAML2OBJ, yaml};
+  llvm::StringRef obj_ref = obj;
+  const llvm::Optional redirects[] = {llvm::None, obj_ref,
+   llvm::None};
+  ASSERT_EQ(0,
+llvm::sys::ExecuteAndWait(YAML2OBJ, args, llvm::None, redirects));
+  uint64_t size;
+  ASSERT_NO_ERROR(llvm::sys::fs::file_size(obj, size));
+  ASSERT_GT(size, 0u);
+
+  ModuleSpec spec{FileSpec(obj)};
+  spec.GetSymbolFileSpec().SetFile(obj, FileSpec::Style::native);
+  auto module_sp = std::make_shared(spec);
+
+  auto objfile = static_cast(module_sp->GetObjectFile());
+  SectionList *section_list = objfile->GetSectionList();
+  ASSERT_NE(nullptr, section_list);
+
+  auto debug_info_sp =
+  section_list->FindSectionByName(ConstString(".debug_info"));
+  ASSERT_NE(nullptr, debug_info_sp);
+  objfile->RelocateSection(debug_info_sp.get());
+
+  DataExtractor data;
+  // length of 0x10 is not needed but length 0x0 crashes
+  objfile->GetData(0x00, 0x10, data);
+  DataBufferSP _buffer_sp = data.GetSharedDataBuffer();
+  uint8_t *bytes = data_buffer_sp->GetBytes();
+
+  addr_t debug_info_offset = debug_info_sp->GetFileOffset();
+  bytes += debug_info_offset;
+
+  // Sanity check - The first byte from the yaml file is 0x47
+  ASSERT_EQ(0x47, *bytes);
+
+  // .rela.debug_info contains 9 relocations:
+  // 7 R_AARCH64_ABS32 - 2 R_AARCH64_ABS64
+  // None have a value. Four have addends.
+  CHECK_ABS32(0x6, 0);
+  CHECK_ABS32(0xC, 0);
+  CHECK_ABS32(0x12, 45);
+  CHECK_ABS32(0x16, 0);
+  CHECK_ABS32(0x1A, 55);
+  CHECK_ABS64(0x1E, 0);
+  CHECK_ABS64(0x2B, 0);
+  CHECK_ABS32(0x39, 73);
+