Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library debugger_page_element; | 5 library debugger_page_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:math'; | 9 import 'dart:math'; |
| 10 import 'observatory_element.dart'; | 10 import 'observatory_element.dart'; |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 String helpShort = 'Show information on a variety of topics'; | 1062 String helpShort = 'Show information on a variety of topics'; |
| 1063 | 1063 |
| 1064 String helpLong = | 1064 String helpLong = |
| 1065 'Show information on a variety of topics.\n' | 1065 'Show information on a variety of topics.\n' |
| 1066 '\n' | 1066 '\n' |
| 1067 'Syntax: info <subcommand>\n'; | 1067 'Syntax: info <subcommand>\n'; |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 class RefreshCoverageCommand extends DebuggerCommand { | |
| 1071 RefreshCoverageCommand(Debugger debugger) : super(debugger, 'coverage', []); | |
| 1072 | |
| 1073 Future run(List<String> args) { | |
| 1074 Set<Script> scripts = debugger.stackElement.activeScripts(); | |
| 1075 List pending = []; | |
| 1076 for (var script in scripts) { | |
| 1077 pending.add(script.refreshCoverage().then((_) { | |
| 1078 debugger.console.print('Refreshed coverage for ${script.name}'); | |
| 1079 })); | |
| 1080 } | |
| 1081 return Future.wait(pending); | |
| 1082 } | |
| 1083 | |
| 1084 String helpShort = 'Refresh code coverage information for current frames'; | |
| 1085 | |
| 1086 String helpLong = | |
| 1087 'Refresh code coverage information for current frames.\n' | |
| 1088 '\n' | |
| 1089 'Syntax: refresh coverage\n\n'; | |
| 1090 } | |
| 1091 | |
| 1092 class RefreshStackCommand extends DebuggerCommand { | 1070 class RefreshStackCommand extends DebuggerCommand { |
| 1093 RefreshStackCommand(Debugger debugger) : super(debugger, 'stack', []); | 1071 RefreshStackCommand(Debugger debugger) : super(debugger, 'stack', []); |
| 1094 | 1072 |
| 1095 Future run(List<String> args) { | 1073 Future run(List<String> args) { |
| 1096 return debugger.refreshStack(); | 1074 return debugger.refreshStack(); |
| 1097 } | 1075 } |
| 1098 | 1076 |
| 1099 String helpShort = 'Refresh isolate stack'; | 1077 String helpShort = 'Refresh isolate stack'; |
| 1100 | 1078 |
| 1101 String helpLong = | 1079 String helpLong = |
| 1102 'Refresh isolate stack.\n' | 1080 'Refresh isolate stack.\n' |
| 1103 '\n' | 1081 '\n' |
| 1104 'Syntax: refresh stack\n'; | 1082 'Syntax: refresh stack\n'; |
| 1105 } | 1083 } |
| 1106 | 1084 |
| 1107 class RefreshCommand extends DebuggerCommand { | 1085 class RefreshCommand extends DebuggerCommand { |
| 1108 RefreshCommand(Debugger debugger) : super(debugger, 'refresh', [ | 1086 RefreshCommand(Debugger debugger) : super(debugger, 'refresh', [ |
| 1109 new RefreshCoverageCommand(debugger), | |
| 1110 new RefreshStackCommand(debugger), | 1087 new RefreshStackCommand(debugger), |
| 1111 ]); | 1088 ]); |
| 1112 | 1089 |
| 1113 Future run(List<String> args) { | 1090 Future run(List<String> args) { |
| 1114 debugger.console.print("'refresh' expects a subcommand (see 'help refresh')" ); | 1091 debugger.console.print("'refresh' expects a subcommand (see 'help refresh')" ); |
| 1115 return new Future.value(null); | 1092 return new Future.value(null); |
| 1116 } | 1093 } |
| 1117 | 1094 |
| 1118 String helpShort = 'Refresh debugging information of various sorts'; | 1095 String helpShort = 'Refresh debugging information of various sorts'; |
| 1119 | 1096 |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1889 | 1866 |
| 1890 @override | 1867 @override |
| 1891 void attached() { | 1868 void attached() { |
| 1892 super.attached(); | 1869 super.attached(); |
| 1893 _onResize(null); | 1870 _onResize(null); |
| 1894 | 1871 |
| 1895 // Wire the debugger object to the stack, console, and command line. | 1872 // Wire the debugger object to the stack, console, and command line. |
| 1896 var stackElement = $['stackElement']; | 1873 var stackElement = $['stackElement']; |
| 1897 debugger.stackElement = stackElement; | 1874 debugger.stackElement = stackElement; |
| 1898 stackElement.debugger = debugger; | 1875 stackElement.debugger = debugger; |
| 1876 stackElement.scroller = $['stackDiv']; | |
| 1899 debugger.console = $['console']; | 1877 debugger.console = $['console']; |
| 1900 debugger.input = $['commandline']; | 1878 debugger.input = $['commandline']; |
| 1901 debugger.input.debugger = debugger; | 1879 debugger.input.debugger = debugger; |
| 1902 debugger.init(); | 1880 debugger.init(); |
| 1903 | 1881 |
| 1904 _resizeSubscription = window.onResize.listen(_onResize); | 1882 _resizeSubscription = window.onResize.listen(_onResize); |
| 1905 _vmSubscriptionFuture = | 1883 _vmSubscriptionFuture = |
| 1906 app.vm.listenEventStream(VM.kVMStream, debugger.onEvent); | 1884 app.vm.listenEventStream(VM.kVMStream, debugger.onEvent); |
| 1907 _isolateSubscriptionFuture = | 1885 _isolateSubscriptionFuture = |
| 1908 app.vm.listenEventStream(VM.kIsolateStream, debugger.onEvent); | 1886 app.vm.listenEventStream(VM.kIsolateStream, debugger.onEvent); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1945 void onPoll() { | 1923 void onPoll() { |
| 1946 debugger.flushStdio(); | 1924 debugger.flushStdio(); |
| 1947 } | 1925 } |
| 1948 | 1926 |
| 1949 void _onResize(_) { | 1927 void _onResize(_) { |
| 1950 var navbarDiv = $['navbarDiv']; | 1928 var navbarDiv = $['navbarDiv']; |
| 1951 var stackDiv = $['stackDiv']; | 1929 var stackDiv = $['stackDiv']; |
| 1952 var splitterDiv = $['splitterDiv']; | 1930 var splitterDiv = $['splitterDiv']; |
| 1953 var cmdDiv = $['commandDiv']; | 1931 var cmdDiv = $['commandDiv']; |
| 1954 | 1932 |
| 1955 int navbarHeight = navbarDiv.clientHeight; | 1933 // For now, force navbar height to 40px in the debugger. |
| 1934 int navbarHeight = 40; | |
|
Cutch
2016/01/14 21:37:40
This is also hard coded in script_inset.dart can y
turnidge
2016/01/15 18:37:03
Done.
| |
| 1956 int splitterHeight = splitterDiv.clientHeight; | 1935 int splitterHeight = splitterDiv.clientHeight; |
| 1957 int cmdHeight = cmdDiv.clientHeight; | 1936 int cmdHeight = cmdDiv.clientHeight; |
| 1958 | 1937 |
| 1959 int windowHeight = window.innerHeight; | 1938 int windowHeight = window.innerHeight; |
| 1960 int fixedHeight = navbarHeight + splitterHeight + cmdHeight; | 1939 int fixedHeight = navbarHeight + splitterHeight + cmdHeight; |
| 1961 int available = windowHeight - fixedHeight; | 1940 int available = windowHeight - fixedHeight; |
| 1962 int stackHeight = available ~/ 1.6; | 1941 int stackHeight = available ~/ 1.6; |
| 1942 navbarDiv.style.setProperty('height', '${navbarHeight}px'); | |
| 1963 stackDiv.style.setProperty('height', '${stackHeight}px'); | 1943 stackDiv.style.setProperty('height', '${stackHeight}px'); |
| 1964 } | 1944 } |
| 1965 | 1945 |
| 1966 @override | 1946 @override |
| 1967 void detached() { | 1947 void detached() { |
| 1968 debugger.isolate = null; | 1948 debugger.isolate = null; |
| 1969 _resizeSubscription.cancel(); | 1949 _resizeSubscription.cancel(); |
| 1970 _resizeSubscription = null; | 1950 _resizeSubscription = null; |
| 1971 cancelFutureSubscription(_vmSubscriptionFuture); | 1951 cancelFutureSubscription(_vmSubscriptionFuture); |
| 1972 _vmSubscriptionFuture = null; | 1952 _vmSubscriptionFuture = null; |
| 1973 cancelFutureSubscription(_isolateSubscriptionFuture); | 1953 cancelFutureSubscription(_isolateSubscriptionFuture); |
| 1974 _isolateSubscriptionFuture = null; | 1954 _isolateSubscriptionFuture = null; |
| 1975 cancelFutureSubscription(_debugSubscriptionFuture); | 1955 cancelFutureSubscription(_debugSubscriptionFuture); |
| 1976 _debugSubscriptionFuture = null; | 1956 _debugSubscriptionFuture = null; |
| 1977 cancelFutureSubscription(_stdoutSubscriptionFuture); | 1957 cancelFutureSubscription(_stdoutSubscriptionFuture); |
| 1978 _stdoutSubscriptionFuture = null; | 1958 _stdoutSubscriptionFuture = null; |
| 1979 cancelFutureSubscription(_stderrSubscriptionFuture); | 1959 cancelFutureSubscription(_stderrSubscriptionFuture); |
| 1980 _stderrSubscriptionFuture = null; | 1960 _stderrSubscriptionFuture = null; |
| 1981 cancelFutureSubscription(_logSubscriptionFuture); | 1961 cancelFutureSubscription(_logSubscriptionFuture); |
| 1982 _logSubscriptionFuture = null; | 1962 _logSubscriptionFuture = null; |
| 1983 super.detached(); | 1963 super.detached(); |
| 1984 } | 1964 } |
| 1985 } | 1965 } |
| 1986 | 1966 |
| 1987 @CustomTag('debugger-stack') | 1967 @CustomTag('debugger-stack') |
| 1988 class DebuggerStackElement extends ObservatoryElement { | 1968 class DebuggerStackElement extends ObservatoryElement { |
| 1989 @published Isolate isolate; | 1969 @published Isolate isolate; |
| 1970 @published Element scroller; | |
| 1990 @observable bool hasStack = false; | 1971 @observable bool hasStack = false; |
| 1991 @observable bool hasMessages = false; | 1972 @observable bool hasMessages = false; |
| 1992 @observable bool isSampled = false; | 1973 @observable bool isSampled = false; |
| 1993 @observable int currentFrame; | 1974 @observable int currentFrame; |
| 1994 ObservatoryDebugger debugger; | 1975 ObservatoryDebugger debugger; |
| 1995 | 1976 |
| 1996 _addFrame(List frameList, Frame frameInfo) { | 1977 _addFrame(List frameList, Frame frameInfo) { |
| 1997 DebuggerFrameElement frameElement = new Element.tag('debugger-frame'); | 1978 DebuggerFrameElement frameElement = new Element.tag('debugger-frame'); |
| 1998 frameElement.frame = frameInfo; | 1979 frameElement.frame = frameInfo; |
| 1980 frameElement.scroller = scroller; | |
| 1999 | 1981 |
| 2000 if (frameInfo.index == currentFrame) { | 1982 if (frameInfo.index == currentFrame) { |
| 2001 frameElement.setCurrent(true); | 1983 frameElement.setCurrent(true); |
| 2002 } else { | 1984 } else { |
| 2003 frameElement.setCurrent(false); | 1985 frameElement.setCurrent(false); |
| 2004 } | 1986 } |
| 2005 | 1987 |
| 2006 var li = new LIElement(); | 1988 var li = new LIElement(); |
| 2007 li.classes.add('list-group-item'); | 1989 li.classes.add('list-group-item'); |
| 2008 li.children.insert(0, frameElement); | 1990 li.children.insert(0, frameElement); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2115 for (var frameElement in frameElements) { | 2097 for (var frameElement in frameElements) { |
| 2116 var dbgFrameElement = frameElement.children[0]; | 2098 var dbgFrameElement = frameElement.children[0]; |
| 2117 if (dbgFrameElement.frame.index == currentFrame) { | 2099 if (dbgFrameElement.frame.index == currentFrame) { |
| 2118 dbgFrameElement.setCurrent(true); | 2100 dbgFrameElement.setCurrent(true); |
| 2119 } else { | 2101 } else { |
| 2120 dbgFrameElement.setCurrent(false); | 2102 dbgFrameElement.setCurrent(false); |
| 2121 } | 2103 } |
| 2122 } | 2104 } |
| 2123 } | 2105 } |
| 2124 | 2106 |
| 2125 Set<Script> activeScripts() { | |
| 2126 var s = new Set<Script>(); | |
| 2127 List frameElements = $['frameList'].children; | |
| 2128 for (var frameElement in frameElements) { | |
| 2129 s.add(frameElement.children[0].script); | |
| 2130 } | |
| 2131 return s; | |
| 2132 } | |
| 2133 | |
| 2134 Future doPauseIsolate() { | 2107 Future doPauseIsolate() { |
| 2135 if (debugger != null) { | 2108 if (debugger != null) { |
| 2136 return debugger.isolate.pause(); | 2109 return debugger.isolate.pause(); |
| 2137 } else { | 2110 } else { |
| 2138 return new Future.value(null); | 2111 return new Future.value(null); |
| 2139 } | 2112 } |
| 2140 } | 2113 } |
| 2141 | 2114 |
| 2142 Future doRefreshStack() { | 2115 Future doRefreshStack() { |
| 2143 if (debugger != null) { | 2116 if (debugger != null) { |
| 2144 return debugger.refreshStack(); | 2117 return debugger.refreshStack(); |
| 2145 } else { | 2118 } else { |
| 2146 return new Future.value(null); | 2119 return new Future.value(null); |
| 2147 } | 2120 } |
| 2148 } | 2121 } |
| 2149 | 2122 |
| 2150 DebuggerStackElement.created() : super.created(); | 2123 DebuggerStackElement.created() : super.created(); |
| 2151 } | 2124 } |
| 2152 | 2125 |
| 2153 @CustomTag('debugger-frame') | 2126 @CustomTag('debugger-frame') |
| 2154 class DebuggerFrameElement extends ObservatoryElement { | 2127 class DebuggerFrameElement extends ObservatoryElement { |
| 2155 @published Frame frame; | 2128 @published Frame frame; |
| 2129 @published Element scroller; | |
| 2156 | 2130 |
| 2157 // Is this the current frame? | 2131 // Is this the current frame? |
| 2158 bool _current = false; | 2132 bool _current = false; |
| 2159 | 2133 |
| 2160 // Has this frame been pinned open? | 2134 // Has this frame been pinned open? |
| 2161 bool _pinned = false; | 2135 bool _pinned = false; |
| 2162 | 2136 |
| 2163 void setCurrent(bool value) { | 2137 void setCurrent(bool value) { |
| 2164 busy = true; | 2138 busy = true; |
| 2165 frame.function.load().then((func) { | 2139 frame.function.load().then((func) { |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2587 } | 2561 } |
| 2588 }); | 2562 }); |
| 2589 } | 2563 } |
| 2590 | 2564 |
| 2591 void focus() { | 2565 void focus() { |
| 2592 $['textBox'].focus(); | 2566 $['textBox'].focus(); |
| 2593 } | 2567 } |
| 2594 | 2568 |
| 2595 DebuggerInputElement.created() : super.created(); | 2569 DebuggerInputElement.created() : super.created(); |
| 2596 } | 2570 } |
| OLD | NEW |