OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project 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 #include "src/log.h" | 5 #include "src/log.h" |
6 | 6 |
7 #include <cstdarg> | 7 #include <cstdarg> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 DCHECK(log_->IsEnabled() && FLAG_log_api); | 869 DCHECK(log_->IsEnabled() && FLAG_log_api); |
870 Log::MessageBuilder msg(log_); | 870 Log::MessageBuilder msg(log_); |
871 va_list ap; | 871 va_list ap; |
872 va_start(ap, format); | 872 va_start(ap, format); |
873 msg.AppendVA(format, ap); | 873 msg.AppendVA(format, ap); |
874 va_end(ap); | 874 va_end(ap); |
875 msg.WriteToLogFile(); | 875 msg.WriteToLogFile(); |
876 } | 876 } |
877 | 877 |
878 | 878 |
879 void Logger::ApiNamedSecurityCheck(Object* key) { | 879 void Logger::ApiSecurityCheck() { |
880 if (!log_->IsEnabled() || !FLAG_log_api) return; | 880 if (!log_->IsEnabled() || !FLAG_log_api) return; |
881 if (key->IsString()) { | 881 ApiEvent("api,check-security"); |
882 SmartArrayPointer<char> str = | |
883 String::cast(key)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | |
884 ApiEvent("api,check-security,\"%s\"", str.get()); | |
885 } else if (key->IsSymbol()) { | |
886 Symbol* symbol = Symbol::cast(key); | |
887 if (symbol->name()->IsUndefined()) { | |
888 ApiEvent("api,check-security,symbol(hash %x)", Symbol::cast(key)->Hash()); | |
889 } else { | |
890 SmartArrayPointer<char> str = String::cast(symbol->name())->ToCString( | |
891 DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | |
892 ApiEvent("api,check-security,symbol(\"%s\" hash %x)", str.get(), | |
893 Symbol::cast(key)->Hash()); | |
894 } | |
895 } else if (key->IsUndefined()) { | |
896 ApiEvent("api,check-security,undefined"); | |
897 } else { | |
898 ApiEvent("api,check-security,['no-name']"); | |
899 } | |
900 } | 882 } |
901 | 883 |
902 | 884 |
903 void Logger::SharedLibraryEvent(const std::string& library_path, | 885 void Logger::SharedLibraryEvent(const std::string& library_path, |
904 uintptr_t start, | 886 uintptr_t start, |
905 uintptr_t end) { | 887 uintptr_t end) { |
906 if (!log_->IsEnabled() || !FLAG_prof_cpp) return; | 888 if (!log_->IsEnabled() || !FLAG_prof_cpp) return; |
907 Log::MessageBuilder msg(log_); | 889 Log::MessageBuilder msg(log_); |
908 msg.Append("shared-library,\"%s\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR, | 890 msg.Append("shared-library,\"%s\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR, |
909 library_path.c_str(), start, end); | 891 library_path.c_str(), start, end); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) { | 1004 void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) { |
1023 if (!log_->IsEnabled() || !FLAG_log_regexp) return; | 1005 if (!log_->IsEnabled() || !FLAG_log_regexp) return; |
1024 Log::MessageBuilder msg(log_); | 1006 Log::MessageBuilder msg(log_); |
1025 msg.Append("regexp-compile,"); | 1007 msg.Append("regexp-compile,"); |
1026 LogRegExpSource(regexp); | 1008 LogRegExpSource(regexp); |
1027 msg.Append(in_cache ? ",hit" : ",miss"); | 1009 msg.Append(in_cache ? ",hit" : ",miss"); |
1028 msg.WriteToLogFile(); | 1010 msg.WriteToLogFile(); |
1029 } | 1011 } |
1030 | 1012 |
1031 | 1013 |
1032 void Logger::ApiIndexedSecurityCheck(uint32_t index) { | |
1033 if (!log_->IsEnabled() || !FLAG_log_api) return; | |
1034 ApiEvent("api,check-security,%u", index); | |
1035 } | |
1036 | |
1037 | |
1038 void Logger::ApiNamedPropertyAccess(const char* tag, | 1014 void Logger::ApiNamedPropertyAccess(const char* tag, |
1039 JSObject* holder, | 1015 JSObject* holder, |
1040 Object* name) { | 1016 Object* name) { |
1041 DCHECK(name->IsName()); | 1017 DCHECK(name->IsName()); |
1042 if (!log_->IsEnabled() || !FLAG_log_api) return; | 1018 if (!log_->IsEnabled() || !FLAG_log_api) return; |
1043 String* class_name_obj = holder->class_name(); | 1019 String* class_name_obj = holder->class_name(); |
1044 SmartArrayPointer<char> class_name = | 1020 SmartArrayPointer<char> class_name = |
1045 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1021 class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1046 if (name->IsString()) { | 1022 if (name->IsString()) { |
1047 SmartArrayPointer<char> property_name = | 1023 SmartArrayPointer<char> property_name = |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 if (jit_logger_) { | 1908 if (jit_logger_) { |
1933 removeCodeEventListener(jit_logger_); | 1909 removeCodeEventListener(jit_logger_); |
1934 delete jit_logger_; | 1910 delete jit_logger_; |
1935 jit_logger_ = NULL; | 1911 jit_logger_ = NULL; |
1936 } | 1912 } |
1937 | 1913 |
1938 return log_->Close(); | 1914 return log_->Close(); |
1939 } | 1915 } |
1940 | 1916 |
1941 } } // namespace v8::internal | 1917 } } // namespace v8::internal |
OLD | NEW |