• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 Google Inc. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //     * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //     * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //     * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 // Provides an API for mapping symbols through OMAP information, if a PDB file
30 // is augmented with it. This allows breakpad to work with addresses in
31 // transformed images by transforming the symbols themselves, rather than
32 // transforming addresses prior to querying symbols (the way it is typically
33 // done by Windows-native tools, including the DIA).
34 
35 #ifndef COMMON_WINDOWS_OMAP_H_
36 #define COMMON_WINDOWS_OMAP_H_
37 
38 #include "common/windows/omap_internal.h"
39 
40 namespace google_breakpad {
41 
42 // If the given session contains OMAP data this extracts it, populating
43 // |omap_data|, and then disabling automatic translation for the session.
44 // OMAP data is present in the PDB if |omap_data| is not empty. This returns
45 // true on success, false otherwise.
46 bool GetOmapDataAndDisableTranslation(IDiaSession* dia_session,
47                                       OmapData* omap_data);
48 
49 // Given raw OMAP data builds an ImageMap. This can be used to query individual
50 // image ranges using MapAddressRange.
51 // |omap_data|| is the OMAP data extracted from the PDB.
52 // |image_map| will be populated with a description of the image mapping. If
53 //     |omap_data| is empty then this will also be empty.
54 void BuildImageMap(const OmapData& omap_data, ImageMap* image_map);
55 
56 // Given an address range in the original image space determines how exactly it
57 // has been tranformed.
58 // |omap_data| is the OMAP data extracted from the PDB, which must not be
59 //     empty.
60 // |original_range| is the address range in the original image being queried.
61 // |mapped_ranges| will be populated with a full description of the mapping.
62 //     They may be disjoint in the transformed image so a vector is needed to
63 //     fully represent the mapping. This will be appended to if it is not
64 //     empty. If |omap_data| is empty then |mapped_ranges| will simply be
65 //     populated with a copy of |original_range| (the identity transform).
66 void MapAddressRange(const ImageMap& image_map,
67                      const AddressRange& original_range,
68                      AddressRangeVector* mapped_ranges);
69 
70 }  // namespace google_breakpad
71 
72 #endif  // COMMON_WINDOWS_OMAP_H_
73