From dc975670c194e0078d684546d49d06c661f163f7 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Tue, 23 Jun 2015 18:35:31 +0000 Subject: Add support for displaying the language in the frame-format string. Enable ${language} to be specified in the frame-format string to see the current frame's compile unit language in "frame info". Test Plan: debug a C++ program, run to main, and run the lldb commands: settings set frame-format "frame lang=${language}\n" frame info you should see: frame lang=c++ test case added in: ./dotest.py --executable lldb -f SettingsCommandTestCase.test_set_frame_format Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D10561 llvm-svn: 240440 --- lldb/source/Core/FormatEntity.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lldb/source/Core/FormatEntity.cpp') diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index b1f28ae17c3..1dec0bfb97e 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) { -- cgit v1.2.3