Skip to content

Commit 2473c13

Browse files
[LLDB][NFC] Remove redundant target/process checks in SBFrame
This is a follow up to llvm#152020, continuing the removal of now-redundant `if(process && target)` checks. Since this causes a diff in every line of the affected functions, this commit also uses the opportunity to create some helper functions and reduce nesting of the affected methods by rewriting all pre-condition checks as early returns, while remaining strictly NFC. This has exposed some odd behaviors: 1. `SBFrame::GetVariables` has a variable `num_produced` which is clearly meant to be incremented on every iteration of the loop but it is only incremented once, after the loop. So its value is always 0 or 1. The variable now lives in `FetchVariablesUnlessInterrupted`. 2. `SBFrame::GetVariables` has an interruption mechanism for local variables, but not for "recognized arguments". It's unclear if this is by design or not, but it is now evident that there is a discrepancy there. 3. In `SBFrame::EvaluateExpression` we only log some error paths, but not all of them. To stick to the strictly NFC nature of this patch, it does not address any of these issues.
1 parent 1ffc38c commit 2473c13

File tree

2 files changed

+273
-256
lines changed

2 files changed

+273
-256
lines changed

lldb/include/lldb/API/SBFrame.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "lldb/API/SBValueList.h"
1414

1515
namespace lldb_private {
16+
class StackFrame;
17+
class Debugger;
1618
namespace python {
1719
class SWIGBridge;
1820
}
@@ -237,6 +239,23 @@ class LLDB_API SBFrame {
237239
/// not currently stopped.
238240
static SBValue CreateProcessIsRunningExprEvalError();
239241

242+
enum WasInterrupted { Yes, No };
243+
244+
/// Populates `value_list` with the variables from `frame` according to
245+
/// `options`. This method checks whether the Debugger received an interrupt
246+
/// before processing every variable, returning `WasInterrupted::yes` in that
247+
/// case.
248+
static WasInterrupted FetchVariablesUnlessInterrupted(
249+
const lldb::SBVariablesOptions &options, lldb_private::StackFrame &frame,
250+
SBValueList &value_list, lldb_private::Debugger &dbg);
251+
252+
/// Populates `value_list` with recognized arguments of `frame` according to
253+
/// `options`.
254+
static void FetchRecognizedArguments(const SBVariablesOptions &options,
255+
lldb_private::StackFrame &frame,
256+
SBTarget target,
257+
SBValueList &value_list);
258+
240259
lldb::ExecutionContextRefSP m_opaque_sp;
241260
};
242261

0 commit comments

Comments
 (0)