• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "gc_cause.h"
18 
19 #include <android-base/logging.h>
20 
21 #include "base/macros.h"
22 #include "runtime_globals.h"
23 
24 #include <ostream>
25 
26 namespace art {
27 namespace gc {
28 
PrettyCause(GcCause cause)29 const char* PrettyCause(GcCause cause) {
30   switch (cause) {
31     case kGcCauseNone: return "None";
32     case kGcCauseForAlloc: return "Alloc";
33     case kGcCauseBackground: return "Background";
34     case kGcCauseExplicit: return "Explicit";
35     case kGcCauseForNativeAlloc: return "NativeAlloc";
36     case kGcCauseCollectorTransition: return "CollectorTransition";
37     case kGcCauseDisableMovingGc: return "DisableMovingGc";
38     case kGcCauseHomogeneousSpaceCompact: return "HomogeneousSpaceCompact";
39     case kGcCauseTrim: return "HeapTrim";
40     case kGcCauseInstrumentation: return "Instrumentation";
41     case kGcCauseAddRemoveAppImageSpace: return "AddRemoveAppImageSpace";
42     case kGcCauseDebugger: return "Debugger";
43     case kGcCauseClassLinker: return "ClassLinker";
44     case kGcCauseJitCodeCache: return "JitCodeCache";
45     case kGcCauseAddRemoveSystemWeakHolder: return "SystemWeakHolder";
46     case kGcCauseHprof: return "Hprof";
47     case kGcCauseGetObjectsAllocated: return "ObjectsAllocated";
48     case kGcCauseProfileSaver: return "ProfileSaver";
49     case kGcCauseDeletingDexCacheArrays: return "DeletingDexCacheArrays";
50   }
51   LOG(FATAL) << "Unreachable";
52   UNREACHABLE();
53 }
54 
operator <<(std::ostream & os,const GcCause & gc_cause)55 std::ostream& operator<<(std::ostream& os, const GcCause& gc_cause) {
56   os << PrettyCause(gc_cause);
57   return os;
58 }
59 
60 }  // namespace gc
61 }  // namespace art
62