llvm-project
56 строк · 1.7 Кб
1//===-- ValueObjectUpdater.cpp --------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/Core/ValueObjectUpdater.h"
10
11using namespace lldb_private;
12
13ValueObjectUpdater::ValueObjectUpdater(lldb::ValueObjectSP in_valobj_sp) {
14if (!in_valobj_sp)
15return;
16// If the user passes in a value object that is dynamic or synthetic, then
17// water it down to the static type.
18m_root_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(
19lldb::eNoDynamicValues, false);
20}
21
22lldb::ValueObjectSP ValueObjectUpdater::GetSP() {
23lldb::ProcessSP process_sp = GetProcessSP();
24if (!process_sp)
25return lldb::ValueObjectSP();
26
27const uint32_t current_stop_id = process_sp->GetLastNaturalStopID();
28if (current_stop_id == m_stop_id)
29return m_user_valobj_sp;
30
31m_stop_id = current_stop_id;
32
33if (!m_root_valobj_sp) {
34m_user_valobj_sp.reset();
35return m_root_valobj_sp;
36}
37
38m_user_valobj_sp = m_root_valobj_sp;
39
40lldb::ValueObjectSP dynamic_sp =
41m_user_valobj_sp->GetDynamicValue(lldb::eDynamicDontRunTarget);
42if (dynamic_sp)
43m_user_valobj_sp = dynamic_sp;
44
45lldb::ValueObjectSP synthetic_sp = m_user_valobj_sp->GetSyntheticValue();
46if (synthetic_sp)
47m_user_valobj_sp = synthetic_sp;
48
49return m_user_valobj_sp;
50}
51
52lldb::ProcessSP ValueObjectUpdater::GetProcessSP() const {
53if (m_root_valobj_sp)
54return m_root_valobj_sp->GetProcessSP();
55return lldb::ProcessSP();
56}
57