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

Side by Side Diff: src/d8.cc

Issue 2733783002: [debug] change coverage API to use offset instead of line/column. (Closed)
Patch Set: rebase Created 3 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
« no previous file with comments | « src/api.cc ('k') | src/debug/debug-interface.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 <errno.h> 5 #include <errno.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 if (!script->Name().ToLocal(&name)) continue; 1706 if (!script->Name().ToLocal(&name)) continue;
1707 std::string file_name = ToSTLString(name); 1707 std::string file_name = ToSTLString(name);
1708 // Skip scripts not backed by a file. 1708 // Skip scripts not backed by a file.
1709 if (!std::ifstream(file_name).good()) continue; 1709 if (!std::ifstream(file_name).good()) continue;
1710 sink << "SF:"; 1710 sink << "SF:";
1711 sink << NormalizePath(file_name, GetWorkingDirectory()) << std::endl; 1711 sink << NormalizePath(file_name, GetWorkingDirectory()) << std::endl;
1712 std::vector<uint32_t> lines; 1712 std::vector<uint32_t> lines;
1713 for (size_t j = 0; j < script_data.FunctionCount(); j++) { 1713 for (size_t j = 0; j < script_data.FunctionCount(); j++) {
1714 debug::Coverage::FunctionData function_data = 1714 debug::Coverage::FunctionData function_data =
1715 script_data.GetFunctionData(j); 1715 script_data.GetFunctionData(j);
1716 int start_line = function_data.Start().GetLineNumber(); 1716 debug::Location start =
1717 int end_line = function_data.End().GetLineNumber(); 1717 script->GetSourceLocation(function_data.StartOffset());
1718 debug::Location end =
1719 script->GetSourceLocation(function_data.EndOffset());
1720 int start_line = start.GetLineNumber();
1721 int end_line = end.GetLineNumber();
1718 uint32_t count = function_data.Count(); 1722 uint32_t count = function_data.Count();
1719 // Ensure space in the array. 1723 // Ensure space in the array.
1720 lines.resize(std::max(static_cast<size_t>(end_line + 1), lines.size()), 1724 lines.resize(std::max(static_cast<size_t>(end_line + 1), lines.size()),
1721 0); 1725 0);
1722 // Boundary lines could be shared between two functions with different 1726 // Boundary lines could be shared between two functions with different
1723 // invocation counts. Take the maximum. 1727 // invocation counts. Take the maximum.
1724 lines[start_line] = std::max(lines[start_line], count); 1728 lines[start_line] = std::max(lines[start_line], count);
1725 lines[end_line] = std::max(lines[end_line], count); 1729 lines[end_line] = std::max(lines[end_line], count);
1726 // Invocation counts for non-boundary lines are overwritten. 1730 // Invocation counts for non-boundary lines are overwritten.
1727 for (int k = start_line + 1; k < end_line; k++) lines[k] = count; 1731 for (int k = start_line + 1; k < end_line; k++) lines[k] = count;
1728 // Write function stats. 1732 // Write function stats.
1729 Local<String> name; 1733 Local<String> name;
1730 std::stringstream name_stream; 1734 std::stringstream name_stream;
1731 if (function_data.Name().ToLocal(&name)) { 1735 if (function_data.Name().ToLocal(&name)) {
1732 name_stream << ToSTLString(name); 1736 name_stream << ToSTLString(name);
1733 } else { 1737 } else {
1734 name_stream << "<" << start_line + 1 << "-"; 1738 name_stream << "<" << start_line + 1 << "-";
1735 name_stream << function_data.Start().GetColumnNumber() << ">"; 1739 name_stream << start.GetColumnNumber() << ">";
1736 } 1740 }
1737 sink << "FN:" << start_line + 1 << "," << name_stream.str() << std::endl; 1741 sink << "FN:" << start_line + 1 << "," << name_stream.str() << std::endl;
1738 sink << "FNDA:" << count << "," << name_stream.str() << std::endl; 1742 sink << "FNDA:" << count << "," << name_stream.str() << std::endl;
1739 } 1743 }
1740 // Write per-line coverage. LCOV uses 1-based line numbers. 1744 // Write per-line coverage. LCOV uses 1-based line numbers.
1741 for (size_t i = 0; i < lines.size(); i++) { 1745 for (size_t i = 0; i < lines.size(); i++) {
1742 sink << "DA:" << (i + 1) << "," << lines[i] << std::endl; 1746 sink << "DA:" << (i + 1) << "," << lines[i] << std::endl;
1743 } 1747 }
1744 sink << "end_of_record" << std::endl; 1748 sink << "end_of_record" << std::endl;
1745 } 1749 }
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
3032 } 3036 }
3033 3037
3034 } // namespace v8 3038 } // namespace v8
3035 3039
3036 3040
3037 #ifndef GOOGLE3 3041 #ifndef GOOGLE3
3038 int main(int argc, char* argv[]) { 3042 int main(int argc, char* argv[]) {
3039 return v8::Shell::Main(argc, argv); 3043 return v8::Shell::Main(argc, argv);
3040 } 3044 }
3041 #endif 3045 #endif
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/debug/debug-interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698