Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- Variable.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/Variable.h" |
| 11 | |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 12 | #include "lldb/Core/Module.h" |
Greg Clayton | 884fb69 | 2011-07-08 21:46:14 +0000 | [diff] [blame] | 13 | #include "lldb/Core/ValueObject.h" |
| 14 | #include "lldb/Core/ValueObjectVariable.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | #include "lldb/Symbol/Block.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 16 | #include "lldb/Symbol/CompileUnit.h" |
Paul Herman | d628cbb | 2015-09-15 23:44:17 +0000 | [diff] [blame] | 17 | #include "lldb/Symbol/CompilerDecl.h" |
| 18 | #include "lldb/Symbol/CompilerDeclContext.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 19 | #include "lldb/Symbol/Function.h" |
| 20 | #include "lldb/Symbol/SymbolContext.h" |
Paul Herman | d628cbb | 2015-09-15 23:44:17 +0000 | [diff] [blame] | 21 | #include "lldb/Symbol/SymbolFile.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 22 | #include "lldb/Symbol/Type.h" |
Greg Clayton | 56939cb | 2015-09-17 22:23:34 +0000 | [diff] [blame] | 23 | #include "lldb/Symbol/TypeSystem.h" |
Greg Clayton | 884fb69 | 2011-07-08 21:46:14 +0000 | [diff] [blame] | 24 | #include "lldb/Symbol/VariableList.h" |
Greg Clayton | afacd14 | 2011-09-02 01:15:17 +0000 | [diff] [blame] | 25 | #include "lldb/Target/ABI.h" |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 26 | #include "lldb/Target/Process.h" |
Greg Clayton | 9da7bd0 | 2010-08-24 21:05:24 +0000 | [diff] [blame] | 27 | #include "lldb/Target/RegisterContext.h" |
Jason Molenda | b57e4a1 | 2013-11-04 09:33:30 +0000 | [diff] [blame] | 28 | #include "lldb/Target/StackFrame.h" |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 29 | #include "lldb/Target/Target.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 30 | #include "lldb/Target/Thread.h" |
Zachary Turner | bf9a773 | 2017-02-02 21:39:50 +0000 | [diff] [blame] | 31 | #include "lldb/Utility/RegularExpression.h" |
| 32 | #include "lldb/Utility/Stream.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 33 | |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 34 | #include "llvm/ADT/Twine.h" |
| 35 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 36 | using namespace lldb; |
| 37 | using namespace lldb_private; |
| 38 | |
| 39 | //---------------------------------------------------------------------- |
| 40 | // Variable constructor |
| 41 | //---------------------------------------------------------------------- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 42 | Variable::Variable( |
| 43 | lldb::user_id_t uid, const char *name, |
| 44 | const char *mangled, // The mangled or fully qualified name of the variable. |
| 45 | const lldb::SymbolFileTypeSP &symfile_type_sp, ValueType scope, |
| 46 | SymbolContextScope *context, const RangeList &scope_range, |
| 47 | Declaration *decl_ptr, const DWARFExpression &location, bool external, |
| 48 | bool artificial, bool static_member) |
| 49 | : UserID(uid), m_name(name), m_mangled(ConstString(mangled)), |
| 50 | m_symfile_type_sp(symfile_type_sp), m_scope(scope), |
| 51 | m_owner_scope(context), m_scope_range(scope_range), |
| 52 | m_declaration(decl_ptr), m_location(location), m_external(external), |
Zachary Turner | 9d76e42 | 2018-12-11 00:15:03 +0000 | [diff] [blame] | 53 | m_artificial(artificial), m_loc_is_const_data(false), |
| 54 | m_static_member(static_member) {} |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 55 | |
| 56 | //---------------------------------------------------------------------- |
| 57 | // Destructor |
| 58 | //---------------------------------------------------------------------- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 59 | Variable::~Variable() {} |
| 60 | |
| 61 | lldb::LanguageType Variable::GetLanguage() const { |
| 62 | SymbolContext variable_sc; |
| 63 | m_owner_scope->CalculateSymbolContext(&variable_sc); |
| 64 | if (variable_sc.comp_unit) |
| 65 | return variable_sc.comp_unit->GetLanguage(); |
| 66 | return lldb::eLanguageTypeUnknown; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 67 | } |
| 68 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 69 | ConstString Variable::GetName() const { |
| 70 | ConstString name = m_mangled.GetName(GetLanguage()); |
| 71 | if (name) |
| 72 | return name; |
| 73 | return m_name; |
Greg Clayton | ddaf6a7 | 2015-07-08 22:32:23 +0000 | [diff] [blame] | 74 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 75 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 76 | ConstString Variable::GetUnqualifiedName() const { return m_name; } |
Greg Clayton | ddaf6a7 | 2015-07-08 22:32:23 +0000 | [diff] [blame] | 77 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 78 | bool Variable::NameMatches(const ConstString &name) const { |
| 79 | if (m_name == name) |
| 80 | return true; |
| 81 | SymbolContext variable_sc; |
| 82 | m_owner_scope->CalculateSymbolContext(&variable_sc); |
Greg Clayton | ddaf6a7 | 2015-07-08 22:32:23 +0000 | [diff] [blame] | 83 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 84 | LanguageType language = eLanguageTypeUnknown; |
| 85 | if (variable_sc.comp_unit) |
| 86 | language = variable_sc.comp_unit->GetLanguage(); |
| 87 | return m_mangled.NameMatches(name, language); |
| 88 | } |
| 89 | bool Variable::NameMatches(const RegularExpression ®ex) const { |
| 90 | if (regex.Execute(m_name.AsCString())) |
| 91 | return true; |
| 92 | if (m_mangled) |
| 93 | return m_mangled.NameMatches(regex, GetLanguage()); |
| 94 | return false; |
Greg Clayton | 83c5cd9 | 2010-11-14 22:13:40 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 97 | Type *Variable::GetType() { |
| 98 | if (m_symfile_type_sp) |
| 99 | return m_symfile_type_sp->GetType(); |
| 100 | return nullptr; |
Paul Herman | d628cbb | 2015-09-15 23:44:17 +0000 | [diff] [blame] | 101 | } |
| 102 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 103 | void Variable::Dump(Stream *s, bool show_context) const { |
| 104 | s->Printf("%p: ", static_cast<const void *>(this)); |
| 105 | s->Indent(); |
| 106 | *s << "Variable" << (const UserID &)*this; |
Paul Herman | d628cbb | 2015-09-15 23:44:17 +0000 | [diff] [blame] | 107 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 108 | if (m_name) |
| 109 | *s << ", name = \"" << m_name << "\""; |
Greg Clayton | ddaf6a7 | 2015-07-08 22:32:23 +0000 | [diff] [blame] | 110 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 111 | if (m_symfile_type_sp) { |
| 112 | Type *type = m_symfile_type_sp->GetType(); |
| 113 | if (type) { |
| 114 | *s << ", type = {" << type->GetID() << "} " << (void *)type << " ("; |
| 115 | type->DumpTypeName(s); |
| 116 | s->PutChar(')'); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 117 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 118 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 119 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 120 | if (m_scope != eValueTypeInvalid) { |
| 121 | s->PutCString(", scope = "); |
| 122 | switch (m_scope) { |
Greg Clayton | 007d5be | 2011-05-30 00:49:24 +0000 | [diff] [blame] | 123 | case eValueTypeVariableGlobal: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 124 | s->PutCString(m_external ? "global" : "static"); |
| 125 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 126 | case eValueTypeVariableArgument: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 127 | s->PutCString("parameter"); |
| 128 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 129 | case eValueTypeVariableLocal: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 130 | s->PutCString("local"); |
| 131 | break; |
| 132 | case eValueTypeVariableThreadLocal: |
| 133 | s->PutCString("thread local"); |
| 134 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 135 | default: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 136 | *s << "??? (" << m_scope << ')'; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | if (show_context && m_owner_scope != nullptr) { |
| 141 | s->PutCString(", context = ( "); |
| 142 | m_owner_scope->DumpSymbolContext(s); |
| 143 | s->PutCString(" )"); |
| 144 | } |
| 145 | |
| 146 | bool show_fullpaths = false; |
| 147 | m_declaration.Dump(s, show_fullpaths); |
| 148 | |
| 149 | if (m_location.IsValid()) { |
| 150 | s->PutCString(", location = "); |
| 151 | lldb::addr_t loclist_base_addr = LLDB_INVALID_ADDRESS; |
| 152 | if (m_location.IsLocationList()) { |
| 153 | SymbolContext variable_sc; |
| 154 | m_owner_scope->CalculateSymbolContext(&variable_sc); |
| 155 | if (variable_sc.function) |
| 156 | loclist_base_addr = variable_sc.function->GetAddressRange() |
| 157 | .GetBaseAddress() |
| 158 | .GetFileAddress(); |
| 159 | } |
Zachary Turner | 95997f6 | 2018-11-15 05:06:59 +0000 | [diff] [blame] | 160 | ABISP abi; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 161 | if (m_owner_scope) { |
| 162 | ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule()); |
| 163 | if (module_sp) |
Zachary Turner | 95997f6 | 2018-11-15 05:06:59 +0000 | [diff] [blame] | 164 | abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 165 | } |
| 166 | m_location.GetDescription(s, lldb::eDescriptionLevelBrief, |
Zachary Turner | 95997f6 | 2018-11-15 05:06:59 +0000 | [diff] [blame] | 167 | loclist_base_addr, abi.get()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | if (m_external) |
| 171 | s->PutCString(", external"); |
| 172 | |
| 173 | if (m_artificial) |
| 174 | s->PutCString(", artificial"); |
| 175 | |
| 176 | s->EOL(); |
| 177 | } |
| 178 | |
| 179 | bool Variable::DumpDeclaration(Stream *s, bool show_fullpaths, |
| 180 | bool show_module) { |
| 181 | bool dumped_declaration_info = false; |
| 182 | if (m_owner_scope) { |
| 183 | SymbolContext sc; |
| 184 | m_owner_scope->CalculateSymbolContext(&sc); |
| 185 | sc.block = nullptr; |
| 186 | sc.line_entry.Clear(); |
| 187 | bool show_inlined_frames = false; |
| 188 | const bool show_function_arguments = true; |
| 189 | const bool show_function_name = true; |
| 190 | |
| 191 | dumped_declaration_info = sc.DumpStopContext( |
| 192 | s, nullptr, Address(), show_fullpaths, show_module, show_inlined_frames, |
| 193 | show_function_arguments, show_function_name); |
| 194 | |
| 195 | if (sc.function) |
| 196 | s->PutChar(':'); |
| 197 | } |
| 198 | if (m_declaration.DumpStopContext(s, false)) |
| 199 | dumped_declaration_info = true; |
| 200 | return dumped_declaration_info; |
| 201 | } |
| 202 | |
| 203 | size_t Variable::MemorySize() const { return sizeof(Variable); } |
| 204 | |
| 205 | CompilerDeclContext Variable::GetDeclContext() { |
| 206 | Type *type = GetType(); |
| 207 | if (type) |
| 208 | return type->GetSymbolFile()->GetDeclContextContainingUID(GetID()); |
| 209 | return CompilerDeclContext(); |
| 210 | } |
| 211 | |
| 212 | CompilerDecl Variable::GetDecl() { |
| 213 | Type *type = GetType(); |
| 214 | return type ? type->GetSymbolFile()->GetDeclForUID(GetID()) : CompilerDecl(); |
| 215 | } |
| 216 | |
| 217 | void Variable::CalculateSymbolContext(SymbolContext *sc) { |
| 218 | if (m_owner_scope) { |
| 219 | m_owner_scope->CalculateSymbolContext(sc); |
| 220 | sc->variable = this; |
| 221 | } else |
| 222 | sc->Clear(false); |
| 223 | } |
| 224 | |
| 225 | bool Variable::LocationIsValidForFrame(StackFrame *frame) { |
| 226 | // Is the variable is described by a single location? |
| 227 | if (!m_location.IsLocationList()) { |
| 228 | // Yes it is, the location is valid. |
| 229 | return true; |
| 230 | } |
| 231 | |
| 232 | if (frame) { |
| 233 | Function *function = |
| 234 | frame->GetSymbolContext(eSymbolContextFunction).function; |
| 235 | if (function) { |
| 236 | TargetSP target_sp(frame->CalculateTarget()); |
| 237 | |
| 238 | addr_t loclist_base_load_addr = |
| 239 | function->GetAddressRange().GetBaseAddress().GetLoadAddress( |
| 240 | target_sp.get()); |
| 241 | if (loclist_base_load_addr == LLDB_INVALID_ADDRESS) |
| 242 | return false; |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 243 | // It is a location list. We just need to tell if the location list |
| 244 | // contains the current address when converted to a load address |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 245 | return m_location.LocationListContainsAddress( |
| 246 | loclist_base_load_addr, |
| 247 | frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get())); |
| 248 | } |
| 249 | } |
| 250 | return false; |
| 251 | } |
| 252 | |
| 253 | bool Variable::LocationIsValidForAddress(const Address &address) { |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 254 | // Be sure to resolve the address to section offset prior to calling this |
| 255 | // function. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 256 | if (address.IsSectionOffset()) { |
| 257 | SymbolContext sc; |
| 258 | CalculateSymbolContext(&sc); |
| 259 | if (sc.module_sp == address.GetModule()) { |
| 260 | // Is the variable is described by a single location? |
| 261 | if (!m_location.IsLocationList()) { |
| 262 | // Yes it is, the location is valid. |
| 263 | return true; |
| 264 | } |
| 265 | |
| 266 | if (sc.function) { |
| 267 | addr_t loclist_base_file_addr = |
| 268 | sc.function->GetAddressRange().GetBaseAddress().GetFileAddress(); |
| 269 | if (loclist_base_file_addr == LLDB_INVALID_ADDRESS) |
| 270 | return false; |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 271 | // It is a location list. We just need to tell if the location list |
| 272 | // contains the current address when converted to a load address |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 273 | return m_location.LocationListContainsAddress(loclist_base_file_addr, |
| 274 | address.GetFileAddress()); |
| 275 | } |
| 276 | } |
| 277 | } |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | bool Variable::IsInScope(StackFrame *frame) { |
| 282 | switch (m_scope) { |
| 283 | case eValueTypeRegister: |
| 284 | case eValueTypeRegisterSet: |
| 285 | return frame != nullptr; |
| 286 | |
| 287 | case eValueTypeConstResult: |
| 288 | case eValueTypeVariableGlobal: |
| 289 | case eValueTypeVariableStatic: |
| 290 | case eValueTypeVariableThreadLocal: |
| 291 | return true; |
| 292 | |
| 293 | case eValueTypeVariableArgument: |
| 294 | case eValueTypeVariableLocal: |
| 295 | if (frame) { |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 296 | // We don't have a location list, we just need to see if the block that |
| 297 | // this variable was defined in is currently |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 298 | Block *deepest_frame_block = |
| 299 | frame->GetSymbolContext(eSymbolContextBlock).block; |
| 300 | if (deepest_frame_block) { |
| 301 | SymbolContext variable_sc; |
| 302 | CalculateSymbolContext(&variable_sc); |
| 303 | |
| 304 | // Check for static or global variable defined at the compile unit |
| 305 | // level that wasn't defined in a block |
| 306 | if (variable_sc.block == nullptr) |
| 307 | return true; |
| 308 | |
| 309 | // Check if the variable is valid in the current block |
| 310 | if (variable_sc.block != deepest_frame_block && |
| 311 | !variable_sc.block->Contains(deepest_frame_block)) |
| 312 | return false; |
| 313 | |
| 314 | // If no scope range is specified then it means that the scope is the |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 315 | // same as the scope of the enclosing lexical block. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 316 | if (m_scope_range.IsEmpty()) |
| 317 | return true; |
| 318 | |
| 319 | addr_t file_address = frame->GetFrameCodeAddress().GetFileAddress(); |
| 320 | return m_scope_range.FindEntryThatContains(file_address) != nullptr; |
| 321 | } |
| 322 | } |
| 323 | break; |
| 324 | |
| 325 | default: |
| 326 | break; |
| 327 | } |
| 328 | return false; |
| 329 | } |
| 330 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 331 | Status Variable::GetValuesForVariableExpressionPath( |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 332 | llvm::StringRef variable_expr_path, ExecutionContextScope *scope, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 333 | GetVariableCallback callback, void *baton, VariableList &variable_list, |
| 334 | ValueObjectList &valobj_list) { |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 335 | Status error; |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 336 | if (!callback || variable_expr_path.empty()) { |
| 337 | error.SetErrorString("unknown error"); |
| 338 | return error; |
| 339 | } |
| 340 | |
| 341 | switch (variable_expr_path.front()) { |
| 342 | case '*': |
| 343 | error = Variable::GetValuesForVariableExpressionPath( |
| 344 | variable_expr_path.drop_front(), scope, callback, baton, variable_list, |
| 345 | valobj_list); |
| 346 | if (error.Fail()) { |
| 347 | error.SetErrorString("unknown error"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 348 | return error; |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 349 | } |
| 350 | for (uint32_t i = 0; i < valobj_list.GetSize();) { |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 351 | Status tmp_error; |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 352 | ValueObjectSP valobj_sp( |
| 353 | valobj_list.GetValueObjectAtIndex(i)->Dereference(tmp_error)); |
| 354 | if (tmp_error.Fail()) { |
| 355 | variable_list.RemoveVariableAtIndex(i); |
| 356 | valobj_list.RemoveValueObjectAtIndex(i); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 357 | } else { |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 358 | valobj_list.SetValueObjectAtIndex(i, valobj_sp); |
| 359 | ++i; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 360 | } |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 361 | } |
| 362 | return error; |
| 363 | case '&': { |
| 364 | error = Variable::GetValuesForVariableExpressionPath( |
| 365 | variable_expr_path.drop_front(), scope, callback, baton, variable_list, |
| 366 | valobj_list); |
| 367 | if (error.Success()) { |
| 368 | for (uint32_t i = 0; i < valobj_list.GetSize();) { |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 369 | Status tmp_error; |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 370 | ValueObjectSP valobj_sp( |
| 371 | valobj_list.GetValueObjectAtIndex(i)->AddressOf(tmp_error)); |
| 372 | if (tmp_error.Fail()) { |
| 373 | variable_list.RemoveVariableAtIndex(i); |
| 374 | valobj_list.RemoveValueObjectAtIndex(i); |
| 375 | } else { |
| 376 | valobj_list.SetValueObjectAtIndex(i, valobj_sp); |
| 377 | ++i; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 378 | } |
| 379 | } |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 380 | } else { |
| 381 | error.SetErrorString("unknown error"); |
| 382 | } |
| 383 | return error; |
| 384 | } break; |
| 385 | |
| 386 | default: { |
| 387 | static RegularExpression g_regex( |
| 388 | llvm::StringRef("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)")); |
| 389 | RegularExpression::Match regex_match(1); |
| 390 | std::string variable_name; |
| 391 | variable_list.Clear(); |
| 392 | if (!g_regex.Execute(variable_expr_path, ®ex_match)) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 393 | error.SetErrorStringWithFormat( |
Zachary Turner | 72f4997c | 2016-11-19 00:50:29 +0000 | [diff] [blame] | 394 | "unable to extract a variable name from '%s'", |
| 395 | variable_expr_path.str().c_str()); |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 396 | return error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 397 | } |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 398 | if (!regex_match.GetMatchAtIndex(variable_expr_path, 1, variable_name)) { |
| 399 | error.SetErrorStringWithFormat( |
Zachary Turner | 72f4997c | 2016-11-19 00:50:29 +0000 | [diff] [blame] | 400 | "unable to extract a variable name from '%s'", |
| 401 | variable_expr_path.str().c_str()); |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 402 | return error; |
| 403 | } |
| 404 | if (!callback(baton, variable_name.c_str(), variable_list)) { |
| 405 | error.SetErrorString("unknown error"); |
| 406 | return error; |
| 407 | } |
| 408 | uint32_t i = 0; |
| 409 | while (i < variable_list.GetSize()) { |
| 410 | VariableSP var_sp(variable_list.GetVariableAtIndex(i)); |
| 411 | ValueObjectSP valobj_sp; |
| 412 | if (!var_sp) { |
| 413 | variable_list.RemoveVariableAtIndex(i); |
| 414 | continue; |
| 415 | } |
| 416 | ValueObjectSP variable_valobj_sp( |
| 417 | ValueObjectVariable::Create(scope, var_sp)); |
| 418 | if (!variable_valobj_sp) { |
| 419 | variable_list.RemoveVariableAtIndex(i); |
| 420 | continue; |
| 421 | } |
| 422 | |
| 423 | llvm::StringRef variable_sub_expr_path = |
| 424 | variable_expr_path.drop_front(variable_name.size()); |
| 425 | if (!variable_sub_expr_path.empty()) { |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 426 | valobj_sp = variable_valobj_sp->GetValueForExpressionPath( |
Pavel Labath | 62ef185 | 2017-12-07 10:38:22 +0000 | [diff] [blame] | 427 | variable_sub_expr_path); |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 428 | if (!valobj_sp) { |
| 429 | error.SetErrorStringWithFormat( |
| 430 | "invalid expression path '%s' for variable '%s'", |
Zachary Turner | 72f4997c | 2016-11-19 00:50:29 +0000 | [diff] [blame] | 431 | variable_sub_expr_path.str().c_str(), |
| 432 | var_sp->GetName().GetCString()); |
Zachary Turner | 2a3d10a | 2016-11-18 19:23:39 +0000 | [diff] [blame] | 433 | variable_list.RemoveVariableAtIndex(i); |
| 434 | continue; |
| 435 | } |
| 436 | } else { |
| 437 | // Just the name of a variable with no extras |
| 438 | valobj_sp = variable_valobj_sp; |
| 439 | } |
| 440 | |
| 441 | valobj_list.Append(valobj_sp); |
| 442 | ++i; |
| 443 | } |
| 444 | |
| 445 | if (variable_list.GetSize() > 0) { |
| 446 | error.Clear(); |
| 447 | return error; |
| 448 | } |
| 449 | } break; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 450 | } |
| 451 | error.SetErrorString("unknown error"); |
| 452 | return error; |
| 453 | } |
| 454 | |
| 455 | bool Variable::DumpLocationForAddress(Stream *s, const Address &address) { |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 456 | // Be sure to resolve the address to section offset prior to calling this |
| 457 | // function. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 458 | if (address.IsSectionOffset()) { |
| 459 | SymbolContext sc; |
| 460 | CalculateSymbolContext(&sc); |
| 461 | if (sc.module_sp == address.GetModule()) { |
Zachary Turner | 95997f6 | 2018-11-15 05:06:59 +0000 | [diff] [blame] | 462 | ABISP abi; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 463 | if (m_owner_scope) { |
| 464 | ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule()); |
| 465 | if (module_sp) |
Zachary Turner | 95997f6 | 2018-11-15 05:06:59 +0000 | [diff] [blame] | 466 | abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | const addr_t file_addr = address.GetFileAddress(); |
| 470 | if (sc.function) { |
| 471 | if (sc.function->GetAddressRange().ContainsFileAddress(address)) { |
| 472 | addr_t loclist_base_file_addr = |
| 473 | sc.function->GetAddressRange().GetBaseAddress().GetFileAddress(); |
| 474 | if (loclist_base_file_addr == LLDB_INVALID_ADDRESS) |
| 475 | return false; |
| 476 | return m_location.DumpLocationForAddress(s, eDescriptionLevelBrief, |
| 477 | loclist_base_file_addr, |
Zachary Turner | 95997f6 | 2018-11-15 05:06:59 +0000 | [diff] [blame] | 478 | file_addr, abi.get()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 479 | } |
| 480 | } |
Zachary Turner | 95997f6 | 2018-11-15 05:06:59 +0000 | [diff] [blame] | 481 | return m_location.DumpLocationForAddress(s, eDescriptionLevelBrief, |
| 482 | LLDB_INVALID_ADDRESS, file_addr, |
| 483 | abi.get()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 484 | } |
| 485 | } |
| 486 | return false; |
| 487 | } |
| 488 | |
| 489 | static void PrivateAutoComplete( |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 490 | StackFrame *frame, llvm::StringRef partial_path, |
| 491 | const llvm::Twine |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 492 | &prefix_path, // Anything that has been resolved already will be in here |
| 493 | const CompilerType &compiler_type, |
| 494 | StringList &matches, bool &word_complete); |
| 495 | |
| 496 | static void PrivateAutoCompleteMembers( |
| 497 | StackFrame *frame, const std::string &partial_member_name, |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 498 | llvm::StringRef partial_path, |
| 499 | const llvm::Twine |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 500 | &prefix_path, // Anything that has been resolved already will be in here |
| 501 | const CompilerType &compiler_type, |
| 502 | StringList &matches, bool &word_complete); |
| 503 | |
| 504 | static void PrivateAutoCompleteMembers( |
| 505 | StackFrame *frame, const std::string &partial_member_name, |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 506 | llvm::StringRef partial_path, |
| 507 | const llvm::Twine |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 508 | &prefix_path, // Anything that has been resolved already will be in here |
| 509 | const CompilerType &compiler_type, |
| 510 | StringList &matches, bool &word_complete) { |
| 511 | |
| 512 | // We are in a type parsing child members |
| 513 | const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses(); |
| 514 | |
| 515 | if (num_bases > 0) { |
| 516 | for (uint32_t i = 0; i < num_bases; ++i) { |
| 517 | CompilerType base_class_type = |
| 518 | compiler_type.GetDirectBaseClassAtIndex(i, nullptr); |
| 519 | |
| 520 | PrivateAutoCompleteMembers( |
| 521 | frame, partial_member_name, partial_path, prefix_path, |
| 522 | base_class_type.GetCanonicalType(), matches, word_complete); |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | const uint32_t num_vbases = compiler_type.GetNumVirtualBaseClasses(); |
| 527 | |
| 528 | if (num_vbases > 0) { |
| 529 | for (uint32_t i = 0; i < num_vbases; ++i) { |
| 530 | CompilerType vbase_class_type = |
| 531 | compiler_type.GetVirtualBaseClassAtIndex(i, nullptr); |
| 532 | |
| 533 | PrivateAutoCompleteMembers( |
| 534 | frame, partial_member_name, partial_path, prefix_path, |
| 535 | vbase_class_type.GetCanonicalType(), matches, word_complete); |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | // We are in a type parsing child members |
| 540 | const uint32_t num_fields = compiler_type.GetNumFields(); |
| 541 | |
| 542 | if (num_fields > 0) { |
| 543 | for (uint32_t i = 0; i < num_fields; ++i) { |
| 544 | std::string member_name; |
| 545 | |
| 546 | CompilerType member_compiler_type = compiler_type.GetFieldAtIndex( |
| 547 | i, member_name, nullptr, nullptr, nullptr); |
| 548 | |
| 549 | if (partial_member_name.empty() || |
| 550 | member_name.find(partial_member_name) == 0) { |
| 551 | if (member_name == partial_member_name) { |
| 552 | PrivateAutoComplete( |
| 553 | frame, partial_path, |
| 554 | prefix_path + member_name, // Anything that has been resolved |
| 555 | // already will be in here |
| 556 | member_compiler_type.GetCanonicalType(), matches, word_complete); |
| 557 | } else { |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 558 | matches.AppendString((prefix_path + member_name).str()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 559 | } |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | static void PrivateAutoComplete( |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 566 | StackFrame *frame, llvm::StringRef partial_path, |
| 567 | const llvm::Twine |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 568 | &prefix_path, // Anything that has been resolved already will be in here |
| 569 | const CompilerType &compiler_type, |
| 570 | StringList &matches, bool &word_complete) { |
| 571 | // printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path = |
| 572 | // '%s'\n", prefix_path.c_str(), partial_path.c_str()); |
| 573 | std::string remaining_partial_path; |
| 574 | |
| 575 | const lldb::TypeClass type_class = compiler_type.GetTypeClass(); |
| 576 | if (partial_path.empty()) { |
| 577 | if (compiler_type.IsValid()) { |
| 578 | switch (type_class) { |
| 579 | default: |
| 580 | case eTypeClassArray: |
| 581 | case eTypeClassBlockPointer: |
| 582 | case eTypeClassBuiltin: |
| 583 | case eTypeClassComplexFloat: |
| 584 | case eTypeClassComplexInteger: |
| 585 | case eTypeClassEnumeration: |
| 586 | case eTypeClassFunction: |
| 587 | case eTypeClassMemberPointer: |
| 588 | case eTypeClassReference: |
| 589 | case eTypeClassTypedef: |
| 590 | case eTypeClassVector: { |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 591 | matches.AppendString(prefix_path.str()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 592 | word_complete = matches.GetSize() == 1; |
| 593 | } break; |
| 594 | |
| 595 | case eTypeClassClass: |
| 596 | case eTypeClassStruct: |
| 597 | case eTypeClassUnion: |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 598 | if (prefix_path.str().back() != '.') |
| 599 | matches.AppendString((prefix_path + ".").str()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 600 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 601 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 602 | case eTypeClassObjCObject: |
| 603 | case eTypeClassObjCInterface: |
| 604 | break; |
| 605 | case eTypeClassObjCObjectPointer: |
| 606 | case eTypeClassPointer: { |
| 607 | bool omit_empty_base_classes = true; |
Adrian Prantl | eca07c5 | 2018-11-05 20:49:07 +0000 | [diff] [blame] | 608 | if (compiler_type.GetNumChildren(omit_empty_base_classes, nullptr) > 0) |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 609 | matches.AppendString((prefix_path + "->").str()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 610 | else { |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 611 | matches.AppendString(prefix_path.str()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 612 | word_complete = true; |
| 613 | } |
| 614 | } break; |
| 615 | } |
| 616 | } else { |
| 617 | if (frame) { |
| 618 | const bool get_file_globals = true; |
| 619 | |
| 620 | VariableList *variable_list = frame->GetVariableList(get_file_globals); |
| 621 | |
| 622 | if (variable_list) { |
| 623 | const size_t num_variables = variable_list->GetSize(); |
| 624 | for (size_t i = 0; i < num_variables; ++i) { |
| 625 | Variable *variable = variable_list->GetVariableAtIndex(i).get(); |
| 626 | matches.AppendString(variable->GetName().AsCString()); |
| 627 | } |
| 628 | } |
| 629 | } |
| 630 | } |
| 631 | } else { |
| 632 | const char ch = partial_path[0]; |
| 633 | switch (ch) { |
| 634 | case '*': |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 635 | if (prefix_path.str().empty()) { |
| 636 | PrivateAutoComplete(frame, partial_path.substr(1), "*", compiler_type, |
| 637 | matches, word_complete); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 638 | } |
| 639 | break; |
| 640 | |
| 641 | case '&': |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 642 | if (prefix_path.isTriviallyEmpty()) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 643 | PrivateAutoComplete(frame, partial_path.substr(1), std::string("&"), |
| 644 | compiler_type, matches, word_complete); |
| 645 | } |
| 646 | break; |
| 647 | |
| 648 | case '-': |
Raphael Isemann | d4ff5ba | 2018-07-27 23:37:08 +0000 | [diff] [blame] | 649 | if (partial_path.size() > 1 && partial_path[1] == '>' && |
| 650 | !prefix_path.str().empty()) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 651 | switch (type_class) { |
| 652 | case lldb::eTypeClassPointer: { |
| 653 | CompilerType pointee_type(compiler_type.GetPointeeType()); |
Raphael Isemann | d4ff5ba | 2018-07-27 23:37:08 +0000 | [diff] [blame] | 654 | if (partial_path.size() > 2 && partial_path[2]) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 655 | // If there is more after the "->", then search deeper |
| 656 | PrivateAutoComplete( |
| 657 | frame, partial_path.substr(2), prefix_path + "->", |
| 658 | pointee_type.GetCanonicalType(), matches, word_complete); |
| 659 | } else { |
| 660 | // Nothing after the "->", so list all members |
| 661 | PrivateAutoCompleteMembers( |
| 662 | frame, std::string(), std::string(), prefix_path + "->", |
| 663 | pointee_type.GetCanonicalType(), matches, word_complete); |
| 664 | } |
| 665 | } break; |
Greg Clayton | 884fb69 | 2011-07-08 21:46:14 +0000 | [diff] [blame] | 666 | default: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 667 | break; |
Greg Clayton | 884fb69 | 2011-07-08 21:46:14 +0000 | [diff] [blame] | 668 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 669 | } |
| 670 | break; |
Greg Clayton | 884fb69 | 2011-07-08 21:46:14 +0000 | [diff] [blame] | 671 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 672 | case '.': |
| 673 | if (compiler_type.IsValid()) { |
| 674 | switch (type_class) { |
| 675 | case lldb::eTypeClassUnion: |
| 676 | case lldb::eTypeClassStruct: |
| 677 | case lldb::eTypeClassClass: |
Raphael Isemann | d4ff5ba | 2018-07-27 23:37:08 +0000 | [diff] [blame] | 678 | if (partial_path.size() > 1 && partial_path[1]) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 679 | // If there is more after the ".", then search deeper |
| 680 | PrivateAutoComplete(frame, partial_path.substr(1), |
| 681 | prefix_path + ".", compiler_type, matches, |
| 682 | word_complete); |
Greg Clayton | afacd14 | 2011-09-02 01:15:17 +0000 | [diff] [blame] | 683 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 684 | } else { |
| 685 | // Nothing after the ".", so list all members |
| 686 | PrivateAutoCompleteMembers(frame, std::string(), partial_path, |
| 687 | prefix_path + ".", compiler_type, |
| 688 | matches, word_complete); |
| 689 | } |
| 690 | break; |
Greg Clayton | f21fead | 2013-05-14 23:43:18 +0000 | [diff] [blame] | 691 | default: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 692 | break; |
Greg Clayton | f21fead | 2013-05-14 23:43:18 +0000 | [diff] [blame] | 693 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 694 | } |
| 695 | break; |
| 696 | default: |
| 697 | if (isalpha(ch) || ch == '_' || ch == '$') { |
| 698 | const size_t partial_path_len = partial_path.size(); |
| 699 | size_t pos = 1; |
| 700 | while (pos < partial_path_len) { |
| 701 | const char curr_ch = partial_path[pos]; |
| 702 | if (isalnum(curr_ch) || curr_ch == '_' || curr_ch == '$') { |
| 703 | ++pos; |
| 704 | continue; |
| 705 | } |
| 706 | break; |
| 707 | } |
| 708 | |
| 709 | std::string token(partial_path, 0, pos); |
| 710 | remaining_partial_path = partial_path.substr(pos); |
| 711 | |
| 712 | if (compiler_type.IsValid()) { |
| 713 | PrivateAutoCompleteMembers(frame, token, remaining_partial_path, |
| 714 | prefix_path, compiler_type, matches, |
| 715 | word_complete); |
| 716 | } else if (frame) { |
| 717 | // We haven't found our variable yet |
| 718 | const bool get_file_globals = true; |
| 719 | |
| 720 | VariableList *variable_list = |
| 721 | frame->GetVariableList(get_file_globals); |
| 722 | |
| 723 | if (!variable_list) |
| 724 | break; |
| 725 | |
| 726 | const size_t num_variables = variable_list->GetSize(); |
| 727 | for (size_t i = 0; i < num_variables; ++i) { |
| 728 | Variable *variable = variable_list->GetVariableAtIndex(i).get(); |
| 729 | |
| 730 | if (!variable) |
| 731 | continue; |
| 732 | |
| 733 | const char *variable_name = variable->GetName().AsCString(); |
| 734 | if (strstr(variable_name, token.c_str()) == variable_name) { |
| 735 | if (strcmp(variable_name, token.c_str()) == 0) { |
| 736 | Type *variable_type = variable->GetType(); |
| 737 | if (variable_type) { |
| 738 | CompilerType variable_compiler_type( |
| 739 | variable_type->GetForwardCompilerType()); |
| 740 | PrivateAutoComplete( |
| 741 | frame, remaining_partial_path, |
| 742 | prefix_path + token, // Anything that has been resolved |
| 743 | // already will be in here |
| 744 | variable_compiler_type.GetCanonicalType(), matches, |
| 745 | word_complete); |
| 746 | } else { |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 747 | matches.AppendString((prefix_path + variable_name).str()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 748 | } |
| 749 | } else if (remaining_partial_path.empty()) { |
Zachary Turner | 4aa8753 | 2016-11-17 01:37:42 +0000 | [diff] [blame] | 750 | matches.AppendString((prefix_path + variable_name).str()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 751 | } |
| 752 | } |
| 753 | } |
| 754 | } |
| 755 | } |
| 756 | break; |
Greg Clayton | f21fead | 2013-05-14 23:43:18 +0000 | [diff] [blame] | 757 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 758 | } |
Greg Clayton | f21fead | 2013-05-14 23:43:18 +0000 | [diff] [blame] | 759 | } |
| 760 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 761 | size_t Variable::AutoComplete(const ExecutionContext &exe_ctx, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 762 | CompletionRequest &request) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 763 | CompilerType compiler_type; |
Greg Clayton | f21fead | 2013-05-14 23:43:18 +0000 | [diff] [blame] | 764 | |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 765 | bool word_complete = false; |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 766 | StringList matches; |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 767 | PrivateAutoComplete(exe_ctx.GetFramePtr(), request.GetCursorArgumentPrefix(), |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 768 | "", compiler_type, matches, word_complete); |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 769 | request.SetWordComplete(word_complete); |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 770 | request.AddCompletions(matches); |
Greg Clayton | f21fead | 2013-05-14 23:43:18 +0000 | [diff] [blame] | 771 | |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 772 | return request.GetNumberOfMatches(); |
Greg Clayton | c749eb8 | 2011-07-11 05:12:02 +0000 | [diff] [blame] | 773 | } |