Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | // Copyright (c) 2010 Google Inc. All Rights Reserved. |
michael@0 | 2 | // |
michael@0 | 3 | // Redistribution and use in source and binary forms, with or without |
michael@0 | 4 | // modification, are permitted provided that the following conditions are |
michael@0 | 5 | // met: |
michael@0 | 6 | // |
michael@0 | 7 | // * Redistributions of source code must retain the above copyright |
michael@0 | 8 | // notice, this list of conditions and the following disclaimer. |
michael@0 | 9 | // * Redistributions in binary form must reproduce the above |
michael@0 | 10 | // copyright notice, this list of conditions and the following disclaimer |
michael@0 | 11 | // in the documentation and/or other materials provided with the |
michael@0 | 12 | // distribution. |
michael@0 | 13 | // * Neither the name of Google Inc. nor the names of its |
michael@0 | 14 | // contributors may be used to endorse or promote products derived from |
michael@0 | 15 | // this software without specific prior written permission. |
michael@0 | 16 | // |
michael@0 | 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
michael@0 | 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@0 | 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@0 | 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
michael@0 | 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
michael@0 | 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 28 | |
michael@0 | 29 | |
michael@0 | 30 | // This file contains the definitions for a DWARF2/3 information |
michael@0 | 31 | // collector that uses the DWARF2/3 reader interface to build a mapping |
michael@0 | 32 | // of addresses to files, lines, and functions. |
michael@0 | 33 | |
michael@0 | 34 | #ifndef COMMON_DWARF_FUNCTIONINFO_H__ |
michael@0 | 35 | #define COMMON_DWARF_FUNCTIONINFO_H__ |
michael@0 | 36 | |
michael@0 | 37 | #include <map> |
michael@0 | 38 | #include <string> |
michael@0 | 39 | #include <utility> |
michael@0 | 40 | #include <vector> |
michael@0 | 41 | |
michael@0 | 42 | #include "common/dwarf/dwarf2reader.h" |
michael@0 | 43 | #include "common/using_std_string.h" |
michael@0 | 44 | |
michael@0 | 45 | |
michael@0 | 46 | namespace dwarf2reader { |
michael@0 | 47 | |
michael@0 | 48 | struct FunctionInfo { |
michael@0 | 49 | // Name of the function |
michael@0 | 50 | string name; |
michael@0 | 51 | // Mangled name of the function |
michael@0 | 52 | string mangled_name; |
michael@0 | 53 | // File containing this function |
michael@0 | 54 | string file; |
michael@0 | 55 | // Line number for start of function. |
michael@0 | 56 | uint32 line; |
michael@0 | 57 | // Beginning address for this function |
michael@0 | 58 | uint64 lowpc; |
michael@0 | 59 | // End address for this function. |
michael@0 | 60 | uint64 highpc; |
michael@0 | 61 | }; |
michael@0 | 62 | |
michael@0 | 63 | struct SourceFileInfo { |
michael@0 | 64 | // Name of the source file name |
michael@0 | 65 | string name; |
michael@0 | 66 | // Low address of source file name |
michael@0 | 67 | uint64 lowpc; |
michael@0 | 68 | }; |
michael@0 | 69 | |
michael@0 | 70 | typedef std::map<uint64, FunctionInfo*> FunctionMap; |
michael@0 | 71 | typedef std::map<uint64, std::pair<string, uint32> > LineMap; |
michael@0 | 72 | |
michael@0 | 73 | // This class is a basic line info handler that fills in the dirs, |
michael@0 | 74 | // file, and linemap passed into it with the data produced from the |
michael@0 | 75 | // LineInfoHandler. |
michael@0 | 76 | class CULineInfoHandler: public LineInfoHandler { |
michael@0 | 77 | public: |
michael@0 | 78 | |
michael@0 | 79 | // |
michael@0 | 80 | CULineInfoHandler(std::vector<SourceFileInfo>* files, |
michael@0 | 81 | std::vector<string>* dirs, |
michael@0 | 82 | LineMap* linemap); |
michael@0 | 83 | virtual ~CULineInfoHandler() { } |
michael@0 | 84 | |
michael@0 | 85 | // Called when we define a directory. We just place NAME into dirs_ |
michael@0 | 86 | // at position DIR_NUM. |
michael@0 | 87 | virtual void DefineDir(const string& name, uint32 dir_num); |
michael@0 | 88 | |
michael@0 | 89 | // Called when we define a filename. We just place |
michael@0 | 90 | // concat(dirs_[DIR_NUM], NAME) into files_ at position FILE_NUM. |
michael@0 | 91 | virtual void DefineFile(const string& name, int32 file_num, |
michael@0 | 92 | uint32 dir_num, uint64 mod_time, uint64 length); |
michael@0 | 93 | |
michael@0 | 94 | |
michael@0 | 95 | // Called when the line info reader has a new line, address pair |
michael@0 | 96 | // ready for us. ADDRESS is the address of the code, LENGTH is the |
michael@0 | 97 | // length of its machine code in bytes, FILE_NUM is the file number |
michael@0 | 98 | // containing the code, LINE_NUM is the line number in that file for |
michael@0 | 99 | // the code, and COLUMN_NUM is the column number the code starts at, |
michael@0 | 100 | // if we know it (0 otherwise). |
michael@0 | 101 | virtual void AddLine(uint64 address, uint64 length, |
michael@0 | 102 | uint32 file_num, uint32 line_num, uint32 column_num); |
michael@0 | 103 | |
michael@0 | 104 | private: |
michael@0 | 105 | LineMap* linemap_; |
michael@0 | 106 | std::vector<SourceFileInfo>* files_; |
michael@0 | 107 | std::vector<string>* dirs_; |
michael@0 | 108 | }; |
michael@0 | 109 | |
michael@0 | 110 | class CUFunctionInfoHandler: public Dwarf2Handler { |
michael@0 | 111 | public: |
michael@0 | 112 | CUFunctionInfoHandler(std::vector<SourceFileInfo>* files, |
michael@0 | 113 | std::vector<string>* dirs, |
michael@0 | 114 | LineMap* linemap, |
michael@0 | 115 | FunctionMap* offset_to_funcinfo, |
michael@0 | 116 | FunctionMap* address_to_funcinfo, |
michael@0 | 117 | CULineInfoHandler* linehandler, |
michael@0 | 118 | const SectionMap& sections, |
michael@0 | 119 | ByteReader* reader) |
michael@0 | 120 | : files_(files), dirs_(dirs), linemap_(linemap), |
michael@0 | 121 | offset_to_funcinfo_(offset_to_funcinfo), |
michael@0 | 122 | address_to_funcinfo_(address_to_funcinfo), |
michael@0 | 123 | linehandler_(linehandler), sections_(sections), |
michael@0 | 124 | reader_(reader), current_function_info_(NULL) { } |
michael@0 | 125 | |
michael@0 | 126 | virtual ~CUFunctionInfoHandler() { } |
michael@0 | 127 | |
michael@0 | 128 | // Start to process a compilation unit at OFFSET from the beginning of the |
michael@0 | 129 | // .debug_info section. We want to see all compilation units, so we |
michael@0 | 130 | // always return true. |
michael@0 | 131 | |
michael@0 | 132 | virtual bool StartCompilationUnit(uint64 offset, uint8 address_size, |
michael@0 | 133 | uint8 offset_size, uint64 cu_length, |
michael@0 | 134 | uint8 dwarf_version); |
michael@0 | 135 | |
michael@0 | 136 | // Start to process a DIE at OFFSET from the beginning of the |
michael@0 | 137 | // .debug_info section. We only care about function related DIE's. |
michael@0 | 138 | virtual bool StartDIE(uint64 offset, enum DwarfTag tag); |
michael@0 | 139 | |
michael@0 | 140 | // Called when we have an attribute with unsigned data to give to |
michael@0 | 141 | // our handler. The attribute is for the DIE at OFFSET from the |
michael@0 | 142 | // beginning of the .debug_info section, has a name of ATTR, a form of |
michael@0 | 143 | // FORM, and the actual data of the attribute is in DATA. |
michael@0 | 144 | virtual void ProcessAttributeUnsigned(uint64 offset, |
michael@0 | 145 | enum DwarfAttribute attr, |
michael@0 | 146 | enum DwarfForm form, |
michael@0 | 147 | uint64 data); |
michael@0 | 148 | |
michael@0 | 149 | // Called when we have an attribute with a DIE reference to give to |
michael@0 | 150 | // our handler. The attribute is for the DIE at OFFSET from the |
michael@0 | 151 | // beginning of the .debug_info section, has a name of ATTR, a form of |
michael@0 | 152 | // FORM, and the offset of the referenced DIE from the start of the |
michael@0 | 153 | // .debug_info section is in DATA. |
michael@0 | 154 | virtual void ProcessAttributeReference(uint64 offset, |
michael@0 | 155 | enum DwarfAttribute attr, |
michael@0 | 156 | enum DwarfForm form, |
michael@0 | 157 | uint64 data); |
michael@0 | 158 | |
michael@0 | 159 | // Called when we have an attribute with string data to give to |
michael@0 | 160 | // our handler. The attribute is for the DIE at OFFSET from the |
michael@0 | 161 | // beginning of the .debug_info section, has a name of ATTR, a form of |
michael@0 | 162 | // FORM, and the actual data of the attribute is in DATA. |
michael@0 | 163 | virtual void ProcessAttributeString(uint64 offset, |
michael@0 | 164 | enum DwarfAttribute attr, |
michael@0 | 165 | enum DwarfForm form, |
michael@0 | 166 | const string& data); |
michael@0 | 167 | |
michael@0 | 168 | // Called when finished processing the DIE at OFFSET. |
michael@0 | 169 | // Because DWARF2/3 specifies a tree of DIEs, you may get starts |
michael@0 | 170 | // before ends of the previous DIE, as we process children before |
michael@0 | 171 | // ending the parent. |
michael@0 | 172 | virtual void EndDIE(uint64 offset); |
michael@0 | 173 | |
michael@0 | 174 | private: |
michael@0 | 175 | std::vector<SourceFileInfo>* files_; |
michael@0 | 176 | std::vector<string>* dirs_; |
michael@0 | 177 | LineMap* linemap_; |
michael@0 | 178 | FunctionMap* offset_to_funcinfo_; |
michael@0 | 179 | FunctionMap* address_to_funcinfo_; |
michael@0 | 180 | CULineInfoHandler* linehandler_; |
michael@0 | 181 | const SectionMap& sections_; |
michael@0 | 182 | ByteReader* reader_; |
michael@0 | 183 | FunctionInfo* current_function_info_; |
michael@0 | 184 | uint64 current_compilation_unit_offset_; |
michael@0 | 185 | }; |
michael@0 | 186 | |
michael@0 | 187 | } // namespace dwarf2reader |
michael@0 | 188 | #endif // COMMON_DWARF_FUNCTIONINFO_H__ |