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

Side by Side Diff: src/a64/simulator-a64.cc

Issue 203563002: A64: Abstract colour definitions for the Simulator tracing. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #if defined(USE_SIMULATOR) 44 #if defined(USE_SIMULATOR)
45 45
46 46
47 // This macro provides a platform independent use of sscanf. The reason for 47 // This macro provides a platform independent use of sscanf. The reason for
48 // SScanF not being implemented in a platform independent way through 48 // SScanF not being implemented in a platform independent way through
49 // ::v8::internal::OS in the same way as SNPrintF is that the 49 // ::v8::internal::OS in the same way as SNPrintF is that the
50 // Windows C Run-Time Library does not provide vsscanf. 50 // Windows C Run-Time Library does not provide vsscanf.
51 #define SScanF sscanf // NOLINT 51 #define SScanF sscanf // NOLINT
52 52
53 53
54 // Helpers for colors.
55 // Depending on your terminal configuration, the colour names may not match the
56 // observed colours.
57 #define COLOUR(colour_code) "\033[" colour_code "m"
58 #define BOLD(colour_code) "1;" colour_code
59 #define NORMAL ""
60 #define GREY "30"
61 #define GREEN "32"
62 #define ORANGE "33"
63 #define BLUE "34"
64 #define PURPLE "35"
65 #define INDIGO "36"
66 #define WHITE "37"
67 typedef char const * const TEXT_COLOUR;
68 TEXT_COLOUR clr_normal = FLAG_log_colour ? COLOUR(NORMAL) : "";
69 TEXT_COLOUR clr_flag_name = FLAG_log_colour ? COLOUR(BOLD(GREY)) : "";
70 TEXT_COLOUR clr_flag_value = FLAG_log_colour ? COLOUR(BOLD(WHITE)) : "";
71 TEXT_COLOUR clr_reg_name = FLAG_log_colour ? COLOUR(BOLD(BLUE)) : "";
72 TEXT_COLOUR clr_reg_value = FLAG_log_colour ? COLOUR(BOLD(INDIGO)) : "";
73 TEXT_COLOUR clr_fpreg_name = FLAG_log_colour ? COLOUR(BOLD(ORANGE)) : "";
74 TEXT_COLOUR clr_fpreg_value = FLAG_log_colour ? COLOUR(BOLD(PURPLE)) : "";
75 TEXT_COLOUR clr_memory_value = FLAG_log_colour ? COLOUR(BOLD(GREEN)) : "";
76 TEXT_COLOUR clr_memory_address = FLAG_log_colour ? COLOUR(GREEN) : "";
77 TEXT_COLOUR clr_debug_number = FLAG_log_colour ? COLOUR(BOLD(ORANGE)) : "";
78 TEXT_COLOUR clr_debug_message = FLAG_log_colour ? COLOUR(ORANGE) : "";
79 TEXT_COLOUR clr_printf = FLAG_log_colour ? COLOUR(GREEN) : "";
80
81
54 // This is basically the same as PrintF, with a guard for FLAG_trace_sim. 82 // This is basically the same as PrintF, with a guard for FLAG_trace_sim.
55 void PRINTF_CHECKING TraceSim(const char* format, ...) { 83 void PRINTF_CHECKING TraceSim(const char* format, ...) {
56 if (FLAG_trace_sim) { 84 if (FLAG_trace_sim) {
57 va_list arguments; 85 va_list arguments;
58 va_start(arguments, format); 86 va_start(arguments, format);
59 OS::VPrint(format, arguments); 87 OS::VPrint(format, arguments);
60 va_end(arguments); 88 va_end(arguments);
61 } 89 }
62 } 90 }
63 91
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 Instruction* end = start->InstructionAtOffset(count * kInstructionSize); 841 Instruction* end = start->InstructionAtOffset(count * kInstructionSize);
814 for (Instruction* pc = start; pc < end; pc = pc->following()) { 842 for (Instruction* pc = start; pc < end; pc = pc->following()) {
815 disassembler_decoder_->Decode(pc); 843 disassembler_decoder_->Decode(pc);
816 } 844 }
817 } 845 }
818 846
819 847
820 void Simulator::PrintSystemRegisters(bool print_all) { 848 void Simulator::PrintSystemRegisters(bool print_all) {
821 static bool first_run = true; 849 static bool first_run = true;
822 850
823 // Define some colour codes to use for the register dump.
824 // TODO(jbramley): Find a more elegant way of defining these.
825 char const * const clr_normal = (FLAG_log_colour) ? ("\033[m") : ("");
826 char const * const clr_flag_name = (FLAG_log_colour) ? ("\033[1;30m") : ("");
827 char const * const clr_flag_value = (FLAG_log_colour) ? ("\033[1;37m") : ("");
828
829 static SimSystemRegister last_nzcv; 851 static SimSystemRegister last_nzcv;
830 if (print_all || first_run || (last_nzcv.RawValue() != nzcv().RawValue())) { 852 if (print_all || first_run || (last_nzcv.RawValue() != nzcv().RawValue())) {
831 fprintf(stream_, "# %sFLAGS: %sN:%d Z:%d C:%d V:%d%s\n", 853 fprintf(stream_, "# %sFLAGS: %sN:%d Z:%d C:%d V:%d%s\n",
832 clr_flag_name, 854 clr_flag_name,
833 clr_flag_value, 855 clr_flag_value,
834 N(), Z(), C(), V(), 856 N(), Z(), C(), V(),
835 clr_normal); 857 clr_normal);
836 } 858 }
837 last_nzcv = nzcv(); 859 last_nzcv = nzcv();
838 860
(...skipping 15 matching lines...) Expand all
854 last_fpcr = fpcr(); 876 last_fpcr = fpcr();
855 877
856 first_run = false; 878 first_run = false;
857 } 879 }
858 880
859 881
860 void Simulator::PrintRegisters(bool print_all_regs) { 882 void Simulator::PrintRegisters(bool print_all_regs) {
861 static bool first_run = true; 883 static bool first_run = true;
862 static int64_t last_regs[kNumberOfRegisters]; 884 static int64_t last_regs[kNumberOfRegisters];
863 885
864 // Define some colour codes to use for the register dump.
865 // TODO(jbramley): Find a more elegant way of defining these.
866 char const * const clr_normal = (FLAG_log_colour) ? ("\033[m") : ("");
867 char const * const clr_reg_name = (FLAG_log_colour) ? ("\033[1;34m") : ("");
868 char const * const clr_reg_value = (FLAG_log_colour) ? ("\033[1;36m") : ("");
869
870 for (unsigned i = 0; i < kNumberOfRegisters; i++) { 886 for (unsigned i = 0; i < kNumberOfRegisters; i++) {
871 if (print_all_regs || first_run || 887 if (print_all_regs || first_run ||
872 (last_regs[i] != xreg(i, Reg31IsStackPointer))) { 888 (last_regs[i] != xreg(i, Reg31IsStackPointer))) {
873 fprintf(stream_, 889 fprintf(stream_,
874 "# %s%4s:%s 0x%016" PRIx64 "%s\n", 890 "# %s%4s:%s 0x%016" PRIx64 "%s\n",
875 clr_reg_name, 891 clr_reg_name,
876 XRegNameForCode(i, Reg31IsStackPointer), 892 XRegNameForCode(i, Reg31IsStackPointer),
877 clr_reg_value, 893 clr_reg_value,
878 xreg(i, Reg31IsStackPointer), 894 xreg(i, Reg31IsStackPointer),
879 clr_normal); 895 clr_normal);
880 } 896 }
881 // Cache the new register value so the next run can detect any changes. 897 // Cache the new register value so the next run can detect any changes.
882 last_regs[i] = xreg(i, Reg31IsStackPointer); 898 last_regs[i] = xreg(i, Reg31IsStackPointer);
883 } 899 }
884 first_run = false; 900 first_run = false;
885 } 901 }
886 902
887 903
888 void Simulator::PrintFPRegisters(bool print_all_regs) { 904 void Simulator::PrintFPRegisters(bool print_all_regs) {
889 static bool first_run = true; 905 static bool first_run = true;
890 static uint64_t last_regs[kNumberOfFPRegisters]; 906 static uint64_t last_regs[kNumberOfFPRegisters];
891 907
892 // Define some colour codes to use for the register dump.
893 // TODO(jbramley): Find a more elegant way of defining these.
894 char const * const clr_normal = (FLAG_log_colour) ? ("\033[m") : ("");
895 char const * const clr_reg_name = (FLAG_log_colour) ? ("\033[1;33m") : ("");
896 char const * const clr_reg_value = (FLAG_log_colour) ? ("\033[1;35m") : ("");
897
898 // Print as many rows of registers as necessary, keeping each individual 908 // Print as many rows of registers as necessary, keeping each individual
899 // register in the same column each time (to make it easy to visually scan 909 // register in the same column each time (to make it easy to visually scan
900 // for changes). 910 // for changes).
901 for (unsigned i = 0; i < kNumberOfFPRegisters; i++) { 911 for (unsigned i = 0; i < kNumberOfFPRegisters; i++) {
902 if (print_all_regs || first_run || (last_regs[i] != dreg_bits(i))) { 912 if (print_all_regs || first_run || (last_regs[i] != dreg_bits(i))) {
903 fprintf(stream_, 913 fprintf(stream_,
904 "# %s %4s:%s 0x%016" PRIx64 "%s (%s%s:%s %g%s %s:%s %g%s)\n", 914 "# %s %4s:%s 0x%016" PRIx64 "%s (%s%s:%s %g%s %s:%s %g%s)\n",
905 clr_reg_name, 915 clr_fpreg_name,
906 VRegNameForCode(i), 916 VRegNameForCode(i),
907 clr_reg_value, 917 clr_fpreg_value,
908 dreg_bits(i), 918 dreg_bits(i),
909 clr_normal, 919 clr_normal,
910 clr_reg_name, 920 clr_fpreg_name,
911 DRegNameForCode(i), 921 DRegNameForCode(i),
912 clr_reg_value, 922 clr_fpreg_value,
913 dreg(i), 923 dreg(i),
914 clr_reg_name, 924 clr_fpreg_name,
915 SRegNameForCode(i), 925 SRegNameForCode(i),
916 clr_reg_value, 926 clr_fpreg_value,
917 sreg(i), 927 sreg(i),
918 clr_normal); 928 clr_normal);
919 } 929 }
920 // Cache the new register value so the next run can detect any changes. 930 // Cache the new register value so the next run can detect any changes.
921 last_regs[i] = dreg_bits(i); 931 last_regs[i] = dreg_bits(i);
922 } 932 }
923 first_run = false; 933 first_run = false;
924 } 934 }
925 935
926 936
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2942 return SScanF(desc + 2, "%" SCNx64, 2952 return SScanF(desc + 2, "%" SCNx64,
2943 reinterpret_cast<uint64_t*>(value)) == 1; 2953 reinterpret_cast<uint64_t*>(value)) == 1;
2944 } else { 2954 } else {
2945 return SScanF(desc, "%" SCNu64, 2955 return SScanF(desc, "%" SCNu64,
2946 reinterpret_cast<uint64_t*>(value)) == 1; 2956 reinterpret_cast<uint64_t*>(value)) == 1;
2947 } 2957 }
2948 } 2958 }
2949 2959
2950 2960
2951 bool Simulator::PrintValue(const char* desc) { 2961 bool Simulator::PrintValue(const char* desc) {
2952 // Define some colour codes to use for the register dump.
2953 // TODO(jbramley): Find a more elegant way of defining these.
2954 char const * const clr_normal = FLAG_log_colour ? "\033[m" : "";
2955 char const * const clr_reg_name = FLAG_log_colour ? "\033[1;34m" : "";
2956 char const * const clr_reg_value = FLAG_log_colour ? "\033[1;36m" : "";
2957 char const * const clr_fpreg_name = FLAG_log_colour ? "\033[1;33m" : "";
2958 char const * const clr_fpreg_value = FLAG_log_colour ? "\033[1;35m" : "";
2959
2960 if (strcmp(desc, "csp") == 0) { 2962 if (strcmp(desc, "csp") == 0) {
2961 ASSERT(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode)); 2963 ASSERT(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode));
2962 PrintF("%s csp:%s 0x%016" PRIx64 "%s\n", 2964 PrintF("%s csp:%s 0x%016" PRIx64 "%s\n",
2963 clr_reg_name, clr_reg_value, xreg(31, Reg31IsStackPointer), clr_normal); 2965 clr_reg_name, clr_reg_value, xreg(31, Reg31IsStackPointer), clr_normal);
2964 return true; 2966 return true;
2965 } else if (strcmp(desc, "wcsp") == 0) { 2967 } else if (strcmp(desc, "wcsp") == 0) {
2966 ASSERT(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode)); 2968 ASSERT(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode));
2967 PrintF("%s wcsp:%s 0x%08" PRIx32 "%s\n", 2969 PrintF("%s wcsp:%s 0x%08" PRIx32 "%s\n",
2968 clr_reg_name, clr_reg_value, wreg(31, Reg31IsStackPointer), clr_normal); 2970 clr_reg_name, clr_reg_value, wreg(31, Reg31IsStackPointer), clr_normal);
2969 return true; 2971 return true;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
3328 // (refer to InvocationCallback in v8.h). 3330 // (refer to InvocationCallback in v8.h).
3329 typedef void (*SimulatorRuntimeDirectApiCall)(int64_t arg0); 3331 typedef void (*SimulatorRuntimeDirectApiCall)(int64_t arg0);
3330 typedef void (*SimulatorRuntimeProfilingApiCall)(int64_t arg0, void* arg1); 3332 typedef void (*SimulatorRuntimeProfilingApiCall)(int64_t arg0, void* arg1);
3331 3333
3332 // This signature supports direct call to accessor getter callback. 3334 // This signature supports direct call to accessor getter callback.
3333 typedef void (*SimulatorRuntimeDirectGetterCall)(int64_t arg0, int64_t arg1); 3335 typedef void (*SimulatorRuntimeDirectGetterCall)(int64_t arg0, int64_t arg1);
3334 typedef void (*SimulatorRuntimeProfilingGetterCall)(int64_t arg0, int64_t arg1, 3336 typedef void (*SimulatorRuntimeProfilingGetterCall)(int64_t arg0, int64_t arg1,
3335 void* arg2); 3337 void* arg2);
3336 3338
3337 void Simulator::VisitException(Instruction* instr) { 3339 void Simulator::VisitException(Instruction* instr) {
3338 // Define some colour codes to use for log messages.
3339 // TODO(jbramley): Find a more elegant way of defining these.
3340 char const* const clr_normal = (FLAG_log_colour) ? ("\033[m")
3341 : ("");
3342 char const* const clr_debug_number = (FLAG_log_colour) ? ("\033[1;33m")
3343 : ("");
3344 char const* const clr_debug_message = (FLAG_log_colour) ? ("\033[0;33m")
3345 : ("");
3346 char const* const clr_printf = (FLAG_log_colour) ? ("\033[0;32m")
3347 : ("");
3348
3349 switch (instr->Mask(ExceptionMask)) { 3340 switch (instr->Mask(ExceptionMask)) {
3350 case HLT: { 3341 case HLT: {
3351 if (instr->ImmException() == kImmExceptionIsDebug) { 3342 if (instr->ImmException() == kImmExceptionIsDebug) {
3352 // Read the arguments encoded inline in the instruction stream. 3343 // Read the arguments encoded inline in the instruction stream.
3353 uint32_t code; 3344 uint32_t code;
3354 uint32_t parameters; 3345 uint32_t parameters;
3355 3346
3356 memcpy(&code, 3347 memcpy(&code,
3357 pc_->InstructionAtOffset(kDebugCodeOffset), 3348 pc_->InstructionAtOffset(kDebugCodeOffset),
3358 sizeof(code)); 3349 sizeof(code));
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
3655 default: 3646 default:
3656 UNIMPLEMENTED(); 3647 UNIMPLEMENTED();
3657 } 3648 }
3658 } 3649 }
3659 3650
3660 #endif // USE_SIMULATOR 3651 #endif // USE_SIMULATOR
3661 3652
3662 } } // namespace v8::internal 3653 } } // namespace v8::internal
3663 3654
3664 #endif // V8_TARGET_ARCH_A64 3655 #endif // V8_TARGET_ARCH_A64
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698