[Lldb-commits] [PATCH] D144078: [lldb] Fix a log format warning on Windows, don't assume uint64_t is a long type

2023-02-15 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo created this revision.
mstorsjo added reviewers: Emmmer, DavidSpickett, JDevlieghere, labath.
Herald added subscribers: luke, frasercrmck, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added subscribers: pcwang-thead, MaskRay.
Herald added a project: LLDB.

On Windows, long is 32 bit, and uint64_t is long long.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144078

Files:
  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp


Index: lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
===
--- lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -636,7 +636,7 @@
 if ((inst & pat.type_mask) == pat.eigen &&
 (inst_type & pat.inst_type) != 0) {
   LLDB_LOGF(
-  log, "EmulateInstructionRISCV::%s: inst(%x at %lx) was decoded to 
%s",
+  log, "EmulateInstructionRISCV::%s: inst(%x at %" PRIx64 ") was 
decoded to %s",
   __FUNCTION__, inst, m_addr, pat.name);
   auto decoded = is_rvc ? pat.decode(try_rvc) : pat.decode(inst);
   return DecodeResult{decoded, inst, is_rvc, pat};


Index: lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
===
--- lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -636,7 +636,7 @@
 if ((inst & pat.type_mask) == pat.eigen &&
 (inst_type & pat.inst_type) != 0) {
   LLDB_LOGF(
-  log, "EmulateInstructionRISCV::%s: inst(%x at %lx) was decoded to %s",
+  log, "EmulateInstructionRISCV::%s: inst(%x at %" PRIx64 ") was decoded to %s",
   __FUNCTION__, inst, m_addr, pat.name);
   auto decoded = is_rvc ? pat.decode(try_rvc) : pat.decode(inst);
   return DecodeResult{decoded, inst, is_rvc, pat};
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a8483b9 - [lldb] Fix a log format warning on Windows, don't assume uint64_t is a long type

2023-02-15 Thread Martin Storsjö via lldb-commits

Author: Martin Storsjö
Date: 2023-02-15T14:44:17+02:00
New Revision: a8483b9b30385807790882b3b770fa6d016a0aa4

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

LOG: [lldb] Fix a log format warning on Windows, don't assume uint64_t is a 
long type

On Windows, long is 32 bit, and uint64_t is long long.

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

Added: 


Modified: 
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp 
b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
index 06772aaa6e17c..414e53fef7342 100644
--- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -636,7 +636,7 @@ std::optional 
EmulateInstructionRISCV::Decode(uint32_t inst) {
 if ((inst & pat.type_mask) == pat.eigen &&
 (inst_type & pat.inst_type) != 0) {
   LLDB_LOGF(
-  log, "EmulateInstructionRISCV::%s: inst(%x at %lx) was decoded to 
%s",
+  log, "EmulateInstructionRISCV::%s: inst(%x at %" PRIx64 ") was 
decoded to %s",
   __FUNCTION__, inst, m_addr, pat.name);
   auto decoded = is_rvc ? pat.decode(try_rvc) : pat.decode(inst);
   return DecodeResult{decoded, inst, is_rvc, pat};



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


[Lldb-commits] [PATCH] D144078: [lldb] Fix a log format warning on Windows, don't assume uint64_t is a long type

2023-02-15 Thread Martin Storsjö via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa8483b9b3038: [lldb] Fix a log format warning on Windows, 
don't assume uint64_t is a long type (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144078

Files:
  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp


Index: lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
===
--- lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -636,7 +636,7 @@
 if ((inst & pat.type_mask) == pat.eigen &&
 (inst_type & pat.inst_type) != 0) {
   LLDB_LOGF(
-  log, "EmulateInstructionRISCV::%s: inst(%x at %lx) was decoded to 
%s",
+  log, "EmulateInstructionRISCV::%s: inst(%x at %" PRIx64 ") was 
decoded to %s",
   __FUNCTION__, inst, m_addr, pat.name);
   auto decoded = is_rvc ? pat.decode(try_rvc) : pat.decode(inst);
   return DecodeResult{decoded, inst, is_rvc, pat};


Index: lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
===
--- lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -636,7 +636,7 @@
 if ((inst & pat.type_mask) == pat.eigen &&
 (inst_type & pat.inst_type) != 0) {
   LLDB_LOGF(
-  log, "EmulateInstructionRISCV::%s: inst(%x at %lx) was decoded to %s",
+  log, "EmulateInstructionRISCV::%s: inst(%x at %" PRIx64 ") was decoded to %s",
   __FUNCTION__, inst, m_addr, pat.name);
   auto decoded = is_rvc ? pat.decode(try_rvc) : pat.decode(inst);
   return DecodeResult{decoded, inst, is_rvc, pat};
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D142792: Add SBValue::GetValueAsAddress(), strip off ptrauth, TBI, MTE bits on AArch64 systems

2023-02-15 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Looking good, one question left on the test file.




Comment at: lldb/source/API/SBValue.cpp:936
+  if (ABISP abi_sp = process_sp->GetABI())
+return abi_sp->FixCodeAddress(ret_val);
+return ret_val;

jasonmolenda wrote:
> DavidSpickett wrote:
> > We've talked about this before, and for now I think the result of `FixCode` 
> > and `FixData` are the same for debug purposes. In the event that that ever 
> > changes, our path is probably to document this as assuming a code address, 
> > then adding specific `ValueAsCodeAddress` and `ValueAsDataAddress`, correct?
> > 
> > (which sounds good to me, just checking we've thought that through)
> > 
> > You could document that in the docstring but there's a good chance it would 
> > cause more confusion than it's worth when at this time, it's not something 
> > users have to care about.
> Yeah, this is a good point that I punted on a bit.  On Darwin we are only 
> using TCR_EL1.T0SZ to tell us how many bits are used for addressing; there's 
> no distinction between code and data for us.  I guess I should worry about 
> someone defining a `FixCodeAddress` method in an ABI plugin that clears lower 
> bits when instruction alignment is required.  It may be that it's safer to 
> use FixDataAddress if I have to choose between the two without any context.  
> In our internal implementation in the apple sources, we only had FixAddress 
> which were used for both.  What do you think?
There is FixAnyAddress which is intended to be the least destructive of the 2, 
but not necessarily the correct one. If we truly have to handle code and data 
addresses differently I think we'll have a whole ABI/platform/architecture 
break to worry about on top of that.

Keep it as is. Just flagging it in case you'd had any concerns there, if you've 
got experience using it and it's fine that's good enough for me.



Comment at: 
lldb/test/API/api/clear-sbvalue-nonadressable-bits/TestClearSBValueNonAddressableBits.py:29
+self.runCmd ("v v v_p v_invalid_p")
+self.runCmd ("v &v &v_p &v_invalid_p")
+

Can you expand the alias here, all the vs are making my head spin.



Comment at: lldb/test/API/api/clear-sbvalue-nonadressable-bits/main.c:16
+
+  scratch = (intptr_t) dlsym(RTLD_DEFAULT, "main");
+  scratch |= (3ULL << 60);

Do you need the `dlsym` here for a specific reason? I'm not familiar with what 
that does.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142792

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


[Lldb-commits] [PATCH] D144114: [lldb] Add expression command options in dwim-print

2023-02-15 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: jingham, Michael137, augusto2112, aprantl.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Adopt `expression`'s options in `dwim-print`.

This is primarily added to support the `--language`/`-l` flag.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144114

Files:
  lldb/source/Commands/CommandObjectDWIMPrint.cpp
  lldb/source/Commands/CommandObjectDWIMPrint.h
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectExpression.h
  lldb/test/API/commands/dwim-print/TestDWIMPrint.py

Index: lldb/test/API/commands/dwim-print/TestDWIMPrint.py
===
--- lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -103,3 +103,14 @@
 lldbutil.run_to_name_breakpoint(self, "main")
 self._expect_cmd(f"dwim-print -T -- argc", "frame variable")
 self._expect_cmd(f"dwim-print -T -- argc + 1", "expression")
+
+def test_expression_language(self):
+self.build()
+lldbutil.run_to_name_breakpoint(self, "main")
+self._expect_cmd(f"dwim-print -l c++ -- argc + 1", "expression")
+
+def test_expression_top_level(self):
+self.build()
+lldbutil.run_to_name_breakpoint(self, "main")
+with self.assertRaises(AssertionError):
+self._expect_cmd(f"dwim-print -p -- argc + 1", "expression")
Index: lldb/source/Commands/CommandObjectExpression.h
===
--- lldb/source/Commands/CommandObjectExpression.h
+++ lldb/source/Commands/CommandObjectExpression.h
@@ -35,6 +35,12 @@
 
 void OptionParsingStarting(ExecutionContext *execution_context) override;
 
+/// Return the appropriate expression options used for evaluating the
+/// expression in the given target.
+EvaluateExpressionOptions
+GetEvalateExpressionOptions(const Target &target, bool use_objc,
+lldb::DynamicValueType use_dynamic);
+
 bool top_level;
 bool unwind_on_error;
 bool ignore_breakpoints;
@@ -67,10 +73,6 @@
 
   bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
 
-  /// Return the appropriate expression options used for evaluating the
-  /// expression in the given target.
-  EvaluateExpressionOptions GetEvalOptions(const Target &target);
-
   /// Evaluates the given expression.
   /// \param output_stream The stream to which the evaluation result will be
   ///  printed.
Index: lldb/source/Commands/CommandObjectExpression.cpp
===
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -181,6 +181,48 @@
   return llvm::ArrayRef(g_expression_options);
 }
 
+EvaluateExpressionOptions
+CommandObjectExpression::CommandOptions::GetEvalateExpressionOptions(
+const Target &target, bool use_objc, lldb::DynamicValueType use_dynamic) {
+  EvaluateExpressionOptions options;
+  options.SetCoerceToId(use_objc);
+  if (m_verbosity == eLanguageRuntimeDescriptionDisplayVerbosityCompact)
+options.SetSuppressPersistentResult(use_objc);
+  options.SetUnwindOnError(unwind_on_error);
+  options.SetIgnoreBreakpoints(ignore_breakpoints);
+  options.SetKeepInMemory(true);
+  options.SetUseDynamic(use_dynamic);
+  options.SetTryAllThreads(try_all_threads);
+  options.SetDebug(debug);
+  options.SetLanguage(language);
+  options.SetExecutionPolicy(
+  allow_jit ? EvaluateExpressionOptions::default_execution_policy
+: lldb_private::eExecutionPolicyNever);
+
+  bool auto_apply_fixits;
+  if (this->auto_apply_fixits == eLazyBoolCalculate)
+auto_apply_fixits = target.GetEnableAutoApplyFixIts();
+  else
+auto_apply_fixits = this->auto_apply_fixits == eLazyBoolYes;
+
+  options.SetAutoApplyFixIts(auto_apply_fixits);
+  options.SetRetriesWithFixIts(target.GetNumberOfRetriesWithFixits());
+
+  if (top_level)
+options.SetExecutionPolicy(eExecutionPolicyTopLevel);
+
+  // If there is any chance we are going to stop and want to see what went
+  // wrong with our expression, we should generate debug info
+  if (!ignore_breakpoints || !unwind_on_error)
+options.SetGenerateDebugInfo(true);
+
+  if (timeout > 0)
+options.SetTimeout(std::chrono::microseconds(timeout));
+  else
+options.SetTimeout(std::nullopt);
+  return options;
+}
+
 CommandObjectExpression::CommandObjectExpression(
 CommandInterpreter &interpreter)
 : CommandObjectRaw(interpreter, "expression",
@@ -343,50 +385,6 @@
   return Status();
 }
 
-EvaluateExpressionOptions
-CommandObjectExpression::GetEvalOptions(const Target &target) {
-  EvaluateExpressionOptions options;
-  options.SetCoerceToId(m_varobj_op

[Lldb-commits] [PATCH] D144114: [lldb] Add expression command options in dwim-print

2023-02-15 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 497720.
kastiglione added a comment.

Some `expression` flags force the use of expression evaluation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144114

Files:
  lldb/source/Commands/CommandObjectDWIMPrint.cpp
  lldb/source/Commands/CommandObjectDWIMPrint.h
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectExpression.h
  lldb/test/API/commands/dwim-print/TestDWIMPrint.py

Index: lldb/test/API/commands/dwim-print/TestDWIMPrint.py
===
--- lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -103,3 +103,19 @@
 lldbutil.run_to_name_breakpoint(self, "main")
 self._expect_cmd(f"dwim-print -T -- argc", "frame variable")
 self._expect_cmd(f"dwim-print -T -- argc + 1", "expression")
+
+def test_expression_language(self):
+"""Text dwim-print uses the language flag, if necessary."""
+self.build()
+lldbutil.run_to_name_breakpoint(self, "main")
+self._expect_cmd(f"dwim-print -l c++ -- argc", "frame variable")
+self._expect_cmd(f"dwim-print -l c++ -- argc + 1", "expression")
+
+def test_forced_expression(self):
+"""Test dwim-print flags that force expression evaluation."""
+self.build()
+lldbutil.run_to_name_breakpoint(self, "main")
+self._expect_cmd(f"dwim-print --debug -- argc", "expression")
+with self.assertRaises(AssertionError):
+# At the top-level, `argc` is not visible.
+self._expect_cmd(f"dwim-print --top-level -- argc", "expression")
Index: lldb/source/Commands/CommandObjectExpression.h
===
--- lldb/source/Commands/CommandObjectExpression.h
+++ lldb/source/Commands/CommandObjectExpression.h
@@ -35,6 +35,12 @@
 
 void OptionParsingStarting(ExecutionContext *execution_context) override;
 
+/// Return the appropriate expression options used for evaluating the
+/// expression in the given target.
+EvaluateExpressionOptions
+GetEvalateExpressionOptions(const Target &target, bool use_objc,
+lldb::DynamicValueType use_dynamic);
+
 bool top_level;
 bool unwind_on_error;
 bool ignore_breakpoints;
@@ -67,10 +73,6 @@
 
   bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
 
-  /// Return the appropriate expression options used for evaluating the
-  /// expression in the given target.
-  EvaluateExpressionOptions GetEvalOptions(const Target &target);
-
   /// Evaluates the given expression.
   /// \param output_stream The stream to which the evaluation result will be
   ///  printed.
Index: lldb/source/Commands/CommandObjectExpression.cpp
===
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -181,6 +181,48 @@
   return llvm::ArrayRef(g_expression_options);
 }
 
+EvaluateExpressionOptions
+CommandObjectExpression::CommandOptions::GetEvalateExpressionOptions(
+const Target &target, bool use_objc, lldb::DynamicValueType use_dynamic) {
+  EvaluateExpressionOptions options;
+  options.SetCoerceToId(use_objc);
+  if (m_verbosity == eLanguageRuntimeDescriptionDisplayVerbosityCompact)
+options.SetSuppressPersistentResult(use_objc);
+  options.SetUnwindOnError(unwind_on_error);
+  options.SetIgnoreBreakpoints(ignore_breakpoints);
+  options.SetKeepInMemory(true);
+  options.SetUseDynamic(use_dynamic);
+  options.SetTryAllThreads(try_all_threads);
+  options.SetDebug(debug);
+  options.SetLanguage(language);
+  options.SetExecutionPolicy(
+  allow_jit ? EvaluateExpressionOptions::default_execution_policy
+: lldb_private::eExecutionPolicyNever);
+
+  bool auto_apply_fixits;
+  if (this->auto_apply_fixits == eLazyBoolCalculate)
+auto_apply_fixits = target.GetEnableAutoApplyFixIts();
+  else
+auto_apply_fixits = this->auto_apply_fixits == eLazyBoolYes;
+
+  options.SetAutoApplyFixIts(auto_apply_fixits);
+  options.SetRetriesWithFixIts(target.GetNumberOfRetriesWithFixits());
+
+  if (top_level)
+options.SetExecutionPolicy(eExecutionPolicyTopLevel);
+
+  // If there is any chance we are going to stop and want to see what went
+  // wrong with our expression, we should generate debug info
+  if (!ignore_breakpoints || !unwind_on_error)
+options.SetGenerateDebugInfo(true);
+
+  if (timeout > 0)
+options.SetTimeout(std::chrono::microseconds(timeout));
+  else
+options.SetTimeout(std::nullopt);
+  return options;
+}
+
 CommandObjectExpression::CommandObjectExpression(
 CommandInterpreter &interpreter)
 : CommandObjectRaw(interpreter, "expression",
@@ -343,50 +385,6 @@
  

[Lldb-commits] [PATCH] D144114: [lldb] Add expression command options in dwim-print

2023-02-15 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 497723.
kastiglione added a comment.

Use `expression`'s "description verbosity"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144114

Files:
  lldb/source/Commands/CommandObjectDWIMPrint.cpp
  lldb/source/Commands/CommandObjectDWIMPrint.h
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectExpression.h
  lldb/test/API/commands/dwim-print/TestDWIMPrint.py

Index: lldb/test/API/commands/dwim-print/TestDWIMPrint.py
===
--- lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -103,3 +103,19 @@
 lldbutil.run_to_name_breakpoint(self, "main")
 self._expect_cmd(f"dwim-print -T -- argc", "frame variable")
 self._expect_cmd(f"dwim-print -T -- argc + 1", "expression")
+
+def test_expression_language(self):
+"""Text dwim-print uses the language flag, if necessary."""
+self.build()
+lldbutil.run_to_name_breakpoint(self, "main")
+self._expect_cmd(f"dwim-print -l c++ -- argc", "frame variable")
+self._expect_cmd(f"dwim-print -l c++ -- argc + 1", "expression")
+
+def test_forced_expression(self):
+"""Test dwim-print flags that force expression evaluation."""
+self.build()
+lldbutil.run_to_name_breakpoint(self, "main")
+self._expect_cmd(f"dwim-print --debug -- argc", "expression")
+with self.assertRaises(AssertionError):
+# At the top-level, `argc` is not visible.
+self._expect_cmd(f"dwim-print --top-level -- argc", "expression")
Index: lldb/source/Commands/CommandObjectExpression.h
===
--- lldb/source/Commands/CommandObjectExpression.h
+++ lldb/source/Commands/CommandObjectExpression.h
@@ -35,6 +35,12 @@
 
 void OptionParsingStarting(ExecutionContext *execution_context) override;
 
+/// Return the appropriate expression options used for evaluating the
+/// expression in the given target.
+EvaluateExpressionOptions
+GetEvalateExpressionOptions(const Target &target, bool use_objc,
+lldb::DynamicValueType use_dynamic);
+
 bool top_level;
 bool unwind_on_error;
 bool ignore_breakpoints;
@@ -67,10 +73,6 @@
 
   bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
 
-  /// Return the appropriate expression options used for evaluating the
-  /// expression in the given target.
-  EvaluateExpressionOptions GetEvalOptions(const Target &target);
-
   /// Evaluates the given expression.
   /// \param output_stream The stream to which the evaluation result will be
   ///  printed.
Index: lldb/source/Commands/CommandObjectExpression.cpp
===
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -181,6 +181,48 @@
   return llvm::ArrayRef(g_expression_options);
 }
 
+EvaluateExpressionOptions
+CommandObjectExpression::CommandOptions::GetEvalateExpressionOptions(
+const Target &target, bool use_objc, lldb::DynamicValueType use_dynamic) {
+  EvaluateExpressionOptions options;
+  options.SetCoerceToId(use_objc);
+  if (m_verbosity == eLanguageRuntimeDescriptionDisplayVerbosityCompact)
+options.SetSuppressPersistentResult(use_objc);
+  options.SetUnwindOnError(unwind_on_error);
+  options.SetIgnoreBreakpoints(ignore_breakpoints);
+  options.SetKeepInMemory(true);
+  options.SetUseDynamic(use_dynamic);
+  options.SetTryAllThreads(try_all_threads);
+  options.SetDebug(debug);
+  options.SetLanguage(language);
+  options.SetExecutionPolicy(
+  allow_jit ? EvaluateExpressionOptions::default_execution_policy
+: lldb_private::eExecutionPolicyNever);
+
+  bool auto_apply_fixits;
+  if (this->auto_apply_fixits == eLazyBoolCalculate)
+auto_apply_fixits = target.GetEnableAutoApplyFixIts();
+  else
+auto_apply_fixits = this->auto_apply_fixits == eLazyBoolYes;
+
+  options.SetAutoApplyFixIts(auto_apply_fixits);
+  options.SetRetriesWithFixIts(target.GetNumberOfRetriesWithFixits());
+
+  if (top_level)
+options.SetExecutionPolicy(eExecutionPolicyTopLevel);
+
+  // If there is any chance we are going to stop and want to see what went
+  // wrong with our expression, we should generate debug info
+  if (!ignore_breakpoints || !unwind_on_error)
+options.SetGenerateDebugInfo(true);
+
+  if (timeout > 0)
+options.SetTimeout(std::chrono::microseconds(timeout));
+  else
+options.SetTimeout(std::nullopt);
+  return options;
+}
+
 CommandObjectExpression::CommandObjectExpression(
 CommandInterpreter &interpreter)
 : CommandObjectRaw(interpreter, "expression",
@@ -343,50 +385,6 @@
   return Status();
 }

[Lldb-commits] [PATCH] D144138: [lldb] Remove pydoc import during script interpreter init

2023-02-15 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: jasonmolenda, mib, jingham, aprantl.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The Python script interpreter imports `pydoc` during initialization, but this 
can be
slow in some cases, and doesn't seem to be necessary any more.

This can be slow because pydoc may execute shell commands (for example `xcrun` 
on
macOS). The shell commands may have variable performance, depending on their 
caches and
search space.

The 2012 bug report for the original commit 
(f71a837bfdc1ddeeb30c6a8897554a11c382)
says the following:

> "script help" in lldb pipes the help documentation through less(1) but 
> there's some
> problem with the key handling and often the keys you'd use to move in less 
> (space to
> move down a page, 'q' to quit) are not received by less (they're going to lldb
> instead)

This was resolved at the time by overriding `pydoc`'s pager to be the 
`plainpager`
function.

I have manually tested `script help(lldb.SBDebugger)` and found no issues with 
the
pager, including using "space" for paging, "/" for searching, and "q" for 
quitting.

The presumption is that lldb and/or Python have improved I/O handling that 
eliminates
the original problem.

The original bug report gave an ~/.lldbinit workaround:

  script import pydoc; pydoc.pager = pydoc.plainpager

Note that calling Python's `help()` will import `pydoc`, but this will only 
happen for
users who use `help()` from the `script` command.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144138

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
@@ -442,7 +442,7 @@
   // do their task
   run_string.Clear();
   run_string.Printf(
-  "run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp, 
pydoc')",
+  "run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp')",
   m_dictionary_name.c_str());
   PyRun_SimpleString(run_string.GetData());
   run_string.Clear();
@@ -455,7 +455,7 @@
   run_string.Clear();
 
   run_string.Printf("run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64
-"; pydoc.pager = pydoc.plainpager')",
+"')",
 m_dictionary_name.c_str(), m_debugger.GetID());
   PyRun_SimpleString(run_string.GetData());
 }


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -442,7 +442,7 @@
   // do their task
   run_string.Clear();
   run_string.Printf(
-  "run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp, pydoc')",
+  "run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp')",
   m_dictionary_name.c_str());
   PyRun_SimpleString(run_string.GetData());
   run_string.Clear();
@@ -455,7 +455,7 @@
   run_string.Clear();
 
   run_string.Printf("run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64
-"; pydoc.pager = pydoc.plainpager')",
+"')",
 m_dictionary_name.c_str(), m_debugger.GetID());
   PyRun_SimpleString(run_string.GetData());
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D144142: [debugserver] Initialize logging earlier in the startup sequence

2023-02-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added a reviewer: jasonmolenda.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Prior to setting up logging, we have uses of RNBLogSTDERR and
RNBLogSTDOUT. These macros will dump to STDERR and STDOUT respectively
if debugserver has a tty. Otherwise, it uses _DNBLog, which will do
nothing if a logging function hasn't been set up. For example, if you
specify a log file that cannot be opened for any reason and you don't
have a tty, you have 0 insight into what happened.

rdar://105473133


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144142

Files:
  lldb/tools/debugserver/source/debugserver.cpp


Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -945,6 +945,21 @@
   sigaddset(&sigset, SIGCHLD);
   sigprocmask(SIG_BLOCK, &sigset, NULL);
 
+  // Set up DNB logging by default. If the user passes different log flags or a
+  // log file, these settings will be modified after processing the command 
line
+  // arguments.
+  auto log_callback = OsLogger::GetLogFunction();
+  if (log_callback) {
+// if os_log() support is available, log through that.
+DNBLogSetLogCallback(log_callback, nullptr);
+DNBLog("debugserver will use os_log for internal logging.");
+  } else {
+// Fall back to ASL support.
+DNBLogSetLogCallback(ASLLogCallback, nullptr);
+DNBLog("debugserver will use ASL for internal logging.");
+  }
+  DNBLogSetLogMask(/*log_flags*/ 0);
+
   g_remoteSP = std::make_shared();
 
   RNBRemote *remote = g_remoteSP.get();
@@ -1318,26 +1333,13 @@
   // It is ok for us to set NULL as the logfile (this will disable any logging)
 
   if (log_file != NULL) {
+DNBLog("debugserver is switching to logging to a file.");
 DNBLogSetLogCallback(FileLogCallback, log_file);
 // If our log file was set, yet we have no log flags, log everything!
 if (log_flags == 0)
   log_flags = LOG_ALL | LOG_RNB_ALL;
 
 DNBLogSetLogMask(log_flags);
-  } else {
-// Enable DNB logging
-
-// if os_log() support is available, log through that.
-auto log_callback = OsLogger::GetLogFunction();
-if (log_callback) {
-  DNBLogSetLogCallback(log_callback, nullptr);
-  DNBLog("debugserver will use os_log for internal logging.");
-} else {
-  // Fall back to ASL support.
-  DNBLogSetLogCallback(ASLLogCallback, NULL);
-  DNBLog("debugserver will use ASL for internal logging.");
-}
-DNBLogSetLogMask(log_flags);
   }
 
   if (DNBLogEnabled()) {


Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -945,6 +945,21 @@
   sigaddset(&sigset, SIGCHLD);
   sigprocmask(SIG_BLOCK, &sigset, NULL);
 
+  // Set up DNB logging by default. If the user passes different log flags or a
+  // log file, these settings will be modified after processing the command line
+  // arguments.
+  auto log_callback = OsLogger::GetLogFunction();
+  if (log_callback) {
+// if os_log() support is available, log through that.
+DNBLogSetLogCallback(log_callback, nullptr);
+DNBLog("debugserver will use os_log for internal logging.");
+  } else {
+// Fall back to ASL support.
+DNBLogSetLogCallback(ASLLogCallback, nullptr);
+DNBLog("debugserver will use ASL for internal logging.");
+  }
+  DNBLogSetLogMask(/*log_flags*/ 0);
+
   g_remoteSP = std::make_shared();
 
   RNBRemote *remote = g_remoteSP.get();
@@ -1318,26 +1333,13 @@
   // It is ok for us to set NULL as the logfile (this will disable any logging)
 
   if (log_file != NULL) {
+DNBLog("debugserver is switching to logging to a file.");
 DNBLogSetLogCallback(FileLogCallback, log_file);
 // If our log file was set, yet we have no log flags, log everything!
 if (log_flags == 0)
   log_flags = LOG_ALL | LOG_RNB_ALL;
 
 DNBLogSetLogMask(log_flags);
-  } else {
-// Enable DNB logging
-
-// if os_log() support is available, log through that.
-auto log_callback = OsLogger::GetLogFunction();
-if (log_callback) {
-  DNBLogSetLogCallback(log_callback, nullptr);
-  DNBLog("debugserver will use os_log for internal logging.");
-} else {
-  // Fall back to ASL support.
-  DNBLogSetLogCallback(ASLLogCallback, NULL);
-  DNBLog("debugserver will use ASL for internal logging.");
-}
-DNBLogSetLogMask(log_flags);
   }
 
   if (DNBLogEnabled()) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D144142: [debugserver] Initialize logging earlier in the startup sequence

2023-02-15 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added inline comments.



Comment at: lldb/tools/debugserver/source/debugserver.cpp:1342
 
 DNBLogSetLogMask(log_flags);
   }

Should this be moved out of this `log_file != NULL` block so that the logging 
flags are set based on `-f` value?  Otherwise looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144142

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


[Lldb-commits] [PATCH] D144142: [debugserver] Initialize logging earlier in the startup sequence

2023-02-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added inline comments.



Comment at: lldb/tools/debugserver/source/debugserver.cpp:1342
 
 DNBLogSetLogMask(log_flags);
   }

jasonmolenda wrote:
> Should this be moved out of this `log_file != NULL` block so that the logging 
> flags are set based on `-f` value?  Otherwise looks good to me.
Good catch, that is indeed the case. I'll update this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144142

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


[Lldb-commits] [PATCH] D144142: [debugserver] Initialize logging earlier in the startup sequence

2023-02-15 Thread Alex Langford via Phabricator via lldb-commits
bulbazord updated this revision to Diff 497818.
bulbazord added a comment.

Moving second use of DNBSetLogMask outside of the log file block


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144142

Files:
  lldb/tools/debugserver/source/debugserver.cpp


Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -945,6 +945,21 @@
   sigaddset(&sigset, SIGCHLD);
   sigprocmask(SIG_BLOCK, &sigset, NULL);
 
+  // Set up DNB logging by default. If the user passes different log flags or a
+  // log file, these settings will be modified after processing the command 
line
+  // arguments.
+  auto log_callback = OsLogger::GetLogFunction();
+  if (log_callback) {
+// if os_log() support is available, log through that.
+DNBLogSetLogCallback(log_callback, nullptr);
+DNBLog("debugserver will use os_log for internal logging.");
+  } else {
+// Fall back to ASL support.
+DNBLogSetLogCallback(ASLLogCallback, nullptr);
+DNBLog("debugserver will use ASL for internal logging.");
+  }
+  DNBLogSetLogMask(/*log_flags*/ 0);
+
   g_remoteSP = std::make_shared();
 
   RNBRemote *remote = g_remoteSP.get();
@@ -1318,27 +1333,13 @@
   // It is ok for us to set NULL as the logfile (this will disable any logging)
 
   if (log_file != NULL) {
+DNBLog("debugserver is switching to logging to a file.");
 DNBLogSetLogCallback(FileLogCallback, log_file);
 // If our log file was set, yet we have no log flags, log everything!
 if (log_flags == 0)
   log_flags = LOG_ALL | LOG_RNB_ALL;
-
-DNBLogSetLogMask(log_flags);
-  } else {
-// Enable DNB logging
-
-// if os_log() support is available, log through that.
-auto log_callback = OsLogger::GetLogFunction();
-if (log_callback) {
-  DNBLogSetLogCallback(log_callback, nullptr);
-  DNBLog("debugserver will use os_log for internal logging.");
-} else {
-  // Fall back to ASL support.
-  DNBLogSetLogCallback(ASLLogCallback, NULL);
-  DNBLog("debugserver will use ASL for internal logging.");
-}
-DNBLogSetLogMask(log_flags);
   }
+  DNBLogSetLogMask(log_flags);
 
   if (DNBLogEnabled()) {
 for (i = 0; i < argc; i++)


Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -945,6 +945,21 @@
   sigaddset(&sigset, SIGCHLD);
   sigprocmask(SIG_BLOCK, &sigset, NULL);
 
+  // Set up DNB logging by default. If the user passes different log flags or a
+  // log file, these settings will be modified after processing the command line
+  // arguments.
+  auto log_callback = OsLogger::GetLogFunction();
+  if (log_callback) {
+// if os_log() support is available, log through that.
+DNBLogSetLogCallback(log_callback, nullptr);
+DNBLog("debugserver will use os_log for internal logging.");
+  } else {
+// Fall back to ASL support.
+DNBLogSetLogCallback(ASLLogCallback, nullptr);
+DNBLog("debugserver will use ASL for internal logging.");
+  }
+  DNBLogSetLogMask(/*log_flags*/ 0);
+
   g_remoteSP = std::make_shared();
 
   RNBRemote *remote = g_remoteSP.get();
@@ -1318,27 +1333,13 @@
   // It is ok for us to set NULL as the logfile (this will disable any logging)
 
   if (log_file != NULL) {
+DNBLog("debugserver is switching to logging to a file.");
 DNBLogSetLogCallback(FileLogCallback, log_file);
 // If our log file was set, yet we have no log flags, log everything!
 if (log_flags == 0)
   log_flags = LOG_ALL | LOG_RNB_ALL;
-
-DNBLogSetLogMask(log_flags);
-  } else {
-// Enable DNB logging
-
-// if os_log() support is available, log through that.
-auto log_callback = OsLogger::GetLogFunction();
-if (log_callback) {
-  DNBLogSetLogCallback(log_callback, nullptr);
-  DNBLog("debugserver will use os_log for internal logging.");
-} else {
-  // Fall back to ASL support.
-  DNBLogSetLogCallback(ASLLogCallback, NULL);
-  DNBLog("debugserver will use ASL for internal logging.");
-}
-DNBLogSetLogMask(log_flags);
   }
+  DNBLogSetLogMask(log_flags);
 
   if (DNBLogEnabled()) {
 for (i = 0; i < argc; i++)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] f1ddfa6 - [lldb] Remove pydoc import during script interpreter init

2023-02-15 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2023-02-15T15:25:59-08:00
New Revision: f1ddfa6d8a72bcc89e01ab8f73bbe5ae5a0dc475

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

LOG: [lldb] Remove pydoc import during script interpreter init

The Python script interpreter imports `pydoc` during initialization, but this 
can be
slow in some cases, and doesn't seem to be necessary any more.

This can be slow because pydoc may execute shell commands (for example `xcrun` 
on
macOS). The shell commands may have variable performance, depending on their 
caches and
search space.

The 2012 bug report for the original commit 
(f71a837bfdc1ddeeb30c6a8897554a11c382)
says the following:

> "script help" in lldb pipes the help documentation through less(1) but 
> there's some
> problem with the key handling and often the keys you'd use to move in less 
> (space to
> move down a page, 'q' to quit) are not received by less (they're going to lldb
> instead)

This was resolved at the time by overriding `pydoc`'s pager to be the 
`plainpager`
function.

I have manually tested `script help(lldb.SBDebugger)` and found no issues with 
the
pager, including using "space" for paging, "/" for searching, and "q" for 
quitting.

The presumption is that lldb and/or Python have improved I/O handling that 
eliminates
the original problem.

The original bug report gave an ~/.lldbinit workaround:

```
script import pydoc; pydoc.pager = pydoc.plainpager
```

Note that calling Python's `help()` will import `pydoc`, but this will only 
happen for
users who use `help()` from the `script` command.

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

Added: 


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

Removed: 




diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 1a2307424750d..edce7c894e4d3 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -441,7 +441,7 @@ 
ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger)
   // do their task
   run_string.Clear();
   run_string.Printf(
-  "run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp, 
pydoc')",
+  "run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp')",
   m_dictionary_name.c_str());
   PyRun_SimpleString(run_string.GetData());
   run_string.Clear();
@@ -454,7 +454,7 @@ 
ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger)
   run_string.Clear();
 
   run_string.Printf("run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64
-"; pydoc.pager = pydoc.plainpager')",
+"')",
 m_dictionary_name.c_str(), m_debugger.GetID());
   PyRun_SimpleString(run_string.GetData());
 }



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


[Lldb-commits] [PATCH] D144138: [lldb] Remove pydoc import during script interpreter init

2023-02-15 Thread Dave Lee via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1ddfa6d8a72: [lldb] Remove pydoc import during script 
interpreter init (authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144138

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
@@ -441,7 +441,7 @@
   // do their task
   run_string.Clear();
   run_string.Printf(
-  "run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp, 
pydoc')",
+  "run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp')",
   m_dictionary_name.c_str());
   PyRun_SimpleString(run_string.GetData());
   run_string.Clear();
@@ -454,7 +454,7 @@
   run_string.Clear();
 
   run_string.Printf("run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64
-"; pydoc.pager = pydoc.plainpager')",
+"')",
 m_dictionary_name.c_str(), m_debugger.GetID());
   PyRun_SimpleString(run_string.GetData());
 }


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -441,7 +441,7 @@
   // do their task
   run_string.Clear();
   run_string.Printf(
-  "run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp, pydoc')",
+  "run_one_line (%s, 'import lldb.formatters, lldb.formatters.cpp')",
   m_dictionary_name.c_str());
   PyRun_SimpleString(run_string.GetData());
   run_string.Clear();
@@ -454,7 +454,7 @@
   run_string.Clear();
 
   run_string.Printf("run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64
-"; pydoc.pager = pydoc.plainpager')",
+"')",
 m_dictionary_name.c_str(), m_debugger.GetID());
   PyRun_SimpleString(run_string.GetData());
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D144114: [lldb] Add expression command options in dwim-print

2023-02-15 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Conceptually, I think this looks good to me.




Comment at: lldb/source/Commands/CommandObjectDWIMPrint.cpp:68
   // First, try `expr` as the name of a frame variable.
-  if (StackFrame *frame = m_exe_ctx.GetFramePtr()) {
-auto valobj_sp = frame->FindVariable(ConstString(expr));
-if (valobj_sp && valobj_sp->GetError().Success()) {
-  if (verbosity == eDWIMPrintVerbosityFull) {
-StringRef flags;
-if (args.HasArgs())
-  flags = args.GetArgString();
-result.AppendMessageWithFormatv("note: ran `frame variable {0}{1}`",
-flags, expr);
+  bool force_expression = m_expr_options.debug || m_expr_options.top_level;
+  if (!force_expression) {

Maybe comment here that these are the only options that only make sense in the 
expression evaluator?



Comment at: lldb/test/API/commands/dwim-print/TestDWIMPrint.py:119
+self._expect_cmd(f"dwim-print --debug -- argc", "expression")
+with self.assertRaises(AssertionError):
+# At the top-level, `argc` is not visible.

why is this needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144114

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


[Lldb-commits] [lldb] dcf18e4 - [debugserver] Initialize logging earlier in the startup sequence

2023-02-15 Thread Alex Langford via lldb-commits

Author: Alex Langford
Date: 2023-02-15T16:35:51-08:00
New Revision: dcf18e4757b2bc2410031e7b69082117d540a1d6

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

LOG: [debugserver] Initialize logging earlier in the startup sequence

Prior to setting up logging, we have uses of RNBLogSTDERR and
RNBLogSTDOUT. These macros will dump to STDERR and STDOUT respectively
if debugserver has a tty. Otherwise, it uses _DNBLog, which will do
nothing if a logging function hasn't been set up. For example, if you
specify a log file that cannot be opened for any reason and you don't
have a tty, you have 0 insight into what happened.

rdar://105473133

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

Added: 


Modified: 
lldb/tools/debugserver/source/debugserver.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/debugserver.cpp 
b/lldb/tools/debugserver/source/debugserver.cpp
index cbff6ac56f773..cfc9646ed2d08 100644
--- a/lldb/tools/debugserver/source/debugserver.cpp
+++ b/lldb/tools/debugserver/source/debugserver.cpp
@@ -945,6 +945,21 @@ int main(int argc, char *argv[]) {
   sigaddset(&sigset, SIGCHLD);
   sigprocmask(SIG_BLOCK, &sigset, NULL);
 
+  // Set up DNB logging by default. If the user passes 
diff erent log flags or a
+  // log file, these settings will be modified after processing the command 
line
+  // arguments.
+  auto log_callback = OsLogger::GetLogFunction();
+  if (log_callback) {
+// if os_log() support is available, log through that.
+DNBLogSetLogCallback(log_callback, nullptr);
+DNBLog("debugserver will use os_log for internal logging.");
+  } else {
+// Fall back to ASL support.
+DNBLogSetLogCallback(ASLLogCallback, nullptr);
+DNBLog("debugserver will use ASL for internal logging.");
+  }
+  DNBLogSetLogMask(/*log_flags*/ 0);
+
   g_remoteSP = std::make_shared();
 
   RNBRemote *remote = g_remoteSP.get();
@@ -1318,27 +1333,13 @@ int main(int argc, char *argv[]) {
   // It is ok for us to set NULL as the logfile (this will disable any logging)
 
   if (log_file != NULL) {
+DNBLog("debugserver is switching to logging to a file.");
 DNBLogSetLogCallback(FileLogCallback, log_file);
 // If our log file was set, yet we have no log flags, log everything!
 if (log_flags == 0)
   log_flags = LOG_ALL | LOG_RNB_ALL;
-
-DNBLogSetLogMask(log_flags);
-  } else {
-// Enable DNB logging
-
-// if os_log() support is available, log through that.
-auto log_callback = OsLogger::GetLogFunction();
-if (log_callback) {
-  DNBLogSetLogCallback(log_callback, nullptr);
-  DNBLog("debugserver will use os_log for internal logging.");
-} else {
-  // Fall back to ASL support.
-  DNBLogSetLogCallback(ASLLogCallback, NULL);
-  DNBLog("debugserver will use ASL for internal logging.");
-}
-DNBLogSetLogMask(log_flags);
   }
+  DNBLogSetLogMask(log_flags);
 
   if (DNBLogEnabled()) {
 for (i = 0; i < argc; i++)



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


[Lldb-commits] [PATCH] D144142: [debugserver] Initialize logging earlier in the startup sequence

2023-02-15 Thread Alex Langford via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdcf18e4757b2: [debugserver] Initialize logging earlier in 
the startup sequence (authored by bulbazord).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144142

Files:
  lldb/tools/debugserver/source/debugserver.cpp


Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -945,6 +945,21 @@
   sigaddset(&sigset, SIGCHLD);
   sigprocmask(SIG_BLOCK, &sigset, NULL);
 
+  // Set up DNB logging by default. If the user passes different log flags or a
+  // log file, these settings will be modified after processing the command 
line
+  // arguments.
+  auto log_callback = OsLogger::GetLogFunction();
+  if (log_callback) {
+// if os_log() support is available, log through that.
+DNBLogSetLogCallback(log_callback, nullptr);
+DNBLog("debugserver will use os_log for internal logging.");
+  } else {
+// Fall back to ASL support.
+DNBLogSetLogCallback(ASLLogCallback, nullptr);
+DNBLog("debugserver will use ASL for internal logging.");
+  }
+  DNBLogSetLogMask(/*log_flags*/ 0);
+
   g_remoteSP = std::make_shared();
 
   RNBRemote *remote = g_remoteSP.get();
@@ -1318,27 +1333,13 @@
   // It is ok for us to set NULL as the logfile (this will disable any logging)
 
   if (log_file != NULL) {
+DNBLog("debugserver is switching to logging to a file.");
 DNBLogSetLogCallback(FileLogCallback, log_file);
 // If our log file was set, yet we have no log flags, log everything!
 if (log_flags == 0)
   log_flags = LOG_ALL | LOG_RNB_ALL;
-
-DNBLogSetLogMask(log_flags);
-  } else {
-// Enable DNB logging
-
-// if os_log() support is available, log through that.
-auto log_callback = OsLogger::GetLogFunction();
-if (log_callback) {
-  DNBLogSetLogCallback(log_callback, nullptr);
-  DNBLog("debugserver will use os_log for internal logging.");
-} else {
-  // Fall back to ASL support.
-  DNBLogSetLogCallback(ASLLogCallback, NULL);
-  DNBLog("debugserver will use ASL for internal logging.");
-}
-DNBLogSetLogMask(log_flags);
   }
+  DNBLogSetLogMask(log_flags);
 
   if (DNBLogEnabled()) {
 for (i = 0; i < argc; i++)


Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -945,6 +945,21 @@
   sigaddset(&sigset, SIGCHLD);
   sigprocmask(SIG_BLOCK, &sigset, NULL);
 
+  // Set up DNB logging by default. If the user passes different log flags or a
+  // log file, these settings will be modified after processing the command line
+  // arguments.
+  auto log_callback = OsLogger::GetLogFunction();
+  if (log_callback) {
+// if os_log() support is available, log through that.
+DNBLogSetLogCallback(log_callback, nullptr);
+DNBLog("debugserver will use os_log for internal logging.");
+  } else {
+// Fall back to ASL support.
+DNBLogSetLogCallback(ASLLogCallback, nullptr);
+DNBLog("debugserver will use ASL for internal logging.");
+  }
+  DNBLogSetLogMask(/*log_flags*/ 0);
+
   g_remoteSP = std::make_shared();
 
   RNBRemote *remote = g_remoteSP.get();
@@ -1318,27 +1333,13 @@
   // It is ok for us to set NULL as the logfile (this will disable any logging)
 
   if (log_file != NULL) {
+DNBLog("debugserver is switching to logging to a file.");
 DNBLogSetLogCallback(FileLogCallback, log_file);
 // If our log file was set, yet we have no log flags, log everything!
 if (log_flags == 0)
   log_flags = LOG_ALL | LOG_RNB_ALL;
-
-DNBLogSetLogMask(log_flags);
-  } else {
-// Enable DNB logging
-
-// if os_log() support is available, log through that.
-auto log_callback = OsLogger::GetLogFunction();
-if (log_callback) {
-  DNBLogSetLogCallback(log_callback, nullptr);
-  DNBLog("debugserver will use os_log for internal logging.");
-} else {
-  // Fall back to ASL support.
-  DNBLogSetLogCallback(ASLLogCallback, NULL);
-  DNBLog("debugserver will use ASL for internal logging.");
-}
-DNBLogSetLogMask(log_flags);
   }
+  DNBLogSetLogMask(log_flags);
 
   if (DNBLogEnabled()) {
 for (i = 0; i < argc; i++)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D143698: Support Debugging TLS variable with lldb

2023-02-15 Thread Kamlesh Kumar via Phabricator via lldb-commits
kkcode0 added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143698

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