This file is indexed.

/usr/lib/llvm-3.4/include/lldb/Core/DataExtractor.h is in liblldb-3.4-dev 1:3.4.2-13.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
//===-- DataExtractor.h -----------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_DataExtractor_h_
#define liblldb_DataExtractor_h_
#if defined (__cplusplus)


#include "lldb/lldb-private.h"
#include <limits.h>
#include <stdint.h>
#include <string.h>

namespace lldb_private {

//----------------------------------------------------------------------
/// @class DataExtractor DataExtractor.h "lldb/Core/DataExtractor.h"
/// @brief An data extractor class.
///
/// DataExtractor is a class that can extract data (swapping if needed)
/// from a data buffer. The data buffer can be caller owned, or can be
/// shared data that can be shared between multiple DataExtractor
/// instances. Multiple DataExtractor objects can share the same data,
/// yet extract values in different address sizes and byte order modes.
/// Each object can have a unique position in the shared data and extract
/// data from different offsets.
///
/// @see DataBuffer
//----------------------------------------------------------------------
class DataExtractor
{
public:
    //------------------------------------------------------------------
    /// @typedef DataExtractor::Type
    /// @brief Type enumerations used in the dump routines.
    /// @see DataExtractor::Dump()
    /// @see DataExtractor::DumpRawHexBytes()
    //------------------------------------------------------------------
    typedef enum
    {
        TypeUInt8,      ///< Format output as unsigned 8 bit integers
        TypeChar,       ///< Format output as characters
        TypeUInt16,     ///< Format output as unsigned 16 bit integers
        TypeUInt32,     ///< Format output as unsigned 32 bit integers
        TypeUInt64,     ///< Format output as unsigned 64 bit integers
        TypePointer,    ///< Format output as pointers
        TypeULEB128,    ///< Format output as ULEB128 numbers
        TypeSLEB128     ///< Format output as SLEB128 numbers
    } Type;

    static void
    DumpHexBytes (Stream *s, 
                  const void *src, 
                  size_t src_len, 
                  uint32_t bytes_per_line,
                  lldb::addr_t base_addr); // Pass LLDB_INVALID_ADDRESS to not show address at start of line
    //------------------------------------------------------------------
    /// Default constructor.
    ///
    /// Initialize all members to a default empty state.
    //------------------------------------------------------------------
    DataExtractor ();

    //------------------------------------------------------------------
    /// Construct with a buffer that is owned by the caller.
    ///
    /// This constructor allows us to use data that is owned by the
    /// caller. The data must stay around as long as this object is
    /// valid.
    ///
    /// @param[in] data
    ///     A pointer to caller owned data.
    ///
    /// @param[in] data_length
    ///     The length in bytes of \a data.
    ///
    /// @param[in] byte_order
    ///     A byte order of the data that we are extracting from.
    ///
    /// @param[in] addr_size
    ///     A new address byte size value.
    //------------------------------------------------------------------
    DataExtractor (const void* data, lldb::offset_t data_length, lldb::ByteOrder byte_order, uint32_t addr_size);

    //------------------------------------------------------------------
    /// Construct with shared data.
    ///
    /// Copies the data shared pointer which adds a reference to the
    /// contained in \a data_sp. The shared data reference is reference
    /// counted to ensure the data lives as long as anyone still has a
    /// valid shared pointer to the data in \a data_sp.
    ///
    /// @param[in] data_sp
    ///     A shared pointer to data.
    ///
    /// @param[in] byte_order
    ///     A byte order of the data that we are extracting from.
    ///
    /// @param[in] addr_size
    ///     A new address byte size value.
    //------------------------------------------------------------------
    DataExtractor (const lldb::DataBufferSP& data_sp, lldb::ByteOrder byte_order, uint32_t addr_size);

    //------------------------------------------------------------------
    /// Construct with a subset of \a data.
    ///
    /// Initialize this object with a subset of the data bytes in \a
    /// data. If \a data contains shared data, then a reference to the
    /// shared data will be added to ensure the shared data stays around
    /// as long as any objects have references to the shared data. The
    /// byte order value and the address size settings are copied from \a
    /// data. If \a offset is not a valid offset in \a data, then no
    /// reference to the shared data will be added. If there are not
    /// \a length bytes available in \a data starting at \a offset,
    /// the length will be truncated to contain as many bytes as
    /// possible.
    ///
    /// @param[in] data
    ///     Another DataExtractor object that contains data.
    ///
    /// @param[in] offset
    ///     The offset into \a data at which the subset starts.
    ///
    /// @param[in] length
    ///     The length in bytes of the subset of data.
    //------------------------------------------------------------------
    DataExtractor (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length);

    DataExtractor (const DataExtractor& rhs);
    //------------------------------------------------------------------
    /// Assignment operator.
    ///
    /// Copies all data, byte order and address size settings from \a rhs into
    /// this object. If \a rhs contains shared data, a reference to that
    /// shared data will be added.
    ///
    /// @param[in] rhs
    ///     Another DataExtractor object to copy.
    ///
    /// @return
    ///     A const reference to this object.
    //------------------------------------------------------------------
    const DataExtractor&
    operator= (const DataExtractor& rhs);

    //------------------------------------------------------------------
    /// Destructor
    ///
    /// If this object contains a valid shared data reference, the
    /// reference count on the data will be decremented, and if zero,
    /// the data will be freed.
    //------------------------------------------------------------------
    ~DataExtractor ();

    //------------------------------------------------------------------
    /// Clears the object state.
    ///
    /// Clears the object contents back to a default invalid state, and
    /// release any references to shared data that this object may
    /// contain.
    //------------------------------------------------------------------
    void
    Clear ();

    //------------------------------------------------------------------
    /// Dumps the binary data as \a type objects to stream \a s (or to
    /// Log() if \a s is NULL) starting \a offset bytes into the data
    /// and stopping after dumping \a length bytes. The offset into the
    /// data is displayed at the beginning of each line and can be
    /// offset by base address \a base_addr. \a num_per_line objects
    /// will be displayed on each line.
    ///
    /// @param[in] s
    ///     The stream to dump the output to. If NULL the output will
    ///     be dumped to Log().
    ///
    /// @param[in] offset
    ///     The offset into the data at which to start dumping.
    ///
    /// @param[in] length
    ///     The number of bytes to dump.
    ///
    /// @param[in] base_addr
    ///     The base address that gets added to the offset displayed on
    ///     each line.
    ///
    /// @param[in] num_per_line
    ///     The number of \a type objects to display on each line.
    ///
    /// @param[in] type
    ///     The type of objects to use when dumping data from this
    ///     object. See DataExtractor::Type.
    ///
    /// @param[in] type_format
    ///     The optional format to use for the \a type objects. If this
    ///     is NULL, the default format for the \a type will be used.
    ///
    /// @return
    ///     The offset at which dumping ended.
    //------------------------------------------------------------------
    lldb::offset_t
    PutToLog (Log *log,
              lldb::offset_t offset,
              lldb::offset_t length,
              uint64_t base_addr,
              uint32_t num_per_line,
              Type type,
              const char *type_format = NULL) const;

    //------------------------------------------------------------------
    /// Dumps \a item_count objects into the stream \a s.
    ///
    /// Dumps \a item_count objects using \a item_format, each of which
    /// are \a item_byte_size bytes long starting at offset \a offset
    /// bytes into the contained data, into the stream \a s. \a
    /// num_per_line objects will be dumped on each line before a new
    /// line will be output. If \a base_addr is a valid address, then
    /// each new line of output will be prededed by the address value
    /// plus appropriate offset, and a colon and space. Bitfield values
    /// can be dumped by calling this function multiple times with the
    /// same start offset, format and size, yet differing \a
    /// item_bit_size and \a item_bit_offset values.
    ///
    /// @param[in] s
    ///     The stream to dump the output to. This value can not be NULL.
    ///
    /// @param[in] offset
    ///     The offset into the data at which to start dumping.
    ///
    /// @param[in] item_format
    ///     The format to use when dumping each item.
    ///
    /// @param[in] item_byte_size
    ///     The byte size of each item.
    ///
    /// @param[in] item_count
    ///     The number of items to dump.
    ///
    /// @param[in] num_per_line
    ///     The number of items to display on each line.
    ///
    /// @param[in] base_addr
    ///     The base address that gets added to the offset displayed on
    ///     each line if the value is valid. Is \a base_addr is
    ///     LLDB_INVALID_ADDRESS then no address values will be prepended
    ///     to any lines.
    ///
    /// @param[in] item_bit_size
    ///     If the value to display is a bitfield, this value should
    ///     be the number of bits that the bitfield item has within the
    ///     item's byte size value. This function will need to be called
    ///     multiple times with identical \a offset and \a item_byte_size
    ///     values in order to display multiple bitfield values that
    ///     exist within the same integer value. If the items being
    ///     displayed are not bitfields, this value should be zero.
    ///
    /// @param[in] item_bit_offset
    ///     If the value to display is a bitfield, this value should
    ///     be the offset in bits, or shift right amount, that the
    ///     bitfield item occupies within the item's byte size value.
    ///     This function will need to be called multiple times with
    ///     identical \a offset and \a item_byte_size values in order
    ///     to display multiple bitfield values that exist within the
    ///     same integer value. If the items being displayed are not
    ///     bitfields, this value should be zero.
    ///
    /// @return
    ///     The offset at which dumping ended.
    //------------------------------------------------------------------
    lldb::offset_t
    Dump (Stream *s,
          lldb::offset_t offset,
          lldb::Format item_format,
          size_t item_byte_size,
          size_t item_count,
          size_t num_per_line,
          uint64_t base_addr,
          uint32_t item_bit_size,
          uint32_t item_bit_offset,
          ExecutionContextScope *exe_scope = NULL) const;

    //------------------------------------------------------------------
    /// Dump a UUID value at \a offset.
    ///
    /// Dump a UUID starting at \a offset bytes into this object's data.
    /// If the stream \a s is NULL, the output will be sent to Log().
    ///
    /// @param[in] s
    ///     The stream to dump the output to. If NULL the output will
    ///     be dumped to Log().
    ///
    /// @param[in] offset
    ///     The offset into the data at which to extract and dump a
    ///     UUID value.
    //------------------------------------------------------------------
    void
    DumpUUID (Stream *s, lldb::offset_t offset) const;

    //------------------------------------------------------------------
    /// Extract an arbitrary number of bytes in the specified byte
    /// order.
    ///
    /// Attemps to extract \a length bytes starting at \a offset bytes
    /// into this data in the requested byte order (\a dst_byte_order)
    /// and place the results in \a dst. \a dst must be at least \a
    /// length bytes long.
    ///
    /// @param[in] offset
    ///     The offset in bytes into the contained data at which to
    ///     start extracting.
    ///
    /// @param[in] length
    ///     The number of bytes to extract.
    ///
    /// @param[in] dst_byte_order
    ///     A byte order of the data that we want when the value in
    ///     copied to \a dst.
    ///
    /// @param[out] dst
    ///     The buffer that will receive the extracted value if there
    ///     are enough bytes available in the current data.
    ///
    /// @return
    ///     The number of bytes that were extracted which will be \a
    ///     length when the value is successfully extracted, or zero
    ///     if there aren't enough bytes at the specified offset.
    //------------------------------------------------------------------
    size_t
    ExtractBytes (lldb::offset_t offset, lldb::offset_t length, lldb::ByteOrder dst_byte_order, void *dst) const;

    //------------------------------------------------------------------
    /// Extract an address from \a *offset_ptr.
    ///
    /// Extract a single address from the data and update the offset
    /// pointed to by \a offset_ptr. The size of the extracted address
    /// comes from the \a m_addr_size member variable and should be
    /// set correctly prior to extracting any address values.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     The extracted address value.
    //------------------------------------------------------------------
    uint64_t
    GetAddress (lldb::offset_t *offset_ptr) const;
    
    uint64_t
    GetAddress_unchecked (lldb::offset_t *offset_ptr) const;

    //------------------------------------------------------------------
    /// Get the current address size.
    ///
    /// Return the size in bytes of any address values this object will
    /// extract.
    ///
    /// @return
    ///     The size in bytes of address values that will be extracted.
    //------------------------------------------------------------------
    uint32_t
    GetAddressByteSize () const
    {
        return m_addr_size;
    }

    //------------------------------------------------------------------
    /// Get the number of bytes contained in this object.
    ///
    /// @return
    ///     The total number of bytes of data this object refers to.
    //------------------------------------------------------------------
    uint64_t
    GetByteSize () const
    {
        return m_end - m_start;
    }

    //------------------------------------------------------------------
    /// Extract a C string from \a *offset_ptr.
    ///
    /// Returns a pointer to a C String from the data at the offset
    /// pointed to by \a offset_ptr. A variable length NULL terminated C
    /// string will be extracted and the \a offset_ptr will be
    /// updated with the offset of the byte that follows the NULL
    /// terminator byte.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     A pointer to the C string value in the data. If the offset
    ///     pointed to by \a offset_ptr is out of bounds, or if the
    ///     offset plus the length of the C string is out of bounds,
    ///     NULL will be returned.
    //------------------------------------------------------------------
    const char *
    GetCStr (lldb::offset_t *offset_ptr) const;

    //------------------------------------------------------------------
    /// Extract a C string from \a *offset_ptr with field size \a len.
    ///
    /// Returns a pointer to a C String from the data at the offset
    /// pointed to by \a offset_ptr, with a field length of \a len.
    /// A NULL terminated C string will be extracted and the \a offset_ptr
    /// will be updated with the offset of the byte that follows the fixed
    /// length field.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     A pointer to the C string value in the data. If the offset
    ///     pointed to by \a offset_ptr is out of bounds, or if the
    ///     offset plus the length of the field is out of bounds, or if
    ///     the field does not contain a NULL terminator byte, NULL will
    ///     be returned.
    const char *
    GetCStr (lldb::offset_t *offset_ptr, lldb::offset_t len) const;

    //------------------------------------------------------------------
    /// Extract \a length bytes from \a *offset_ptr.
    ///
    /// Returns a pointer to a bytes in this object's data at the offset
    /// pointed to by \a offset_ptr. If \a length is zero or too large,
    /// then the offset pointed to by \a offset_ptr will not be updated
    /// and NULL will be returned.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[in] length
    ///     The optional length of a string to extract. If the value is
    ///     zero, a NULL terminated C string will be extracted.
    ///
    /// @return
    ///     A pointer to the bytes in this object's data if the offset
    ///     and length are valid, or NULL otherwise.
    //------------------------------------------------------------------
    const void*
    GetData (lldb::offset_t *offset_ptr, lldb::offset_t length) const
    {
        const uint8_t *ptr = PeekData (*offset_ptr, length);
        if (ptr)
            *offset_ptr += length;
        return ptr;
    }
    
    //------------------------------------------------------------------
    /// Copy \a length bytes from \a *offset, without swapping bytes.
    ///
    /// @param[in] offset
    ///     The offset into this data from which to start copying
    ///
    /// @param[in] length
    ///     The length of the data to copy from this object
    ///
    /// @param[out] dst
    ///     The buffer to place the output data.
    ///
    /// @return
    ///     Returns the number of bytes that were copied, or zero if 
    ///     anything goes wrong.
    //------------------------------------------------------------------
    lldb::offset_t
    CopyData (lldb::offset_t offset,
              lldb::offset_t length,
              void *dst) const;

    //------------------------------------------------------------------
    /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied
    /// data is treated as a value that can be swapped to match the
    /// specified byte order.
    ///
    /// For values that are larger than the supported integer sizes,
    /// this function can be used to extract data in a specified byte
    /// order. It can also be used to copy a smaller integer value from
    /// to a larger value. The extra bytes left over will be padded
    /// correctly according to the byte order of this object and the
    /// \a dst_byte_order. This can be very handy when say copying a 
    /// partial data value into a register.
    ///
    /// @param[in] src_offset
    ///     The offset into this data from which to start copying an
    ///     endian entity
    ///
    /// @param[in] src_len
    ///     The length of the endian data to copy from this object
    ///     into the \a dst object
    ///
    /// @param[out] dst
    ///     The buffer where to place the endian data. The data might 
    ///     need to be byte swapped (and appropriately padded with 
    ///     zeroes if \a src_len != \a dst_len) if \a dst_byte_order 
    ///     does not match the byte order in this object.
    ///
    /// @param[in] dst_len
    ///     The length number of bytes that the endian value will 
    ///     occupy is \a dst.
    ///
    /// @param[in] byte_order
    ///     The byte order that the endian value should be in the \a dst
    ///     buffer.
    ///
    /// @return
    ///     Returns the number of bytes that were copied, or zero if 
    ///     anything goes wrong.
    //------------------------------------------------------------------
    lldb::offset_t
    CopyByteOrderedData (lldb::offset_t src_offset,
                         lldb::offset_t src_len,
                         void *dst, 
                         lldb::offset_t dst_len,
                         lldb::ByteOrder dst_byte_order) const;

    //------------------------------------------------------------------
    /// Get the data end pointer.
    ///
    /// @return
    ///     Returns a pointer to the next byte contained in this
    ///     object's data, or NULL of there is no data in this object.
    //------------------------------------------------------------------
    const uint8_t *
    GetDataEnd () const
    {
        return m_end;
    }

    //------------------------------------------------------------------
    /// Get the shared data offset.
    ///
    /// Get the offset of the first byte of data in the shared data (if
    /// any).
    ///
    /// @return
    ///     If this object contains shared data, this function returns
    ///     the offset in bytes into that shared data, zero otherwise.
    //------------------------------------------------------------------
    size_t
    GetSharedDataOffset () const;

    //------------------------------------------------------------------
    /// Get a the data start pointer.
    ///
    /// @return
    ///     Returns a pointer to the first byte contained in this
    ///     object's data, or NULL of there is no data in this object.
    //------------------------------------------------------------------
    const uint8_t *
    GetDataStart () const
    {
        return m_start;
    }


    //------------------------------------------------------------------
    /// Extract a float from \a *offset_ptr.
    ///
    /// Extract a single float value.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     The floating value that was extracted, or zero on failure.
    //------------------------------------------------------------------
    float
    GetFloat (lldb::offset_t *offset_ptr) const;

    double
    GetDouble (lldb::offset_t *offset_ptr) const;

    long double
    GetLongDouble (lldb::offset_t *offset_ptr) const;

    //------------------------------------------------------------------
    /// Extract a GNU encoded pointer value from \a *offset_ptr.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[in] eh_ptr_enc
    ///     The GNU pointer encoding type.
    ///
    /// @param[in] pc_rel_addr
    ///     The PC relative address to use when the encoding is
    ///     \c DW_GNU_EH_PE_pcrel.
    ///
    /// @param[in] text_addr
    ///     The text (code) relative address to use when the encoding is
    ///     \c DW_GNU_EH_PE_textrel.
    ///
    /// @param[in] data_addr
    ///     The data relative address to use when the encoding is
    ///     \c DW_GNU_EH_PE_datarel.
    ///
    /// @return
    ///     The extracted GNU encoded pointer value.
    //------------------------------------------------------------------
    uint64_t
    GetGNUEHPointer (lldb::offset_t *offset_ptr,
                     uint32_t eh_ptr_enc,
                     lldb::addr_t pc_rel_addr,
                     lldb::addr_t text_addr,
                     lldb::addr_t data_addr);

    //------------------------------------------------------------------
    /// Extract an integer of size \a byte_size from \a *offset_ptr.
    ///
    /// Extract a single integer value and update the offset pointed to
    /// by \a offset_ptr. The size of the extracted integer is specified
    /// by the \a byte_size argument. \a byte_size should have a value
    /// >= 1 and <= 4 since the return value is only 32 bits wide. Any
    /// \a byte_size values less than 1 or greater than 4 will result in
    /// nothing being extracted, and zero being returned.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[in] byte_size
    ///     The size in byte of the integer to extract.
    ///
    /// @return
    ///     The integer value that was extracted, or zero on failure.
    //------------------------------------------------------------------
    uint32_t
    GetMaxU32 (lldb::offset_t *offset_ptr, size_t byte_size) const;

    //------------------------------------------------------------------
    /// Extract an unsigned integer of size \a byte_size from \a
    /// *offset_ptr.
    ///
    /// Extract a single unsigned integer value and update the offset
    /// pointed to by \a offset_ptr. The size of the extracted integer
    /// is specified by the \a byte_size argument. \a byte_size should
    /// have a value greater than or equal to one and less than or equal
    /// to eight since the return value is 64 bits wide. Any
    /// \a byte_size values less than 1 or greater than 8 will result in
    /// nothing being extracted, and zero being returned.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[in] byte_size
    ///     The size in byte of the integer to extract.
    ///
    /// @return
    ///     The unsigned integer value that was extracted, or zero on
    ///     failure.
    //------------------------------------------------------------------
    uint64_t
    GetMaxU64 (lldb::offset_t *offset_ptr, size_t byte_size) const;

    uint64_t
    GetMaxU64_unchecked (lldb::offset_t *offset_ptr, size_t byte_size) const;

    //------------------------------------------------------------------
    /// Extract an signed integer of size \a byte_size from \a *offset_ptr.
    ///
    /// Extract a single signed integer value (sign extending if required)
    /// and update the offset pointed to by \a offset_ptr. The size of
    /// the extracted integer is specified by the \a byte_size argument.
    /// \a byte_size should have a value greater than or equal to one
    /// and less than or equal to eight since the return value is 64
    /// bits wide. Any \a byte_size values less than 1 or greater than
    /// 8 will result in nothing being extracted, and zero being returned.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[in] byte_size
    ///     The size in byte of the integer to extract.
    ///
    /// @return
    ///     The sign extended signed integer value that was extracted,
    ///     or zero on failure.
    //------------------------------------------------------------------
    int64_t
    GetMaxS64 (lldb::offset_t *offset_ptr, size_t size) const;

    //------------------------------------------------------------------
    /// Extract an unsigned integer of size \a byte_size from \a
    /// *offset_ptr, then extract the bitfield from this value if
    /// \a bitfield_bit_size is non-zero.
    ///
    /// Extract a single unsigned integer value and update the offset
    /// pointed to by \a offset_ptr. The size of the extracted integer
    /// is specified by the \a byte_size argument. \a byte_size should
    /// have a value greater than or equal to one and less than or equal
    /// to 8 since the return value is 64 bits wide. Any
    /// \a byte_size values less than 1 or greater than 8 will result in
    /// nothing being extracted, and zero being returned.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[in] byte_size
    ///     The size in byte of the integer to extract.
    ///
    /// @param[in] bitfield_bit_size
    ///     The size in bits of the bitfield value to extract, or zero
    ///     to just extract the entire integer value.
    ///
    /// @param[in] bitfield_bit_offset
    ///     The bit offset of the bitfield value in the extracted
    ///     integer (the number of bits to shift the integer to the
    ///     right).
    ///
    /// @return
    ///     The unsigned bitfield integer value that was extracted, or
    ///     zero on failure.
    //------------------------------------------------------------------
    uint64_t
    GetMaxU64Bitfield (lldb::offset_t *offset_ptr,
                       size_t size,
                       uint32_t bitfield_bit_size,
                       uint32_t bitfield_bit_offset) const;

    //------------------------------------------------------------------
    /// Extract an signed integer of size \a byte_size from \a
    /// *offset_ptr, then extract and signe extend the bitfield from
    /// this value if \a bitfield_bit_size is non-zero.
    ///
    /// Extract a single signed integer value (sign extending if required)
    /// and update the offset pointed to by \a offset_ptr. The size of
    /// the extracted integer is specified by the \a byte_size argument.
    /// \a byte_size should have a value greater than or equal to one
    /// and less than or equal to eight since the return value is 64
    /// bits wide. Any \a byte_size values less than 1 or greater than
    /// 8 will result in nothing being extracted, and zero being returned.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[in] byte_size
    ///     The size in bytes of the integer to extract.
    ///
    /// @param[in] bitfield_bit_size
    ///     The size in bits of the bitfield value to extract, or zero
    ///     to just extract the entire integer value.
    ///
    /// @param[in] bitfield_bit_offset
    ///     The bit offset of the bitfield value in the extracted
    ///     integer (the number of bits to shift the integer to the
    ///     right).
    ///
    /// @return
    ///     The signed bitfield integer value that was extracted, or
    ///     zero on failure.
    //------------------------------------------------------------------
    int64_t
    GetMaxS64Bitfield (lldb::offset_t *offset_ptr,
                       size_t size,
                       uint32_t bitfield_bit_size,
                       uint32_t bitfield_bit_offset) const;

    //------------------------------------------------------------------
    /// Extract an pointer from \a *offset_ptr.
    ///
    /// Extract a single pointer from the data and update the offset
    /// pointed to by \a offset_ptr. The size of the extracted pointer
    /// comes from the \a m_addr_size member variable and should be
    /// set correctly prior to extracting any pointer values.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     The extracted pointer value as a 64 integer.
    //------------------------------------------------------------------
    uint64_t
    GetPointer (lldb::offset_t *offset_ptr) const;

    //------------------------------------------------------------------
    /// Get the current byte order value.
    ///
    /// @return
    ///     The current byte order value from this object's internal
    ///     state.
    //------------------------------------------------------------------
    lldb::ByteOrder
    GetByteOrder() const
    {
        return m_byte_order;
    }

    //------------------------------------------------------------------
    /// Extract a uint8_t value from \a *offset_ptr.
    ///
    /// Extract a single uint8_t from the binary data at the offset
    /// pointed to by \a offset_ptr, and advance the offset on success.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     The extracted uint8_t value.
    //------------------------------------------------------------------
    uint8_t
    GetU8 ( lldb::offset_t *offset_ptr) const;

    uint8_t
    GetU8_unchecked (lldb::offset_t *offset_ptr) const
    {
        uint8_t val = m_start[*offset_ptr];
        *offset_ptr += 1;
        return val;
    }
    
    uint16_t
    GetU16_unchecked (lldb::offset_t *offset_ptr) const;

    uint32_t
    GetU32_unchecked (lldb::offset_t *offset_ptr) const;

    uint64_t
    GetU64_unchecked (lldb::offset_t *offset_ptr) const;
    //------------------------------------------------------------------
    /// Extract \a count uint8_t values from \a *offset_ptr.
    ///
    /// Extract \a count uint8_t values from the binary data at the
    /// offset pointed to by \a offset_ptr, and advance the offset on
    /// success. The extracted values are copied into \a dst.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[out] dst
    ///     A buffer to copy \a count uint8_t values into. \a dst must
    ///     be large enough to hold all requested data.
    ///
    /// @param[in] count
    ///     The number of uint8_t values to extract.
    ///
    /// @return
    ///     \a dst if all values were properly extracted and copied,
    ///     NULL otherise.
    //------------------------------------------------------------------
    void *
    GetU8 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;

    //------------------------------------------------------------------
    /// Extract a uint16_t value from \a *offset_ptr.
    ///
    /// Extract a single uint16_t from the binary data at the offset
    /// pointed to by \a offset_ptr, and update the offset on success.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     The extracted uint16_t value.
    //------------------------------------------------------------------
    uint16_t
    GetU16 (lldb::offset_t *offset_ptr) const;

    //------------------------------------------------------------------
    /// Extract \a count uint16_t values from \a *offset_ptr.
    ///
    /// Extract \a count uint16_t values from the binary data at the
    /// offset pointed to by \a offset_ptr, and advance the offset on
    /// success. The extracted values are copied into \a dst.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[out] dst
    ///     A buffer to copy \a count uint16_t values into. \a dst must
    ///     be large enough to hold all requested data.
    ///
    /// @param[in] count
    ///     The number of uint16_t values to extract.
    ///
    /// @return
    ///     \a dst if all values were properly extracted and copied,
    ///     NULL otherise.
    //------------------------------------------------------------------
    void *
    GetU16 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;

    //------------------------------------------------------------------
    /// Extract a uint32_t value from \a *offset_ptr.
    ///
    /// Extract a single uint32_t from the binary data at the offset
    /// pointed to by \a offset_ptr, and update the offset on success.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     The extracted uint32_t value.
    //------------------------------------------------------------------
    uint32_t
    GetU32 (lldb::offset_t *offset_ptr) const;

    //------------------------------------------------------------------
    /// Extract \a count uint32_t values from \a *offset_ptr.
    ///
    /// Extract \a count uint32_t values from the binary data at the
    /// offset pointed to by \a offset_ptr, and advance the offset on
    /// success. The extracted values are copied into \a dst.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[out] dst
    ///     A buffer to copy \a count uint32_t values into. \a dst must
    ///     be large enough to hold all requested data.
    ///
    /// @param[in] count
    ///     The number of uint32_t values to extract.
    ///
    /// @return
    ///     \a dst if all values were properly extracted and copied,
    ///     NULL otherise.
    //------------------------------------------------------------------
    void *
    GetU32 (lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;

    //------------------------------------------------------------------
    /// Extract a uint64_t value from \a *offset_ptr.
    ///
    /// Extract a single uint64_t from the binary data at the offset
    /// pointed to by \a offset_ptr, and update the offset on success.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     The extracted uint64_t value.
    //------------------------------------------------------------------
    uint64_t
    GetU64 (lldb::offset_t *offset_ptr) const;

    //------------------------------------------------------------------
    /// Extract \a count uint64_t values from \a *offset_ptr.
    ///
    /// Extract \a count uint64_t values from the binary data at the
    /// offset pointed to by \a offset_ptr, and advance the offset on
    /// success. The extracted values are copied into \a dst.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @param[out] dst
    ///     A buffer to copy \a count uint64_t values into. \a dst must
    ///     be large enough to hold all requested data.
    ///
    /// @param[in] count
    ///     The number of uint64_t values to extract.
    ///
    /// @return
    ///     \a dst if all values were properly extracted and copied,
    ///     NULL otherise.
    //------------------------------------------------------------------
    void *
    GetU64 ( lldb::offset_t *offset_ptr, void *dst, uint32_t count) const;

    //------------------------------------------------------------------
    /// Extract a signed LEB128 value from \a *offset_ptr.
    ///
    /// Extracts an signed LEB128 number from this object's data
    /// starting at the offset pointed to by \a offset_ptr. The offset
    /// pointed to by \a offset_ptr will be updated with the offset of
    /// the byte following the last extracted byte.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     The extracted signed integer value.
    //------------------------------------------------------------------
    int64_t
    GetSLEB128 (lldb::offset_t *offset_ptr) const;

    //------------------------------------------------------------------
    /// Extract a unsigned LEB128 value from \a *offset_ptr.
    ///
    /// Extracts an unsigned LEB128 number from this object's data
    /// starting at the offset pointed to by \a offset_ptr. The offset
    /// pointed to by \a offset_ptr will be updated with the offset of
    /// the byte following the last extracted byte.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    ///     The extracted unsigned integer value.
    //------------------------------------------------------------------
    uint64_t
    GetULEB128 (lldb::offset_t *offset_ptr) const;

    lldb::DataBufferSP &
    GetSharedDataBuffer ()
    {
        return m_data_sp;
    }

    //------------------------------------------------------------------
    /// Peek at a C string at \a offset.
    ///
    /// Peeks at a string in the contained data. No verification is done
    /// to make sure the entire string lies within the bounds of this
    /// object's data, only \a offset is verified to be a valid offset.
    ///
    /// @param[in] offset
    ///     An offset into the data.
    ///
    /// @return
    ///     A non-NULL C string pointer if \a offset is a valid offset,
    ///     NULL otherwise.
    //------------------------------------------------------------------
    const char *
    PeekCStr (lldb::offset_t offset) const;

    //------------------------------------------------------------------
    /// Peek at a bytes at \a offset.
    ///
    /// Returns a pointer to \a length bytes at \a offset as long as
    /// there are \a length bytes available starting at \a offset.
    ///
    /// @return
    ///     A non-NULL data pointer if \a offset is a valid offset and
    ///     there are \a length bytes available at that offset, NULL
    ///     otherwise.
    //------------------------------------------------------------------
    const uint8_t*
    PeekData (lldb::offset_t offset, lldb::offset_t length) const
    {
        if (length > 0 && ValidOffsetForDataOfSize(offset, length))
            return m_start + offset;
        return NULL;
    }

    //------------------------------------------------------------------
    /// Set the address byte size.
    ///
    /// Set the size in bytes that will be used when extracting any
    /// address and pointer values from data contained in this object.
    ///
    /// @param[in] addr_size
    ///     The size in bytes to use when extracting addresses.
    //------------------------------------------------------------------
    void
    SetAddressByteSize (uint32_t addr_size)
    {
        m_addr_size = addr_size;
    }

    //------------------------------------------------------------------
    /// Set data with a buffer that is caller owned.
    ///
    /// Use data that is owned by the caller when extracting values.
    /// The data must stay around as long as this object, or any object
    /// that copies a subset of this object's data, is valid. If \a
    /// bytes is NULL, or \a length is zero, this object will contain
    /// no data.
    ///
    /// @param[in] bytes
    ///     A pointer to caller owned data.
    ///
    /// @param[in] length
    ///     The length in bytes of \a bytes.
    ///
    /// @param[in] byte_order
    ///     A byte order of the data that we are extracting from.
    ///
    /// @return
    ///     The number of bytes that this object now contains.
    //------------------------------------------------------------------
    lldb::offset_t
    SetData (const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order);

    //------------------------------------------------------------------
    /// Adopt a subset of \a data.
    ///
    /// Set this object's data to be a subset of the data bytes in \a
    /// data. If \a data contains shared data, then a reference to the
    /// shared data will be added to ensure the shared data stays around
    /// as long as any objects have references to the shared data. The
    /// byte order and the address size settings are copied from \a
    /// data. If \a offset is not a valid offset in \a data, then no
    /// reference to the shared data will be added. If there are not
    /// \a length bytes available in \a data starting at \a offset,
    /// the length will be truncated to contains as many bytes as
    /// possible.
    ///
    /// @param[in] data
    ///     Another DataExtractor object that contains data.
    ///
    /// @param[in] offset
    ///     The offset into \a data at which the subset starts.
    ///
    /// @param[in] length
    ///     The length in bytes of the subset of \a data.
    ///
    /// @return
    ///     The number of bytes that this object now contains.
    //------------------------------------------------------------------
    lldb::offset_t
    SetData (const DataExtractor& data, lldb::offset_t offset, lldb::offset_t length);

    //------------------------------------------------------------------
    /// Adopt a subset of shared data in \a data_sp.
    ///
    /// Copies the data shared pointer which adds a reference to the
    /// contained in \a data_sp. The shared data reference is reference
    /// counted to ensure the data lives as long as anyone still has a
    /// valid shared pointer to the data in \a data_sp. The byte order
    /// and address byte size settings remain the same. If
    /// \a offset is not a valid offset in \a data_sp, then no reference
    /// to the shared data will be added. If there are not \a length
    /// bytes available in \a data starting at \a offset, the length
    /// will be truncated to contains as many bytes as possible.
    ///
    /// @param[in] data_sp
    ///     A shared pointer to data.
    ///
    /// @param[in] offset
    ///     The offset into \a data_sp at which the subset starts.
    ///
    /// @param[in] length
    ///     The length in bytes of the subset of \a data_sp.
    ///
    /// @return
    ///     The number of bytes that this object now contains.
    //------------------------------------------------------------------
    lldb::offset_t
    SetData (const lldb::DataBufferSP& data_sp, lldb::offset_t offset = 0, lldb::offset_t length = LLDB_INVALID_OFFSET);

    //------------------------------------------------------------------
    /// Set the byte_order value.
    ///
    /// Sets the byte order of the data to extract. Extracted values
    /// will be swapped if necessary when decoding.
    ///
    /// @param[in] byte_order
    ///     The byte order value to use when extracting data.
    //------------------------------------------------------------------
    void
    SetByteOrder (lldb::ByteOrder byte_order)
    {
        m_byte_order = byte_order;
    }

    //------------------------------------------------------------------
    /// Skip an LEB128 number at \a *offset_ptr.
    ///
    /// Skips a LEB128 number (signed or unsigned) from this object's
    /// data starting at the offset pointed to by \a offset_ptr. The
    /// offset pointed to by \a offset_ptr will be updated with the
    /// offset of the byte following the last extracted byte.
    ///
    /// @param[in,out] offset_ptr
    ///     A pointer to an offset within the data that will be advanced
    ///     by the appropriate number of bytes if the value is extracted
    ///     correctly. If the offset is out of bounds or there are not
    ///     enough bytes to extract this value, the offset will be left
    ///     unmodified.
    ///
    /// @return
    //      The number of bytes consumed during the extraction.
    //------------------------------------------------------------------
    uint32_t
    Skip_LEB128 (lldb::offset_t *offset_ptr) const;

    //------------------------------------------------------------------
    /// Test the validity of \a offset.
    ///
    /// @return
    ///     \b true if \a offset is a valid offset into the data in this
    ///     object, \b false otherwise.
    //------------------------------------------------------------------
    bool
    ValidOffset (lldb::offset_t offset) const
    {
        return offset < GetByteSize();
    }

    //------------------------------------------------------------------
    /// Test the availability of \a length bytes of data from \a offset.
    ///
    /// @return
    ///     \b true if \a offset is a valid offset and there are \a
    ///     length bytes available at that offset, \b false otherwise.
    //------------------------------------------------------------------
    bool
    ValidOffsetForDataOfSize (lldb::offset_t offset, lldb::offset_t length) const
    {
        return length <= BytesLeft (offset);
    }

    size_t
    Copy (DataExtractor& dest_data) const;
    
    bool
    Append (DataExtractor& rhs);
    
    bool
    Append (void* bytes, lldb::offset_t length);

    lldb::offset_t
    BytesLeft (lldb::offset_t offset) const
    {
        const lldb::offset_t size = GetByteSize();
        if (size > offset)
            return size - offset;
        return 0;
    }

protected:
    
    //------------------------------------------------------------------
    // Member variables
    //------------------------------------------------------------------
    const uint8_t * m_start;        ///< A pointer to the first byte of data.
    const uint8_t * m_end;          ///< A pointer to the byte that is past the end of the data.
    lldb::ByteOrder m_byte_order;   ///< The byte order of the data we are extracting from.
    uint32_t m_addr_size;           ///< The address size to use when extracting pointers or addresses
    mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can be shared among multilple instances
};

} // namespace lldb_private

#endif  // #if defined (__cplusplus)
#endif  // #ifndef liblldb_DataExtractor_h_