1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BASE_DEBUG_ALIAS_H_
6 #define THIRD_PARTY_BASE_DEBUG_ALIAS_H_
7 
8 namespace pdfium {
9 namespace base {
10 namespace debug {
11 
12 // Make the optimizer think that var is aliased. This is to prevent it from
13 // optimizing out local variables that would not otherwise be live at the point
14 // of a potential crash.
15 // base::debug::Alias should only be used for local variables, not globals,
16 // object members, or function return values - these must be copied to locals if
17 // you want to ensure they are recorded in crash dumps.
18 // Note that if the local variable is a pointer then its value will be retained
19 // but the memory that it points to will probably not be saved in the crash
20 // dump - by default only stack memory is saved. Therefore the aliasing
21 // technique is usually only worthwhile with non-pointer variables. If you have
22 // a pointer to an object and you want to retain the object's state you need to
23 // copy the object or its fields to local variables. Example usage:
24 //   int last_error = err_;
25 //   base::debug::Alias(&last_error);
26 //   DEBUG_ALIAS_FOR_CSTR(name_copy, p->name, 16);
27 //   CHECK(false);
28 void Alias(const void* var);
29 
30 }  // namespace debug
31 }  // namespace base
32 }  // namespace pdfium
33 
34 #endif  // THIRD_PARTY_BASE_DEBUG_ALIAS_H_
35