Skip to content

Commit 34a821b

Browse files
[lldb] add a marker before skipped frames
1 parent 15bbdd1 commit 34a821b

File tree

4 files changed

+66
-11
lines changed

4 files changed

+66
-11
lines changed

lldb/include/lldb/Target/StackFrame.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,16 @@ class StackFrame : public ExecutionContextScope,
335335
/// \param[in] frame_marker
336336
/// Optional string that will be prepended to the frame output description.
337337
///
338+
/// \param[in] skipped_frame_marker
339+
/// Optional string that will be prepended to the first or last non skipped
340+
/// frame output description.
341+
///
338342
/// \return
339343
/// \b true if and only if dumping with the given \p format worked.
340344
bool DumpUsingFormat(Stream &strm,
341345
const lldb_private::FormatEntity::Entry *format,
342-
llvm::StringRef frame_marker = {});
346+
llvm::StringRef frame_marker = {},
347+
llvm::StringRef skipped_frame_marker = {});
343348

344349
/// Print a description for this frame using the frame-format formatter
345350
/// settings. If the current frame-format settings are invalid, then the
@@ -353,8 +358,13 @@ class StackFrame : public ExecutionContextScope,
353358
///
354359
/// \param [in] frame_marker
355360
/// Optional string that will be prepended to the frame output description.
361+
///
362+
/// \param[in] skipped_frame_marker
363+
/// Optional string that will be prepended to the first or last non skipped
364+
/// frame output description.
356365
void DumpUsingSettingsFormat(Stream *strm, bool show_unique = false,
357-
const char *frame_marker = nullptr);
366+
const char *frame_marker = nullptr,
367+
const std::wstring skipped_frame_marker = L"");
358368

359369
/// Print a description for this frame using a default format.
360370
///
@@ -387,10 +397,15 @@ class StackFrame : public ExecutionContextScope,
387397
/// \param[in] frame_marker
388398
/// Passed to DumpUsingSettingsFormat() for the frame info printing.
389399
///
400+
///
401+
/// \param[in] skipped_frame_marker
402+
/// Optional string that will be prepended to the first or last non skipped
403+
/// frame output description.
390404
/// \return
391405
/// Returns true if successful.
392406
bool GetStatus(Stream &strm, bool show_frame_info, bool show_source,
393-
bool show_unique = false, const char *frame_marker = nullptr);
407+
bool show_unique = false, const char *frame_marker = nullptr,
408+
const std::wstring skipped_frame_marker = L"");
394409

395410
/// Query whether this frame is a concrete frame on the call stack, or if it
396411
/// is an inlined frame derived from the debug information and presented by

lldb/include/lldb/Target/StackFrameList.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ class StackFrameList {
4949
/// Resets the selected frame index of this object.
5050
void ClearSelectedFrameIndex();
5151

52+
/// Return \code true if the next frame is hidden. False otherwise or if it's
53+
/// the last frame.
54+
bool IsNextFrameHidden(lldb_private::StackFrame &frame);
55+
56+
/// Return \code true if the previous frame is hidden. False otherwise or if
57+
/// it's the first frame.
58+
bool IsPreviousFrameHidden(lldb_private::StackFrame &frame);
59+
5260
/// Get the currently selected frame index.
5361
/// We should only call SelectMostRelevantFrame if (a) the user hasn't already
5462
/// selected a frame, and (b) if this really is a user facing

lldb/source/Target/StackFrame.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "lldb/ValueObject/ValueObjectConstResult.h"
3838
#include "lldb/ValueObject/ValueObjectMemory.h"
3939
#include "lldb/ValueObject/ValueObjectVariable.h"
40+
#include "llvm/Support/ConvertUTF.h"
4041

4142
#include "lldb/lldb-enumerations.h"
4243

@@ -1920,11 +1921,13 @@ void StackFrame::CalculateExecutionContext(ExecutionContext &exe_ctx) {
19201921

19211922
bool StackFrame::DumpUsingFormat(Stream &strm,
19221923
const FormatEntity::Entry *format,
1923-
llvm::StringRef frame_marker) {
1924+
llvm::StringRef frame_marker,
1925+
llvm::StringRef skipped_frame_marker) {
19241926
GetSymbolContext(eSymbolContextEverything);
19251927
ExecutionContext exe_ctx(shared_from_this());
19261928
StreamString s;
19271929
s.PutCString(frame_marker);
1930+
s.PutCString(skipped_frame_marker);
19281931

19291932
if (format && FormatEntity::Format(*format, s, &m_sc, &exe_ctx, nullptr,
19301933
nullptr, false, false)) {
@@ -1934,8 +1937,9 @@ bool StackFrame::DumpUsingFormat(Stream &strm,
19341937
return false;
19351938
}
19361939

1937-
void StackFrame::DumpUsingSettingsFormat(Stream *strm, bool show_unique,
1938-
const char *frame_marker) {
1940+
void StackFrame::DumpUsingSettingsFormat(
1941+
Stream *strm, bool show_unique, const char *frame_marker,
1942+
const std::wstring skipped_frame_marker) {
19391943
if (strm == nullptr)
19401944
return;
19411945

@@ -1953,7 +1957,11 @@ void StackFrame::DumpUsingSettingsFormat(Stream *strm, bool show_unique,
19531957
frame_format = &format_entry;
19541958
}
19551959
}
1956-
if (!DumpUsingFormat(*strm, frame_format, frame_marker)) {
1960+
1961+
std::string skipped_frame_delimiter_utf8;
1962+
llvm::convertWideToUTF8(skipped_frame_marker, skipped_frame_delimiter_utf8);
1963+
if (!DumpUsingFormat(*strm, frame_format, frame_marker,
1964+
skipped_frame_delimiter_utf8)) {
19571965
Dump(strm, true, false);
19581966
strm->EOL();
19591967
}
@@ -2034,10 +2042,12 @@ bool StackFrame::HasCachedData() const {
20342042
}
20352043

20362044
bool StackFrame::GetStatus(Stream &strm, bool show_frame_info, bool show_source,
2037-
bool show_unique, const char *frame_marker) {
2045+
bool show_unique, const char *frame_marker,
2046+
const std::wstring skipped_frame_marker) {
20382047
if (show_frame_info) {
20392048
strm.Indent();
2040-
DumpUsingSettingsFormat(&strm, show_unique, frame_marker);
2049+
DumpUsingSettingsFormat(&strm, show_unique, frame_marker,
2050+
skipped_frame_marker);
20412051
}
20422052

20432053
if (show_source) {

lldb/source/Target/StackFrameList.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,24 @@ StackFrameList::GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr) {
879879
return ret_sp;
880880
}
881881

882+
bool StackFrameList::IsNextFrameHidden(lldb_private::StackFrame &frame) {
883+
uint32_t frame_idx = frame.GetFrameIndex();
884+
StackFrameSP frame_sp = GetFrameAtIndex(frame_idx + 1);
885+
if (!frame_sp)
886+
return false;
887+
return frame_sp->IsHidden();
888+
}
889+
890+
bool StackFrameList::IsPreviousFrameHidden(lldb_private::StackFrame &frame) {
891+
uint32_t frame_idx = frame.GetFrameIndex();
892+
if (frame_idx == 0)
893+
return false;
894+
StackFrameSP frame_sp = GetFrameAtIndex(frame_idx - 1);
895+
if (!frame_sp)
896+
return false;
897+
return frame_sp->IsHidden();
898+
}
899+
882900
size_t StackFrameList::GetStatus(Stream &strm, uint32_t first_frame,
883901
uint32_t num_frames, bool show_frame_info,
884902
uint32_t num_frames_with_source,
@@ -920,6 +938,11 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t first_frame,
920938
else
921939
marker = unselected_marker;
922940
}
941+
std::wstring skipped_frame_marker = L" ";
942+
if (IsPreviousFrameHidden(*frame_sp))
943+
skipped_frame_marker = L"";
944+
else if (IsNextFrameHidden(*frame_sp))
945+
skipped_frame_marker = L"";
923946

924947
// Hide uninteresting frames unless it's the selected frame.
925948
if (!show_hidden && frame_sp != selected_frame_sp && frame_sp->IsHidden())
@@ -933,10 +956,9 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t first_frame,
933956
m_thread.GetID(), num_frames_displayed))
934957
break;
935958

936-
937959
if (!frame_sp->GetStatus(strm, show_frame_info,
938960
num_frames_with_source > (first_frame - frame_idx),
939-
show_unique, marker))
961+
show_unique, marker, skipped_frame_marker))
940962
break;
941963
++num_frames_displayed;
942964
}

0 commit comments

Comments
 (0)