================
@@ -0,0 +1,183 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Target/BorrowedStackFrame.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+char BorrowedStackFrame::ID;
+
+BorrowedStackFrame::BorrowedStackFrame(
+    StackFrameSP borrowed_frame_sp, uint32_t new_frame_index,
+    std::optional<uint32_t> new_concrete_frame_index)
+    : StackFrame(
+          borrowed_frame_sp->GetThread(), new_frame_index,
+          borrowed_frame_sp->GetConcreteFrameIndex(),
+          borrowed_frame_sp->GetRegisterContextSP(),
+          borrowed_frame_sp->GetStackID().GetPC(),
+          borrowed_frame_sp->GetStackID().GetCallFrameAddressWithoutMetadata(),
+          borrowed_frame_sp->m_behaves_like_zeroth_frame,
+          &borrowed_frame_sp->GetSymbolContext(eSymbolContextEverything)),
+      m_borrowed_frame_sp(borrowed_frame_sp),
+      m_new_frame_index(new_frame_index),
+      m_new_concrete_frame_index(new_concrete_frame_index
+                                     ? *new_concrete_frame_index
+                                     : new_frame_index) {}
+
+uint32_t BorrowedStackFrame::GetFrameIndex() const { return m_new_frame_index; 
}
+
+void BorrowedStackFrame::SetFrameIndex(uint32_t index) {
+  m_new_frame_index = index;
+}
+
+uint32_t BorrowedStackFrame::GetConcreteFrameIndex() {
+  // Inline frames don't have their own concrete frame index.
----------------
jimingham wrote:

That comment is not right.  Inline frames have the concrete frame index of the 
unwind frame in which they were inlined.  A better comment would be:

`// FIXME: We need to find where the concrete frame into which this frame was 
inlined 
  // landed in the new stack frame list as that is the correct concrete frame 
index in this
  //stack frame.
`
But I also don't think you want to actually check IsInlined here.  Rather, when 
you set the m_new_concrete_frame_index in the constructor, you want to do:

new_concrete_frame_index
                                     ? *new_concrete_frame_index
                                     : IsInlined() ? LLDB_INVALID_ID : 
new_frame_index

then GetConcreteFrameIndex can just report whatever got set.

https://github.com/llvm/llvm-project/pull/170191
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to