forked from OSchip/llvm-project
Introudce a IsTopLevelFunction() API on Language and Function
This is meant to support languages that have a scripting mode with top-level code that acts as global For now, this flag only controls whether 'frame variable' will attempt to treat globals as locals when within such a function llvm-svn: 248960
This commit is contained in:
parent
6dec87a8a0
commit
6754e04f6d
|
@ -631,6 +631,24 @@ public:
|
|||
//------------------------------------------------------------------
|
||||
bool
|
||||
GetIsOptimized ();
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Get whether this function represents a 'top-level' function
|
||||
///
|
||||
/// The concept of a top-level function is language-specific, mostly
|
||||
/// meant to represent the notion of scripting-style code that has
|
||||
/// global visibility of the variables/symbols/functions/...
|
||||
/// defined within the containing file/module
|
||||
///
|
||||
/// If stopped in a top-level function, LLDB will expose global variables
|
||||
/// as-if locals in the 'frame variable' command
|
||||
///
|
||||
/// @return
|
||||
/// Returns 'true' if this function is a top-level function,
|
||||
/// 'false' otherwise.
|
||||
//------------------------------------------------------------------
|
||||
bool
|
||||
IsTopLevelFunction ();
|
||||
|
||||
lldb::DisassemblerSP
|
||||
GetInstructions (const ExecutionContext &exe_ctx,
|
||||
|
|
|
@ -41,6 +41,9 @@ public:
|
|||
virtual lldb::LanguageType
|
||||
GetLanguageType () const = 0;
|
||||
|
||||
bool
|
||||
IsTopLevelFunction (Function& function);
|
||||
|
||||
virtual lldb::TypeCategoryImplSP
|
||||
GetFormatters ();
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "lldb/Interpreter/OptionGroupVariable.h"
|
||||
#include "lldb/Symbol/CompilerType.h"
|
||||
#include "lldb/Symbol/ClangASTContext.h"
|
||||
#include "lldb/Symbol/Function.h"
|
||||
#include "lldb/Symbol/ObjectFile.h"
|
||||
#include "lldb/Symbol/SymbolContext.h"
|
||||
#include "lldb/Symbol/Type.h"
|
||||
|
@ -409,6 +410,10 @@ protected:
|
|||
|
||||
DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(eLanguageRuntimeDescriptionDisplayVerbosityFull,eFormatDefault,summary_format_sp));
|
||||
|
||||
const SymbolContext& sym_ctx = frame->GetSymbolContext(eSymbolContextFunction);
|
||||
if (sym_ctx.function && sym_ctx.function->IsTopLevelFunction())
|
||||
m_option_variable.show_globals = true;
|
||||
|
||||
if (variable_list)
|
||||
{
|
||||
const Format format = m_option_format.GetFormat();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "lldb/Symbol/LineTable.h"
|
||||
#include "lldb/Symbol/SymbolFile.h"
|
||||
#include "lldb/Symbol/SymbolVendor.h"
|
||||
#include "lldb/Target/Language.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
||||
using namespace lldb;
|
||||
|
@ -481,6 +482,17 @@ Function::GetIsOptimized ()
|
|||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
Function::IsTopLevelFunction ()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (Language* language = Language::FindPlugin(GetLanguage()))
|
||||
result = language->IsTopLevelFunction(*this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ConstString
|
||||
Function::GetDisplayName () const
|
||||
{
|
||||
|
|
|
@ -89,6 +89,12 @@ Language::ForEach (std::function<bool(Language*)> callback)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Language::IsTopLevelFunction (Function& function)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
lldb::TypeCategoryImplSP
|
||||
Language::GetFormatters ()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue