LLDB  mainline
ValueObjectUpdater.cpp
Go to the documentation of this file.
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 
10 
11 using namespace lldb_private;
12 
13 ValueObjectUpdater::ValueObjectUpdater(lldb::ValueObjectSP in_valobj_sp) {
14  if (!in_valobj_sp)
15  return;
16  // If the user passes in a value object that is dynamic or synthetic, then
17  // water it down to the static type.
18  m_root_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(
19  lldb::eNoDynamicValues, false);
20 }
21 
22 lldb::ValueObjectSP ValueObjectUpdater::GetSP() {
23  lldb::ProcessSP process_sp = GetProcessSP();
24  if (!process_sp)
25  return lldb::ValueObjectSP();
26 
27  const uint32_t current_stop_id = process_sp->GetLastNaturalStopID();
28  if (current_stop_id == m_stop_id)
29  return m_user_valobj_sp;
30 
31  m_stop_id = current_stop_id;
32 
33  if (!m_root_valobj_sp) {
34  m_user_valobj_sp.reset();
35  return m_root_valobj_sp;
36  }
37 
39 
40  lldb::ValueObjectSP dynamic_sp =
42  if (dynamic_sp)
43  m_user_valobj_sp = dynamic_sp;
44 
45  lldb::ValueObjectSP synthetic_sp = m_user_valobj_sp->GetSyntheticValue();
46  if (synthetic_sp)
47  m_user_valobj_sp = synthetic_sp;
48 
49  return m_user_valobj_sp;
50 }
51 
52 lldb::ProcessSP ValueObjectUpdater::GetProcessSP() const {
53  if (m_root_valobj_sp)
54  return m_root_valobj_sp->GetProcessSP();
55  return lldb::ProcessSP();
56 }
lldb_private::ValueObjectUpdater::ValueObjectUpdater
ValueObjectUpdater(lldb::ValueObjectSP in_valobj_sp)
Definition: ValueObjectUpdater.cpp:13
lldb::eNoDynamicValues
@ eNoDynamicValues
Definition: lldb-enumerations.h:495
lldb_private::ValueObjectUpdater::GetSP
lldb::ValueObjectSP GetSP()
Gets the correct value object from the root object for a given process stop ID.
Definition: ValueObjectUpdater.cpp:22
lldb_private::ValueObjectUpdater::m_root_valobj_sp
lldb::ValueObjectSP m_root_valobj_sp
The root value object is the static typed variable object.
Definition: ValueObjectUpdater.h:23
lldb::eDynamicDontRunTarget
@ eDynamicDontRunTarget
Definition: lldb-enumerations.h:497
lldb_private::ValueObjectUpdater::m_stop_id
uint32_t m_stop_id
The stop ID that m_user_valobj_sp is valid for.
Definition: ValueObjectUpdater.h:27
lldb_private::ValueObjectUpdater::GetProcessSP
lldb::ProcessSP GetProcessSP() const
Definition: ValueObjectUpdater.cpp:52
uint32_t
ValueObjectUpdater.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ValueObjectUpdater::m_user_valobj_sp
lldb::ValueObjectSP m_user_valobj_sp
The user value object is the value object the user wants to see.
Definition: ValueObjectUpdater.h:25