diff options
author | 2012-04-04 16:53:10 -0700 | |
---|---|---|
committer | 2012-04-04 16:53:10 -0700 | |
commit | 460384f04f933f94546db7bfbfa02896b9e77962 (patch) | |
tree | e95299a4a62f63c9a3ca981d26993f440f2b02c0 | |
parent | 5e284224e5525ee0a8494a73d84c8ef86e022a0a (diff) |
Use the operator<< generator more widely.
Change-Id: Iae3b8f32f49f4c91cd41c53bbafb95db071d57bb
-rw-r--r-- | build/Android.common.mk | 4 | ||||
-rw-r--r-- | jdwpspy/Android.mk | 4 | ||||
-rw-r--r-- | jdwpspy/Net.cpp | 2 | ||||
-rw-r--r-- | jdwpspy/find_JdwpConstants.cpp | 1 | ||||
-rw-r--r-- | src/dex_verifier.cc | 23 | ||||
-rw-r--r-- | src/dex_verifier.h | 137 | ||||
-rw-r--r-- | src/jdwp/jdwp_constants.cc | 210 | ||||
-rw-r--r-- | src/jdwp/jdwp_constants.h | 16 | ||||
-rw-r--r-- | src/jdwp/jdwp_main.cc | 50 | ||||
-rwxr-xr-x | tools/generate-operator-out.py | 59 |
10 files changed, 132 insertions, 374 deletions
diff --git a/build/Android.common.mk b/build/Android.common.mk index 28ac65bb3e..8191b43bed 100644 --- a/build/Android.common.mk +++ b/build/Android.common.mk @@ -145,7 +145,6 @@ LIBART_COMMON_SRC_FILES := \ src/java_lang_reflect_Method.cc \ src/java_lang_reflect_Proxy.cc \ src/java_util_concurrent_atomic_AtomicLong.cc \ - src/jdwp/jdwp_constants.cc \ src/jdwp/jdwp_event.cc \ src/jdwp/jdwp_expand_buf.cc \ src/jdwp/jdwp_handler.cc \ @@ -268,9 +267,12 @@ $(error unsupported HOST_ARCH=$(HOST_ARCH)) endif # HOST_ARCH != x86 LIBART_ENUM_OPERATOR_OUT_HEADER_FILES := \ + src/dex_verifier.h \ src/indirect_reference_table.h \ src/instruction_set.h \ src/invoke_type.h \ + src/jdwp/jdwp.h \ + src/jdwp/jdwp_constants.h \ src/mutex.h LIBARTTEST_COMMON_SRC_FILES := \ diff --git a/jdwpspy/Android.mk b/jdwpspy/Android.mk index 60ccb38ddc..a6c2f64046 100644 --- a/jdwpspy/Android.mk +++ b/jdwpspy/Android.mk @@ -5,8 +5,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ Main.cpp \ - Net.cpp \ - find_JdwpConstants.cpp + Net.cpp LOCAL_C_INCLUDES += \ art/src @@ -14,4 +13,3 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE := jdwpspy include $(BUILD_HOST_EXECUTABLE) - diff --git a/jdwpspy/Net.cpp b/jdwpspy/Net.cpp index abcae2144a..55515f1e0a 100644 --- a/jdwpspy/Net.cpp +++ b/jdwpspy/Net.cpp @@ -510,7 +510,7 @@ static void dumpPacket(const unsigned char* packetBuf, const char* srcName, printf("%s --> %s\n", prefix, getCommandName(cmdSet, cmd)); } else { std::ostringstream ss; - ss << error; + ss << "TODO"; // get access to the operator<<, or regenerate it for jdwpspy? printf("%s REPLY dataLen=%-5u id=0x%08x flags=0x%02x err=%d (%s) [%02d:%02d]\n", prefix, dataLen, id, flags, error, ss.str().c_str(), min,sec); } diff --git a/jdwpspy/find_JdwpConstants.cpp b/jdwpspy/find_JdwpConstants.cpp deleted file mode 100644 index d035d2e0f4..0000000000 --- a/jdwpspy/find_JdwpConstants.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "jdwp/jdwp_constants.cc" diff --git a/src/dex_verifier.cc b/src/dex_verifier.cc index 987777ce6e..f02379c84a 100644 --- a/src/dex_verifier.cc +++ b/src/dex_verifier.cc @@ -43,26 +43,6 @@ namespace verifier { static const bool gDebugVerify = false; -std::ostream& operator<<(std::ostream& os, const VerifyError& rhs) { - switch (rhs) { - case VERIFY_ERROR_NONE: os << "VERIFY_ERROR_NONE"; break; - case VERIFY_ERROR_BAD_CLASS_HARD: os << "VERIFY_ERROR_BAD_CLASS_HARD"; break; - case VERIFY_ERROR_BAD_CLASS_SOFT: os << "VERIFY_ERROR_BAD_CLASS_SOFT"; break; - case VERIFY_ERROR_NO_CLASS: os << "VERIFY_ERROR_NO_CLASS"; break; - case VERIFY_ERROR_NO_FIELD: os << "VERIFY_ERROR_NO_FIELD"; break; - case VERIFY_ERROR_NO_METHOD: os << "VERIFY_ERROR_NO_METHOD"; break; - case VERIFY_ERROR_ACCESS_CLASS: os << "VERIFY_ERROR_ACCESS_CLASS"; break; - case VERIFY_ERROR_ACCESS_FIELD: os << "VERIFY_ERROR_ACCESS_FIELD"; break; - case VERIFY_ERROR_ACCESS_METHOD: os << "VERIFY_ERROR_ACCESS_METHOD"; break; - case VERIFY_ERROR_CLASS_CHANGE: os << "VERIFY_ERROR_CLASS_CHANGE"; break; - case VERIFY_ERROR_INSTANTIATION: os << "VERIFY_ERROR_INSTANTIATION"; break; - default: - os << "VerifyError[" << static_cast<int>(rhs) << "]"; - break; - } - return os; -} - static const char* type_strings[] = { "Unknown", "Conflict", @@ -1681,8 +1661,7 @@ bool DexVerifier::VerifyCodeFlow() { << " insns_size=" << insns_size << ")"; } /* Create and initialize table holding register status */ - reg_table_.Init(PcToRegisterLineTable::kTrackRegsGcPoints, insn_flags_.get(), insns_size, - registers_size, this); + reg_table_.Init(kTrackRegsGcPoints, insn_flags_.get(), insns_size, registers_size, this); work_line_.reset(new RegisterLine(registers_size, this)); saved_line_.reset(new RegisterLine(registers_size, this)); diff --git a/src/dex_verifier.h b/src/dex_verifier.h index ee36f5380d..ce6963dd86 100644 --- a/src/dex_verifier.h +++ b/src/dex_verifier.h @@ -39,7 +39,7 @@ struct ReferenceMap2Visitor; #if defined(ART_USE_LLVM_COMPILER) namespace compiler_llvm { class InferredRegCategoryMap; -} +} // namespace compiler_llvm #endif namespace verifier { @@ -61,31 +61,31 @@ class RegTypeCache; class RegType { public: enum Type { - kRegTypeUnknown = 0, /* initial state */ - kRegTypeConflict, /* merge clash makes this reg's type unknowable */ - kRegTypeBoolean, /* Z */ + kRegTypeUnknown = 0, // Initial state. + kRegTypeConflict, // Merge clash makes this reg's type unknowable. + kRegTypeBoolean, // Z. kRegType1nrSTART = kRegTypeBoolean, kRegTypeIntegralSTART = kRegTypeBoolean, - kRegTypeByte, /* B */ - kRegTypeShort, /* S */ - kRegTypeChar, /* C */ - kRegTypeInteger, /* I */ + kRegTypeByte, // B. + kRegTypeShort, // S. + kRegTypeChar, // C. + kRegTypeInteger, // I. kRegTypeIntegralEND = kRegTypeInteger, - kRegTypeFloat, /* F */ + kRegTypeFloat, // F. kRegType1nrEND = kRegTypeFloat, - kRegTypeLongLo, /* J - lower-numbered register; endian-independent */ + kRegTypeLongLo, // J - lower-numbered register; endian-independent. kRegTypeLongHi, - kRegTypeDoubleLo, /* D */ + kRegTypeDoubleLo, // D. kRegTypeDoubleHi, - kRegTypeConstLo, /* const derived wide, lower half - could be long or double */ - kRegTypeConstHi, /* const derived wide, upper half - could be long or double */ + kRegTypeConstLo, // Const derived wide, lower half - could be long or double. + kRegTypeConstHi, // Const derived wide, upper half - could be long or double. kRegTypeLastFixedLocation = kRegTypeConstHi, - kRegTypeConst, /* 32-bit constant derived value - could be float or int */ - kRegTypeUnresolvedReference, // Reference type that couldn't be resolved - kRegTypeUninitializedReference, // Freshly allocated reference type - kRegTypeUninitializedThisReference, // Freshly allocated reference passed as "this" - kRegTypeUnresolvedAndUninitializedReference, // Freshly allocated unresolved reference type - kRegTypeReference, // Reference type + kRegTypeConst, // 32-bit constant derived value - could be float or int. + kRegTypeUnresolvedReference, // Reference type that couldn't be resolved. + kRegTypeUninitializedReference, // Freshly allocated reference type. + kRegTypeUninitializedThisReference, // Freshly allocated reference passed as "this". + kRegTypeUnresolvedAndUninitializedReference, // Freshly allocated unresolved reference type. + kRegTypeReference, // Reference type. }; Type GetType() const { @@ -422,53 +422,53 @@ class InsnFlags { } void SetInTry() { - flags_ |= 1 << kInsnFlagInTry; + flags_ |= 1 << kInTry; } void ClearInTry() { - flags_ &= ~(1 << kInsnFlagInTry); + flags_ &= ~(1 << kInTry); } bool IsInTry() const { - return (flags_ & (1 << kInsnFlagInTry)) != 0; + return (flags_ & (1 << kInTry)) != 0; } void SetBranchTarget() { - flags_ |= 1 << kInsnFlagBranchTarget; + flags_ |= 1 << kBranchTarget; } void ClearBranchTarget() { - flags_ &= ~(1 << kInsnFlagBranchTarget); + flags_ &= ~(1 << kBranchTarget); } bool IsBranchTarget() const { - return (flags_ & (1 << kInsnFlagBranchTarget)) != 0; + return (flags_ & (1 << kBranchTarget)) != 0; } void SetGcPoint() { - flags_ |= 1 << kInsnFlagGcPoint; + flags_ |= 1 << kGcPoint; } void ClearGcPoint() { - flags_ &= ~(1 << kInsnFlagGcPoint); + flags_ &= ~(1 << kGcPoint); } bool IsGcPoint() const { - return (flags_ & (1 << kInsnFlagGcPoint)) != 0; + return (flags_ & (1 << kGcPoint)) != 0; } void SetVisited() { - flags_ |= 1 << kInsnFlagVisited; + flags_ |= 1 << kVisited; } void ClearVisited() { - flags_ &= ~(1 << kInsnFlagVisited); + flags_ &= ~(1 << kVisited); } bool IsVisited() const { - return (flags_ & (1 << kInsnFlagVisited)) != 0; + return (flags_ & (1 << kVisited)) != 0; } void SetChanged() { - flags_ |= 1 << kInsnFlagChanged; + flags_ |= 1 << kChanged; } void ClearChanged() { - flags_ &= ~(1 << kInsnFlagChanged); + flags_ &= ~(1 << kChanged); } bool IsChanged() const { - return (flags_ & (1 << kInsnFlagChanged)) != 0; + return (flags_ & (1 << kChanged)) != 0; } bool IsVisitedOrChanged() const { @@ -481,21 +481,21 @@ class InsnFlags { strncpy(encoding, "XXXXX", sizeof(encoding)); } else { strncpy(encoding, "-----", sizeof(encoding)); - if (IsInTry()) encoding[kInsnFlagInTry] = 'T'; - if (IsBranchTarget()) encoding[kInsnFlagBranchTarget] = 'B'; - if (IsGcPoint()) encoding[kInsnFlagGcPoint] = 'G'; - if (IsVisited()) encoding[kInsnFlagVisited] = 'V'; - if (IsChanged()) encoding[kInsnFlagChanged] = 'C'; + if (IsInTry()) encoding[kInTry] = 'T'; + if (IsBranchTarget()) encoding[kBranchTarget] = 'B'; + if (IsGcPoint()) encoding[kGcPoint] = 'G'; + if (IsVisited()) encoding[kVisited] = 'V'; + if (IsChanged()) encoding[kChanged] = 'C'; } return std::string(encoding); } private: - enum InsnFlag { - kInsnFlagInTry, - kInsnFlagBranchTarget, - kInsnFlagGcPoint, - kInsnFlagVisited, - kInsnFlagChanged, + enum { + kInTry, + kBranchTarget, + kGcPoint, + kVisited, + kChanged, }; // Size of instruction in code units @@ -547,18 +547,18 @@ enum TypeCategory { * to be rewritten to fail at runtime. */ enum VerifyError { - VERIFY_ERROR_NONE = 0, /* no error; must be zero */ - VERIFY_ERROR_BAD_CLASS_HARD, /* VerifyError; hard error that skips compilation */ - VERIFY_ERROR_BAD_CLASS_SOFT, /* VerifyError; soft error that verifies again at runtime */ - - VERIFY_ERROR_NO_CLASS, /* NoClassDefFoundError */ - VERIFY_ERROR_NO_FIELD, /* NoSuchFieldError */ - VERIFY_ERROR_NO_METHOD, /* NoSuchMethodError */ - VERIFY_ERROR_ACCESS_CLASS, /* IllegalAccessError */ - VERIFY_ERROR_ACCESS_FIELD, /* IllegalAccessError */ - VERIFY_ERROR_ACCESS_METHOD, /* IllegalAccessError */ - VERIFY_ERROR_CLASS_CHANGE, /* IncompatibleClassChangeError */ - VERIFY_ERROR_INSTANTIATION, /* InstantiationError */ + VERIFY_ERROR_NONE = 0, // No error; must be zero. + VERIFY_ERROR_BAD_CLASS_HARD, // VerifyError; hard error that skips compilation. + VERIFY_ERROR_BAD_CLASS_SOFT, // VerifyError; soft error that verifies again at runtime. + + VERIFY_ERROR_NO_CLASS, // NoClassDefFoundError. + VERIFY_ERROR_NO_FIELD, // NoSuchFieldError. + VERIFY_ERROR_NO_METHOD, // NoSuchMethodError. + VERIFY_ERROR_ACCESS_CLASS, // IllegalAccessError. + VERIFY_ERROR_ACCESS_FIELD, // IllegalAccessError. + VERIFY_ERROR_ACCESS_METHOD, // IllegalAccessError. + VERIFY_ERROR_CLASS_CHANGE, // IncompatibleClassChangeError. + VERIFY_ERROR_INSTANTIATION, // InstantiationError. }; std::ostream& operator<<(std::ostream& os, const VerifyError& rhs); @@ -580,9 +580,9 @@ const int kVerifyErrorRefTypeShift = 6; */ enum RegisterMapFormat { kRegMapFormatUnknown = 0, - kRegMapFormatNone = 1, /* indicates no map data follows */ - kRegMapFormatCompact8 = 2, /* compact layout, 8-bit addresses */ - kRegMapFormatCompact16 = 3, /* compact layout, 16-bit addresses */ + kRegMapFormatNone = 1, // Indicates no map data follows. + kRegMapFormatCompact8 = 2, // Compact layout, 8-bit addresses. + kRegMapFormatCompact16 = 3, // Compact layout, 16-bit addresses. }; const int kRegMapFormatShift = 5; const uint8_t kRegMapFormatMask = 0x7; @@ -838,16 +838,17 @@ class RegisterLine { }; std::ostream& operator<<(std::ostream& os, const RegisterLine& rhs); +// We don't need to store the register data for many instructions, because we either only need +// it at branch points (for verification) or GC points and branches (for verification + +// type-precise register analysis). +enum RegisterTrackingMode { + kTrackRegsBranches, + kTrackRegsGcPoints, + kTrackRegsAll, +}; + class PcToRegisterLineTable { public: - // We don't need to store the register data for many instructions, because we either only need - // it at branch points (for verification) or GC points and branches (for verification + - // type-precise register analysis). - enum RegisterTrackingMode { - kTrackRegsBranches, - kTrackRegsGcPoints, - kTrackRegsAll, - }; PcToRegisterLineTable() {} ~PcToRegisterLineTable() { STLDeleteValues(&pc_to_register_line_); diff --git a/src/jdwp/jdwp_constants.cc b/src/jdwp/jdwp_constants.cc deleted file mode 100644 index 15057eaeed..0000000000 --- a/src/jdwp/jdwp_constants.cc +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * String constants to go along with enumerated values. (Pity we don't - * have enumerated constant reflection in C.) These are only needed for - * making the output human-readable. - */ -#include "jdwp/jdwp_constants.h" - -#include <iostream> - -namespace art { - -namespace JDWP { - -std::ostream& operator<<(std::ostream& os, const JdwpError& rhs) { - switch (rhs) { - case ERR_NONE: os << "NONE"; break; - case ERR_INVALID_THREAD: os << "INVALID_THREAD"; break; - case ERR_INVALID_THREAD_GROUP: os << "INVALID_THREAD_GROUP"; break; - case ERR_INVALID_PRIORITY: os << "INVALID_PRIORITY"; break; - case ERR_THREAD_NOT_SUSPENDED: os << "THREAD_NOT_SUSPENDED"; break; - case ERR_THREAD_SUSPENDED: os << "THREAD_SUSPENDED"; break; - case ERR_THREAD_NOT_ALIVE: os << "THREAD_NOT_ALIVE"; break; - case ERR_INVALID_OBJECT: os << "INVALID_OBJEC"; break; - case ERR_INVALID_CLASS: os << "INVALID_CLASS"; break; - case ERR_CLASS_NOT_PREPARED: os << "CLASS_NOT_PREPARED"; break; - case ERR_INVALID_METHODID: os << "INVALID_METHODID"; break; - case ERR_INVALID_LOCATION: os << "INVALID_LOCATION"; break; - case ERR_INVALID_FIELDID: os << "INVALID_FIELDID"; break; - case ERR_INVALID_FRAMEID: os << "INVALID_FRAMEID"; break; - case ERR_NO_MORE_FRAMES: os << "NO_MORE_FRAMES"; break; - case ERR_OPAQUE_FRAME: os << "OPAQUE_FRAME"; break; - case ERR_NOT_CURRENT_FRAME: os << "NOT_CURRENT_FRAME"; break; - case ERR_TYPE_MISMATCH: os << "TYPE_MISMATCH"; break; - case ERR_INVALID_SLOT: os << "INVALID_SLOT"; break; - case ERR_DUPLICATE: os << "DUPLICATE"; break; - case ERR_NOT_FOUND: os << "NOT_FOUND"; break; - case ERR_INVALID_MONITOR: os << "INVALID_MONITOR"; break; - case ERR_NOT_MONITOR_OWNER: os << "NOT_MONITOR_OWNER"; break; - case ERR_INTERRUPT: os << "INTERRUPT"; break; - case ERR_INVALID_CLASS_FORMAT: os << "INVALID_CLASS_FORMAT"; break; - case ERR_CIRCULAR_CLASS_DEFINITION: os << "CIRCULAR_CLASS_DEFINITION"; break; - case ERR_FAILS_VERIFICATION: os << "FAILS_VERIFICATION"; break; - case ERR_ADD_METHOD_NOT_IMPLEMENTED: os << "ADD_METHOD_NOT_IMPLEMENTED"; break; - case ERR_SCHEMA_CHANGE_NOT_IMPLEMENTED: os << "SCHEMA_CHANGE_NOT_IMPLEMENTED"; break; - case ERR_INVALID_TYPESTATE: os << "INVALID_TYPESTATE"; break; - case ERR_HIERARCHY_CHANGE_NOT_IMPLEMENTED: os << "HIERARCHY_CHANGE_NOT_IMPLEMENTED"; break; - case ERR_DELETE_METHOD_NOT_IMPLEMENTED: os << "DELETE_METHOD_NOT_IMPLEMENTED"; break; - case ERR_UNSUPPORTED_VERSION: os << "UNSUPPORTED_VERSION"; break; - case ERR_NAMES_DONT_MATCH: os << "NAMES_DONT_MATCH"; break; - case ERR_CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED: os << "CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED"; break; - case ERR_METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED: os << "METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED"; break; - case ERR_NOT_IMPLEMENTED: os << "NOT_IMPLEMENTED"; break; - case ERR_NULL_POINTER: os << "NULL_POINTER"; break; - case ERR_ABSENT_INFORMATION: os << "ABSENT_INFORMATION"; break; - case ERR_INVALID_EVENT_TYPE: os << "INVALID_EVENT_TYPE"; break; - case ERR_ILLEGAL_ARGUMENT: os << "ILLEGAL_ARGUMENT"; break; - case ERR_OUT_OF_MEMORY: os << "OUT_OF_MEMORY"; break; - case ERR_ACCESS_DENIED: os << "ACCESS_DENIED"; break; - case ERR_VM_DEAD: os << "VM_DEAD"; break; - case ERR_INTERNAL: os << "INTERNAL"; break; - case ERR_UNATTACHED_THREAD: os << "UNATTACHED_THREAD"; break; - case ERR_INVALID_TAG: os << "INVALID_TAG"; break; - case ERR_ALREADY_INVOKING: os << "ALREADY_INVOKING"; break; - case ERR_INVALID_INDEX: os << "INVALID_INDEX"; break; - case ERR_INVALID_LENGTH: os << "INVALID_LENGTH"; break; - case ERR_INVALID_STRING: os << "INVALID_STRING"; break; - case ERR_INVALID_CLASS_LOADER: os << "INVALID_CLASS_LOADER"; break; - case ERR_INVALID_ARRAY: os << "INVALID_ARRAY"; break; - case ERR_TRANSPORT_LOAD: os << "TRANSPORT_LOAD"; break; - case ERR_TRANSPORT_INIT: os << "TRANSPORT_INIT"; break; - case ERR_NATIVE_METHOD: os << "NATIVE_METHOD"; break; - case ERR_INVALID_COUNT: os << "INVALID_COUNT"; break; - default: - os << "JdwpError[" << static_cast<int>(rhs) << "]"; - break; - } - return os; -} - -std::ostream& operator<<(std::ostream& os, const JdwpEventKind& rhs) { - switch (rhs) { - case EK_SINGLE_STEP: os << "SINGLE_STEP"; break; - case EK_BREAKPOINT: os << "BREAKPOINT"; break; - case EK_FRAME_POP: os << "FRAME_POP"; break; - case EK_EXCEPTION: os << "EXCEPTION"; break; - case EK_USER_DEFINED: os << "USER_DEFINED"; break; - case EK_THREAD_START: os << "THREAD_START"; break; - case EK_THREAD_DEATH: os << "THREAD_DEATH"; break; - case EK_CLASS_PREPARE: os << "CLASS_PREPARE"; break; - case EK_CLASS_UNLOAD: os << "CLASS_UNLOAD"; break; - case EK_CLASS_LOAD: os << "CLASS_LOAD"; break; - case EK_FIELD_ACCESS: os << "FIELD_ACCESS"; break; - case EK_FIELD_MODIFICATION: os << "FIELD_MODIFICATION"; break; - case EK_EXCEPTION_CATCH: os << "EXCEPTION_CATCH"; break; - case EK_METHOD_ENTRY: os << "METHOD_ENTRY"; break; - case EK_METHOD_EXIT: os << "METHOD_EXIT"; break; - case EK_METHOD_EXIT_WITH_RETURN_VALUE: os << "METHOD_EXIT_WITH_RETURN_VALUE"; break; - case EK_MONITOR_CONTENDED_ENTER: os << "MONITOR_CONTENDED_ENTER"; break; - case EK_MONITOR_CONTENDED_ENTERED: os << "MONITOR_CONTENDED_ENTERED"; break; - case EK_MONITOR_WAIT: os << "MONITOR_WAIT"; break; - case EK_MONITOR_WAITED: os << "MONITOR_WAITED"; break; - case EK_VM_START: os << "VM_START"; break; - case EK_VM_DEATH: os << "VM_DEATH"; break; - case EK_VM_DISCONNECTED: os << "VM_DISCONNECTED"; break; - default: - os << "JdwpEventKind[" << static_cast<int>(rhs) << "]"; - break; - } - return os; -} - -std::ostream& operator<<(std::ostream& os, const JdwpModKind& rhs) { - switch (rhs) { - case MK_COUNT: os << "COUNT"; break; - case MK_CONDITIONAL: os << "CONDITIONAL"; break; - case MK_THREAD_ONLY: os << "THREAD_ONLY"; break; - case MK_CLASS_ONLY: os << "CLASS_ONLY"; break; - case MK_CLASS_MATCH: os << "CLASS_MATCH"; break; - case MK_CLASS_EXCLUDE: os << "CLASS_EXCLUDE"; break; - case MK_LOCATION_ONLY: os << "LOCATION_ONLY"; break; - case MK_EXCEPTION_ONLY: os << "EXCEPTION_ONLY"; break; - case MK_FIELD_ONLY: os << "FIELD_ONLY"; break; - case MK_STEP: os << "STEP"; break; - case MK_INSTANCE_ONLY: os << "INSTANCE_ONLY"; break; - case MK_SOURCE_NAME_MATCH: os << "SOURCE_NAME_MATCH"; break; - default: - os << "JdwpModKind[" << static_cast<int>(rhs) << "]"; - break; - } - return os; -} - -std::ostream& operator<<(std::ostream& os, const JdwpStepDepth& rhs) { - switch (rhs) { - case SD_INTO: os << "INTO"; break; - case SD_OVER: os << "OVER"; break; - case SD_OUT: os << "OUT"; break; - default: - os << "JdwpStepDepth[" << static_cast<int>(rhs) << "]"; - break; - } - return os; -} - -std::ostream& operator<<(std::ostream& os, const JdwpStepSize& rhs) { - switch (rhs) { - case SS_MIN: os << "MIN"; break; - case SS_LINE: os << "LINE"; break; - default: - os << "JdwpStepSize[" << static_cast<int>(rhs) << "]"; - break; - } - return os; -} - -std::ostream& operator<<(std::ostream& os, const JdwpSuspendPolicy& rhs) { - switch (rhs) { - case SP_NONE: os << "NONE"; break; - case SP_EVENT_THREAD: os << "EVENT_THREAD"; break; - case SP_ALL: os << "ALL"; break; - default: - os << "JdwpSuspendPolicy[" << static_cast<int>(rhs) << "]"; - break; - } - return os; -} - -std::ostream& operator<<(std::ostream& os, const JdwpSuspendStatus& rhs) { - switch (rhs) { - case SUSPEND_STATUS_NOT_SUSPENDED: os << "NOT SUSPENDED"; break; - case SUSPEND_STATUS_SUSPENDED: os << "SUSPENDED"; break; - default: - os << "JdwpSuspendStatus[" << static_cast<int>(rhs) << "]"; - break; - } - return os; -} - -std::ostream& operator<<(std::ostream& os, const JdwpThreadStatus& rhs) { - switch (rhs) { - case TS_ZOMBIE: os << "ZOMBIE"; break; - case TS_RUNNING: os << "RUNNING"; break; - case TS_SLEEPING: os << "SLEEPING"; break; - case TS_MONITOR: os << "MONITOR"; break; - case TS_WAIT: os << "WAIT"; break; - default: - os << "JdwpThreadStatus[" << static_cast<int>(rhs) << "]"; - break; - } - return os; -} - -} // namespace JDWP - -} // namespace art diff --git a/src/jdwp/jdwp_constants.h b/src/jdwp/jdwp_constants.h index 14dc6cfa6a..ebc575b6b6 100644 --- a/src/jdwp/jdwp_constants.h +++ b/src/jdwp/jdwp_constants.h @@ -163,9 +163,9 @@ std::ostream& operator<<(std::ostream& os, const JdwpInvokeOptions& value); * StepDepth constants. */ enum JdwpStepDepth { - SD_INTO = 0, /* step into method calls */ - SD_OVER = 1, /* step over method calls */ - SD_OUT = 2, /* step out of current method */ + SD_INTO = 0, // Step into method calls. + SD_OVER = 1, // Step over method calls. + SD_OUT = 2, // Step out of current method. }; std::ostream& operator<<(std::ostream& os, const JdwpStepDepth& value); @@ -173,8 +173,8 @@ std::ostream& operator<<(std::ostream& os, const JdwpStepDepth& value); * StepSize constants. */ enum JdwpStepSize { - SS_MIN = 0, /* step by minimum (e.g. 1 bytecode inst) */ - SS_LINE = 1, /* if possible, step to next line */ + SS_MIN = 0, // Step by minimum (for example, one bytecode). + SS_LINE = 1, // If possible, step to next line. }; std::ostream& operator<<(std::ostream& os, const JdwpStepSize& value); @@ -182,9 +182,9 @@ std::ostream& operator<<(std::ostream& os, const JdwpStepSize& value); * SuspendPolicy constants. */ enum JdwpSuspendPolicy { - SP_NONE = 0, /* suspend no threads */ - SP_EVENT_THREAD = 1, /* suspend event thread */ - SP_ALL = 2, /* suspend all threads */ + SP_NONE = 0, // Suspend no threads. + SP_EVENT_THREAD = 1, // Suspend event thread. + SP_ALL = 2, // Suspend all threads. }; std::ostream& operator<<(std::ostream& os, const JdwpSuspendPolicy& value); diff --git a/src/jdwp/jdwp_main.cc b/src/jdwp/jdwp_main.cc index ad2281f216..ec85aa8baa 100644 --- a/src/jdwp/jdwp_main.cc +++ b/src/jdwp/jdwp_main.cc @@ -435,21 +435,6 @@ int64_t JdwpState::LastDebuggerActivity() { return now - last; } -static const char* kTransportNames[] = { - "Unknown", - "Socket", - "AndroidAdb", -}; -std::ostream& operator<<(std::ostream& os, const JdwpTransportType& value) { - int32_t int_value = static_cast<int32_t>(value); - if (value >= kJdwpTransportUnknown && value <= kJdwpTransportAndroidAdb) { - os << kTransportNames[int_value]; - } else { - os << "JdwpTransportType[" << int_value << "]"; - } - return os; -} - std::ostream& operator<<(std::ostream& os, const JdwpLocation& rhs) { os << "JdwpLocation[" << Dbg::GetClassName(rhs.classId) << "." << Dbg::GetMethodName(rhs.classId, rhs.methodId) @@ -466,41 +451,6 @@ bool operator!=(const JdwpLocation& lhs, const JdwpLocation& rhs) { return !(lhs == rhs); } -std::ostream& operator<<(std::ostream& os, const JdwpTag& value) { - switch (value) { - case JT_ARRAY: os << "JT_ARRAY"; break; - case JT_BYTE: os << "JT_BYTE"; break; - case JT_CHAR: os << "JT_CHAR"; break; - case JT_OBJECT: os << "JT_OBJECT"; break; - case JT_FLOAT: os << "JT_FLOAT"; break; - case JT_DOUBLE: os << "JT_DOUBLE"; break; - case JT_INT: os << "JT_INT"; break; - case JT_LONG: os << "JT_LONG"; break; - case JT_SHORT: os << "JT_SHORT"; break; - case JT_VOID: os << "JT_VOID"; break; - case JT_BOOLEAN: os << "JT_BOOLEAN"; break; - case JT_STRING: os << "JT_STRING"; break; - case JT_THREAD: os << "JT_THREAD"; break; - case JT_THREAD_GROUP: os << "JT_THREAD_GROUP"; break; - case JT_CLASS_LOADER: os << "JT_CLASS_LOADER"; break; - case JT_CLASS_OBJECT: os << "JT_CLASS_OBJECT"; break; - default: - os << "JdwpTag[" << static_cast<int32_t>(value) << "]"; - } - return os; -} - -std::ostream& operator<<(std::ostream& os, const JdwpTypeTag& value) { - switch (value) { - case TT_CLASS: os << "TT_CLASS"; break; - case TT_INTERFACE: os << "TT_INTERFACE"; break; - case TT_ARRAY: os << "TT_ARRAY"; break; - default: - os << "JdwpTypeTag[" << static_cast<int32_t>(value) << "]"; - } - return os; -} - } // namespace JDWP } // namespace art diff --git a/tools/generate-operator-out.py b/tools/generate-operator-out.py index ca7df1e48d..91d4669cc7 100755 --- a/tools/generate-operator-out.py +++ b/tools/generate-operator-out.py @@ -41,6 +41,7 @@ _ENUM_START_RE = re.compile(r'\benum\b\s+(\S+)\s+\{') _ENUM_VALUE_RE = re.compile(r'([A-Za-z0-9_]+)(.*)') _ENUM_END_RE = re.compile(r'^\s*\};$') _ENUMS = {} +_NAMESPACES = {} def Confused(filename, line_number, line): sys.stderr.write('%s:%d: confused by:\n%s\n' % (filename, line_number, line)) @@ -51,19 +52,46 @@ def ProcessFile(filename): lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n') in_enum = False line_number = 0 + + namespaces = [] + enclosing_classes = [] + for raw_line in lines: line_number += 1 - # TODO: take namespaces and enclosing classes/structs into account. - - # Is this the start of a new enum? if not in_enum: + # Is this the start of a new enum? m = _ENUM_START_RE.search(raw_line) if m: # Yes, so add an empty entry to _ENUMS for this enum. enum_name = m.group(1) + if len(enclosing_classes) > 0: + enum_name = '::'.join(enclosing_classes) + '::' + enum_name _ENUMS[enum_name] = [] + _NAMESPACES[enum_name] = '::'.join(namespaces) in_enum = True + continue + + # Is this the start or end of a namespace? + m = re.compile(r'^namespace (\S+) \{').search(raw_line) + if m: + namespaces.append(m.group(1)) + continue + m = re.compile(r'^\}\s+// namespace').search(raw_line) + if m: + namespaces = namespaces[0:len(namespaces) - 1] + continue + + # Is this the start or end of an enclosing class or struct? + m = re.compile(r'^(?:class|struct) (\S+) \{').search(raw_line) + if m: + enclosing_classes.append(m.group(1)) + continue + m = re.compile(r'^\};').search(raw_line) + if m: + enclosing_classes = enclosing_classes[0:len(enclosing_classes) - 1] + continue + continue # Is this the end of the current enum? @@ -74,8 +102,13 @@ def ProcessFile(filename): in_enum = False continue + # Whitespace? + line = raw_line.strip() + if len(line) == 0: + continue + # Is this another enum value? - m = _ENUM_VALUE_RE.search(raw_line.strip()) + m = _ENUM_VALUE_RE.search(line) if not m: Confused(filename, line_number, raw_line) @@ -88,7 +121,7 @@ def ProcessFile(filename): # Lose literal values because we don't care; turn "= 123, // blah" into ", // blah". rest = m.group(2).strip() - m_literal = re.compile(r'= (0x[0-9a-f]+|-?[0-9]+)').search(rest) + m_literal = re.compile(r'= (0x[0-9a-f]+|-?[0-9]+|\'.\')').search(rest) if m_literal: rest = rest[(len(m_literal.group(0))):] @@ -104,13 +137,15 @@ def ProcessFile(filename): # Anything left should be a comment. if len(rest) and not rest.startswith('// '): - print rest Confused(filename, line_number, raw_line) m_comment = re.compile(r'<<(.*?)>>').search(rest) if m_comment: enum_text = m_comment.group(1) + if len(enclosing_classes) > 0: + enum_value = '::'.join(enclosing_classes) + '::' + enum_value + _ENUMS[enum_name].append((enum_value, enum_text)) def main(): @@ -129,11 +164,14 @@ def main(): print '#include "%s"' % header_file print - print 'namespace art {' - print for enum_name in _ENUMS: print '// This was automatically generated by %s --- do not edit!' % sys.argv[0] + + namespaces = _NAMESPACES[enum_name].split('::') + for namespace in namespaces: + print 'namespace %s {' % namespace + print 'std::ostream& operator<<(std::ostream& os, const %s& rhs) {' % enum_name print ' switch (rhs) {' for (enum_value, enum_text) in _ENUMS[enum_name]: @@ -142,9 +180,10 @@ def main(): print ' }' print ' return os;' print '}' - print - print '} // namespace art' + for namespace in reversed(namespaces): + print '} // namespace %s' % namespace + print sys.exit(0) |