[gjs: 1/2] Display current line of source code when displaying current frame in debugger
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/2] Display current line of source code when displaying current frame in debugger
- Date: Wed, 27 Jan 2021 18:16:26 +0000 (UTC)
commit 0ca8997eab18ebf37a0e0ee757cc90a93e8a50f3
Author: Nasah Kuma <nasahnash19 gmail com>
Date: Wed Jan 27 18:16:25 2021 +0000
Display current line of source code when displaying current frame in debugger
installed-tests/debugger/down-up.debugger.output | 8 ++++++
installed-tests/debugger/frame.debugger.output | 2 ++
installed-tests/debugger/throw.debugger.output | 2 ++
modules/script/_bootstrap/debugger.js | 33 +++++++++++++-----------
4 files changed, 30 insertions(+), 15 deletions(-)
---
diff --git a/installed-tests/debugger/down-up.debugger.output
b/installed-tests/debugger/down-up.debugger.output
index 73f6191d..c8b1a3ba 100644
--- a/installed-tests/debugger/down-up.debugger.output
+++ b/installed-tests/debugger/down-up.debugger.output
@@ -7,21 +7,29 @@ db> down
Youngest frame selected; you cannot go down.
db> up
#1 c() at down-up.debugger.js:12:4
+ 12 d();
db> up
#2 b() at down-up.debugger.js:8:4
+ 8 c();
db> up
#3 a() at down-up.debugger.js:4:4
+ 4 b();
db> up
#4 toplevel at down-up.debugger.js:19:0
+ 19 a();
db> up
Initial frame selected; you cannot go up.
db> down
#3 a() at down-up.debugger.js:4:4
+ 4 b();
db> dn
#2 b() at down-up.debugger.js:8:4
+ 8 c();
db> dn
#1 c() at down-up.debugger.js:12:4
+ 12 d();
db> dn
#0 d() at down-up.debugger.js:16:4
+ 16 debugger;
db> c
Program exited with code 0
diff --git a/installed-tests/debugger/frame.debugger.output b/installed-tests/debugger/frame.debugger.output
index 25f9df99..9e456cda 100644
--- a/installed-tests/debugger/frame.debugger.output
+++ b/installed-tests/debugger/frame.debugger.output
@@ -5,7 +5,9 @@ db> c
Debugger statement, b() at frame.debugger.js:8:4
db> frame 2
#2 toplevel at frame.debugger.js:11:0
+ 11 a();
db> f 1
#1 a() at frame.debugger.js:4:4
+ 4 b();
db> c
Program exited with code 0
diff --git a/installed-tests/debugger/throw.debugger.output b/installed-tests/debugger/throw.debugger.output
index 4e9b5adc..3dd87088 100644
--- a/installed-tests/debugger/throw.debugger.output
+++ b/installed-tests/debugger/throw.debugger.output
@@ -6,6 +6,7 @@ Debugger statement, a() at throw.debugger.js:4:4
db> throw 'foobar' + 3.14;
Unwinding due to exception. (Type 'c' to continue unwinding.)
#0 a() at throw.debugger.js:4:4
+ 4 debugger;
Exception value is:
$1 = "foobar3.14"
db> fin
@@ -15,6 +16,7 @@ $2 = "foobar3.14"
(To rethrow it, type 'throw'.)
Unwinding due to exception. (Type 'c' to continue unwinding.)
#0 toplevel at throw.debugger.js:9:4
+ 9 a();
Exception value is:
$3 = "foobar3.14"
db> throw
diff --git a/modules/script/_bootstrap/debugger.js b/modules/script/_bootstrap/debugger.js
index 326ec8e9..d1b22ed9 100644
--- a/modules/script/_bootstrap/debugger.js
+++ b/modules/script/_bootstrap/debugger.js
@@ -140,7 +140,7 @@ Debugger.Script.prototype.describeOffset = function describeOffset(offset) {
return `${url}:${lineNumber}:${columnNumber}`;
};
-function showFrame(f, n, option) {
+function showFrame(f, n, option = {btCommand: false, fullOption: false}) {
if (f === undefined || f === null) {
f = focusedFrame;
if (f === null) {
@@ -153,19 +153,22 @@ function showFrame(f, n, option) {
if (n === undefined)
throw new Error('Internal error: frame not on stack');
}
- if (!option) {
- print(`#${n.toString().padEnd(4)} ${f.describeFull()}`);
- } else {
- const variables = f.environment.names();
- print(`#${n.toString().padEnd(4)} ${f.describeFull()}`);
- for (let i = 0; i < variables.length; i++) {
- if (variables.length === 0)
- print('No locals.');
-
- const value = f.environment.getVariable(variables[i]);
- const [brief] = debuggeeValueToString(value, {brief: false, pretty: false});
- print(`${variables[i]} = ${brief}`);
+ print(`#${n.toString().padEnd(4)} ${f.describeFull()}`);
+ if (option.btCommand) {
+ if (option.fullOption) {
+ const variables = f.environment.names();
+ for (let i = 0; i < variables.length; i++) {
+ if (variables.length === 0)
+ print('No locals.');
+
+ const value = f.environment.getVariable(variables[i]);
+ const [brief] = debuggeeValueToString(value, {brief: false, pretty: false});
+ print(`${variables[i]} = ${brief}`);
+ }
}
+ } else {
+ let lineNumber = f.line;
+ print(` ${lineNumber}\t${f.script.source.text.split('\n')[lineNumber - 1]}`);
}
}
@@ -205,10 +208,10 @@ function backtraceCommand(option) {
print('No stack.');
if (option === '') {
for (let i = 0, f = topFrame; f; i++, f = f.older)
- showFrame(f, i, false);
+ showFrame(f, i, {btCommand: true, fullOption: false});
} else if (option === 'full') {
for (let i = 0, f = topFrame; f; i++, f = f.older)
- showFrame(f, i, true);
+ showFrame(f, i, {btCommand: true, fullOption: true});
} else {
print('Invalid option');
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]