| 1 |
// Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
#include "drgnpy.h" |
| 5 |
#include "../plugins.h" |
| 6 |
|
| 7 |
void drgn_call_plugins_prog(const char *name, struct drgn_program *prog) |
| 8 |
{ |
| 9 |
PyGILState_guard(); |
| 10 |
|
| 11 |
static PyObject *call_plugins; |
| 12 |
if (!call_plugins) { |
| 13 |
_cleanup_pydecref_ PyObject *_drgn_util_plugins_module = |
| 14 |
PyImport_ImportModule("_drgn_util.plugins"); |
| 15 |
if (!_drgn_util_plugins_module) { |
| 16 |
PyErr_WriteUnraisable(NULL); |
| 17 |
return; |
| 18 |
} |
| 19 |
call_plugins = PyObject_GetAttrString(_drgn_util_plugins_module, |
| 20 |
"call_plugins"); |
| 21 |
if (!call_plugins) { |
| 22 |
PyErr_WriteUnraisable(NULL); |
| 23 |
return; |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
Program *prog_obj = container_of(prog, Program, prog); |
| 28 |
_cleanup_pydecref_ PyObject *res = |
| 29 |
PyObject_CallFunction(call_plugins, "sO", name, prog_obj); |
| 30 |
if (!res) |
| 31 |
PyErr_WriteUnraisable(call_plugins); |
| 32 |
} |