Improve the evaluate requests (#2583)

Currently it evaluates the given expression in the context of the top most stack frame.
The expression should access to any variables and arguments that are in the scope chain.
Implement the eval_at request with the level of the scope chain as a further argument.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
Robert Sipka
2018-11-15 15:53:10 +01:00
committed by GitHub
parent 6c4b316609
commit 47fa5904b1
10 changed files with 170 additions and 13 deletions
+23
View File
@@ -171,6 +171,29 @@ class DebuggerPrompt(Cmd):
self.stop = True
do_e = do_eval
def do_eval_at(self, args):
""" Evaluate JavaScript source code at a scope chain level """
code = ''
index = 0
try:
args = args.split(" ", 1)
index = int(args[0])
if len(args) == 2:
code = args[1]
if index < 0 or index > 65535:
raise ValueError("Invalid scope chain index: %d (must be between 0 and 65535)" % index)
except ValueError as val_errno:
print("Error: %s" % (val_errno))
return
self.debugger.eval_at(code, index)
self.stop = True
def do_memstats(self, _):
""" Memory statistics """
self.debugger.memstats()