A minimalist plugin manager for GDB, inspired by vim-plug.
- Simple plugin declaration syntax
- Automatic installation and updating of plugins from GitHub
- Support for both Python (.py) and GDB script (.gdb) plugins
- Autoload functionality
-
Copy the code into your
~/.gdbinitfile -
Alternatively, you can source it directly:
echo "source /path/to/gdb_plug.py" >> ~/.gdbinitAdd plugin declarations to your .gdbinit:
python
import os
import subprocess
import sys
# Auto install at first run
def load_gdbplug():
# Path configurations
plugin_dir = os.path.expanduser("~/.config/gdb")
plugin_path = os.path.join(plugin_dir, "gdbplug.py")
raw_plugin_url = "https://raw.githubusercontent.com/PEMessage/gdbplug/main/gdbplug.py"
if not os.path.exists(plugin_path):
print("Installing gdbplug...")
try:
os.makedirs(plugin_dir, exist_ok=True)
subprocess.run([
"curl", "-fLo", plugin_path,
"--create-dirs", raw_plugin_url
], check=True)
except Exception as e:
print(f"Installation failed: {e}")
sys.exit(1)
import gdb as G
G.execute("source {}".format(plugin_path))
load_gdbplug()
# Initialize plugin manager
Plug.begin(autoload=True) # global configuration
# Register plugins
if True:
Plug.plug("hugsy/gef") # Autoload by default
Plug.plug("cyrus-and/gdb-dashboard", autoload=False) # per-plug configuration
# Load all autoload plugins
Plug.end()
endPlug update [name...]- Update all or specified pluginsPlug list- List registered pluginsPlug load <name>- Load a specific plugin
When registering a plugin with Plug.plug():
repo: GitHub repository (required, format: "user/repo")name: Plugin name (defaults to repository name)directory: Installation directory (defaults to~/.config/gdb/plug/<name>)autoload: Whether to load automatically (default: True)
GDB_PLUG_HOME: Custom plugin installation directory (default:~/.config/gdb/plug)GDB_PLUG_AUTOLOAD: Overwirte global autoload configuration
- Register plugins in your
.gdbinit:
Plug.begin()
Plug.plug("hugsy/gef")
Plug.plug("cyrus-and/gdb-dashboard", autoload=False)
Plug.end()- Install the plugins:
(gdb) Plug update
- Manually load a plugin (if not autoloaded):
(gdb) Plug load GEP
- List installed plugins:
(gdb) Plug list
When loading a plugin, the manager looks for these files in order:
<plugin-name>.py<plugin-name>.gdbmain.pymain.gdb.gdbinitgdbinit-<plugin-name>.py(e.g.,gdbinit-gep.py)
GPL
This project was inspired by vim-plug's simplicity and effectiveness for managing Vim plugins.
Contributions are welcome! Please open issues or pull requests for any improvements, especially to the PlugCommand.complete function as noted in the source.