Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SBBlock.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/API/SBBlock.h" |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 11 | #include "lldb/API/SBFileSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | #include "lldb/Symbol/Block.h" |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 13 | #include "lldb/Symbol/Function.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 14 | |
| 15 | using namespace lldb; |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 16 | using namespace lldb_private; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | |
| 18 | |
| 19 | SBBlock::SBBlock () : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 20 | m_opaque_ptr (NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | { |
| 22 | } |
| 23 | |
| 24 | SBBlock::SBBlock (lldb_private::Block *lldb_object_ptr) : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 25 | m_opaque_ptr (lldb_object_ptr) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 26 | { |
| 27 | } |
| 28 | |
| 29 | SBBlock::~SBBlock () |
| 30 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 31 | m_opaque_ptr = NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | bool |
| 35 | SBBlock::IsValid () const |
| 36 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 37 | return m_opaque_ptr != NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 40 | bool |
| 41 | SBBlock::IsInlined () const |
| 42 | { |
| 43 | if (m_opaque_ptr) |
| 44 | return m_opaque_ptr->GetInlinedFunctionInfo () != NULL; |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | const char * |
| 49 | SBBlock::GetInlinedName () const |
| 50 | { |
| 51 | if (m_opaque_ptr) |
| 52 | { |
| 53 | const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo (); |
| 54 | if (inlined_info) |
| 55 | return inlined_info->GetName().AsCString (NULL); |
| 56 | } |
| 57 | return NULL; |
| 58 | } |
| 59 | |
| 60 | SBFileSpec |
| 61 | SBBlock::GetInlinedCallSiteFile () const |
| 62 | { |
| 63 | SBFileSpec sb_file; |
| 64 | if (m_opaque_ptr) |
| 65 | { |
| 66 | const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo (); |
| 67 | if (inlined_info) |
| 68 | sb_file.SetFileSpec (inlined_info->GetCallSite().GetFile()); |
| 69 | } |
| 70 | return sb_file; |
| 71 | } |
| 72 | |
| 73 | uint32_t |
| 74 | SBBlock::GetInlinedCallSiteLine () const |
| 75 | { |
| 76 | if (m_opaque_ptr) |
| 77 | { |
| 78 | const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo (); |
| 79 | if (inlined_info) |
| 80 | return inlined_info->GetCallSite().GetLine(); |
| 81 | } |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | uint32_t |
| 86 | SBBlock::GetInlinedCallSiteColumn () const |
| 87 | { |
| 88 | if (m_opaque_ptr) |
| 89 | { |
| 90 | const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo (); |
| 91 | if (inlined_info) |
| 92 | return inlined_info->GetCallSite().GetColumn(); |
| 93 | } |
| 94 | return 0; |
| 95 | } |
| 96 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 97 | void |
| 98 | SBBlock::AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list) |
| 99 | { |
| 100 | if (IsValid()) |
| 101 | { |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 102 | bool show_inline = true; |
| 103 | m_opaque_ptr->AppendVariables (can_create, get_parent_variables, show_inline, var_list); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 107 | SBBlock |
| 108 | SBBlock::GetParent () |
| 109 | { |
| 110 | SBBlock sb_block; |
| 111 | if (m_opaque_ptr) |
| 112 | sb_block.m_opaque_ptr = m_opaque_ptr->GetParent(); |
| 113 | return sb_block; |
| 114 | } |
| 115 | |
| 116 | SBBlock |
| 117 | SBBlock::GetSibling () |
| 118 | { |
| 119 | SBBlock sb_block; |
| 120 | if (m_opaque_ptr) |
| 121 | sb_block.m_opaque_ptr = m_opaque_ptr->GetSibling(); |
| 122 | return sb_block; |
| 123 | } |
| 124 | |
| 125 | SBBlock |
| 126 | SBBlock::GetFirstChild () |
| 127 | { |
| 128 | SBBlock sb_block; |
| 129 | if (m_opaque_ptr) |
| 130 | sb_block.m_opaque_ptr = m_opaque_ptr->GetFirstChild(); |
| 131 | return sb_block; |
| 132 | } |
| 133 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 134 | |
| 135 | |