124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//===-- SBBlock.cpp ---------------------------------------------*- C++ -*-===//
224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//
324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//                     The LLVM Compiler Infrastructure
424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//
524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// This file is distributed under the University of Illinois Open Source
624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner// License. See LICENSE.TXT for details.
724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//
824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner//===----------------------------------------------------------------------===//
924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner
1024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/API/SBBlock.h"
1123b8abbe214c252028f6e09f79169529c846409dGreg Clayton#include "lldb/API/SBAddress.h"
1269aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton#include "lldb/API/SBFileSpec.h"
137dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton#include "lldb/API/SBFrame.h"
1498f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice#include "lldb/API/SBStream.h"
157dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton#include "lldb/API/SBValue.h"
1623b8abbe214c252028f6e09f79169529c846409dGreg Clayton#include "lldb/Core/AddressRange.h"
177dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton#include "lldb/Core/Log.h"
187dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton#include "lldb/Core/ValueObjectVariable.h"
1924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner#include "lldb/Symbol/Block.h"
2069aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton#include "lldb/Symbol/Function.h"
2198f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice#include "lldb/Symbol/SymbolContext.h"
227dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton#include "lldb/Symbol/VariableList.h"
237dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton#include "lldb/Target/StackFrame.h"
247dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton#include "lldb/Target/Target.h"
2524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner
2624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattnerusing namespace lldb;
2769aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Claytonusing namespace lldb_private;
2824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner
2924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner
3024943d2ee8bfaa7cf5893e4709143924157a5c1eChris LattnerSBBlock::SBBlock () :
3163094e0bb161580564954dee512955c1c79d3476Greg Clayton    m_opaque_ptr (NULL)
3224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{
3324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner}
3424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner
3524943d2ee8bfaa7cf5893e4709143924157a5c1eChris LattnerSBBlock::SBBlock (lldb_private::Block *lldb_object_ptr) :
3663094e0bb161580564954dee512955c1c79d3476Greg Clayton    m_opaque_ptr (lldb_object_ptr)
3724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{
3824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner}
3924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner
40538eb82a89a68dbc57251915080bd5152b333978Greg ClaytonSBBlock::SBBlock(const SBBlock &rhs) :
41538eb82a89a68dbc57251915080bd5152b333978Greg Clayton    m_opaque_ptr (rhs.m_opaque_ptr)
42538eb82a89a68dbc57251915080bd5152b333978Greg Clayton{
43538eb82a89a68dbc57251915080bd5152b333978Greg Clayton}
44538eb82a89a68dbc57251915080bd5152b333978Greg Clayton
45538eb82a89a68dbc57251915080bd5152b333978Greg Claytonconst SBBlock &
46538eb82a89a68dbc57251915080bd5152b333978Greg ClaytonSBBlock::operator = (const SBBlock &rhs)
47538eb82a89a68dbc57251915080bd5152b333978Greg Clayton{
48538eb82a89a68dbc57251915080bd5152b333978Greg Clayton    m_opaque_ptr = rhs.m_opaque_ptr;
49538eb82a89a68dbc57251915080bd5152b333978Greg Clayton    return *this;
50538eb82a89a68dbc57251915080bd5152b333978Greg Clayton}
51538eb82a89a68dbc57251915080bd5152b333978Greg Clayton
5224943d2ee8bfaa7cf5893e4709143924157a5c1eChris LattnerSBBlock::~SBBlock ()
5324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{
5463094e0bb161580564954dee512955c1c79d3476Greg Clayton    m_opaque_ptr = NULL;
5524943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner}
5624943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner
5724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattnerbool
5824943d2ee8bfaa7cf5893e4709143924157a5c1eChris LattnerSBBlock::IsValid () const
5924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{
6063094e0bb161580564954dee512955c1c79d3476Greg Clayton    return m_opaque_ptr != NULL;
6124943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner}
6224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner
6369aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Claytonbool
6469aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock::IsInlined () const
6569aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton{
6669aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    if (m_opaque_ptr)
6769aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        return m_opaque_ptr->GetInlinedFunctionInfo () != NULL;
6869aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    return false;
6969aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton}
7069aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton
7169aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Claytonconst char *
7269aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock::GetInlinedName () const
7369aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton{
7469aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    if (m_opaque_ptr)
7569aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    {
7669aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo ();
7769aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        if (inlined_info)
7869aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton            return inlined_info->GetName().AsCString (NULL);
7969aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    }
8069aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    return NULL;
8169aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton}
8269aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton
8369aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBFileSpec
8469aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock::GetInlinedCallSiteFile () const
8569aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton{
8669aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    SBFileSpec sb_file;
8769aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    if (m_opaque_ptr)
8869aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    {
8969aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo ();
9069aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        if (inlined_info)
9169aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton            sb_file.SetFileSpec (inlined_info->GetCallSite().GetFile());
9269aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    }
9369aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    return sb_file;
9469aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton}
9569aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton
9669aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Claytonuint32_t
9769aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock::GetInlinedCallSiteLine () const
9869aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton{
9969aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    if (m_opaque_ptr)
10069aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    {
10169aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo ();
10269aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        if (inlined_info)
10369aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton            return inlined_info->GetCallSite().GetLine();
10469aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    }
10569aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    return 0;
10669aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton}
10769aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton
10869aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Claytonuint32_t
10969aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock::GetInlinedCallSiteColumn () const
11069aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton{
11169aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    if (m_opaque_ptr)
11269aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    {
11369aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo ();
11469aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        if (inlined_info)
11569aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton            return inlined_info->GetCallSite().GetColumn();
11669aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    }
11769aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    return 0;
11869aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton}
11969aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton
12024943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattnervoid
12124943d2ee8bfaa7cf5893e4709143924157a5c1eChris LattnerSBBlock::AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list)
12224943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner{
12324943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner    if (IsValid())
12424943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner    {
12533ed170599d41fe407a4dcf5f0875c75e1ad1375Greg Clayton        bool show_inline = true;
12633ed170599d41fe407a4dcf5f0875c75e1ad1375Greg Clayton        m_opaque_ptr->AppendVariables (can_create, get_parent_variables, show_inline, var_list);
12724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner    }
12824943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner}
12924943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner
13069aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock
13169aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock::GetParent ()
13269aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton{
13369aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    SBBlock sb_block;
13469aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    if (m_opaque_ptr)
13569aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        sb_block.m_opaque_ptr = m_opaque_ptr->GetParent();
13669aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    return sb_block;
13769aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton}
13869aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton
13923b8abbe214c252028f6e09f79169529c846409dGreg Claytonlldb::SBBlock
14023b8abbe214c252028f6e09f79169529c846409dGreg ClaytonSBBlock::GetContainingInlinedBlock  ()
14123b8abbe214c252028f6e09f79169529c846409dGreg Clayton{
14223b8abbe214c252028f6e09f79169529c846409dGreg Clayton    SBBlock sb_block;
14323b8abbe214c252028f6e09f79169529c846409dGreg Clayton    if (m_opaque_ptr)
14423b8abbe214c252028f6e09f79169529c846409dGreg Clayton        sb_block.m_opaque_ptr = m_opaque_ptr->GetContainingInlinedBlock ();
14523b8abbe214c252028f6e09f79169529c846409dGreg Clayton    return sb_block;
14623b8abbe214c252028f6e09f79169529c846409dGreg Clayton}
14723b8abbe214c252028f6e09f79169529c846409dGreg Clayton
14869aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock
14969aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock::GetSibling ()
15069aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton{
15169aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    SBBlock sb_block;
15269aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    if (m_opaque_ptr)
15369aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        sb_block.m_opaque_ptr = m_opaque_ptr->GetSibling();
15469aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    return sb_block;
15569aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton}
15669aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton
15769aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock
15869aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg ClaytonSBBlock::GetFirstChild ()
15969aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton{
16069aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    SBBlock sb_block;
16169aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    if (m_opaque_ptr)
16269aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton        sb_block.m_opaque_ptr = m_opaque_ptr->GetFirstChild();
16369aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton    return sb_block;
16469aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton}
16569aa5d9a7620a183cdc4da12cc87ea82e2ffcbf9Greg Clayton
16623b8abbe214c252028f6e09f79169529c846409dGreg Claytonlldb_private::Block *
1677dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg ClaytonSBBlock::GetPtr ()
168a66ba46379fe41036d870975c56ccc2319cb6618Greg Clayton{
169a66ba46379fe41036d870975c56ccc2319cb6618Greg Clayton    return m_opaque_ptr;
170a66ba46379fe41036d870975c56ccc2319cb6618Greg Clayton}
171a66ba46379fe41036d870975c56ccc2319cb6618Greg Clayton
172dd62d729cf960051615a74c1e67e2e41ec789fd7Greg Claytonvoid
1737dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg ClaytonSBBlock::SetPtr (lldb_private::Block *block)
174dd62d729cf960051615a74c1e67e2e41ec789fd7Greg Clayton{
175dd62d729cf960051615a74c1e67e2e41ec789fd7Greg Clayton    m_opaque_ptr = block;
176dd62d729cf960051615a74c1e67e2e41ec789fd7Greg Clayton}
17724943d2ee8bfaa7cf5893e4709143924157a5c1eChris Lattner
17898f930f429160f9777f626c3ac6aa609f4e965d2Caroline Ticebool
17998f930f429160f9777f626c3ac6aa609f4e965d2Caroline TiceSBBlock::GetDescription (SBStream &description)
18098f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice{
18196154be69fa240a662419183ed08e1cfc5418164Greg Clayton    Stream &strm = description.ref();
18296154be69fa240a662419183ed08e1cfc5418164Greg Clayton
18398f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice    if (m_opaque_ptr)
184e7a566e3301b272d18a5f752f99c8cb8b63b28a4Caroline Tice    {
18598f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice        lldb::user_id_t id = m_opaque_ptr->GetID();
1865f35a4be95aed0e5b2cb36f7d785bcbfc67284aeDaniel Malea        strm.Printf ("Block: {id: %" PRIu64 "} ", id);
18798f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice        if (IsInlined())
188e7a566e3301b272d18a5f752f99c8cb8b63b28a4Caroline Tice        {
18996154be69fa240a662419183ed08e1cfc5418164Greg Clayton            strm.Printf (" (inlined, '%s') ", GetInlinedName());
190e7a566e3301b272d18a5f752f99c8cb8b63b28a4Caroline Tice        }
19198f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice        lldb_private::SymbolContext sc;
19298f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice        m_opaque_ptr->CalculateSymbolContext (&sc);
19398f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice        if (sc.function)
194e7a566e3301b272d18a5f752f99c8cb8b63b28a4Caroline Tice        {
19596154be69fa240a662419183ed08e1cfc5418164Greg Clayton            m_opaque_ptr->DumpAddressRanges (&strm,
19698f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice                                             sc.function->GetAddressRange().GetBaseAddress().GetFileAddress());
197e7a566e3301b272d18a5f752f99c8cb8b63b28a4Caroline Tice        }
198e7a566e3301b272d18a5f752f99c8cb8b63b28a4Caroline Tice    }
19998f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice    else
20096154be69fa240a662419183ed08e1cfc5418164Greg Clayton        strm.PutCString ("No value");
20198f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice
20298f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice    return true;
20398f930f429160f9777f626c3ac6aa609f4e965d2Caroline Tice}
20423b8abbe214c252028f6e09f79169529c846409dGreg Clayton
20523b8abbe214c252028f6e09f79169529c846409dGreg Claytonuint32_t
20623b8abbe214c252028f6e09f79169529c846409dGreg ClaytonSBBlock::GetNumRanges ()
20723b8abbe214c252028f6e09f79169529c846409dGreg Clayton{
20823b8abbe214c252028f6e09f79169529c846409dGreg Clayton    if (m_opaque_ptr)
20923b8abbe214c252028f6e09f79169529c846409dGreg Clayton        return m_opaque_ptr->GetNumRanges();
21023b8abbe214c252028f6e09f79169529c846409dGreg Clayton    return 0;
21123b8abbe214c252028f6e09f79169529c846409dGreg Clayton}
21223b8abbe214c252028f6e09f79169529c846409dGreg Clayton
21323b8abbe214c252028f6e09f79169529c846409dGreg Claytonlldb::SBAddress
21423b8abbe214c252028f6e09f79169529c846409dGreg ClaytonSBBlock::GetRangeStartAddress (uint32_t idx)
21523b8abbe214c252028f6e09f79169529c846409dGreg Clayton{
21623b8abbe214c252028f6e09f79169529c846409dGreg Clayton    lldb::SBAddress sb_addr;
21723b8abbe214c252028f6e09f79169529c846409dGreg Clayton    if (m_opaque_ptr)
21823b8abbe214c252028f6e09f79169529c846409dGreg Clayton    {
21923b8abbe214c252028f6e09f79169529c846409dGreg Clayton        AddressRange range;
22023b8abbe214c252028f6e09f79169529c846409dGreg Clayton        if (m_opaque_ptr->GetRangeAtIndex(idx, range))
22123b8abbe214c252028f6e09f79169529c846409dGreg Clayton        {
22223b8abbe214c252028f6e09f79169529c846409dGreg Clayton            sb_addr.ref() = range.GetBaseAddress();
22323b8abbe214c252028f6e09f79169529c846409dGreg Clayton        }
22423b8abbe214c252028f6e09f79169529c846409dGreg Clayton    }
22523b8abbe214c252028f6e09f79169529c846409dGreg Clayton    return sb_addr;
22623b8abbe214c252028f6e09f79169529c846409dGreg Clayton}
22723b8abbe214c252028f6e09f79169529c846409dGreg Clayton
22823b8abbe214c252028f6e09f79169529c846409dGreg Claytonlldb::SBAddress
22923b8abbe214c252028f6e09f79169529c846409dGreg ClaytonSBBlock::GetRangeEndAddress (uint32_t idx)
23023b8abbe214c252028f6e09f79169529c846409dGreg Clayton{
23123b8abbe214c252028f6e09f79169529c846409dGreg Clayton    lldb::SBAddress sb_addr;
23223b8abbe214c252028f6e09f79169529c846409dGreg Clayton    if (m_opaque_ptr)
23323b8abbe214c252028f6e09f79169529c846409dGreg Clayton    {
23423b8abbe214c252028f6e09f79169529c846409dGreg Clayton        AddressRange range;
23523b8abbe214c252028f6e09f79169529c846409dGreg Clayton        if (m_opaque_ptr->GetRangeAtIndex(idx, range))
23623b8abbe214c252028f6e09f79169529c846409dGreg Clayton        {
23723b8abbe214c252028f6e09f79169529c846409dGreg Clayton            sb_addr.ref() = range.GetBaseAddress();
23823b8abbe214c252028f6e09f79169529c846409dGreg Clayton            sb_addr.ref().Slide(range.GetByteSize());
23923b8abbe214c252028f6e09f79169529c846409dGreg Clayton        }
24023b8abbe214c252028f6e09f79169529c846409dGreg Clayton    }
24123b8abbe214c252028f6e09f79169529c846409dGreg Clayton    return sb_addr;
24223b8abbe214c252028f6e09f79169529c846409dGreg Clayton}
24323b8abbe214c252028f6e09f79169529c846409dGreg Clayton
24423b8abbe214c252028f6e09f79169529c846409dGreg Claytonuint32_t
24523b8abbe214c252028f6e09f79169529c846409dGreg ClaytonSBBlock::GetRangeIndexForBlockAddress (lldb::SBAddress block_addr)
24623b8abbe214c252028f6e09f79169529c846409dGreg Clayton{
24723b8abbe214c252028f6e09f79169529c846409dGreg Clayton    if (m_opaque_ptr && block_addr.IsValid())
24823b8abbe214c252028f6e09f79169529c846409dGreg Clayton    {
249bc36a861b8e0b2f2dde34f27c9fa9629a357d598Greg Clayton        return m_opaque_ptr->GetRangeIndexContainingAddress (block_addr.ref());
25023b8abbe214c252028f6e09f79169529c846409dGreg Clayton    }
25123b8abbe214c252028f6e09f79169529c846409dGreg Clayton
25223b8abbe214c252028f6e09f79169529c846409dGreg Clayton    return UINT32_MAX;
25323b8abbe214c252028f6e09f79169529c846409dGreg Clayton}
25423b8abbe214c252028f6e09f79169529c846409dGreg Clayton
2557dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton
2567dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Claytonlldb::SBValueList
2577dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg ClaytonSBBlock::GetVariables (lldb::SBFrame& frame,
2587dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton                       bool arguments,
2597dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton                       bool locals,
2607dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton                       bool statics,
2617dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton                       lldb::DynamicValueType use_dynamic)
2627dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton{
2637dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton    Block *block = GetPtr();
2647dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton    SBValueList value_list;
2657dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton    if (block)
2667dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton    {
2677dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton        StackFrameSP frame_sp(frame.GetFrameSP());
2687dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton        VariableListSP variable_list_sp (block->GetBlockVariableList (true));
2697dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton
2707dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton        if (variable_list_sp)
2717dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton        {
2727dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton            const size_t num_variables = variable_list_sp->GetSize();
2737dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton            if (num_variables)
2747dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton            {
2757dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton                for (size_t i = 0; i < num_variables; ++i)
2767dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton                {
2777dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2Greg Clayton                    VariableSP variable_sp (variable_list_sp->GetVariableAtIndex(i));
278