Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: syzygy/agent/asan/reporters/crashpad_reporter.cc

Issue 2576003002: Add the ability to defer the initialization of the SyzyAsan crash reporter. (Closed)
Patch Set: Add an entry point to reinitialize the crash reporter. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 Google Inc. All Rights Reserved. 1 // Copyright 2016 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // doesn't generalize to other clients. Moving forward we will be adding a 42 // doesn't generalize to other clients. Moving forward we will be adding a
43 // generic callback mechanism for instrumented clients to inform the RTL of the 43 // generic callback mechanism for instrumented clients to inform the RTL of the
44 // crash handler to use. 44 // crash handler to use.
45 bool EnsureCrashpadConnected() { 45 bool EnsureCrashpadConnected() {
46 static bool initialized = false; 46 static bool initialized = false;
47 static bool crashpad_present = false; 47 static bool crashpad_present = false;
48 48
49 // Only initialize once. 49 // Only initialize once.
50 if (initialized) 50 if (initialized)
51 return crashpad_present; 51 return crashpad_present;
52 initialized = true;
53 52
54 // Get the name of the crashpad endpoint, failing if none exists. 53 // Get the name of the crashpad endpoint, failing if none exists.
55 std::unique_ptr<base::Environment> env(base::Environment::Create()); 54 std::unique_ptr<base::Environment> env(base::Environment::Create());
56 std::string pipe_name; 55 std::string pipe_name;
57 if (!env->GetVar(kCrashpadPipeNameVar, &pipe_name)) 56 if (!env->GetVar(kCrashpadPipeNameVar, &pipe_name))
58 return false; 57 return false;
58
59 // Only flip the initialization bit once we've been able to read the
60 // environment variable to make this work if Crashpad wasn't present
61 // during the process initialization but is here later.
62 initialized = true;
59 std::wstring pipe_name_w = base::UTF8ToWide(pipe_name); 63 std::wstring pipe_name_w = base::UTF8ToWide(pipe_name);
60 64
61 // Initialize the crashpad client. 65 // Initialize the crashpad client.
62 if (!g_crashpad_client.SetHandlerIPCPipe(pipe_name_w)) 66 if (!g_crashpad_client.SetHandlerIPCPipe(pipe_name_w))
63 return false; 67 return false;
64 if (!g_crashpad_client.UseHandler()) 68 if (!g_crashpad_client.UseHandler())
65 return false; 69 return false;
66 70
67 crashpad_present = true; 71 crashpad_present = true;
68 return true; 72 return true;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 crashpad_info->set_system_crash_reporter_forwarding( 181 crashpad_info->set_system_crash_reporter_forwarding(
178 crashpad::TriState::kDisabled); 182 crashpad::TriState::kDisabled);
179 crashpad_info->set_gather_indirectly_referenced_memory( 183 crashpad_info->set_gather_indirectly_referenced_memory(
180 crashpad::TriState::kEnabled, 1 * 1024 * 1024); 184 crashpad::TriState::kEnabled, 1 * 1024 * 1024);
181 crashpad_info->set_simple_annotations(crash_keys_.get()); 185 crashpad_info->set_simple_annotations(crash_keys_.get());
182 } 186 }
183 187
184 } // namespace reporters 188 } // namespace reporters
185 } // namespace asan 189 } // namespace asan
186 } // namespace agent 190 } // namespace agent
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698