Add gdb.current_language and gdb.Frame.language
This adds the gdb.current_language function, which can be used to find the current language without (1) ever having the value "auto" or (2) having to parse the output of "show language". It also adds the gdb.Frame.language, which can be used to find the language of a given frame. This is normally preferable if one has a Frame object handy.
This commit is contained in:
parent
46c7fd95fc
commit
80fa4b2a60
7 changed files with 78 additions and 0 deletions
|
@ -1571,6 +1571,14 @@ gdbpy_progspaces (PyObject *unused1, PyObject *unused2)
|
|||
return list.release ();
|
||||
}
|
||||
|
||||
/* Return the name of the current language. */
|
||||
|
||||
static PyObject *
|
||||
gdbpy_current_language (PyObject *unused1, PyObject *unused2)
|
||||
{
|
||||
return host_string_to_python_string (current_language->name ()).release ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* The "current" objfile. This is set when gdb detects that a new
|
||||
|
@ -2534,6 +2542,10 @@ Format ADDRESS, an address within PROG_SPACE, a gdb.Progspace, using\n\
|
|||
ARCH, a gdb.Architecture to determine the address size. The format of\n\
|
||||
the returned string is 'ADDRESS <SYMBOL+OFFSET>' without the quotes." },
|
||||
|
||||
{ "current_language", gdbpy_current_language, METH_NOARGS,
|
||||
"current_language () -> string\n\
|
||||
Return the name of the currently selected language." },
|
||||
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue