blob: 8be43e7825d089fc0958e410201a5fd294915f91 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- Block.cpp -----------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/Symbol/Block.h"
11#include "lldb/Symbol/Function.h"
12#include "lldb/Core/Module.h"
13#include "lldb/Core/Section.h"
Sean Callananc617a4c2011-08-05 23:43:37 +000014#include "lldb/Symbol/SymbolFile.h"
Chris Lattner24943d22010-06-08 16:52:24 +000015#include "lldb/Symbol/SymbolVendor.h"
16#include "lldb/Symbol/VariableList.h"
17
18using namespace lldb;
19using namespace lldb_private;
20
Greg Clayton75ccf502010-08-21 02:22:51 +000021Block::Block(lldb::user_id_t uid) :
Chris Lattner24943d22010-06-08 16:52:24 +000022 UserID(uid),
Greg Clayton75ccf502010-08-21 02:22:51 +000023 m_parent_scope (NULL),
24 m_sibling (NULL),
25 m_children (),
26 m_ranges (),
27 m_inlineInfoSP (),
Greg Claytonb04e7a82010-08-24 21:05:24 +000028 m_variable_list_sp (),
Greg Clayton75ccf502010-08-21 02:22:51 +000029 m_parsed_block_info (false),
30 m_parsed_block_variables (false),
31 m_parsed_child_blocks (false)
Chris Lattner24943d22010-06-08 16:52:24 +000032{
33}
34
Chris Lattner24943d22010-06-08 16:52:24 +000035Block::~Block ()
36{
37}
38
39void
Greg Claytoneea26402010-09-14 23:36:40 +000040Block::GetDescription(Stream *s, Function *function, lldb::DescriptionLevel level, Target *target) const
Greg Clayton12bec712010-06-28 21:30:43 +000041{
Greg Claytonc67b7d12010-09-10 01:30:46 +000042 *s << "id = " << ((const UserID&)*this);
43
Greg Clayton12bec712010-06-28 21:30:43 +000044 size_t num_ranges = m_ranges.size();
45 if (num_ranges)
46 {
47
48 addr_t base_addr = LLDB_INVALID_ADDRESS;
Greg Claytoneea26402010-09-14 23:36:40 +000049 if (target)
50 base_addr = function->GetAddressRange().GetBaseAddress().GetLoadAddress(target);
Greg Clayton12bec712010-06-28 21:30:43 +000051 if (base_addr == LLDB_INVALID_ADDRESS)
Greg Clayton75ccf502010-08-21 02:22:51 +000052 base_addr = function->GetAddressRange().GetBaseAddress().GetFileAddress();
Greg Clayton12bec712010-06-28 21:30:43 +000053
Greg Claytonc67b7d12010-09-10 01:30:46 +000054 s->Printf(", range%s = ", num_ranges > 1 ? "s" : "");
Greg Clayton12bec712010-06-28 21:30:43 +000055 std::vector<VMRange>::const_iterator pos, end = m_ranges.end();
56 for (pos = m_ranges.begin(); pos != end; ++pos)
57 pos->Dump(s, base_addr, 4);
58 }
Greg Clayton12bec712010-06-28 21:30:43 +000059
60 if (m_inlineInfoSP.get() != NULL)
Greg Clayton1924e242010-09-15 05:51:24 +000061 {
62 bool show_fullpaths = (level == eDescriptionLevelVerbose);
63 m_inlineInfoSP->Dump(s, show_fullpaths);
64 }
Greg Clayton12bec712010-06-28 21:30:43 +000065}
66
67void
Chris Lattner24943d22010-06-08 16:52:24 +000068Block::Dump(Stream *s, addr_t base_addr, int32_t depth, bool show_context) const
69{
70 if (depth < 0)
71 {
Greg Clayton75ccf502010-08-21 02:22:51 +000072 Block *parent = GetParent();
73 if (parent)
74 {
75 // We have a depth that is less than zero, print our parent blocks
76 // first
77 parent->Dump(s, base_addr, depth + 1, show_context);
78 }
Chris Lattner24943d22010-06-08 16:52:24 +000079 }
80
81 s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
82 s->Indent();
83 *s << "Block" << ((const UserID&)*this);
Greg Clayton12bec712010-06-28 21:30:43 +000084 const Block* parent_block = GetParent();
85 if (parent_block)
Chris Lattner24943d22010-06-08 16:52:24 +000086 {
Greg Clayton12bec712010-06-28 21:30:43 +000087 s->Printf(", parent = {0x%8.8x}", parent_block->GetID());
Chris Lattner24943d22010-06-08 16:52:24 +000088 }
89 if (m_inlineInfoSP.get() != NULL)
Greg Clayton1924e242010-09-15 05:51:24 +000090 {
91 bool show_fullpaths = false;
92 m_inlineInfoSP->Dump(s, show_fullpaths);
93 }
Chris Lattner24943d22010-06-08 16:52:24 +000094
95 if (!m_ranges.empty())
96 {
97 *s << ", ranges =";
98 std::vector<VMRange>::const_iterator pos;
99 std::vector<VMRange>::const_iterator end = m_ranges.end();
100 for (pos = m_ranges.begin(); pos != end; ++pos)
101 {
102 if (parent_block != NULL && parent_block->Contains(*pos) == false)
103 *s << '!';
104 else
105 *s << ' ';
106 pos->Dump(s, base_addr);
107 }
108 }
109 s->EOL();
110
111 if (depth > 0)
112 {
113 s->IndentMore();
114
Greg Claytonb04e7a82010-08-24 21:05:24 +0000115 if (m_variable_list_sp.get())
Chris Lattner24943d22010-06-08 16:52:24 +0000116 {
Greg Claytonb04e7a82010-08-24 21:05:24 +0000117 m_variable_list_sp->Dump(s, show_context);
Chris Lattner24943d22010-06-08 16:52:24 +0000118 }
119
Greg Clayton75ccf502010-08-21 02:22:51 +0000120 for (Block *child_block = GetFirstChild(); child_block != NULL; child_block = child_block->GetSibling())
Chris Lattner24943d22010-06-08 16:52:24 +0000121 {
Greg Clayton75ccf502010-08-21 02:22:51 +0000122 child_block->Dump(s, base_addr, depth - 1, show_context);
Chris Lattner24943d22010-06-08 16:52:24 +0000123 }
124
125 s->IndentLess();
126 }
127
128}
129
130
Greg Clayton75ccf502010-08-21 02:22:51 +0000131Block *
132Block::FindBlockByID (user_id_t block_id)
133{
134 if (block_id == GetID())
135 return this;
136
137 Block *matching_block = NULL;
138 for (Block *child_block = GetFirstChild(); child_block != NULL; child_block = child_block->GetSibling())
139 {
140 matching_block = child_block->FindBlockByID (block_id);
141 if (matching_block)
142 break;
143 }
144 return matching_block;
145}
146
Chris Lattner24943d22010-06-08 16:52:24 +0000147void
Greg Claytonb04e7a82010-08-24 21:05:24 +0000148Block::CalculateSymbolContext (SymbolContext* sc)
Chris Lattner24943d22010-06-08 16:52:24 +0000149{
Greg Clayton75ccf502010-08-21 02:22:51 +0000150 if (m_parent_scope)
151 m_parent_scope->CalculateSymbolContext(sc);
Chris Lattner24943d22010-06-08 16:52:24 +0000152 sc->block = this;
Chris Lattner24943d22010-06-08 16:52:24 +0000153}
154
155void
Greg Clayton69aa5d92010-09-07 04:20:48 +0000156Block::DumpStopContext
157(
158 Stream *s,
159 const SymbolContext *sc_ptr,
160 const Declaration *child_inline_call_site,
161 bool show_fullpaths,
162 bool show_inline_blocks)
Chris Lattner24943d22010-06-08 16:52:24 +0000163{
Greg Claytonff44ab42011-04-23 02:04:55 +0000164 const InlineFunctionInfo* inline_info = NULL;
165 Block* inlined_block;
166 if (sc_ptr)
167 inlined_block = GetContainingInlinedBlock ();
168 else
169 inlined_block = GetInlinedParent();
Chris Lattner24943d22010-06-08 16:52:24 +0000170
Greg Claytonff44ab42011-04-23 02:04:55 +0000171 if (inlined_block)
172 inline_info = inlined_block->GetInlinedFunctionInfo();
Greg Clayton69aa5d92010-09-07 04:20:48 +0000173 const Declaration *inline_call_site = child_inline_call_site;
Chris Lattner24943d22010-06-08 16:52:24 +0000174 if (inline_info)
175 {
Greg Clayton69aa5d92010-09-07 04:20:48 +0000176 inline_call_site = &inline_info->GetCallSite();
177 if (sc_ptr)
Chris Lattner24943d22010-06-08 16:52:24 +0000178 {
Greg Clayton69aa5d92010-09-07 04:20:48 +0000179 // First frame in a frame with inlined functions
Chris Lattner24943d22010-06-08 16:52:24 +0000180 s->PutCString (" [inlined]");
181 }
Greg Clayton3c126042011-02-08 02:40:32 +0000182 if (show_inline_blocks && child_inline_call_site)
Greg Clayton69aa5d92010-09-07 04:20:48 +0000183 s->EOL();
184 else
185 s->PutChar(' ');
Greg Claytonff44ab42011-04-23 02:04:55 +0000186
187 if (sc_ptr == NULL)
188 s->Indent();
189
Greg Clayton69aa5d92010-09-07 04:20:48 +0000190 s->PutCString(inline_info->GetName ().AsCString());
191
192 if (child_inline_call_site && child_inline_call_site->IsValid())
Chris Lattner24943d22010-06-08 16:52:24 +0000193 {
Greg Clayton69aa5d92010-09-07 04:20:48 +0000194 s->PutCString(" at ");
195 child_inline_call_site->DumpStopContext (s, show_fullpaths);
Chris Lattner24943d22010-06-08 16:52:24 +0000196 }
197 }
198
Greg Claytonff44ab42011-04-23 02:04:55 +0000199 // The first call to this function from something that has a symbol
200 // context will pass in a valid sc_ptr. Subsequent calls to this function
201 // from this function for inline purposes will NULL out sc_ptr. So on the
202 // first time through we dump the line table entry (which is always at the
203 // deepest inline code block). And subsequent calls to this function we
204 // will use hte inline call site information to print line numbers.
Greg Clayton69aa5d92010-09-07 04:20:48 +0000205 if (sc_ptr)
Chris Lattner24943d22010-06-08 16:52:24 +0000206 {
207 // If we have any inlined functions, this will be the deepest most
208 // inlined location
Greg Clayton69aa5d92010-09-07 04:20:48 +0000209 if (sc_ptr->line_entry.IsValid())
Chris Lattner24943d22010-06-08 16:52:24 +0000210 {
211 s->PutCString(" at ");
Greg Clayton69aa5d92010-09-07 04:20:48 +0000212 sc_ptr->line_entry.DumpStopContext (s, show_fullpaths);
Chris Lattner24943d22010-06-08 16:52:24 +0000213 }
214 }
Greg Clayton69aa5d92010-09-07 04:20:48 +0000215
216 if (show_inline_blocks)
217 {
Greg Claytonff44ab42011-04-23 02:04:55 +0000218 if (inlined_block)
Greg Clayton69aa5d92010-09-07 04:20:48 +0000219 {
Greg Claytonff44ab42011-04-23 02:04:55 +0000220 inlined_block->Block::DumpStopContext (s,
221 NULL,
222 inline_call_site,
223 show_fullpaths,
224 show_inline_blocks);
Greg Clayton69aa5d92010-09-07 04:20:48 +0000225 }
226 else if (child_inline_call_site)
227 {
228 SymbolContext sc;
229 CalculateSymbolContext(&sc);
230 if (sc.function)
231 {
232 s->EOL();
233 s->Indent (sc.function->GetMangled().GetName().AsCString());
234 if (child_inline_call_site && child_inline_call_site->IsValid())
235 {
236 s->PutCString(" at ");
237 child_inline_call_site->DumpStopContext (s, show_fullpaths);
238 }
239 }
240 }
241 }
Chris Lattner24943d22010-06-08 16:52:24 +0000242}
243
244
245void
246Block::DumpSymbolContext(Stream *s)
247{
Greg Clayton75ccf502010-08-21 02:22:51 +0000248 SymbolContext sc;
249 CalculateSymbolContext(&sc);
250 if (sc.function)
251 sc.function->DumpSymbolContext(s);
Chris Lattner24943d22010-06-08 16:52:24 +0000252 s->Printf(", Block{0x%8.8x}", GetID());
253}
254
Caroline Tice98f930f2010-09-20 05:20:02 +0000255void
256Block::DumpAddressRanges (Stream *s, lldb::addr_t base_addr)
257{
258 if (!m_ranges.empty())
259 {
260 std::vector<VMRange>::const_iterator pos, end = m_ranges.end();
261 for (pos = m_ranges.begin(); pos != end; ++pos)
262 pos->Dump (s, base_addr);
263 }
264}
265
Chris Lattner24943d22010-06-08 16:52:24 +0000266bool
267Block::Contains (addr_t range_offset) const
268{
269 return VMRange::ContainsValue(m_ranges, range_offset);
270}
271
272bool
Greg Clayton72b71582010-09-02 21:44:10 +0000273Block::Contains (const Block *block) const
274{
Greg Clayton72b71582010-09-02 21:44:10 +0000275 if (this == block)
Greg Claytona357ecf2010-09-14 03:16:58 +0000276 return false; // This block doesn't contain itself...
Greg Clayton72b71582010-09-02 21:44:10 +0000277
Greg Claytona357ecf2010-09-14 03:16:58 +0000278 // Walk the parent chain for "block" and see if any if them match this block
Greg Clayton72b71582010-09-02 21:44:10 +0000279 const Block *block_parent;
280 for (block_parent = block->GetParent();
281 block_parent != NULL;
282 block_parent = block_parent->GetParent())
283 {
Greg Claytona357ecf2010-09-14 03:16:58 +0000284 if (this == block_parent)
285 return true; // One of the parents of "block" is this object!
Greg Clayton72b71582010-09-02 21:44:10 +0000286 }
287 return false;
288}
289
290bool
Chris Lattner24943d22010-06-08 16:52:24 +0000291Block::Contains (const VMRange& range) const
292{
293 return VMRange::ContainsRange(m_ranges, range);
294}
295
Greg Clayton75ccf502010-08-21 02:22:51 +0000296Block *
297Block::GetParent () const
Chris Lattner24943d22010-06-08 16:52:24 +0000298{
Greg Clayton75ccf502010-08-21 02:22:51 +0000299 if (m_parent_scope)
Chris Lattner24943d22010-06-08 16:52:24 +0000300 {
Greg Clayton75ccf502010-08-21 02:22:51 +0000301 SymbolContext sc;
302 m_parent_scope->CalculateSymbolContext(&sc);
303 if (sc.block)
304 return sc.block;
Chris Lattner24943d22010-06-08 16:52:24 +0000305 }
Greg Clayton75ccf502010-08-21 02:22:51 +0000306 return NULL;
Chris Lattner24943d22010-06-08 16:52:24 +0000307}
308
Greg Clayton33ed1702010-08-24 00:45:41 +0000309Block *
Greg Claytonb04e7a82010-08-24 21:05:24 +0000310Block::GetContainingInlinedBlock ()
311{
Greg Clayton69aa5d92010-09-07 04:20:48 +0000312 if (GetInlinedFunctionInfo())
Greg Claytonb04e7a82010-08-24 21:05:24 +0000313 return this;
314 return GetInlinedParent ();
315}
316
317Block *
318Block::GetInlinedParent ()
Greg Clayton33ed1702010-08-24 00:45:41 +0000319{
320 Block *parent_block = GetParent ();
321 if (parent_block)
322 {
Greg Clayton69aa5d92010-09-07 04:20:48 +0000323 if (parent_block->GetInlinedFunctionInfo())
Greg Clayton33ed1702010-08-24 00:45:41 +0000324 return parent_block;
325 else
326 return parent_block->GetInlinedParent();
327 }
328 return NULL;
329}
330
331
332bool
Greg Claytonb04e7a82010-08-24 21:05:24 +0000333Block::GetRangeContainingOffset (const addr_t offset, VMRange &range)
334{
335 uint32_t range_idx = VMRange::FindRangeIndexThatContainsValue (m_ranges, offset);
336 if (range_idx < m_ranges.size())
337 {
338 range = m_ranges[range_idx];
339 return true;
340 }
341 range.Clear();
342 return false;
343}
344
345
346bool
Greg Clayton33ed1702010-08-24 00:45:41 +0000347Block::GetRangeContainingAddress (const Address& addr, AddressRange &range)
348{
349 SymbolContext sc;
350 CalculateSymbolContext(&sc);
351 if (sc.function)
352 {
353 const AddressRange &func_range = sc.function->GetAddressRange();
354 if (addr.GetSection() == func_range.GetBaseAddress().GetSection())
355 {
356 const addr_t addr_offset = addr.GetOffset();
357 const addr_t func_offset = func_range.GetBaseAddress().GetOffset();
358 if (addr_offset >= func_offset && addr_offset < func_offset + func_range.GetByteSize())
359 {
360 addr_t offset = addr_offset - func_offset;
361
362 uint32_t range_idx = VMRange::FindRangeIndexThatContainsValue (m_ranges, offset);
363 if (range_idx < m_ranges.size())
364 {
365 range.GetBaseAddress() = func_range.GetBaseAddress();
366 range.GetBaseAddress().SetOffset(func_offset + m_ranges[range_idx].GetBaseAddress());
367 range.SetByteSize(m_ranges[range_idx].GetByteSize());
368 return true;
369 }
370 }
371 }
372 }
373 range.Clear();
374 return false;
375}
376
Greg Claytonff44ab42011-04-23 02:04:55 +0000377bool
378Block::GetRangeAtIndex (uint32_t range_idx, AddressRange &range)
379{
380 if (range_idx < m_ranges.size())
381 {
382 SymbolContext sc;
383 CalculateSymbolContext(&sc);
384 if (sc.function)
385 {
386 range.GetBaseAddress() = sc.function->GetAddressRange().GetBaseAddress();
387 range.GetBaseAddress().Slide(m_ranges[range_idx].GetBaseAddress ());
388 range.SetByteSize (m_ranges[range_idx].GetByteSize());
389 return true;
390 }
391 }
392 return false;
393}
Greg Claytonfeb6e562010-11-14 00:22:48 +0000394
395bool
396Block::GetStartAddress (Address &addr)
397{
398 if (m_ranges.empty())
399 return false;
400
401 SymbolContext sc;
402 CalculateSymbolContext(&sc);
403 if (sc.function)
404 {
405 addr = sc.function->GetAddressRange().GetBaseAddress();
406 addr.Slide(m_ranges.front().GetBaseAddress ());
407 return true;
408 }
409 return false;
410}
411
Chris Lattner24943d22010-06-08 16:52:24 +0000412void
413Block::AddRange(addr_t start_offset, addr_t end_offset)
414{
415 m_ranges.resize(m_ranges.size()+1);
416 m_ranges.back().Reset(start_offset, end_offset);
417}
418
Chris Lattner24943d22010-06-08 16:52:24 +0000419// Return the current number of bytes that this object occupies in memory
420size_t
421Block::MemorySize() const
422{
423 size_t mem_size = sizeof(Block) + m_ranges.size() * sizeof(VMRange);
424 if (m_inlineInfoSP.get())
425 mem_size += m_inlineInfoSP->MemorySize();
Greg Claytonb04e7a82010-08-24 21:05:24 +0000426 if (m_variable_list_sp.get())
427 mem_size += m_variable_list_sp->MemorySize();
Chris Lattner24943d22010-06-08 16:52:24 +0000428 return mem_size;
429
430}
431
Greg Clayton75ccf502010-08-21 02:22:51 +0000432void
433Block::AddChild(const BlockSP &child_block_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000434{
Greg Clayton75ccf502010-08-21 02:22:51 +0000435 if (child_block_sp)
436 {
437 Block *block_needs_sibling = NULL;
Chris Lattner24943d22010-06-08 16:52:24 +0000438
Greg Clayton75ccf502010-08-21 02:22:51 +0000439 if (!m_children.empty())
440 block_needs_sibling = m_children.back().get();
Chris Lattner24943d22010-06-08 16:52:24 +0000441
Greg Clayton75ccf502010-08-21 02:22:51 +0000442 child_block_sp->SetParentScope (this);
443 m_children.push_back (child_block_sp);
Chris Lattner24943d22010-06-08 16:52:24 +0000444
Greg Clayton75ccf502010-08-21 02:22:51 +0000445 if (block_needs_sibling)
446 block_needs_sibling->SetSibling (child_block_sp.get());
447 }
Chris Lattner24943d22010-06-08 16:52:24 +0000448}
449
450void
451Block::SetInlinedFunctionInfo(const char *name, const char *mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr)
452{
453 m_inlineInfoSP.reset(new InlineFunctionInfo(name, mangled, decl_ptr, call_decl_ptr));
454}
455
Jim Ingham7382a532010-08-18 19:29:16 +0000456
457
458VariableListSP
Greg Clayton1bd2b2f2011-06-17 22:10:16 +0000459Block::GetBlockVariableList (bool can_create)
Jim Ingham7382a532010-08-18 19:29:16 +0000460{
Greg Clayton75ccf502010-08-21 02:22:51 +0000461 if (m_parsed_block_variables == false)
Jim Ingham7382a532010-08-18 19:29:16 +0000462 {
Greg Claytonb04e7a82010-08-24 21:05:24 +0000463 if (m_variable_list_sp.get() == NULL && can_create)
Greg Clayton75ccf502010-08-21 02:22:51 +0000464 {
465 m_parsed_block_variables = true;
466 SymbolContext sc;
467 CalculateSymbolContext(&sc);
468 assert(sc.module_sp);
469 sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc);
470 }
Jim Ingham7382a532010-08-18 19:29:16 +0000471 }
Greg Clayton1bd2b2f2011-06-17 22:10:16 +0000472 return m_variable_list_sp;
473}
Jim Ingham7382a532010-08-18 19:29:16 +0000474
Greg Clayton1bd2b2f2011-06-17 22:10:16 +0000475uint32_t
476Block::AppendBlockVariables (bool can_create,
477 bool get_child_block_variables,
478 bool stop_if_child_block_is_inlined_function,
479 VariableList *variable_list)
480{
481 uint32_t num_variables_added = 0;
482 VariableList *block_var_list = GetBlockVariableList (can_create).get();
483 if (block_var_list)
Jim Ingham7382a532010-08-18 19:29:16 +0000484 {
Greg Clayton1bd2b2f2011-06-17 22:10:16 +0000485 num_variables_added += block_var_list->GetSize();
486 variable_list->AddVariables (block_var_list);
487 }
488
489 if (get_child_block_variables)
490 {
491 for (Block *child_block = GetFirstChild();
492 child_block != NULL;
493 child_block = child_block->GetSibling())
494 {
495 if (stop_if_child_block_is_inlined_function == false ||
496 child_block->GetInlinedFunctionInfo() == NULL)
497 {
498 num_variables_added += child_block->AppendBlockVariables (can_create,
499 get_child_block_variables,
500 stop_if_child_block_is_inlined_function,
501 variable_list);
Jim Ingham7382a532010-08-18 19:29:16 +0000502 }
503 }
504 }
Greg Clayton1bd2b2f2011-06-17 22:10:16 +0000505 return num_variables_added;
Jim Ingham7382a532010-08-18 19:29:16 +0000506}
507
508uint32_t
Greg Clayton33ed1702010-08-24 00:45:41 +0000509Block::AppendVariables
510(
511 bool can_create,
512 bool get_parent_variables,
513 bool stop_if_block_is_inlined_function,
514 VariableList *variable_list
515)
Jim Ingham7382a532010-08-18 19:29:16 +0000516{
517 uint32_t num_variables_added = 0;
Greg Clayton1bd2b2f2011-06-17 22:10:16 +0000518 VariableListSP variable_list_sp(GetBlockVariableList(can_create));
Jim Ingham7382a532010-08-18 19:29:16 +0000519
Greg Clayton69aa5d92010-09-07 04:20:48 +0000520 bool is_inlined_function = GetInlinedFunctionInfo() != NULL;
Jim Ingham7382a532010-08-18 19:29:16 +0000521 if (variable_list_sp.get())
522 {
523 num_variables_added = variable_list_sp->GetSize();
524 variable_list->AddVariables(variable_list_sp.get());
525 }
Greg Clayton33ed1702010-08-24 00:45:41 +0000526
Jim Ingham7382a532010-08-18 19:29:16 +0000527 if (get_parent_variables)
528 {
Greg Clayton33ed1702010-08-24 00:45:41 +0000529 if (stop_if_block_is_inlined_function && is_inlined_function)
530 return num_variables_added;
531
Jim Ingham7382a532010-08-18 19:29:16 +0000532 Block* parent_block = GetParent();
533 if (parent_block)
Greg Clayton33ed1702010-08-24 00:45:41 +0000534 num_variables_added += parent_block->AppendVariables (can_create, get_parent_variables, stop_if_block_is_inlined_function, variable_list);
Jim Ingham7382a532010-08-18 19:29:16 +0000535 }
536 return num_variables_added;
537}
538
Sean Callananc617a4c2011-08-05 23:43:37 +0000539clang::DeclContext *
540Block::GetClangDeclContextForInlinedFunction()
541{
542 SymbolContext sc;
543
544 CalculateSymbolContext (&sc);
545
546 if (!sc.module_sp)
547 return NULL;
548
549 SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor();
550
551 if (!sym_vendor)
552 return NULL;
553
554 SymbolFile *sym_file = sym_vendor->GetSymbolFile();
555
556 if (!sym_file)
557 return NULL;
558
559 return sym_file->GetClangDeclContextForTypeUID (sc, m_uid);
560}
561
Chris Lattner24943d22010-06-08 16:52:24 +0000562void
Greg Clayton75ccf502010-08-21 02:22:51 +0000563Block::SetBlockInfoHasBeenParsed (bool b, bool set_children)
Chris Lattner24943d22010-06-08 16:52:24 +0000564{
Greg Clayton75ccf502010-08-21 02:22:51 +0000565 m_parsed_block_info = b;
566 if (set_children)
Chris Lattner24943d22010-06-08 16:52:24 +0000567 {
Greg Clayton75ccf502010-08-21 02:22:51 +0000568 m_parsed_child_blocks = true;
569 for (Block *child_block = GetFirstChild(); child_block != NULL; child_block = child_block->GetSibling())
570 child_block->SetBlockInfoHasBeenParsed (b, true);
Chris Lattner24943d22010-06-08 16:52:24 +0000571 }
Chris Lattner24943d22010-06-08 16:52:24 +0000572}
Greg Clayton1bd2b2f2011-06-17 22:10:16 +0000573
574void
575Block::SetDidParseVariables (bool b, bool set_children)
576{
577 m_parsed_block_variables = b;
578 if (set_children)
579 {
580 for (Block *child_block = GetFirstChild(); child_block != NULL; child_block = child_block->GetSibling())
581 child_block->SetDidParseVariables (b, true);
582 }
583}
584