From 397a02ac232ffca5df9dd5072b9bc64b6f8d58c9 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Fri, 30 Apr 2021 12:09:09 -0500 Subject: [PATCH 01/12] Check for LLDB up to version 20 in Linux --- scripts/linux.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/linux.js b/scripts/linux.js index 40d0bbd0..d58fa468 100644 --- a/scripts/linux.js +++ b/scripts/linux.js @@ -21,10 +21,15 @@ function getLldbExecutable() { return process.env.npm_config_lldb_exe; } - const lldbExeNames = [ - 'lldb', 'lldb-5.0', 'lldb-4.0', - 'lldb-3.9', 'lldb-3.8', 'lldb-3.7', 'lldb-3.6' - ]; + // Use `Array.prototype.concat.apply` to support + // runtimes without `Array.prototype.flatMap`. + // Look for LLDB up to version 20. + const versions = Array.prototype.concat.apply([], + Array.from({length: 20}, (_, i) => i + 1).map((major) => + Array.from({ length: major < 4 ? 10 : 1 }, (_, minor) => major + '.' + minor) + )); + + const lldbExeNames = ['lldb'].concat(versions.reverse().map((v) => 'lldb-' + v)); return lldb.tryExecutables(lldbExeNames); } From 3161e9f9a3e932392336518ff94d603b93415160 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Fri, 30 Apr 2021 12:09:33 -0500 Subject: [PATCH 02/12] Fetch headers from official LLVM github monorepo --- scripts/lldb.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/scripts/lldb.js b/scripts/lldb.js index 06226ad3..c0107eee 100644 --- a/scripts/lldb.js +++ b/scripts/lldb.js @@ -10,7 +10,23 @@ const fs = require('fs'); * @returns {string} Branch of the corresponding lldb release */ function versionToBranch(version) { - return 'release_' + version.replace('.', ''); + // `llvm-project` v1-3 branches are in the form `release/major.minor.x`: + // release/1.0.x ... release/3.9.x + // `llvm-project` v4-latest branches are in the form `release/major.x`: + // release/4.x ... release/12.x + + // split into array of semver components + var chars = (version.indexOf('.') === -1 + ? version.split('') // split `39` into ['3', '9'] + : version.split('.').filter(x => x !== '.') // split `3.9` into ['3', '9'] + ); + + // if version < 4, keep `major.minor` components + // if version >= 4, only keep `major` component + chars = chars.slice(0, (+chars[0] >= 4) ? 1 : 2); + + // join components into the form `release/3.9.x` + return 'release/' + chars.concat('x').join('.'); } /** @@ -44,18 +60,30 @@ function cloneHeaders(lldbVersion, buildDir) { if (!fs.existsSync(lldbInstallDir)) { console.log(`\nCloning lldb ${lldbHeadersBranch} into ${lldbInstallDir}`); + // use `git clone --filter` in git v2.19 to only download `lldb` dir of `llvm-project` monorepo + // see: https://stackoverflow.com/a/52269934/3117331 + // see: https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout/ child_process.execFileSync( 'git', ['clone', '--depth', '1', + '--filter=blob:none', + '--sparse', '--branch', lldbHeadersBranch, - 'https://github.com/llvm-mirror/lldb.git', + 'https://github.com/llvm/llvm-project.git', lldbInstallDir ], { stdio: 'inherit' }); // show progress + child_process.execFileSync( + 'git', [ + '-C', lldbInstallDir, + 'sparse-checkout', + 'set', 'lldb' + ], + { stdio: 'inherit' }); // show progress } else { console.log(`\nSkip cloning lldb headers because ${lldbInstallDir} exists`); } - return path.join(lldbInstallDir, 'include'); + return path.join(lldbInstallDir, 'lldb', 'include'); } /** From 46bc04dd7cfc06bfaed074989272fe49e9f636a2 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 18 Nov 2021 09:30:30 -0600 Subject: [PATCH 03/12] add llvm 10-13 to github actions matrix in push.yml --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 1ad8cf50..d18b1a01 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -28,7 +28,7 @@ jobs: # https://github.com/nodejs/node/issues/32981 is fixed # TODO(mmarchini): test on 20.04 (need different lldb version) os: [ubuntu-18.04, ubuntu-20.04] - llvm: [ 8, 9 ] + llvm: [ 8, 9, 10, 11, 12, 13 ] steps: - uses: actions/checkout@v1 - name: Use Node.js ${{ matrix.node.version }} ${{ matrix.node.mirror }} From 5872b4961ea1e2449d66129ccbdb68b3ff403139 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 30 Jun 2022 12:46:06 -0700 Subject: [PATCH 04/12] install lldb from llvm apt repos when not packaged by Ubuntu, update node versions matrix --- .github/workflows/push.yml | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index d18b1a01..a1cba87d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -19,16 +19,18 @@ jobs: - version: 10.x - version: 12.x - version: 14.x - - version: 15.x + - version: 16.x + - version: 18.x + - version: 19.x mirror: https://nodejs.org/download/nightly - - version: 15.x + - version: 19.x mirror: https://nodejs.org/download/v8-canary # os: [ubuntu-latest, macos-latest] # Temporarily disable MacOS until # https://github.com/nodejs/node/issues/32981 is fixed # TODO(mmarchini): test on 20.04 (need different lldb version) os: [ubuntu-18.04, ubuntu-20.04] - llvm: [ 8, 9, 10, 11, 12, 13 ] + llvm: [8, 9, 10, 11, 12, 13, 14] steps: - uses: actions/checkout@v1 - name: Use Node.js ${{ matrix.node.version }} ${{ matrix.node.mirror }} @@ -40,6 +42,28 @@ jobs: - name: install dependencies Linux if: startsWith(matrix.os, 'ubuntu-') run: | + use_llvm_repos=0 + + case "${{ matrix.os }}-${{ matrix.llvm }}" in + ubuntu18.04-10) use_llvm_repos=1;; + ubuntu18.04-11) use_llvm_repos=1;; + ubuntu18.04-12) use_llvm_repos=1;; + ubuntu18.04-13) use_llvm_repos=1;; + ubuntu18.04-14) use_llvm_repos=1;; + ubuntu20.04-13) use_llvm_repos=1;; + ubuntu20.04-14) use_llvm_repos=1;; + *) use_llvm_repos=0;; + esac + + if [[ ${use_llvm_repos} == 1 ]]; then + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -; + release="$(lsb_release -cs)" + cat << EOF | sudo tee /etc/apt/sources.list.d/llvm-${{ matrix.llvm }}.list + deb http://apt.llvm.org/${release}/ llvm-toolchain-${release}-${{ matrix.llvm }} main + deb-src http://apt.llvm.org/${release}/ llvm-toolchain-${release}-${{ matrix.llvm }} main + EOF + fi + sudo apt-get -qq update sudo apt-get install lldb-${{ matrix.llvm }} liblldb-${{ matrix.llvm }}-dev lcov gdb -y sudo ln -s $(which lldb-${{ matrix.llvm }}) /usr/bin/lldb @@ -48,13 +72,13 @@ jobs: npm install --llnode_build_addon=true --llnode_coverage=true - name: run tests run: TEST_LLDB_BINARY=`which lldb-${{ matrix.llvm }}` npm run nyc-test-all - if: matrix.node.version != '15.x' + if: matrix.node.version != '19.x' - name: run tests (nightly) run: TEST_LLDB_BINARY=`which lldb-${{ matrix.llvm }}` npm run nyc-test-all - if: matrix.node.version == '15.x' + if: matrix.node.version == '19.x' continue-on-error: true - name: prepare coverage - if: startsWith(matrix.os, 'ubuntu-') && matrix.node.version != '15.x' + if: startsWith(matrix.os, 'ubuntu-') && matrix.node.version != '19.x' run: | npm run coverage cat ./coverage-js.info > ./coverage.info @@ -70,7 +94,7 @@ jobs: - name: Use Node.js LTS uses: actions/setup-node@v1 with: - node-version: 12.x + node-version: 18.x - name: npm install, build, and test run: | sudo apt-get -qq update From d5144f33ea0acc5a02a698a12c841c5b50ff1c80 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 30 Jun 2022 12:48:37 -0700 Subject: [PATCH 05/12] fix bash whitespace --- .github/workflows/push.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index a1cba87d..74170156 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -59,9 +59,9 @@ jobs: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -; release="$(lsb_release -cs)" cat << EOF | sudo tee /etc/apt/sources.list.d/llvm-${{ matrix.llvm }}.list - deb http://apt.llvm.org/${release}/ llvm-toolchain-${release}-${{ matrix.llvm }} main - deb-src http://apt.llvm.org/${release}/ llvm-toolchain-${release}-${{ matrix.llvm }} main - EOF + deb http://apt.llvm.org/${release}/ llvm-toolchain-${release}-${{ matrix.llvm }} main + deb-src http://apt.llvm.org/${release}/ llvm-toolchain-${release}-${{ matrix.llvm }} main + EOF fi sudo apt-get -qq update From 3577f85590a7a4a54f5fe4d1c9d04ffffb04414e Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 30 Jun 2022 12:57:23 -0700 Subject: [PATCH 06/12] install lldb without prefix when using llvm apt repos --- .github/workflows/push.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 74170156..c0a075b1 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -43,6 +43,7 @@ jobs: if: startsWith(matrix.os, 'ubuntu-') run: | use_llvm_repos=0 + lldb_pkg="lldb-${{ matrix.llvm }}" case "${{ matrix.os }}-${{ matrix.llvm }}" in ubuntu18.04-10) use_llvm_repos=1;; @@ -56,6 +57,7 @@ jobs: esac if [[ ${use_llvm_repos} == 1 ]]; then + lldb_pkg="lldb"; wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -; release="$(lsb_release -cs)" cat << EOF | sudo tee /etc/apt/sources.list.d/llvm-${{ matrix.llvm }}.list @@ -65,8 +67,10 @@ jobs: fi sudo apt-get -qq update - sudo apt-get install lldb-${{ matrix.llvm }} liblldb-${{ matrix.llvm }}-dev lcov gdb -y - sudo ln -s $(which lldb-${{ matrix.llvm }}) /usr/bin/lldb + sudo apt-get install ${lldb_pkg} lib${lldb_pkg}-dev lcov gdb -y + if [[ -z "$(which lldb-${{ matrix.llvm }})" ]]; then + sudo ln -s "$(which lldb-${{ matrix.llvm }})" /usr/bin/lldb + fi - name: npm install run: | npm install --llnode_build_addon=true --llnode_coverage=true From c3a980fa98f44e4af248d6a3b0d4bee634b3b24d Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 30 Jun 2022 13:00:25 -0700 Subject: [PATCH 07/12] fix typos --- .github/workflows/push.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c0a075b1..6af2c6f0 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -43,21 +43,19 @@ jobs: if: startsWith(matrix.os, 'ubuntu-') run: | use_llvm_repos=0 - lldb_pkg="lldb-${{ matrix.llvm }}" case "${{ matrix.os }}-${{ matrix.llvm }}" in - ubuntu18.04-10) use_llvm_repos=1;; - ubuntu18.04-11) use_llvm_repos=1;; - ubuntu18.04-12) use_llvm_repos=1;; - ubuntu18.04-13) use_llvm_repos=1;; - ubuntu18.04-14) use_llvm_repos=1;; - ubuntu20.04-13) use_llvm_repos=1;; - ubuntu20.04-14) use_llvm_repos=1;; + ubuntu-18.04-10) use_llvm_repos=1;; + ubuntu-18.04-11) use_llvm_repos=1;; + ubuntu-18.04-12) use_llvm_repos=1;; + ubuntu-18.04-13) use_llvm_repos=1;; + ubuntu-18.04-14) use_llvm_repos=1;; + ubuntu-20.04-13) use_llvm_repos=1;; + ubuntu-20.04-14) use_llvm_repos=1;; *) use_llvm_repos=0;; esac if [[ ${use_llvm_repos} == 1 ]]; then - lldb_pkg="lldb"; wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -; release="$(lsb_release -cs)" cat << EOF | sudo tee /etc/apt/sources.list.d/llvm-${{ matrix.llvm }}.list @@ -67,10 +65,12 @@ jobs: fi sudo apt-get -qq update - sudo apt-get install ${lldb_pkg} lib${lldb_pkg}-dev lcov gdb -y - if [[ -z "$(which lldb-${{ matrix.llvm }})" ]]; then - sudo ln -s "$(which lldb-${{ matrix.llvm }})" /usr/bin/lldb - fi + sudo apt-get install -y --no-install-recommends \ + lcov gdb \ + lldb-${{ matrix.llvm }} \ + liblldb-${{ matrix.llvm }}-dev + + sudo ln -s "$(which lldb-${{ matrix.llvm }})" /usr/bin/lldb - name: npm install run: | npm install --llnode_build_addon=true --llnode_coverage=true From d65c0cf3162b5f596d57dc7ed8d267bed223b171 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 30 Jun 2022 13:06:04 -0700 Subject: [PATCH 08/12] also symlink llvm-config binary --- .github/workflows/push.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 6af2c6f0..8832360d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -70,7 +70,13 @@ jobs: lldb-${{ matrix.llvm }} \ liblldb-${{ matrix.llvm }}-dev - sudo ln -s "$(which lldb-${{ matrix.llvm }})" /usr/bin/lldb + if [[ -n "$(which lldb-${{ matrix.llvm }})" ]]; then + sudo ln -s "$(which lldb-${{ matrix.llvm }})" /usr/bin/lldb + fi + + if [[ -n "$(which llvm-config-${{ matrix.llvm }})" ]]; then + sudo ln -s "$(which llvm-config-${{ matrix.llvm }})" /usr/bin/llvm-config + fi - name: npm install run: | npm install --llnode_build_addon=true --llnode_coverage=true From 1113ceefb06efa76eae27bdd59f7fc77a1943044 Mon Sep 17 00:00:00 2001 From: Anton Whalley Date: Wed, 17 Aug 2022 20:14:32 +0100 Subject: [PATCH 09/12] test: update test for multi-line error Signed-off-by: Anton Whalley --- test/common.js | 29 +++++++++++++++++++++++------ test/plugin/inspect-test.js | 4 ++-- test/plugin/scan-test.js | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/test/common.js b/test/common.js index 14b890e9..2028e64b 100644 --- a/test/common.js +++ b/test/common.js @@ -52,12 +52,23 @@ function SessionOutput(session, stream, timeout) { if (!this.waiting) break - let index = buf.indexOf('\n'); + let line = ''; + let index = 0; + + let inv = buf.indexOf('invalid_expr'); + if (inv !== -1) { + line = buf; + index = buf.length; + } else { + + index = buf.indexOf('\n'); + + if (index === -1) + break; + + line = buf.slice(0, index); + } - if (index === -1) - break; - - const line = buf.slice(0, index); buf = buf.slice(index + 1); if (/process \d+ exited/i.test(line)) @@ -107,6 +118,7 @@ SessionOutput.prototype.wait = function wait(regexp, callback, allLines) { const lines = []; function onLine(line) { + // console.log(line); lines.push(line); if (self.session) debug(`[LINE][${self.session.lldb.pid}]`, line); @@ -197,9 +209,14 @@ function Session(options) { this.stderr = new SessionOutput(this, this.lldb.stderr, timeout); this.stderr.on('line', (line) => { - debug('[stderr]', line); + console.log("stderrorline:" + line); + }); + + this.stdout.on('line', (line) => { + }); + // Map these methods to stdout for compatibility with legacy tests. this.wait = SessionOutput.prototype.wait.bind(this.stdout); this.waitError = SessionOutput.prototype.wait.bind(this.stderr); diff --git a/test/plugin/inspect-test.js b/test/plugin/inspect-test.js index 75510fa0..0ff8f795 100644 --- a/test/plugin/inspect-test.js +++ b/test/plugin/inspect-test.js @@ -658,11 +658,11 @@ function verifyInvalidExpr(t, sess) { return teardown(t, sess, err); } t.ok( - /error: error: use of undeclared identifier 'invalid_expr'/.test(line), + /use of undeclared identifier 'invalid_expr'/.test(line), 'invalid expression should return an error' ); teardown(t, sess); - }); + }, false); } tape('v8 inspect', (t) => { diff --git a/test/plugin/scan-test.js b/test/plugin/scan-test.js index 13b2cbd4..475c4a16 100644 --- a/test/plugin/scan-test.js +++ b/test/plugin/scan-test.js @@ -27,7 +27,7 @@ function testFindrefsForInvalidExpr(t, sess, next) { sess.waitError(/error:/, (err, line) => { t.error(err); t.ok( - /error: error: use of undeclared identifier 'invalid_expr'/.test(line), + /use of undeclared identifier 'invalid_expr'/.test(line), 'invalid expression should return an error' ); next(); From 67d560b1cc854c8ee01fb2311627c4097e2a2874 Mon Sep 17 00:00:00 2001 From: Anton Whalley Date: Wed, 17 Aug 2022 20:26:00 +0100 Subject: [PATCH 10/12] test: remove 16 18 nightly Signed-off-by: Anton Whalley --- .github/workflows/push.yml | 12 ++++++------ test/common.js | 11 +---------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 8832360d..924032c6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -19,12 +19,12 @@ jobs: - version: 10.x - version: 12.x - version: 14.x - - version: 16.x - - version: 18.x - - version: 19.x - mirror: https://nodejs.org/download/nightly - - version: 19.x - mirror: https://nodejs.org/download/v8-canary + # - version: 16.x + # - version: 18.x + # - version: 19.x + # mirror: https://nodejs.org/download/nightly + # - version: 19.x + # mirror: https://nodejs.org/download/v8-canary # os: [ubuntu-latest, macos-latest] # Temporarily disable MacOS until # https://github.com/nodejs/node/issues/32981 is fixed diff --git a/test/common.js b/test/common.js index 2028e64b..773603ae 100644 --- a/test/common.js +++ b/test/common.js @@ -118,7 +118,7 @@ SessionOutput.prototype.wait = function wait(regexp, callback, allLines) { const lines = []; function onLine(line) { - // console.log(line); + lines.push(line); if (self.session) debug(`[LINE][${self.session.lldb.pid}]`, line); @@ -208,15 +208,6 @@ function Session(options) { this.stdout = new SessionOutput(this, this.lldb.stdout, timeout); this.stderr = new SessionOutput(this, this.lldb.stderr, timeout); - this.stderr.on('line', (line) => { - console.log("stderrorline:" + line); - }); - - this.stdout.on('line', (line) => { - - }); - - // Map these methods to stdout for compatibility with legacy tests. this.wait = SessionOutput.prototype.wait.bind(this.stdout); this.waitError = SessionOutput.prototype.wait.bind(this.stderr); From acbdb181a3ee40427ed092f4175923bf47df8c9a Mon Sep 17 00:00:00 2001 From: Anton Whalley Date: Wed, 17 Aug 2022 20:50:05 +0100 Subject: [PATCH 11/12] test: fix lib/lib mapping issue Signed-off-by: Anton Whalley --- .github/workflows/push.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 924032c6..96a4f361 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -72,6 +72,8 @@ jobs: if [[ -n "$(which lldb-${{ matrix.llvm }})" ]]; then sudo ln -s "$(which lldb-${{ matrix.llvm }})" /usr/bin/lldb + sudo mkdir -p /usr/lib/lib/python3.8 + sudo ln -s /usr/lib/llvm-${{ matrix.llvm }}/lib/python3.8/site-packages /usr/lib/lib/python3.8/site-packages fi if [[ -n "$(which llvm-config-${{ matrix.llvm }})" ]]; then From 5ea886a7ef41dac549a40cb4012fdb2e06f322e4 Mon Sep 17 00:00:00 2001 From: Anton Whalley Date: Wed, 17 Aug 2022 22:08:59 +0100 Subject: [PATCH 12/12] test: bump timeouts due to later lldbs Signed-off-by: Anton Whalley --- test/common.js | 4 ++-- test/plugin/workqueue-test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/common.js b/test/common.js index 773603ae..a54abed6 100644 --- a/test/common.js +++ b/test/common.js @@ -42,7 +42,7 @@ function SessionOutput(session, stream, timeout) { this.waiting = false; this.waitQueue = []; let buf = ''; - this.timeout = timeout || 10000; + this.timeout = timeout || 20000; this.session = session; this.flush = function flush() { @@ -170,7 +170,7 @@ SessionOutput.prototype.linesUntil = function linesUntil(regexp, callback) { function Session(options) { EventEmitter.call(this); - const timeout = parseInt(process.env.TEST_TIMEOUT) || 10000; + const timeout = parseInt(process.env.TEST_TIMEOUT) || 20000; const lldbBin = process.env.TEST_LLDB_BINARY || 'lldb'; const env = Object.assign({}, process.env); diff --git a/test/plugin/workqueue-test.js b/test/plugin/workqueue-test.js index 7fcb7a93..5ffda231 100644 --- a/test/plugin/workqueue-test.js +++ b/test/plugin/workqueue-test.js @@ -26,7 +26,7 @@ function testWorkqueueCommands(t, sess) { } tape('v8 workqueue commands', (t) => { - t.timeoutAfter(15000); + t.timeoutAfter(30000); const sess = common.Session.create('workqueue-scenario.js'); sess.timeoutAfter