1 //===-- DataExtractor.h -----------------------------------------*- 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 #ifndef liblldb_DataExtractor_h_ 11 #define liblldb_DataExtractor_h_ 12 #if defined (__cplusplus) 13 14 15 #include "lldb/lldb-private.h" 16 17 #include "llvm/ADT/SmallVector.h" 18 19 #include <limits.h> 20 #include <stdint.h> 21 #include <string.h> 22 #include <vector> 23 24 namespace lldb_private { 25 26 //---------------------------------------------------------------------- 27 /// @class DataExtractor DataExtractor.h "lldb/Core/DataExtractor.h" 28 /// @brief An data extractor class. 29 /// 30 /// DataExtractor is a class that can extract data (swapping if needed) 31 /// from a data buffer. The data buffer can be caller owned, or can be 32 /// shared data that can be shared between multiple DataExtractor 33 /// instances. Multiple DataExtractor objects can share the same data, 34 /// yet extract values in different address sizes and byte order modes. 35 /// Each object can have a unique position in the shared data and extract 36 /// data from different offsets. 37 /// 38 /// @see DataBuffer 39 //---------------------------------------------------------------------- 40 class DataExtractor 41 { 42 public: 43 //------------------------------------------------------------------ 44 /// @typedef DataExtractor::Type 45 /// @brief Type enumerations used in the dump routines. 46 /// @see DataExtractor::Dump() 47 /// @see DataExtractor::DumpRawHexBytes() 48 //------------------------------------------------------------------ 49 typedef enum 50 { 51 TypeUInt8, ///< Format output as unsigned 8 bit integers 52 TypeChar, ///< Format output as characters 53 TypeUInt16, ///< Format output as unsigned 16 bit integers 54 TypeUInt32, ///< Format output as unsigned 32 bit integers 55 TypeUInt64, ///< Format output as unsigned 64 bit integers 56 TypePointer, ///< Format output as pointers 57 TypeULEB128, ///< Format output as ULEB128 numbers 58 TypeSLEB128 ///< Format output as SLEB128 numbers 59 } Type; 60 61 static void 62 DumpHexBytes (Stream *s, 63 const void *src, 64 size_t src_len, 65 uint32_t bytes_per_line, 66 lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS to not show address at start of line 67 //------------------------------------------------------------------ 68 /// Default constructor. 69 /// 70 /// Initialize all members to a default empty state. 71 //------------------------------------------------------------------ 72 DataExtractor (); 73 74 //------------------------------------------------------------------ 75 /// Construct with a buffer that is owned by the caller. 76 /// 77 /// This constructor allows us to use data that is owned by the 78 /// caller. The data must stay around as long as this object is 79 /// valid. 80 /// 81 /// @param[in] data 82 /// A pointer to caller owned data. 83 /// 84 /// @param[in] data_length 85 /// The length in bytes of \a data. 86 /// 87 /// @param[in] byte_order 88 /// A byte order of the data that we are extracting from. 89 /// 90 /// @param[in] addr_size 91 /// A new address byte size value. 92 /// 93 /// @param[in] target_byte_size 94 /// A size of a target byte in 8-bit host bytes 95 //------------------------------------------------------------------ 96 DataExtractor (const void* data, lldb::offset_t data_length, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size = 1); 97 98 //------------------------------------------------------------------ 99 /// Construct with shared data. 100 /// 101 /// Copies the data shared pointer which adds a reference to the 102 /// contained in \a data_sp. The shared data reference is reference 103 /// counted to ensure the data lives as long as anyone still has a 104 /// valid shared pointer to the data in \a data_sp. 105 /// 106 /// @param[in] data_sp 107 /// A shared pointer to data. 108 /// 109 /// @param[in] byte_order 110 /// A byte order of the data that we are extracting from. 111 /// 112 /// @param[in] addr_size 113 /// A new address byte size value. 114 /// 115 /// @param[in] target_byte_size 116 /// A size of a target byte in 8-bit host bytes 117 //------------------------------------------------------------------ 118 DataExtractor (const lldb::DataBufferSP& data_sp, lldb::ByteOrder byte_order, uint32_t addr_size, uint32_t target_byte_size = 1); 119 120 //------------------------------------------------------------------ 121 /// Construct with a subset of \a data. 122 /// 123 /// Initialize this object with a subset of the data bytes in \a 124 /// data. If \a data contains shared data, then a reference to the 125 /// shared data will be added to ensure the shared data stays around 126 /// as long as any objects have references to the shared data. The 127 /// byte order value and the address size settings are copied from \a 128 /// data. If \a offset is not a valid offset in \a data, then no 129 /// reference to the shared data will be added. If there are not 130 /// \a length bytes available in \a data starting at \a offset, 131 /// the length will be truncated to contain as many bytes as 132 /// possible. 133 /// 134 /// @param[in] data 135 /// Another DataExtractor object that contains data. 136 /// 137 /// @param[in] offset 138 /// The offset into \a data at which the subset starts. 139 /// 140 /// @param[in] length 141 /// The length in bytes of the subset of data. 142 /// 143 /// @param[in] target_byte_size 144 /// A size of a target byte in 8-bit host bytes 145 //------------------------------------------------------------------ 146 DataExtractor (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length, uint32_t target_byte_size = 1); 147 148 DataExtractor (const DataExtractor& rhs); 149 //------------------------------------------------------------------ 150 /// Assignment operator. 151 /// 152 /// Copies all data, byte order and address size settings from \a rhs into 153 /// this object. If \a rhs contains shared data, a reference to that 154 /// shared data will be added. 155 /// 156 /// @param[in] rhs 157 /// Another DataExtractor object to copy. 158 /// 159 /// @return 160 /// A const reference to this object. 161 //------------------------------------------------------------------ 162 const DataExtractor& 163 operator= (const DataExtractor& rhs); 164 165 //------------------------------------------------------------------ 166 /// Destructor 167 /// 168 /// If this object contains a valid shared data reference, the 169 /// reference count on the data will be decremented, and if zero, 170 /// the data will be freed. 171 //------------------------------------------------------------------ 172 ~DataExtractor (); 173 174 //------------------------------------------------------------------ 175 /// Clears the object state. 176 /// 177 /// Clears the object contents back to a default invalid state, and 178 /// release any references to shared data that this object may 179 /// contain. 180 //------------------------------------------------------------------ 181 void 182 Clear (); 183 184 //------------------------------------------------------------------ 185 /// Dumps the binary data as \a type objects to stream \a s (or to 186 /// Log() if \a s is NULL) starting \a offset bytes into the data 187 /// and stopping after dumping \a length bytes. The offset into the 188 /// data is displayed at the beginning of each line and can be 189 /// offset by base address \a base_addr. \a num_per_line objects 190 /// will be displayed on each line. 191 /// 192 /// @param[in] s 193 /// The stream to dump the output to. If NULL the output will 194 /// be dumped to Log(). 195 /// 196 /// @param[in] offset 197 /// The offset into the data at which to start dumping. 198 /// 199 /// @param[in] length 200 /// The number of bytes to dump. 201 /// 202 /// @param[in] base_addr 203 /// The base address that gets added to the offset displayed on 204 /// each line. 205 /// 206 /// @param[in] num_per_line 207 /// The number of \a type objects to display on each line. 208 /// 209 /// @param[in] type 210 /// The type of objects to use when dumping data from this 211 /// object. See DataExtractor::Type. 212 /// 213 /// @param[in] type_format 214 /// The optional format to use for the \a type objects. If this 215 /// is NULL, the default format for the \a type will be used. 216 /// 217 /// @return 218 /// The offset at which dumping ended. 219 //------------------------------------------------------------------ 220 lldb::offset_t 221 PutToLog (Log *log, 222 lldb::offset_t offset, 223 lldb::offset_t length, 224 uint64_t base_addr, 225 uint32_t num_per_line, 226 Type type, 227 const char *type_format = NULL) const; 228 229 //------------------------------------------------------------------ 230 /// Dumps \a item_count objects into the stream \a s. 231 /// 232 /// Dumps \a item_count objects using \a item_format, each of which 233 /// are \a item_byte_size bytes long starting at offset \a offset 234 /// bytes into the contained data, into the stream \a s. \a 235 /// num_per_line objects will be dumped on each line before a new 236 /// line will be output. If \a base_addr is a valid address, then 237 /// each new line of output will be preceded by the address value 238 /// plus appropriate offset, and a colon and space. Bitfield values 239 /// can be dumped by calling this function multiple times with the 240 /// same start offset, format and size, yet differing \a 241 /// item_bit_size and \a item_bit_offset values. 242 /// 243 /// @param[in] s 244 /// The stream to dump the output to. This value can not be NULL. 245 /// 246 /// @param[in] offset 247 /// The offset into the data at which to start dumping. 248 /// 249 /// @param[in] item_format 250 /// The format to use when dumping each item. 251 /// 252 /// @param[in] item_byte_size 253 /// The byte size of each item. 254 /// 255 /// @param[in] item_count 256 /// The number of items to dump. 257 /// 258 /// @param[in] num_per_line 259 /// The number of items to display on each line. 260 /// 261 /// @param[in] base_addr 262 /// The base address that gets added to the offset displayed on 263 /// each line if the value is valid. Is \a base_addr is 264 /// LLDB_INVALID_ADDRESS then no address values will be prepended 265 /// to any lines. 266 /// 267 /// @param[in] item_bit_size 268 /// If the value to display is a bitfield, this value should 269 /// be the number of bits that the bitfield item has within the 270 /// item's byte size value. This function will need to be called 271 /// multiple times with identical \a offset and \a item_byte_size 272 /// values in order to display multiple bitfield values that 273 /// exist within the same integer value. If the items being 274 /// displayed are not bitfields, this value should be zero. 275 /// 276 /// @param[in] item_bit_offset 277 /// If the value to display is a bitfield, this value should 278 /// be the offset in bits, or shift right amount, that the 279 /// bitfield item occupies within the item's byte size value. 280 /// This function will need to be called multiple times with 281 /// identical \a offset and \a item_byte_size values in order 282 /// to display multiple bitfield values that exist within the 283 /// same integer value. If the items being displayed are not 284 /// bitfields, this value should be zero. 285 /// 286 /// @return 287 /// The offset at which dumping ended. 288 //------------------------------------------------------------------ 289 lldb::offset_t 290 Dump (Stream *s, 291 lldb::offset_t offset, 292 lldb::Format item_format, 293 size_t item_byte_size, 294 size_t item_count, 295 size_t num_per_line, 296 uint64_t base_addr, 297 uint32_t item_bit_size, 298 uint32_t item_bit_offset, 299 ExecutionContextScope *exe_scope = NULL) const; 300 301 //------------------------------------------------------------------ 302 /// Dump a UUID value at \a offset. 303 /// 304 /// Dump a UUID starting at \a offset bytes into this object's data. 305 /// If the stream \a s is NULL, the output will be sent to Log(). 306 /// 307 /// @param[in] s 308 /// The stream to dump the output to. If NULL the output will 309 /// be dumped to Log(). 310 /// 311 /// @param[in] offset 312 /// The offset into the data at which to extract and dump a 313 /// UUID value. 314 //------------------------------------------------------------------ 315 void 316 DumpUUID (Stream *s, lldb::offset_t offset) const; 317 318 //------------------------------------------------------------------ 319 /// Extract an arbitrary number of bytes in the specified byte 320 /// order. 321 /// 322 /// Attemps to extract \a length bytes starting at \a offset bytes 323 /// into this data in the requested byte order (\a dst_byte_order) 324 /// and place the results in \a dst. \a dst must be at least \a 325 /// length bytes long. 326 /// 327 /// @param[in] offset 328 /// The offset in bytes into the contained data at which to 329 /// start extracting. 330 /// 331 /// @param[in] length 332 /// The number of bytes to extract. 333 /// 334 /// @param[in] dst_byte_order 335 /// A byte order of the data that we want when the value in 336 /// copied to \a dst. 337 /// 338 /// @param[out] dst 339 /// The buffer that will receive the extracted value if there 340 /// are enough bytes available in the current data. 341 /// 342 /// @return 343 /// The number of bytes that were extracted which will be \a 344 /// length when the value is successfully extracted, or zero 345 /// if there aren't enough bytes at the specified offset. 346 //------------------------------------------------------------------ 347 size_t 348 ExtractBytes (lldb::offset_t offset, lldb::offset_t length, lldb::ByteOrder dst_byte_order, void *dst) const; 349 350 //------------------------------------------------------------------ 351 /// Extract an address from \a *offset_ptr. 352 /// 353 /// Extract a single address from the data and update the offset 354 /// pointed to by \a offset_ptr. The size of the extracted address 355 /// comes from the \a m_addr_size member variable and should be 356 /// set correctly prior to extracting any address values. 357 /// 358 /// @param[in,out] offset_ptr 359 /// A pointer to an offset within the data that will be advanced 360 /// by the appropriate number of bytes if the value is extracted 361 /// correctly. If the offset is out of bounds or there are not 362 /// enough bytes to extract this value, the offset will be left 363 /// unmodified. 364 /// 365 /// @return 366 /// The extracted address value. 367 //------------------------------------------------------------------ 368 uint64_t 369 GetAddress (lldb::offset_t *offset_ptr) const; 370 371 uint64_t 372 GetAddress_unchecked (lldb::offset_t *offset_ptr) const; 373 374 //------------------------------------------------------------------ 375 /// Get the current address size. 376 /// 377 /// Return the size in bytes of any address values this object will 378 /// extract. 379 /// 380 /// @return 381 /// The size in bytes of address values that will be extracted. 382 //------------------------------------------------------------------ 383 uint32_t GetAddressByteSize()384 GetAddressByteSize () const 385 { 386 return m_addr_size; 387 } 388 389 //------------------------------------------------------------------ 390 /// Get the number of bytes contained in this object. 391 /// 392 /// @return 393 /// The total number of bytes of data this object refers to. 394 //------------------------------------------------------------------ 395 uint64_t GetByteSize()396 GetByteSize () const 397 { 398 return m_end - m_start; 399 } 400 401 //------------------------------------------------------------------ 402 /// Extract a C string from \a *offset_ptr. 403 /// 404 /// Returns a pointer to a C String from the data at the offset 405 /// pointed to by \a offset_ptr. A variable length NULL terminated C 406 /// string will be extracted and the \a offset_ptr will be 407 /// updated with the offset of the byte that follows the NULL 408 /// terminator byte. 409 /// 410 /// @param[in,out] offset_ptr 411 /// A pointer to an offset within the data that will be advanced 412 /// by the appropriate number of bytes if the value is extracted 413 /// correctly. If the offset is out of bounds or there are not 414 /// enough bytes to extract this value, the offset will be left 415 /// unmodified. 416 /// 417 /// @return 418 /// A pointer to the C string value in the data. If the offset 419 /// pointed to by \a offset_ptr is out of bounds, or if the 420 /// offset plus the length of the C string is out of bounds, 421 /// NULL will be returned. 422 //------------------------------------------------------------------ 423 const char * 424 GetCStr (lldb::offset_t *offset_ptr) const; 425 426 //------------------------------------------------------------------ 427 /// Extract a C string from \a *offset_ptr with field size \a len. 428 /// 429 /// Returns a pointer to a C String from the data at the offset 430 /// pointed to by \a offset_ptr, with a field length of \a len. 431 /// A NULL terminated C string will be extracted and the \a offset_ptr 432 /// will be updated with the offset of the byte that follows the fixed 433 /// length field. 434 /// 435 /// @param[in,out] offset_ptr 436 /// A pointer to an offset within the data that will be advanced 437 /// by the appropriate number of bytes if the value is extracted 438 /// correctly. If the offset is out of bounds or there are not 439 /// enough bytes to extract this value, the offset will be left 440 /// unmodified. 441 /// 442 /// @return 443 /// A pointer to the C string value in the data. If the offset 444 /// pointed to by \a offset_ptr is out of bounds, or if the 445 /// offset plus the length of the field is out of bounds, or if 446 /// the field does not contain a NULL terminator byte, NULL will 447 /// be returned. 448 const char * 449 GetCStr (lldb::offset_t *offset_ptr, lldb::offset_t len) const; 450 451 //------------------------------------------------------------------ 452 /// Extract \a length bytes from \a *offset_ptr. 453 /// 454 /// Returns a pointer to a bytes in this object's data at the offset 455 /// pointed to by \a offset_ptr. If \a length is zero or too large, 456 /// then the offset pointed to by \a offset_ptr will not be updated 457 /// and NULL will be returned. 458 /// 459 /// @param[in,out] offset_ptr 460 /// A pointer to an offset within the data that will be advanced 461 /// by the appropriate number of bytes if the value is extracted 462 /// correctly. If the offset is out of bounds or there are not 463 /// enough bytes to extract this value, the offset will be left 464 /// unmodified. 465 /// 466 /// @param[in] length 467 /// The optional length of a string to extract. If the value is 468 /// zero, a NULL terminated C string will be extracted. 469 /// 470 /// @return 471 /// A pointer to the bytes in this object's data if the offset 472 /// and length are valid, or NULL otherwise. 473 //------------------------------------------------------------------ 474 const void* GetData(lldb::offset_t * offset_ptr,lldb::offset_t length)475 GetData (lldb::offset_t *offset_ptr, lldb::offset_t length) const 476 { 477 const uint8_t *ptr = PeekData (*offset_ptr, length); 478 if (ptr) 479 *offset_ptr += length; 480 return ptr; 481 } 482 483 //------------------------------------------------------------------ 484 /// Copy \a length bytes from \a *offset, without swapping bytes. 485 /// 486 /// @param[in] offset 487 /// The offset into this data from which to start copying 488 /// 489 /// @param[in] length 490 /// The length of the data to copy from this object 491 /// 492 /// @param[out] dst 493 /// The buffer to place the output data. 494 /// 495 /// @return 496 /// Returns the number of bytes that were copied, or zero if 497 /// anything goes wrong. 498 //------------------------------------------------------------------ 499 lldb::offset_t 500 CopyData (lldb::offset_t offset, 501 lldb::offset_t length, 502 void *dst) const; 503 504 //------------------------------------------------------------------ 505 /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied 506 /// data is treated as a value that can be swapped to match the 507 /// specified byte order. 508 /// 509 /// For values that are larger than the supported integer sizes, 510 /// this function can be used to extract data in a specified byte 511 /// order. It can also be used to copy a smaller integer value from 512 /// to a larger value. The extra bytes left over will be padded 513 /// correctly according to the byte order of this object and the 514 /// \a dst_byte_order. This can be very handy when say copying a 515 /// partial data value into a register. 516 /// 517 /// @param[in] src_offset 518 /// The offset into this data from which to start copying an 519 /// endian entity 520 /// 521 /// @param[in] src_len 522 /// The length of the endian data to copy from this object 523 /// into the \a dst object 524 /// 525 /// @param[out] dst 526 /// The buffer where to place the endian data. The data might 527 /// need to be byte swapped (and appropriately padded with 528 /// zeroes if \a src_len != \a dst_len) if \a dst_byte_order 529 /// does not match the byte order in this object. 530 /// 531 /// @param[in] dst_len 532 /// The length number of bytes that the endian value will 533 /// occupy is \a dst. 534 /// 535 /// @param[in] byte_order 536 /// The byte order that the endian value should be in the \a dst 537 /// buffer. 538 /// 539 /// @return 540 /// Returns the number of bytes that were copied, or zero if 541 /// anything goes wrong. 542 //------------------------------------------------------------------ 543 lldb::offset_t 544 CopyByteOrderedData (lldb::offset_t src_offset, 545 lldb::offset_t src_len, 546 void *dst, 547 lldb::offset_t dst_len, 548 lldb::ByteOrder dst_byte_order) const; 549 550 //------------------------------------------------------------------ 551 /// Get the data end pointer. 552 /// 553 /// @return 554 /// Returns a pointer to the next byte contained in this 555 /// object's data, or NULL of there is no data in this object. 556 //------------------------------------------------------------------ 557 const uint8_t * GetDataEnd()558 GetDataEnd () const 559 { 560 return m_end; 561 } 562 563 //------------------------------------------------------------------ 564 /// Get the shared data offset. 565 /// 566 /// Get the offset of the first byte of data in the shared data (if 567 /// any). 568 /// 569 /// @return 570 /// If this object contains shared data, this function returns 571 /// the offset in bytes into that shared data, zero otherwise. 572 //------------------------------------------------------------------ 573 size_t 574 GetSharedDataOffset () const; 575 576 //------------------------------------------------------------------ 577 /// Get the data start pointer. 578 /// 579 /// @return 580 /// Returns a pointer to the first byte contained in this 581 /// object's data, or NULL of there is no data in this object. 582 //------------------------------------------------------------------ 583 const uint8_t * GetDataStart()584 GetDataStart () const 585 { 586 return m_start; 587 } 588 589 590 //------------------------------------------------------------------ 591 /// Extract a float from \a *offset_ptr. 592 /// 593 /// Extract a single float value. 594 /// 595 /// @param[in,out] offset_ptr 596 /// A pointer to an offset within the data that will be advanced 597 /// by the appropriate number of bytes if the value is extracted 598 /// correctly. If the offset is out of bounds or there are not 599 /// enough bytes to extract this value, the offset will be left 600 /// unmodified. 601 /// 602 /// @return 603 /// The floating value that was extracted, or zero on failure. 604 //------------------------------------------------------------------ 605 float 606 GetFloat (lldb::offset_t *offset_ptr) const; 607 608 double 609 GetDouble (lldb::offset_t *offset_ptr) const; 610 611 long double 612 GetLongDouble (lldb::offset_t *offset_ptr) const; 613 614 //------------------------------------------------------------------ 615 /// Extract a GNU encoded pointer value from \a *offset_ptr. 616 /// 617 /// @param[in,out] offset_ptr 618 /// A pointer to an offset within the data that will be advanced 619 /// by the appropriate number of bytes if the value is extracted 620 /// correctly. If the offset is out of bounds or there are not 621 /// enough bytes to extract this value, the offset will be left 622 /// unmodified. 623 /// 624 /// @param[in] eh_ptr_enc 625 /// The GNU pointer encoding type. 626 /// 627 /// @param[in] pc_rel_addr 628 /// The PC relative address to use when the encoding is 629 /// \c DW_GNU_EH_PE_pcrel. 630 /// 631 /// @param[in] text_addr 632 /// The text (code) relative address to use when the encoding is 633 /// \c DW_GNU_EH_PE_textrel. 634 /// 635 /// @param[in] data_addr 636 /// The data relative address to use when the encoding is 637 /// \c DW_GNU_EH_PE_datarel. 638 /// 639 /// @return 640 /// The extracted GNU encoded pointer value. 641 //------------------------------------------------------------------ 642 uint64_t 643 GetGNUEHPointer (lldb::offset_t *offset_ptr, 644 uint32_t eh_ptr_enc, 645 lldb::addr_t pc_rel_addr, 646 lldb::addr_t text_addr, 647 lldb::addr_t data_addr); 648 649 //------------------------------------------------------------------ 650 /// Extract an integer of size \a byte_size from \a *offset_ptr. 651 /// 652 /// Extract a single integer value and update the offset pointed to 653 /// by \a offset_ptr. The size of the extracted integer is specified 654 /// by the \a byte_size argument. \a byte_size should have a value 655 /// >= 1 and <= 4 since the return value is only 32 bits wide. Any 656 /// \a byte_size values less than 1 or greater than 4 will result in 657 /// nothing being extracted, and zero being returned. 658 /// 659 /// @param[in,out] offset_ptr 660 /// A pointer to an offset within the data that will be advanced 661 /// by the appropriate number of bytes if the value is extracted 662 /// correctly. If the offset is out of bounds or there are not 663 /// enough bytes to extract this value, the offset will be left 664 /// unmodified. 665 /// 666 /// @param[in] byte_size 667 /// The size in byte of the integer to extract. 668 /// 669 /// @return 670 /// The integer value that was extracted, or zero on failure. 671 //------------------------------------------------------------------ 672 uint32_t 673 GetMaxU32 (lldb::offset_t *offset_ptr, size_t byte_size) const; 674 675 //------------------------------------------------------------------ 676 /// Extract an unsigned integer of size \a byte_size from \a 677 /// *offset_ptr. 678 /// 679 /// Extract a single unsigned integer value and update the offset 680 /// pointed to by \a offset_ptr. The size of the extracted integer 681 /// is specified by the \a byte_size argument. \a byte_size should 682 /// have a value greater than or equal to one and less than or equal 683 /// to eight since the return value is 64 bits wide. Any 684 /// \a byte_size values less than 1 or greater than 8 will result in 685 /// nothing being extracted, and zero being returned. 686 /// 687 /// @param[in,out] offset_ptr 688 /// A pointer to an offset within the data that will be advanced 689 /// by the appropriate number of bytes if the value is extracted 690 /// correctly. If the offset is out of bounds or there are not 691 /// enough bytes to extract this value, the offset will be left 692 /// unmodified. 693 /// 694 /// @param[in] byte_size 695 /// The size in byte of the integer to extract. 696 /// 697 /// @return 698 /// The unsigned integer value that was extracted, or zero on 699 /// failure. 700 //------------------------------------------------------------------ 701 uint64_t 702 GetMaxU64 (lldb::offset_t *offset_ptr, size_t byte_size) const; 703 704 uint64_t 705 GetMaxU64_unchecked (lldb::offset_t *offset_ptr, size_t byte_size) const; 706 707 //------------------------------------------------------------------ 708 /// Extract an signed integer of size \a byte_size from \a *offset_ptr. 709 /// 710 /// Extract a single signed integer value (sign extending if required) 711 /// and update the offset pointed to by \a offset_ptr. The size of 712 /// the extracted integer is specified by the \a byte_size argument. 713 /// \a byte_size should have a value greater than or equal to one 714 /// and less than or equal to eight since the return value is 64 715 /// bits wide. Any \a byte_size values less than 1 or greater than 716 /// 8 will result in nothing being extracted, and zero being returned. 717 /// 718 /// @param[in,out] offset_ptr 719 /// A pointer to an offset within the data that will be advanced 720 /// by the appropriate number of bytes if the value is extracted 721 /// correctly. If the offset is out of bounds or there are not 722 /// enough bytes to extract this value, the offset will be left 723 /// unmodified. 724 /// 725 /// @param[in] byte_size 726 /// The size in byte of the integer to extract. 727 /// 728 /// @return 729 /// The sign extended signed integer value that was extracted, 730 /// or zero on failure. 731 //------------------------------------------------------------------ 732 int64_t 733 GetMaxS64 (lldb::offset_t *offset_ptr, size_t size) const; 734 735 //------------------------------------------------------------------ 736 /// Extract an unsigned integer of size \a byte_size from \a 737 /// *offset_ptr, then extract the bitfield from this value if 738 /// \a bitfield_bit_size is non-zero. 739 /// 740 /// Extract a single unsigned integer value and update the offset 741 /// pointed to by \a offset_ptr. The size of the extracted integer 742 /// is specified by the \a byte_size argument. \a byte_size should 743 /// have a value greater than or equal to one and less than or equal 744 /// to 8 since the return value is 64 bits wide. Any 745 /// \a byte_size values less than 1 or greater than 8 will result in 746 /// nothing being extracted, and zero being returned. 747 /// 748 /// @param[in,out] offset_ptr 749 /// A pointer to an offset within the data that will be advanced 750 /// by the appropriate number of bytes if the value is extracted 751 /// correctly. If the offset is out of bounds or there are not 752 /// enough bytes to extract this value, the offset will be left 753 /// unmodified. 754 /// 755 /// @param[in] byte_size 756 /// The size in byte of the integer to extract. 757 /// 758 /// @param[in] bitfield_bit_size 759 /// The size in bits of the bitfield value to extract, or zero 760 /// to just extract the entire integer value. 761 /// 762 /// @param[in] bitfield_bit_offset 763 /// The bit offset of the bitfield value in the extracted 764 /// integer (the number of bits to shift the integer to the 765 /// right). 766 /// 767 /// @return 768 /// The unsigned bitfield integer value that was extracted, or 769 /// zero on failure. 770 //------------------------------------------------------------------ 771 uint64_t 772 GetMaxU64Bitfield (lldb::offset_t *offset_ptr, 773 size_t size, 774 uint32_t bitfield_bit_size, 775 uint32_t bitfield_bit_offset) const; 776 777 //------------------------------------------------------------------ 778 /// Extract an signed integer of size \a byte_size from \a 779 /// *offset_ptr, then extract and signe extend the bitfield from 780 /// this value if \a bitfield_bit_size is non-zero. 781 /// 782 /// Extract a single signed integer value (sign extending if required) 783 /// and update the offset pointed to by \a offset_ptr. The size of 784 /// the extracted integer is specified by the \a byte_size argument. 785 /// \a byte_size should have a value greater than or equal to one 786 /// and less than or equal to eight since the return value is 64 787 /// bits wide. Any \a byte_size values less than 1 or greater than 788 /// 8 will result in nothing being extracted, and zero being returned. 789 /// 790 /// @param[in,out] offset_ptr 791 /// A pointer to an offset within the data that will be advanced 792 /// by the appropriate number of bytes if the value is extracted 793 /// correctly. If the offset is out of bounds or there are not 794 /// enough bytes to extract this value, the offset will be left 795 /// unmodified. 796 /// 797 /// @param[in] byte_size 798 /// The size in bytes of the integer to extract. 799 /// 800 /// @param[in] bitfield_bit_size 801 /// The size in bits of the bitfield value to extract, or zero 802 /// to just extract the entire integer value. 803 /// 804 /// @param[in] bitfield_bit_offset 805 /// The bit offset of the bitfield value in the extracted 806 /// integer (the number of bits to shift the integer to the 807 /// right). 808 /// 809 /// @return 810 /// The signed bitfield integer value that was extracted, or 811 /// zero on failure. 812 //------------------------------------------------------------------ 813 int64_t 814 GetMaxS64Bitfield (lldb::offset_t *offset_ptr, 815 size_t size, 816 uint32_t bitfield_bit_size, 817 uint32_t bitfield_bit_offset) const; 818 819 //------------------------------------------------------------------ 820 /// Extract an pointer from \a *offset_ptr. 821 /// 822 /// Extract a single pointer from the data and update the offset 823 /// pointed to by \a offset_ptr. The size of the extracted pointer 824 /// comes from the \a m_addr_size member variable and should be 825 /// set correctly prior to extracting any pointer values. 826 /// 827 /// @param[in,out] offset_ptr 828 /// A pointer to an offset within the data that will be advanced 829 /// by the appropriate number of bytes if the value is extracted 830 /// correctly. If the offset is out of bounds or there are not 831 /// enough bytes to extract this value, the offset will be left 832 /// unmodified. 833 /// 834 /// @return 835 /// The extracted pointer value as a 64 integer. 836 //------------------------------------------------------------------ 837 uint64_t 838 GetPointer (lldb::offset_t *offset_ptr) const; 839 840 //------------------------------------------------------------------ 841 /// Get the current byte order value. 842 /// 843 /// @return 844 /// The current byte order value from this object's internal 845 /// state. 846 //------------------------------------------------------------------ 847 lldb::ByteOrder GetByteOrder()848 GetByteOrder() const 849 { 850 return m_byte_order; 851 } 852 853 //------------------------------------------------------------------ 854 /// Extract a uint8_t value from \a *offset_ptr. 855 /// 856 /// Extract a single uint8_t from the binary data at the offset 857 /// pointed to by \a offset_ptr, and advance the offset on success. 858 /// 859 /// @param[in,out] offset_ptr 860 /// A pointer to an offset within the data that will be advanced 861 /// by the appropriate number of bytes if the value is extracted 862 /// correctly. If the offset is out of bounds or there are not 863 /// enough bytes to extract this value, the offset will be left 864 /// unmodified. 865 /// 866 /// @return 867 /// The extracted uint8_t value. 868 //------------------------------------------------------------------ 869 uint8_t 870 GetU8 ( lldb::offset_t *offset_ptr) const; 871 872 uint8_t GetU8_unchecked(lldb::offset_t * offset_ptr)873 GetU8_unchecked (lldb::offset_t *offset_ptr) const 874 { 875 uint8_t val = m_start[*offset_ptr]; 876 *offset_ptr += 1; 877 return val; 878 } 879 880 uint16_t 881 GetU16_unchecked (lldb::offset_t *offset_ptr) const; 882 883 uint32_t 884 GetU32_unchecked (lldb::offset_t *offset_ptr) const; 885 886 uint64_t 887 GetU64_unchecked (lldb::offset_t *offset_ptr) const; 888 //------------------------------------------------------------------ 889 /// Extract \a count uint8_t values from \a *offset_ptr. 890 /// 891 /// Extract \a count uint8_t values from the binary data at the 892 /// offset pointed to by \a offset_ptr, and advance the offset on 893 /// success. The extracted values are copied into \a dst. 894 /// 895 /// @param[in,out] offset_ptr 896 /// A pointer to an offset within the data that will be advanced 897 /// by the appropriate number of bytes if the value is extracted 898 /// correctly. If the offset is out of bounds or there are not 899 /// enough bytes to extract this value, the offset will be left 900 /// unmodified. 901 /// 902 /// @param[out] dst 903 /// A buffer to copy \a count uint8_t values into. \a dst must 904 /// be large enough to hold all requested data. 905 /// 906 /// @param[in] count 907 /// The number of uint8_t values to extract. 908 /// 909 /// @return 910 /// \a dst if all values were properly extracted and copied, 911 /// NULL otherwise. 912 //------------------------------------------------------------------ 913 void * 914 GetU8 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; 915 916 //------------------------------------------------------------------ 917 /// Extract a uint16_t value from \a *offset_ptr. 918 /// 919 /// Extract a single uint16_t from the binary data at the offset 920 /// pointed to by \a offset_ptr, and update the offset on success. 921 /// 922 /// @param[in,out] offset_ptr 923 /// A pointer to an offset within the data that will be advanced 924 /// by the appropriate number of bytes if the value is extracted 925 /// correctly. If the offset is out of bounds or there are not 926 /// enough bytes to extract this value, the offset will be left 927 /// unmodified. 928 /// 929 /// @return 930 /// The extracted uint16_t value. 931 //------------------------------------------------------------------ 932 uint16_t 933 GetU16 (lldb::offset_t *offset_ptr) const; 934 935 //------------------------------------------------------------------ 936 /// Extract \a count uint16_t values from \a *offset_ptr. 937 /// 938 /// Extract \a count uint16_t values from the binary data at the 939 /// offset pointed to by \a offset_ptr, and advance the offset on 940 /// success. The extracted values are copied into \a dst. 941 /// 942 /// @param[in,out] offset_ptr 943 /// A pointer to an offset within the data that will be advanced 944 /// by the appropriate number of bytes if the value is extracted 945 /// correctly. If the offset is out of bounds or there are not 946 /// enough bytes to extract this value, the offset will be left 947 /// unmodified. 948 /// 949 /// @param[out] dst 950 /// A buffer to copy \a count uint16_t values into. \a dst must 951 /// be large enough to hold all requested data. 952 /// 953 /// @param[in] count 954 /// The number of uint16_t values to extract. 955 /// 956 /// @return 957 /// \a dst if all values were properly extracted and copied, 958 /// NULL otherwise. 959 //------------------------------------------------------------------ 960 void * 961 GetU16 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; 962 963 //------------------------------------------------------------------ 964 /// Extract a uint32_t value from \a *offset_ptr. 965 /// 966 /// Extract a single uint32_t from the binary data at the offset 967 /// pointed to by \a offset_ptr, and update the offset on success. 968 /// 969 /// @param[in,out] offset_ptr 970 /// A pointer to an offset within the data that will be advanced 971 /// by the appropriate number of bytes if the value is extracted 972 /// correctly. If the offset is out of bounds or there are not 973 /// enough bytes to extract this value, the offset will be left 974 /// unmodified. 975 /// 976 /// @return 977 /// The extracted uint32_t value. 978 //------------------------------------------------------------------ 979 uint32_t 980 GetU32 (lldb::offset_t *offset_ptr) const; 981 982 //------------------------------------------------------------------ 983 /// Extract \a count uint32_t values from \a *offset_ptr. 984 /// 985 /// Extract \a count uint32_t values from the binary data at the 986 /// offset pointed to by \a offset_ptr, and advance the offset on 987 /// success. The extracted values are copied into \a dst. 988 /// 989 /// @param[in,out] offset_ptr 990 /// A pointer to an offset within the data that will be advanced 991 /// by the appropriate number of bytes if the value is extracted 992 /// correctly. If the offset is out of bounds or there are not 993 /// enough bytes to extract this value, the offset will be left 994 /// unmodified. 995 /// 996 /// @param[out] dst 997 /// A buffer to copy \a count uint32_t values into. \a dst must 998 /// be large enough to hold all requested data. 999 /// 1000 /// @param[in] count 1001 /// The number of uint32_t values to extract. 1002 /// 1003 /// @return 1004 /// \a dst if all values were properly extracted and copied, 1005 /// NULL otherwise. 1006 //------------------------------------------------------------------ 1007 void * 1008 GetU32 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; 1009 1010 //------------------------------------------------------------------ 1011 /// Extract a uint64_t value from \a *offset_ptr. 1012 /// 1013 /// Extract a single uint64_t from the binary data at the offset 1014 /// pointed to by \a offset_ptr, and update the offset on success. 1015 /// 1016 /// @param[in,out] offset_ptr 1017 /// A pointer to an offset within the data that will be advanced 1018 /// by the appropriate number of bytes if the value is extracted 1019 /// correctly. If the offset is out of bounds or there are not 1020 /// enough bytes to extract this value, the offset will be left 1021 /// unmodified. 1022 /// 1023 /// @return 1024 /// The extracted uint64_t value. 1025 //------------------------------------------------------------------ 1026 uint64_t 1027 GetU64 (lldb::offset_t *offset_ptr) const; 1028 1029 //------------------------------------------------------------------ 1030 /// Extract \a count uint64_t values from \a *offset_ptr. 1031 /// 1032 /// Extract \a count uint64_t values from the binary data at the 1033 /// offset pointed to by \a offset_ptr, and advance the offset on 1034 /// success. The extracted values are copied into \a dst. 1035 /// 1036 /// @param[in,out] offset_ptr 1037 /// A pointer to an offset within the data that will be advanced 1038 /// by the appropriate number of bytes if the value is extracted 1039 /// correctly. If the offset is out of bounds or there are not 1040 /// enough bytes to extract this value, the offset will be left 1041 /// unmodified. 1042 /// 1043 /// @param[out] dst 1044 /// A buffer to copy \a count uint64_t values into. \a dst must 1045 /// be large enough to hold all requested data. 1046 /// 1047 /// @param[in] count 1048 /// The number of uint64_t values to extract. 1049 /// 1050 /// @return 1051 /// \a dst if all values were properly extracted and copied, 1052 /// NULL otherwise. 1053 //------------------------------------------------------------------ 1054 void * 1055 GetU64 ( lldb::offset_t *offset_ptr, void *dst, uint32_t count) const; 1056 1057 //------------------------------------------------------------------ 1058 /// Extract a signed LEB128 value from \a *offset_ptr. 1059 /// 1060 /// Extracts an signed LEB128 number from this object's data 1061 /// starting at the offset pointed to by \a offset_ptr. The offset 1062 /// pointed to by \a offset_ptr will be updated with the offset of 1063 /// the byte following the last extracted byte. 1064 /// 1065 /// @param[in,out] offset_ptr 1066 /// A pointer to an offset within the data that will be advanced 1067 /// by the appropriate number of bytes if the value is extracted 1068 /// correctly. If the offset is out of bounds or there are not 1069 /// enough bytes to extract this value, the offset will be left 1070 /// unmodified. 1071 /// 1072 /// @return 1073 /// The extracted signed integer value. 1074 //------------------------------------------------------------------ 1075 int64_t 1076 GetSLEB128 (lldb::offset_t *offset_ptr) const; 1077 1078 //------------------------------------------------------------------ 1079 /// Extract a unsigned LEB128 value from \a *offset_ptr. 1080 /// 1081 /// Extracts an unsigned LEB128 number from this object's data 1082 /// starting at the offset pointed to by \a offset_ptr. The offset 1083 /// pointed to by \a offset_ptr will be updated with the offset of 1084 /// the byte following the last extracted byte. 1085 /// 1086 /// @param[in,out] offset_ptr 1087 /// A pointer to an offset within the data that will be advanced 1088 /// by the appropriate number of bytes if the value is extracted 1089 /// correctly. If the offset is out of bounds or there are not 1090 /// enough bytes to extract this value, the offset will be left 1091 /// unmodified. 1092 /// 1093 /// @return 1094 /// The extracted unsigned integer value. 1095 //------------------------------------------------------------------ 1096 uint64_t 1097 GetULEB128 (lldb::offset_t *offset_ptr) const; 1098 1099 lldb::DataBufferSP & GetSharedDataBuffer()1100 GetSharedDataBuffer () 1101 { 1102 return m_data_sp; 1103 } 1104 1105 //------------------------------------------------------------------ 1106 /// Peek at a C string at \a offset. 1107 /// 1108 /// Peeks at a string in the contained data. No verification is done 1109 /// to make sure the entire string lies within the bounds of this 1110 /// object's data, only \a offset is verified to be a valid offset. 1111 /// 1112 /// @param[in] offset 1113 /// An offset into the data. 1114 /// 1115 /// @return 1116 /// A non-NULL C string pointer if \a offset is a valid offset, 1117 /// NULL otherwise. 1118 //------------------------------------------------------------------ 1119 const char * 1120 PeekCStr (lldb::offset_t offset) const; 1121 1122 //------------------------------------------------------------------ 1123 /// Peek at a bytes at \a offset. 1124 /// 1125 /// Returns a pointer to \a length bytes at \a offset as long as 1126 /// there are \a length bytes available starting at \a offset. 1127 /// 1128 /// @return 1129 /// A non-NULL data pointer if \a offset is a valid offset and 1130 /// there are \a length bytes available at that offset, NULL 1131 /// otherwise. 1132 //------------------------------------------------------------------ 1133 const uint8_t* PeekData(lldb::offset_t offset,lldb::offset_t length)1134 PeekData (lldb::offset_t offset, lldb::offset_t length) const 1135 { 1136 if (length > 0 && ValidOffsetForDataOfSize(offset, length)) 1137 return m_start + offset; 1138 return NULL; 1139 } 1140 1141 //------------------------------------------------------------------ 1142 /// Set the address byte size. 1143 /// 1144 /// Set the size in bytes that will be used when extracting any 1145 /// address and pointer values from data contained in this object. 1146 /// 1147 /// @param[in] addr_size 1148 /// The size in bytes to use when extracting addresses. 1149 //------------------------------------------------------------------ 1150 void SetAddressByteSize(uint32_t addr_size)1151 SetAddressByteSize (uint32_t addr_size) 1152 { 1153 m_addr_size = addr_size; 1154 } 1155 1156 //------------------------------------------------------------------ 1157 /// Set data with a buffer that is caller owned. 1158 /// 1159 /// Use data that is owned by the caller when extracting values. 1160 /// The data must stay around as long as this object, or any object 1161 /// that copies a subset of this object's data, is valid. If \a 1162 /// bytes is NULL, or \a length is zero, this object will contain 1163 /// no data. 1164 /// 1165 /// @param[in] bytes 1166 /// A pointer to caller owned data. 1167 /// 1168 /// @param[in] length 1169 /// The length in bytes of \a bytes. 1170 /// 1171 /// @param[in] byte_order 1172 /// A byte order of the data that we are extracting from. 1173 /// 1174 /// @return 1175 /// The number of bytes that this object now contains. 1176 //------------------------------------------------------------------ 1177 lldb::offset_t 1178 SetData (const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order); 1179 1180 //------------------------------------------------------------------ 1181 /// Adopt a subset of \a data. 1182 /// 1183 /// Set this object's data to be a subset of the data bytes in \a 1184 /// data. If \a data contains shared data, then a reference to the 1185 /// shared data will be added to ensure the shared data stays around 1186 /// as long as any objects have references to the shared data. The 1187 /// byte order and the address size settings are copied from \a 1188 /// data. If \a offset is not a valid offset in \a data, then no 1189 /// reference to the shared data will be added. If there are not 1190 /// \a length bytes available in \a data starting at \a offset, 1191 /// the length will be truncated to contains as many bytes as 1192 /// possible. 1193 /// 1194 /// @param[in] data 1195 /// Another DataExtractor object that contains data. 1196 /// 1197 /// @param[in] offset 1198 /// The offset into \a data at which the subset starts. 1199 /// 1200 /// @param[in] length 1201 /// The length in bytes of the subset of \a data. 1202 /// 1203 /// @return 1204 /// The number of bytes that this object now contains. 1205 //------------------------------------------------------------------ 1206 lldb::offset_t 1207 SetData (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length); 1208 1209 //------------------------------------------------------------------ 1210 /// Adopt a subset of shared data in \a data_sp. 1211 /// 1212 /// Copies the data shared pointer which adds a reference to the 1213 /// contained in \a data_sp. The shared data reference is reference 1214 /// counted to ensure the data lives as long as anyone still has a 1215 /// valid shared pointer to the data in \a data_sp. The byte order 1216 /// and address byte size settings remain the same. If 1217 /// \a offset is not a valid offset in \a data_sp, then no reference 1218 /// to the shared data will be added. If there are not \a length 1219 /// bytes available in \a data starting at \a offset, the length 1220 /// will be truncated to contains as many bytes as possible. 1221 /// 1222 /// @param[in] data_sp 1223 /// A shared pointer to data. 1224 /// 1225 /// @param[in] offset 1226 /// The offset into \a data_sp at which the subset starts. 1227 /// 1228 /// @param[in] length 1229 /// The length in bytes of the subset of \a data_sp. 1230 /// 1231 /// @return 1232 /// The number of bytes that this object now contains. 1233 //------------------------------------------------------------------ 1234 lldb::offset_t 1235 SetData (const lldb::DataBufferSP& data_sp, lldb::offset_t offset = 0, lldb::offset_t length = LLDB_INVALID_OFFSET); 1236 1237 //------------------------------------------------------------------ 1238 /// Set the byte_order value. 1239 /// 1240 /// Sets the byte order of the data to extract. Extracted values 1241 /// will be swapped if necessary when decoding. 1242 /// 1243 /// @param[in] byte_order 1244 /// The byte order value to use when extracting data. 1245 //------------------------------------------------------------------ 1246 void SetByteOrder(lldb::ByteOrder byte_order)1247 SetByteOrder (lldb::ByteOrder byte_order) 1248 { 1249 m_byte_order = byte_order; 1250 } 1251 1252 //------------------------------------------------------------------ 1253 /// Skip an LEB128 number at \a *offset_ptr. 1254 /// 1255 /// Skips a LEB128 number (signed or unsigned) from this object's 1256 /// data starting at the offset pointed to by \a offset_ptr. The 1257 /// offset pointed to by \a offset_ptr will be updated with the 1258 /// offset of the byte following the last extracted byte. 1259 /// 1260 /// @param[in,out] offset_ptr 1261 /// A pointer to an offset within the data that will be advanced 1262 /// by the appropriate number of bytes if the value is extracted 1263 /// correctly. If the offset is out of bounds or there are not 1264 /// enough bytes to extract this value, the offset will be left 1265 /// unmodified. 1266 /// 1267 /// @return 1268 // The number of bytes consumed during the extraction. 1269 //------------------------------------------------------------------ 1270 uint32_t 1271 Skip_LEB128 (lldb::offset_t *offset_ptr) const; 1272 1273 //------------------------------------------------------------------ 1274 /// Test the validity of \a offset. 1275 /// 1276 /// @return 1277 /// \b true if \a offset is a valid offset into the data in this 1278 /// object, \b false otherwise. 1279 //------------------------------------------------------------------ 1280 bool ValidOffset(lldb::offset_t offset)1281 ValidOffset (lldb::offset_t offset) const 1282 { 1283 return offset < GetByteSize(); 1284 } 1285 1286 //------------------------------------------------------------------ 1287 /// Test the availability of \a length bytes of data from \a offset. 1288 /// 1289 /// @return 1290 /// \b true if \a offset is a valid offset and there are \a 1291 /// length bytes available at that offset, \b false otherwise. 1292 //------------------------------------------------------------------ 1293 bool ValidOffsetForDataOfSize(lldb::offset_t offset,lldb::offset_t length)1294 ValidOffsetForDataOfSize (lldb::offset_t offset, lldb::offset_t length) const 1295 { 1296 return length <= BytesLeft (offset); 1297 } 1298 1299 size_t 1300 Copy (DataExtractor& dest_data) const; 1301 1302 bool 1303 Append (DataExtractor& rhs); 1304 1305 bool 1306 Append (void* bytes, lldb::offset_t length); 1307 1308 lldb::offset_t BytesLeft(lldb::offset_t offset)1309 BytesLeft (lldb::offset_t offset) const 1310 { 1311 const lldb::offset_t size = GetByteSize(); 1312 if (size > offset) 1313 return size - offset; 1314 return 0; 1315 } 1316 1317 void 1318 Checksum (llvm::SmallVectorImpl<uint8_t> &dest, 1319 uint64_t max_data = 0); 1320 1321 1322 protected: 1323 1324 //------------------------------------------------------------------ 1325 // Member variables 1326 //------------------------------------------------------------------ 1327 const uint8_t * m_start; ///< A pointer to the first byte of data. 1328 const uint8_t * m_end; ///< A pointer to the byte that is past the end of the data. 1329 lldb::ByteOrder m_byte_order; ///< The byte order of the data we are extracting from. 1330 uint32_t m_addr_size; ///< The address size to use when extracting pointers or addresses 1331 mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can be shared among multiple instances 1332 const uint32_t m_target_byte_size; 1333 }; 1334 1335 } // namespace lldb_private 1336 1337 #endif // #if defined (__cplusplus) 1338 #endif // #ifndef liblldb_DataExtractor_h_ 1339