LLDB mainline
Value.cpp
Go to the documentation of this file.
1//===-- Value.cpp ---------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/Core/Value.h"
10
11#include "lldb/Core/Address.h"
12#include "lldb/Core/Module.h"
16#include "lldb/Symbol/Type.h"
19#include "lldb/Target/Process.h"
21#include "lldb/Target/Target.h"
25#include "lldb/Utility/Endian.h"
28#include "lldb/Utility/Log.h"
30#include "lldb/Utility/State.h"
31#include "lldb/Utility/Stream.h"
32#include "lldb/lldb-defines.h"
33#include "lldb/lldb-forward.h"
34#include "lldb/lldb-types.h"
35
36#include <memory>
37#include <optional>
38#include <string>
39
40#include <cinttypes>
41
42using namespace lldb;
43using namespace lldb_private;
44
46
47Value::Value(const Scalar &scalar)
48 : m_value(scalar), m_compiler_type(), m_data_buffer() {}
49
50Value::Value(const void *bytes, int len)
53 SetBytes(bytes, len);
54}
55
60 const uintptr_t rhs_value =
62 if ((rhs_value != 0) &&
63 (rhs_value == (uintptr_t)v.m_data_buffer.GetBytes())) {
64 m_data_buffer.CopyData(v.m_data_buffer.GetBytes(),
65 v.m_data_buffer.GetByteSize());
66
67 m_value = (uintptr_t)m_data_buffer.GetBytes();
68 }
69}
70
72 if (this != &rhs) {
73 m_value = rhs.m_value;
75 m_context = rhs.m_context;
78 const uintptr_t rhs_value =
80 if ((rhs_value != 0) &&
81 (rhs_value == (uintptr_t)rhs.m_data_buffer.GetBytes())) {
84
85 m_value = (uintptr_t)m_data_buffer.GetBytes();
86 }
87 }
88 return *this;
89}
90
91void Value::SetBytes(const void *bytes, int len) {
93 m_data_buffer.CopyData(bytes, len);
94 m_value = (uintptr_t)m_data_buffer.GetBytes();
95}
96
97void Value::AppendBytes(const void *bytes, int len) {
99 m_data_buffer.AppendData(bytes, len);
100 m_value = (uintptr_t)m_data_buffer.GetBytes();
101}
102
103void Value::Dump(Stream *strm) {
104 if (!strm)
105 return;
106 m_value.GetValue(*strm, true);
107 strm->Printf(", value_type = %s, context = %p, context_type = %s",
110}
111
113
115 switch (m_value_type) {
118 break;
120 return eAddressTypeLoad;
122 return eAddressTypeFile;
124 return eAddressTypeHost;
125 }
126 return eAddressTypeInvalid;
127}
128
130 switch (address_type) {
131 case eAddressTypeFile:
133 case eAddressTypeLoad:
135 case eAddressTypeHost:
139 }
140 llvm_unreachable("Unexpected address type!");
141}
142
145 return static_cast<RegisterInfo *>(m_context);
146 return nullptr;
147}
148
151 return static_cast<Type *>(m_context);
152 return nullptr;
153}
154
156 if (this == &rhs)
157 return 0;
158
159 size_t curr_size = m_data_buffer.GetByteSize();
161 switch (rhs.GetValueType()) {
163 return 0;
164 case ValueType::Scalar: {
165 const size_t scalar_size = rhs.m_value.GetByteSize();
166 if (scalar_size > 0) {
167 const size_t new_size = curr_size + scalar_size;
168 if (ResizeData(new_size) == new_size) {
169 rhs.m_value.GetAsMemoryData(m_data_buffer.GetBytes() + curr_size,
170 scalar_size, endian::InlHostByteOrder(),
171 error);
172 return scalar_size;
173 }
174 }
175 } break;
179 const uint8_t *src = rhs.GetBuffer().GetBytes();
180 const size_t src_len = rhs.GetBuffer().GetByteSize();
181 if (src && src_len > 0) {
182 const size_t new_size = curr_size + src_len;
183 if (ResizeData(new_size) == new_size) {
184 ::memcpy(m_data_buffer.GetBytes() + curr_size, src, src_len);
185 return src_len;
186 }
187 }
188 } break;
189 }
190 return 0;
191}
192
193size_t Value::ResizeData(size_t len) {
195 m_data_buffer.SetByteSize(len);
196 m_value = (uintptr_t)m_data_buffer.GetBytes();
197 return m_data_buffer.GetByteSize();
198}
199
201 switch (m_context_type) {
203 case ContextType::RegisterInfo: // RegisterInfo *
204 case ContextType::LLDBType: // Type *
205 break;
206
207 case ContextType::Variable: // Variable *
208 ResolveValue(exe_ctx);
209 return true;
210 }
211 return false;
212}
213
214uint64_t Value::GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx) {
215 switch (m_context_type) {
216 case ContextType::RegisterInfo: // RegisterInfo *
217 if (GetRegisterInfo()) {
218 if (error_ptr)
219 error_ptr->Clear();
220 return GetRegisterInfo()->byte_size;
221 }
222 break;
223
225 case ContextType::LLDBType: // Type *
226 case ContextType::Variable: // Variable *
227 {
228 auto *scope = exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
229 auto size_or_err = GetCompilerType().GetByteSize(scope);
230 if (!size_or_err) {
231 if (error_ptr && error_ptr->Success())
232 *error_ptr = Status::FromError(size_or_err.takeError());
233 else
234 LLDB_LOG_ERRORV(GetLog(LLDBLog::Types), size_or_err.takeError(), "{0}");
235 } else {
236 if (error_ptr)
237 error_ptr->Clear();
238 return *size_or_err;
239 }
240 break;
241 }
242 }
243 if (error_ptr && error_ptr->Success())
244 *error_ptr = Status::FromErrorString("Unable to determine byte size.");
245 return 0;
246}
247
249 if (!m_compiler_type.IsValid()) {
250 switch (m_context_type) {
252 break;
253
255 break; // TODO: Eventually convert into a compiler type?
256
258 Type *lldb_type = GetType();
259 if (lldb_type)
261 } break;
262
264 Variable *variable = GetVariable();
265 if (variable) {
266 Type *variable_type = variable->GetType();
267 if (variable_type)
268 m_compiler_type = variable_type->GetForwardCompilerType();
269 }
270 } break;
271 }
272 }
273
274 return m_compiler_type;
275}
276
277void Value::SetCompilerType(const CompilerType &compiler_type) {
278 m_compiler_type = compiler_type;
279}
280
282 switch (m_context_type) {
284 if (GetRegisterInfo())
285 return GetRegisterInfo()->format;
286 break;
287
291 const CompilerType &ast_type = GetCompilerType();
292 if (ast_type.IsValid())
293 return ast_type.GetFormat();
294 } break;
295 }
296
297 // Return a good default in case we can't figure anything out
298 return eFormatHex;
299}
300
302 switch (m_value_type) {
304 return false;
306 if (m_value.GetData(data))
307 return true;
308 break;
309
313 if (m_data_buffer.GetByteSize()) {
314 data.SetData(m_data_buffer.GetBytes(), m_data_buffer.GetByteSize(),
315 data.GetByteOrder());
316 return true;
317 }
318 break;
319 }
320
321 return false;
322}
323
325 Module *module) {
326 data.Clear();
327
330 AddressType address_type = eAddressTypeFile;
331 Address file_so_addr;
332 const CompilerType &ast_type = GetCompilerType();
333 std::optional<uint64_t> type_size =
334 llvm::expectedToOptional(ast_type.GetByteSize(
335 exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr));
336 // Nothing to be done for a zero-sized type.
337 if (type_size && *type_size == 0)
338 return error;
339
340 switch (m_value_type) {
342 error = Status::FromErrorString("invalid value");
343 break;
344 case ValueType::Scalar: {
346 if (ast_type.IsValid())
347 data.SetAddressByteSize(ast_type.GetPointerByteSize());
348 else
349 data.SetAddressByteSize(sizeof(void *));
350
351 if (!type_size)
352 return Status::FromErrorString("type does not have a size");
353
354 uint32_t result_byte_size = *type_size;
355 if (m_value.GetData(data, result_byte_size))
356 return error; // Success;
357
358 error = Status::FromErrorString("extracting data from value failed");
359 break;
360 }
362 if (exe_ctx == nullptr) {
364 "can't read load address (no execution context)");
365 } else {
366 Process *process = exe_ctx->GetProcessPtr();
367 if (process == nullptr || !process->IsAlive()) {
368 Target *target = exe_ctx->GetTargetPtr();
369 if (target) {
370 // Allow expressions to run and evaluate things when the target has
371 // memory sections loaded. This allows you to use "target modules
372 // load" to load your executable and any shared libraries, then
373 // execute commands where you can look at types in data sections.
374 if (target->HasLoadedSections()) {
375 address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
376 if (target->ResolveLoadAddress(address, file_so_addr)) {
377 address_type = eAddressTypeLoad;
378 data.SetByteOrder(target->GetArchitecture().GetByteOrder());
381 } else
382 address = LLDB_INVALID_ADDRESS;
383 }
384 } else {
386 "can't read load address (invalid process)");
387 }
388 } else {
389 address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
390 address_type = eAddressTypeLoad;
391 data.SetByteOrder(
392 process->GetTarget().GetArchitecture().GetByteOrder());
395 }
396 }
397 break;
398
400 if (exe_ctx == nullptr) {
402 "can't read file address (no execution context)");
403 } else if (exe_ctx->GetTargetPtr() == nullptr) {
404 error =
405 Status::FromErrorString("can't read file address (invalid target)");
406 } else {
407 address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
408 if (address == LLDB_INVALID_ADDRESS) {
409 error = Status::FromErrorString("invalid file address");
410 } else {
411 if (module == nullptr) {
412 // The only thing we can currently lock down to a module so that we
413 // can resolve a file address, is a variable.
414 Variable *variable = GetVariable();
415 if (variable) {
416 SymbolContext var_sc;
417 variable->CalculateSymbolContext(&var_sc);
418 module = var_sc.module_sp.get();
419 }
420 }
421
422 if (module) {
423 bool resolved = false;
424 ObjectFile *objfile = module->GetObjectFile();
425 if (objfile) {
426 Address so_addr(address, objfile->GetSectionList());
427 addr_t load_address =
428 so_addr.GetLoadAddress(exe_ctx->GetTargetPtr());
429 bool process_launched_and_stopped =
430 exe_ctx->GetProcessPtr()
432 true /* must_exist */)
433 : false;
434 // Don't use the load address if the process has exited.
435 if (load_address != LLDB_INVALID_ADDRESS &&
436 process_launched_and_stopped) {
437 resolved = true;
438 address = load_address;
439 address_type = eAddressTypeLoad;
440 data.SetByteOrder(
442 data.SetAddressByteSize(exe_ctx->GetTargetRef()
445 } else {
446 if (so_addr.IsSectionOffset()) {
447 resolved = true;
448 file_so_addr = so_addr;
449 data.SetByteOrder(objfile->GetByteOrder());
450 data.SetAddressByteSize(objfile->GetAddressByteSize());
451 }
452 }
453 }
454 if (!resolved) {
455 Variable *variable = GetVariable();
456
457 if (module) {
458 if (variable)
460 "unable to resolve the module for file address 0x%" PRIx64
461 " for variable '%s' in %s",
462 address, variable->GetName().AsCString(""),
463 module->GetFileSpec().GetPath().c_str());
464 else
466 "unable to resolve the module for file address 0x%" PRIx64
467 " in %s",
468 address, module->GetFileSpec().GetPath().c_str());
469 } else {
470 if (variable)
472 "unable to resolve the module for file address 0x%" PRIx64
473 " for variable '%s'",
474 address, variable->GetName().AsCString(""));
475 else
477 "unable to resolve the module for file address 0x%" PRIx64,
478 address);
479 }
480 }
481 } else {
482 // Can't convert a file address to anything valid without more
483 // context (which Module it came from)
485 "can't read memory from file address without more context");
486 }
487 }
488 }
489 break;
490
492 address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
493 address_type = eAddressTypeHost;
494 if (exe_ctx) {
495 if (Target *target = exe_ctx->GetTargetPtr()) {
496 ByteOrder byte_order = target->GetArchitecture().GetByteOrder();
497 // ValueObjectRegister stores structured register types in target byte
498 // order and all other register buffers in host byte order.
500 !llvm::isa_and_present<RegisterTypeComposite>(
501 GetRegisterInfo()->register_type))
502 byte_order = endian::InlHostByteOrder();
503 data.SetByteOrder(byte_order);
504 data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
505 break;
506 }
507 }
508 // fallback to host settings
510 data.SetAddressByteSize(sizeof(void *));
511 break;
512 }
513
514 // Bail if we encountered any errors
515 if (error.Fail())
516 return error;
517
518 if (address == LLDB_INVALID_ADDRESS) {
520 "invalid %s address",
521 address_type == eAddressTypeHost ? "host" : "load");
522 return error;
523 }
524
525 // If we got here, we need to read the value from memory.
526 size_t byte_size = GetValueByteSize(&error, exe_ctx);
527
528 // Bail if we encountered any errors getting the byte size.
529 if (error.Fail())
530 return error;
531
532 // No memory to read for zero-sized types.
533 if (byte_size == 0)
534 return error;
535
536 // Make sure we have enough room within "data", and if we don't make
537 // something large enough that does
538 if (!data.ValidOffsetForDataOfSize(0, byte_size)) {
539 auto data_sp = std::make_shared<DataBufferHeap>(byte_size, '\0');
540 data.SetData(data_sp);
541 }
542
543 uint8_t *dst = const_cast<uint8_t *>(data.PeekData(0, byte_size));
544 if (dst != nullptr) {
545 if (address_type == eAddressTypeHost) {
546 // The address is an address in this process, so just copy it.
547 if (address == 0) {
548 error =
549 Status::FromErrorString("trying to read from host address of 0.");
550 return error;
551 }
552 memcpy(dst, reinterpret_cast<uint8_t *>(address), byte_size);
553 } else if ((address_type == eAddressTypeLoad) ||
554 (address_type == eAddressTypeFile)) {
555 if (file_so_addr.IsValid()) {
556 const bool force_live_memory = true;
557 if (exe_ctx->GetTargetRef().ReadMemory(file_so_addr, dst, byte_size,
558 error, force_live_memory) !=
559 byte_size) {
561 "read memory from 0x%" PRIx64 " failed", (uint64_t)address);
562 }
563 } else {
564 // The execution context might have a NULL process, but it might have a
565 // valid process in the exe_ctx->target, so use the
566 // ExecutionContext::GetProcess accessor to ensure we get the process
567 // if there is one.
568 Process *process = exe_ctx->GetProcessPtr();
569
570 if (process) {
571 const size_t bytes_read =
572 process->ReadMemory(address, dst, byte_size, error);
573 if (bytes_read != byte_size)
575 "read memory from 0x%" PRIx64 " failed (%u of %u bytes read)",
576 (uint64_t)address, (uint32_t)bytes_read, (uint32_t)byte_size);
577 } else {
579 "read memory from 0x%" PRIx64 " failed (invalid process)",
580 (uint64_t)address);
581 }
582 }
583 } else {
585 "unsupported AddressType value (%i)", address_type);
586 }
587 } else {
588 error = Status::FromErrorString("out of memory");
589 }
590
591 return error;
592}
593
595 const CompilerType &compiler_type = GetCompilerType();
596 if (compiler_type.IsValid()) {
597 switch (m_value_type) {
599 case ValueType::Scalar: // raw scalar value
600 break;
601
603 case ValueType::LoadAddress: // load address value
604 case ValueType::HostAddress: // host address value (for memory in the process
605 // that is using liblldb)
606 {
607 DataExtractor data;
608 lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS);
609 Status error(GetValueAsData(exe_ctx, data, module));
610 if (error.Success()) {
611 Scalar scalar;
612 if (compiler_type.GetValueAsScalar(
613 data, 0, data.GetByteSize(), scalar,
614 exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)) {
615 m_value = scalar;
617 } else {
618 if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes()) {
619 m_value.Clear();
621 }
622 }
623 } else {
624 if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes()) {
625 m_value.Clear();
627 }
628 }
629 } break;
630 }
631 }
632 return m_value;
633}
634
637 return static_cast<Variable *>(m_context);
638 return nullptr;
639}
640
642 m_value.Clear();
643 m_compiler_type.Clear();
645 m_context = nullptr;
647 m_data_buffer.Clear();
648}
649
651 switch (value_type) {
653 return "invalid";
655 return "scalar";
657 return "file address";
659 return "load address";
661 return "host address";
662 };
663 llvm_unreachable("enum cases exhausted.");
664}
665
667 switch (context_type) {
669 return "invalid";
671 return "RegisterInfo *";
673 return "Type *";
675 return "Variable *";
676 };
677 llvm_unreachable("enum cases exhausted.");
678}
679
681 if (!module || !target || (GetValueType() != ValueType::FileAddress))
682 return;
683
685 if (file_addr == LLDB_INVALID_ADDRESS)
686 return;
687
688 Address so_addr;
689 if (!module->ResolveFileAddress(file_addr, so_addr))
690 return;
691 lldb::addr_t load_addr = so_addr.GetLoadAddress(target);
692 if (load_addr == LLDB_INVALID_ADDRESS)
693 return;
694
696 GetScalar() = load_addr;
697}
698
699void ValueList::PushValue(const Value &value) { m_values.push_back(value); }
700
701size_t ValueList::GetSize() { return m_values.size(); }
702
704 if (idx < GetSize()) {
705 return &(m_values[idx]);
706 } else
707 return nullptr;
708}
709
710void ValueList::Clear() { m_values.clear(); }
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG_ERRORV(log, error,...)
Definition Log.h:421
A section + offset based address class.
Definition Address.h:62
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition Address.cpp:303
bool IsValid() const
Check if the object state is valid.
Definition Address.h:355
bool IsSectionOffset() const
Check if an address is section offset.
Definition Address.h:342
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition ArchSpec.cpp:894
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition ArchSpec.cpp:943
Generic representation of a type in a programming language.
bool GetValueAsScalar(const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, Scalar &value, ExecutionContextScope *exe_scope) const
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
size_t GetPointerByteSize() const
AST related queries.
lldb::Format GetFormat() const
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
lldb::offset_t GetByteSize() const override
Get the number of bytes in the data buffer.
An data extractor class.
bool ValidOffsetForDataOfSize(lldb::offset_t offset, lldb::offset_t length) const
Test the availability of length bytes of data from offset.
void Clear()
Clears the object state.
virtual const uint8_t * PeekData(lldb::offset_t offset, lldb::offset_t length) const
Peek at a bytes at offset.
virtual uint64_t GetByteSize() const
Get the number of bytes contained in this object.
void SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
virtual lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
void SetAddressByteSize(uint32_t addr_size)
Set the address byte size.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
ExecutionContextScope * GetBestExecutionContextScope() const
Target * GetTargetPtr() const
Returns a pointer to the target object.
Target & GetTargetRef() const
Returns a reference to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:380
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:91
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
Definition Module.cpp:421
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition Module.h:447
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:46
virtual lldb::ByteOrder GetByteOrder() const =0
Gets whether endian swapping should occur when extracting data from this object file.
virtual uint32_t GetAddressByteSize() const =0
Gets the address size in bytes for the current object file.
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
A plug-in interface definition class for debugging a process.
Definition Process.h:369
virtual size_t ReadMemory(const ProcessAddress &process_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition Process.cpp:2114
lldb::StateType GetState()
Get accessor for the current process state.
Definition Process.cpp:1319
virtual bool IsAlive()
Check if a process is still alive.
Definition Process.cpp:1142
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1270
size_t GetByteSize() const
Definition Scalar.cpp:163
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition Scalar.cpp:366
size_t GetAsMemoryData(void *dst, size_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
Definition Scalar.cpp:791
An error handling class.
Definition Status.h:118
void Clear()
Clear the object state.
Definition Status.cpp:214
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:136
bool Success() const
Test for success condition.
Definition Status.cpp:303
A stream class that can stream formatted output to a file.
Definition Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
Defines a symbol context baton that can be handed other debug core functions.
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow, bool allow_section_end=false)
Definition Target.cpp:3521
virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len, Status &error, bool force_live_memory=false, lldb::addr_t *load_addr_ptr=nullptr, bool *did_read_live_memory=nullptr)
Definition Target.cpp:2126
const ArchSpec & GetArchitecture() const
Definition Target.h:1324
CompilerType GetForwardCompilerType()
void PushValue(const Value &value)
Definition Value.cpp:699
collection m_values
Definition Value.h:206
Value * GetValueAtIndex(size_t idx)
Definition Value.cpp:703
const Scalar & GetScalar() const
See comment on m_scalar to understand what GetScalar returns.
Definition Value.h:114
void AppendBytes(const void *bytes, int len)
Definition Value.cpp:97
Status GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data, Module *module)
Definition Value.cpp:324
RegisterInfo * GetRegisterInfo() const
Definition Value.cpp:143
ValueType
Type that describes Value::m_value.
Definition Value.h:42
@ HostAddress
A host address value (for memory in the process that < A is using liblldb).
Definition Value.h:53
@ FileAddress
A file address value.
Definition Value.h:48
@ LoadAddress
A load address value.
Definition Value.h:50
@ Scalar
A raw scalar value.
Definition Value.h:46
void Dump(Stream *strm)
Definition Value.cpp:103
static ValueType GetValueTypeFromAddressType(AddressType address_type)
Definition Value.cpp:129
ContextType m_context_type
Definition Value.h:184
Value & operator=(const Value &rhs)
Definition Value.cpp:71
size_t AppendDataToHostBuffer(const Value &rhs)
Definition Value.cpp:155
ValueType GetValueType() const
Definition Value.cpp:112
void SetCompilerType(const CompilerType &compiler_type)
Definition Value.cpp:277
DataBufferHeap m_data_buffer
Definition Value.h:185
lldb::Format GetValueDefaultFormat()
Definition Value.cpp:281
Scalar & ResolveValue(ExecutionContext *exe_ctx, Module *module=nullptr)
Definition Value.cpp:594
static const char * GetValueTypeAsCString(ValueType context_type)
Definition Value.cpp:650
DataBufferHeap & GetBuffer()
Definition Value.h:123
uint64_t GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx)
Definition Value.cpp:214
void SetValueType(ValueType value_type)
Definition Value.h:90
CompilerType m_compiler_type
Definition Value.h:181
ContextType
Type that describes Value::m_context.
Definition Value.h:57
@ Variable
lldb_private::Variable *.
Definition Value.h:66
@ RegisterInfo
RegisterInfo * (can be a scalar or a vector register).
Definition Value.h:62
@ LLDBType
lldb_private::Type *.
Definition Value.h:64
ValueType m_value_type
Definition Value.h:183
bool GetData(DataExtractor &data)
Definition Value.cpp:301
AddressType GetValueAddressType() const
Definition Value.cpp:114
const CompilerType & GetCompilerType()
Definition Value.cpp:248
static const char * GetContextTypeAsCString(ContextType context_type)
Definition Value.cpp:666
void ConvertToLoadAddress(Module *module, Target *target)
Convert this value's file address to a load address, if possible.
Definition Value.cpp:680
size_t ResizeData(size_t len)
Definition Value.cpp:193
void SetBytes(const void *bytes, int len)
Definition Value.cpp:91
bool ValueOf(ExecutionContext *exe_ctx)
Definition Value.cpp:200
Scalar m_value
Represents a value, which can be a scalar, a load address, a file address, or a host address.
Definition Value.h:180
Variable * GetVariable()
Definition Value.cpp:635
ConstString GetName() const
Definition Variable.cpp:83
void CalculateSymbolContext(SymbolContext *sc)
Definition Variable.cpp:220
uint8_t * GetBytes()
Get a pointer to the data.
Definition DataBuffer.h:108
#define LLDB_INVALID_ADDRESS
lldb::ByteOrder InlHostByteOrder()
Definition Endian.h:25
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:338
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
Definition State.cpp:89
@ eAddressTypeFile
Address is an address as found in an object or symbol file.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
@ eAddressTypeHost
Address is an address in the process that is running this code.
Format
Display format definitions.
ByteOrder
Byte ordering definitions.
uint64_t addr_t
Definition lldb-types.h:80
uint32_t byte_size
Size in bytes of the register.
lldb::Format format
Default display format.