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:
Tom Tromey
2022-05-24 10:15:17 -06:00
parent 46c7fd95fc
commit 80fa4b2a60
7 changed files with 78 additions and 0 deletions

View File

@@ -668,6 +668,14 @@ Here are some examples of the possible string formats:
@end smallexample
@end defun
@defun gdb.current_language ()
Return the name of the current language as a string. Unlike
@code{gdb.parameter('language')}, this function will never return
@samp{auto}. If a @code{gdb.Frame} object is available (@pxref{Frames
In Python}), the @code{language} method might be preferable in some
cases, as that is not affected by the user's language setting.
@end defun
@node Exception Handling
@subsubsection Exception Handling
@cindex python exceptions
@@ -5202,6 +5210,10 @@ Stack}.
Return an integer, the stack frame level for this frame. @xref{Frames, ,Stack Frames}.
@end defun
@defun Frame.language ()
Return a string, the source language for this frame.
@end defun
@node Blocks In Python
@subsubsection Accessing blocks from Python