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

Side by Side Diff: base/logging.h

Issue 1846373002: Revert of Patch to try dump-on-DCHECK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « base/debug/dump_without_crashing.cc ('k') | 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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cassert> 10 #include <cassert>
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity)) 630 LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity))
631 631
632 #define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) 632 #define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
633 633
634 #define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) 634 #define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
635 635
636 // Definitions for DCHECK et al. 636 // Definitions for DCHECK et al.
637 637
638 #if DCHECK_IS_ON() 638 #if DCHECK_IS_ON()
639 639
640 // If DCHECK is configured to dump-without-crashing then omit these, so that
641 // anything using them directly will break the build. See crbug.com/596231.
642 #if !defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
643
644 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ 640 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
645 COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__) 641 COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__)
646 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL 642 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL
647 const LogSeverity LOG_DCHECK = LOG_FATAL; 643 const LogSeverity LOG_DCHECK = LOG_FATAL;
648 644
649 #endif // !defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
650
651 #else // DCHECK_IS_ON() 645 #else // DCHECK_IS_ON()
652 646
653 // These are just dummy values. 647 // These are just dummy values.
654 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ 648 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
655 COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__) 649 COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__)
656 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO 650 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO
657 const LogSeverity LOG_DCHECK = LOG_INFO; 651 const LogSeverity LOG_DCHECK = LOG_INFO;
658 652
659 #endif // DCHECK_IS_ON() 653 #endif // DCHECK_IS_ON()
660 654
661 // DCHECK et al. make sure to reference |condition| regardless of 655 // DCHECK et al. make sure to reference |condition| regardless of
662 // whether DCHECKs are enabled; this is so that we don't get unused 656 // whether DCHECKs are enabled; this is so that we don't get unused
663 // variable warnings if the only use of a variable is in a DCHECK. 657 // variable warnings if the only use of a variable is in a DCHECK.
664 // This behavior is different from DLOG_IF et al. 658 // This behavior is different from DLOG_IF et al.
665 659
666 #if defined(_PREFAST_) && defined(OS_WIN) 660 #if defined(_PREFAST_) && defined(OS_WIN)
667 // See comments on the previous use of __analysis_assume. 661 // See comments on the previous use of __analysis_assume.
668 662
669 #if defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
670 #error "Only one of _PREFAST_ and DCHECK_IS_DUMP_WITHOUT_CRASH may be set"
671 #endif // defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
672
673 #define DCHECK(condition) \ 663 #define DCHECK(condition) \
674 __analysis_assume(!!(condition)), \ 664 __analysis_assume(!!(condition)), \
675 LAZY_STREAM(LOG_STREAM(DCHECK), false) \ 665 LAZY_STREAM(LOG_STREAM(DCHECK), false) \
676 << "Check failed: " #condition ". " 666 << "Check failed: " #condition ". "
677 667
678 #define DPCHECK(condition) \ 668 #define DPCHECK(condition) \
679 __analysis_assume(!!(condition)), \ 669 __analysis_assume(!!(condition)), \
680 LAZY_STREAM(PLOG_STREAM(DCHECK), false) \ 670 LAZY_STREAM(PLOG_STREAM(DCHECK), false) \
681 << "Check failed: " #condition ". " 671 << "Check failed: " #condition ". "
682 672
683 #elif DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH) 673 #else // _PREFAST_
684 // DCHECK is configured to dump-without-crashing, rather than logging.
685 // See crbug.com/596231.
686
687 BASE_EXPORT void DCheckDumpWithoutCrashing();
688
689 #define DCHECK(condition) \
690 (condition) ? (void)0 : logging::DCheckDumpWithoutCrashing(), \
691 EAT_STREAM_PARAMETERS
692
693 // Since we're uploading a crash dump, not logging, DPCHECK behaves identically.
694 #define DPCHECK(condition) DCHECK(condition)
695
696 #else // DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
697 674
698 #define DCHECK(condition) \ 675 #define DCHECK(condition) \
699 LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \ 676 LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \
700 << "Check failed: " #condition ". " 677 << "Check failed: " #condition ". "
701 678
702 #define DPCHECK(condition) \ 679 #define DPCHECK(condition) \
703 LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \ 680 LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \
704 << "Check failed: " #condition ". " 681 << "Check failed: " #condition ". "
705 682
706 #endif // DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH) 683 #endif // _PREFAST_
707 684
708 // Helper macro for binary operators. 685 // Helper macro for binary operators.
709 // Don't use this macro directly in your code, use DCHECK_EQ et al below. 686 // Don't use this macro directly in your code, use DCHECK_EQ et al below.
710
711 #if DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
712 // DCHECK is configured to dump-without-crashing, rather than logging.
713 // See crbug.com/596231.
714
715 // Use logging::Check*Impl() to ensure that operator<<()s don't go unused.
716 #define DCHECK_OP(name, op, val1, val2) \
717 DCHECK(logging::Check##name##Impl((val1), (val2), #val1 " " #op " " #val2))
718
719 #else // DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
720
721 // The 'switch' is used to prevent the 'else' from being ambiguous when the 687 // The 'switch' is used to prevent the 'else' from being ambiguous when the
722 // macro is used in an 'if' clause such as: 688 // macro is used in an 'if' clause such as:
723 // if (a == 1) 689 // if (a == 1)
724 // DCHECK_EQ(2, a); 690 // DCHECK_EQ(2, a);
725 #define DCHECK_OP(name, op, val1, val2) \ 691 #define DCHECK_OP(name, op, val1, val2) \
726 switch (0) case 0: default: \ 692 switch (0) case 0: default: \
727 if (logging::CheckOpResult true_if_passed = \ 693 if (logging::CheckOpResult true_if_passed = \
728 DCHECK_IS_ON() ? \ 694 DCHECK_IS_ON() ? \
729 logging::Check##name##Impl((val1), (val2), \ 695 logging::Check##name##Impl((val1), (val2), \
730 #val1 " " #op " " #val2) : nullptr) \ 696 #val1 " " #op " " #val2) : nullptr) \
731 ; \ 697 ; \
732 else \ 698 else \
733 logging::LogMessage(__FILE__, __LINE__, ::logging::LOG_DCHECK, \ 699 logging::LogMessage(__FILE__, __LINE__, ::logging::LOG_DCHECK, \
734 true_if_passed.message()).stream() 700 true_if_passed.message()).stream()
735 701
736 #endif // DCHECK_IS_ON() && defined(DCHECK_IS_DUMP_WITHOUT_CRASH)
737
738 // Equality/Inequality checks - compare two values, and log a 702 // Equality/Inequality checks - compare two values, and log a
739 // LOG_DCHECK message including the two values when the result is not 703 // LOG_DCHECK message including the two values when the result is not
740 // as expected. The values must have operator<<(ostream, ...) 704 // as expected. The values must have operator<<(ostream, ...)
741 // defined. 705 // defined.
742 // 706 //
743 // You may append to the error message like so: 707 // You may append to the error message like so:
744 // DCHECK_NE(1, 2) << ": The world must be ending!"; 708 // DCHECK_NE(1, 2) << ": The world must be ending!";
745 // 709 //
746 // We are very careful to ensure that each argument is evaluated exactly 710 // We are very careful to ensure that each argument is evaluated exactly
747 // once, and that anything which is legal to pass as a function argument is 711 // once, and that anything which is legal to pass as a function argument is
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 #elif NOTIMPLEMENTED_POLICY == 5 956 #elif NOTIMPLEMENTED_POLICY == 5
993 #define NOTIMPLEMENTED() do {\ 957 #define NOTIMPLEMENTED() do {\
994 static bool logged_once = false;\ 958 static bool logged_once = false;\
995 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 959 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
996 logged_once = true;\ 960 logged_once = true;\
997 } while(0);\ 961 } while(0);\
998 EAT_STREAM_PARAMETERS 962 EAT_STREAM_PARAMETERS
999 #endif 963 #endif
1000 964
1001 #endif // BASE_LOGGING_H_ 965 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « base/debug/dump_without_crashing.cc ('k') | base/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698