diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/gdb/lib-for-tests/catcher.py | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/gdb/lib-for-tests/catcher.py')
-rw-r--r-- | js/src/gdb/lib-for-tests/catcher.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/js/src/gdb/lib-for-tests/catcher.py b/js/src/gdb/lib-for-tests/catcher.py new file mode 100644 index 0000000000..8ef3529255 --- /dev/null +++ b/js/src/gdb/lib-for-tests/catcher.py @@ -0,0 +1,35 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +# Apparently, there's simply no way to ask GDB to exit with a non-zero +# status when the script run with the --eval-command option fails. Thus, if +# we have --eval-command run prologue.py directly, syntax errors there will +# lead GDB to exit with no indication anything went wrong. +# +# To avert that, we use this very small launcher script to run prologue.py +# and catch errors. +# +# Remember, errors in this file will cause spurious passes, so keep this as +# simple as possible! +# flake8: noqa: F821 + +import os +import sys +import traceback + + +def execfile(filename, globs, locs): + with open(filename) as f: + code = compile(f.read(), filename, "exec") + exec(code, globs, locs) + + +try: + # testlibdir is set on the GDB command line, via: + # --eval-command python testlibdir=... + execfile(os.path.join(testlibdir, "prologue.py"), globals(), locals()) +except Exception as err: + sys.stderr.write("Error running GDB prologue:\n") + traceback.print_exc() + sys.exit(1) |