diff --git a/lldb/include/lldb/Core/FormatEntity.h b/lldb/include/lldb/Core/FormatEntity.h index 4ae4fd38dbb7..db4f59132832 100644 --- a/lldb/include/lldb/Core/FormatEntity.h +++ b/lldb/include/lldb/Core/FormatEntity.h @@ -61,6 +61,7 @@ namespace lldb_private ScriptTarget, ModuleFile, File, + Lang, FrameIndex, FrameRegisterPC, FrameRegisterSP, diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index b1f28ae17c3f..1dec0bfb97e3 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Debugger.h" +#include "lldb/Core/Language.h" #include "lldb/Core/Module.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamString.h" @@ -210,6 +211,7 @@ static FormatEntity::Entry::Definition g_top_level_entries[] = ENTRY_CHILDREN ("ansi" , Invalid , None , g_ansi_entries), ENTRY ("current-pc-arrow" , CurrentPCArrow , CString ), ENTRY_CHILDREN ("file" , File , CString , g_file_child_entries), + ENTRY ("language" , Lang , CString), ENTRY_CHILDREN ("frame" , Invalid , None , g_frame_child_entries), ENTRY_CHILDREN ("function" , Invalid , None , g_function_child_entries), ENTRY_CHILDREN ("line" , Invalid , None , g_line_child_entries), @@ -321,6 +323,7 @@ FormatEntity::Entry::TypeToCString (Type t) ENUM_TO_CSTR(ScriptTarget); ENUM_TO_CSTR(ModuleFile); ENUM_TO_CSTR(File); + ENUM_TO_CSTR(Lang); ENUM_TO_CSTR(FrameIndex); ENUM_TO_CSTR(FrameRegisterPC); ENUM_TO_CSTR(FrameRegisterSP); @@ -1515,6 +1518,23 @@ FormatEntity::Format (const Entry &entry, } return false; + case Entry::Type::Lang: + if (sc) + { + CompileUnit *cu = sc->comp_unit; + if (cu) + { + Language lang(cu->GetLanguage()); + const char *lang_name = lang.AsCString(); + if (lang_name) + { + s.PutCString(lang_name); + return true; + } + } + } + return false; + case Entry::Type::FrameIndex: if (exe_ctx) { diff --git a/lldb/test/settings/TestSettings.py b/lldb/test/settings/TestSettings.py index 4305107936c2..17d34b73f6a9 100644 --- a/lldb/test/settings/TestSettings.py +++ b/lldb/test/settings/TestSettings.py @@ -129,7 +129,7 @@ class SettingsCommandTestCase(TestBase): self.format_string = m.group(1) # Change the default format to print function.name rather than function.name-with-args - format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}\n" + format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, lang=${language}}\n" self.runCmd("settings set frame-format %s" % format_string) # Immediately test the setting. diff --git a/lldb/www/formats.html b/lldb/www/formats.html index cbc32ad0052b..58db831d596f 100755 --- a/lldb/www/formats.html +++ b/lldb/www/formats.html @@ -73,6 +73,7 @@ Variable NameDescription file.basenameThe current compile unit file basename for the current frame. file.fullpathThe current compile unit file fullpath for the current frame. + languageThe current compile unit language for the current frame. frame.indexThe frame index (0, 1, 2, 3...) frame.pcThe generic frame register for the program counter. frame.spThe generic frame register for the stack pointer.