Fix Clang-tidy modernize-use-nullptr warnings in some files in source/Core; other minor fixes.

llvm-svn: 263289
This commit is contained in:
Eugene Zelenko 2016-03-11 20:20:38 +00:00
parent a8b64fe64f
commit c5dac77ad8
3 changed files with 253 additions and 318 deletions

View File

@ -38,8 +38,14 @@
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/ThreadPlan.h"
#ifndef LLDB_DISABLE_CURSES
#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/StackFrame.h"
#endif
using namespace lldb;
using namespace lldb_private;
@ -67,7 +73,7 @@ IOHandler::IOHandler (Debugger &debugger,
m_popped (false),
m_flags (flags),
m_type (type),
m_user_data (NULL),
m_user_data(nullptr),
m_done (false),
m_active (false)
{
@ -83,49 +89,37 @@ IOHandler::~IOHandler() = default;
int
IOHandler::GetInputFD()
{
if (m_input_sp)
return m_input_sp->GetFile().GetDescriptor();
return -1;
return (m_input_sp ? m_input_sp->GetFile().GetDescriptor() : -1);
}
int
IOHandler::GetOutputFD()
{
if (m_output_sp)
return m_output_sp->GetFile().GetDescriptor();
return -1;
return (m_output_sp ? m_output_sp->GetFile().GetDescriptor() : -1);
}
int
IOHandler::GetErrorFD()
{
if (m_error_sp)
return m_error_sp->GetFile().GetDescriptor();
return -1;
return (m_error_sp ? m_error_sp->GetFile().GetDescriptor() : -1);
}
FILE *
IOHandler::GetInputFILE()
{
if (m_input_sp)
return m_input_sp->GetFile().GetStream();
return NULL;
return (m_input_sp ? m_input_sp->GetFile().GetStream() : nullptr);
}
FILE *
IOHandler::GetOutputFILE()
{
if (m_output_sp)
return m_output_sp->GetFile().GetStream();
return NULL;
return (m_output_sp ? m_output_sp->GetFile().GetStream() : nullptr);
}
FILE *
IOHandler::GetErrorFILE()
{
if (m_error_sp)
return m_error_sp->GetFile().GetStream();
return NULL;
return (m_error_sp ? m_error_sp->GetFile().GetStream() : nullptr);
}
StreamFileSP &
@ -186,9 +180,9 @@ IOHandlerConfirm::IOHandlerConfirm (Debugger &debugger,
bool default_response) :
IOHandlerEditline(debugger,
IOHandler::Type::Confirm,
NULL, // NULL editline_name means no history loaded/saved
NULL, // No prompt
NULL, // No continuation prompt
nullptr, // nullptr editline_name means no history loaded/saved
nullptr, // No prompt
nullptr, // No continuation prompt
false, // Multi-line
false, // Don't colorize the prompt (i.e. the confirm message.)
0,
@ -204,7 +198,6 @@ IOHandlerConfirm::IOHandlerConfirm (Debugger &debugger,
prompt_stream.Printf(": [y/N] ");
SetPrompt (prompt_stream.GetString().c_str());
}
IOHandlerConfirm::~IOHandlerConfirm() = default;
@ -304,14 +297,14 @@ IOHandlerDelegate::IOHandlerComplete (IOHandler &io_handler,
--word_start;
while (word_start > current_line && !isspace(*word_start))
--word_start;
CommandCompletions::InvokeCommonCompletionCallbacks (io_handler.GetDebugger().GetCommandInterpreter(),
CommandCompletions::eVariablePathCompletion,
word_start,
skip_first_n_matches,
max_matches,
NULL,
word_complete,
matches);
CommandCompletions::InvokeCommonCompletionCallbacks(io_handler.GetDebugger().GetCommandInterpreter(),
CommandCompletions::eVariablePathCompletion,
word_start,
skip_first_n_matches,
max_matches,
nullptr,
word_complete,
matches);
size_t num_matches = matches.GetSize();
if (num_matches > 0)
@ -382,7 +375,7 @@ IOHandlerEditline::IOHandlerEditline (Debugger &debugger,
m_delegate (delegate),
m_prompt (),
m_continuation_prompt(),
m_current_lines_ptr (NULL),
m_current_lines_ptr(nullptr),
m_base_line_number (line_number_start),
m_curr_line_idx (UINT32_MAX),
m_multi_line (multi_line),
@ -460,12 +453,12 @@ IOHandlerEditline::GetLine (std::string &line, bool &interrupted)
{
if (GetIsInteractive())
{
const char *prompt = NULL;
const char *prompt = nullptr;
if (m_multi_line && m_curr_line_idx > 0)
prompt = GetContinuationPrompt();
if (prompt == NULL)
if (prompt == nullptr)
prompt = GetPrompt();
if (prompt && prompt[0])
@ -484,7 +477,7 @@ IOHandlerEditline::GetLine (std::string &line, bool &interrupted)
m_editing = true;
while (!done)
{
if (fgets(buffer, sizeof(buffer), in) == NULL)
if (fgets(buffer, sizeof(buffer), in) == nullptr)
{
const int saved_errno = errno;
if (feof(in))
@ -532,7 +525,6 @@ IOHandlerEditline::GetLine (std::string &line, bool &interrupted)
#endif
}
#ifndef LLDB_DISABLE_LIBEDIT
bool
IOHandlerEditline::IsInputCompleteCallback (Editline *editline,
@ -587,7 +579,7 @@ IOHandlerEditline::GetPrompt ()
{
#endif
if (m_prompt.empty())
return NULL;
return nullptr;
#ifndef LLDB_DISABLE_LIBEDIT
}
#endif
@ -603,7 +595,7 @@ IOHandlerEditline::SetPrompt (const char *p)
m_prompt.clear();
#ifndef LLDB_DISABLE_LIBEDIT
if (m_editline_ap)
m_editline_ap->SetPrompt (m_prompt.empty() ? NULL : m_prompt.c_str());
m_editline_ap->SetPrompt(m_prompt.empty() ? nullptr : m_prompt.c_str());
#endif
return true;
}
@ -611,9 +603,7 @@ IOHandlerEditline::SetPrompt (const char *p)
const char *
IOHandlerEditline::GetContinuationPrompt ()
{
if (m_continuation_prompt.empty())
return NULL;
return m_continuation_prompt.c_str();
return (m_continuation_prompt.empty() ? nullptr : m_continuation_prompt.c_str());
}
void
@ -626,7 +616,7 @@ IOHandlerEditline::SetContinuationPrompt (const char *p)
#ifndef LLDB_DISABLE_LIBEDIT
if (m_editline_ap)
m_editline_ap->SetContinuationPrompt (m_continuation_prompt.empty() ? NULL : m_continuation_prompt.c_str());
m_editline_ap->SetContinuationPrompt(m_continuation_prompt.empty() ? nullptr : m_continuation_prompt.c_str());
#endif
}
@ -671,7 +661,7 @@ IOHandlerEditline::GetLines (StringList &lines, bool &interrupted)
{
FILE *out = GetOutputFILE();
if (out)
::fprintf(out, "%u%s", m_base_line_number + (uint32_t)lines.GetSize(), GetPrompt() == NULL ? " " : "");
::fprintf(out, "%u%s", m_base_line_number + (uint32_t)lines.GetSize(), GetPrompt() == nullptr ? " " : "");
}
m_curr_line_idx = lines.GetSize();
@ -790,13 +780,6 @@ IOHandlerEditline::PrintAsync (Stream *stream, const char *s, size_t len)
// for instance, windows
#ifndef LLDB_DISABLE_CURSES
#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/StackFrame.h"
#define KEY_RETURN 10
#define KEY_ESCAPE 27
@ -1078,13 +1061,13 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
virtual const char *
WindowDelegateGetHelpText ()
{
return NULL;
return nullptr;
}
virtual KeyHelp *
WindowDelegateGetKeyHelp ()
{
return NULL;
return nullptr;
}
};
@ -1124,9 +1107,9 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
public:
Window (const char *name) :
m_name (name),
m_window (NULL),
m_panel (NULL),
m_parent (NULL),
m_window(nullptr),
m_panel(nullptr),
m_parent(nullptr),
m_subwindows (),
m_delegate_sp (),
m_curr_active_window_idx (UINT32_MAX),
@ -1140,9 +1123,9 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
Window (const char *name, WINDOW *w, bool del = true) :
m_name (name),
m_window (NULL),
m_panel (NULL),
m_parent (NULL),
m_window(nullptr),
m_panel(nullptr),
m_parent(nullptr),
m_subwindows (),
m_delegate_sp (),
m_curr_active_window_idx (UINT32_MAX),
@ -1158,8 +1141,8 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
Window (const char *name, const Rect &bounds) :
m_name (name),
m_window (NULL),
m_parent (NULL),
m_window(nullptr),
m_parent(nullptr),
m_subwindows (),
m_delegate_sp (),
m_curr_active_window_idx (UINT32_MAX),
@ -1180,7 +1163,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
}
void
Reset (WINDOW *w = NULL, bool del = true)
Reset(WINDOW *w = nullptr, bool del = true)
{
if (m_window == w)
return;
@ -1188,12 +1171,12 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
if (m_panel)
{
::del_panel (m_panel);
m_panel = NULL;
m_panel = nullptr;
}
if (m_window && m_delete)
{
::delwin (m_window);
m_window = NULL;
m_window = nullptr;
m_delete = false;
}
if (w)
@ -1415,7 +1398,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
// Window drawing utilities
//----------------------------------------------------------------------
void
DrawTitleBox (const char *title, const char *bottom_message = NULL)
DrawTitleBox(const char *title, const char *bottom_message = nullptr)
{
attr_t attr = 0;
if (IsActive())
@ -1456,7 +1439,6 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
}
if (attr)
AttributeOff(attr);
}
virtual void
@ -1554,7 +1536,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
Windows subwindows (m_subwindows);
for (auto subwindow_sp : subwindows)
{
if (subwindow_sp->m_can_activate == false)
if (!subwindow_sp->m_can_activate)
{
HandleCharResult result = subwindow_sp->HandleChar(key);
if (result != eKeyNotHandled)
@ -1569,7 +1551,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
SetActiveWindow (Window *window)
{
const size_t num_subwindows = m_subwindows.size();
for (size_t i=0; i<num_subwindows; ++i)
for (size_t i = 0; i < num_subwindows; ++i)
{
if (m_subwindows[i].get() == window)
{
@ -1601,7 +1583,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
// Find first window that wants to be active if this window is active
const size_t num_subwindows = m_subwindows.size();
for (size_t i=0; i<num_subwindows; ++i)
for (size_t i = 0; i < num_subwindows; ++i)
{
if (m_subwindows[i]->GetCanBeActive())
{
@ -1944,7 +1926,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
m_max_submenu_name_length (0),
m_max_submenu_key_name_length (0),
m_selected (0),
m_parent (NULL),
m_parent(nullptr),
m_submenus (),
m_canned_result (MenuActionResult::NotHandled),
m_delegate_sp()
@ -1965,7 +1947,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
m_max_submenu_name_length (0),
m_max_submenu_key_name_length (0),
m_selected (0),
m_parent (NULL),
m_parent(nullptr),
m_submenus (),
m_canned_result (MenuActionResult::NotHandled),
m_delegate_sp()
@ -1990,7 +1972,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
m_max_submenu_key_name_length = 0;
Menus &submenus = GetSubmenus();
const size_t num_submenus = submenus.size();
for (size_t i=0; i<num_submenus; ++i)
for (size_t i = 0; i < num_submenus; ++i)
{
Menu *submenu = submenus[i].get();
if (static_cast<size_t>(m_max_submenu_name_length) < submenu->m_name.size())
@ -2022,7 +2004,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
if (width > 2)
{
width -= 2;
for (int i=0; i< width; ++i)
for (int i = 0; i < width; ++i)
window.PutChar(ACS_HLINE);
}
window.PutChar(ACS_RTEE);
@ -2097,7 +2079,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
{
window.SetBackground(2);
window.MoveCursor(0, 0);
for (size_t i=0; i<num_submenus; ++i)
for (size_t i = 0; i < num_submenus; ++i)
{
Menu *menu = submenus[i].get();
if (i > 0)
@ -2121,7 +2103,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
window.Erase();
window.SetBackground(2);
window.Box();
for (size_t i=0; i<num_submenus; ++i)
for (size_t i = 0; i < num_submenus; ++i)
{
const bool is_selected =
(i == static_cast<size_t>(selected_idx));
@ -2171,7 +2153,6 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
break;
case KEY_RIGHT:
{
++m_selected;
if (m_selected >= static_cast<int>(num_submenus))
m_selected = 0;
@ -2180,11 +2161,9 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
else if (!submenus.empty())
run_menu_sp = submenus.front();
result = eKeyHandled;
}
break;
case KEY_LEFT:
{
--m_selected;
if (m_selected < 0)
m_selected = num_submenus - 1;
@ -2193,11 +2172,10 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
else if (!submenus.empty())
run_menu_sp = submenus.front();
result = eKeyHandled;
}
break;
default:
for (size_t i=0; i<num_submenus; ++i)
for (size_t i = 0; i < num_submenus; ++i)
{
if (submenus[i]->GetKeyValue() == key)
{
@ -2285,8 +2263,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
return eKeyHandled;
default:
{
for (size_t i=0; i<num_submenus; ++i)
for (size_t i = 0; i < num_submenus; ++i)
{
Menu *menu = submenus[i].get();
if (menu->GetKeyValue() == key)
@ -2298,9 +2275,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
return eKeyHandled;
}
}
}
break;
}
}
else if (menu_type == Menu::Type::Separator)
@ -2314,11 +2289,10 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
public:
Application (FILE *in, FILE *out) :
m_window_sp(),
m_screen (NULL),
m_screen(nullptr),
m_in (in),
m_out (out)
{
}
~Application ()
@ -2328,7 +2302,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
if (m_screen)
{
::delscreen(m_screen);
m_screen = NULL;
m_screen = nullptr;
}
}
@ -2340,7 +2314,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
#if 0
::initscr();
#else
m_screen = ::newterm(NULL, m_out, m_in);
m_screen = ::newterm(nullptr, m_out, m_in);
#endif
::start_color();
::curs_set(0);
@ -2457,7 +2431,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
ConstString broadcaster_class (broadcaster->GetBroadcasterClass());
if (broadcaster_class == broadcaster_class_process)
{
debugger.GetCommandInterpreter().UpdateExecutionContext(NULL);
debugger.GetCommandInterpreter().UpdateExecutionContext(nullptr);
update = true;
continue; // Don't get any key, just update our view
}
@ -2472,7 +2446,7 @@ type summary add -s "${var.origin%S} ${var.size%S}" curses::Rect
switch (key_result)
{
case eKeyHandled:
debugger.GetCommandInterpreter().UpdateExecutionContext(NULL);
debugger.GetCommandInterpreter().UpdateExecutionContext(nullptr);
update = true;
break;
case eKeyNotHandled:
@ -2556,7 +2530,7 @@ struct Row
if (valobj)
{
const size_t num_children = valobj->GetNumChildren();
for (size_t i=0; i<num_children; ++i)
for (size_t i = 0; i < num_children; ++i)
{
children.push_back(Row (valobj->GetChildAtIndex(i, true), this));
}
@ -2646,7 +2620,7 @@ class TreeItem;
class TreeDelegate
{
public:
TreeDelegate() {}
TreeDelegate() = default;
virtual ~TreeDelegate() = default;
virtual void TreeDelegateDrawTreeItem (TreeItem &item, Window &window) = 0;
@ -2659,11 +2633,10 @@ typedef std::shared_ptr<TreeDelegate> TreeDelegateSP;
class TreeItem
{
public:
TreeItem (TreeItem *parent, TreeDelegate &delegate, bool might_have_children) :
m_parent (parent),
m_delegate (delegate),
m_user_data (NULL),
m_user_data(nullptr),
m_identifier (0),
m_row_idx (-1),
m_children (),
@ -2751,7 +2724,7 @@ public:
// The root item must calculate its children,
// or we must calculate the number of children
// if the item is expanded
if (m_parent == NULL || expanded)
if (m_parent == nullptr || expanded)
GetNumChildren();
for (auto &item : m_children)
@ -2849,7 +2822,7 @@ public:
{
// If we displayed all the rows and item.Draw() returns
// false we are done drawing and can exit this for loop
if (item.Draw(window, first_visible_row, selected_row_idx, row_idx, num_rows_left) == false)
if (!item.Draw(window, first_visible_row, selected_row_idx, row_idx, num_rows_left))
break;
}
}
@ -2897,7 +2870,7 @@ public:
if (static_cast<uint32_t>(m_row_idx) == row_idx)
return this;
if (m_children.empty())
return NULL;
return nullptr;
if (IsExpanded())
{
for (auto &item : m_children)
@ -2907,7 +2880,7 @@ public:
return selected_item_ptr;
}
}
return NULL;
return nullptr;
}
void *
@ -2957,8 +2930,8 @@ public:
TreeWindowDelegate (Debugger &debugger, const TreeDelegateSP &delegate_sp) :
m_debugger (debugger),
m_delegate_sp (delegate_sp),
m_root (NULL, *delegate_sp, true),
m_selected_item (NULL),
m_root(nullptr, *delegate_sp, true),
m_selected_item(nullptr),
m_num_rows (0),
m_selected_row_idx (0),
m_first_visible_row (0),
@ -3031,12 +3004,11 @@ public:
}
else
{
m_selected_item = NULL;
m_selected_item = nullptr;
}
window.DeferredRefresh();
return true; // Drawing handled
}
@ -3060,7 +3032,7 @@ public:
{ ' ', "Toggle item expansion" },
{ ',', "Page up" },
{ '.', "Page down" },
{ '\0', NULL }
{ '\0', nullptr }
};
return g_source_view_key_help;
}
@ -3205,7 +3177,7 @@ public:
StreamString strm;
const SymbolContext &sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
ExecutionContext exe_ctx (frame_sp);
if (FormatEntity::Format(m_format, strm, &sc, &exe_ctx, NULL, NULL, false, false))
if (FormatEntity::Format(m_format, strm, &sc, &exe_ctx, nullptr, nullptr, false, false))
{
int right_pad = 1;
window.PutCStringTruncated(strm.GetString().c_str(), right_pad);
@ -3276,7 +3248,7 @@ public:
{
StreamString strm;
ExecutionContext exe_ctx (thread_sp);
if (FormatEntity::Format (m_format, strm, NULL, &exe_ctx, NULL, NULL, false, false))
if (FormatEntity::Format(m_format, strm, nullptr, &exe_ctx, nullptr, nullptr, false, false))
{
int right_pad = 1;
window.PutCStringTruncated(strm.GetString().c_str(), right_pad);
@ -3310,7 +3282,7 @@ public:
TreeItem t (&item, *m_frame_delegate_sp, false);
size_t num_frames = thread_sp->GetStackFrameCount();
item.Resize (num_frames, t);
for (size_t i=0; i<num_frames; ++i)
for (size_t i = 0; i < num_frames; ++i)
{
item[i].SetUserData(thread_sp.get());
item[i].SetIdentifier(i);
@ -3385,7 +3357,7 @@ public:
{
StreamString strm;
ExecutionContext exe_ctx (process_sp);
if (FormatEntity::Format (m_format, strm, NULL, &exe_ctx, NULL, NULL, false, false))
if (FormatEntity::Format(m_format, strm, nullptr, &exe_ctx, nullptr, nullptr, false, false))
{
int right_pad = 1;
window.PutCStringTruncated(strm.GetString().c_str(), right_pad);
@ -3420,7 +3392,7 @@ public:
Mutex::Locker locker (threads.GetMutex());
size_t num_threads = threads.GetSize();
item.Resize (num_threads, t);
for (size_t i=0; i<num_threads; ++i)
for (size_t i = 0; i < num_threads; ++i)
{
item[i].SetIdentifier(threads.GetThreadAtIndex(i)->GetID());
item[i].SetMightHaveChildren(true);
@ -3450,7 +3422,7 @@ public:
ValueObjectListDelegate () :
m_valobj_list (),
m_rows (),
m_selected_row (NULL),
m_selected_row(nullptr),
m_selected_row_idx (0),
m_first_visible_row (0),
m_num_rows (0),
@ -3462,7 +3434,7 @@ public:
ValueObjectListDelegate (ValueObjectList &valobj_list) :
m_valobj_list (valobj_list),
m_rows (),
m_selected_row (NULL),
m_selected_row(nullptr),
m_selected_row_idx (0),
m_first_visible_row (0),
m_num_rows (0),
@ -3477,15 +3449,15 @@ public:
void
SetValues (ValueObjectList &valobj_list)
{
m_selected_row = NULL;
m_selected_row = nullptr;
m_selected_row_idx = 0;
m_first_visible_row = 0;
m_num_rows = 0;
m_rows.clear();
m_valobj_list = valobj_list;
const size_t num_values = m_valobj_list.GetSize();
for (size_t i=0; i<num_values; ++i)
m_rows.push_back(Row(m_valobj_list.GetValueObjectAtIndex(i), NULL));
for (size_t i = 0; i < num_values; ++i)
m_rows.push_back(Row(m_valobj_list.GetValueObjectAtIndex(i), nullptr));
}
bool
@ -3560,7 +3532,7 @@ public:
{ ' ', "Toggle item expansion" },
{ ',', "Page up" },
{ '.', "Page down" },
{ '\0', NULL }
{ '\0', nullptr }
};
return g_source_view_key_help;
}
@ -3713,10 +3685,10 @@ protected:
{
ValueObject *valobj = row.valobj.get();
if (valobj == NULL)
if (valobj == nullptr)
return false;
const char *type_name = options.show_types ? valobj->GetTypeName().GetCString() : NULL;
const char *type_name = options.show_types ? valobj->GetTypeName().GetCString() : nullptr;
const char *name = valobj->GetName().GetCString();
const char *value = valobj->GetValueAsCString ();
const char *summary = valobj->GetSummaryAsCString ();
@ -3844,7 +3816,7 @@ protected:
}
}
}
return NULL;
return nullptr;
}
Row *
@ -3868,7 +3840,7 @@ public:
FrameVariablesWindowDelegate (Debugger &debugger) :
ValueObjectListDelegate (),
m_debugger (debugger),
m_frame_block (NULL)
m_frame_block(nullptr)
{
}
@ -3885,8 +3857,8 @@ public:
{
ExecutionContext exe_ctx (m_debugger.GetCommandInterpreter().GetExecutionContext());
Process *process = exe_ctx.GetProcessPtr();
Block *frame_block = NULL;
StackFrame *frame = NULL;
Block *frame_block = nullptr;
StackFrame *frame = nullptr;
if (process)
{
@ -3916,7 +3888,7 @@ public:
{
const DynamicValueType use_dynamic = eDynamicDontRunTarget;
const size_t num_locals = locals->GetSize();
for (size_t i=0; i<num_locals; ++i)
for (size_t i = 0; i < num_locals; ++i)
{
ValueObjectSP value_sp = frame->GetValueObjectForFrameVariable (locals->GetVariableAtIndex(i), use_dynamic);
if (value_sp)
@ -3926,7 +3898,6 @@ public:
local_values.Append(synthetic_value_sp);
else
local_values.Append(value_sp);
}
}
// Update the values
@ -3936,7 +3907,7 @@ public:
}
else
{
m_frame_block = NULL;
m_frame_block = nullptr;
// Update the values with an empty list if there is no frame
SetValues(local_values);
}
@ -4121,7 +4092,7 @@ CursesKeyToCString (int ch)
snprintf(g_desc, sizeof(g_desc), "\\x%2.2x", ch);
return g_desc;
}
return NULL;
return nullptr;
}
HelpDialogDelegate::HelpDialogDelegate (const char *text, KeyHelp *key_help_array) :
@ -4328,7 +4299,7 @@ public:
{ KEY_RIGHT, "Expand" },
{ KEY_PPAGE, "Page up" },
{ KEY_NPAGE, "Page down" },
{ '\0', NULL }
{ '\0', nullptr }
};
return g_source_view_key_help;
}
@ -4439,7 +4410,7 @@ public:
ThreadList &threads = process->GetThreadList();
Mutex::Locker locker (threads.GetMutex());
size_t num_threads = threads.GetSize();
for (size_t i=0; i<num_threads; ++i)
for (size_t i = 0; i < num_threads; ++i)
{
ThreadSP thread_sp = threads.GetThreadAtIndex(i);
char menu_char = '\0';
@ -4456,7 +4427,7 @@ public:
if (queue_name && queue_name[0])
thread_menu_title.Printf (" %s", queue_name);
}
menu.AddSubmenu (MenuSP (new Menu(thread_menu_title.GetString().c_str(), NULL, menu_char, thread_sp->GetID())));
menu.AddSubmenu(MenuSP(new Menu(thread_menu_title.GetString().c_str(), nullptr, menu_char, thread_sp->GetID())));
}
}
else if (submenus.size() > 7)
@ -4629,7 +4600,7 @@ public:
if (StateIsStoppedState(state, true))
{
StreamString strm;
if (thread && FormatEntity::Format (m_format, strm, NULL, &exe_ctx, NULL, NULL, false, false))
if (thread && FormatEntity::Format(m_format, strm, nullptr, &exe_ctx, nullptr, nullptr, false, false))
{
window.MoveCursor (40, 0);
window.PutCStringTruncated(strm.GetString().c_str(), 1);
@ -4666,7 +4637,7 @@ public:
m_debugger (debugger),
m_sc (),
m_file_sp (),
m_disassembly_scope (NULL),
m_disassembly_scope(nullptr),
m_disassembly_sp (),
m_disassembly_range (),
m_title (),
@ -4725,7 +4696,7 @@ public:
{ 'S', "Step in (single instruction)" },
{ ',', "Page up" },
{ '.', "Page down" },
{ '\0', NULL }
{ '\0', nullptr }
};
return g_source_view_key_help;
}
@ -4735,7 +4706,7 @@ public:
{
ExecutionContext exe_ctx = m_debugger.GetCommandInterpreter().GetExecutionContext();
Process *process = exe_ctx.GetProcessPtr();
Thread *thread = NULL;
Thread *thread = nullptr;
bool update_location = false;
if (process)
@ -4870,7 +4841,7 @@ public:
if (m_disassembly_scope != m_sc.function)
{
m_disassembly_scope = m_sc.function;
m_disassembly_sp = m_sc.function->GetInstructions (exe_ctx, NULL, prefer_file_cache);
m_disassembly_sp = m_sc.function->GetInstructions(exe_ctx, nullptr, prefer_file_cache);
if (m_disassembly_sp)
{
set_selected_line_to_pc = true;
@ -4891,7 +4862,7 @@ public:
if (m_disassembly_scope != m_sc.symbol)
{
m_disassembly_scope = m_sc.symbol;
m_disassembly_sp = m_sc.symbol->GetInstructions (exe_ctx, NULL, prefer_file_cache);
m_disassembly_sp = m_sc.symbol->GetInstructions(exe_ctx, nullptr, prefer_file_cache);
if (m_disassembly_sp)
{
set_selected_line_to_pc = true;
@ -4965,7 +4936,7 @@ public:
const attr_t selected_highlight_attr = A_REVERSE;
const attr_t pc_highlight_attr = COLOR_PAIR(1);
for (size_t i=0; i<num_visible_lines; ++i)
for (size_t i = 0; i < num_visible_lines; ++i)
{
const uint32_t curr_line = m_first_visible_line + i;
if (curr_line < num_source_lines)
@ -5095,7 +5066,7 @@ public:
m_first_visible_line = pc_idx - non_visible_pc_offset;
}
for (size_t i=0; i<num_visible_lines; ++i)
for (size_t i = 0; i < num_visible_lines; ++i)
{
const uint32_t inst_idx = m_first_visible_line + i;
Instruction *inst = insts.GetInstructionAtIndex(inst_idx).get();
@ -5141,20 +5112,20 @@ public:
const char *operands = inst->GetOperands(&exe_ctx);
const char *comment = inst->GetComment(&exe_ctx);
if (mnemonic && mnemonic[0] == '\0')
mnemonic = NULL;
if (operands && operands[0] == '\0')
operands = NULL;
if (comment && comment[0] == '\0')
comment = NULL;
if (mnemonic != nullptr && mnemonic[0] == '\0')
mnemonic = nullptr;
if (operands != nullptr && operands[0] == '\0')
operands = nullptr;
if (comment != nullptr && comment[0] == '\0')
comment = nullptr;
strm.Clear();
if (mnemonic && operands && comment)
if (mnemonic != nullptr && operands != nullptr && comment != nullptr)
strm.Printf ("%-8s %-25s ; %s", mnemonic, operands, comment);
else if (mnemonic && operands)
else if (mnemonic != nullptr && operands != nullptr)
strm.Printf ("%-8s %s", mnemonic, operands);
else if (mnemonic)
else if (mnemonic != nullptr)
strm.Printf ("%s", mnemonic);
int right_pad = 1;
@ -5275,15 +5246,15 @@ public:
ExecutionContext exe_ctx = m_debugger.GetCommandInterpreter().GetExecutionContext();
if (exe_ctx.HasProcessScope() && exe_ctx.GetProcessRef().IsAlive())
{
BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint (NULL, // Don't limit the breakpoint to certain modules
m_file_sp->GetFileSpec(), // Source file
m_selected_line + 1, // Source line number (m_selected_line is zero based)
0, // No offset
eLazyBoolCalculate, // Check inlines using global setting
eLazyBoolCalculate, // Skip prologue using global setting,
false, // internal
false, // request_hardware
eLazyBoolCalculate); // move_to_nearest_code
BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint(nullptr, // Don't limit the breakpoint to certain modules
m_file_sp->GetFileSpec(), // Source file
m_selected_line + 1, // Source line number (m_selected_line is zero based)
0, // No offset
eLazyBoolCalculate, // Check inlines using global setting
eLazyBoolCalculate, // Skip prologue using global setting,
false, // internal
false, // request_hardware
eLazyBoolCalculate); // move_to_nearest_code
// Make breakpoint one shot
bp_sp->GetOptions()->SetOneShot(true);
exe_ctx.GetProcessRef().Resume();
@ -5312,15 +5283,15 @@ public:
ExecutionContext exe_ctx = m_debugger.GetCommandInterpreter().GetExecutionContext();
if (exe_ctx.HasTargetScope())
{
BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint (NULL, // Don't limit the breakpoint to certain modules
m_file_sp->GetFileSpec(), // Source file
m_selected_line + 1, // Source line number (m_selected_line is zero based)
0, // No offset
eLazyBoolCalculate, // Check inlines using global setting
eLazyBoolCalculate, // Skip prologue using global setting,
false, // internal
false, // request_hardware
eLazyBoolCalculate); // move_to_nearest_code
BreakpointSP bp_sp = exe_ctx.GetTargetRef().CreateBreakpoint(nullptr, // Don't limit the breakpoint to certain modules
m_file_sp->GetFileSpec(), // Source file
m_selected_line + 1, // Source line number (m_selected_line is zero based)
0, // No offset
eLazyBoolCalculate, // Check inlines using global setting
eLazyBoolCalculate, // Skip prologue using global setting,
false, // internal
false, // request_hardware
eLazyBoolCalculate); // move_to_nearest_code
}
}
else if (m_selected_line < GetNumDisassemblyLines())
@ -5454,38 +5425,38 @@ IOHandlerCursesGUI::Activate ()
MenuDelegateSP app_menu_delegate_sp = std::static_pointer_cast<MenuDelegate>(app_delegate_sp);
MenuSP lldb_menu_sp(new Menu("LLDB" , "F1", KEY_F(1), ApplicationDelegate::eMenuID_LLDB));
MenuSP exit_menuitem_sp(new Menu("Exit", NULL, 'x', ApplicationDelegate::eMenuID_LLDBExit));
MenuSP exit_menuitem_sp(new Menu("Exit", nullptr, 'x', ApplicationDelegate::eMenuID_LLDBExit));
exit_menuitem_sp->SetCannedResult(MenuActionResult::Quit);
lldb_menu_sp->AddSubmenu (MenuSP (new Menu("About LLDB", NULL, 'a', ApplicationDelegate::eMenuID_LLDBAbout)));
lldb_menu_sp->AddSubmenu (MenuSP (new Menu("About LLDB", nullptr, 'a', ApplicationDelegate::eMenuID_LLDBAbout)));
lldb_menu_sp->AddSubmenu (MenuSP (new Menu(Menu::Type::Separator)));
lldb_menu_sp->AddSubmenu (exit_menuitem_sp);
MenuSP target_menu_sp(new Menu("Target" ,"F2", KEY_F(2), ApplicationDelegate::eMenuID_Target));
target_menu_sp->AddSubmenu (MenuSP (new Menu("Create", NULL, 'c', ApplicationDelegate::eMenuID_TargetCreate)));
target_menu_sp->AddSubmenu (MenuSP (new Menu("Delete", NULL, 'd', ApplicationDelegate::eMenuID_TargetDelete)));
target_menu_sp->AddSubmenu (MenuSP (new Menu("Create", nullptr, 'c', ApplicationDelegate::eMenuID_TargetCreate)));
target_menu_sp->AddSubmenu (MenuSP (new Menu("Delete", nullptr, 'd', ApplicationDelegate::eMenuID_TargetDelete)));
MenuSP process_menu_sp(new Menu("Process", "F3", KEY_F(3), ApplicationDelegate::eMenuID_Process));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Attach" , NULL, 'a', ApplicationDelegate::eMenuID_ProcessAttach)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Detach" , NULL, 'd', ApplicationDelegate::eMenuID_ProcessDetach)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Launch" , NULL, 'l', ApplicationDelegate::eMenuID_ProcessLaunch)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Attach" , nullptr, 'a', ApplicationDelegate::eMenuID_ProcessAttach)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Detach" , nullptr, 'd', ApplicationDelegate::eMenuID_ProcessDetach)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Launch" , nullptr, 'l', ApplicationDelegate::eMenuID_ProcessLaunch)));
process_menu_sp->AddSubmenu (MenuSP (new Menu(Menu::Type::Separator)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Continue", NULL, 'c', ApplicationDelegate::eMenuID_ProcessContinue)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Halt" , NULL, 'h', ApplicationDelegate::eMenuID_ProcessHalt)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Kill" , NULL, 'k', ApplicationDelegate::eMenuID_ProcessKill)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Continue", nullptr, 'c', ApplicationDelegate::eMenuID_ProcessContinue)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Halt" , nullptr, 'h', ApplicationDelegate::eMenuID_ProcessHalt)));
process_menu_sp->AddSubmenu (MenuSP (new Menu("Kill" , nullptr, 'k', ApplicationDelegate::eMenuID_ProcessKill)));
MenuSP thread_menu_sp(new Menu("Thread", "F4", KEY_F(4), ApplicationDelegate::eMenuID_Thread));
thread_menu_sp->AddSubmenu (MenuSP (new Menu("Step In" , NULL, 'i', ApplicationDelegate::eMenuID_ThreadStepIn)));
thread_menu_sp->AddSubmenu (MenuSP (new Menu("Step Over", NULL, 'v', ApplicationDelegate::eMenuID_ThreadStepOver)));
thread_menu_sp->AddSubmenu (MenuSP (new Menu("Step Out" , NULL, 'o', ApplicationDelegate::eMenuID_ThreadStepOut)));
thread_menu_sp->AddSubmenu (MenuSP (new Menu("Step In" , nullptr, 'i', ApplicationDelegate::eMenuID_ThreadStepIn)));
thread_menu_sp->AddSubmenu (MenuSP (new Menu("Step Over", nullptr, 'v', ApplicationDelegate::eMenuID_ThreadStepOver)));
thread_menu_sp->AddSubmenu (MenuSP (new Menu("Step Out" , nullptr, 'o', ApplicationDelegate::eMenuID_ThreadStepOut)));
MenuSP view_menu_sp(new Menu("View", "F5", KEY_F(5), ApplicationDelegate::eMenuID_View));
view_menu_sp->AddSubmenu (MenuSP (new Menu("Backtrace", NULL, 'b', ApplicationDelegate::eMenuID_ViewBacktrace)));
view_menu_sp->AddSubmenu (MenuSP (new Menu("Registers", NULL, 'r', ApplicationDelegate::eMenuID_ViewRegisters)));
view_menu_sp->AddSubmenu (MenuSP (new Menu("Source" , NULL, 's', ApplicationDelegate::eMenuID_ViewSource)));
view_menu_sp->AddSubmenu (MenuSP (new Menu("Variables", NULL, 'v', ApplicationDelegate::eMenuID_ViewVariables)));
view_menu_sp->AddSubmenu (MenuSP (new Menu("Backtrace", nullptr, 'b', ApplicationDelegate::eMenuID_ViewBacktrace)));
view_menu_sp->AddSubmenu (MenuSP (new Menu("Registers", nullptr, 'r', ApplicationDelegate::eMenuID_ViewRegisters)));
view_menu_sp->AddSubmenu (MenuSP (new Menu("Source" , nullptr, 's', ApplicationDelegate::eMenuID_ViewSource)));
view_menu_sp->AddSubmenu (MenuSP (new Menu("Variables", nullptr, 'v', ApplicationDelegate::eMenuID_ViewVariables)));
MenuSP help_menu_sp(new Menu("Help", "F6", KEY_F(6), ApplicationDelegate::eMenuID_Help));
help_menu_sp->AddSubmenu (MenuSP (new Menu("GUI Help", NULL, 'g', ApplicationDelegate::eMenuID_HelpGUIHelp)));
help_menu_sp->AddSubmenu (MenuSP (new Menu("GUI Help", nullptr, 'g', ApplicationDelegate::eMenuID_HelpGUIHelp)));
m_app_ap->Initialize();
WindowSP &main_window_sp = m_app_ap->GetMainWindow();

View File

@ -7,9 +7,17 @@
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/Module.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Support/Signals.h"
// Project includes
#include "lldb/Core/AddressResolverFileLine.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Log.h"
@ -40,9 +48,6 @@
#include "Plugins/ObjectFile/JIT/ObjectFileJIT.h"
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Support/Signals.h"
using namespace lldb;
using namespace lldb_private;
@ -60,8 +65,8 @@ GetModuleCollection()
// is a big problem we can introduce a Finalize method that will tear everything down in
// a predictable order.
static ModuleCollection *g_module_collection = NULL;
if (g_module_collection == NULL)
static ModuleCollection *g_module_collection = nullptr;
if (g_module_collection == nullptr)
g_module_collection = new ModuleCollection();
return *g_module_collection;
@ -75,8 +80,8 @@ Module::GetAllocationModuleCollectionMutex()
// if it will tear itself down before the "g_module_collection_mutex" below
// will. So we leak a Mutex object below to safeguard against that
static Mutex *g_module_collection_mutex = NULL;
if (g_module_collection_mutex == NULL)
static Mutex *g_module_collection_mutex = nullptr;
if (g_module_collection_mutex == nullptr)
g_module_collection_mutex = new Mutex (Mutex::eMutexTypeRecursive); // NOTE: known leak
return g_module_collection_mutex;
}
@ -95,10 +100,10 @@ Module::GetAllocatedModuleAtIndex (size_t idx)
ModuleCollection &modules = GetModuleCollection();
if (idx < modules.size())
return modules[idx];
return NULL;
return nullptr;
}
#if 0
#if 0
// These functions help us to determine if modules are still loaded, yet don't require that
// you have a command interpreter and can easily be called from an external debugger.
namespace lldb {
@ -117,7 +122,7 @@ namespace lldb {
ModuleCollection &modules = GetModuleCollection();
const size_t count = modules.size();
printf ("%s: %" PRIu64 " modules:\n", __PRETTY_FUNCTION__, (uint64_t)count);
for (size_t i=0; i<count; ++i)
for (size_t i = 0; i < count; ++i)
{
StreamString strm;
@ -165,7 +170,7 @@ Module::Module (const ModuleSpec &module_spec) :
}
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
if (log)
if (log != nullptr)
log->Printf ("%p Module::Module((%s) '%s%s%s%s')",
static_cast<void*>(this),
module_spec.GetArchitecture().GetArchitectureName(),
@ -274,7 +279,7 @@ Module::Module(const FileSpec& file_spec,
m_object_mod_time = *object_mod_time_ptr;
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
if (log)
if (log != nullptr)
log->Printf ("%p Module::Module((%s) '%s%s%s%s')",
static_cast<void*>(this), m_arch.GetArchitectureName(),
m_file.GetPath().c_str(),
@ -325,7 +330,7 @@ Module::~Module()
modules.erase(pos);
}
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_OBJECT|LIBLLDB_LOG_MODULES));
if (log)
if (log != nullptr)
log->Printf ("%p Module::~Module((%s) '%s%s%s%s')",
static_cast<void*>(this),
m_arch.GetArchitectureName(),
@ -395,18 +400,17 @@ Module::GetMemoryObjectFile (const lldb::ProcessSP &process_sp, lldb::addr_t hea
return m_objfile_sp.get();
}
const lldb_private::UUID&
Module::GetUUID()
{
if (m_did_parse_uuid.load() == false)
if (!m_did_parse_uuid.load())
{
Mutex::Locker locker (m_mutex);
if (m_did_parse_uuid.load() == false)
if (!m_did_parse_uuid.load())
{
ObjectFile * obj_file = GetObjectFile ();
if (obj_file != NULL)
if (obj_file != nullptr)
{
obj_file->GetUUID(&m_uuid);
m_did_parse_uuid = true;
@ -439,12 +443,12 @@ Module::ParseAllDebugSymbols()
sc.comp_unit = symbols->GetCompileUnitAtIndex(cu_idx).get();
if (sc.comp_unit)
{
sc.function = NULL;
sc.function = nullptr;
symbols->ParseVariablesForContext(sc);
symbols->ParseCompileUnitFunctions(sc);
for (size_t func_idx = 0; (sc.function = sc.comp_unit->GetFunctionAtIndex(func_idx).get()) != NULL; ++func_idx)
for (size_t func_idx = 0; (sc.function = sc.comp_unit->GetFunctionAtIndex(func_idx).get()) != nullptr; ++func_idx)
{
symbols->ParseFunctionBlocks(sc);
@ -452,9 +456,8 @@ Module::ParseAllDebugSymbols()
symbols->ParseVariablesForContext(sc);
}
// Parse all types for this compile unit
sc.function = NULL;
sc.function = nullptr;
symbols->ParseTypes(sc);
}
}
@ -689,7 +692,6 @@ Module::ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t li
return sc_list.GetSize() - initial_count;
}
size_t
Module::FindGlobalVariables (const ConstString &name,
const CompilerDeclContext *parent_decl_ctx,
@ -728,7 +730,7 @@ Module::FindCompileUnits (const FileSpec &path,
SymbolContext sc;
sc.module_sp = shared_from_this();
const bool compare_directory = (bool)path.GetDirectory();
for (size_t i=0; i<num_compile_units; ++i)
for (size_t i = 0; i < num_compile_units; ++i)
{
sc.comp_unit = GetCompileUnitAtIndex(i).get();
if (sc.comp_unit)
@ -791,12 +793,12 @@ Module::FindFunctions (const ConstString &name,
{
SymbolContext sc;
size_t i = old_size;
while (i<sc_list.GetSize())
while (i < sc_list.GetSize())
{
if (sc_list.GetContextAtIndex(i, sc))
{
const char *func_name = sc.GetFunctionName().GetCString();
if (func_name && strstr (func_name, name.GetCString()) == NULL)
if (func_name && strstr(func_name, name.GetCString()) == nullptr)
{
// Remove the current context
sc_list.RemoveContextAtIndex(i);
@ -861,7 +863,7 @@ Module::FindFunctions (const RegularExpression& regex,
if (num_functions_added_to_sc_list == 0)
{
// No functions were added, just symbols, so we can just append them
for (size_t i=0; i<num_matches; ++i)
for (size_t i = 0; i < num_matches; ++i)
{
sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
SymbolType sym_type = sc.symbol->GetType();
@ -874,7 +876,7 @@ Module::FindFunctions (const RegularExpression& regex,
{
typedef std::map<lldb::addr_t, uint32_t> FileAddrToIndexMap;
FileAddrToIndexMap file_addr_to_index;
for (size_t i=start_size; i<end_functions_added_index; ++i)
for (size_t i = start_size; i < end_functions_added_index; ++i)
{
const SymbolContext &sc = sc_list[i];
if (sc.block)
@ -885,7 +887,7 @@ Module::FindFunctions (const RegularExpression& regex,
FileAddrToIndexMap::const_iterator end = file_addr_to_index.end();
// Functions were added so we need to merge symbols into any
// existing function symbol contexts
for (size_t i=start_size; i<num_matches; ++i)
for (size_t i = start_size; i < num_matches; ++i)
{
sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]);
SymbolType sym_type = sc.symbol->GetType();
@ -916,7 +918,7 @@ Module::FindAddressesForLine (const lldb::TargetSP target_sp,
AddressResolverFileLine resolver(file, line, true);
resolver.ResolveAddress (filter);
for (size_t n=0;n<resolver.GetNumberOfAddresses();n++)
for (size_t n = 0; n < resolver.GetNumberOfAddresses(); n++)
{
Address addr = resolver.GetAddressRangeAtIndex(n).GetBaseAddress();
Function *f = addr.CalculateSymbolContextFunction();
@ -937,7 +939,7 @@ Module::FindTypes_Impl (const SymbolContext& sc,
TypeMap& types)
{
Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
if (sc.module_sp.get() == NULL || sc.module_sp.get() == this)
if (!sc.module_sp || sc.module_sp.get() == this)
{
SymbolVendor *symbols = GetSymbolVendor ();
if (symbols)
@ -975,7 +977,6 @@ Module::FindFirstType (const SymbolContext& sc,
return TypeSP();
}
size_t
Module::FindTypes (const SymbolContext& sc,
const ConstString &name,
@ -1004,7 +1005,7 @@ Module::FindTypes (const SymbolContext& sc,
exact_match = true;
}
ConstString type_basename_const_str (type_basename.c_str());
if (FindTypes_Impl(sc, type_basename_const_str, NULL, append, max_matches, searched_symbol_files, typesmap))
if (FindTypes_Impl(sc, type_basename_const_str, nullptr, append, max_matches, searched_symbol_files, typesmap))
{
typesmap.RemoveMismatchedTypes (type_scope, type_basename, type_class, exact_match);
num_matches = typesmap.GetSize();
@ -1017,13 +1018,13 @@ Module::FindTypes (const SymbolContext& sc,
{
// The "type_name_cstr" will have been modified if we have a valid type class
// prefix (like "struct", "class", "union", "typedef" etc).
FindTypes_Impl(sc, ConstString(type_name_cstr), NULL, append, max_matches, searched_symbol_files, typesmap);
FindTypes_Impl(sc, ConstString(type_name_cstr), nullptr, append, max_matches, searched_symbol_files, typesmap);
typesmap.RemoveMismatchedTypes (type_class);
num_matches = typesmap.GetSize();
}
else
{
num_matches = FindTypes_Impl(sc, name, NULL, append, max_matches, searched_symbol_files, typesmap);
num_matches = FindTypes_Impl(sc, name, nullptr, append, max_matches, searched_symbol_files, typesmap);
}
}
if (num_matches > 0)
@ -1034,13 +1035,13 @@ Module::FindTypes (const SymbolContext& sc,
SymbolVendor*
Module::GetSymbolVendor (bool can_create, lldb_private::Stream *feedback_strm)
{
if (m_did_load_symbol_vendor.load() == false)
if (!m_did_load_symbol_vendor.load())
{
Mutex::Locker locker (m_mutex);
if (m_did_load_symbol_vendor.load() == false && can_create)
if (!m_did_load_symbol_vendor.load() && can_create)
{
ObjectFile *obj_file = GetObjectFile ();
if (obj_file != NULL)
if (obj_file != nullptr)
{
Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
m_symfile_ap.reset(SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
@ -1131,14 +1132,13 @@ Module::ReportError (const char *format, ...)
strm.EOL();
}
Host::SystemLog (Host::eSystemLogError, "%s", strm.GetString().c_str());
}
}
bool
Module::FileHasChanged () const
{
if (m_file_has_changed == false)
if (!m_file_has_changed)
m_file_has_changed = (m_file.GetModificationTime() != m_mod_time);
return m_file_has_changed;
}
@ -1146,7 +1146,7 @@ Module::FileHasChanged () const
void
Module::ReportErrorIfModifyDetected (const char *format, ...)
{
if (m_first_file_changed_log == false)
if (!m_first_file_changed_log)
{
if (FileHasChanged ())
{
@ -1206,7 +1206,7 @@ Module::ReportWarning (const char *format, ...)
void
Module::LogMessage (Log *log, const char *format, ...)
{
if (log)
if (log != nullptr)
{
StreamString log_message;
GetDescription(&log_message, lldb::eDescriptionLevelFull);
@ -1222,7 +1222,7 @@ Module::LogMessage (Log *log, const char *format, ...)
void
Module::LogMessageVerboseBacktrace (Log *log, const char *format, ...)
{
if (log)
if (log != nullptr)
{
StreamString log_message;
GetDescription(&log_message, lldb::eDescriptionLevelFull);
@ -1267,14 +1267,13 @@ Module::Dump(Stream *s)
s->IndentLess();
}
TypeList*
Module::GetTypeList ()
{
SymbolVendor *symbols = GetSymbolVendor ();
if (symbols)
return &symbols->GetTypeList();
return NULL;
return nullptr;
}
const ConstString &
@ -1286,10 +1285,10 @@ Module::GetObjectName() const
ObjectFile *
Module::GetObjectFile()
{
if (m_did_load_objfile.load() == false)
if (!m_did_load_objfile.load())
{
Mutex::Locker locker (m_mutex);
if (m_did_load_objfile.load() == false)
if (!m_did_load_objfile.load())
{
Timer scoped_timer(__PRETTY_FUNCTION__,
"Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString(""));
@ -1330,10 +1329,10 @@ SectionList *
Module::GetSectionList()
{
// Populate m_unified_sections_ap with sections from objfile.
if (m_sections_ap.get() == NULL)
if (!m_sections_ap)
{
ObjectFile *obj_file = GetObjectFile();
if (obj_file)
if (obj_file != nullptr)
obj_file->CreateSections(*GetUnifiedSectionList());
}
return m_sections_ap.get();
@ -1346,7 +1345,7 @@ Module::SectionFileAddressesChanged ()
if (obj_file)
obj_file->SectionFileAddressesChanged ();
SymbolVendor* sym_vendor = GetSymbolVendor();
if (sym_vendor)
if (sym_vendor != nullptr)
sym_vendor->SectionFileAddressesChanged ();
}
@ -1354,7 +1353,7 @@ SectionList *
Module::GetUnifiedSectionList()
{
// Populate m_unified_sections_ap with sections from objfile.
if (m_sections_ap.get() == NULL)
if (!m_sections_ap)
m_sections_ap.reset(new SectionList());
return m_sections_ap.get();
}
@ -1373,7 +1372,7 @@ Module::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symb
if (symtab)
return symtab->FindFirstSymbolWithNameAndType (name, symbol_type, Symtab::eDebugAny, Symtab::eVisibilityAny);
}
return NULL;
return nullptr;
}
void
Module::SymbolIndicesToSymbolContextList (Symtab *symtab, std::vector<uint32_t> &symbol_indexes, SymbolContextList &sc_list)
@ -1420,7 +1419,6 @@ Module::FindSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_t
// No need to protect this call using m_mutex all other method calls are
// already thread safe.
Timer scoped_timer(__PRETTY_FUNCTION__,
"Module::FindSymbolsWithNameAndType (name = %s, type = %i)",
name.AsCString(),
@ -1534,7 +1532,7 @@ Module::SetSymbolFileFileSpec (const FileSpec &file)
bool
Module::IsExecutable ()
{
if (GetObjectFile() == NULL)
if (GetObjectFile() == nullptr)
return false;
else
return GetObjectFile()->IsExecutable();
@ -1547,7 +1545,7 @@ Module::IsLoadedInTarget (Target *target)
if (obj_file)
{
SectionList *sections = GetSectionList();
if (sections != NULL)
if (sections != nullptr)
{
size_t num_sections = sections->GetSize();
for (size_t sect_idx = 0; sect_idx < num_sections; sect_idx++)
@ -1593,15 +1591,14 @@ Module::LoadScriptingResourceInTarget (Target *target, Error& error, Stream* fee
FileSpecList file_specs = platform_sp->LocateExecutableScriptingResources (target,
*this,
feedback_stream);
const uint32_t num_specs = file_specs.GetSize();
if (num_specs)
{
ScriptInterpreter *script_interpreter = debugger.GetCommandInterpreter().GetScriptInterpreter();
if (script_interpreter)
{
for (uint32_t i=0; i<num_specs; ++i)
for (uint32_t i = 0; i < num_specs; ++i)
{
FileSpec scripting_fspec (file_specs.GetFileSpecAtIndex(i));
if (scripting_fspec && scripting_fspec.Exists())
@ -1655,7 +1652,7 @@ bool
Module::SetLoadAddress (Target &target, lldb::addr_t value, bool value_is_offset, bool &changed)
{
ObjectFile *object_file = GetObjectFile();
if (object_file)
if (object_file != nullptr)
{
changed = object_file->SetLoadAddress(target, value, value_is_offset);
return true;
@ -1676,10 +1673,7 @@ Module::MatchesModuleSpec (const ModuleSpec &module_ref)
if (uuid.IsValid())
{
// If the UUID matches, then nothing more needs to match...
if (uuid == GetUUID())
return true;
else
return false;
return (uuid == GetUUID());
}
const FileSpec &file_spec = module_ref.GetFileSpec();
@ -1734,9 +1728,9 @@ Module::GetVersion (uint32_t *versions, uint32_t num_versions)
if (obj_file)
return obj_file->GetVersion (versions, num_versions);
if (versions && num_versions)
if (versions != nullptr && num_versions != 0)
{
for (uint32_t i=0; i<num_versions; ++i)
for (uint32_t i = 0; i < num_versions; ++i)
versions[i] = LLDB_INVALID_MODULE_VERSION;
}
return 0;

View File

@ -10,10 +10,9 @@
#include "lldb/Core/ModuleList.h"
// C Includes
#include <stdint.h>
// C++ Includes
#include <mutex> // std::once
#include <cstdint>
#include <mutex>
// Other libraries and framework includes
// Project includes
@ -29,23 +28,17 @@
using namespace lldb;
using namespace lldb_private;
//----------------------------------------------------------------------
// ModuleList constructor
//----------------------------------------------------------------------
ModuleList::ModuleList() :
m_modules(),
m_modules_mutex (Mutex::eMutexTypeRecursive),
m_notifier(NULL)
m_notifier(nullptr)
{
}
//----------------------------------------------------------------------
// Copy constructor
//----------------------------------------------------------------------
ModuleList::ModuleList(const ModuleList& rhs) :
m_modules(),
m_modules_mutex (Mutex::eMutexTypeRecursive),
m_notifier(NULL)
m_notifier(nullptr)
{
Mutex::Locker lhs_locker(m_modules_mutex);
Mutex::Locker rhs_locker(rhs.m_modules_mutex);
@ -59,9 +52,6 @@ ModuleList::ModuleList (ModuleList::Notifier* notifier) :
{
}
//----------------------------------------------------------------------
// Assignment operator
//----------------------------------------------------------------------
const ModuleList&
ModuleList::operator= (const ModuleList& rhs)
{
@ -93,12 +83,7 @@ ModuleList::operator= (const ModuleList& rhs)
return *this;
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
ModuleList::~ModuleList()
{
}
ModuleList::~ModuleList() = default;
void
ModuleList::AppendImpl (const ModuleSP &module_sp, bool use_notifier)
@ -334,7 +319,7 @@ ModuleList::GetModulePointerAtIndexUnlocked (size_t idx) const
{
if (idx < m_modules.size())
return m_modules[idx].get();
return NULL;
return nullptr;
}
ModuleSP
@ -381,25 +366,25 @@ ModuleList::FindFunctions (const ConstString &name,
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindFunctions (lookup_name,
NULL,
lookup_name_type_mask,
include_symbols,
include_inlines,
true,
sc_list);
(*pos)->FindFunctions(lookup_name,
nullptr,
lookup_name_type_mask,
include_symbols,
include_inlines,
true,
sc_list);
}
if (match_name_after_lookup)
{
SymbolContext sc;
size_t i = old_size;
while (i<sc_list.GetSize())
while (i < sc_list.GetSize())
{
if (sc_list.GetContextAtIndex(i, sc))
{
const char *func_name = sc.GetFunctionName().GetCString();
if (func_name && strstr (func_name, name.GetCString()) == NULL)
if (func_name != nullptr && strstr(func_name, name.GetCString()) == nullptr)
{
// Remove the current context
sc_list.RemoveContextAtIndex(i);
@ -410,7 +395,6 @@ ModuleList::FindFunctions (const ConstString &name,
++i;
}
}
}
else
{
@ -418,7 +402,7 @@ ModuleList::FindFunctions (const ConstString &name,
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindFunctions (name, NULL, name_type_mask, include_symbols, include_inlines, true, sc_list);
(*pos)->FindFunctions(name, nullptr, name_type_mask, include_symbols, include_inlines, true, sc_list);
}
}
return sc_list.GetSize() - old_size;
@ -455,12 +439,12 @@ ModuleList::FindFunctionSymbols (const ConstString &name,
{
SymbolContext sc;
size_t i = old_size;
while (i<sc_list.GetSize())
while (i < sc_list.GetSize())
{
if (sc_list.GetContextAtIndex(i, sc))
{
const char *func_name = sc.GetFunctionName().GetCString();
if (func_name && strstr (func_name, name.GetCString()) == NULL)
if (func_name != nullptr && strstr(func_name, name.GetCString()) == nullptr)
{
// Remove the current context
sc_list.RemoveContextAtIndex(i);
@ -471,7 +455,6 @@ ModuleList::FindFunctionSymbols (const ConstString &name,
++i;
}
}
}
else
{
@ -486,7 +469,6 @@ ModuleList::FindFunctionSymbols (const ConstString &name,
return sc_list.GetSize() - old_size;
}
size_t
ModuleList::FindFunctions(const RegularExpression &name,
bool include_symbols,
@ -535,12 +517,11 @@ ModuleList::FindGlobalVariables (const ConstString &name,
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindGlobalVariables (name, NULL, append, max_matches, variable_list);
(*pos)->FindGlobalVariables(name, nullptr, append, max_matches, variable_list);
}
return variable_list.GetSize() - initial_size;
}
size_t
ModuleList::FindGlobalVariables (const RegularExpression& regex,
bool append,
@ -557,7 +538,6 @@ ModuleList::FindGlobalVariables (const RegularExpression& regex,
return variable_list.GetSize() - initial_size;
}
size_t
ModuleList::FindSymbolsWithNameAndType (const ConstString &name,
SymbolType symbol_type,
@ -628,7 +608,6 @@ ModuleList::FindModule (const Module *module_ptr) const
}
}
return module_sp;
}
ModuleSP
@ -653,7 +632,6 @@ ModuleList::FindModule (const UUID &uuid) const
return module_sp;
}
size_t
ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeList& types) const
{
@ -684,7 +662,7 @@ ModuleList::FindTypes (const SymbolContext& sc, const ConstString &name, bool na
{
// Search the module if the module is not equal to the one in the symbol
// context "sc". If "sc" contains a empty module shared pointer, then
// the comparison will always be true (valid_module_ptr != NULL).
// the comparison will always be true (valid_module_ptr != nullptr).
if (sc.module_sp.get() != (*pos).get())
total_matches += (*pos)->FindTypes (world_sc, name, name_is_fully_qualified, max_matches, searched_symbol_files, types);
@ -750,7 +728,6 @@ ModuleList::GetSize() const
return size;
}
void
ModuleList::Dump(Stream *s) const
{
@ -769,7 +746,7 @@ ModuleList::Dump(Stream *s) const
void
ModuleList::LogUUIDAndPaths (Log *log, const char *prefix_cstr)
{
if (log)
if (log != nullptr)
{
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, begin = m_modules.begin(), end = m_modules.end();
@ -831,14 +808,11 @@ ModuleList::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t res
}
uint32_t
ModuleList::ResolveSymbolContextForFilePath
(
const char *file_path,
uint32_t line,
bool check_inlines,
uint32_t resolve_scope,
SymbolContextList& sc_list
) const
ModuleList::ResolveSymbolContextForFilePath(const char *file_path,
uint32_t line,
bool check_inlines,
uint32_t resolve_scope,
SymbolContextList& sc_list) const
{
FileSpec file_spec(file_path, false);
return ResolveSymbolContextsForFileSpec (file_spec, line, check_inlines, resolve_scope, sc_list);
@ -878,13 +852,13 @@ ModuleList::GetIndexForModule (const Module *module) const
static ModuleList &
GetSharedModuleList ()
{
static ModuleList *g_shared_module_list = NULL;
static ModuleList *g_shared_module_list = nullptr;
static std::once_flag g_once_flag;
std::call_once(g_once_flag, [](){
// NOTE: Intentionally leak the module list so a program doesn't have to
// cleanup all modules and object files as it exits. This just wastes time
// doing a bunch of cleanup that isn't required.
if (g_shared_module_list == NULL)
if (g_shared_module_list == nullptr)
g_shared_module_list = new ModuleList(); // <--- Intentional leak!!!
});
return *g_shared_module_list;
@ -896,7 +870,7 @@ ModuleList::ModuleIsInCache (const Module *module_ptr)
if (module_ptr)
{
ModuleList &shared_module_list = GetSharedModuleList ();
return shared_module_list.FindModule (module_ptr).get() != NULL;
return shared_module_list.FindModule(module_ptr).get() != nullptr;
}
return false;
}
@ -914,15 +888,12 @@ ModuleList::RemoveOrphanSharedModules (bool mandatory)
}
Error
ModuleList::GetSharedModule
(
const ModuleSpec &module_spec,
ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
ModuleSP *old_module_sp_ptr,
bool *did_create_ptr,
bool always_create
)
ModuleList::GetSharedModule(const ModuleSpec &module_spec,
ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
ModuleSP *old_module_sp_ptr,
bool *did_create_ptr,
bool always_create)
{
ModuleList &shared_module_list = GetSharedModuleList ();
Mutex::Locker locker(shared_module_list.m_modules_mutex);
@ -944,7 +915,7 @@ ModuleList::GetSharedModule
// Make sure no one else can try and get or create a module while this
// function is actively working on it by doing an extra lock on the
// global mutex list.
if (always_create == false)
if (!always_create)
{
ModuleList matching_module_list;
const size_t num_matching_modules = shared_module_list.FindModules (module_spec, matching_module_list);
@ -957,11 +928,11 @@ ModuleList::GetSharedModule
// Make sure the file for the module hasn't been modified
if (module_sp->FileHasChanged())
{
if (old_module_sp_ptr && !old_module_sp_ptr->get())
if (old_module_sp_ptr && !*old_module_sp_ptr)
*old_module_sp_ptr = module_sp;
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_MODULES));
if (log)
if (log != nullptr)
log->Printf("module changed: %p, removing from global module list",
static_cast<void*>(module_sp.get()));
@ -1105,7 +1076,6 @@ ModuleList::GetSharedModule
return error;
}
// Make sure no one else can try and get or create a module while this
// function is actively working on it by doing an extra lock on the
// global mutex list.
@ -1120,7 +1090,7 @@ ModuleList::GetSharedModule
// If we didn't have a UUID in mind when looking for the object file,
// then we should make sure the modification time hasn't changed!
if (platform_module_spec.GetUUIDPtr() == NULL)
if (platform_module_spec.GetUUIDPtr() == nullptr)
{
TimeValue file_spec_mod_time(located_binary_modulespec.GetFileSpec().GetModificationTime());
if (file_spec_mod_time.IsValid())
@ -1136,7 +1106,7 @@ ModuleList::GetSharedModule
}
}
if (module_sp.get() == NULL)
if (!module_sp)
{
module_sp.reset (new Module (platform_module_spec));
// Make sure there are a module and an object file since we can specify
@ -1226,7 +1196,7 @@ ModuleList::LoadScriptingResourcesInTarget (Target *target,
}
}
}
return errors.size() == 0;
return errors.empty();
}
void