1 //===-- Value.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/Core/Value.h" 11 12 #include "lldb/Core/Address.h" 13 #include "lldb/Core/Module.h" 14 #include "lldb/Symbol/CompilerType.h" 15 #include "lldb/Symbol/ObjectFile.h" 16 #include "lldb/Symbol/SymbolContext.h" 17 #include "lldb/Symbol/Type.h" 18 #include "lldb/Symbol/Variable.h" 19 #include "lldb/Target/ExecutionContext.h" 20 #include "lldb/Target/Process.h" 21 #include "lldb/Target/SectionLoadList.h" 22 #include "lldb/Target/Target.h" 23 #include "lldb/Utility/ConstString.h" 24 #include "lldb/Utility/DataBufferHeap.h" 25 #include "lldb/Utility/DataExtractor.h" 26 #include "lldb/Utility/Endian.h" 27 #include "lldb/Utility/FileSpec.h" 28 #include "lldb/Utility/State.h" 29 #include "lldb/Utility/Stream.h" 30 #include "lldb/lldb-defines.h" 31 #include "lldb/lldb-forward.h" 32 #include "lldb/lldb-types.h" 33 34 #include <memory> 35 #include <string> 36 37 #include <inttypes.h> 38 39 using namespace lldb; 40 using namespace lldb_private; 41 42 Value::Value() 43 : m_value(), m_vector(), m_compiler_type(), m_context(NULL), 44 m_value_type(eValueTypeScalar), m_context_type(eContextTypeInvalid), 45 m_data_buffer() {} 46 47 Value::Value(const Scalar &scalar) 48 : m_value(scalar), m_vector(), m_compiler_type(), m_context(NULL), 49 m_value_type(eValueTypeScalar), m_context_type(eContextTypeInvalid), 50 m_data_buffer() {} 51 52 Value::Value(const void *bytes, int len) 53 : m_value(), m_vector(), m_compiler_type(), m_context(NULL), 54 m_value_type(eValueTypeHostAddress), m_context_type(eContextTypeInvalid), 55 m_data_buffer() { 56 SetBytes(bytes, len); 57 } 58 59 Value::Value(const Value &v) 60 : m_value(v.m_value), m_vector(v.m_vector), 61 m_compiler_type(v.m_compiler_type), m_context(v.m_context), 62 m_value_type(v.m_value_type), m_context_type(v.m_context_type), 63 m_data_buffer() { 64 const uintptr_t rhs_value = 65 (uintptr_t)v.m_value.ULongLong(LLDB_INVALID_ADDRESS); 66 if ((rhs_value != 0) && 67 (rhs_value == (uintptr_t)v.m_data_buffer.GetBytes())) { 68 m_data_buffer.CopyData(v.m_data_buffer.GetBytes(), 69 v.m_data_buffer.GetByteSize()); 70 71 m_value = (uintptr_t)m_data_buffer.GetBytes(); 72 } 73 } 74 75 Value &Value::operator=(const Value &rhs) { 76 if (this != &rhs) { 77 m_value = rhs.m_value; 78 m_vector = rhs.m_vector; 79 m_compiler_type = rhs.m_compiler_type; 80 m_context = rhs.m_context; 81 m_value_type = rhs.m_value_type; 82 m_context_type = rhs.m_context_type; 83 const uintptr_t rhs_value = 84 (uintptr_t)rhs.m_value.ULongLong(LLDB_INVALID_ADDRESS); 85 if ((rhs_value != 0) && 86 (rhs_value == (uintptr_t)rhs.m_data_buffer.GetBytes())) { 87 m_data_buffer.CopyData(rhs.m_data_buffer.GetBytes(), 88 rhs.m_data_buffer.GetByteSize()); 89 90 m_value = (uintptr_t)m_data_buffer.GetBytes(); 91 } 92 } 93 return *this; 94 } 95 96 void Value::SetBytes(const void *bytes, int len) { 97 m_value_type = eValueTypeHostAddress; 98 m_data_buffer.CopyData(bytes, len); 99 m_value = (uintptr_t)m_data_buffer.GetBytes(); 100 } 101 102 void Value::AppendBytes(const void *bytes, int len) { 103 m_value_type = eValueTypeHostAddress; 104 m_data_buffer.AppendData(bytes, len); 105 m_value = (uintptr_t)m_data_buffer.GetBytes(); 106 } 107 108 void Value::Dump(Stream *strm) { 109 m_value.GetValue(strm, true); 110 strm->Printf(", value_type = %s, context = %p, context_type = %s", 111 Value::GetValueTypeAsCString(m_value_type), m_context, 112 Value::GetContextTypeAsCString(m_context_type)); 113 } 114 115 Value::ValueType Value::GetValueType() const { return m_value_type; } 116 117 AddressType Value::GetValueAddressType() const { 118 switch (m_value_type) { 119 default: 120 case eValueTypeScalar: 121 break; 122 case eValueTypeLoadAddress: 123 return eAddressTypeLoad; 124 case eValueTypeFileAddress: 125 return eAddressTypeFile; 126 case eValueTypeHostAddress: 127 return eAddressTypeHost; 128 } 129 return eAddressTypeInvalid; 130 } 131 132 RegisterInfo *Value::GetRegisterInfo() const { 133 if (m_context_type == eContextTypeRegisterInfo) 134 return static_cast<RegisterInfo *>(m_context); 135 return NULL; 136 } 137 138 Type *Value::GetType() { 139 if (m_context_type == eContextTypeLLDBType) 140 return static_cast<Type *>(m_context); 141 return NULL; 142 } 143 144 size_t Value::AppendDataToHostBuffer(const Value &rhs) { 145 if (this == &rhs) 146 return 0; 147 148 size_t curr_size = m_data_buffer.GetByteSize(); 149 Status error; 150 switch (rhs.GetValueType()) { 151 case eValueTypeScalar: { 152 const size_t scalar_size = rhs.m_value.GetByteSize(); 153 if (scalar_size > 0) { 154 const size_t new_size = curr_size + scalar_size; 155 if (ResizeData(new_size) == new_size) { 156 rhs.m_value.GetAsMemoryData(m_data_buffer.GetBytes() + curr_size, 157 scalar_size, endian::InlHostByteOrder(), 158 error); 159 return scalar_size; 160 } 161 } 162 } break; 163 case eValueTypeVector: { 164 const size_t vector_size = rhs.m_vector.length; 165 if (vector_size > 0) { 166 const size_t new_size = curr_size + vector_size; 167 if (ResizeData(new_size) == new_size) { 168 ::memcpy(m_data_buffer.GetBytes() + curr_size, rhs.m_vector.bytes, 169 vector_size); 170 return vector_size; 171 } 172 } 173 } break; 174 case eValueTypeFileAddress: 175 case eValueTypeLoadAddress: 176 case eValueTypeHostAddress: { 177 const uint8_t *src = rhs.GetBuffer().GetBytes(); 178 const size_t src_len = rhs.GetBuffer().GetByteSize(); 179 if (src && src_len > 0) { 180 const size_t new_size = curr_size + src_len; 181 if (ResizeData(new_size) == new_size) { 182 ::memcpy(m_data_buffer.GetBytes() + curr_size, src, src_len); 183 return src_len; 184 } 185 } 186 } break; 187 } 188 return 0; 189 } 190 191 size_t Value::ResizeData(size_t len) { 192 m_value_type = eValueTypeHostAddress; 193 m_data_buffer.SetByteSize(len); 194 m_value = (uintptr_t)m_data_buffer.GetBytes(); 195 return m_data_buffer.GetByteSize(); 196 } 197 198 bool Value::ValueOf(ExecutionContext *exe_ctx) { 199 switch (m_context_type) { 200 case eContextTypeInvalid: 201 case eContextTypeRegisterInfo: // RegisterInfo * 202 case eContextTypeLLDBType: // Type * 203 break; 204 205 case eContextTypeVariable: // Variable * 206 ResolveValue(exe_ctx); 207 return true; 208 } 209 return false; 210 } 211 212 uint64_t Value::GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx) { 213 switch (m_context_type) { 214 case eContextTypeRegisterInfo: // RegisterInfo * 215 if (GetRegisterInfo()) { 216 if (error_ptr) 217 error_ptr->Clear(); 218 return GetRegisterInfo()->byte_size; 219 } 220 break; 221 222 case eContextTypeInvalid: 223 case eContextTypeLLDBType: // Type * 224 case eContextTypeVariable: // Variable * 225 { 226 auto *scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr; 227 if (llvm::Optional<uint64_t> size = GetCompilerType().GetByteSize(scope)) { 228 if (error_ptr) 229 error_ptr->Clear(); 230 return *size; 231 } 232 break; 233 } 234 } 235 if (error_ptr && error_ptr->Success()) 236 error_ptr->SetErrorString("Unable to determine byte size."); 237 return 0; 238 } 239 240 const CompilerType &Value::GetCompilerType() { 241 if (!m_compiler_type.IsValid()) { 242 switch (m_context_type) { 243 case eContextTypeInvalid: 244 break; 245 246 case eContextTypeRegisterInfo: 247 break; // TODO: Eventually convert into a compiler type? 248 249 case eContextTypeLLDBType: { 250 Type *lldb_type = GetType(); 251 if (lldb_type) 252 m_compiler_type = lldb_type->GetForwardCompilerType(); 253 } break; 254 255 case eContextTypeVariable: { 256 Variable *variable = GetVariable(); 257 if (variable) { 258 Type *variable_type = variable->GetType(); 259 if (variable_type) 260 m_compiler_type = variable_type->GetForwardCompilerType(); 261 } 262 } break; 263 } 264 } 265 266 return m_compiler_type; 267 } 268 269 void Value::SetCompilerType(const CompilerType &compiler_type) { 270 m_compiler_type = compiler_type; 271 } 272 273 lldb::Format Value::GetValueDefaultFormat() { 274 switch (m_context_type) { 275 case eContextTypeRegisterInfo: 276 if (GetRegisterInfo()) 277 return GetRegisterInfo()->format; 278 break; 279 280 case eContextTypeInvalid: 281 case eContextTypeLLDBType: 282 case eContextTypeVariable: { 283 const CompilerType &ast_type = GetCompilerType(); 284 if (ast_type.IsValid()) 285 return ast_type.GetFormat(); 286 } break; 287 } 288 289 // Return a good default in case we can't figure anything out 290 return eFormatHex; 291 } 292 293 bool Value::GetData(DataExtractor &data) { 294 switch (m_value_type) { 295 default: 296 break; 297 298 case eValueTypeScalar: 299 if (m_value.GetData(data)) 300 return true; 301 break; 302 303 case eValueTypeLoadAddress: 304 case eValueTypeFileAddress: 305 case eValueTypeHostAddress: 306 if (m_data_buffer.GetByteSize()) { 307 data.SetData(m_data_buffer.GetBytes(), m_data_buffer.GetByteSize(), 308 data.GetByteOrder()); 309 return true; 310 } 311 break; 312 } 313 314 return false; 315 } 316 317 Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, 318 uint32_t data_offset, Module *module) { 319 data.Clear(); 320 321 Status error; 322 lldb::addr_t address = LLDB_INVALID_ADDRESS; 323 AddressType address_type = eAddressTypeFile; 324 Address file_so_addr; 325 const CompilerType &ast_type = GetCompilerType(); 326 switch (m_value_type) { 327 case eValueTypeVector: 328 if (ast_type.IsValid()) 329 data.SetAddressByteSize(ast_type.GetPointerByteSize()); 330 else 331 data.SetAddressByteSize(sizeof(void *)); 332 data.SetData(m_vector.bytes, m_vector.length, m_vector.byte_order); 333 break; 334 335 case eValueTypeScalar: { 336 data.SetByteOrder(endian::InlHostByteOrder()); 337 if (ast_type.IsValid()) 338 data.SetAddressByteSize(ast_type.GetPointerByteSize()); 339 else 340 data.SetAddressByteSize(sizeof(void *)); 341 342 uint32_t limit_byte_size = UINT32_MAX; 343 344 if (llvm::Optional<uint64_t> size = ast_type.GetByteSize( 345 exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)) 346 limit_byte_size = *size; 347 348 if (limit_byte_size <= m_value.GetByteSize()) { 349 if (m_value.GetData(data, limit_byte_size)) 350 return error; // Success; 351 } 352 353 error.SetErrorStringWithFormat("extracting data from value failed"); 354 break; 355 } 356 case eValueTypeLoadAddress: 357 if (exe_ctx == NULL) { 358 error.SetErrorString("can't read load address (no execution context)"); 359 } else { 360 Process *process = exe_ctx->GetProcessPtr(); 361 if (process == NULL || !process->IsAlive()) { 362 Target *target = exe_ctx->GetTargetPtr(); 363 if (target) { 364 // Allow expressions to run and evaluate things when the target has 365 // memory sections loaded. This allows you to use "target modules 366 // load" to load your executable and any shared libraries, then 367 // execute commands where you can look at types in data sections. 368 const SectionLoadList &target_sections = target->GetSectionLoadList(); 369 if (!target_sections.IsEmpty()) { 370 address = m_value.ULongLong(LLDB_INVALID_ADDRESS); 371 if (target_sections.ResolveLoadAddress(address, file_so_addr)) { 372 address_type = eAddressTypeLoad; 373 data.SetByteOrder(target->GetArchitecture().GetByteOrder()); 374 data.SetAddressByteSize( 375 target->GetArchitecture().GetAddressByteSize()); 376 } else 377 address = LLDB_INVALID_ADDRESS; 378 } 379 } else { 380 error.SetErrorString("can't read load address (invalid process)"); 381 } 382 } else { 383 address = m_value.ULongLong(LLDB_INVALID_ADDRESS); 384 address_type = eAddressTypeLoad; 385 data.SetByteOrder( 386 process->GetTarget().GetArchitecture().GetByteOrder()); 387 data.SetAddressByteSize( 388 process->GetTarget().GetArchitecture().GetAddressByteSize()); 389 } 390 } 391 break; 392 393 case eValueTypeFileAddress: 394 if (exe_ctx == NULL) { 395 error.SetErrorString("can't read file address (no execution context)"); 396 } else if (exe_ctx->GetTargetPtr() == NULL) { 397 error.SetErrorString("can't read file address (invalid target)"); 398 } else { 399 address = m_value.ULongLong(LLDB_INVALID_ADDRESS); 400 if (address == LLDB_INVALID_ADDRESS) { 401 error.SetErrorString("invalid file address"); 402 } else { 403 if (module == NULL) { 404 // The only thing we can currently lock down to a module so that we 405 // can resolve a file address, is a variable. 406 Variable *variable = GetVariable(); 407 if (variable) { 408 SymbolContext var_sc; 409 variable->CalculateSymbolContext(&var_sc); 410 module = var_sc.module_sp.get(); 411 } 412 } 413 414 if (module) { 415 bool resolved = false; 416 ObjectFile *objfile = module->GetObjectFile(); 417 if (objfile) { 418 Address so_addr(address, objfile->GetSectionList()); 419 addr_t load_address = 420 so_addr.GetLoadAddress(exe_ctx->GetTargetPtr()); 421 bool process_launched_and_stopped = 422 exe_ctx->GetProcessPtr() 423 ? StateIsStoppedState(exe_ctx->GetProcessPtr()->GetState(), 424 true /* must_exist */) 425 : false; 426 // Don't use the load address if the process has exited. 427 if (load_address != LLDB_INVALID_ADDRESS && 428 process_launched_and_stopped) { 429 resolved = true; 430 address = load_address; 431 address_type = eAddressTypeLoad; 432 data.SetByteOrder( 433 exe_ctx->GetTargetRef().GetArchitecture().GetByteOrder()); 434 data.SetAddressByteSize(exe_ctx->GetTargetRef() 435 .GetArchitecture() 436 .GetAddressByteSize()); 437 } else { 438 if (so_addr.IsSectionOffset()) { 439 resolved = true; 440 file_so_addr = so_addr; 441 data.SetByteOrder(objfile->GetByteOrder()); 442 data.SetAddressByteSize(objfile->GetAddressByteSize()); 443 } 444 } 445 } 446 if (!resolved) { 447 Variable *variable = GetVariable(); 448 449 if (module) { 450 if (variable) 451 error.SetErrorStringWithFormat( 452 "unable to resolve the module for file address 0x%" PRIx64 453 " for variable '%s' in %s", 454 address, variable->GetName().AsCString(""), 455 module->GetFileSpec().GetPath().c_str()); 456 else 457 error.SetErrorStringWithFormat( 458 "unable to resolve the module for file address 0x%" PRIx64 459 " in %s", 460 address, module->GetFileSpec().GetPath().c_str()); 461 } else { 462 if (variable) 463 error.SetErrorStringWithFormat( 464 "unable to resolve the module for file address 0x%" PRIx64 465 " for variable '%s'", 466 address, variable->GetName().AsCString("")); 467 else 468 error.SetErrorStringWithFormat( 469 "unable to resolve the module for file address 0x%" PRIx64, 470 address); 471 } 472 } 473 } else { 474 // Can't convert a file address to anything valid without more 475 // context (which Module it came from) 476 error.SetErrorString( 477 "can't read memory from file address without more context"); 478 } 479 } 480 } 481 break; 482 483 case eValueTypeHostAddress: 484 address = m_value.ULongLong(LLDB_INVALID_ADDRESS); 485 address_type = eAddressTypeHost; 486 if (exe_ctx) { 487 Target *target = exe_ctx->GetTargetPtr(); 488 if (target) { 489 data.SetByteOrder(target->GetArchitecture().GetByteOrder()); 490 data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize()); 491 break; 492 } 493 } 494 // fallback to host settings 495 data.SetByteOrder(endian::InlHostByteOrder()); 496 data.SetAddressByteSize(sizeof(void *)); 497 break; 498 } 499 500 // Bail if we encountered any errors 501 if (error.Fail()) 502 return error; 503 504 if (address == LLDB_INVALID_ADDRESS) { 505 error.SetErrorStringWithFormat("invalid %s address", 506 address_type == eAddressTypeHost ? "host" 507 : "load"); 508 return error; 509 } 510 511 // If we got here, we need to read the value from memory 512 size_t byte_size = GetValueByteSize(&error, exe_ctx); 513 514 // Bail if we encountered any errors getting the byte size 515 if (error.Fail()) 516 return error; 517 518 // Make sure we have enough room within "data", and if we don't make 519 // something large enough that does 520 if (!data.ValidOffsetForDataOfSize(data_offset, byte_size)) { 521 auto data_sp = 522 std::make_shared<DataBufferHeap>(data_offset + byte_size, '\0'); 523 data.SetData(data_sp); 524 } 525 526 uint8_t *dst = const_cast<uint8_t *>(data.PeekData(data_offset, byte_size)); 527 if (dst != NULL) { 528 if (address_type == eAddressTypeHost) { 529 // The address is an address in this process, so just copy it. 530 if (address == 0) { 531 error.SetErrorStringWithFormat( 532 "trying to read from host address of 0."); 533 return error; 534 } 535 memcpy(dst, reinterpret_cast<uint8_t *>(address), byte_size); 536 } else if ((address_type == eAddressTypeLoad) || 537 (address_type == eAddressTypeFile)) { 538 if (file_so_addr.IsValid()) { 539 // We have a file address that we were able to translate into a section 540 // offset address so we might be able to read this from the object 541 // files if we don't have a live process. Lets always try and read from 542 // the process if we have one though since we want to read the actual 543 // value by setting "prefer_file_cache" to false. 544 const bool prefer_file_cache = false; 545 if (exe_ctx->GetTargetRef().ReadMemory(file_so_addr, prefer_file_cache, 546 dst, byte_size, 547 error) != byte_size) { 548 error.SetErrorStringWithFormat( 549 "read memory from 0x%" PRIx64 " failed", (uint64_t)address); 550 } 551 } else { 552 // The execution context might have a NULL process, but it might have a 553 // valid process in the exe_ctx->target, so use the 554 // ExecutionContext::GetProcess accessor to ensure we get the process 555 // if there is one. 556 Process *process = exe_ctx->GetProcessPtr(); 557 558 if (process) { 559 const size_t bytes_read = 560 process->ReadMemory(address, dst, byte_size, error); 561 if (bytes_read != byte_size) 562 error.SetErrorStringWithFormat( 563 "read memory from 0x%" PRIx64 " failed (%u of %u bytes read)", 564 (uint64_t)address, (uint32_t)bytes_read, (uint32_t)byte_size); 565 } else { 566 error.SetErrorStringWithFormat("read memory from 0x%" PRIx64 567 " failed (invalid process)", 568 (uint64_t)address); 569 } 570 } 571 } else { 572 error.SetErrorStringWithFormat("unsupported AddressType value (%i)", 573 address_type); 574 } 575 } else { 576 error.SetErrorStringWithFormat("out of memory"); 577 } 578 579 return error; 580 } 581 582 Scalar &Value::ResolveValue(ExecutionContext *exe_ctx) { 583 const CompilerType &compiler_type = GetCompilerType(); 584 if (compiler_type.IsValid()) { 585 switch (m_value_type) { 586 case eValueTypeScalar: // raw scalar value 587 break; 588 589 default: 590 case eValueTypeFileAddress: 591 case eValueTypeLoadAddress: // load address value 592 case eValueTypeHostAddress: // host address value (for memory in the process 593 // that is using liblldb) 594 { 595 DataExtractor data; 596 lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS); 597 Status error(GetValueAsData(exe_ctx, data, 0, NULL)); 598 if (error.Success()) { 599 Scalar scalar; 600 if (compiler_type.GetValueAsScalar(data, 0, data.GetByteSize(), 601 scalar)) { 602 m_value = scalar; 603 m_value_type = eValueTypeScalar; 604 } else { 605 if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes()) { 606 m_value.Clear(); 607 m_value_type = eValueTypeScalar; 608 } 609 } 610 } else { 611 if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes()) { 612 m_value.Clear(); 613 m_value_type = eValueTypeScalar; 614 } 615 } 616 } break; 617 } 618 } 619 return m_value; 620 } 621 622 Variable *Value::GetVariable() { 623 if (m_context_type == eContextTypeVariable) 624 return static_cast<Variable *>(m_context); 625 return NULL; 626 } 627 628 void Value::Clear() { 629 m_value.Clear(); 630 m_vector.Clear(); 631 m_compiler_type.Clear(); 632 m_value_type = eValueTypeScalar; 633 m_context = NULL; 634 m_context_type = eContextTypeInvalid; 635 m_data_buffer.Clear(); 636 } 637 638 const char *Value::GetValueTypeAsCString(ValueType value_type) { 639 switch (value_type) { 640 case eValueTypeScalar: 641 return "scalar"; 642 case eValueTypeVector: 643 return "vector"; 644 case eValueTypeFileAddress: 645 return "file address"; 646 case eValueTypeLoadAddress: 647 return "load address"; 648 case eValueTypeHostAddress: 649 return "host address"; 650 }; 651 return "???"; 652 } 653 654 const char *Value::GetContextTypeAsCString(ContextType context_type) { 655 switch (context_type) { 656 case eContextTypeInvalid: 657 return "invalid"; 658 case eContextTypeRegisterInfo: 659 return "RegisterInfo *"; 660 case eContextTypeLLDBType: 661 return "Type *"; 662 case eContextTypeVariable: 663 return "Variable *"; 664 }; 665 return "???"; 666 } 667 668 void Value::ConvertToLoadAddress(Module *module, Target *target) { 669 if (!module || !target || (GetValueType() != eValueTypeFileAddress)) 670 return; 671 672 lldb::addr_t file_addr = GetScalar().ULongLong(LLDB_INVALID_ADDRESS); 673 if (file_addr == LLDB_INVALID_ADDRESS) 674 return; 675 676 Address so_addr; 677 if (!module->ResolveFileAddress(file_addr, so_addr)) 678 return; 679 lldb::addr_t load_addr = so_addr.GetLoadAddress(target); 680 if (load_addr == LLDB_INVALID_ADDRESS) 681 return; 682 683 SetValueType(Value::eValueTypeLoadAddress); 684 GetScalar() = load_addr; 685 } 686 687 ValueList::ValueList(const ValueList &rhs) { m_values = rhs.m_values; } 688 689 const ValueList &ValueList::operator=(const ValueList &rhs) { 690 m_values = rhs.m_values; 691 return *this; 692 } 693 694 void ValueList::PushValue(const Value &value) { m_values.push_back(value); } 695 696 size_t ValueList::GetSize() { return m_values.size(); } 697 698 Value *ValueList::GetValueAtIndex(size_t idx) { 699 if (idx < GetSize()) { 700 return &(m_values[idx]); 701 } else 702 return NULL; 703 } 704 705 void ValueList::Clear() { m_values.clear(); } 706