[Openmp-commits] [openmp] [OpenMP][OMPD] Fix GDB plugin to work correctly when installed (PR #153956)
Michał Górny via Openmp-commits
openmp-commits at lists.llvm.org
Sat Aug 16 07:44:12 PDT 2025
https://github.com/mgorny created https://github.com/llvm/llvm-project/pull/153956
Fix the `sys.path` logic in the GDB plugin to insert the intended self-path in the first position rather than appending it to the end. The latter implied that if `sys.path` (naturally) contained the GDB's `gdb-plugin` directory, `import ompd` would return the top-level `ompd/__init__.py` module rather than the `ompd/ompd.py` submodule, as intended by adding the `ompd/` directory to `sys.path`.
This is intended to be a minimal change necessary to fix the issue. Alternatively, the code could be modified to import `ompd.ompd` and stop modifying `sys.path` entirely. However, I do not know why this option was chosen in teh first place, so I can't tell if this won't break something.
Fixes #153954
>From d56cad31649ba499622b6114c18e4f334546789a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny at gentoo.org>
Date: Sat, 16 Aug 2025 16:37:37 +0200
Subject: [PATCH] [OpenMP][OMPD] Fix GDB plugin to work correctly when
installed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fix the `sys.path` logic in the GDB plugin to insert the intended
self-path in the first position rather than appending it to the end.
The latter implied that if `sys.path` (naturally) contained the GDB's
`gdb-plugin` directory, `import ompd` would return the top-level
`ompd/__init__.py` module rather than the `ompd/ompd.py` submodule,
as intended by adding the `ompd/` directory to `sys.path`.
This is intended to be a minimal change necessary to fix the issue.
Alternatively, the code could be modified to import `ompd.ompd`
and stop modifying `sys.path` entirely. However, I do not know why this
option was chosen in teh first place, so I can't tell if this won't
break something.
Fixes #153954
Signed-off-by: Michał Górny <mgorny at gentoo.org>
---
openmp/libompd/gdb-plugin/ompd/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openmp/libompd/gdb-plugin/ompd/__init__.py b/openmp/libompd/gdb-plugin/ompd/__init__.py
index b9f572dce8dce..ab30e65392ea2 100644
--- a/openmp/libompd/gdb-plugin/ompd/__init__.py
+++ b/openmp/libompd/gdb-plugin/ompd/__init__.py
@@ -4,7 +4,7 @@
if __name__ == "__main__":
try:
- sys.path.append(os.path.dirname(__file__))
+ sys.path.insert(0, os.path.dirname(__file__))
import ompd
More information about the Openmp-commits
mailing list