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

Side by Side Diff: base/logging.h

Issue 1124673004: Chrome OS: Reduce NOTREACHED() overhead for release builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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
« no previous file with comments | « no previous file | base/logging.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_LOGGING_H_ 5 #ifndef BASE_LOGGING_H_
6 #define BASE_LOGGING_H_ 6 #define BASE_LOGGING_H_
7 7
8 #include <cassert> 8 #include <cassert>
9 #include <string> 9 #include <string>
10 #include <cstring> 10 #include <cstring>
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 LAZY_STREAM(LOG_STREAM(DCHECK), false) \ 646 LAZY_STREAM(LOG_STREAM(DCHECK), false) \
647 << "Check failed: " #condition ". " 647 << "Check failed: " #condition ". "
648 648
649 #define DPCHECK(condition) \ 649 #define DPCHECK(condition) \
650 __analysis_assume(!!(condition)), \ 650 __analysis_assume(!!(condition)), \
651 LAZY_STREAM(PLOG_STREAM(DCHECK), false) \ 651 LAZY_STREAM(PLOG_STREAM(DCHECK), false) \
652 << "Check failed: " #condition ". " 652 << "Check failed: " #condition ". "
653 653
654 #else // _PREFAST_ 654 #else // _PREFAST_
655 655
656 #define DCHECK(condition) \ 656 #define DCHECK(condition) \
657 LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \ 657 LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \
danakj 2015/05/04 18:21:46 This is unrelated, please don't lump multiple logi
Thiemo Nagel 2015/05/04 19:15:47 Done.
658 << "Check failed: " #condition ". " 658 << "Check failed: " #condition ". "
659 659
660 #define DPCHECK(condition) \ 660 #define DPCHECK(condition) \
661 LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \ 661 LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \
662 << "Check failed: " #condition ". " 662 << "Check failed: " #condition ". "
663 663
664 #endif // _PREFAST_ 664 #endif // _PREFAST_
665 665
666 // Helper macro for binary operators. 666 // Helper macro for binary operators.
667 // Don't use this macro directly in your code, use DCHECK_EQ et al below. 667 // Don't use this macro directly in your code, use DCHECK_EQ et al below.
668 #define DCHECK_OP(name, op, val1, val2) \ 668 #define DCHECK_OP(name, op, val1, val2) \
669 if (DCHECK_IS_ON()) \ 669 if (DCHECK_IS_ON()) \
670 if (std::string* _result = logging::Check##name##Impl( \ 670 if (std::string* _result = logging::Check##name##Impl( \
671 (val1), (val2), #val1 " " #op " " #val2)) \ 671 (val1), (val2), #val1 " " #op " " #val2)) \
(...skipping 21 matching lines...) Expand all
693 693
694 #define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2) 694 #define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
695 #define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2) 695 #define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2)
696 #define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2) 696 #define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2)
697 #define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2) 697 #define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2)
698 #define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) 698 #define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
699 #define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2) 699 #define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2)
700 #define DCHECK_IMPLIES(val1, val2) DCHECK(!(val1) || (val2)) 700 #define DCHECK_IMPLIES(val1, val2) DCHECK(!(val1) || (val2))
701 701
702 #if !DCHECK_IS_ON() && defined(OS_CHROMEOS) 702 #if !DCHECK_IS_ON() && defined(OS_CHROMEOS)
703 #define NOTREACHED() LOG(ERROR) << "NOTREACHED() hit in " << \ 703 // Implement logging of NOTREACHED() as a dedicated function to get function
704 __FUNCTION__ << ". " 704 // call overhead down to a minimum.
705 void LogErrorNotReached(const char* file, int line, const char* function_name);
706 #define NOTREACHED() \
707 true ? ::logging::LogErrorNotReached(__FILE__, __LINE__, __FUNCTION__) \
danakj 2015/05/04 18:27:41 what's the point of the ternary that's always true
Thiemo Nagel 2015/05/04 19:15:47 The ternary is used as a binder so that EAT_STREAM
708 : EAT_STREAM_PARAMETERS
705 #else 709 #else
706 #define NOTREACHED() DCHECK(false) 710 #define NOTREACHED() DCHECK(false)
707 #endif 711 #endif
708 712
709 // Redefine the standard assert to use our nice log files 713 // Redefine the standard assert to use our nice log files
710 #undef assert 714 #undef assert
711 #define assert(x) DLOG_ASSERT(x) 715 #define assert(x) DLOG_ASSERT(x)
712 716
713 // This class more or less represents a particular log message. You 717 // This class more or less represents a particular log message. You
714 // create an instance of LogMessage and then stream stuff to it. 718 // create an instance of LogMessage and then stream stuff to it.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 #elif NOTIMPLEMENTED_POLICY == 5 930 #elif NOTIMPLEMENTED_POLICY == 5
927 #define NOTIMPLEMENTED() do {\ 931 #define NOTIMPLEMENTED() do {\
928 static bool logged_once = false;\ 932 static bool logged_once = false;\
929 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 933 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
930 logged_once = true;\ 934 logged_once = true;\
931 } while(0);\ 935 } while(0);\
932 EAT_STREAM_PARAMETERS 936 EAT_STREAM_PARAMETERS
933 #endif 937 #endif
934 938
935 #endif // BASE_LOGGING_H_ 939 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | base/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698