2010-06-09 00:52:24 +08:00
|
|
|
//===-- CompileUnit.cpp -----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Symbol/CompileUnit.h"
|
|
|
|
#include "lldb/Core/Module.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Symbol/LineTable.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/SymbolVendor.h"
|
|
|
|
#include "lldb/Symbol/VariableList.h"
|
2015-08-28 02:18:49 +08:00
|
|
|
#include "lldb/Target/LanguageRuntime.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2015-07-29 08:42:47 +08:00
|
|
|
CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language, bool is_optimized) :
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleChild(module_sp),
|
2010-10-21 04:54:39 +08:00
|
|
|
FileSpec (pathname, false),
|
2010-06-09 00:52:24 +08:00
|
|
|
UserID(cu_sym_id),
|
|
|
|
m_user_data (user_data),
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
m_language (language),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_flags (0),
|
|
|
|
m_functions (),
|
|
|
|
m_support_files (),
|
|
|
|
m_line_table_ap (),
|
2015-07-29 08:42:47 +08:00
|
|
|
m_variables(),
|
|
|
|
m_is_optimized (is_optimized)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
if (language != eLanguageTypeUnknown)
|
|
|
|
m_flags.Set(flagsParsedLanguage);
|
2012-02-24 09:59:29 +08:00
|
|
|
assert(module_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2015-07-29 08:42:47 +08:00
|
|
|
CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &fspec, const lldb::user_id_t cu_sym_id, lldb::LanguageType language, bool is_optimized) :
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleChild(module_sp),
|
2010-06-09 00:52:24 +08:00
|
|
|
FileSpec (fspec),
|
|
|
|
UserID(cu_sym_id),
|
|
|
|
m_user_data (user_data),
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
m_language (language),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_flags (0),
|
|
|
|
m_functions (),
|
|
|
|
m_support_files (),
|
|
|
|
m_line_table_ap (),
|
2015-07-29 08:42:47 +08:00
|
|
|
m_variables(),
|
|
|
|
m_is_optimized (is_optimized)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
if (language != eLanguageTypeUnknown)
|
|
|
|
m_flags.Set(flagsParsedLanguage);
|
2012-02-24 09:59:29 +08:00
|
|
|
assert(module_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CompileUnit::~CompileUnit ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompileUnit::CalculateSymbolContext(SymbolContext* sc)
|
|
|
|
{
|
|
|
|
sc->comp_unit = this;
|
|
|
|
GetModule()->CalculateSymbolContext(sc);
|
|
|
|
}
|
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleSP
|
2011-08-13 05:40:01 +08:00
|
|
|
CompileUnit::CalculateSymbolContextModule ()
|
|
|
|
{
|
|
|
|
return GetModule();
|
|
|
|
}
|
|
|
|
|
|
|
|
CompileUnit *
|
|
|
|
CompileUnit::CalculateSymbolContextCompileUnit ()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
CompileUnit::DumpSymbolContext(Stream *s)
|
|
|
|
{
|
|
|
|
GetModule()->DumpSymbolContext(s);
|
2012-11-30 05:49:15 +08:00
|
|
|
s->Printf(", CompileUnit{0x%8.8" PRIx64 "}", GetID());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-29 05:30:43 +08:00
|
|
|
void
|
|
|
|
CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const
|
|
|
|
{
|
2015-08-28 02:18:49 +08:00
|
|
|
const char* language = LanguageRuntime::GetNameForLanguageType(m_language);
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
*s << "id = " << (const UserID&)*this << ", file = \"" << (const FileSpec&)*this << "\", language = \"" << language << '"';
|
2010-06-29 05:30:43 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Dump the current contents of this object. No functions that cause on
|
|
|
|
// demand parsing of functions, globals, statics are called, so this
|
|
|
|
// is a good function to call to get an idea of the current contents of
|
|
|
|
// the CompileUnit object.
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
CompileUnit::Dump(Stream *s, bool show_context) const
|
|
|
|
{
|
2015-08-28 02:18:49 +08:00
|
|
|
const char* language = LanguageRuntime::GetNameForLanguageType(m_language);
|
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
s->Printf("%p: ", static_cast<const void*>(this));
|
2010-06-09 00:52:24 +08:00
|
|
|
s->Indent();
|
2014-04-04 12:06:10 +08:00
|
|
|
*s << "CompileUnit" << static_cast<const UserID&>(*this)
|
2015-08-28 02:18:49 +08:00
|
|
|
<< ", language = \"" << language
|
2014-04-04 12:06:10 +08:00
|
|
|
<< "\", file = '" << static_cast<const FileSpec&>(*this) << "'\n";
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
// m_types.Dump(s);
|
|
|
|
|
|
|
|
if (m_variables.get())
|
|
|
|
{
|
|
|
|
s->IndentMore();
|
|
|
|
m_variables->Dump(s, show_context);
|
|
|
|
s->IndentLess();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m_functions.empty())
|
|
|
|
{
|
|
|
|
s->IndentMore();
|
|
|
|
std::vector<FunctionSP>::const_iterator pos;
|
|
|
|
std::vector<FunctionSP>::const_iterator end = m_functions.end();
|
|
|
|
for (pos = m_functions.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
(*pos)->Dump(s, show_context);
|
|
|
|
}
|
|
|
|
|
|
|
|
s->IndentLess();
|
|
|
|
s->EOL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Add a function to this compile unit
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
CompileUnit::AddFunction(FunctionSP& funcSP)
|
|
|
|
{
|
|
|
|
// TODO: order these by address
|
|
|
|
m_functions.push_back(funcSP);
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionSP
|
|
|
|
CompileUnit::GetFunctionAtIndex (size_t idx)
|
|
|
|
{
|
|
|
|
FunctionSP funcSP;
|
|
|
|
if (idx < m_functions.size())
|
|
|
|
funcSP = m_functions[idx];
|
|
|
|
return funcSP;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-06-18 13:27:05 +08:00
|
|
|
// Find functions using the Mangled::Tokens token list. This
|
|
|
|
// function currently implements an interactive approach designed to find
|
|
|
|
// all instances of certain functions. It isn't designed to the
|
2010-06-09 00:52:24 +08:00
|
|
|
// quickest way to lookup functions as it will need to iterate through
|
|
|
|
// all functions and see if they match, though it does provide a powerful
|
|
|
|
// and context sensitive way to search for all functions with a certain
|
|
|
|
// name, all functions in a namespace, or all functions of a template
|
|
|
|
// type. See Mangled::Tokens::Parse() comments for more information.
|
|
|
|
//
|
|
|
|
// The function prototype will need to change to return a list of
|
|
|
|
// results. It was originally used to help debug the Mangled class
|
|
|
|
// and the Mangled::Tokens::MatchesQuery() function and it currently
|
|
|
|
// will print out a list of matching results for the functions that
|
|
|
|
// are currently in this compile unit.
|
|
|
|
//
|
|
|
|
// A FindFunctions method should be called prior to this that takes
|
|
|
|
// a regular function name (const char * or ConstString as a parameter)
|
|
|
|
// before resorting to this slower but more complete function. The
|
|
|
|
// other FindFunctions method should be able to take advantage of any
|
|
|
|
// accelerator tables available in the debug information (which is
|
|
|
|
// parsed by the SymbolFile parser plug-ins and registered with each
|
|
|
|
// Module).
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//void
|
|
|
|
//CompileUnit::FindFunctions(const Mangled::Tokens& tokens)
|
|
|
|
//{
|
|
|
|
// if (!m_functions.empty())
|
|
|
|
// {
|
|
|
|
// Stream s(stdout);
|
|
|
|
// std::vector<FunctionSP>::const_iterator pos;
|
|
|
|
// std::vector<FunctionSP>::const_iterator end = m_functions.end();
|
|
|
|
// for (pos = m_functions.begin(); pos != end; ++pos)
|
|
|
|
// {
|
|
|
|
// const ConstString& demangled = (*pos)->Mangled().Demangled();
|
|
|
|
// if (demangled)
|
|
|
|
// {
|
|
|
|
// const Mangled::Tokens& func_tokens = (*pos)->Mangled().GetTokens();
|
|
|
|
// if (func_tokens.MatchesQuery (tokens))
|
|
|
|
// s << "demangled MATCH found: " << demangled << "\n";
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
FunctionSP
|
|
|
|
CompileUnit::FindFunctionByUID (lldb::user_id_t func_uid)
|
|
|
|
{
|
|
|
|
FunctionSP funcSP;
|
|
|
|
if (!m_functions.empty())
|
|
|
|
{
|
|
|
|
std::vector<FunctionSP>::const_iterator pos;
|
|
|
|
std::vector<FunctionSP>::const_iterator end = m_functions.end();
|
|
|
|
for (pos = m_functions.begin(); pos != end; ++pos)
|
|
|
|
{
|
|
|
|
if ((*pos)->GetID() == func_uid)
|
|
|
|
{
|
|
|
|
funcSP = *pos;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return funcSP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
lldb::LanguageType
|
|
|
|
CompileUnit::GetLanguage()
|
|
|
|
{
|
|
|
|
if (m_language == eLanguageTypeUnknown)
|
|
|
|
{
|
|
|
|
if (m_flags.IsClear(flagsParsedLanguage))
|
|
|
|
{
|
|
|
|
m_flags.Set(flagsParsedLanguage);
|
|
|
|
SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor();
|
|
|
|
if (symbol_vendor)
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
CalculateSymbolContext(&sc);
|
|
|
|
m_language = symbol_vendor->ParseCompileUnitLanguage(sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_language;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
LineTable*
|
|
|
|
CompileUnit::GetLineTable()
|
|
|
|
{
|
2014-04-20 21:17:36 +08:00
|
|
|
if (m_line_table_ap.get() == nullptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (m_flags.IsClear(flagsParsedLineTable))
|
|
|
|
{
|
|
|
|
m_flags.Set(flagsParsedLineTable);
|
|
|
|
SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor();
|
|
|
|
if (symbol_vendor)
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
CalculateSymbolContext(&sc);
|
|
|
|
symbol_vendor->ParseCompileUnitLineTable(sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_line_table_ap.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CompileUnit::SetLineTable(LineTable* line_table)
|
|
|
|
{
|
2014-04-20 21:17:36 +08:00
|
|
|
if (line_table == nullptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
m_flags.Clear(flagsParsedLineTable);
|
|
|
|
else
|
|
|
|
m_flags.Set(flagsParsedLineTable);
|
|
|
|
m_line_table_ap.reset(line_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
VariableListSP
|
|
|
|
CompileUnit::GetVariableList(bool can_create)
|
|
|
|
{
|
2014-04-20 21:17:36 +08:00
|
|
|
if (m_variables.get() == nullptr && can_create)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
CalculateSymbolContext(&sc);
|
|
|
|
assert(sc.module_sp);
|
|
|
|
sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_variables;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2011-09-23 08:54:11 +08:00
|
|
|
CompileUnit::FindLineEntry (uint32_t start_idx, uint32_t line, const FileSpec* file_spec_ptr, bool exact, LineEntry *line_entry_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
uint32_t file_idx = 0;
|
|
|
|
|
|
|
|
if (file_spec_ptr)
|
|
|
|
{
|
2011-09-23 08:54:11 +08:00
|
|
|
file_idx = GetSupportFiles().FindFileIndex (1, *file_spec_ptr, true);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (file_idx == UINT32_MAX)
|
|
|
|
return UINT32_MAX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// All the line table entries actually point to the version of the Compile
|
2015-06-18 13:27:05 +08:00
|
|
|
// Unit that is in the support files (the one at 0 was artificially added.)
|
2010-06-09 00:52:24 +08:00
|
|
|
// So prefer the one further on in the support files if it exists...
|
|
|
|
FileSpecList &support_files = GetSupportFiles();
|
2011-09-23 08:54:11 +08:00
|
|
|
const bool full = true;
|
|
|
|
file_idx = support_files.FindFileIndex (1, support_files.GetFileSpecAtIndex(0), full);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (file_idx == UINT32_MAX)
|
|
|
|
file_idx = 0;
|
|
|
|
}
|
|
|
|
LineTable *line_table = GetLineTable();
|
|
|
|
if (line_table)
|
2011-09-23 08:54:11 +08:00
|
|
|
return line_table->FindLineEntryIndexByFileIndex (start_idx, file_idx, line, exact, line_entry_ptr);
|
2010-06-09 00:52:24 +08:00
|
|
|
return UINT32_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
CompileUnit::ResolveSymbolContext
|
|
|
|
(
|
|
|
|
const FileSpec& file_spec,
|
|
|
|
uint32_t line,
|
|
|
|
bool check_inlines,
|
|
|
|
bool exact,
|
|
|
|
uint32_t resolve_scope,
|
|
|
|
SymbolContextList &sc_list
|
|
|
|
)
|
|
|
|
{
|
2010-09-12 14:24:05 +08:00
|
|
|
// First find all of the file indexes that match our "file_spec". If
|
|
|
|
// "file_spec" has an empty directory, then only compare the basenames
|
|
|
|
// when finding file indexes
|
|
|
|
std::vector<uint32_t> file_indexes;
|
2013-10-04 06:27:29 +08:00
|
|
|
const bool full_match = (bool)file_spec.GetDirectory();
|
2014-11-15 09:54:26 +08:00
|
|
|
const bool remove_backup_dots = true;
|
|
|
|
bool file_spec_matches_cu_file_spec = FileSpec::Equal(file_spec, *this, full_match, remove_backup_dots);
|
2010-09-12 14:24:05 +08:00
|
|
|
|
|
|
|
// If we are not looking for inlined functions and our file spec doesn't
|
|
|
|
// match then we are done...
|
|
|
|
if (file_spec_matches_cu_file_spec == false && check_inlines == false)
|
|
|
|
return 0;
|
|
|
|
|
2014-11-15 09:54:26 +08:00
|
|
|
uint32_t file_idx = GetSupportFiles().FindFileIndex (1, file_spec, true, remove_backup_dots);
|
2010-09-12 14:24:05 +08:00
|
|
|
while (file_idx != UINT32_MAX)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-09-12 14:24:05 +08:00
|
|
|
file_indexes.push_back (file_idx);
|
2014-11-15 09:54:26 +08:00
|
|
|
file_idx = GetSupportFiles().FindFileIndex (file_idx + 1, file_spec, true, remove_backup_dots);
|
2010-09-12 14:24:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const size_t num_file_indexes = file_indexes.size();
|
|
|
|
if (num_file_indexes == 0)
|
|
|
|
return 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-09-12 14:24:05 +08:00
|
|
|
const uint32_t prev_size = sc_list.GetSize();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-09-12 14:24:05 +08:00
|
|
|
SymbolContext sc(GetModule());
|
|
|
|
sc.comp_unit = this;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
2010-09-12 14:24:05 +08:00
|
|
|
if (line != 0)
|
|
|
|
{
|
|
|
|
LineTable *line_table = sc.comp_unit->GetLineTable();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2014-04-20 21:17:36 +08:00
|
|
|
if (line_table != nullptr)
|
2010-09-12 14:24:05 +08:00
|
|
|
{
|
|
|
|
uint32_t found_line;
|
|
|
|
uint32_t line_idx;
|
|
|
|
|
|
|
|
if (num_file_indexes == 1)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-09-12 14:24:05 +08:00
|
|
|
// We only have a single support file that matches, so use
|
|
|
|
// the line table function that searches for a line entries
|
|
|
|
// that match a single support file index
|
2012-05-22 07:06:47 +08:00
|
|
|
LineEntry line_entry;
|
|
|
|
line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_indexes.front(), line, exact, &line_entry);
|
2010-09-12 14:24:05 +08:00
|
|
|
|
|
|
|
// If "exact == true", then "found_line" will be the same
|
|
|
|
// as "line". If "exact == false", the "found_line" will be the
|
|
|
|
// closest line entry with a line number greater than "line" and
|
|
|
|
// we will use this for our subsequent line exact matches below.
|
2012-05-22 07:06:47 +08:00
|
|
|
found_line = line_entry.line;
|
2010-09-12 14:24:05 +08:00
|
|
|
|
2010-09-14 10:20:48 +08:00
|
|
|
while (line_idx != UINT32_MAX)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-05-22 07:06:47 +08:00
|
|
|
// If they only asked for the line entry, then we're done, we can just copy that over.
|
|
|
|
// But if they wanted more than just the line number, fill it in.
|
|
|
|
if (resolve_scope == eSymbolContextLineEntry)
|
|
|
|
{
|
|
|
|
sc.line_entry = line_entry;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope);
|
|
|
|
}
|
|
|
|
|
2010-09-12 14:24:05 +08:00
|
|
|
sc_list.Append(sc);
|
2012-05-22 07:06:47 +08:00
|
|
|
line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes.front(), found_line, true, &line_entry);
|
2010-09-12 14:24:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We found multiple support files that match "file_spec" so use
|
|
|
|
// the line table function that searches for a line entries
|
|
|
|
// that match a multiple support file indexes.
|
2012-05-22 07:06:47 +08:00
|
|
|
LineEntry line_entry;
|
|
|
|
line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_indexes, line, exact, &line_entry);
|
2010-09-12 14:24:05 +08:00
|
|
|
|
|
|
|
// If "exact == true", then "found_line" will be the same
|
|
|
|
// as "line". If "exact == false", the "found_line" will be the
|
|
|
|
// closest line entry with a line number greater than "line" and
|
|
|
|
// we will use this for our subsequent line exact matches below.
|
2012-05-22 07:06:47 +08:00
|
|
|
found_line = line_entry.line;
|
2010-09-12 14:24:05 +08:00
|
|
|
|
2010-09-14 10:20:48 +08:00
|
|
|
while (line_idx != UINT32_MAX)
|
2010-09-12 14:24:05 +08:00
|
|
|
{
|
2012-05-22 07:06:47 +08:00
|
|
|
if (resolve_scope == eSymbolContextLineEntry)
|
|
|
|
{
|
|
|
|
sc.line_entry = line_entry;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope);
|
|
|
|
}
|
|
|
|
|
2010-09-12 14:24:05 +08:00
|
|
|
sc_list.Append(sc);
|
2012-05-22 07:06:47 +08:00
|
|
|
line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes, found_line, true, &line_entry);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-12 14:24:05 +08:00
|
|
|
}
|
|
|
|
else if (file_spec_matches_cu_file_spec && !check_inlines)
|
|
|
|
{
|
|
|
|
// only append the context if we aren't looking for inline call sites
|
|
|
|
// by file and line and if the file spec matches that of the compile unit
|
|
|
|
sc_list.Append(sc);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
return sc_list.GetSize() - prev_size;
|
|
|
|
}
|
|
|
|
|
2015-07-29 08:42:47 +08:00
|
|
|
bool
|
|
|
|
CompileUnit::GetIsOptimized ()
|
|
|
|
{
|
|
|
|
return m_is_optimized;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
CompileUnit::SetVariableList(VariableListSP &variables)
|
|
|
|
{
|
|
|
|
m_variables = variables;
|
|
|
|
}
|
|
|
|
|
2015-04-21 00:31:29 +08:00
|
|
|
const std::vector<ConstString> &
|
|
|
|
CompileUnit::GetImportedModules ()
|
|
|
|
{
|
|
|
|
if (m_imported_modules.empty() &&
|
|
|
|
m_flags.IsClear(flagsParsedImportedModules))
|
|
|
|
{
|
|
|
|
m_flags.Set(flagsParsedImportedModules);
|
|
|
|
if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor())
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
CalculateSymbolContext(&sc);
|
|
|
|
symbol_vendor->ParseImportedModules(sc, m_imported_modules);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_imported_modules;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
FileSpecList&
|
|
|
|
CompileUnit::GetSupportFiles ()
|
|
|
|
{
|
|
|
|
if (m_support_files.GetSize() == 0)
|
|
|
|
{
|
|
|
|
if (m_flags.IsClear(flagsParsedSupportFiles))
|
|
|
|
{
|
|
|
|
m_flags.Set(flagsParsedSupportFiles);
|
|
|
|
SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor();
|
|
|
|
if (symbol_vendor)
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
CalculateSymbolContext(&sc);
|
|
|
|
symbol_vendor->ParseCompileUnitSupportFiles(sc, m_support_files);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_support_files;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
CompileUnit::GetUserData () const
|
|
|
|
{
|
|
|
|
return m_user_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|