Skip to content

Commit 24fac56

Browse files
robertsipkartakacs
authored andcommitted
Add debugger option (#239)
JSRemoteTest-DCO-1.0-Signed-off-by: Robert Sipka [email protected]
1 parent edcc48c commit 24fac56

File tree

8 files changed

+79
-22
lines changed

8 files changed

+79
-22
lines changed

jstest/__main__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def parse_options():
5959
action='store_true', default=False,
6060
help='do not test the application (default: %(default)s)')
6161

62+
parser.add_argument('--debugger', nargs='?', const='no_address', metavar='ADDRESS',
63+
help='Enable jerry debugger (Set ADDRESS to run debugger at startup')
64+
6265
parser.add_argument('--device',
6366
choices=['stm32f4dis', 'rpi2', 'artik053', 'artik530'],
6467
default='stm32f4dis',
@@ -149,6 +152,15 @@ def adjust_options(options):
149152
options.no_flash = True
150153
options.no_test = True
151154

155+
# TODO: resolve this section, debugger should work on every target.
156+
if options.debugger:
157+
if options.device == 'stm32f4dis':
158+
jstest.console.warning('Debugger is not supported on STM32F4-Discovery')
159+
options.debugger = None
160+
elif options.device == 'artik053' and options.app == 'jerryscript':
161+
jstest.console.warning('Debugger is not supported on ARTIK053 with JerryScript')
162+
options.debugger = None
163+
152164
if options.emulate:
153165
options.no_flash = True
154166

jstest/builder/modules/iotjs.build.config

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@
2929
],
3030
"conditional-options": [
3131
{
32-
"condition": "%{coverage}",
32+
"condition": "%{memstat}",
33+
"args": ["--jerry-memstat"]
34+
},
35+
{
36+
"condition": "%{debugger}",
3337
"args": [
34-
"--buildtype=debug",
3538
"--jerry-debugger",
39+
"--jerry-cmake-param=-DJERRY_PORT_DEFAULT=ON",
3640
"--no-snapshot"
3741
]
3842
},
39-
{
40-
"condition": "%{memstat}",
41-
"args": ["--jerry-memstat"]
42-
},
4343
{
4444
"condition": "%{minimal-profile-build}",
4545
"args": ["--profile=profiles/minimal.profile"]
@@ -108,6 +108,15 @@
108108
]
109109
}
110110
},
111+
{
112+
"condition": "%{debugger}",
113+
"env": {
114+
"IOTJS_BUILD_OPTION": [
115+
"--jerry-debugger",
116+
"--no-snapshot"
117+
]
118+
}
119+
},
111120
{
112121
"condition": "%{coverage} and %{test-build}",
113122
"env": {
@@ -199,6 +208,15 @@
199208
]
200209
}
201210
},
211+
{
212+
"condition": "%{debugger}",
213+
"env": {
214+
"IOTJS_BUILD_OPTION": [
215+
"--jerry-debugger",
216+
"--no-snapshot"
217+
]
218+
}
219+
},
202220
{
203221
"condition": "%{coverage} or %{memstat}",
204222
"env": { "IOTJS_BUILD_OPTION": ["--compile-flag=-g", "--jerry-compile-flag=-g"] }
@@ -289,6 +307,13 @@
289307
"--no-snapshot"
290308
]
291309
},
310+
{
311+
"condition": "%{debugger}",
312+
"args": [
313+
"--jerry-debugger",
314+
"--no-snapshot"
315+
]
316+
},
292317
{
293318
"condition": "%{coverage} or %{memstat}",
294319
"args": ["--compile-flag=-g", "--jerry-compile-flag=-g"]

jstest/builder/modules/jerryscript.build.config

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"--profile=%{jerryscript}/jerry-core/profiles/minimal.profile",
2626
"--toolchain=%{jerryscript}/cmake/toolchain_mcu_stm32f4.cmake",
2727
"--compile-flag=-I%{jerryscript}/targets/nuttx-stm32f4",
28-
"--compile-flag='-isystem %{nuttx}/include'"
28+
"--compile-flag=-isystem %{nuttx}/include"
2929
],
3030
"conditional-options": [
3131
{
@@ -39,6 +39,12 @@
3939
{
4040
"condition": "%{es2015subset-profile-build} or %{test-build}",
4141
"args": ["--profile=%{jerryscript}/jerry-core/profiles/es2015-subset.profile"]
42+
},
43+
{
44+
"condition": "%{debugger}",
45+
"args": [
46+
"--jerry-debugger=ON"
47+
]
4248
}
4349
]
4450
},
@@ -81,6 +87,12 @@
8187
"condition": "'%{build-type}' == 'debug'",
8288
"args": ["--debug"]
8389
},
90+
{
91+
"condition": "%{debugger}",
92+
"args": [
93+
"--jerry-debugger=ON"
94+
]
95+
},
8496
{
8597
"condition": "%{memstat}",
8698
"args": ["--mem-stats=ON"]
@@ -134,8 +146,10 @@
134146
"args": ["--mem-stats=ON"]
135147
},
136148
{
137-
"condition": "%{coverage} or %{memstat}",
138-
"args": ["--debug"]
149+
"condition": "%{debugger}",
150+
"args": [
151+
"--jerry-debugger=ON"
152+
]
139153
},
140154
{
141155
"condition": "%{es5.1-profile-build}",

jstest/common/symbol_resolver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def resolve_symbol(symbol, env):
116116
'flash': not env.options.no_flash,
117117
'memstat': not env.options.no_memstat,
118118
'coverage': bool(env.options.coverage),
119+
'debugger':bool(env.options.debugger),
119120
'test-build': 'test-build' in env.options.id,
120121
'minimal-profile-build': 'minimal-profile-build' in env.options.id,
121122
'es5.1-profile-build': 'target-es5.1-profile-build' in env.options.id,

jstest/resources/etc/tester.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ def run_jerry(options):
121121
if not options.no_memstat:
122122
args.append('--mem-stats')
123123

124+
if options.debug_port:
125+
args.append('--start-debug-server')
126+
args.append('--debug-port')
127+
args.append('%s' % options.debug_port)
128+
124129
output, exitcode = execute(options.cwd, options.cmd, args)
125130

126131
mempeak = 'n/a'
@@ -162,10 +167,10 @@ def run_iotjs(options):
162167
if not options.no_memstat:
163168
args.append('--mem-stats')
164169

165-
if options.coverage_port:
170+
if options.debug_port:
166171
args.append('--start-debug-server')
167172
args.append('--debug-port')
168-
args.append('%s' % options.coverage_port)
173+
args.append('%s' % options.debug_port)
169174

170175
args.append(options.testfile)
171176

@@ -244,10 +249,9 @@ def parse_arguments():
244249
parser.add_argument('--testfile', metavar='file',
245250
help='Test file with path')
246251

247-
parser.add_argument('--coverage-port',
252+
parser.add_argument('--debug-port',
248253
metavar='PORT',
249-
help='Specify the PORT for jerry-debugger to'
250-
' calculate the JS source code coverage')
254+
help='Specify the PORT for jerry-debugger')
251255

252256
parser.add_argument('--no-memstat',
253257
action='store_true', default=False,

jstest/testrunner/devices/serial_device.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ def _prepare_command(self, testset, test):
7575
if not self.env.options.no_memstat:
7676
args = ['--mem-stats']
7777

78-
if self.env.options.coverage and self.device == 'artik053':
79-
port = testrunner_utils.read_port_from_url(self.env.options.coverage)
80-
81-
args.append('--debug-port %s' % port)
78+
if self.env.options.debugger and self.env.options.debugger != 'no_address':
79+
port = testrunner_utils.read_port_from_url(self.env.options.debugger)
8280
args.append('--start-debug-server')
81+
args.append('--debug-port')
82+
args.append('%s' % port)
8383

8484
command = {
8585
'iotjs': 'iotjs %s %s' % (' '.join(args), testfile),

jstest/testrunner/devices/ssh_device.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ def execute(self, testset, test):
9292
if self.env.options.no_memstat:
9393
command += ' --no-memstat'
9494

95-
if self.env.options.coverage and self.app == 'iotjs':
96-
port = testrunner_utils.read_port_from_url(self.env.options.coverage)
97-
command += ' --coverage-port %s' % port
95+
if self.env.options.debugger and self.env.options.debugger != 'no_address':
96+
port = testrunner_utils.read_port_from_url(self.env.options.debugger)
97+
command += ' --debug-port %s' % port
9898

99+
if self.env.options.coverage:
99100
# Start the client script on a different thread for coverage.
100101
client_thread = Thread(target=testrunner_utils.run_coverage_script,
101102
kwargs={'env' :self.env})

pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
[MESSAGES CONTROL]
16-
disable=missing-docstring, anomalous-backslash-in-string, attribute-defined-outside-init, import-error, broad-except, redefined-variable-type, superfluous-parens, bad-continuation, eval-used, fixme, too-many-arguments
16+
disable=missing-docstring, anomalous-backslash-in-string, attribute-defined-outside-init, import-error, broad-except, redefined-variable-type, superfluous-parens, bad-continuation, eval-used, fixme, too-many-arguments, too-many-branches
1717

1818
[REPORTS]
1919

0 commit comments

Comments
 (0)