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) 2006, Google Inc. |
michael@0 | 2 | // All rights reserved. |
michael@0 | 3 | // |
michael@0 | 4 | // Redistribution and use in source and binary forms, with or without |
michael@0 | 5 | // modification, are permitted provided that the following conditions are |
michael@0 | 6 | // met: |
michael@0 | 7 | // |
michael@0 | 8 | // * Redistributions of source code must retain the above copyright |
michael@0 | 9 | // notice, this list of conditions and the following disclaimer. |
michael@0 | 10 | // * Redistributions in binary form must reproduce the above |
michael@0 | 11 | // copyright notice, this list of conditions and the following disclaimer |
michael@0 | 12 | // in the documentation and/or other materials provided with the |
michael@0 | 13 | // distribution. |
michael@0 | 14 | // * Neither the name of Google Inc. nor the names of its |
michael@0 | 15 | // contributors may be used to endorse or promote products derived from |
michael@0 | 16 | // this software without specific prior written permission. |
michael@0 | 17 | // |
michael@0 | 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
michael@0 | 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@0 | 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@0 | 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
michael@0 | 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
michael@0 | 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 29 | |
michael@0 | 30 | // minidump_dump.cc: Print the contents of a minidump file in somewhat |
michael@0 | 31 | // readable text. |
michael@0 | 32 | // |
michael@0 | 33 | // Author: Mark Mentovai |
michael@0 | 34 | |
michael@0 | 35 | #include <stdio.h> |
michael@0 | 36 | #include <string.h> |
michael@0 | 37 | |
michael@0 | 38 | #include "common/scoped_ptr.h" |
michael@0 | 39 | #include "google_breakpad/processor/minidump.h" |
michael@0 | 40 | #include "processor/logging.h" |
michael@0 | 41 | |
michael@0 | 42 | namespace { |
michael@0 | 43 | |
michael@0 | 44 | using google_breakpad::Minidump; |
michael@0 | 45 | using google_breakpad::MinidumpThreadList; |
michael@0 | 46 | using google_breakpad::MinidumpModuleList; |
michael@0 | 47 | using google_breakpad::MinidumpMemoryInfoList; |
michael@0 | 48 | using google_breakpad::MinidumpMemoryList; |
michael@0 | 49 | using google_breakpad::MinidumpException; |
michael@0 | 50 | using google_breakpad::MinidumpAssertion; |
michael@0 | 51 | using google_breakpad::MinidumpSystemInfo; |
michael@0 | 52 | using google_breakpad::MinidumpMiscInfo; |
michael@0 | 53 | using google_breakpad::MinidumpBreakpadInfo; |
michael@0 | 54 | |
michael@0 | 55 | static void DumpRawStream(Minidump *minidump, |
michael@0 | 56 | uint32_t stream_type, |
michael@0 | 57 | const char *stream_name, |
michael@0 | 58 | int *errors) { |
michael@0 | 59 | uint32_t length = 0; |
michael@0 | 60 | if (!minidump->SeekToStreamType(stream_type, &length)) { |
michael@0 | 61 | return; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | printf("Stream %s:\n", stream_name); |
michael@0 | 65 | |
michael@0 | 66 | if (length == 0) { |
michael@0 | 67 | printf("\n"); |
michael@0 | 68 | return; |
michael@0 | 69 | } |
michael@0 | 70 | std::vector<char> contents(length); |
michael@0 | 71 | if (!minidump->ReadBytes(&contents[0], length)) { |
michael@0 | 72 | ++*errors; |
michael@0 | 73 | BPLOG(ERROR) << "minidump.ReadBytes failed"; |
michael@0 | 74 | return; |
michael@0 | 75 | } |
michael@0 | 76 | size_t current_offset = 0; |
michael@0 | 77 | while (current_offset < length) { |
michael@0 | 78 | size_t remaining = length - current_offset; |
michael@0 | 79 | // Printf requires an int and direct casting from size_t results |
michael@0 | 80 | // in compatibility warnings. |
michael@0 | 81 | uint32_t int_remaining = remaining; |
michael@0 | 82 | printf("%.*s", int_remaining, &contents[current_offset]); |
michael@0 | 83 | char *next_null = reinterpret_cast<char *>( |
michael@0 | 84 | memchr(&contents[current_offset], 0, remaining)); |
michael@0 | 85 | if (next_null == NULL) |
michael@0 | 86 | break; |
michael@0 | 87 | printf("\\0\n"); |
michael@0 | 88 | size_t null_offset = next_null - &contents[0]; |
michael@0 | 89 | current_offset = null_offset + 1; |
michael@0 | 90 | } |
michael@0 | 91 | printf("\n\n"); |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | static bool PrintMinidumpDump(const char *minidump_file) { |
michael@0 | 95 | Minidump minidump(minidump_file); |
michael@0 | 96 | if (!minidump.Read()) { |
michael@0 | 97 | BPLOG(ERROR) << "minidump.Read() failed"; |
michael@0 | 98 | return false; |
michael@0 | 99 | } |
michael@0 | 100 | minidump.Print(); |
michael@0 | 101 | |
michael@0 | 102 | int errors = 0; |
michael@0 | 103 | |
michael@0 | 104 | MinidumpThreadList *thread_list = minidump.GetThreadList(); |
michael@0 | 105 | if (!thread_list) { |
michael@0 | 106 | ++errors; |
michael@0 | 107 | BPLOG(ERROR) << "minidump.GetThreadList() failed"; |
michael@0 | 108 | } else { |
michael@0 | 109 | thread_list->Print(); |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | MinidumpModuleList *module_list = minidump.GetModuleList(); |
michael@0 | 113 | if (!module_list) { |
michael@0 | 114 | ++errors; |
michael@0 | 115 | BPLOG(ERROR) << "minidump.GetModuleList() failed"; |
michael@0 | 116 | } else { |
michael@0 | 117 | module_list->Print(); |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | MinidumpMemoryList *memory_list = minidump.GetMemoryList(); |
michael@0 | 121 | if (!memory_list) { |
michael@0 | 122 | ++errors; |
michael@0 | 123 | BPLOG(ERROR) << "minidump.GetMemoryList() failed"; |
michael@0 | 124 | } else { |
michael@0 | 125 | memory_list->Print(); |
michael@0 | 126 | } |
michael@0 | 127 | |
michael@0 | 128 | MinidumpException *exception = minidump.GetException(); |
michael@0 | 129 | if (!exception) { |
michael@0 | 130 | BPLOG(INFO) << "minidump.GetException() failed"; |
michael@0 | 131 | } else { |
michael@0 | 132 | exception->Print(); |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | MinidumpAssertion *assertion = minidump.GetAssertion(); |
michael@0 | 136 | if (!assertion) { |
michael@0 | 137 | BPLOG(INFO) << "minidump.GetAssertion() failed"; |
michael@0 | 138 | } else { |
michael@0 | 139 | assertion->Print(); |
michael@0 | 140 | } |
michael@0 | 141 | |
michael@0 | 142 | MinidumpSystemInfo *system_info = minidump.GetSystemInfo(); |
michael@0 | 143 | if (!system_info) { |
michael@0 | 144 | ++errors; |
michael@0 | 145 | BPLOG(ERROR) << "minidump.GetSystemInfo() failed"; |
michael@0 | 146 | } else { |
michael@0 | 147 | system_info->Print(); |
michael@0 | 148 | } |
michael@0 | 149 | |
michael@0 | 150 | MinidumpMiscInfo *misc_info = minidump.GetMiscInfo(); |
michael@0 | 151 | if (!misc_info) { |
michael@0 | 152 | ++errors; |
michael@0 | 153 | BPLOG(ERROR) << "minidump.GetMiscInfo() failed"; |
michael@0 | 154 | } else { |
michael@0 | 155 | misc_info->Print(); |
michael@0 | 156 | } |
michael@0 | 157 | |
michael@0 | 158 | MinidumpBreakpadInfo *breakpad_info = minidump.GetBreakpadInfo(); |
michael@0 | 159 | if (!breakpad_info) { |
michael@0 | 160 | // Breakpad info is optional, so don't treat this as an error. |
michael@0 | 161 | BPLOG(INFO) << "minidump.GetBreakpadInfo() failed"; |
michael@0 | 162 | } else { |
michael@0 | 163 | breakpad_info->Print(); |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | MinidumpMemoryInfoList *memory_info_list = minidump.GetMemoryInfoList(); |
michael@0 | 167 | if (!memory_info_list) { |
michael@0 | 168 | ++errors; |
michael@0 | 169 | BPLOG(ERROR) << "minidump.GetMemoryInfoList() failed"; |
michael@0 | 170 | } else { |
michael@0 | 171 | memory_info_list->Print(); |
michael@0 | 172 | } |
michael@0 | 173 | |
michael@0 | 174 | DumpRawStream(&minidump, |
michael@0 | 175 | MD_LINUX_CMD_LINE, |
michael@0 | 176 | "MD_LINUX_CMD_LINE", |
michael@0 | 177 | &errors); |
michael@0 | 178 | DumpRawStream(&minidump, |
michael@0 | 179 | MD_LINUX_ENVIRON, |
michael@0 | 180 | "MD_LINUX_ENVIRON", |
michael@0 | 181 | &errors); |
michael@0 | 182 | DumpRawStream(&minidump, |
michael@0 | 183 | MD_LINUX_LSB_RELEASE, |
michael@0 | 184 | "MD_LINUX_LSB_RELEASE", |
michael@0 | 185 | &errors); |
michael@0 | 186 | DumpRawStream(&minidump, |
michael@0 | 187 | MD_LINUX_PROC_STATUS, |
michael@0 | 188 | "MD_LINUX_PROC_STATUS", |
michael@0 | 189 | &errors); |
michael@0 | 190 | DumpRawStream(&minidump, |
michael@0 | 191 | MD_LINUX_CPU_INFO, |
michael@0 | 192 | "MD_LINUX_CPU_INFO", |
michael@0 | 193 | &errors); |
michael@0 | 194 | DumpRawStream(&minidump, |
michael@0 | 195 | MD_LINUX_MAPS, |
michael@0 | 196 | "MD_LINUX_MAPS", |
michael@0 | 197 | &errors); |
michael@0 | 198 | |
michael@0 | 199 | return errors == 0; |
michael@0 | 200 | } |
michael@0 | 201 | |
michael@0 | 202 | } // namespace |
michael@0 | 203 | |
michael@0 | 204 | int main(int argc, char **argv) { |
michael@0 | 205 | BPLOG_INIT(&argc, &argv); |
michael@0 | 206 | |
michael@0 | 207 | if (argc != 2) { |
michael@0 | 208 | fprintf(stderr, "usage: %s <file>\n", argv[0]); |
michael@0 | 209 | return 1; |
michael@0 | 210 | } |
michael@0 | 211 | |
michael@0 | 212 | return PrintMinidumpDump(argv[1]) ? 0 : 1; |
michael@0 | 213 | } |