File: plugins.c

package info (click to toggle)
drgn 0.0.33-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,892 kB
  • sloc: python: 59,081; ansic: 51,400; awk: 423; makefile: 339; sh: 113
file content (32 lines) | stat: -rw-r--r-- 862 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) Meta Platforms, Inc. and affiliates.
// SPDX-License-Identifier: LGPL-2.1-or-later

#include "drgnpy.h"
#include "../plugins.h"

void drgn_call_plugins_prog(const char *name, struct drgn_program *prog)
{
	PyGILState_guard();

	static PyObject *call_plugins;
	if (!call_plugins) {
		_cleanup_pydecref_ PyObject *_drgn_util_plugins_module =
			PyImport_ImportModule("_drgn_util.plugins");
		if (!_drgn_util_plugins_module) {
			PyErr_WriteUnraisable(NULL);
			return;
		}
		call_plugins = PyObject_GetAttrString(_drgn_util_plugins_module,
						      "call_plugins");
		if (!call_plugins) {
			PyErr_WriteUnraisable(NULL);
			return;
		}
	}

	Program *prog_obj = container_of(prog, Program, prog);
	_cleanup_pydecref_ PyObject *res =
		PyObject_CallFunction(call_plugins, "sO", name, prog_obj);
	if (!res)
		PyErr_WriteUnraisable(call_plugins);
}