Index: source/API/SBAddress.cpp =================================================================== --- source/API/SBAddress.cpp +++ source/API/SBAddress.cpp @@ -120,8 +120,8 @@ else m_opaque_ap->Clear(); - // Check if we weren't were able to resolve a section offset address. - // If we weren't it is ok, the load address might be a location on the + // Check if we weren't were able to resolve a section offset address. If + // we weren't it is ok, the load address might be a location on the // stack or heap, so we should just have an address with no section and // a valid offset if (!m_opaque_ap->IsValid()) @@ -163,9 +163,9 @@ } const Address &SBAddress::ref() const { - // This object should already have checked with "IsValid()" - // prior to calling this function. In case you didn't we will assert - // and die to let you know. + // This object should already have checked with "IsValid()" prior to + // calling this function. In case you didn't we will assert and die to + // let you know. assert(m_opaque_ap.get()); return *m_opaque_ap; } @@ -173,8 +173,8 @@ Address *SBAddress::get() { return m_opaque_ap.get(); } bool SBAddress::GetDescription(SBStream &description) { - // Call "ref()" on the stream to make sure it creates a backing stream in - // case there isn't one already... + // Call "ref()" on the stream to make sure it creates a backing stream + // in case there isn't one already... Stream &strm = description.ref(); if (m_opaque_ap->IsValid()) { m_opaque_ap->Dump(&strm, NULL, Address::DumpStyleResolvedDescription, Index: source/API/SBCommandInterpreter.cpp =================================================================== --- source/API/SBCommandInterpreter.cpp +++ source/API/SBCommandInterpreter.cpp @@ -272,8 +272,8 @@ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); int num_completions = 0; - // Sanity check the arguments that are passed in: - // cursor & last_char have to be within the current_line. + // Sanity check the arguments that are passed in: cursor & last_char + // have to be within the current_line. if (current_line == nullptr || cursor == nullptr || last_char == nullptr) return 0; Index: source/API/SBDebugger.cpp =================================================================== --- source/API/SBDebugger.cpp +++ source/API/SBDebugger.cpp @@ -69,10 +69,10 @@ typedef bool (*LLDBCommandPluginInit)(lldb::SBDebugger & debugger); lldb::SBDebugger debugger_sb(debugger_sp); - // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) - // function. - // TODO: mangle this differently for your system - on OSX, the first - // underscore needs to be removed and the second one stays + // This calls the bool lldb::PluginInitialize(lldb::SBDebugger + // debugger) function. TODO: mangle this differently for your system - + // on OSX, the first underscore needs to be removed and the second one + // stays LLDBCommandPluginInit init_func = (LLDBCommandPluginInit)(uintptr_t)dynlib.getAddressOfSymbol( "_ZN4lldb16PluginInitializeENS_10SBDebuggerE"); @@ -167,15 +167,12 @@ SBDebugger debugger; - // Currently we have issues if this function is called simultaneously on two - // different - // threads. The issues mainly revolve around the fact that the - // lldb_private::FormatManager - // uses global collections and having two threads parsing the .lldbinit files - // can cause - // mayhem. So to get around this for now we need to use a mutex to prevent bad - // things - // from happening. + // Currently we have issues if this function is called simultaneously on + // two different threads. The issues mainly revolve around the fact that + // the lldb_private::FormatManager uses global collections and having + // two threads parsing the .lldbinit files can cause mayhem. So to get + // around this for now we need to use a mutex to prevent bad things from + // happening. static std::recursive_mutex g_mutex; std::lock_guard guard(g_mutex); @@ -256,9 +253,9 @@ m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b); } -// Shouldn't really be settable after initialization as this could cause lots of -// problems; don't want users -// trying to switch modes in the middle of a debugging session. +// Shouldn't really be settable after initialization as this could cause +// lots of problems; don't want users trying to switch modes in the middle +// of a debugging session. void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); @@ -838,7 +835,8 @@ } ++idx; } - // +1 for the host platform, which should always appear first in the list. + // +1 for the host platform, which should always appear first in the + // list. return idx + 1; } Index: source/API/SBError.cpp =================================================================== --- source/API/SBError.cpp +++ source/API/SBError.cpp @@ -154,7 +154,8 @@ } const lldb_private::Status &SBError::operator*() const { - // Be sure to call "IsValid()" before calling this function or it will crash + // Be sure to call "IsValid()" before calling this function or it will + // crash return *m_opaque_ap; } Index: source/API/SBEvent.cpp =================================================================== --- source/API/SBEvent.cpp +++ source/API/SBEvent.cpp @@ -107,8 +107,8 @@ if (lldb_event) success = lldb_event->BroadcasterIs(broadcaster.get()); - // For logging, this gets a little chatty so only enable this when verbose - // logging is on + // For logging, this gets a little chatty so only enable this when + // verbose logging is on Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); LLDB_LOGV(log, "({0}) (SBBroadcaster({1}): {2}) => {3}", get(), broadcaster.get(), broadcaster.GetName(), success); @@ -125,10 +125,10 @@ EventSP &SBEvent::GetSP() const { return m_event_sp; } Event *SBEvent::get() const { - // There is a dangerous accessor call GetSharedPtr which can be used, so if - // we have anything valid in m_event_sp, we must use that since if it gets - // used by a function that puts something in there, then it won't update - // m_opaque_ptr... + // There is a dangerous accessor call GetSharedPtr which can be used, so + // if we have anything valid in m_event_sp, we must use that since if it + // gets used by a function that puts something in there, then it won't + // update m_opaque_ptr... if (m_event_sp) m_opaque_ptr = m_event_sp.get(); Index: source/API/SBFrame.cpp =================================================================== --- source/API/SBFrame.cpp +++ source/API/SBFrame.cpp @@ -1026,7 +1026,8 @@ break; } if (add_variable) { - // Only add variables once so we don't end up with duplicates + // Only add variables once so we don't end up with + // duplicates if (variable_set.find(variable_sp) == variable_set.end()) variable_set.insert(variable_sp); else Index: source/API/SBInstruction.cpp =================================================================== --- source/API/SBInstruction.cpp +++ source/API/SBInstruction.cpp @@ -27,24 +27,22 @@ #include "lldb/Utility/DataExtractor.h" //---------------------------------------------------------------------- -// We recently fixed a leak in one of the Instruction subclasses where -// the instruction will only hold a weak reference to the disassembler -// to avoid a cycle that was keeping both objects alive (leak) and we -// need the InstructionImpl class to make sure our public API behaves -// as users would expect. Calls in our public API allow clients to do -// things like: +// We recently fixed a leak in one of the Instruction subclasses where the +// instruction will only hold a weak reference to the disassembler to +// avoid a cycle that was keeping both objects alive (leak) and we need +// the InstructionImpl class to make sure our public API behaves as users +// would expect. Calls in our public API allow clients to do things like: // // 1 lldb::SBInstruction inst; -// 2 inst = target.ReadInstructions(pc, 1).GetInstructionAtIndex(0) -// 3 if (inst.DoesBranch()) -// 4 ... +// 2 inst = target.ReadInstructions(pc, 1).GetInstructionAtIndex(0) 3 if +// (inst.DoesBranch()) 4 ... // // There was a temporary lldb::DisassemblerSP object created in the // SBInstructionList that was returned by lldb.target.ReadInstructions() -// that will go away after line 2 but the "inst" object should be able -// to still answer questions about itself. So we make sure that any -// SBInstruction objects that are given out have a strong reference to -// the disassembler and the instruction so that the object can live and +// that will go away after line 2 but the "inst" object should be able to +// still answer questions about itself. So we make sure that any +// SBInstruction objects that are given out have a strong reference to the +// disassembler and the instruction so that the object can live and // successfully respond to all queries. //---------------------------------------------------------------------- class InstructionImpl { @@ -204,8 +202,9 @@ if (module_sp) module_sp->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc); - // Use the "ref()" instead of the "get()" accessor in case the SBStream - // didn't have a stream already created, one will get created... + // Use the "ref()" instead of the "get()" accessor in case the + // SBStream didn't have a stream already created, one will get + // created... FormatEntity::Entry format; FormatEntity::Parse("${addr}: ", format); inst_sp->Dump(&s.ref(), 0, true, false, NULL, &sc, NULL, &format, 0); Index: source/API/SBLaunchInfo.cpp =================================================================== --- source/API/SBLaunchInfo.cpp +++ source/API/SBLaunchInfo.cpp @@ -148,8 +148,8 @@ } const char *SBLaunchInfo::GetShell() { - // Constify this string so that it is saved in the string pool. Otherwise - // it would be freed when this function goes out of scope. + // Constify this string so that it is saved in the string pool. + // Otherwise it would be freed when this function goes out of scope. ConstString shell(m_opaque_sp->GetShell().GetPath().c_str()); return shell.AsCString(); } Index: source/API/SBModule.cpp =================================================================== --- source/API/SBModule.cpp +++ source/API/SBModule.cpp @@ -167,9 +167,9 @@ if (module_sp) { // We are going to return a "const char *" value through the public // API, so we need to constify it so it gets added permanently the - // string pool and then we don't need to worry about the lifetime of the - // string as it will never go away once it has been put into the ConstString - // string pool + // string pool and then we don't need to worry about the lifetime of + // the string as it will never go away once it has been put into the + // ConstString string pool uuid_cstr = ConstString(module_sp->GetUUID().GetAsString()).GetCString(); } @@ -515,9 +515,9 @@ ModuleSP module_sp(GetSP()); if (module_sp) { std::string triple(module_sp->GetArchitecture().GetTriple().str()); - // Unique the string so we don't run into ownership issues since - // the const strings put the string into the string pool once and - // the strings never comes out + // Unique the string so we don't run into ownership issues since the + // const strings put the string into the string pool once and the + // strings never comes out ConstString const_triple(triple.c_str()); return const_triple.GetCString(); } Index: source/API/SBModuleSpec.cpp =================================================================== --- source/API/SBModuleSpec.cpp +++ source/API/SBModuleSpec.cpp @@ -70,9 +70,9 @@ const char *SBModuleSpec::GetTriple() { std::string triple(m_opaque_ap->GetArchitecture().GetTriple().str()); - // Unique the string so we don't run into ownership issues since - // the const strings put the string into the string pool once and - // the strings never comes out + // Unique the string so we don't run into ownership issues since the + // const strings put the string into the string pool once and the + // strings never comes out ConstString const_triple(triple.c_str()); return const_triple.GetCString(); } Index: source/API/SBPlatform.cpp =================================================================== --- source/API/SBPlatform.cpp +++ source/API/SBPlatform.cpp @@ -280,8 +280,8 @@ if (platform_sp) { ArchSpec arch(platform_sp->GetSystemArchitecture()); if (arch.IsValid()) { - // Const-ify the string so we don't need to worry about the lifetime of - // the string + // Const-ify the string so we don't need to worry about the lifetime + // of the string return ConstString(arch.GetTriple().getTriple().c_str()).GetCString(); } } @@ -294,8 +294,8 @@ std::string s; if (platform_sp->GetOSBuildString(s)) { if (!s.empty()) { - // Const-ify the string so we don't need to worry about the lifetime of - // the string + // Const-ify the string so we don't need to worry about the + // lifetime of the string return ConstString(s.c_str()).GetCString(); } } @@ -309,8 +309,8 @@ std::string s; if (platform_sp->GetOSKernelDescription(s)) { if (!s.empty()) { - // Const-ify the string so we don't need to worry about the lifetime of - // the string + // Const-ify the string so we don't need to worry about the + // lifetime of the string return ConstString(s.c_str()).GetCString(); } } Index: source/API/SBProcess.cpp =================================================================== --- source/API/SBProcess.cpp +++ source/API/SBProcess.cpp @@ -896,8 +896,8 @@ ProcessSP process_sp = Process::ProcessEventData::GetProcessFromEvent(event.get()); if (!process_sp) { - // StructuredData events also know the process they come from. - // Try that. + // StructuredData events also know the process they come from. Try + // that. process_sp = EventDataStructuredData::GetProcessFromEvent(event.get()); } Index: source/API/SBQueueItem.cpp =================================================================== --- source/API/SBQueueItem.cpp +++ source/API/SBQueueItem.cpp @@ -111,9 +111,8 @@ ConstString type_const(type); thread_sp = m_queue_item_sp->GetExtendedBacktraceThread(type_const); if (thread_sp) { - // Save this in the Process' ExtendedThreadList so a strong pointer - // retains the - // object + // Save this in the Process' ExtendedThreadList so a strong + // pointer retains the object process_sp->GetExtendedThreadList().AddThread(thread_sp); result.SetThread(thread_sp); if (log) { Index: source/API/SBStream.cpp =================================================================== --- source/API/SBStream.cpp +++ source/API/SBStream.cpp @@ -60,8 +60,8 @@ std::string local_data; if (m_opaque_ap.get()) { - // See if we have any locally backed data. If so, copy it so we can then - // redirect it to the file so we don't lose the data + // See if we have any locally backed data. If so, copy it so we can + // then redirect it to the file so we don't lose the data if (!m_is_file) local_data = static_cast(m_opaque_ap.get())->GetString(); } @@ -79,8 +79,8 @@ if (m_opaque_ap.get()) { m_is_file = true; - // If we had any data locally in our StreamString, then pass that along to - // the to new file we are redirecting to. + // If we had any data locally in our StreamString, then pass that + // along to the to new file we are redirecting to. if (!local_data.empty()) m_opaque_ap->Write(&local_data[0], local_data.size()); } else @@ -93,8 +93,8 @@ std::string local_data; if (m_opaque_ap.get()) { - // See if we have any locally backed data. If so, copy it so we can then - // redirect it to the file so we don't lose the data + // See if we have any locally backed data. If so, copy it so we can + // then redirect it to the file so we don't lose the data if (!m_is_file) local_data = static_cast(m_opaque_ap.get())->GetString(); } @@ -103,8 +103,8 @@ if (m_opaque_ap.get()) { m_is_file = true; - // If we had any data locally in our StreamString, then pass that along to - // the to new file we are redirecting to. + // If we had any data locally in our StreamString, then pass that + // along to the to new file we are redirecting to. if (!local_data.empty()) m_opaque_ap->Write(&local_data[0], local_data.size()); } else @@ -114,8 +114,8 @@ void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) { std::string local_data; if (m_opaque_ap.get()) { - // See if we have any locally backed data. If so, copy it so we can then - // redirect it to the file so we don't lose the data + // See if we have any locally backed data. If so, copy it so we can + // then redirect it to the file so we don't lose the data if (!m_is_file) local_data = static_cast(m_opaque_ap.get())->GetString(); } @@ -124,8 +124,8 @@ if (m_opaque_ap.get()) { m_is_file = true; - // If we had any data locally in our StreamString, then pass that along to - // the to new file we are redirecting to. + // If we had any data locally in our StreamString, then pass that + // along to the to new file we are redirecting to. if (!local_data.empty()) m_opaque_ap->Write(&local_data[0], local_data.size()); } else @@ -144,8 +144,8 @@ void SBStream::Clear() { if (m_opaque_ap.get()) { - // See if we have any locally backed data. If so, copy it so we can then - // redirect it to the file so we don't lose the data + // See if we have any locally backed data. If so, copy it so we can + // then redirect it to the file so we don't lose the data if (m_is_file) m_opaque_ap.reset(); else Index: source/API/SBTarget.cpp =================================================================== --- source/API/SBTarget.cpp +++ source/API/SBTarget.cpp @@ -84,8 +84,8 @@ const auto state = process_sp->GetState(); if (process_sp->IsAlive() && state == eStateConnected) { // If we are already connected, then we have already specified the - // listener, so if a valid listener is supplied, we need to error out - // to let the client know. + // listener, so if a valid listener is supplied, we need to error + // out to let the client know. if (attach_info.GetListener()) return Status("process is connected and already has a listener, pass " "empty listener"); @@ -288,8 +288,8 @@ if (state == eStateConnected) { // If we are already connected, then we have already specified the - // listener, so if a valid listener is supplied, we need to error out - // to let the client know. + // listener, so if a valid listener is supplied, we need to error + // out to let the client know. if (listener.IsValid()) { error.SetErrorString("process is connected and already has a listener, " "pass empty listener"); @@ -593,8 +593,9 @@ return sb_addr; } - // We have a load address that isn't in a section, just return an address - // with the offset filled in (the address) and the section set to NULL + // We have a load address that isn't in a section, just return an + // address with the offset filled in (the address) and the section set + // to NULL addr.SetRawAddress(vm_addr); return sb_addr; } @@ -624,8 +625,9 @@ return sb_addr; } - // We have a load address that isn't in a section, just return an address - // with the offset filled in (the address) and the section set to NULL + // We have a load address that isn't in a section, just return an + // address with the offset filled in (the address) and the section set + // to NULL addr.SetRawAddress(vm_addr); return sb_addr; } @@ -1543,9 +1545,9 @@ TargetSP target_sp(GetSP()); if (target_sp) { std::string triple(target_sp->GetArchitecture().GetTriple().str()); - // Unique the string so we don't run into ownership issues since - // the const strings put the string into the string pool once and - // the strings never comes out + // Unique the string so we don't run into ownership issues since the + // const strings put the string into the string pool once and the + // strings never comes out ConstString const_triple(triple.c_str()); return const_triple.GetCString(); } @@ -1695,8 +1697,8 @@ } } - // Didn't find the type in the symbols; try the Objective-C runtime - // if one is installed + // Didn't find the type in the symbols; try the Objective-C runtime if + // one is installed ProcessSP process_sp(target_sp->GetProcessSP()); Index: source/API/SBThread.cpp =================================================================== --- source/API/SBThread.cpp +++ source/API/SBThread.cpp @@ -614,9 +614,8 @@ return sb_error; } - // User level plans should be Master Plans so they can be interrupted, other - // plans executed, and - // then a "continue" will resume the plan. + // User level plans should be Master Plans so they can be interrupted, + // other plans executed, and then a "continue" will resume the plan. if (new_plan != NULL) { new_plan->SetIsMasterPlan(true); new_plan->SetOkayToDiscard(false); @@ -908,11 +907,10 @@ } } - // Grab the current function, then we will make sure the "until" address is - // within the function. We discard addresses that are out of the current - // function, and then if there are no addresses remaining, give an - // appropriate - // error message. + // Grab the current function, then we will make sure the "until" + // address is within the function. We discard addresses that are out + // of the current function, and then if there are no addresses + // remaining, give an appropriate error message. bool all_in_function = true; AddressRange fun_range = frame_sc.function->GetAddressRange(); @@ -1374,8 +1372,7 @@ runtime->GetExtendedBacktraceThread(real_thread, type_const)); if (new_thread_sp) { // Save this in the Process' ExtendedThreadList so a strong - // pointer retains the - // object. + // pointer retains the object. process->GetExtendedThreadList().AddThread(new_thread_sp); sb_origin_thread.SetThread(new_thread_sp); if (log) { Index: source/API/SBThreadPlan.cpp =================================================================== --- source/API/SBThreadPlan.cpp +++ source/API/SBThreadPlan.cpp @@ -134,12 +134,11 @@ return false; } -// This section allows an SBThreadPlan to push another of the common types of -// plans... +// This section allows an SBThreadPlan to push another of the common types +// of plans... // -// FIXME, you should only be able to queue thread plans from inside the methods -// of a -// Scripted Thread Plan. Need a way to enforce that. +// FIXME, you should only be able to queue thread plans from inside the +// methods of a Scripted Thread Plan. Need a way to enforce that. SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address, Index: source/API/SBType.cpp =================================================================== --- source/API/SBType.cpp +++ source/API/SBType.cpp @@ -89,8 +89,8 @@ const TypeImpl &SBType::ref() const { // "const SBAddress &addr" should already have checked "addr.IsValid()" - // prior to calling this function. In case you didn't we will assert - // and die to let you know. + // prior to calling this function. In case you didn't we will assert and + // die to let you know. assert(m_opaque_sp.get()); return *m_opaque_sp; } Index: source/API/SBTypeCategory.cpp =================================================================== --- source/API/SBTypeCategory.cpp +++ source/API/SBTypeCategory.cpp @@ -338,12 +338,11 @@ if (!summary.IsValid()) return false; - // FIXME: we need to iterate over all the Debugger objects and have each of - // them contain a copy of the function - // since we currently have formatters live in a global space, while Python - // code lives in a specific Debugger-related environment - // this should eventually be fixed by deciding a final location in the LLDB - // object space for formatters + // FIXME: we need to iterate over all the Debugger objects and have each + // of them contain a copy of the function since we currently have + // formatters live in a global space, while Python code lives in a + // specific Debugger-related environment this should eventually be fixed + // by deciding a final location in the LLDB object space for formatters if (summary.IsFunctionCode()) { const void *name_token = (const void *)ConstString(type_name.GetName()).GetCString(); @@ -450,12 +449,11 @@ if (!synth.IsValid()) return false; - // FIXME: we need to iterate over all the Debugger objects and have each of - // them contain a copy of the function - // since we currently have formatters live in a global space, while Python - // code lives in a specific Debugger-related environment - // this should eventually be fixed by deciding a final location in the LLDB - // object space for formatters + // FIXME: we need to iterate over all the Debugger objects and have each + // of them contain a copy of the function since we currently have + // formatters live in a global space, while Python code lives in a + // specific Debugger-related environment this should eventually be fixed + // by deciding a final location in the LLDB object space for formatters if (synth.IsClassCode()) { const void *name_token = (const void *)ConstString(type_name.GetName()).GetCString(); Index: source/API/SBValue.cpp =================================================================== --- source/API/SBValue.cpp +++ source/API/SBValue.cpp @@ -86,19 +86,16 @@ if (m_valobj_sp.get() == NULL) return false; else { - // FIXME: This check is necessary but not sufficient. We for sure don't - // want to touch SBValues whose owning - // targets have gone away. This check is a little weak in that it - // enforces that restriction when you call - // IsValid, but since IsValid doesn't lock the target, you have no - // guarantee that the SBValue won't go - // invalid after you call this... - // Also, an SBValue could depend on data from one of the modules in the - // target, and those could go away - // independently of the target, for instance if a module is unloaded. But - // right now, neither SBValues - // nor ValueObjects know which modules they depend on. So I have no good - // way to make that check without + // FIXME: This check is necessary but not sufficient. We for sure + // don't want to touch SBValues whose owning targets have gone away. + // This check is a little weak in that it enforces that restriction + // when you call IsValid, but since IsValid doesn't lock the target, + // you have no guarantee that the SBValue won't go invalid after you + // call this... Also, an SBValue could depend on data from one of + // the modules in the target, and those could go away independently + // of the target, for instance if a module is unloaded. But right + // now, neither SBValues nor ValueObjects know which modules they + // depend on. So I have no good way to make that check without // tracking that in all the ValueObject subclasses. TargetSP target_sp = m_valobj_sp->GetTargetSP(); if (target_sp && target_sp->IsValid()) @@ -129,9 +126,9 @@ ProcessSP process_sp(value_sp->GetProcessSP()); if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock())) { - // We don't allow people to play around with ValueObject if the process is - // running. - // If you want to look at values, pause the process, then look. + // We don't allow people to play around with ValueObject if the + // process is running. If you want to look at values, pause the + // process, then look. if (log) log->Printf("SBValue(%p)::GetSP() => error: process is running", static_cast(value_sp.get())); @@ -169,12 +166,11 @@ bool GetUseSynthetic() { return m_use_synthetic; } - // All the derived values that we would make from the m_valobj_sp will share - // the ExecutionContext with m_valobj_sp, so we don't need to do the - // calculations - // in GetSP to return the Target, Process, Thread or Frame. It is convenient - // to - // provide simple accessors for these, which I do here. + // All the derived values that we would make from the m_valobj_sp will + // share the ExecutionContext with m_valobj_sp, so we don't need to do + // the calculations in GetSP to return the Target, Process, Thread or + // Frame. It is convenient to provide simple accessors for these, which + // I do here. TargetSP GetTargetSP() { if (m_valobj_sp) return m_valobj_sp->GetTargetSP(); @@ -243,8 +239,8 @@ bool SBValue::IsValid() { // If this function ever changes to anything that does more than just - // check if the opaque shared pointer is non NULL, then we need to update - // all "if (m_opaque_sp)" code in this file. + // check if the opaque shared pointer is non NULL, then we need to + // update all "if (m_opaque_sp)" code in this file. return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() && m_opaque_sp->GetRootSP().get() != NULL; } @@ -991,7 +987,8 @@ ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { - // using default values for all the fancy options, just do it if you can + // using default values for all the fancy options, just do it if you + // can child_sp = value_sp->GetValueForExpressionPath(expr_path); } @@ -1397,11 +1394,9 @@ if (module_sp) module_sp->ResolveFileAddress(value, addr); } else if (addr_type == eAddressTypeLoad) { - // no need to check the return value on this.. if it can actually do the - // resolve - // addr will be in the form (section,offset), otherwise it will simply - // be returned - // as (NULL, value) + // no need to check the return value on this.. if it can actually + // do the resolve addr will be in the form (section,offset), + // otherwise it will simply be returned as (NULL, value) addr.SetLoadAddress(value, target_sp.get()); } } @@ -1515,7 +1510,8 @@ SBError &error) { SBWatchpoint sb_watchpoint; - // If the SBValue is not valid, there's no point in even trying to watch it. + // If the SBValue is not valid, there's no point in even trying to watch + // it. ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); TargetSP target_sp(GetTarget().GetSP()); @@ -1579,9 +1575,8 @@ return sb_watchpoint; } -// FIXME: Remove this method impl (as well as the decl in .h) once it is no -// longer needed. -// Backward compatibility fix in the interim. +// FIXME: Remove this method impl (as well as the decl in .h) once it is +// no longer needed. Backward compatibility fix in the interim. lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write) { SBError error; Index: source/API/SystemInitializerFull.cpp =================================================================== --- source/API/SystemInitializerFull.cpp +++ source/API/SystemInitializerFull.cpp @@ -138,11 +138,11 @@ #define LLDBSwigPyInit init_lldb #endif -// these are the Pythonic implementations of the required callbacks -// these are scripting-language specific, which is why they belong here -// we still need to use function pointers to them instead of relying -// on linkage-time resolution because the SWIG stuff and this file -// get built at different times +// these are the Pythonic implementations of the required callbacks these +// are scripting-language specific, which is why they belong here we still +// need to use function pointers to them instead of relying on linkage- +// time resolution because the SWIG stuff and this file get built at +// different times extern "C" bool LLDBSwigPythonBreakpointCallbackFunction( const char *python_function_name, const char *session_dictionary_name, const lldb::StackFrameSP &sb_frame, @@ -262,10 +262,9 @@ #if !defined(LLDB_DISABLE_PYTHON) InitializeSWIG(); - // ScriptInterpreterPython::Initialize() depends on things like HostInfo being - // initialized - // so it can compute the python directory etc, so we need to do this after - // SystemInitializerCommon::Initialize(). + // ScriptInterpreterPython::Initialize() depends on things like HostInfo + // being initialized so it can compute the python directory etc, so we + // need to do this after SystemInitializerCommon::Initialize(). ScriptInterpreterPython::Initialize(); #endif @@ -363,8 +362,8 @@ DynamicLoaderDarwinKernel::Initialize(); #endif - // This plugin is valid on any host that talks to a Darwin remote. - // It shouldn't be limited to __APPLE__. + // This plugin is valid on any host that talks to a Darwin remote. It + // shouldn't be limited to __APPLE__. StructuredDataDarwinLog::Initialize(); //---------------------------------------------------------------------- @@ -382,9 +381,9 @@ // Scan for any system or user LLDB plug-ins PluginManager::Initialize(); - // The process settings need to know about installed plug-ins, so the Settings - // must be initialized - // AFTER PluginManager::Initialize is called. + // The process settings need to know about installed plug-ins, so the + // Settings must be initialized AFTER PluginManager::Initialize is + // called. Debugger::SettingsInitialize(); } Index: source/Breakpoint/Breakpoint.cpp =================================================================== --- source/Breakpoint/Breakpoint.cpp +++ source/Breakpoint/Breakpoint.cpp @@ -290,8 +290,8 @@ // the breakpoint vs. its locations. // Disable at the breakpoint level should override the location settings. -// That way you can conveniently turn off a whole breakpoint without messing -// up the individual settings. +// That way you can conveniently turn off a whole breakpoint without +// messing up the individual settings. void Breakpoint::SetEnabled(bool enable) { if (enable == m_options_up->IsEnabled()) @@ -330,11 +330,10 @@ bool Breakpoint::IgnoreCountShouldStop() { uint32_t ignore = GetIgnoreCount(); if (ignore != 0) { - // When we get here we know the location that caused the stop doesn't have - // an ignore count, - // since by contract we call it first... So we don't have to find & - // decrement it, we only have - // to decrement our own ignore count. + // When we get here we know the location that caused the stop doesn't + // have an ignore count, since by contract we call it first... So we + // don't have to find & decrement it, we only have to decrement our + // own ignore count. DecrementIgnoreCount(); return false; } else @@ -478,8 +477,7 @@ bool send_event) { if (m_resolver_sp) { // If this is not an internal breakpoint, set up to record the new - // locations, then dispatch - // an event with the new locations. + // locations, then dispatch an event with the new locations. if (!IsInternal() && send_event) { BreakpointEventData *new_locations_event = new BreakpointEventData( eBreakpointEventTypeLocationsAdded, shared_from_this()); @@ -517,14 +515,14 @@ std::lock_guard guard(module_list.GetMutex()); if (load) { // The logic for handling new modules is: - // 1) If the filter rejects this module, then skip it. - // 2) Run through the current location list and if there are any locations + // 1) If the filter rejects this module, then skip it. 2) Run through + // the current location list and if there are any locations // for that module, we mark the module as "seen" and we don't try to // re-resolve // breakpoint locations for that module. // However, we do add breakpoint sites to these locations if needed. - // 3) If we don't see this module in our breakpoint location list, call - // ResolveInModules. + // 3) If we don't see this module in our breakpoint location list, + // call ResolveInModules. ModuleList new_modules; // We'll stuff the "unseen" modules in this list, // and then resolve @@ -540,9 +538,9 @@ for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations()) { - // If the section for this location was deleted, that means - // it's Module has gone away but somebody forgot to tell us. - // Let's clean it up here. + // If the section for this location was deleted, that means it's + // Module has gone away but somebody forgot to tell us. Let's + // clean it up here. Address section_addr(break_loc_sp->GetAddress()); if (section_addr.SectionWasDeleted()) { locations_with_no_section.Add(break_loc_sp); @@ -554,9 +552,9 @@ SectionSP section_sp(section_addr.GetSection()); - // If we don't have a Section, that means this location is a raw address - // that we haven't resolved to a section yet. So we'll have to look - // in all the new modules to resolve this location. + // If we don't have a Section, that means this location is a raw + // address that we haven't resolved to a section yet. So we'll + // have to look in all the new modules to resolve this location. // Otherwise, if it was set in this module, re-resolve it here. if (section_sp && section_sp->GetModule() == module_sp) { if (!seen) @@ -584,9 +582,9 @@ ResolveBreakpointInModules(new_modules); } } else { - // Go through the currently set locations and if any have breakpoints in - // the module list, then remove their breakpoint sites, and their locations - // if asked to. + // Go through the currently set locations and if any have breakpoints + // in the module list, then remove their breakpoint sites, and their + // locations if asked to. BreakpointEventData *removed_locations_event; if (!IsInternal()) @@ -607,9 +605,8 @@ SectionSP section_sp(break_loc_sp->GetAddress().GetSection()); if (section_sp && section_sp->GetModule() == module_sp) { // Remove this breakpoint since the shared library is - // unloaded, but keep the breakpoint location around - // so we always get complete hit count and breakpoint - // lifetime info + // unloaded, but keep the breakpoint location around so we + // always get complete hit count and breakpoint lifetime info break_loc_sp->ClearBreakpointSite(); if (removed_locations_event) { removed_locations_event->GetBreakpointLocationCollection().Add( @@ -637,7 +634,8 @@ bool equivalent_scs = false; if (old_sc.module_sp.get() == new_sc.module_sp.get()) { - // If these come from the same module, we can directly compare the pointers: + // If these come from the same module, we can directly compare the + // pointers: if (old_sc.comp_unit && new_sc.comp_unit && (old_sc.comp_unit == new_sc.comp_unit)) { if (old_sc.function && new_sc.function && @@ -688,21 +686,19 @@ size_t num_old_locations = old_break_locs.GetSize(); if (num_old_locations == 0) { - // There were no locations in the old module, so we just need to check if - // there were any in the new module. + // There were no locations in the old module, so we just need to check + // if there were any in the new module. ModuleList temp_list; temp_list.Append(new_module_sp); ResolveBreakpointInModules(temp_list); } else { - // First search the new module for locations. - // Then compare this with the old list, copy over locations that "look the - // same" - // Then delete the old locations. - // Finally remember to post the creation event. + // First search the new module for locations. Then compare this with + // the old list, copy over locations that "look the same" Then delete + // the old locations. Finally remember to post the creation event. // - // Two locations are the same if they have the same comp unit & function (by - // name) and there are the same number - // of locations in the old function as in the new one. + // Two locations are the same if they have the same comp unit & + // function (by name) and there are the same number of locations in + // the old function as in the new one. ModuleList temp_list; temp_list.Append(new_module_sp); @@ -714,14 +710,14 @@ size_t num_new_locations = new_break_locs.GetSize(); if (num_new_locations > 0) { - // Break out the case of one location -> one location since that's the - // most common one, and there's no need - // to build up the structures needed for the merge in that case. + // Break out the case of one location -> one location since that's + // the most common one, and there's no need to build up the + // structures needed for the merge in that case. if (num_new_locations == 1 && num_old_locations == 1) { bool equivalent_locations = false; SymbolContext old_sc, new_sc; - // The only way the old and new location can be equivalent is if they - // have the same amount of information: + // The only way the old and new location can be equivalent is if + // they have the same amount of information: BreakpointLocationSP old_loc_sp = old_break_locs.GetByIndex(0); BreakpointLocationSP new_loc_sp = new_break_locs.GetByIndex(0); @@ -738,9 +734,8 @@ locations_to_announce.Add(new_loc_sp); } } else { - // We don't want to have to keep computing the SymbolContexts for these - // addresses over and over, - // so lets get them up front: + // We don't want to have to keep computing the SymbolContexts for + // these addresses over and over, so lets get them up front: typedef std::map IDToSCMap; IDToSCMap old_sc_map; @@ -763,7 +758,8 @@ lldb::break_id_t old_id = old_sc_map.begin()->first; SymbolContext &old_sc = old_sc_map.begin()->second; - // Count the number of entries equivalent to this SC for the old list: + // Count the number of entries equivalent to this SC for the old + // list: std::vector old_id_vec; old_id_vec.push_back(old_id); @@ -783,13 +779,11 @@ } // Alright, if we have the same number of potentially equivalent - // locations in the old - // and new modules, we'll just map them one to one in ascending ID - // order (assuming the - // resolver's order would match the equivalent ones. - // Otherwise, we'll dump all the old ones, and just take the new ones, - // erasing the elements - // from both maps as we go. + // locations in the old and new modules, we'll just map them one + // to one in ascending ID order (assuming the resolver's order + // would match the equivalent ones. Otherwise, we'll dump all + // the old ones, and just take the new ones, erasing the + // elements from both maps as we go. if (old_id_vec.size() == new_id_vec.size()) { llvm::sort(old_id_vec.begin(), old_id_vec.end()); @@ -820,13 +814,11 @@ } } - // Now remove the remaining old locations, and cons up a removed locations - // event. - // Note, we don't put the new locations that were swapped with an old - // location on the locations_to_remove - // list, so we don't need to worry about telling the world about removing a - // location we didn't tell them - // about adding. + // Now remove the remaining old locations, and cons up a removed + // locations event. Note, we don't put the new locations that were + // swapped with an old location on the locations_to_remove list, so we + // don't need to worry about telling the world about removing a + // location we didn't tell them about adding. BreakpointEventData *locations_event; if (!IsInternal()) @@ -888,10 +880,9 @@ const size_t num_locations = GetNumLocations(); const size_t num_resolved_locations = GetNumResolvedLocations(); - // They just made the breakpoint, they don't need to be told HOW they made - // it... - // Also, we'll print the breakpoint number differently depending on whether - // there is 1 or more locations. + // They just made the breakpoint, they don't need to be told HOW they + // made it... Also, we'll print the breakpoint number differently + // depending on whether there is 1 or more locations. if (level != eDescriptionLevelInitial) { s->Printf("%i: ", GetID()); GetResolverDescription(s); @@ -907,9 +898,9 @@ s->Printf(", resolved = %" PRIu64 ", hit count = %d", (uint64_t)num_resolved_locations, GetHitCount()); } else { - // Don't print the pending notification for exception resolvers since we - // don't generally - // know how to set them until the target is run. + // Don't print the pending notification for exception resolvers + // since we don't generally know how to set them until the target is + // run. if (m_resolver_sp->getResolverID() != BreakpointResolver::ExceptionResolver) s->Printf(", locations = 0 (pending)"); @@ -964,9 +955,9 @@ break; } - // The brief description is just the location name (1.2 or whatever). That's - // pointless to - // show in the breakpoint's description, so suppress it. + // The brief description is just the location name (1.2 or whatever). + // That's pointless to show in the breakpoint's description, so suppress + // it. if (show_locations && level != lldb::eDescriptionLevelBrief) { s->IndentMore(); for (size_t i = 0; i < num_locations; ++i) { @@ -986,8 +977,8 @@ bool Breakpoint::GetMatchingFileLine(const ConstString &filename, uint32_t line_number, BreakpointLocationCollection &loc_coll) { - // TODO: To be correct, this method needs to fill the breakpoint location - // collection + // TODO: To be correct, this method needs to fill the breakpoint + // location collection // with the location IDs which match the filename and line_number. // Index: source/Breakpoint/BreakpointID.cpp =================================================================== --- source/Breakpoint/BreakpointID.cpp +++ source/Breakpoint/BreakpointID.cpp @@ -28,11 +28,10 @@ static llvm::StringRef g_range_specifiers[] = {"-", "to", "To", "TO"}; -// Tells whether or not STR is valid to use between two strings representing -// breakpoint IDs, to -// indicate a range of breakpoint IDs. This is broken out into a separate -// function so that we can -// easily change or add to the format for specifying ID ranges at a later date. +// Tells whether or not STR is valid to use between two strings +// representing breakpoint IDs, to indicate a range of breakpoint IDs. +// This is broken out into a separate function so that we can easily +// change or add to the format for specifying ID ranges at a later date. bool BreakpointID::IsRangeIdentifier(llvm::StringRef str) { for (auto spec : g_range_specifiers) { @@ -85,7 +84,8 @@ if (input.consumeInteger(0, bp_id)) return llvm::None; - // period is optional, but if it exists, it must be followed by a number. + // period is optional, but if it exists, it must be followed by a + // number. if (input.consume_front(".")) { if (input.consumeInteger(0, loc_id)) return llvm::None; Index: source/Breakpoint/BreakpointIDList.cpp =================================================================== --- source/Breakpoint/BreakpointIDList.cpp +++ source/Breakpoint/BreakpointIDList.cpp @@ -236,14 +236,14 @@ return; } - // We have valid range starting & ending breakpoint IDs. Go through all - // the breakpoints in the target and find all the breakpoints that fit - // into this range, and add them to new_args. + // We have valid range starting & ending breakpoint IDs. Go through + // all the breakpoints in the target and find all the breakpoints that + // fit into this range, and add them to new_args. // Next check to see if we have location id's. If so, make sure the // start_bp_id and end_bp_id are for the same breakpoint; otherwise we - // have an illegal range: breakpoint id ranges that specify bp locations - // are NOT allowed to cross major bp id numbers. + // have an illegal range: breakpoint id ranges that specify bp + // locations are NOT allowed to cross major bp id numbers. if ((start_loc_id != LLDB_INVALID_BREAK_ID) || (end_loc_id != LLDB_INVALID_BREAK_ID)) { Index: source/Breakpoint/BreakpointLocation.cpp =================================================================== --- source/Breakpoint/BreakpointLocation.cpp +++ source/Breakpoint/BreakpointLocation.cpp @@ -110,8 +110,8 @@ if (thread_id != LLDB_INVALID_THREAD_ID) GetLocationOptions()->SetThreadID(thread_id); else { - // If we're resetting this to an invalid thread id, then - // don't make an options pointer just to do that. + // If we're resetting this to an invalid thread id, then don't make an + // options pointer just to do that. if (m_options_ap.get() != nullptr) m_options_ap->SetThreadID(thread_id); } @@ -132,8 +132,8 @@ if (index != 0) GetLocationOptions()->GetThreadSpec()->SetIndex(index); else { - // If we're resetting this to an invalid thread id, then - // don't make an options pointer just to do that. + // If we're resetting this to an invalid thread id, then don't make an + // options pointer just to do that. if (m_options_ap.get() != nullptr) m_options_ap->GetThreadSpec()->SetIndex(index); } @@ -154,8 +154,8 @@ if (thread_name != nullptr) GetLocationOptions()->GetThreadSpec()->SetName(thread_name); else { - // If we're resetting this to an invalid thread id, then - // don't make an options pointer just to do that. + // If we're resetting this to an invalid thread id, then don't make an + // options pointer just to do that. if (m_options_ap.get() != nullptr) m_options_ap->GetThreadSpec()->SetName(thread_name); } @@ -176,8 +176,8 @@ if (queue_name != nullptr) GetLocationOptions()->GetThreadSpec()->SetQueueName(queue_name); else { - // If we're resetting this to an invalid thread id, then - // don't make an options pointer just to do that. + // If we're resetting this to an invalid thread id, then don't make an + // options pointer just to do that. if (m_options_ap.get() != nullptr) m_options_ap->GetThreadSpec()->SetQueueName(queue_name); } @@ -252,8 +252,8 @@ if (condition_hash != m_condition_hash || !m_user_expression_sp || !m_user_expression_sp->MatchesContext(exe_ctx)) { LanguageType language = eLanguageTypeUnknown; - // See if we can figure out the language from the frame, otherwise use the - // default language: + // See if we can figure out the language from the frame, otherwise use + // the default language: CompileUnit *comp_unit = m_address.CalculateSymbolContextCompileUnit(); if (comp_unit) language = comp_unit->GetLanguage(); @@ -282,9 +282,9 @@ m_condition_hash = condition_hash; } - // We need to make sure the user sees any parse errors in their condition, so - // we'll hook the - // constructor errors up to the debugger's Async I/O. + // We need to make sure the user sees any parse errors in their + // condition, so we'll hook the constructor errors up to the debugger's + // Async I/O. ValueObjectSP result_value_sp; @@ -372,9 +372,9 @@ } BreakpointOptions *BreakpointLocation::GetLocationOptions() { - // If we make the copy we don't copy the callbacks because that is potentially - // expensive and we don't want to do that for the simple case where someone is - // just disabling the location. + // If we make the copy we don't copy the callbacks because that is + // potentially expensive and we don't want to do that for the simple + // case where someone is just disabling the location. if (m_options_ap.get() == nullptr) m_options_ap.reset( new BreakpointOptions(false)); @@ -388,17 +388,17 @@ ->GetThreadSpecNoCreate()); } -// RETURNS - true if we should stop at this breakpoint, false if we -// should continue. Note, we don't check the thread spec for the breakpoint -// here, since if the breakpoint is not for this thread, then the event won't -// even get reported, so the check is redundant. +// RETURNS - true if we should stop at this breakpoint, false if we should +// continue. Note, we don't check the thread spec for the breakpoint +// here, since if the breakpoint is not for this thread, then the event +// won't even get reported, so the check is redundant. bool BreakpointLocation::ShouldStop(StoppointCallbackContext *context) { bool should_stop = true; Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS); - // Do this first, if a location is disabled, it shouldn't increment its hit - // count. + // Do this first, if a location is disabled, it shouldn't increment its + // hit count. if (!IsEnabled()) return false; @@ -478,10 +478,9 @@ bool BreakpointLocation::ClearBreakpointSite() { if (m_bp_site_sp.get()) { ProcessSP process_sp(m_owner.GetTarget().GetProcessSP()); - // If the process exists, get it to remove the owner, it will remove the - // physical implementation - // of the breakpoint as well if there are no more owners. Otherwise just - // remove this owner. + // If the process exists, get it to remove the owner, it will remove + // the physical implementation of the breakpoint as well if there are + // no more owners. Otherwise just remove this owner. if (process_sp) process_sp->RemoveOwnerFromBreakpointSite(GetBreakpoint().GetID(), GetID(), m_bp_site_sp); @@ -498,9 +497,9 @@ lldb::DescriptionLevel level) { SymbolContext sc; - // If the description level is "initial" then the breakpoint is printing out - // our initial state, - // and we should let it decide how it wants to print our label. + // If the description level is "initial" then the breakpoint is printing + // out our initial state, and we should let it decide how it wants to + // print our label. if (level != eDescriptionLevelInitial) { s->Indent(); BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID()); @@ -551,7 +550,8 @@ } } else { - // If we don't have a comp unit, see if we have a symbol we can print. + // If we don't have a comp unit, see if we have a symbol we can + // print. if (sc.symbol) { s->EOL(); if (IsReExported()) Index: source/Breakpoint/BreakpointLocationList.cpp =================================================================== --- source/Breakpoint/BreakpointLocationList.cpp +++ source/Breakpoint/BreakpointLocationList.cpp @@ -48,13 +48,13 @@ lldb::break_id_t break_id) { BreakpointLocationSP bp = FindByID(break_id); if (bp) { - // Let the BreakpointLocation decide if it should stop here (could not have - // reached it's target hit count yet, or it could have a callback + // Let the BreakpointLocation decide if it should stop here (could not + // have reached it's target hit count yet, or it could have a callback // that decided it shouldn't stop (shared library loads/unloads). return bp->ShouldStop(context); } - // We should stop here since this BreakpointLocation isn't valid anymore or it - // doesn't exist. + // We should stop here since this BreakpointLocation isn't valid anymore + // or it doesn't exist. return true; } @@ -266,13 +266,13 @@ void BreakpointLocationList::RemoveInvalidLocations(const ArchSpec &arch) { std::lock_guard guard(m_mutex); size_t idx = 0; - // Don't cache m_location.size() as it will change since we might - // remove locations from our vector... + // Don't cache m_location.size() as it will change since we might remove + // locations from our vector... while (idx < m_locations.size()) { BreakpointLocation *bp_loc = m_locations[idx].get(); if (bp_loc->GetAddress().SectionWasDeleted()) { - // Section was deleted which means this breakpoint comes from a module - // that is no longer valid, so we should remove it. + // Section was deleted which means this breakpoint comes from a + // module that is no longer valid, so we should remove it. RemoveLocationByIndex(idx); continue; } @@ -280,14 +280,15 @@ ModuleSP module_sp(bp_loc->GetAddress().GetModule()); if (module_sp) { if (!arch.IsCompatibleMatch(module_sp->GetArchitecture())) { - // The breakpoint was in a module whose architecture is no longer - // compatible with "arch", so we need to remove it + // The breakpoint was in a module whose architecture is no + // longer compatible with "arch", so we need to remove it RemoveLocationByIndex(idx); continue; } } } - // Only increment the index if we didn't remove the locations at index "idx" + // Only increment the index if we didn't remove the locations at index + // "idx" ++idx; } } Index: source/Breakpoint/BreakpointOptions.cpp =================================================================== --- source/Breakpoint/BreakpointOptions.cpp +++ source/Breakpoint/BreakpointOptions.cpp @@ -37,8 +37,8 @@ BreakpointOptions::CommandData::SerializeToStructuredData() { size_t num_strings = user_source.GetSize(); if (num_strings == 0 && script_source.empty()) { - // We shouldn't serialize commands if there aren't any, return an empty sp - // to indicate this. + // We shouldn't serialize commands if there aren't any, return an + // empty sp to indicate this. return StructuredData::ObjectSP(); } @@ -424,15 +424,16 @@ void BreakpointOptions::SetCallback(BreakpointHitCallback callback, const lldb::BatonSP &callback_baton_sp, bool callback_is_synchronous) { - // FIXME: This seems unsafe. If BatonSP actually *is* a CommandBaton, but - // in a shared_ptr instead of a shared_ptr, then we - // will set m_baton_is_command_baton to false, which is incorrect. - // One possible solution is to make the base Baton class provide a method - // such as: + // FIXME: This seems unsafe. If BatonSP actually *is* a CommandBaton, + // but in a shared_ptr instead of a shared_ptr, + // then we will set m_baton_is_command_baton to false, which is + // incorrect. One possible solution is to make the base Baton class + // provide a method such as: // virtual StringRef getBatonId() const { return ""; } - // and have CommandBaton override this to return something unique, and then - // check for it here. Another option might be to make Baton using the llvm - // casting infrastructure, so that we could write something like: + // and have CommandBaton override this to return something unique, and + // then check for it here. Another option might be to make Baton using + // the llvm casting infrastructure, so that we could write something + // like: // if (llvm::isa(callback_baton_sp)) // at relevant callsites instead of storing a boolean. m_callback_is_synchronous = callback_is_synchronous; @@ -476,8 +477,8 @@ : nullptr, context, break_id, break_loc_id); } else if (IsCallbackSynchronous()) { - // If a synchronous callback is called at async time, it should not say - // to stop. + // If a synchronous callback is called at async time, it should not + // say to stop. return false; } } @@ -553,9 +554,8 @@ void BreakpointOptions::GetDescription(Stream *s, lldb::DescriptionLevel level) const { - // Figure out if there are any options not at their default value, and only - // print - // anything if there are: + // Figure out if there are any options not at their default value, and + // only print anything if there are: if (m_ignore_count != 0 || !m_enabled || m_one_shot || m_auto_continue || (GetThreadSpecNoCreate() != nullptr && @@ -659,9 +659,9 @@ if (target) { CommandReturnObject result; Debugger &debugger = target->GetDebugger(); - // Rig up the results secondary output stream to the debugger's, so the - // output will come out synchronously - // if the debugger is set up that way. + // Rig up the results secondary output stream to the debugger's, so + // the output will come out synchronously if the debugger is set up + // that way. StreamSP output_stream(debugger.GetAsyncOutputStream()); StreamSP error_stream(debugger.GetAsyncErrorStream()); Index: source/Breakpoint/BreakpointResolver.cpp =================================================================== --- source/Breakpoint/BreakpointResolver.cpp +++ source/Breakpoint/BreakpointResolver.cpp @@ -15,8 +15,8 @@ // Project includes #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" -// Have to include the other breakpoint resolver types here so the static create -// from StructuredData can call them. +// Have to include the other breakpoint resolver types here so the static +// create from StructuredData can call them. #include "lldb/Breakpoint/BreakpointResolverAddress.h" #include "lldb/Breakpoint/BreakpointResolverFileLine.h" #include "lldb/Breakpoint/BreakpointResolverFileRegex.h" @@ -192,8 +192,8 @@ FileSpec match_original_file_spec; uint32_t closest_line_number = UINT32_MAX; - // Pull out the first entry, and all the others that match its file spec, - // and stuff them in the tmp list. + // Pull out the first entry, and all the others that match its file + // spec, and stuff them in the tmp list. while (current_idx < sc_list.GetSize()) { bool matches; @@ -211,17 +211,17 @@ tmp_sc_list.Append(sc); sc_list.RemoveContextAtIndex(current_idx); - // ResolveSymbolContext will always return a number that is >= the line - // number you pass in. - // So the smaller line number is always better. + // ResolveSymbolContext will always return a number that is >= the + // line number you pass in. So the smaller line number is always + // better. if (sc.line_entry.line < closest_line_number) closest_line_number = sc.line_entry.line; } else current_idx++; } - // Okay, we've found the closest line number match, now throw away all the - // others: + // Okay, we've found the closest line number match, now throw away all + // the others: current_idx = 0; while (current_idx < tmp_sc_list.GetSize()) { @@ -234,8 +234,7 @@ } // Next go through and see if there are line table entries that are - // contiguous, and if so keep only the - // first of the contiguous range: + // contiguous, and if so keep only the first of the contiguous range: current_idx = 0; std::map blocks_with_breakpoints; @@ -262,7 +261,8 @@ Address line_start = sc.line_entry.range.GetBaseAddress(); if (line_start.IsValid()) { if (filter.AddressPasses(line_start)) { - // If the line number is before the prologue end, move it there... + // If the line number is before the prologue end, move it + // there... bool skipped_prologue = false; if (skip_prologue) { if (sc.function) { @@ -315,9 +315,9 @@ void BreakpointResolver::SetOffset(lldb::addr_t offset) { // There may already be an offset, so we are actually adjusting location - // addresses by the difference. - // lldb::addr_t slide = offset - m_offset; - // FIXME: We should go fix up all the already set locations for the new slide. + // addresses by the difference. lldb::addr_t slide = offset - m_offset; + // FIXME: We should go fix up all the already set locations for the new + // slide. m_offset = offset; } Index: source/Breakpoint/BreakpointResolverAddress.cpp =================================================================== --- source/Breakpoint/BreakpointResolverAddress.cpp +++ source/Breakpoint/BreakpointResolverAddress.cpp @@ -100,11 +100,10 @@ } void BreakpointResolverAddress::ResolveBreakpoint(SearchFilter &filter) { - // If the address is not section relative, then we should not try to - // re-resolve it, it is just some - // random address and we wouldn't know what to do on reload. But if it is - // section relative, we need to - // re-resolve it since the section it's in may have shifted on re-run. + // If the address is not section relative, then we should not try to re- + // resolve it, it is just some random address and we wouldn't know what + // to do on reload. But if it is section relative, we need to re- + // resolve it since the section it's in may have shifted on re-run. bool re_resolve = false; if (m_addr.GetSection() || m_module_filespec) re_resolve = true; @@ -136,9 +135,9 @@ if (filter.AddressPasses(m_addr)) { if (m_breakpoint->GetNumLocations() == 0) { - // If the address is just an offset, and we're given a module, see if we - // can find the appropriate module - // loaded in the binary, and fix up m_addr to use that. + // If the address is just an offset, and we're given a module, see + // if we can find the appropriate module loaded in the binary, and + // fix up m_addr to use that. if (!m_addr.IsSectionOffset() && m_module_filespec) { Target &target = m_breakpoint->GetTarget(); ModuleSpec module_spec(m_module_filespec); Index: source/Breakpoint/BreakpointResolverFileLine.cpp =================================================================== --- source/Breakpoint/BreakpointResolverFileLine.cpp +++ source/Breakpoint/BreakpointResolverFileLine.cpp @@ -108,13 +108,13 @@ return WrapOptionsDict(options_dict_sp); } -// Filter the symbol context list to remove contexts where the line number was -// moved into a new function. We do this conservatively, so if e.g. we cannot -// resolve the function in the context (which can happen in case of -// line-table-only debug info), we leave the context as is. The trickiest part -// here is handling inlined functions -- in this case we need to make sure we -// look at the declaration line of the inlined function, NOT the function it was -// inlined into. +// Filter the symbol context list to remove contexts where the line number +// was moved into a new function. We do this conservatively, so if e.g. we +// cannot resolve the function in the context (which can happen in case of +// line-table-only debug info), we leave the context as is. The trickiest +// part here is handling inlined functions -- in this case we need to make +// sure we look at the declaration line of the inlined function, NOT the +// function it was inlined into. void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list, bool is_relative) { if (m_exact_match) @@ -129,8 +129,8 @@ SymbolContext sc; sc_list.GetContextAtIndex(i, sc); if (is_relative) { - // If the path was relative, make sure any matches match as long as the - // relative parts of the path match the path from support files + // If the path was relative, make sure any matches match as long as + // the relative parts of the path match the path from support files auto sc_dir = sc.line_entry.file.GetDirectory().GetStringRef(); if (!sc_dir.endswith(relative_path)) { // We had a relative path specified and the relative directory @@ -173,9 +173,9 @@ // { // ... // - // the compiler will set the declaration line to the "foo" line, which is - // the reason why we have -1 here. This can fail in case of two inline - // functions defined back-to-back: + // the compiler will set the declaration line to the "foo" line, which + // is the reason why we have -1 here. This can fail in case of two + // inline functions defined back-to-back: // // inline int foo1() { ... } // inline int foo2() { ... } @@ -199,20 +199,22 @@ assert(m_breakpoint != NULL); // There is a tricky bit here. You can have two compilation units that - // #include the same file, and in one of them the function at m_line_number is - // used (and so code and a line entry for it is generated) but in the other it - // isn't. If we considered the CU's independently, then in the second - // inclusion, we'd move the breakpoint to the next function that actually - // generated code in the header file. That would end up being confusing. So - // instead, we do the CU iterations by hand here, then scan through the - // complete list of matches, and figure out the closest line number match, and - // only set breakpoints on that match. - - // Note also that if file_spec only had a file name and not a directory, there - // may be many different file spec's in the resultant list. The closest line - // match for one will not be right for some totally different file. So we go - // through the match list and pull out the sets that have the same file spec - // in their line_entry and treat each set separately. + // #include the same file, and in one of them the function at + // m_line_number is used (and so code and a line entry for it is + // generated) but in the other it isn't. If we considered the CU's + // independently, then in the second inclusion, we'd move the breakpoint + // to the next function that actually generated code in the header file. + // That would end up being confusing. So instead, we do the CU + // iterations by hand here, then scan through the complete list of + // matches, and figure out the closest line number match, and only set + // breakpoints on that match. + + // Note also that if file_spec only had a file name and not a directory, + // there may be many different file spec's in the resultant list. The + // closest line match for one will not be right for some totally + // different file. So we go through the match list and pull out the + // sets that have the same file spec in their line_entry and treat each + // set separately. FileSpec search_file_spec = m_file_spec; const bool is_relative = m_file_spec.IsRelative(); Index: source/Breakpoint/BreakpointResolverName.cpp =================================================================== --- source/Breakpoint/BreakpointResolverName.cpp +++ source/Breakpoint/BreakpointResolverName.cpp @@ -239,11 +239,9 @@ } // FIXME: Right now we look at the module level, and call the module's -// "FindFunctions". -// Greg says he will add function tables, maybe at the CompileUnit level to -// accelerate function -// lookup. At that point, we should switch the depth to CompileUnit, and look -// in these tables. +// "FindFunctions". Greg says he will add function tables, maybe at the +// CompileUnit level to accelerate function lookup. At that point, we +// should switch the depth to CompileUnit, and look in these tables. Searcher::CallbackReturn BreakpointResolverName::SearchCallback(SearchFilter &filter, @@ -301,8 +299,8 @@ break; } - // If the filter specifies a Compilation Unit, remove the ones that don't pass - // at this point. + // If the filter specifies a Compilation Unit, remove the ones that + // don't pass at this point. if (filter_by_cu || filter_by_language) { uint32_t num_functions = func_list.GetSize(); Index: source/Breakpoint/BreakpointSite.cpp =================================================================== --- source/Breakpoint/BreakpointSite.cpp +++ source/Breakpoint/BreakpointSite.cpp @@ -49,8 +49,8 @@ return ++g_next_id; } -// RETURNS - true if we should stop at this breakpoint, false if we -// should continue. +// RETURNS - true if we should stop at this breakpoint, false if we should +// continue. bool BreakpointSite::ShouldStop(StoppointCallbackContext *context) { std::lock_guard guard(m_owners_mutex); Index: source/Breakpoint/BreakpointSiteList.cpp =================================================================== --- source/Breakpoint/BreakpointSiteList.cpp +++ source/Breakpoint/BreakpointSiteList.cpp @@ -23,9 +23,9 @@ BreakpointSiteList::~BreakpointSiteList() {} -// Add breakpoint site to the list. However, if the element already exists in -// the -// list, then we don't add it, and return LLDB_INVALID_BREAK_ID. +// Add breakpoint site to the list. However, if the element already +// exists in the list, then we don't add it, and return +// LLDB_INVALID_BREAK_ID. lldb::break_id_t BreakpointSiteList::Add(const BreakpointSiteSP &bp) { lldb::addr_t bp_site_load_addr = bp->GetLoadAddress(); @@ -44,24 +44,25 @@ lldb::break_id_t site_id) { BreakpointSiteSP site_sp(FindByID(site_id)); if (site_sp) { - // Let the BreakpointSite decide if it should stop here (could not have - // reached it's target hit count yet, or it could have a callback + // Let the BreakpointSite decide if it should stop here (could not + // have reached it's target hit count yet, or it could have a callback // that decided it shouldn't stop (shared library loads/unloads). return site_sp->ShouldStop(context); } - // We should stop here since this BreakpointSite isn't valid anymore or it - // doesn't exist. + // We should stop here since this BreakpointSite isn't valid anymore or + // it doesn't exist. return true; } lldb::break_id_t BreakpointSiteList::FindIDByAddress(lldb::addr_t addr) { BreakpointSiteSP bp = FindByAddress(addr); if (bp) { - // DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8" - // PRIx64 " ) => %u", __FUNCTION__, (uint64_t)addr, bp->GetID()); + // DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = + // 0x%8.8" PRIx64 " ) => %u", __FUNCTION__, (uint64_t)addr, + // bp->GetID()); return bp.get()->GetID(); } - // DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8" PRIx64 - // " ) => NONE", __FUNCTION__, (uint64_t)addr); + // DBLogIf(PD_LOG_BREAKPOINTS, "BreakpointSiteList::%s ( addr = 0x%8.8" + // PRIx64 " ) => NONE", __FUNCTION__, (uint64_t)addr); return LLDB_INVALID_BREAK_ID; } @@ -185,10 +186,9 @@ if (lower == m_bp_site_list.end() || (*lower).first >= upper_bound) return false; - // This is one tricky bit. The breakpoint might overlap the bottom end of the - // range. So we grab the - // breakpoint prior to the lower bound, and check that that + its byte size - // isn't in our range. + // This is one tricky bit. The breakpoint might overlap the bottom end + // of the range. So we grab the breakpoint prior to the lower bound, + // and check that that + its byte size isn't in our range. if (lower != m_bp_site_list.begin()) { collection::const_iterator prev_pos = lower; prev_pos--; Index: source/Breakpoint/Watchpoint.cpp =================================================================== --- source/Breakpoint/Watchpoint.cpp +++ source/Breakpoint/Watchpoint.cpp @@ -38,8 +38,8 @@ if (type && type->IsValid()) m_type = *type; else { - // If we don't have a known type, then we force it to unsigned int of the - // right size. + // If we don't have a known type, then we force it to unsigned int of + // the right size. ClangASTContext *ast_context = target.GetScratchClangASTContext(); m_type = ast_context->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 8 * size); @@ -89,8 +89,8 @@ m_watch_spec_str = str; } -// Override default impl of StoppointLocation::IsHardware() since m_is_hardware -// member field is more accurate. +// Override default impl of StoppointLocation::IsHardware() since +// m_is_hardware member field is more accurate. bool Watchpoint::IsHardware() const { return m_is_hardware; } bool Watchpoint::IsWatchVariable() const { return m_is_watch_variable; } @@ -103,10 +103,10 @@ Address watch_address(GetLoadAddress()); if (!m_type.IsValid()) { // Don't know how to report new & old values, since we couldn't make a - // scalar type for this watchpoint. - // This works around an assert in ValueObjectMemory::Create. - // FIXME: This should not happen, but if it does in some case we care about, - // we can go grab the value raw and print it as unsigned. + // scalar type for this watchpoint. This works around an assert in + // ValueObjectMemory::Create. FIXME: This should not happen, but if it + // does in some case we care about, we can go grab the value raw and + // print it as unsigned. return false; } m_new_value_sp = ValueObjectMemory::Create( @@ -129,8 +129,8 @@ } } -// RETURNS - true if we should stop at this breakpoint, false if we -// should continue. +// RETURNS - true if we should stop at this breakpoint, false if we should +// continue. bool Watchpoint::ShouldStop(StoppointCallbackContext *context) { IncrementHitCount(); @@ -216,11 +216,10 @@ bool Watchpoint::IsEnabled() const { return m_enabled; } -// Within StopInfo.cpp, we purposely turn on the ephemeral mode right before -// temporarily disable the watchpoint -// in order to perform possible watchpoint actions without triggering further -// watchpoint events. -// After the temporary disabled watchpoint is enabled, we then turn off the +// Within StopInfo.cpp, we purposely turn on the ephemeral mode right +// before temporarily disable the watchpoint in order to perform possible +// watchpoint actions without triggering further watchpoint events. After +// the temporary disabled watchpoint is enabled, we then turn off the // ephemeral mode. void Watchpoint::TurnOnEphemeralMode() { m_is_ephemeral = true; } @@ -243,8 +242,8 @@ ++m_disabled_count; // Don't clear the snapshots for now. - // Within StopInfo.cpp, we purposely do disable/enable watchpoint while - // performing watchpoint actions. + // Within StopInfo.cpp, we purposely do disable/enable watchpoint + // while performing watchpoint actions. } bool changed = enabled != m_enabled; m_enabled = enabled; @@ -285,7 +284,8 @@ if (m_condition_ap.get()) m_condition_ap.reset(); } else { - // Pass nullptr for expr_prefix (no translation-unit level definitions). + // Pass nullptr for expr_prefix (no translation-unit level + // definitions). Status error; m_condition_ap.reset(m_target.GetUserExpressionForLanguage( condition, llvm::StringRef(), lldb::eLanguageTypeUnknown, Index: source/Breakpoint/WatchpointList.cpp =================================================================== --- source/Breakpoint/WatchpointList.cpp +++ source/Breakpoint/WatchpointList.cpp @@ -204,8 +204,8 @@ WatchpointSP wp_sp = FindByID(watch_id); if (wp_sp) { // Let the Watchpoint decide if it should stop here (could not have - // reached it's target hit count yet, or it could have a callback - // that decided it shouldn't stop. + // reached it's target hit count yet, or it could have a callback that + // decided it shouldn't stop. return wp_sp->ShouldStop(context); } // We should stop here since this Watchpoint isn't valid anymore or it Index: source/Breakpoint/WatchpointOptions.cpp =================================================================== --- source/Breakpoint/WatchpointOptions.cpp +++ source/Breakpoint/WatchpointOptions.cpp @@ -142,9 +142,8 @@ void WatchpointOptions::GetDescription(Stream *s, lldb::DescriptionLevel level) const { - // Figure out if there are any options not at their default value, and only - // print - // anything if there are: + // Figure out if there are any options not at their default value, and + // only print anything if there are: if ((GetThreadSpecNoCreate() != nullptr && GetThreadSpecNoCreate()->HasSpecification())) { Index: source/Commands/CommandCompletions.cpp =================================================================== --- source/Commands/CommandCompletions.cpp +++ source/Commands/CommandCompletions.cpp @@ -133,9 +133,10 @@ llvm::SmallString Resolved; if (!Resolver.ResolveExact(Username, Resolved)) { - // We couldn't resolve it as a full username. If there were no slashes - // then this might be a partial username. We try to resolve it as such - // but after that, we're done regardless of any matches. + // We couldn't resolve it as a full username. If there were no + // slashes then this might be a partial username. We try to + // resolve it as such but after that, we're done regardless of any + // matches. if (FirstSep == llvm::StringRef::npos) { llvm::StringSet<> MatchSet; saw_directory = Resolver.ResolvePartial(Username, MatchSet); @@ -149,9 +150,9 @@ return matches.GetSize(); } - // If there was no trailing slash, then we're done as soon as we resolve the - // expression to the correct directory. Otherwise we need to continue - // looking for matches within that directory. + // If there was no trailing slash, then we're done as soon as we + // resolve the expression to the correct directory. Otherwise we need + // to continue looking for matches within that directory. if (FirstSep == llvm::StringRef::npos) { // Make sure it ends with a separator. path::append(CompletionBuffer, path::get_separator()); @@ -161,8 +162,8 @@ } // We want to keep the form the user typed, so we special case this to - // search in the fully resolved directory, but CompletionBuffer keeps the - // unmodified form that the user typed. + // search in the fully resolved directory, but CompletionBuffer keeps + // the unmodified form that the user typed. Storage = Resolved; SearchDir = Storage; } else { @@ -181,8 +182,8 @@ } assert(!PartialItem.contains(path::get_separator())); - // SearchDir now contains the directory to search in, and Prefix contains the - // text we want to match against items in that directory. + // SearchDir now contains the directory to search in, and Prefix + // contains the text we want to match against items in that directory. std::error_code EC; fs::directory_iterator Iter(SearchDir, EC, false); @@ -202,8 +203,8 @@ if (!st) continue; - // If it's a symlink, then we treat it as a directory as long as the target - // is a directory. + // If it's a symlink, then we treat it as a directory as long as the + // target is a directory. bool is_dir = fs::is_directory(*st); if (fs::is_symlink_file(*st)) { fs::file_status target_st; @@ -213,9 +214,9 @@ if (only_directories && !is_dir) continue; - // Shrink it back down so that it just has the original prefix the user - // typed and remove the part of the name which is common to the located - // item and what the user typed. + // Shrink it back down so that it just has the original prefix the + // user typed and remove the part of the name which is common to the + // located item and what the user typed. CompletionBuffer.resize(FullPrefixLen); Name = Name.drop_front(PartialItem.size()); CompletionBuffer.append(Name); Index: source/Commands/CommandObjectApropos.cpp =================================================================== --- source/Commands/CommandObjectApropos.cpp +++ source/Commands/CommandObjectApropos.cpp @@ -37,8 +37,8 @@ search_word_arg.arg_type = eArgTypeSearchWord; search_word_arg.arg_repetition = eArgRepeatPlain; - // There is only one variant this argument could be; put it into the argument - // entry. + // There is only one variant this argument could be; put it into the + // argument entry. arg.push_back(search_word_arg); // Push the data for the first argument into the m_arguments vector. @@ -53,8 +53,8 @@ if (argc == 1) { auto search_word = args[0].ref; if (!search_word.empty()) { - // The bulk of the work must be done inside the Command Interpreter, since - // the command dictionary is private. + // The bulk of the work must be done inside the Command Interpreter, + // since the command dictionary is private. StringList commands_found; StringList commands_help; Index: source/Commands/CommandObjectBreakpoint.cpp =================================================================== --- source/Commands/CommandObjectBreakpoint.cpp +++ source/Commands/CommandObjectBreakpoint.cpp @@ -85,8 +85,8 @@ switch (short_option) { case 'c': - // Normally an empty breakpoint condition marks is as unset. - // But we need to say it was passed in. + // Normally an empty breakpoint condition marks is as unset. But we + // need to say it was passed in. m_bp_opts.SetCondition(option_arg.str().c_str()); m_bp_opts.m_set_flags.Set(BreakpointOptions::eCondition); break; @@ -243,8 +243,9 @@ }; -// If an additional option set beyond LLDB_OPTION_SET_10 is added, make sure to -// update the numbers passed to LLDB_OPT_SET_FROM_TO(...) appropriately. +// If an additional option set beyond LLDB_OPTION_SET_10 is added, make +// sure to update the numbers passed to LLDB_OPT_SET_FROM_TO(...) +// appropriately. #define LLDB_OPT_FILE (LLDB_OPT_SET_FROM_TO(1, 9) & ~LLDB_OPT_SET_2) #define LLDB_OPT_NOT_10 (LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10) #define LLDB_OPT_SKIP_PROLOGUE (LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3, 8)) @@ -263,8 +264,9 @@ "#included, set target.inline-breakpoint-strategy to \"always\"." }, { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLineNum, "Specifies the line number on which to set this breakpoint." }, - // Comment out this option for the moment, as we don't actually use it, but will in the future. - // This way users won't see it, but the infrastructure is left in place. + // Comment out this option for the moment, as we don't actually use it, + // but will in the future. This way users won't see it, but the + // infrastructure is left in place. // { 0, false, "column", 'C', OptionParser::eRequiredArgument, nullptr, "", // "Set the breakpoint by source location at this particular column."}, @@ -344,7 +346,8 @@ "Sets a breakpoint or set of breakpoints in the executable.", "breakpoint set "), m_bp_opts(), m_options() { - // We're picking up all the normal options, commands and disable. + // We're picking up all the normal options, commands and + // disable. m_all_options.Append(&m_bp_opts, LLDB_OPT_SET_1 | LLDB_OPT_SET_3 | LLDB_OPT_SET_4, LLDB_OPT_SET_ALL); @@ -635,7 +638,8 @@ return false; } - // The following are the various types of breakpoints that could be set: + // The following are the various types of breakpoints that could be + // set: // 1). -f -l -p [-s -g] (setting breakpoint by source location) // 2). -a [-s -g] (setting breakpoint by address) // 3). -n [-s -g] (setting breakpoint by function name) @@ -665,8 +669,8 @@ FileSpec module_spec; const bool internal = false; - // If the user didn't specify skip-prologue, having an offset should turn - // that off. + // If the user didn't specify skip-prologue, having an offset should + // turn that off. if (m_options.m_offset_addr != 0 && m_options.m_skip_prologue == eLazyBoolCalculate) m_options.m_skip_prologue = eLazyBoolNo; @@ -706,8 +710,9 @@ case eSetTypeAddress: // Breakpoint by address { - // If a shared library has been specified, make an lldb_private::Address - // with the library, and use that. That way the address breakpoint + // If a shared library has been specified, make an + // lldb_private::Address with the library, and use that. That way + // the address breakpoint // will track the load location of the library. size_t num_modules_specified = m_options.m_modules.GetSize(); if (num_modules_specified == 1) { @@ -854,9 +859,9 @@ output_stream.Printf("Breakpoint set in dummy target, will get copied " "into future targets.\n"); else { - // Don't print out this warning for exception breakpoints. They can get - // set before the target is set, but we won't know how to actually set - // the breakpoint till we run. + // Don't print out this warning for exception breakpoints. They + // can get set before the target is set, but we won't know how to + // actually set the breakpoint till we run. if (bp_sp->GetNumLocations() == 0 && break_type != eSetTypeException) { output_stream.Printf("WARNING: Unable to resolve breakpoint to any " "actual locations.\n"); @@ -875,8 +880,8 @@ bool GetDefaultFile(Target *target, FileSpec &file, CommandReturnObject &result) { uint32_t default_line; - // First use the Source Manager's default file. - // Then use the current stack frame's file. + // First use the Source Manager's default file. Then use the current + // stack frame's file. if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line)) { StackFrame *cur_frame = m_exe_ctx.GetFramePtr(); if (cur_frame == nullptr) { @@ -931,8 +936,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); m_options.Append(&m_bp_opts, @@ -1010,8 +1015,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -1125,8 +1130,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -1210,8 +1215,8 @@ // clang-format off { LLDB_OPT_SET_ALL, false, "internal", 'i', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Show debugger internal breakpoints" }, { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Give a brief description of the breakpoint (no location info)." }, - // FIXME: We need to add an "internal" command, and then add this sort of thing to it. - // But I need to see it for now, and don't want to wait. + // FIXME: We need to add an "internal" command, and then add this sort + // of thing to it. But I need to see it for now, and don't want to wait. { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Give a full description of the breakpoint and its locations." }, { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Explain everything we know about the breakpoint (for debugging debugger bugs)." }, { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "List Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets." }, @@ -1329,7 +1334,8 @@ Stream &output_stream = result.GetOutputStream(); if (command.empty()) { - // No breakpoint selected; show info about all currently set breakpoints. + // No breakpoint selected; show info about all currently set + // breakpoints. result.AppendMessage("Current breakpoints:"); for (size_t i = 0; i < num_breakpoints; ++i) { Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex(i).get(); @@ -1452,7 +1458,8 @@ return false; } - // The following are the various types of breakpoints that could be cleared: + // The following are the various types of breakpoints that could be + // cleared: // 1). -f -l (clearing breakpoint by source location) BreakpointClearType break_type = eClearTypeInvalid; @@ -1492,8 +1499,8 @@ Breakpoint *bp = breakpoints.FindBreakpointByID(BreakIDs[i]).get(); if (bp->GetMatchingFileLine(filename, m_options.m_line_num, loc_coll)) { - // If the collection size is 0, it's a full match and we can just - // remove the breakpoint. + // If the collection size is 0, it's a full match and we can + // just remove the breakpoint. if (loc_coll.GetSize() == 0) { bp->GetDescription(&ss, lldb::eDescriptionLevelBrief); ss.EOL(); @@ -1549,8 +1556,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -1657,8 +1664,8 @@ target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get(); BreakpointLocation *location = breakpoint->FindLocationByID(cur_bp_id.GetLocationID()).get(); - // It makes no sense to try to delete individual locations, so we - // disable them instead. + // It makes no sense to try to delete individual locations, + // so we disable them instead. if (location) { location->SetEnabled(false); ++disable_count; @@ -1898,8 +1905,8 @@ return false; } } - // Now configure them, we already pre-checked the names so we don't need - // to check the error: + // Now configure them, we already pre-checked the names so we don't + // need to check the error: BreakpointSP bp_sp; if (m_bp_id.m_breakpoint.OptionWasSet()) { @@ -2009,7 +2016,8 @@ size_t num_valid_ids = valid_bp_ids.GetSize(); const char *bp_name = m_name_options.m_name.GetCurrentValue(); Status error; // This error reports illegal names, but we've already - // checked that, so we don't need to check it again here. + // checked that, so we don't need to check it again + // here. for (size_t index = 0; index < num_valid_ids; index++) { lldb::break_id_t bp_id = valid_bp_ids.GetBreakpointIDAtIndex(index).GetBreakpointID(); @@ -2247,8 +2255,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -2334,7 +2342,8 @@ if (num_breakpoints == 0) { result.AppendMessage("No breakpoints added."); } else { - // No breakpoint selected; show info about all currently set breakpoints. + // No breakpoint selected; show info about all currently set + // breakpoints. result.AppendMessage("New breakpoints:"); for (size_t i = 0; i < num_breakpoints; ++i) { BreakpointID bp_id = new_bps.GetBreakpointIDAtIndex(i); @@ -2377,8 +2386,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -2541,8 +2550,8 @@ // had *better* be an entry both before & // after of one of the first two types. // 4). A breakpoint name - // If args is empty, we will use the last created breakpoint (if there is - // one.) + // If args is empty, we will use the last created breakpoint (if there + // is one.) Args temp_args; @@ -2559,31 +2568,28 @@ return; } - // Create a new Args variable to use; copy any non-breakpoint-id-ranges stuff - // directly from the old ARGS to - // the new TEMP_ARGS. Do not copy breakpoint id range strings over; instead - // generate a list of strings for - // all the breakpoint ids in the range, and shove all of those breakpoint id - // strings into TEMP_ARGS. + // Create a new Args variable to use; copy any non-breakpoint-id-ranges + // stuff directly from the old ARGS to the new TEMP_ARGS. Do not copy + // breakpoint id range strings over; instead generate a list of strings + // for all the breakpoint ids in the range, and shove all of those + // breakpoint id strings into TEMP_ARGS. BreakpointIDList::FindAndReplaceIDRanges(args, target, allow_locations, purpose, result, temp_args); - // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual - // BreakpointIDList: + // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an + // actual BreakpointIDList: valid_ids->InsertStringArray(temp_args.GetConstArgumentVector(), temp_args.GetArgumentCount(), result); - // At this point, all of the breakpoint ids that the user passed in have been - // converted to breakpoint IDs - // and put into valid_ids. + // At this point, all of the breakpoint ids that the user passed in + // have been converted to breakpoint IDs and put into valid_ids. if (result.Succeeded()) { - // Now that we've converted everything from args into a list of breakpoint - // ids, go through our tentative list - // of breakpoint id's and verify that they correspond to valid/currently set - // breakpoints. + // Now that we've converted everything from args into a list of + // breakpoint ids, go through our tentative list of breakpoint id's + // and verify that they correspond to valid/currently set breakpoints. const size_t count = valid_ids->GetSize(); for (size_t i = 0; i < count; ++i) { Index: source/Commands/CommandObjectBreakpointCommand.cpp =================================================================== --- source/Commands/CommandObjectBreakpointCommand.cpp +++ source/Commands/CommandObjectBreakpointCommand.cpp @@ -35,10 +35,10 @@ // CommandObjectBreakpointCommandAdd //------------------------------------------------------------------------- -// FIXME: "script-type" needs to have its contents determined dynamically, so -// somebody can add a new scripting -// language to lldb and have it pickable here without having to change this -// enumeration by hand and rebuild lldb proper. +// FIXME: "script-type" needs to have its contents determined dynamically, +// so somebody can add a new scripting language to lldb and have it +// pickable here without having to change this enumeration by hand and +// rebuild lldb proper. static OptionEnumValueElement g_script_option_enumeration[4] = { {eScriptLanguageNone, "command", @@ -412,8 +412,8 @@ } else { BreakpointLocationSP bp_loc_sp( bp->FindLocationByID(cur_bp_id.GetLocationID())); - // This breakpoint does have an associated location. - // Get its breakpoint options. + // This breakpoint does have an associated location. Get its + // breakpoint options. if (bp_loc_sp) bp_options = bp_loc_sp->GetLocationOptions(); } @@ -422,9 +422,9 @@ } } - // If we are using script language, get the script interpreter - // in order to set or collect command callback. Otherwise, call - // the methods associated with this object. + // If we are using script language, get the script interpreter in + // order to set or collect command callback. Otherwise, call the + // methods associated with this object. if (m_options.m_use_script_language) { ScriptInterpreter *script_interp = m_interpreter.GetScriptInterpreter(); // Special handling for one-liner specified inline. @@ -456,16 +456,15 @@ std::vector m_bp_options_vec; // This stores the // breakpoint options that // we are currently - // collecting commands for. In the CollectData... calls we need - // to hand this off to the IOHandler, which may run asynchronously. - // So we have to have some way to keep it alive, and not leak it. - // Making it an ivar of the command object, which never goes away - // achieves this. Note that if we were able to run - // the same command concurrently in one interpreter we'd have to - // make this "per invocation". But there are many more reasons - // why it is not in general safe to do that in lldb at present, - // so it isn't worthwhile to come up with a more complex mechanism - // to address this particular weakness right now. + // collecting commands for. In the CollectData... calls we need to hand + // this off to the IOHandler, which may run asynchronously. So we have + // to have some way to keep it alive, and not leak it. Making it an ivar + // of the command object, which never goes away achieves this. Note + // that if we were able to run the same command concurrently in one + // interpreter we'd have to make this "per invocation". But there are + // many more reasons why it is not in general safe to do that in lldb at + // present, so it isn't worthwhile to come up with a more complex + // mechanism to address this particular weakness right now. static const char *g_reader_instructions; }; Index: source/Commands/CommandObjectCommands.cpp =================================================================== --- source/Commands/CommandObjectCommands.cpp +++ source/Commands/CommandObjectCommands.cpp @@ -332,8 +332,7 @@ m_interpreter.HandleCommandsFromFile(cmd_file, exe_ctx, options, result); } else { // No options were set, inherit any settings from nested "command - // source" commands, - // or set to sane default settings... + // source" commands, or set to sane default settings... CommandInterpreterRunOptions options; m_interpreter.HandleCommandsFromFile(cmd_file, exe_ctx, options, result); } @@ -613,9 +612,9 @@ return false; } - // Strip the new alias name off 'raw_command_string' (leave it on args, - // which gets passed to 'Execute', which - // does the stripping itself. + // Strip the new alias name off 'raw_command_string' (leave it on + // args, which gets passed to 'Execute', which does the stripping + // itself. size_t pos = raw_command_string.find(alias_command); if (pos == 0) { raw_command_string = raw_command_string.substr(alias_command.size()); @@ -637,9 +636,10 @@ return false; } - // Get CommandObject that is being aliased. The command name is read from - // the front of raw_command_string. raw_command_string is returned with the - // name of the command object stripped off the front. + // Get CommandObject that is being aliased. The command name is read + // from the front of raw_command_string. raw_command_string is + // returned with the name of the command object stripped off the + // front. llvm::StringRef original_raw_command_string = raw_command_string; CommandObject *cmd_obj = m_interpreter.GetCommandObjectForCommand(raw_command_string); @@ -652,10 +652,10 @@ result.SetStatus(eReturnStatusFailed); return false; } else if (!cmd_obj->WantsRawCommandString()) { - // Note that args was initialized with the original command, and has not - // been updated to this point. - // Therefore can we pass it to the version of Execute that does not - // need/expect raw input in the alias. + // Note that args was initialized with the original command, and has + // not been updated to this point. Therefore can we pass it to the + // version of Execute that does not need/expect raw input in the + // alias. return HandleAliasingNormalCommand(args, result); } else { return HandleAliasingRawCommand(alias_command, raw_command_string, @@ -717,8 +717,8 @@ args.Shift(); // Shift the alias command word off the argument vector. args.Shift(); // Shift the old command word off the argument vector. - // Verify that the command is alias'able, and get the appropriate command - // object. + // Verify that the command is alias'able, and get the appropriate + // command object. if (m_interpreter.CommandExists(alias_command)) { result.AppendErrorWithFormat( @@ -1129,8 +1129,8 @@ return error; } const size_t first_separator_char_pos = 1; - // use the char that follows 's' as the regex separator character - // so we can have "s///" or "s|||" + // use the char that follows 's' as the regex separator character so + // we can have "s///" or "s|||" const char separator_char = regex_sed[first_separator_char_pos]; const size_t second_separator_char_pos = regex_sed.find(separator_char, first_separator_char_pos + 1); @@ -1159,8 +1159,8 @@ } if (third_separator_char_pos != regex_sed_size - 1) { - // Make sure that everything that follows the last regex - // separator char + // Make sure that everything that follows the last regex separator + // char if (regex_sed.find_first_not_of("\t\n\v\f\r ", third_separator_char_pos + 1) != std::string::npos) { @@ -1538,13 +1538,15 @@ Status error; const bool init_session = true; - // FIXME: this is necessary because CommandObject::CheckRequirements() - // assumes that commands won't ever be recursively invoked, but it's - // actually possible to craft a Python script that does other "command - // script imports" in __lldb_init_module the real fix is to have recursive - // commands possible with a CommandInvocation object separate from the - // CommandObject itself, so that recursive command invocations won't stomp - // on each other (wrt to execution contents, options, and more) + // FIXME: this is necessary because + // CommandObject::CheckRequirements() assumes that commands won't + // ever be recursively invoked, but it's actually possible to craft + // a Python script that does other "command script imports" in + // __lldb_init_module the real fix is to have recursive commands + // possible with a CommandInvocation object separate from the + // CommandObject itself, so that recursive command invocations won't + // stomp on each other (wrt to execution contents, options, and + // more) m_exe_ctx.Clear(); if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule( entry.c_str(), m_options.m_allow_reload, init_session, error)) { Index: source/Commands/CommandObjectDisassemble.cpp =================================================================== --- source/Commands/CommandObjectDisassemble.cpp +++ source/Commands/CommandObjectDisassemble.cpp @@ -205,10 +205,9 @@ execution_context ? execution_context->GetTargetPtr() : nullptr; // This is a hack till we get the ability to specify features based on - // architecture. For now GetDisassemblyFlavor - // is really only valid for x86 (and for the llvm assembler plugin, but I'm - // papering over that since that is the - // only disassembler plugin we have... + // architecture. For now GetDisassemblyFlavor is really only valid for + // x86 (and for the llvm assembler plugin, but I'm papering over that + // since that is the only disassembler plugin we have... if (target) { if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86 || target->GetArchitecture().GetTriple().getArch() == @@ -314,8 +313,8 @@ // Always show the PC in the disassembly uint32_t options = Disassembler::eOptionMarkPCAddress; - // Mark the source line for the current PC only if we are doing mixed source - // and assembly + // Mark the source line for the current PC only if we are doing mixed + // source and assembly if (m_options.show_mixed) options |= Disassembler::eOptionMarkPCSourceLine; @@ -470,7 +469,8 @@ if (m_options.num_instructions != 0) { if (ranges.empty()) { - // The default action is to disassemble the current frame function. + // The default action is to disassemble the current frame + // function. if (frame) { SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); @@ -516,7 +516,8 @@ result.AppendMessage("\n"); } else { if (ranges.empty()) { - // The default action is to disassemble the current frame function. + // The default action is to disassemble the current frame + // function. if (frame) { SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); Index: source/Commands/CommandObjectExpression.cpp =================================================================== --- source/Commands/CommandObjectExpression.cpp +++ source/Commands/CommandObjectExpression.cpp @@ -284,8 +284,8 @@ expression_arg.arg_type = eArgTypeExpression; expression_arg.arg_repetition = eArgRepeatPlain; - // There is only one variant this argument could be; put it into the argument - // entry. + // There is only one variant this argument could be; put it into the + // argument entry. arg.push_back(expression_arg); // Push the data for the first argument into the m_arguments vector. @@ -322,9 +322,9 @@ Stream *output_stream, Stream *error_stream, CommandReturnObject *result) { - // Don't use m_exe_ctx as this might be called asynchronously - // after the command object DoExecute has finished when doing - // multi-line expression that use an input reader... + // Don't use m_exe_ctx as this might be called asynchronously after the + // command object DoExecute has finished when doing multi-line + // expression that use an input reader... ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); Target *target = exe_ctx.GetTargetPtr(); @@ -363,8 +363,8 @@ if (m_command_options.top_level) options.SetExecutionPolicy(eExecutionPolicyTopLevel); - // If there is any chance we are going to stop and want to see - // what went wrong with our expression, we should generate debug info + // If there is any chance we are going to stop and want to see what + // went wrong with our expression, we should generate debug info if (!m_command_options.ignore_breakpoints || !m_command_options.unwind_on_error) options.SetGenerateDebugInfo(true); @@ -377,8 +377,8 @@ ExpressionResults success = target->EvaluateExpression( expr, frame, result_valobj_sp, options, &m_fixed_expression); - // We only tell you about the FixIt if we applied it. The compiler errors - // will suggest the FixIt if it parsed. + // We only tell you about the FixIt if we applied it. The compiler + // errors will suggest the FixIt if it parsed. if (error_stream && !m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts()) { if (success == eExpressionCompleted) @@ -475,9 +475,9 @@ // An empty lines is used to indicate the end of input const size_t num_lines = lines.GetSize(); if (num_lines > 0 && lines[num_lines - 1].empty()) { - // Remove the last empty line from "lines" so it doesn't appear - // in our resulting input and return true to indicate we are done - // getting lines + // Remove the last empty line from "lines" so it doesn't appear in our + // resulting input and return true to indicate we are done getting + // lines lines.PopBack(); return true; } @@ -561,20 +561,17 @@ Debugger &debugger = target->GetDebugger(); - // Check if the LLDB command interpreter is sitting on top of a REPL - // that - // launched it... + // Check if the LLDB command interpreter is sitting on top of a + // REPL that launched it... if (debugger.CheckTopIOHandlerTypes( IOHandler::Type::CommandInterpreter, IOHandler::Type::REPL)) { - // the LLDB command interpreter is sitting on top of a REPL that - // launched it, - // so just say the command interpreter is done and fall back to the - // existing REPL + // the LLDB command interpreter is sitting on top of a REPL + // that launched it, so just say the command interpreter is + // done and fall back to the existing REPL m_interpreter.GetIOHandler(false)->SetIsDone(true); } else { - // We are launching the REPL on top of the current LLDB command - // interpreter, - // so just push one + // We are launching the REPL on top of the current LLDB + // command interpreter, so just push one bool initialize = false; Status repl_error; REPLSP repl_sp(target->GetREPL( @@ -629,27 +626,25 @@ if (!m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts()) { CommandHistory &history = m_interpreter.GetCommandHistory(); - // FIXME: Can we figure out what the user actually typed (e.g. some alias - // for expr???) - // If we can it would be nice to show that. + // FIXME: Can we figure out what the user actually typed (e.g. some + // alias for expr???) If we can it would be nice to show that. std::string fixed_command("expression "); if (expr == command) fixed_command.append(m_fixed_expression); else { - // Add in any options that might have been in the original command: + // Add in any options that might have been in the original + // command: fixed_command.append(command, expr - command); fixed_command.append(m_fixed_expression); } history.AppendString(fixed_command); } - // Increment statistics to record this expression evaluation - // success. + // Increment statistics to record this expression evaluation success. target->IncrementStats(StatisticKind::ExpressionSuccessful); return true; } - // Increment statistics to record this expression evaluation - // failure. + // Increment statistics to record this expression evaluation failure. target->IncrementStats(StatisticKind::ExpressionFailure); result.SetStatus(eReturnStatusFailed); return false; Index: source/Commands/CommandObjectFrame.cpp =================================================================== --- source/Commands/CommandObjectFrame.cpp +++ source/Commands/CommandObjectFrame.cpp @@ -326,8 +326,8 @@ protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - // No need to check "thread" for validity as eCommandRequiresThread ensures - // it is valid + // No need to check "thread" for validity as eCommandRequiresThread + // ensures it is valid Thread *thread = m_exe_ctx.GetThreadPtr(); uint32_t frame_idx = UINT32_MAX; @@ -342,8 +342,8 @@ frame_idx += m_options.relative_frame_offset; else { if (frame_idx == 0) { - // If you are already at the bottom of the stack, then just warn and - // don't reset the frame. + // If you are already at the bottom of the stack, then just + // warn and don't reset the frame. result.AppendError("Already at the bottom of the stack."); result.SetStatus(eReturnStatusFailed); return false; @@ -351,18 +351,17 @@ frame_idx = 0; } } else if (m_options.relative_frame_offset > 0) { - // I don't want "up 20" where "20" takes you past the top of the stack - // to produce - // an error, but rather to just go to the top. So I have to count the - // stack here... + // I don't want "up 20" where "20" takes you past the top of the + // stack to produce an error, but rather to just go to the top. + // So I have to count the stack here... const uint32_t num_frames = thread->GetStackFrameCount(); if (static_cast(num_frames - frame_idx) > m_options.relative_frame_offset) frame_idx += m_options.relative_frame_offset; else { if (frame_idx == num_frames - 1) { - // If we are already at the top of the stack, just warn and don't - // reset the frame. + // If we are already at the top of the stack, just warn and + // don't reset the frame. result.AppendError("Already at the top of the stack."); result.SetStatus(eReturnStatusFailed); return false; @@ -504,16 +503,15 @@ } bool DoExecute(Args &command, CommandReturnObject &result) override { - // No need to check "frame" for validity as eCommandRequiresFrame ensures it - // is valid + // No need to check "frame" for validity as eCommandRequiresFrame + // ensures it is valid StackFrame *frame = m_exe_ctx.GetFramePtr(); Stream &s = result.GetOutputStream(); - // Be careful about the stack frame, if any summary formatter runs code, it - // might clear the StackFrameList - // for the thread. So hold onto a shared pointer to the frame so it stays - // alive. + // Be careful about the stack frame, if any summary formatter runs + // code, it might clear the StackFrameList for the thread. So hold + // onto a shared pointer to the frame so it stays alive. VariableList *variable_list = frame->GetVariableList(m_option_variable.show_globals); @@ -677,9 +675,8 @@ if (m_option_variable.show_scope) scope_string = GetScopeString(var_sp).str(); - // Use the variable object code to make sure we are - // using the same APIs as the public API will be - // using... + // Use the variable object code to make sure we are using the + // same APIs as the public API will be using... valobj_sp = frame->GetValueObjectForFrameVariable( var_sp, m_varobj_options.use_dynamic); if (valobj_sp) { Index: source/Commands/CommandObjectHelp.cpp =================================================================== --- source/Commands/CommandObjectHelp.cpp +++ source/Commands/CommandObjectHelp.cpp @@ -61,8 +61,8 @@ command_arg.arg_type = eArgTypeCommandName; command_arg.arg_repetition = eArgRepeatStar; - // There is only one variant this argument could be; put it into the argument - // entry. + // There is only one variant this argument could be; put it into the + // argument entry. arg.push_back(command_arg); // Push the data for the first argument into the m_arguments vector. @@ -89,10 +89,10 @@ CommandObject *cmd_obj; const size_t argc = command.GetArgumentCount(); - // 'help' doesn't take any arguments, other than command names. If argc is 0, - // we show the user - // all commands (aliases and user commands if asked for). Otherwise every - // argument must be the name of a command or a sub-command. + // 'help' doesn't take any arguments, other than command names. If argc + // is 0, we show the user all commands (aliases and user commands if + // asked for). Otherwise every argument must be the name of a command + // or a sub-command. if (argc == 0) { uint32_t cmd_types = CommandInterpreter::eCommandTypesBuiltin; if (m_options.m_show_aliases) @@ -105,8 +105,8 @@ result.SetStatus(eReturnStatusSuccessFinishNoResult); m_interpreter.GetHelp(result, cmd_types); // General help } else { - // Get command object for the first command argument. Only search built-in - // command dictionary. + // Get command object for the first command argument. Only search + // built-in command dictionary. StringList matches; auto command_name = command[0].ref; cmd_obj = m_interpreter.GetCommandObject(command_name, &matches); @@ -115,8 +115,8 @@ StringList matches; bool all_okay = true; CommandObject *sub_cmd_obj = cmd_obj; - // Loop down through sub_command dictionaries until we find the command - // object that corresponds to the help command entered. + // Loop down through sub_command dictionaries until we find the + // command object that corresponds to the help command entered. std::string sub_command; for (auto &entry : command.entries().drop_front()) { sub_command = entry.ref; @@ -188,8 +188,8 @@ output_strm.Printf("\t%s\n", matches.GetStringAtIndex(i)); } } else { - // Maybe the user is asking for help about a command argument rather than - // a command. + // Maybe the user is asking for help about a command argument rather + // than a command. const CommandArgumentType arg_type = CommandObject::LookupArgumentName(command_name); if (arg_type != eArgTypeLastArg) { @@ -224,9 +224,9 @@ } else { CommandObject *cmd_obj = m_interpreter.GetCommandObject(input[0].ref); - // The command that they are getting help on might be ambiguous, in which - // case we should complete that, - // otherwise complete with the command the user is getting help on... + // The command that they are getting help on might be ambiguous, in + // which case we should complete that, otherwise complete with the + // command the user is getting help on... if (cmd_obj) { input.Shift(); Index: source/Commands/CommandObjectLog.cpp =================================================================== --- source/Commands/CommandObjectLog.cpp +++ source/Commands/CommandObjectLog.cpp @@ -163,7 +163,8 @@ return false; } - // Store into a std::string since we're about to shift the channel off. + // Store into a std::string since we're about to shift the channel + // off. const std::string channel = args[0].ref; args.Shift(); // Shift off the channel char log_file[PATH_MAX]; Index: source/Commands/CommandObjectMemory.cpp =================================================================== --- source/Commands/CommandObjectMemory.cpp +++ source/Commands/CommandObjectMemory.cpp @@ -362,8 +362,8 @@ protected: bool DoExecute(Args &command, CommandReturnObject &result) override { - // No need to check "target" for validity as eCommandRequiresTarget ensures - // it is valid + // No need to check "target" for validity as eCommandRequiresTarget + // ensures it is valid Target *target = m_exe_ctx.GetTargetPtr(); const size_t argc = command.GetArgumentCount(); @@ -574,8 +574,8 @@ // TODO For non-8-bit byte addressable architectures this needs to be // revisited to fully support all lldb's range of formatting options. - // Furthermore code memory reads (for those architectures) will not - // be correctly formatted even w/o formatting options. + // Furthermore code memory reads (for those architectures) will not be + // correctly formatted even w/o formatting options. size_t item_byte_size = target->GetArchitecture().GetDataByteSize() > 1 ? target->GetArchitecture().GetDataByteSize() @@ -646,8 +646,8 @@ DataBufferSP data_sp; size_t bytes_read = 0; if (clang_ast_type.GetOpaqueQualType()) { - // Make sure we don't display our type as ASCII bytes like the default - // memory read + // Make sure we don't display our type as ASCII bytes like the + // default memory read if (!m_format_options.GetFormatValue().OptionWasSet()) m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault); @@ -690,8 +690,8 @@ ") were able to be read from 0x%" PRIx64 ".\n", (uint64_t)bytes_read, (uint64_t)total_byte_size, addr); } else { - // we treat c-strings as a special case because they do not have a fixed - // size + // we treat c-strings as a special case because they do not have a + // fixed size if (m_format_options.GetByteSizeValue().OptionWasSet() && !m_format_options.HasGDBFormat()) item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue(); @@ -844,16 +844,15 @@ if (!m_format_options.GetCountValue().OptionWasSet() || item_count == 1) { // this turns requests such as // memory read -fc -s10 -c1 *charPtrPtr - // which make no sense (what is a char of size 10?) - // into a request for fetching 10 chars of size 1 from the same memory - // location + // which make no sense (what is a char of size 10?) into a request + // for fetching 10 chars of size 1 from the same memory location format = eFormatCharArray; item_count = item_byte_size; item_byte_size = 1; } else { - // here we passed a count, and it was not 1 - // so we have a byte_size and a count - // we could well multiply those, but instead let's just fail + // here we passed a count, and it was not 1 so we have a byte_size + // and a count we could well multiply those, but instead let's + // just fail result.AppendErrorWithFormat( "reading memory as characters of size %" PRIu64 " is not supported", (uint64_t)item_byte_size); @@ -1446,8 +1445,8 @@ case eFormatPointer: { // Decode hex bytes - // Be careful, getAsInteger with a radix of 16 rejects "0xab" so we - // have to special case that: + // Be careful, getAsInteger with a radix of 16 rejects "0xab" so + // we have to special case that: bool success = false; if (entry.ref.startswith("0x")) success = !entry.ref.getAsInteger(0, uval64); @@ -1761,8 +1760,8 @@ const char *GetRepeatCommand(Args ¤t_command_args, uint32_t index) override { - // If we repeat this command, repeat it without any arguments so we can - // show the next memory range + // If we repeat this command, repeat it without any arguments so we + // can show the next memory range return m_cmd_name.c_str(); } Index: source/Commands/CommandObjectMultiword.cpp =================================================================== --- source/Commands/CommandObjectMultiword.cpp +++ source/Commands/CommandObjectMultiword.cpp @@ -54,9 +54,8 @@ AddNamesMatchingPartialString(m_subcommand_dict, sub_cmd, *matches); if (num_matches == 1) { - // Cleaner, but slightly less efficient would be to call back into this - // function, since I now - // know I have an exact match... + // Cleaner, but slightly less efficient would be to call back into + // this function, since I now know I have an exact match... sub_cmd = matches->GetStringAtIndex(0); pos = m_subcommand_dict.find(sub_cmd); @@ -120,9 +119,9 @@ StringList matches; CommandObject *sub_cmd_obj = GetSubcommandObject(sub_command, &matches); if (sub_cmd_obj != nullptr) { - // Now call CommandObject::Execute to process options in `rest_of_line`. - // From there the command-specific version of Execute will be called, - // with the processed arguments. + // Now call CommandObject::Execute to process options in + // `rest_of_line`. From there the command-specific version of Execute + // will be called, with the processed arguments. args.Shift(); sub_cmd_obj->Execute(args_string, result); @@ -193,8 +192,8 @@ int max_return_elements, bool &word_complete, StringList &matches) { - // Any of the command matches will provide a complete word, otherwise the - // individual completers will override this. + // Any of the command matches will provide a complete word, otherwise + // the individual completers will override this. word_complete = true; auto arg0 = input[0].ref; @@ -225,7 +224,8 @@ if (sub_command_object == nullptr) { return matches.GetSize(); } else { - // Remove the one match that we got from calling GetSubcommandObject. + // Remove the one match that we got from calling + // GetSubcommandObject. matches.DeleteStringAtIndex(0); input.Shift(); cursor_index--; Index: source/Commands/CommandObjectPlatform.cpp =================================================================== --- source/Commands/CommandObjectPlatform.cpp +++ source/Commands/CommandObjectPlatform.cpp @@ -385,8 +385,8 @@ Status error; if (platform_sp->IsConnected()) { - // Cache the instance name if there is one since we are - // about to disconnect and the name might go with it. + // Cache the instance name if there is one since we are about to + // disconnect and the name might go with it. const char *hostname_cstr = platform_sp->GetHostname(); std::string hostname; if (hostname_cstr) @@ -867,8 +867,8 @@ // argument entry. arg2.push_back(file_arg_host); - // Push the data for the first and the second arguments into the m_arguments - // vector. + // Push the data for the first and the second arguments into the + // m_arguments vector. m_arguments.push_back(arg1); m_arguments.push_back(arg2); } @@ -1059,8 +1059,8 @@ if (argc > 0) { if (m_options.launch_info.GetExecutableFile()) { - // We already have an executable file, so we will use this - // and all arguments to this function are extra arguments + // We already have an executable file, so we will use this and + // all arguments to this function are extra arguments m_options.launch_info.GetArguments().AppendArguments(args); } else { // We don't have any file yet, so the first argument is our @@ -1509,8 +1509,8 @@ class CommandOptions : public Options { public: CommandOptions() : Options() { - // Keep default values of all options in one place: OptionParsingStarting - // () + // Keep default values of all options in one place: + // OptionParsingStarting () OptionParsingStarting(nullptr); } @@ -1573,9 +1573,8 @@ if (GetDefinitions()[opt_defs_index].short_option == 'n') { // Are we in the name? - // Look to see if there is a -P argument provided, and if so use that - // plugin, otherwise - // use the default plugin. + // Look to see if there is a -P argument provided, and if so use + // that plugin, otherwise use the default plugin. const char *partial_name = nullptr; partial_name = input.GetArgumentAtIndex(opt_arg_pos); Index: source/Commands/CommandObjectProcess.cpp =================================================================== --- source/Commands/CommandObjectProcess.cpp +++ source/Commands/CommandObjectProcess.cpp @@ -179,19 +179,19 @@ llvm::StringRef target_settings_argv0 = target->GetArg0(); - // Determine whether we will disable ASLR or leave it in the default state - // (i.e. enabled if the platform supports it). - // First check if the process launch options explicitly turn on/off - // disabling ASLR. If so, use that setting; - // otherwise, use the 'settings target.disable-aslr' setting. + // Determine whether we will disable ASLR or leave it in the default + // state (i.e. enabled if the platform supports it). First check if + // the process launch options explicitly turn on/off disabling ASLR. + // If so, use that setting; otherwise, use the 'settings target + // .disable-aslr' setting. bool disable_aslr = false; if (m_options.disable_aslr != eLazyBoolCalculate) { - // The user specified an explicit setting on the process launch line. Use - // it. + // The user specified an explicit setting on the process launch + // line. Use it. disable_aslr = (m_options.disable_aslr == eLazyBoolYes); } else { - // The user did not explicitly specify whether to disable ASLR. Fall back - // to the target.disable-aslr setting. + // The user did not explicitly specify whether to disable ASLR. + // Fall back to the target.disable-aslr setting. disable_aslr = target->GetDisableASLR(); } @@ -233,10 +233,9 @@ if (error.Success()) { ProcessSP process_sp(target->GetProcessSP()); if (process_sp) { - // There is a race condition where this thread will return up the call - // stack to the main command - // handler and show an (lldb) prompt before HandlePrivateEvent (from - // PrivateStateThread) has + // There is a race condition where this thread will return up the + // call stack to the main command handler and show an (lldb) + // prompt before HandlePrivateEvent (from PrivateStateThread) has // a chance to call PushProcessIOHandler(). process_sp->SyncIOHandler(0, 2000); @@ -328,8 +327,8 @@ class CommandOptions : public Options { public: CommandOptions() : Options() { - // Keep default values of all options in one place: OptionParsingStarting - // () + // Keep default values of all options in one place: + // OptionParsingStarting () OptionParsingStarting(nullptr); } @@ -400,9 +399,8 @@ if (GetDefinitions()[opt_defs_index].short_option == 'n') { // Are we in the name? - // Look to see if there is a -P argument provided, and if so use that - // plugin, otherwise - // use the default plugin. + // Look to see if there is a -P argument provided, and if so use + // that plugin, otherwise use the default plugin. const char *partial_name = nullptr; partial_name = input.GetArgumentAtIndex(opt_arg_pos); @@ -452,11 +450,10 @@ m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - // N.B. The attach should be synchronous. It doesn't help much to get the - // prompt back between initiating the attach - // and the target actually stopping. So even if the interpreter is set to - // be asynchronous, we wait for the stop - // ourselves here. + // N.B. The attach should be synchronous. It doesn't help much to get + // the prompt back between initiating the attach and the target + // actually stopping. So even if the interpreter is set to be + // asynchronous, we wait for the stop ourselves here. StateType state = eStateInvalid; Process *process = m_exe_ctx.GetProcessPtr(); @@ -482,9 +479,8 @@ } // Record the old executable module, we want to issue a warning if the - // process of attaching changed the - // current executable (like somebody said "file foo" then attached to a PID - // whose executable was bar.) + // process of attaching changed the current executable (like somebody + // said "file foo" then attached to a PID whose executable was bar.) ModuleSP old_exec_module_sp = target->GetExecutableModule(); ArchSpec old_arch_spec = target->GetArchitecture(); @@ -519,8 +515,8 @@ if (!result.Succeeded()) return false; - // Okay, we're done. Last step is to warn if the executable module has - // changed: + // Okay, we're done. Last step is to warn if the executable module + // has changed: char new_path[PATH_MAX]; ModuleSP new_exec_module_sp(target->GetExecutableModule()); if (!old_exec_module_sp) { @@ -553,8 +549,8 @@ target->GetArchitecture().GetTriple().getTriple().c_str()); } - // This supports the use-case scenario of immediately continuing the process - // once attached. + // This supports the use-case scenario of immediately continuing the + // process once attached. if (m_options.attach_info.GetContinueOnceAttached()) m_interpreter.HandleCommand("process continue", eLazyBoolNo, result); @@ -593,8 +589,8 @@ class CommandOptions : public Options { public: CommandOptions() : Options() { - // Keep default values of all options in one place: OptionParsingStarting - // () + // Keep default values of all options in one place: + // OptionParsingStarting () OptionParsingStarting(nullptr); } @@ -691,18 +687,17 @@ error = process->Resume(); if (error.Success()) { - // There is a race condition where this thread will return up the call - // stack to the main command - // handler and show an (lldb) prompt before HandlePrivateEvent (from - // PrivateStateThread) has + // There is a race condition where this thread will return up the + // call stack to the main command handler and show an (lldb) + // prompt before HandlePrivateEvent (from PrivateStateThread) has // a chance to call PushProcessIOHandler(). process->SyncIOHandler(iohandler_id, 2000); result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n", process->GetID()); if (synchronous_execution) { - // If any state changed events had anything to say, add that to the - // result + // If any state changed events had anything to say, add that to + // the result result.AppendMessage(stream.GetString()); result.SetDidChangeProcessState(true); @@ -844,8 +839,8 @@ class CommandOptions : public Options { public: CommandOptions() : Options() { - // Keep default values of all options in one place: OptionParsingStarting - // () + // Keep default values of all options in one place: + // OptionParsingStarting () OptionParsingStarting(nullptr); } @@ -973,8 +968,8 @@ class CommandOptions : public Options { public: CommandOptions() : Options() { - // Keep default values of all options in one place: OptionParsingStarting - // () + // Keep default values of all options in one place: + // OptionParsingStarting () OptionParsingStarting(nullptr); } @@ -1560,8 +1555,8 @@ int32_t signo = signals_sp->GetSignalNumberFromName(arg.c_str()); if (signo != LLDB_INVALID_SIGNAL_NUMBER) { // Casting the actions as bools here should be okay, because - // VerifyCommandOptionValue guarantees - // the value is either 0 or 1. + // VerifyCommandOptionValue guarantees the value is either 0 or + // 1. if (stop_action != -1) signals_sp->SetShouldStop(signo, stop_action); if (pass_action != -1) { @@ -1577,8 +1572,8 @@ } } } else { - // No signal specified, if any command options were specified, update ALL - // signals. + // No signal specified, if any command options were specified, + // update ALL signals. if ((notify_action != -1) || (stop_action != -1) || (pass_action != -1)) { if (m_interpreter.Confirm( "Do you really want to update all the signals?", false)) { Index: source/Commands/CommandObjectQuit.cpp =================================================================== --- source/Commands/CommandObjectQuit.cpp +++ source/Commands/CommandObjectQuit.cpp @@ -30,10 +30,9 @@ CommandObjectQuit::~CommandObjectQuit() {} -// returns true if there is at least one alive process -// is_a_detach will be true if all alive processes will be detached when you -// quit -// and false if at least one process will be killed instead +// returns true if there is at least one alive process is_a_detach will be +// true if all alive processes will be detached when you quit and false if +// at least one process will be killed instead bool CommandObjectQuit::ShouldAskForConfirmation(bool &is_a_detach) { if (m_interpreter.GetPromptOnQuit() == false) return false; @@ -56,7 +55,8 @@ process_sp->WarnBeforeDetach()) { should_prompt = true; if (process_sp->GetShouldDetach() == false) { - // if we need to kill at least one process, just say so and return + // if we need to kill at least one process, just say so and + // return is_a_detach = false; return should_prompt; } Index: source/Commands/CommandObjectRegister.cpp =================================================================== --- source/Commands/CommandObjectRegister.cpp +++ source/Commands/CommandObjectRegister.cpp @@ -192,8 +192,8 @@ num_register_sets = reg_ctx->GetRegisterSetCount(); for (set_idx = 0; set_idx < num_register_sets; ++set_idx) { - // When dump_all_sets option is set, dump primitive as well as derived - // registers. + // When dump_all_sets option is set, dump primitive as well as + // derived registers. DumpRegisterSet(m_exe_ctx, strm, reg_ctx, set_idx, !m_command_options.dump_all_sets.GetCurrentValue()); } @@ -209,11 +209,11 @@ result.SetStatus(eReturnStatusFailed); } else { for (auto &entry : command) { - // in most LLDB commands we accept $rbx as the name for register RBX - - // and here we would reject it and non-existant. we should be more - // consistent towards the user and allow them to say reg read $rbx - - // internally, however, we should be strict and not allow ourselves - // to call our registers $rbx in our own API + // in most LLDB commands we accept $rbx as the name for register + // RBX - and here we would reject it and non-existant. we should + // be more consistent towards the user and allow them to say reg + // read $rbx - internally, however, we should be strict and not + // allow ourselves to call our registers $rbx in our own API auto arg_str = entry.ref; arg_str.consume_front("$"); @@ -264,17 +264,19 @@ } break; case 'a': - // When we don't use OptionValue::SetValueFromCString(const char *) to - // set an option value, it won't be marked as being set in the options - // so we make a call to let users know the value was set via option + // When we don't use OptionValue::SetValueFromCString(const char + // *) to set an option value, it won't be marked as being set in + // the options so we make a call to let users know the value was + // set via option dump_all_sets.SetCurrentValue(true); dump_all_sets.SetOptionWasSet(); break; case 'A': - // When we don't use OptionValue::SetValueFromCString(const char *) to - // set an option value, it won't be marked as being set in the options - // so we make a call to let users know the value was set via option + // When we don't use OptionValue::SetValueFromCString(const char + // *) to set an option value, it won't be marked as being set in + // the options so we make a call to let users know the value was + // set via option alternate_name.SetCurrentValue(true); dump_all_sets.SetOptionWasSet(); break; @@ -350,11 +352,11 @@ auto reg_name = command[0].ref; auto value_str = command[1].ref; - // in most LLDB commands we accept $rbx as the name for register RBX - and - // here we would reject it and non-existant. we should be more consistent - // towards the user and allow them to say reg write $rbx - internally, - // however, we should be strict and not allow ourselves to call our - // registers $rbx in our own API + // in most LLDB commands we accept $rbx as the name for register RBX + // - and here we would reject it and non-existant. we should be more + // consistent towards the user and allow them to say reg write $rbx + // - internally, however, we should be strict and not allow + // ourselves to call our registers $rbx in our own API reg_name.consume_front("$"); const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name); @@ -365,8 +367,8 @@ Status error(reg_value.SetValueFromString(reg_info, value_str)); if (error.Success()) { if (reg_ctx->WriteRegister(reg_info, reg_value)) { - // Toss all frames and anything else in the thread - // after a register has been written. + // Toss all frames and anything else in the thread after a + // register has been written. m_exe_ctx.GetThreadRef().Flush(); result.SetStatus(eReturnStatusSuccessFinishNoResult); return true; Index: source/Commands/CommandObjectSettings.cpp =================================================================== --- source/Commands/CommandObjectSettings.cpp +++ source/Commands/CommandObjectSettings.cpp @@ -219,12 +219,10 @@ if (error.Success()) { // FIXME this is the same issue as the one in commands script import - // we could be setting target.load-script-from-symbol-file which would - // cause - // Python scripts to be loaded, which could run LLDB commands - // (e.g. settings set target.process.python-os-plugin-path) and cause a - // crash - // if we did not clear the command's exe_ctx first + // we could be setting target.load-script-from-symbol-file which + // would cause Python scripts to be loaded, which could run LLDB + // commands (e.g. settings set target.process.python-os-plugin-path) + // and cause a crash if we did not clear the command's exe_ctx first ExecutionContext exe_ctx(m_exe_ctx); m_exe_ctx.Clear(); error = m_interpreter.GetDebugger().SetPropertyValue( @@ -372,8 +370,8 @@ if (argc > 0) { const bool dump_qualified_name = true; - // TODO: Convert to StringRef based enumeration. Requires converting - // GetPropertyAtPath first. + // TODO: Convert to StringRef based enumeration. Requires + // converting GetPropertyAtPath first. for (size_t i = 0; i < argc; ++i) { const char *property_path = args.GetArgumentAtIndex(i); Index: source/Commands/CommandObjectSource.cpp =================================================================== --- source/Commands/CommandObjectSource.cpp +++ source/Commands/CommandObjectSource.cpp @@ -148,16 +148,13 @@ Options *GetOptions() override { return &m_options; } protected: - // Dump the line entries in each symbol context. - // Return the number of entries found. - // If module_list is set, only dump lines contained in one of the modules. - // If file_spec is set, only dump lines in the file. + // Dump the line entries in each symbol context. Return the number of + // entries found. If module_list is set, only dump lines contained in + // one of the modules. If file_spec is set, only dump lines in the file. // If the start_line option was specified, don't print lines less than - // start_line. - // If the end_line option was specified, don't print lines greater than - // end_line. - // If the num_lines option was specified, dont print more than num_lines - // entries. + // start_line. If the end_line option was specified, don't print lines + // greater than end_line. If the num_lines option was specified, dont + // print more than num_lines entries. uint32_t DumpLinesInSymbolContexts(Stream &strm, const SymbolContextList &sc_list, const ModuleList &module_list, @@ -222,13 +219,11 @@ } // Dump the requested line entries for the file in the compilation unit. - // Return the number of entries found. - // If module_list is set, only dump lines contained in one of the modules. - // If the start_line option was specified, don't print lines less than - // start_line. - // If the end_line option was specified, don't print lines greater than - // end_line. - // If the num_lines option was specified, dont print more than num_lines + // Return the number of entries found. If module_list is set, only dump + // lines contained in one of the modules. If the start_line option was + // specified, don't print lines less than start_line. If the end_line + // option was specified, don't print lines greater than end_line. If the + // num_lines option was specified, dont print more than num_lines // entries. uint32_t DumpFileLinesInCompUnit(Stream &strm, Module *module, CompileUnit *cu, const FileSpec &file_spec) { @@ -249,8 +244,8 @@ const FileSpec &cu_file_spec = cu_file_list.GetFileSpecAtIndex(file_idx); - // Dump all matching lines at or above start_line for the file in the - // CU. + // Dump all matching lines at or above start_line for the file in + // the CU. const ConstString &file_spec_name = file_spec.GetFilename(); const ConstString &module_file_name = module->GetFileSpec().GetFilename(); @@ -259,8 +254,8 @@ while (true) { LineEntry line_entry; - // Find the lowest index of a line entry with a line equal to - // or higher than 'line'. + // Find the lowest index of a line entry with a line equal to or + // higher than 'line'. uint32_t start_idx = 0; start_idx = cu->FindLineEntry(start_idx, line, &cu_file_spec, /*exact=*/false, &line_entry); @@ -271,7 +266,8 @@ if (end_line > 0 && line_entry.line > end_line) break; - // Loop through to find any other entries for this line, dumping each. + // Loop through to find any other entries for this line, dumping + // each. line = line_entry.line; do { num_matches++; @@ -305,22 +301,19 @@ return num_matches; } - // Dump the requested line entries for the file in the module. - // Return the number of entries found. - // If module_list is set, only dump lines contained in one of the modules. - // If the start_line option was specified, don't print lines less than - // start_line. - // If the end_line option was specified, don't print lines greater than - // end_line. - // If the num_lines option was specified, dont print more than num_lines + // Dump the requested line entries for the file in the module. Return + // the number of entries found. If module_list is set, only dump lines + // contained in one of the modules. If the start_line option was + // specified, don't print lines less than start_line. If the end_line + // option was specified, don't print lines greater than end_line. If the + // num_lines option was specified, dont print more than num_lines // entries. uint32_t DumpFileLinesInModule(Stream &strm, Module *module, const FileSpec &file_spec) { uint32_t num_matches = 0; if (module) { - // Look through all the compilation units (CUs) in this module for ones - // that - // contain lines of code from this source file. + // Look through all the compilation units (CUs) in this module for + // ones that contain lines of code from this source file. for (size_t i = 0; i < module->GetNumCompileUnits(); i++) { // Look for a matching source file in this CU. CompUnitSP cu_sp(module->GetCompileUnitAtIndex(i)); @@ -333,11 +326,10 @@ return num_matches; } - // Given an address and a list of modules, append the symbol contexts of all - // line entries - // containing the address found in the modules and return the count of - // matches. If none - // is found, return an error in 'error_strm'. + // Given an address and a list of modules, append the symbol contexts of + // all line entries containing the address found in the modules and + // return the count of matches. If none is found, return an error in + // 'error_strm'. size_t GetSymbolContextsForAddress(const ModuleList &module_list, lldb::addr_t addr, SymbolContextList &sc_list, @@ -347,8 +339,9 @@ assert(module_list.GetSize() > 0); Target *target = m_exe_ctx.GetTargetPtr(); if (target->GetSectionLoadList().IsEmpty()) { - // The target isn't loaded yet, we need to lookup the file address in - // all modules. Note: the module list option does not apply to addresses. + // The target isn't loaded yet, we need to lookup the file address + // in all modules. Note: the module list option does not apply to + // addresses. const size_t num_modules = module_list.GetSize(); for (size_t i = 0; i < num_modules; ++i) { ModuleSP module_sp(module_list.GetModuleAtIndex(i)); @@ -409,8 +402,8 @@ return num_matches; } - // Dump the line entries found in functions matching the name specified in the - // option. + // Dump the line entries found in functions matching the name specified + // in the option. bool DumpLinesInFunctions(CommandReturnObject &result) { SymbolContextList sc_list_funcs; ConstString name(m_options.symbol_name.c_str()); @@ -774,9 +767,9 @@ const char *GetRepeatCommand(Args ¤t_command_args, uint32_t index) override { - // This is kind of gross, but the command hasn't been parsed yet so we can't - // look at the option values for this invocation... I have to scan the - // arguments directly. + // This is kind of gross, but the command hasn't been parsed yet so we + // can't look at the option values for this invocation... I have to + // scan the arguments directly. auto iter = llvm::find_if(current_command_args, [](const Args::ArgEntry &e) { return e.ref == "-r" || e.ref == "--reverse"; @@ -863,12 +856,11 @@ end_line = start_line + m_options.num_lines; } - // This is a little hacky, but the first line table entry for a function - // points to the "{" that - // starts the function block. It would be nice to actually get the - // function - // declaration in there too. So back up a bit, but not further than what - // you're going to display. + // This is a little hacky, but the first line table entry for a + // function points to the "{" that starts the function block. It + // would be nice to actually get the function declaration in there + // too. So back up a bit, but not further than what you're going to + // display. uint32_t extra_lines; if (m_options.num_lines >= 10) extra_lines = 5; @@ -880,9 +872,8 @@ else line_no = start_line - extra_lines; - // For fun, if the function is shorter than the number of lines we're - // supposed to display, - // only display the function... + // For fun, if the function is shorter than the number of lines + // we're supposed to display, only display the function... if (end_line != 0) { if (m_options.num_lines > end_line - line_no) m_options.num_lines = end_line - line_no + extra_lines; @@ -913,14 +904,14 @@ return 0; } - // From Jim: The FindMatchingFunctions / FindMatchingFunctionSymbols functions - // "take a possibly empty vector of strings which are names of modules, and - // run the two search functions on the subset of the full module list that - // matches the strings in the input vector". If we wanted to put these - // somewhere, - // there should probably be a module-filter-list that can be passed to the - // various ModuleList::Find* calls, which would either be a vector of string - // names or a ModuleSpecList. + // From Jim: The FindMatchingFunctions / FindMatchingFunctionSymbols + // functions "take a possibly empty vector of strings which are names of + // modules, and run the two search functions on the subset of the full + // module list that matches the strings in the input vector". If we + // wanted to put these somewhere, there should probably be a module- + // filter-list that can be passed to the various ModuleList::Find* + // calls, which would either be a vector of string names or a + // ModuleSpecList. size_t FindMatchingFunctions(Target *target, const ConstString &name, SymbolContextList &sc_list) { // Displaying the source for a symbol: @@ -993,12 +984,12 @@ SymbolContextList sc_list; ConstString name(m_options.symbol_name.c_str()); - // Displaying the source for a symbol. Search for function named name. + // Displaying the source for a symbol. Search for function named + // name. size_t num_matches = FindMatchingFunctions(target, name, sc_list); if (!num_matches) { - // If we didn't find any functions with that name, try searching for - // symbols - // that line up exactly with function addresses. + // If we didn't find any functions with that name, try searching + // for symbols that line up exactly with function addresses. SymbolContextList sc_list_symbols; size_t num_symbol_matches = FindMatchingFunctionSymbols(target, name, sc_list_symbols); @@ -1170,10 +1161,9 @@ } } else if (m_options.file_name.empty()) { // Last valid source manager context, or the current frame if no - // valid last context in source manager. - // One little trick here, if you type the exact same list command twice in - // a row, it is - // more likely because you typed it once, then typed it again + // valid last context in source manager. One little trick here, if + // you type the exact same list command twice in a row, it is more + // likely because you typed it once, then typed it again if (m_options.start_line == 0) { if (target->GetSourceManager().DisplayMoreWithLineNumbers( &result.GetOutputStream(), m_options.num_lines, Index: source/Commands/CommandObjectTarget.cpp =================================================================== --- source/Commands/CommandObjectTarget.cpp +++ source/Commands/CommandObjectTarget.cpp @@ -273,11 +273,9 @@ target_sp)); if (target_sp) { - // Only get the platform after we create the target because we might - // have - // switched platforms depending on what the arguments were to - // CreateTarget() - // we can't rely on the selected platform. + // Only get the platform after we create the target because we + // might have switched platforms depending on what the arguments + // were to CreateTarget() we can't rely on the selected platform. PlatformSP platform_sp = target_sp->GetPlatform(); @@ -297,9 +295,8 @@ } else { // there is no local file and we need one // in order to make the remote ---> local transfer we need a - // platform - // TODO: if the user has passed in a --platform argument, use it - // to fetch the right platform + // platform TODO: if the user has passed in a --platform + // argument, use it to fetch the right platform if (!platform_sp) { result.AppendError( "unable to perform remote debugging without a platform"); @@ -368,8 +365,8 @@ &core_file)); if (process_sp) { - // Seems weird that we Launch a core file, but that is - // what we do! + // Seems weird that we Launch a core file, but that is what + // we do! error = process_sp->LoadCore(); if (error.Fail()) { @@ -924,8 +921,8 @@ } } } else { - // No shared libraries, we just want to find globals for the compile - // units files that were specified + // No shared libraries, we just want to find globals for the + // compile units files that were specified for (size_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) target->GetImages().FindCompileUnits( compile_units.GetFileSpecAtIndex(cu_idx), append, sc_list); @@ -997,12 +994,11 @@ new_prefix_arg.arg_type = eArgTypeNewPathPrefix; new_prefix_arg.arg_repetition = eArgRepeatPairPlus; - // There are two required arguments that must always occur together, i.e. an - // argument "pair". Because they - // must always occur together, they are treated as two variants of one - // argument rather than two independent - // arguments. Push them both into the first argument position for - // m_arguments... + // There are two required arguments that must always occur together, + // i.e. an argument "pair". Because they must always occur together, + // they are treated as two variants of one argument rather than two + // independent arguments. Push them both into the first argument + // position for m_arguments... arg.push_back(old_prefix_arg); arg.push_back(new_prefix_arg); @@ -1111,12 +1107,11 @@ new_prefix_arg.arg_type = eArgTypeNewPathPrefix; new_prefix_arg.arg_repetition = eArgRepeatPairPlus; - // There are two required arguments that must always occur together, i.e. an - // argument "pair". Because they - // must always occur together, they are treated as two variants of one - // argument rather than two independent - // arguments. Push them both into the same argument position for - // m_arguments... + // There are two required arguments that must always occur together, + // i.e. an argument "pair". Because they must always occur together, + // they are treated as two variants of one argument rather than two + // independent arguments. Push them both into the same argument + // position for m_arguments... arg2.push_back(old_prefix_arg); arg2.push_back(new_prefix_arg); @@ -1635,8 +1630,8 @@ strm.PutCString(":\n"); for (TypeSP type_sp : type_list.Types()) { if (type_sp) { - // Resolve the clang type so that any forward references - // to types that haven't yet been parsed will get parsed. + // Resolve the clang type so that any forward references to + // types that haven't yet been parsed will get parsed. type_sp->GetFullCompilerType(); type_sp->GetDescription(&strm, eDescriptionLevelFull, true); // Print all typedef chains @@ -1686,8 +1681,8 @@ TypeSP type_sp(type_list.GetTypeAtIndex(0)); if (type_sp) { - // Resolve the clang type so that any forward references - // to types that haven't yet been parsed will get parsed. + // Resolve the clang type so that any forward references to types + // that haven't yet been parsed will get parsed. type_sp->GetFullCompilerType(); type_sp->GetDescription(&strm, eDescriptionLevelFull, true); // Print all typedef chains @@ -1766,8 +1761,7 @@ target->GetImages().FindModules(module_spec, module_list); // Not found in our module list for our target, check the main - // shared module list in case it is a extra file used somewhere - // else + // shared module list in case it is a extra file used somewhere else if (num_matches == 0) { module_spec.GetArchitecture() = target->GetArchitecture(); ModuleList::FindSharedModules(module_spec, module_list); @@ -2607,8 +2601,7 @@ ModuleSpec module_spec; bool search_using_module_spec = false; - // Allow "load" option to work without --file or --uuid - // option. + // Allow "load" option to work without --file or --uuid option. if (load) { if (!m_file_option.GetOptionValue().OptionWasSet() && !m_uuid_option_group.GetOptionValue().OptionWasSet()) { @@ -2930,9 +2923,8 @@ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); const bool use_global_module_list = m_options.m_use_global_module_list; // Define a local module list here to ensure it lives longer than any - // "locker" - // object which might lock its contents below (through the "module_list_ptr" - // variable). + // "locker" object which might lock its contents below (through the + // "module_list_ptr" variable). ModuleList module_list; if (target == nullptr && !use_global_module_list) { result.AppendError("invalid target, create a debug target using the " @@ -2979,11 +2971,10 @@ size_t num_modules = 0; - // This locker will be locked on the mutex in module_list_ptr if it is - // non-nullptr. - // Otherwise it will lock the AllocationModuleCollectionMutex when - // accessing - // the global module list directly. + // This locker will be locked on the mutex in module_list_ptr if it + // is non-nullptr. Otherwise it will lock the + // AllocationModuleCollectionMutex when accessing the global module + // list directly. std::unique_lock guard( Module::GetAllocationModuleCollectionMutex(), std::defer_lock); @@ -3139,8 +3130,8 @@ } break; } - // The address was valid, but the image isn't loaded, output the - // address in an appropriate format + // The address was valid, but the image isn't loaded, output + // the address in an appropriate format header_addr.Dump(&strm, target, Address::DumpStyleFileAddress); break; } @@ -3153,7 +3144,8 @@ size_t ref_count = 0; ModuleSP module_sp(module->shared_from_this()); if (module_sp) { - // Take one away to make sure we don't count our local "module_sp" + // Take one away to make sure we don't count our local + // "module_sp" ref_count = module_sp.use_count() - 1; } if (width) @@ -3832,8 +3824,8 @@ ModuleSP current_module; // Where it is possible to look in the current symbol context - // first, try that. If this search was successful and --all - // was not passed, don't print anything else. + // first, try that. If this search was successful and --all was + // not passed, don't print anything else. if (LookupHere(m_interpreter, result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -4045,10 +4037,9 @@ if (!module_spec.GetFileSpec() && !module_spec.GetPlatformFileSpec()) module_spec.GetFileSpec().GetFilename() = symbol_fspec.GetFilename(); } - // We now have a module that represents a symbol file - // that can be used for a module that might exist in the - // current target, so we need to find that module in the - // target + // We now have a module that represents a symbol file that can be + // used for a module that might exist in the current target, so we + // need to find that module in the target ModuleList matching_module_list; size_t num_matches = 0; @@ -4056,7 +4047,8 @@ lldb_private::ModuleSpecList symfile_module_specs; if (ObjectFile::GetModuleSpecifications(module_spec.GetSymbolFileSpec(), 0, 0, symfile_module_specs)) { - // Now extract the module spec that matches the target architecture + // Now extract the module spec that matches the target + // architecture ModuleSpec target_arch_module_spec; ModuleSpec symfile_module_spec; target_arch_module_spec.GetArchitecture() = target->GetArchitecture(); @@ -4073,9 +4065,8 @@ } if (num_matches == 0) { - // No matches yet, iterate through the module specs to find a UUID - // value that - // we can match up to an image in our target + // No matches yet, iterate through the module specs to find a + // UUID value that we can match up to an image in our target const size_t num_symfile_module_specs = symfile_module_specs.GetSize(); for (size_t i = 0; i < num_symfile_module_specs && num_matches == 0; @@ -4095,8 +4086,8 @@ } } - // Just try to match up the file by basename if we have no matches at this - // point + // Just try to match up the file by basename if we have no matches + // at this point if (num_matches == 0) num_matches = target->GetImages().FindModules(module_spec, matching_module_list); @@ -4108,7 +4099,8 @@ if (!filename_no_extension) break; - // Check if there was no extension to strip and the basename is the same + // Check if there was no extension to strip and the basename is + // the same if (filename_no_extension == module_spec.GetFileSpec().GetFilename()) break; @@ -4141,20 +4133,22 @@ ObjectFile *object_file = symbol_file->GetObjectFile(); if (object_file && object_file->GetFileSpec() == symbol_fspec) { - // Provide feedback that the symfile has been successfully added. + // Provide feedback that the symfile has been successfully + // added. const FileSpec &module_fs = module_sp->GetFileSpec(); result.AppendMessageWithFormat( "symbol file '%s' has been added to '%s'\n", symfile_path, module_fs.GetPath().c_str()); - // Let clients know something changed in the module - // if it is currently loaded + // Let clients know something changed in the module if it is + // currently loaded ModuleList module_list; module_list.Append(module_sp); target->SymbolsDidLoad(module_list); - // Make sure we load any scripting resources that may be embedded - // in the debug info files in case the platform supports that. + // Make sure we load any scripting resources that may be + // embedded in the debug info files in case the platform + // supports that. Status error; StreamString feedback_stream; module_sp->LoadScriptingResourceInTarget(target, error, Index: source/Commands/CommandObjectThread.cpp =================================================================== --- source/Commands/CommandObjectThread.cpp +++ source/Commands/CommandObjectThread.cpp @@ -74,9 +74,9 @@ } protected: - // Mark the thread index as mutable, as we don't care about it from a const - // perspective, we only care about m_stack_frames so we keep our std::set - // sorted. + // Mark the thread index as mutable, as we don't care about it from a + // const perspective, we only care about m_stack_frames so we keep our + // std::set sorted. mutable std::vector m_thread_index_ids; std::stack m_stack_frames; }; @@ -104,8 +104,8 @@ } // Use tids instead of ThreadSPs to prevent deadlocking problems which - // result from JIT-ing - // code while iterating over the (locked) ThreadSP list. + // result from JIT-ing code while iterating over the (locked) ThreadSP + // list. std::vector tids; if (all_threads || m_unique_stacks) { @@ -194,13 +194,12 @@ protected: // Override this to do whatever you need to do for one thread. // - // If you return false, the iteration will stop, otherwise it will proceed. - // The result is set to m_success_return (defaults to - // eReturnStatusSuccessFinishResult) before the iteration, - // so you only need to set the return status in HandleOneThread if you want to - // indicate an error. - // If m_add_return is true, a blank line will be inserted between each of the - // listings (except the last one.) + // If you return false, the iteration will stop, otherwise it will + // proceed. The result is set to m_success_return (defaults to + // eReturnStatusSuccessFinishResult) before the iteration, so you only + // need to set the return status in HandleOneThread if you want to + // indicate an error. If m_add_return is true, a blank line will be + // inserted between each of the listings (except the last one.) virtual bool HandleOneThread(lldb::tid_t, CommandReturnObject &result) = 0; @@ -261,8 +260,8 @@ class CommandOptions : public Options { public: CommandOptions() : Options() { - // Keep default values of all options in one place: OptionParsingStarting - // () + // Keep default values of all options in one place: + // OptionParsingStarting () OptionParsingStarting(nullptr); } @@ -433,8 +432,8 @@ class CommandOptions : public Options { public: CommandOptions() : Options() { - // Keep default values of all options in one place: OptionParsingStarting - // () + // Keep default values of all options in one place: + // OptionParsingStarting () OptionParsingStarting(nullptr); } @@ -647,8 +646,7 @@ const lldb::RunMode stop_other_threads = m_options.m_run_mode; // This is a bit unfortunate, but not all the commands in this command - // object support - // only while stepping, so I use the bool for them. + // object support only while stepping, so I use the bool for them. bool bool_stop_other_threads; if (m_options.m_run_mode == eAllThreads) bool_stop_other_threads = false; @@ -752,9 +750,9 @@ return false; } - // If we got a new plan, then set it to be a master plan (User level Plans - // should be master plans - // so that they can be interruptible). Then resume the process. + // If we got a new plan, then set it to be a master plan (User level + // Plans should be master plans so that they can be interruptible). + // Then resume the process. if (new_plan_sp) { new_plan_sp->SetIsMasterPlan(true); @@ -784,16 +782,15 @@ return false; } - // There is a race condition where this thread will return up the call - // stack to the main command handler - // and show an (lldb) prompt before HandlePrivateEvent (from - // PrivateStateThread) has - // a chance to call PushProcessIOHandler(). + // There is a race condition where this thread will return up the + // call stack to the main command handler and show an (lldb) prompt + // before HandlePrivateEvent (from PrivateStateThread) has a chance + // to call PushProcessIOHandler(). process->SyncIOHandler(iohandler_id, 2000); if (synchronous_execution) { - // If any state changed events had anything to say, add that to the - // result + // If any state changed events had anything to say, add that to + // the result if (stream.GetSize() > 0) result.AppendMessage(stream.GetString()); @@ -870,9 +867,9 @@ (state == eStateSuspended)) { const size_t argc = command.GetArgumentCount(); if (argc > 0) { - // These two lines appear at the beginning of both blocks in - // this if..else, but that is because we need to release the - // lock before calling process->Resume below. + // These two lines appear at the beginning of both blocks in this + // if..else, but that is because we need to release the lock + // before calling process->Resume below. std::lock_guard guard( process->GetThreadList().GetMutex()); const uint32_t num_threads = process->GetThreadList().GetSize(); @@ -931,9 +928,9 @@ process->GetID()); } } else { - // These two lines appear at the beginning of both blocks in - // this if..else, but that is because we need to release the - // lock before calling process->Resume below. + // These two lines appear at the beginning of both blocks in this + // if..else, but that is because we need to release the lock + // before calling process->Resume below. std::lock_guard guard( process->GetThreadList().GetMutex()); const uint32_t num_threads = process->GetThreadList().GetSize(); @@ -970,8 +967,8 @@ result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n", process->GetID()); if (synchronous_execution) { - // If any state changed events had anything to say, add that to the - // result + // If any state changed events had anything to say, add that to + // the result if (stream.GetSize() > 0) result.AppendMessage(stream.GetString()); @@ -1019,8 +1016,8 @@ CommandOptions() : Options(), m_thread_idx(LLDB_INVALID_THREAD_ID), m_frame_idx(LLDB_INVALID_FRAME_ID) { - // Keep default values of all options in one place: OptionParsingStarting - // () + // Keep default values of all options in one place: + // OptionParsingStarting () OptionParsingStarting(nullptr); } @@ -1195,8 +1192,8 @@ ThreadPlanSP new_plan_sp; if (frame->HasDebugInformation()) { - // Finally we got here... Translate the given line number to a bunch of - // addresses: + // Finally we got here... Translate the given line number to a + // bunch of addresses: SymbolContext sc(frame->GetSymbolContext(eSymbolContextCompUnit)); LineTable *line_table = nullptr; if (sc.comp_unit) @@ -1274,11 +1271,10 @@ new_plan_sp = thread->QueueThreadPlanForStepUntil( abort_other_plans, &address_list.front(), address_list.size(), m_options.m_stop_others, m_options.m_frame_idx); - // User level plans should be master plans so they can be interrupted - // (e.g. by hitting a breakpoint) - // and other plans executed by the user (stepping around the breakpoint) - // and then a "continue" - // will resume the original plan. + // User level plans should be master plans so they can be + // interrupted (e.g. by hitting a breakpoint) and other plans + // executed by the user (stepping around the breakpoint) and then + // a "continue" will resume the original plan. new_plan_sp->SetIsMasterPlan(true); new_plan_sp->SetOkayToDiscard(false); } else { @@ -1302,8 +1298,8 @@ result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n", process->GetID()); if (synchronous_execution) { - // If any state changed events had anything to say, add that to the - // result + // If any state changed events had anything to say, add that to + // the result if (stream.GetSize() > 0) result.AppendMessage(stream.GetString()); @@ -1529,8 +1525,8 @@ class CommandOptions : public Options { public: CommandOptions() : Options(), m_from_expression(false) { - // Keep default values of all options in one place: OptionParsingStarting - // () + // Keep default values of all options in one place: + // OptionParsingStarting () OptionParsingStarting(nullptr); } @@ -1608,9 +1604,8 @@ protected: bool DoExecute(const char *command, CommandReturnObject &result) override { - // I am going to handle this by hand, because I don't want you to have to - // say: - // "thread return -- -5". + // I am going to handle this by hand, because I don't want you to have + // to say: "thread return -- -5". if (command[0] == '-' && command[1] == 'x') { if (command && command[2] != '\0') result.AppendWarning("Return values ignored when returning from user " @@ -1859,8 +1854,8 @@ class CommandOptions : public Options { public: CommandOptions() : Options() { - // Keep default values of all options in one place: OptionParsingStarting - // () + // Keep default values of all options in one place: + // OptionParsingStarting () OptionParsingStarting(nullptr); } Index: source/Commands/CommandObjectType.cpp =================================================================== --- source/Commands/CommandObjectType.cpp +++ source/Commands/CommandObjectType.cpp @@ -206,8 +206,8 @@ "the script interpreter.\n"); error_sp->Flush(); } else { - // now I have a valid function name, let's add this as script - // for every type in the list + // now I have a valid function name, let's add this as + // script for every type in the list TypeSummaryImplSP script_format; script_format.reset(new ScriptSummaryFormat( @@ -450,8 +450,8 @@ "error: unable to obtain a proper name for the class.\n"); error_sp->Flush(); } else { - // everything should be fine now, let's add the synth provider - // class + // everything should be fine now, let's add the synth + // provider class SyntheticChildrenSP synth_provider; synth_provider.reset(new ScriptedSyntheticChildren( @@ -1421,8 +1421,8 @@ return result.Succeeded(); } - // if I am here, script_format must point to something good, so I can add that - // as a script summary to all interested parties + // if I am here, script_format must point to something good, so I can + // add that as a script summary to all interested parties Status error; @@ -2756,10 +2756,9 @@ class CommandObjectTypeLookup : public CommandObjectRaw { protected: - // this function is allowed to do a more aggressive job at guessing languages - // than the expression parser - // is comfortable with - so leave the original call alone and add one that is - // specific to type lookup + // this function is allowed to do a more aggressive job at guessing + // languages than the expression parser is comfortable with - so leave + // the original call alone and add one that is specific to type lookup lldb::LanguageType GuessLanguage(StackFrame *frame) { lldb::LanguageType lang_type = lldb::eLanguageTypeUnknown; @@ -2913,8 +2912,8 @@ // TargetSP // target_sp(GetCommandInterpreter().GetDebugger().GetSelectedTarget()); - // const bool fill_all_in = true; - // ExecutionContext exe_ctx(target_sp.get(), fill_all_in); + // const bool fill_all_in = true; ExecutionContext + // exe_ctx(target_sp.get(), fill_all_in); ExecutionContextScope *best_scope = exe_ctx.GetBestExecutionContextScope(); bool any_found = false; @@ -2933,10 +2932,9 @@ languages.push_back(Language::FindPlugin(m_command_options.m_language)); } - // This is not the most efficient way to do this, but we support very few - // languages - // so the cost of the sort is going to be dwarfed by the actual lookup - // anyway + // This is not the most efficient way to do this, but we support very + // few languages so the cost of the sort is going to be dwarfed by the + // actual lookup anyway if (StackFrame *frame = m_exe_ctx.GetFramePtr()) { guessed_language = GuessLanguage(frame); if (guessed_language != eLanguageTypeUnknown) { @@ -2974,7 +2972,8 @@ } } } - // this is "type lookup SomeName" and we did find a match, so get out + // this is "type lookup SomeName" and we did find a match, so get + // out if (any_found && is_global_search) break; else if (is_first_language && is_global_search && Index: source/Commands/CommandObjectWatchpoint.cpp =================================================================== --- source/Commands/CommandObjectWatchpoint.cpp +++ source/Commands/CommandObjectWatchpoint.cpp @@ -96,8 +96,8 @@ llvm::StringRef second; size_t i; int32_t idx; - // Go through the arguments and make a canonical form of arg list containing - // only numbers with possible "-" in between. + // Go through the arguments and make a canonical form of arg list + // containing only numbers with possible "-" in between. for (auto &entry : args.entries()) { if ((idx = WithRSAIndex(entry.ref)) == -1) { StrRefArgs.push_back(entry.ref); @@ -112,7 +112,8 @@ StrRefArgs.push_back(second); } // Now process the canonical list and fill in the vector of uint32_t's. - // If there is any error, return false and the client should ignore wp_ids. + // If there is any error, return false and the client should ignore + // wp_ids. uint32_t beg, end, id; size_t size = StrRefArgs.size(); bool in_range = false; @@ -178,8 +179,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -269,7 +270,8 @@ Stream &output_stream = result.GetOutputStream(); if (command.GetArgumentCount() == 0) { - // No watchpoint selected; show info about all currently set watchpoints. + // No watchpoint selected; show info about all currently set + // watchpoints. result.AppendMessage("Current watchpoints:"); for (size_t i = 0; i < num_watchpoints; ++i) { Watchpoint *wp = watchpoints.GetByIndex(i).get(); @@ -317,8 +319,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -389,8 +391,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -463,8 +465,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -546,8 +548,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -674,8 +676,8 @@ CommandArgumentEntry arg; CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); - // Add the entry for the first argument for this command to the object's - // arguments vector. + // Add the entry for the first argument for this command to the + // object's arguments vector. m_arguments.push_back(arg); } @@ -848,8 +850,8 @@ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); StackFrame *frame = m_exe_ctx.GetFramePtr(); - // If no argument is present, issue an error message. There's no way to set - // a watchpoint. + // If no argument is present, issue an error message. There's no way + // to set a watchpoint. if (command.GetArgumentCount() <= 0) { result.GetErrorStream().Printf("error: required argument missing; " "specify your program variable to watch " @@ -863,8 +865,8 @@ m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchWrite; } - // We passed the sanity check for the command. - // Proceed to set the watchpoint now. + // We passed the sanity check for the command. Proceed to set the + // watchpoint now. lldb::addr_t addr = 0; size_t size = 0; @@ -1072,8 +1074,8 @@ if (expr == nullptr) expr = raw_command; - // If no argument is present, issue an error message. There's no way to set - // a watchpoint. + // If no argument is present, issue an error message. There's no way + // to set a watchpoint. if (command.GetArgumentCount() == 0) { result.GetErrorStream().Printf("error: required argument missing; " "specify an expression to evaulate into " @@ -1087,8 +1089,8 @@ m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchWrite; } - // We passed the sanity check for the command. - // Proceed to set the watchpoint now. + // We passed the sanity check for the command. Proceed to set the + // watchpoint now. lldb::addr_t addr = 0; size_t size = 0; @@ -1130,8 +1132,8 @@ // Now it's time to create the watchpoint. uint32_t watch_type = m_option_watchpoint.watch_type; - // Fetch the type from the value object, the type of the watched object is - // the pointee type + // Fetch the type from the value object, the type of the watched + // object is the pointee type /// of the expression, so convert to that if we found a valid type. CompilerType compiler_type(valobj_sp->GetCompilerType()); Index: source/Commands/CommandObjectWatchpointCommand.cpp =================================================================== --- source/Commands/CommandObjectWatchpointCommand.cpp +++ source/Commands/CommandObjectWatchpointCommand.cpp @@ -33,10 +33,10 @@ // CommandObjectWatchpointCommandAdd //------------------------------------------------------------------------- -// FIXME: "script-type" needs to have its contents determined dynamically, so -// somebody can add a new scripting -// language to lldb and have it pickable here without having to change this -// enumeration by hand and rebuild lldb proper. +// FIXME: "script-type" needs to have its contents determined dynamically, +// so somebody can add a new scripting language to lldb and have it +// pickable here without having to change this enumeration by hand and +// rebuild lldb proper. static OptionEnumValueElement g_script_option_enumeration[4] = { {eScriptLanguageNone, "command", @@ -222,8 +222,8 @@ std::string &line) override { io_handler.SetIsDone(true); - // The WatchpointOptions object is owned by the watchpoint or watchpoint - // location + // The WatchpointOptions object is owned by the watchpoint or + // watchpoint location WatchpointOptions *wp_options = (WatchpointOptions *)io_handler.GetUserData(); if (wp_options) { @@ -254,11 +254,10 @@ std::unique_ptr data_ap( new WatchpointOptions::CommandData()); - // It's necessary to set both user_source and script_source to the oneliner. - // The former is used to generate callback description (as in watchpoint - // command list) - // while the latter is used for Python to interpret during the actual - // callback. + // It's necessary to set both user_source and script_source to the + // oneliner. The former is used to generate callback description (as + // in watchpoint command list) while the latter is used for Python to + // interpret during the actual callback. data_ap->user_source.AppendString(oneliner); data_ap->script_source.assign(oneliner); data_ap->stop_on_error = m_options.m_stop_on_error; @@ -286,9 +285,9 @@ if (target) { CommandReturnObject result; Debugger &debugger = target->GetDebugger(); - // Rig up the results secondary output stream to the debugger's, so the - // output will come out synchronously - // if the debugger is set up that way. + // Rig up the results secondary output stream to the debugger's, + // so the output will come out synchronously if the debugger is + // set up that way. StreamSP output_stream(debugger.GetAsyncOutputStream()); StreamSP error_stream(debugger.GetAsyncErrorStream()); @@ -441,20 +440,19 @@ if (wp_options == nullptr) continue; - // If we are using script language, get the script interpreter - // in order to set or collect command callback. Otherwise, call - // the methods associated with this object. + // If we are using script language, get the script interpreter in + // order to set or collect command callback. Otherwise, call the + // methods associated with this object. if (m_options.m_use_script_language) { // Special handling for one-liner specified inline. if (m_options.m_use_one_liner) { m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback( wp_options, m_options.m_one_liner.c_str()); } - // Special handling for using a Python function by name - // instead of extending the watchpoint callback data structures, we - // just automatize - // what the user would do manually: make their watchpoint command be a - // function call + // Special handling for using a Python function by name instead + // of extending the watchpoint callback data structures, we just + // automatize what the user would do manually: make their + // watchpoint command be a function call else if (!m_options.m_function_name.empty()) { std::string oneliner(m_options.m_function_name); oneliner += "(frame, wp, internal_dict)"; @@ -635,7 +633,8 @@ if (wp) { const WatchpointOptions *wp_options = wp->GetOptions(); if (wp_options) { - // Get the callback baton associated with the current watchpoint. + // Get the callback baton associated with the current + // watchpoint. const Baton *baton = wp_options->GetBaton(); if (baton) { result.GetOutputStream().Printf("Watchpoint %u:\n", cur_wp_id); Index: source/Core/Address.cpp =================================================================== --- source/Core/Address.cpp +++ source/Core/Address.cpp @@ -141,8 +141,8 @@ deref_so_addr)) return true; } else { - // If we were not running, yet able to read an integer, we must - // have a module + // If we were not running, yet able to read an integer, we must have + // a module ModuleSP module_sp(address.GetModule()); assert(module_sp); @@ -150,9 +150,9 @@ return true; } - // We couldn't make "deref_addr" into a section offset value, but we were - // able to read the address, so we return a section offset address with - // no section and "deref_addr" as the offset (address). + // We couldn't make "deref_addr" into a section offset value, but we + // were able to read the address, so we return a section offset + // address with no section and "deref_addr" as the offset (address). deref_so_addr.SetRawAddress(deref_addr); return true; } @@ -278,15 +278,16 @@ // Section isn't resolved, we can't return a valid file address return LLDB_INVALID_ADDRESS; } - // We have a valid file range, so we can return the file based - // address by adding the file base address to our offset + // We have a valid file range, so we can return the file based address + // by adding the file base address to our offset return sect_file_addr + m_offset; } else if (SectionWasDeletedPrivate()) { - // Used to have a valid section but it got deleted so the - // offset doesn't mean anything without the section + // Used to have a valid section but it got deleted so the offset + // doesn't mean anything without the section return LLDB_INVALID_ADDRESS; } - // No section, we just return the offset since it is the value in this case + // No section, we just return the offset since it is the value in this + // case return m_offset; } @@ -303,15 +304,15 @@ } } } else if (SectionWasDeletedPrivate()) { - // Used to have a valid section but it got deleted so the - // offset doesn't mean anything without the section + // Used to have a valid section but it got deleted so the offset + // doesn't mean anything without the section return LLDB_INVALID_ADDRESS; } else { // We don't have a section so the offset is the load address return m_offset; } - // The section isn't resolved or an invalid target was passed in - // so we can't return a valid load address. + // The section isn't resolved or an invalid target was passed in so we + // can't return a valid load address. return LLDB_INVALID_ADDRESS; } @@ -374,9 +375,8 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size) const { - // If the section was nullptr, only load address is going to work unless we - // are - // trying to deref a pointer + // If the section was nullptr, only load address is going to work unless + // we are trying to deref a pointer SectionSP section_sp(GetSection()); if (!section_sp && style != DumpStyleResolvedPointerDescription) style = DumpStyleLoadAddress; @@ -642,24 +642,26 @@ (style != DumpStyleResolvedDescriptionNoFunctionArguments); const bool show_function_name = (style != DumpStyleNoFunctionName); if (sc.function == nullptr && sc.symbol != nullptr) { - // If we have just a symbol make sure it is in the right section + // If we have just a symbol make sure it is in the right + // section if (sc.symbol->ValueIsAddress()) { if (sc.symbol->GetAddressRef().GetSection() != GetSection()) { - // don't show the module if the symbol is a trampoline symbol + // don't show the module if the symbol is a trampoline + // symbol show_stop_context = false; } } } if (show_stop_context) { - // We have a function or a symbol from the same - // sections as this address. + // We have a function or a symbol from the same sections as + // this address. sc.DumpStopContext(s, exe_scope, *this, show_fullpaths, show_module, show_inlined_frames, show_function_arguments, show_function_name); } else { - // We found a symbol but it was in a different - // section so it isn't the symbol we should be - // showing, just show the section name + offset + // We found a symbol but it was in a different section so it + // isn't the symbol we should be showing, just show the + // section name + offset Dump(s, exe_scope, DumpStyleSectionNameOffset); } } @@ -770,15 +772,12 @@ bool Address::SectionWasDeletedPrivate() const { lldb::SectionWP empty_section_wp; - // If either call to "std::weak_ptr::owner_before(...) value returns true, - // this - // indicates that m_section_wp once contained (possibly still does) a - // reference - // to a valid shared pointer. This helps us know if we had a valid reference - // to - // a section which is now invalid because the module it was in was - // unloaded/deleted, - // or if the address doesn't have a valid reference to a section. + // If either call to "std::weak_ptr::owner_before(...) value returns + // true, this indicates that m_section_wp once contained (possibly still + // does) a reference to a valid shared pointer. This helps us know if we + // had a valid reference to a section which is now invalid because the + // module it was in was unloaded/deleted, or if the address doesn't have + // a valid reference to a section. return empty_section_wp.owner_before(m_section_wp) || m_section_wp.owner_before(empty_section_wp); } @@ -786,8 +785,8 @@ uint32_t Address::CalculateSymbolContext(SymbolContext *sc, uint32_t resolve_scope) const { sc->Clear(false); - // Absolute addresses don't have enough information to reconstruct even their - // target. + // Absolute addresses don't have enough information to reconstruct even + // their target. SectionSP section_sp(GetSection()); if (section_sp) { @@ -926,8 +925,8 @@ } size_t Address::MemorySize() const { - // Noting special for the memory size of a single Address object, - // it is just the size of itself. + // Noting special for the memory size of a single Address object, it is + // just the size of itself. return sizeof(Address); } @@ -938,8 +937,8 @@ // compare the module pointers. // // To sum things up: -// - works great for addresses within the same module -// - it works for addresses across multiple modules, but don't expect the +// - works great for addresses within the same module - it works for +// addresses across multiple modules, but don't expect the // address results to make much sense // // This basically lets Address objects be used in ordered collection @@ -976,7 +975,8 @@ } } -// The operator == checks for exact equality only (same section, same offset) +// The operator == checks for exact equality only (same section, same +// offset) bool lldb_private::operator==(const Address &a, const Address &rhs) { return a.GetOffset() == rhs.GetOffset() && a.GetSection() == rhs.GetSection(); } @@ -992,7 +992,8 @@ if (module_sp) { ObjectFile *obj_file = module_sp->GetObjectFile(); if (obj_file) { - // Give the symbol vendor a chance to add to the unified section list. + // Give the symbol vendor a chance to add to the unified section + // list. module_sp->GetSymbolVendor(); return obj_file->GetAddressClass(GetFileAddress()); } Index: source/Core/AddressResolverFileLine.cpp =================================================================== --- source/Core/AddressResolverFileLine.cpp +++ source/Core/AddressResolverFileLine.cpp @@ -62,8 +62,9 @@ m_address_ranges.push_back(new_range); if (log) { StreamString s; - // new_bp_loc->GetDescription (&s, lldb::eDescriptionLevelVerbose); - // log->Printf ("Added address: %s\n", s.GetData()); + // new_bp_loc->GetDescription (&s, + // lldb::eDescriptionLevelVerbose); log->Printf ("Added address: + // %s\n", s.GetData()); } } else { if (log) Index: source/Core/AddressResolverName.cpp =================================================================== --- source/Core/AddressResolverName.cpp +++ source/Core/AddressResolverName.cpp @@ -60,11 +60,9 @@ AddressResolverName::~AddressResolverName() = default; // FIXME: Right now we look at the module level, and call the module's -// "FindFunctions". -// Greg says he will add function tables, maybe at the CompileUnit level to -// accelerate function -// lookup. At that point, we should switch the depth to CompileUnit, and look -// in these tables. +// "FindFunctions". Greg says he will add function tables, maybe at the +// CompileUnit level to accelerate function lookup. At that point, we +// should switch the depth to CompileUnit, and look in these tables. Searcher::CallbackReturn AddressResolverName::SearchCallback(SearchFilter &filter, Index: source/Core/Broadcaster.cpp =================================================================== --- source/Core/Broadcaster.cpp +++ source/Core/Broadcaster.cpp @@ -74,9 +74,8 @@ void Broadcaster::BroadcasterImpl::Clear() { std::lock_guard guard(m_listeners_mutex); - // Make sure the listener forgets about this broadcaster. We do - // this in the broadcaster in case the broadcaster object initiates - // the removal. + // Make sure the listener forgets about this broadcaster. We do this in + // the broadcaster in case the broadcaster object initiates the removal. for (auto &pair : GetListeners()) pair.first->BroadcasterWillDestruct(&m_broadcaster); @@ -142,8 +141,9 @@ m_listeners.push_back( std::make_pair(lldb::ListenerWP(listener_sp), event_mask)); - // Individual broadcasters decide whether they have outstanding data when a - // listener attaches, and insert it into the listener with this method. + // Individual broadcasters decide whether they have outstanding data + // when a listener attaches, and insert it into the listener with this + // method. m_broadcaster.AddInitialEventsToListener(listener_sp, event_mask); } Index: source/Core/Communication.cpp =================================================================== --- source/Core/Communication.cpp +++ source/Core/Communication.cpp @@ -97,16 +97,15 @@ lldb::ConnectionSP connection_sp(m_connection_sp); if (connection_sp) { ConnectionStatus status = connection_sp->Disconnect(error_ptr); - // We currently don't protect connection_sp with any mutex for - // multi-threaded environments. So lets not nuke our connection class - // without putting some multi-threaded protections in. We also probably - // don't want to pay for the overhead it might cause if every time we - // access the connection we have to take a lock. + // We currently don't protect connection_sp with any mutex for multi- + // threaded environments. So lets not nuke our connection class + // without putting some multi-threaded protections in. We also + // probably don't want to pay for the overhead it might cause if every + // time we access the connection we have to take a lock. // - // This unique pointer will cleanup after itself when this object goes away, - // so there is no need to currently have it destroy itself immediately - // upon disconnnect. - // connection_sp.reset(); + // This unique pointer will cleanup after itself when this object goes + // away, so there is no need to currently have it destroy itself + // immediately upon disconnnect. connection_sp.reset(); return status; } return eConnectionStatusNoConnection; @@ -164,8 +163,8 @@ return 0; } - // We aren't using a read thread, just read the data synchronously in this - // thread. + // We aren't using a read thread, just read the data synchronously in + // this thread. return ReadFromConnection(dst, dst_len, timeout, status, error_ptr); } @@ -240,8 +239,8 @@ size_t Communication::GetCachedBytes(void *dst, size_t dst_len) { std::lock_guard guard(m_bytes_mutex); if (!m_bytes.empty()) { - // If DST is nullptr and we have a thread, then return the number - // of bytes that are available so the caller can call again + // If DST is nullptr and we have a thread, then return the number of + // bytes that are available so the caller can call again if (dst == nullptr) return m_bytes.size(); @@ -267,7 +266,8 @@ (status != lldb::eConnectionStatusEndOfFile)) return; if (m_callback) { - // If the user registered a callback, then call it and do not broadcast + // If the user registered a callback, then call it and do not + // broadcast m_callback(m_callback_baton, bytes, len); } else if (bytes != nullptr && len > 0) { std::lock_guard guard(m_bytes_mutex); @@ -336,9 +336,8 @@ break; case eConnectionStatusInterrupted: // Synchronization signal from // SynchronizeWithReadThread() - // The connection returns eConnectionStatusInterrupted only when there is - // no - // input pending to be read, so we can signal that. + // The connection returns eConnectionStatusInterrupted only when + // there is no input pending to be read, so we can signal that. comm->BroadcastEvent(eBroadcastBitNoMorePendingInput); break; case eConnectionStatusNoConnection: // No connection Index: source/Core/Debugger.cpp =================================================================== --- source/Core/Debugger.cpp +++ source/Core/Debugger.cpp @@ -167,13 +167,15 @@ "}${addr-file-or-load}{ " \ "<${function.concrete-only-addr-offset-no-padding}>}: " -// gdb's disassembly format can be emulated with -// ${current-pc-arrow}${addr-file-or-load}{ -// <${function.name-without-args}${function.concrete-only-addr-offset-no-padding}>}: +// gdb's disassembly format can be emulated with ${current-pc-arrow +// }${addr-file-or-load}{ <${function.name-without-args}${function +// .concrete-only-addr-offset-no-padding}>}: -// lldb's original format for disassembly would look like this format string - -// {${function.initial-function}{${module.file.basename}`}{${function.name-without-args}}:\n}{${function.changed}\n{${module.file.basename}`}{${function.name-without-args}}:\n}{${current-pc-arrow} -// }{${addr-file-or-load}}: +// lldb's original format for disassembly would look like this format +// string - {${function.initial- +// function}{${module.file.basename}`}{${function.name-without- +// args}}:\n}{${function.changed}\n{${module.file.basename}`}{${function +// .name-without-args}}:\n}{${current-pc-arrow} }{${addr-file-or-load}}: #define DEFAULT_STOP_SHOW_COLUMN_ANSI_PREFIX "${ansi.underline}" #define DEFAULT_STOP_SHOW_COLUMN_ANSI_SUFFIX "${ansi.normal}" @@ -340,8 +342,8 @@ CommandInterpreter::eBroadcastBitResetPrompt, bytes.release()); GetCommandInterpreter().BroadcastEvent(prompt_change_event_sp); } else if (property_path == g_properties[ePropertyUseColor].name) { - // use-color changed. Ping the prompt so it can reset the ansi terminal - // codes. + // use-color changed. Ping the prompt so it can reset the ansi + // terminal codes. SetPrompt(GetPrompt()); } else if (is_load_script && target_sp && load_script_old_value == eLoadScriptFromSymFileWarn) { @@ -590,9 +592,10 @@ return true; } } else { - // The g_load_plugin_callback is registered in SBDebugger::Initialize() - // and if the public API layer isn't available (code is linking against - // all of the internal LLDB static libraries), then we can't load plugins + // The g_load_plugin_callback is registered in + // SBDebugger::Initialize() and if the public API layer isn't + // available (code is linking against all of the internal LLDB static + // libraries), then we can't load plugins error.SetErrorString("Public API layer is not available"); } return false; @@ -613,9 +616,9 @@ namespace fs = llvm::sys::fs; // If we have a regular file, a symbolic link or unknown file type, try - // and process the file. We must handle unknown as sometimes the directory - // enumeration might be enumerating a file system that doesn't have correct - // file type information. + // and process the file. We must handle unknown as sometimes the + // directory enumeration might be enumerating a file system that doesn't + // have correct file type information. if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) { FileSpec plugin_file_spec(file_spec); @@ -633,10 +636,10 @@ } else if (ft == fs::file_type::directory_file || ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) { - // Try and recurse into anything that a directory or symbolic link. - // We must also do this for unknown as sometimes the directory enumeration - // might be enumerating a file system that doesn't have correct file type - // information. + // Try and recurse into anything that a directory or symbolic link. We + // must also do this for unknown as sometimes the directory + // enumeration might be enumerating a file system that doesn't have + // correct file type information. return FileSpec::eEnumerateDirectoryResultEnter; } @@ -827,9 +830,9 @@ } m_broadcaster_manager_sp->Clear(); - // Close the input file _before_ we close the input read communications - // class - // as it does NOT own the input file, our m_input_file does. + // Close the input file _before_ we close the input read + // communications class as it does NOT own the input file, our + // m_input_file does. m_terminal_state.Clear(); if (m_input_file_sp) m_input_file_sp->GetFile().Close(); @@ -865,8 +868,8 @@ if (!in_file.IsValid()) in_file.SetStream(stdin, true); - // Save away the terminal state if that is relevant, so that we can restore it - // in RestoreInputState. + // Save away the terminal state if that is relevant, so that we can + // restore it in RestoreInputState. SaveInputTerminalState(); } @@ -880,8 +883,9 @@ if (!out_file.IsValid()) out_file.SetStream(stdout, false); - // do not create the ScriptInterpreter just for setting the output file handle - // as the constructor will know how to do the right thing on its own + // do not create the ScriptInterpreter just for setting the output file + // handle as the constructor will know how to do the right thing on its + // own const bool can_create = false; ScriptInterpreter *script_interpreter = GetCommandInterpreter().GetScriptInterpreter(can_create); @@ -946,8 +950,8 @@ } void Debugger::ClearIOHandlers() { - // The bottom input reader should be the main debugger input reader. We do - // not want to close that one here. + // The bottom input reader should be the main debugger input reader. We + // do not want to close that one here. std::lock_guard guard(m_input_reader_stack.GetMutex()); while (m_input_reader_stack.GetSize() > 1) { IOHandlerSP reader_sp(m_input_reader_stack.Top()); @@ -1027,11 +1031,11 @@ void Debugger::AdoptTopIOHandlerFilesIfInvalid(StreamFileSP &in, StreamFileSP &out, StreamFileSP &err) { - // Before an IOHandler runs, it must have in/out/err streams. - // This function is called when one ore more of the streams - // are nullptr. We use the top input reader's in/out/err streams, - // or fall back to the debugger file handles, or we fall back - // onto stdin/stdout/stderr as a last resort. + // Before an IOHandler runs, it must have in/out/err streams. This + // function is called when one ore more of the streams are nullptr. We + // use the top input reader's in/out/err streams, or fall back to the + // debugger file handles, or we fall back onto stdin/stdout/stderr as a + // last resort. std::lock_guard guard(m_input_reader_stack.GetMutex()); IOHandlerSP top_reader_sp(m_input_reader_stack.Top()); @@ -1087,8 +1091,8 @@ m_input_reader_stack.Push(reader_sp); reader_sp->Activate(); - // Interrupt the top input reader to it will exit its Run() function - // and let this new input reader take over + // Interrupt the top input reader to it will exit its Run() function and + // let this new input reader take over if (top_reader_sp) { top_reader_sp->Deactivate(); top_reader_sp->Cancel(); @@ -1101,8 +1105,8 @@ std::lock_guard guard(m_input_reader_stack.GetMutex()); - // The reader on the stop of the stack is done, so let the next - // read on the stack refresh its prompt and if there is one... + // The reader on the stop of the stack is done, so let the next read on + // the stack refresh its prompt and if there is one... if (m_input_reader_stack.IsEmpty()) return false; @@ -1198,8 +1202,8 @@ } } // The first context on a list of instructions will have a prev_sc that - // has no Function or Symbol -- if SymbolContext had an IsValid() method, it - // would return false. But we do get a prev_sc pointer. + // has no Function or Symbol -- if SymbolContext had an IsValid() + // method, it would return false. But we do get a prev_sc pointer. if ((sc && (sc->function || sc->symbol)) && prev_sc && (prev_sc->function == nullptr && prev_sc->symbol == nullptr)) { initial_function = true; @@ -1210,9 +1214,9 @@ void Debugger::SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton) { - // For simplicity's sake, I am not going to deal with how to close down any - // open logging streams, I just redirect everything from here on out to the - // callback. + // For simplicity's sake, I am not going to deal with how to close down + // any open logging streams, I just redirect everything from here on out + // to the callback. m_log_callback_stream_sp = std::make_shared(log_callback, baton); } @@ -1227,7 +1231,8 @@ std::shared_ptr log_stream_sp; if (m_log_callback_stream_sp) { log_stream_sp = m_log_callback_stream_sp; - // For now when using the callback mode you always get thread & timestamp. + // For now when using the callback mode you always get thread & + // timestamp. log_options |= LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME; } else if (log_file.empty()) { @@ -1464,8 +1469,9 @@ } void Debugger::HandleThreadEvent(const EventSP &event_sp) { - // At present the only thread event we handle is the Frame Changed event, - // and all we do for that is just reprint the thread status for that thread. + // At present the only thread event we handle is the Frame Changed + // event, and all we do for that is just reprint the thread status for + // that thread. using namespace lldb; const uint32_t event_type = event_sp->GetType(); const bool stop_format = true; @@ -1518,8 +1524,8 @@ CommandInterpreter::eBroadcastBitAsynchronousOutputData | CommandInterpreter::eBroadcastBitAsynchronousErrorData); - // Let the thread that spawned us know that we have started up and - // that we are now listening to all required events so no events get missed + // Let the thread that spawned us know that we have started up and that + // we are now listening to all required events so no events get missed m_sync_broadcaster.BroadcastEvent(eBroadcastBitEventThreadIsListening); bool done = false; @@ -1598,13 +1604,11 @@ "lldb.debugger.event-handler", EventHandlerThread, this, nullptr, g_debugger_event_thread_stack_bytes); - // Make sure DefaultEventHandler() is running and listening to events before - // we return - // from this function. We are only listening for events of type - // eBroadcastBitEventThreadIsListening so we don't need to check the event, - // we just need - // to wait an infinite amount of time for it (nullptr timeout as the first - // parameter) + // Make sure DefaultEventHandler() is running and listening to events + // before we return from this function. We are only listening for + // events of type eBroadcastBitEventThreadIsListening so we don't need + // to check the event, we just need to wait an infinite amount of time + // for it (nullptr timeout as the first parameter) lldb::EventSP event_sp; listener_sp->GetEvent(event_sp, llvm::None); } Index: source/Core/Disassembler.cpp =================================================================== --- source/Core/Disassembler.cpp +++ source/Core/Disassembler.cpp @@ -96,8 +96,8 @@ const char *plugin_name) { if (target_sp && flavor == nullptr) { // FIXME - we don't have the mechanism in place to do per-architecture - // settings. But since we know that for now - // we only support flavors on x86 & x86_64, + // settings. But since we know that for now we only support flavors + // on x86 & x86_64, if (arch.GetTriple().getArch() == llvm::Triple::x86 || arch.GetTriple().getArch() == llvm::Triple::x86_64) flavor = target_sp->GetDisassemblyFlavor(); @@ -108,8 +108,8 @@ static void ResolveAddress(const ExecutionContext &exe_ctx, const Address &addr, Address &resolved_addr) { if (!addr.IsSectionOffset()) { - // If we weren't passed in a section offset address range, - // try and resolve it to something + // If we weren't passed in a section offset address range, try and + // resolve it to something Target *target = exe_ctx.GetTargetPtr(); if (target) { if (target->GetSectionLoadList().IsEmpty()) { @@ -118,8 +118,8 @@ target->GetSectionLoadList().ResolveLoadAddress(addr.GetOffset(), resolved_addr); } - // We weren't able to resolve the address, just treat it as a - // raw address + // We weren't able to resolve the address, just treat it as a raw + // address if (resolved_addr.IsValid()) return; } @@ -327,7 +327,8 @@ const ExecutionContext &exe_ctx, const SymbolContext &sc, SourceLine &line) { - // TODO: should we also check target.process.thread.step-avoid-libraries ? + // TODO: should we also check target.process.thread.step-avoid-libraries + // ? const RegularExpression *avoid_regex = nullptr; @@ -410,15 +411,13 @@ disassembly_format = &format; } - // First pass: step through the list of instructions, - // find how long the initial addresses strings are, insert padding - // in the second pass so the opcodes all line up nicely. + // First pass: step through the list of instructions, find how long the + // initial addresses strings are, insert padding in the second pass so + // the opcodes all line up nicely. - // Also build up the source line mapping if this is mixed source & assembly - // mode. - // Calculate the source line for each assembly instruction (eliding inlined - // functions - // which the user wants to skip). + // Also build up the source line mapping if this is mixed source & + // assembly mode. Calculate the source line for each assembly + // instruction (eliding inlined functions which the user wants to skip). std::map> source_lines_seen; Symbol *previous_symbol = nullptr; @@ -444,12 +443,12 @@ if (cur_line > address_text_size) address_text_size = cur_line; - // Add entries to our "source_lines_seen" map+set which list which - // sources lines occur in this disassembly session. We will print - // lines of context around a source line, but we don't want to print - // a source line that has a line table entry of its own - we'll leave - // that source line to be printed when it actually occurs in the - // disassembly. + // Add entries to our "source_lines_seen" map+set which list + // which sources lines occur in this disassembly session. We + // will print lines of context around a source line, but we + // don't want to print a source line that has a line table entry + // of its own - we'll leave that source line to be printed when + // it actually occurs in the disassembly. if (mixed_source_and_assembly && sc.line_entry.IsValid()) { if (sc.symbol != previous_symbol) { @@ -494,18 +493,16 @@ if (resolved_mask) { if (mixed_source_and_assembly) { - // If we've started a new function (non-inlined), print all of the - // source lines from the - // function declaration until the first line table entry - typically - // the opening curly brace of - // the function. + // If we've started a new function (non-inlined), print all of + // the source lines from the function declaration until the + // first line table entry - typically the opening curly brace + // of the function. if (previous_symbol != sc.symbol) { - // The default disassembly format puts an extra blank line between - // functions - so - // when we're displaying the source context for a function, we - // don't want to add - // a blank line after the source context or we'll end up with two - // of them. + // The default disassembly format puts an extra blank line + // between functions - so when we're displaying the source + // context for a function, we don't want to add a blank line + // after the source context or we'll end up with two of + // them. if (previous_symbol != nullptr) source_lines_to_display.print_source_context_end_eol = false; @@ -542,8 +539,8 @@ current_source_line_range); } - // If we've left a previous source line's address range, print a new - // source line + // If we've left a previous source line's address range, print + // a new source line if (!current_source_line_range.ContainsFileAddress(addr)) { sc.GetAddressRange(scope, 0, use_inline_block_range, current_source_line_range); @@ -555,11 +552,11 @@ if (ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, this_line) == false) { - // Only print this source line if it is different from the - // last source line we printed. There may have been inlined - // functions between these lines that we elided, resulting in - // the same line being printed twice in a row for a contiguous - // block of assembly instructions. + // Only print this source line if it is different from + // the last source line we printed. There may have been + // inlined functions between these lines that we elided, + // resulting in the same line being printed twice in a + // row for a contiguous block of assembly instructions. if (this_line != previous_line) { std::vector previous_lines; @@ -710,9 +707,9 @@ if (show_bytes) { if (m_opcode.GetType() == Opcode::eTypeBytes) { - // x86_64 and i386 are the only ones that use bytes right now so - // pad out the byte dump to be able to always show 15 bytes (3 chars each) - // plus a space + // x86_64 and i386 are the only ones that use bytes right now so pad + // out the byte dump to be able to always show 15 bytes (3 chars + // each) plus a space if (max_opcode_byte_size > 0) m_opcode.Dump(&ss, max_opcode_byte_size * 3 + 1); else @@ -729,9 +726,10 @@ const size_t opcode_pos = ss.GetSizeOfLastLine(); - // The default opcode size of 7 characters is plenty for most architectures - // but some like arm can pull out the occasional vqrshrun.s16. We won't get - // consistent column spacing in these cases, unfortunately. + // The default opcode size of 7 characters is plenty for most + // architectures but some like arm can pull out the occasional + // vqrshrun.s16. We won't get consistent column spacing in these cases, + // unfortunately. if (m_opcode_name.length() >= opcode_column_width) { opcode_column_width = m_opcode_name.length() + 1; } @@ -846,7 +844,8 @@ return option_value_sp; } - // Check to see if the line contains the end-of-dictionary marker ("}") + // Check to see if the line contains the end-of-dictionary marker + // ("}") std::string line(buffer); size_t len = line.size(); @@ -903,7 +902,8 @@ option_value_sp.reset(); return option_value_sp; } - // We've used the data_type to read an array; re-set the type to Invalid + // We've used the data_type to read an array; re-set the type to + // Invalid data_type = OptionValue::eTypeInvalid; } else if ((value[0] == '0') && (value[1] == 'x')) { value_sp = std::make_shared(0, 0); @@ -916,10 +916,9 @@ } if (const_key == encoding_key) { - // A 'data_encoding=..." is NOT a normal key-value pair; it is meta-data - // indicating the - // data type of an upcoming array (usually the next bit of data to be - // read in). + // A 'data_encoding=..." is NOT a normal key-value pair; it is + // meta-data indicating the data type of an upcoming array + // (usually the next bit of data to be read in). if (strcmp(value.c_str(), "uint32_t") == 0) data_type = OptionValue::eTypeUInt64; } else @@ -1107,9 +1106,9 @@ } } - // Hexagon needs the first instruction of the packet with the branch. - // Go backwards until we find an instruction marked end-of-packet, or - // until we hit start. + // Hexagon needs the first instruction of the packet with the branch. Go + // backwards until we find an instruction marked end-of-packet, or until + // we hit start. if (target.GetArchitecture().GetTriple().getArch() == llvm::Triple::hexagon) { // If we didn't find a branch, find the last packet start. if (next_branch == UINT32_MAX) { @@ -1128,8 +1127,8 @@ // If we have an error reading memory, return start if (!error.Success()) return start; - // check if this is the last instruction in a packet - // bits 15:14 will be 11b or 00b for a duplex + // check if this is the last instruction in a packet bits 15:14 will + // be 11b or 00b for a duplex if (((inst_bytes & 0xC000) == 0xC000) || ((inst_bytes & 0xC000) == 0x0000)) { // instruction after this should be the start of next packet Index: source/Core/DumpDataExtractor.cpp =================================================================== --- source/Core/DumpDataExtractor.cpp +++ source/Core/DumpDataExtractor.cpp @@ -328,7 +328,8 @@ s->PutChar(NON_PRINTABLE_CHAR); } - // If we are only printing one character surround it with single quotes + // If we are only printing one character surround it with single + // quotes if (item_count == 1 && item_format == eFormatChar) s->PutChar('\''); } break; @@ -693,9 +694,8 @@ break; // please keep the single-item formats below in sync with - // FormatManager::GetSingleItemFormat - // if you fail to do so, users will start getting different outputs - // depending on internal + // FormatManager::GetSingleItemFormat if you fail to do so, users will + // start getting different outputs depending on internal // implementation details they should not care about || case eFormatVectorOfChar: // || s->PutChar('{'); // \/ Index: source/Core/DynamicLoader.cpp =================================================================== --- source/Core/DynamicLoader.cpp +++ source/Core/DynamicLoader.cpp @@ -86,8 +86,8 @@ executable->GetArchitecture()); auto module_sp = std::make_shared(module_spec); - // Check if the executable has changed and set it to the target executable - // if they differ. + // Check if the executable has changed and set it to the target + // executable if they differ. if (module_sp && module_sp->GetUUID().IsValid() && executable->GetUUID().IsValid()) { if (module_sp->GetUUID() != executable->GetUUID()) @@ -99,8 +99,8 @@ if (!executable) { executable = target.GetSharedModule(module_spec); if (executable.get() != target.GetExecutableModulePointer()) { - // Don't load dependent images since we are in dyld where we will know - // and find out about all images that are loaded + // Don't load dependent images since we are in dyld where we + // will know and find out about all images that are loaded const bool get_dependent_images = false; target.SetExecutableModule(executable, get_dependent_images); } @@ -176,9 +176,9 @@ bool check_alternative_file_name = true; if (base_addr_is_offset) { - // Try to fetch the load address of the file from the process as we need - // absolute load - // address to read the file out of the memory instead of a load bias. + // Try to fetch the load address of the file from the process as we + // need absolute load address to read the file out of the memory + // instead of a load bias. bool is_loaded = false; lldb::addr_t load_addr; Status error = m_process->GetFileLoadAddress(file, is_loaded, load_addr); @@ -188,9 +188,8 @@ } } - // We failed to find the module based on its name. Lets try to check if we can - // find a - // different name based on the memory region info. + // We failed to find the module based on its name. Lets try to check if + // we can find a different name based on the memory region info. if (check_alternative_file_name) { MemoryRegionInfo memory_info; Status error = m_process->GetMemoryRegionInfo(base_addr, memory_info); Index: source/Core/FileSpecList.cpp =================================================================== --- source/Core/FileSpecList.cpp +++ source/Core/FileSpecList.cpp @@ -42,8 +42,7 @@ } //------------------------------------------------------------------ -// Only append the "file_spec" if this list doesn't already contain -// it. +// Only append the "file_spec" if this list doesn't already contain it. // // Returns true if "file_spec" was added, false if this list already // contained a copy of "file_spec". @@ -78,8 +77,8 @@ // Find the index of the file in the file spec list that matches // "file_spec" starting "start_idx" entries into the file spec list. // -// Returns the valid index of the file that matches "file_spec" if -// it is found, else std::numeric_limits::max() is returned. +// Returns the valid index of the file that matches "file_spec" if it is +// found, else std::numeric_limits::max() is returned. //------------------------------------------------------------------ size_t FileSpecList::FindFileIndex(size_t start_idx, const FileSpec &file_spec, bool full, bool remove_dots) const { @@ -106,8 +105,8 @@ } //------------------------------------------------------------------ -// Returns the FileSpec object at index "idx". If "idx" is out of -// range, then an empty FileSpec object will be returned. +// Returns the FileSpec object at index "idx". If "idx" is out of range, +// then an empty FileSpec object will be returned. //------------------------------------------------------------------ const FileSpec &FileSpecList::GetFileSpecAtIndex(size_t idx) const { if (idx < m_files.size()) @@ -123,11 +122,11 @@ } //------------------------------------------------------------------ -// Return the size in bytes that this object takes in memory. This -// returns the size in bytes of this object's member variables and -// any FileSpec objects its member variables contain, the result -// doesn't not include the string values for the directories any -// filenames as those are in shared string pools. +// Return the size in bytes that this object takes in memory. This returns +// the size in bytes of this object's member variables and any FileSpec +// objects its member variables contain, the result doesn't not include +// the string values for the directories any filenames as those are in +// shared string pools. //------------------------------------------------------------------ size_t FileSpecList::MemorySize() const { size_t mem_size = sizeof(FileSpecList); Index: source/Core/FormatEntity.cpp =================================================================== --- source/Core/FormatEntity.cpp +++ source/Core/FormatEntity.cpp @@ -467,10 +467,9 @@ if (sc->function) { func_addr = sc->function->GetAddressRange().GetBaseAddress(); if (sc->block && !concrete_only) { - // Check to make sure we aren't in an inline - // function. If we are, use the inline block - // range that contains "format_addr" since - // blocks can be discontiguous. + // Check to make sure we aren't in an inline function. If we + // are, use the inline block range that contains "format_addr" + // since blocks can be discontiguous. Block *inline_block = sc->block->GetContainingInlinedBlock(); AddressRange inline_range; if (inline_block && @@ -822,8 +821,7 @@ if (do_deref_pointer && !is_array_range) { // I have not deref-ed yet, let's do it // this happens when we are not going through - // GetValueForVariableExpressionPath - // to get to the target ValueObject + // GetValueForVariableExpressionPath to get to the target ValueObject Status error; target = target->Dereference(error).get(); if (error.Fail()) { @@ -842,11 +840,12 @@ return false; } - // we do not want to use the summary for a bitfield of type T:n - // if we were originally dealing with just a T - that would get - // us into an endless recursion + // we do not want to use the summary for a bitfield of type T:n if we + // were originally dealing with just a T - that would get us into an + // endless recursion if (target->IsBitfield() && was_var_indexed) { - // TODO: check for a (T:n)-specific summary - we should still obey that + // TODO: check for a (T:n)-specific summary - we should still obey + // that StreamString bitfield_name; bitfield_name.Printf("%s:%d", target->GetTypeName().AsCString(), target->GetBitfieldBitSize()); @@ -904,16 +903,15 @@ } } - // if directly trying to print ${var}, and this is an aggregate, display a - // nice - // type @ location message + // if directly trying to print ${var}, and this is an aggregate, display + // a nice type @ location message if (is_aggregate && was_plain_var) { s << target->GetTypeName() << " @ " << target->GetLocationAsCString(); return true; } - // if directly trying to print ${var%V}, and this is an aggregate, do not let - // the user do it + // if directly trying to print ${var%V}, and this is an aggregate, do + // not let the user do it if (is_aggregate && ((was_var_format && val_obj_display == @@ -1113,11 +1111,14 @@ switch (entry.type) { case Entry::Type::Invalid: case Entry::Type::ParentNumber: // Only used for - // FormatEntity::Entry::Definition encoding + // FormatEntity::Entry::Definition + // encoding case Entry::Type::ParentString: // Only used for - // FormatEntity::Entry::Definition encoding + // FormatEntity::Entry::Definition + // encoding case Entry::Type::InsertString: // Only used for - // FormatEntity::Entry::Definition encoding + // FormatEntity::Entry::Definition + // encoding return false; case Entry::Type::Root: @@ -1142,8 +1143,8 @@ if (!success) break; } - // Only if all items in a scope succeed, then do we - // print the output into the main stream + // Only if all items in a scope succeed, then do we print the output + // into the main stream if (success) s.Write(scope_stream.GetString().data(), scope_stream.GetString().size()); } @@ -1206,9 +1207,9 @@ // Watch for the special "tid" format... if (entry.printf_format == "tid") { // TODO(zturner): Rather than hardcoding this to be platform - // specific, it should be controlled by a - // setting and the default value of the setting can be different - // depending on the platform. + // specific, it should be controlled by a setting and the + // default value of the setting can be different depending on + // the platform. Target &target = thread->GetProcess()->GetTarget(); ArchSpec arch(target.GetArchitecture()); llvm::Triple::OSType ostype = arch.IsValid() @@ -1644,9 +1645,9 @@ const char *open_paren = strchr(cstr, '('); const char *close_paren = nullptr; const char *generic = strchr(cstr, '<'); - // if before the arguments list begins there is a template sign - // then scan to the end of the generic args before you try to find - // the arguments list + // if before the arguments list begins there is a template + // sign then scan to the end of the generic args before you + // try to find the arguments list if (generic && open_paren && generic < open_paren) { int generic_depth = 1; ++generic; @@ -1913,10 +1914,10 @@ DumpCommaSeparatedChildEntryNames(error_strm, entry_def); error.SetErrorStringWithFormat("%s", error_strm.GetData()); } else if (sep_char == ':') { - // Any value whose separator is a with a ':' means this value has a - // string argument - // that needs to be stored in the entry (like "${script.var:}"). - // In this case the string value is the empty string which is ok. + // Any value whose separator is a with a ':' means this value + // has a string argument that needs to be stored in the entry + // (like "${script.var:}"). In this case the string value is + // the empty string which is ok. } else { error.SetErrorStringWithFormat("%s", "invalid entry definitions"); } @@ -1925,10 +1926,9 @@ if (entry_def->children) { error = ParseEntry(value, entry_def, entry); } else if (sep_char == ':') { - // Any value whose separator is a with a ':' means this value has a - // string argument - // that needs to be stored in the entry (like - // "${script.var:modulename.function}") + // Any value whose separator is a with a ':' means this value + // has a string argument that needs to be stored in the entry + // (like "${script.var:modulename.function}") entry.string = value.str(); } else { error.SetErrorStringWithFormat( @@ -1990,14 +1990,15 @@ const size_t non_special_chars = format.find_first_of("${}\\"); if (non_special_chars == llvm::StringRef::npos) { - // No special characters, just string bytes so add them and we are done + // No special characters, just string bytes so add them and we are + // done parent_entry.AppendText(format); return error; } if (non_special_chars > 0) { - // We have a special character, so add all characters before these as a - // plain string + // We have a special character, so add all characters before these + // as a plain string parent_entry.AppendText(format.substr(0, non_special_chars)); format = format.drop_front(non_special_chars); } @@ -2065,17 +2066,17 @@ case '0': // 1 to 3 octal chars { - // Make a string that can hold onto the initial zero char, - // up to 3 octal digits, and a terminating NULL. + // Make a string that can hold onto the initial zero char, up to + // 3 octal digits, and a terminating NULL. char oct_str[5] = {0, 0, 0, 0, 0}; int i; for (i = 0; (format[i] >= '0' && format[i] <= '7') && i < 4; ++i) oct_str[i] = format[i]; - // We don't want to consume the last octal character since - // the main for loop will do this for us, so we advance p by - // one less than i (even if i is zero) + // We don't want to consume the last octal character since the + // main for loop will do this for us, so we advance p by one + // less than i (even if i is zero) format = format.drop_front(i); unsigned long octal_value = ::strtoul(oct_str, nullptr, 8); if (octal_value <= UINT8_MAX) { @@ -2090,8 +2091,8 @@ case 'x': // hex number in the format if (isxdigit(format[0])) { - // Make a string that can hold onto two hex chars plus a - // NULL terminator + // Make a string that can hold onto two hex chars plus a NULL + // terminator char hex_str[3] = {0, 0, 0}; hex_str[0] = format[0]; @@ -2115,8 +2116,8 @@ break; default: - // Just desensitize any other character by just printing what - // came after the '\' + // Just desensitize any other character by just printing what came + // after the '\' parent_entry.AppendChar(desens_char); break; } @@ -2143,13 +2144,12 @@ entry.printf_format = variable_format.str(); // If the format contains a '%' we are going to assume this is - // a printf style format. So if you want to format your thread ID - // using "0x%llx" you can use: - // ${thread.id%0x%llx} + // a printf style format. So if you want to format your thread + // ID using "0x%llx" you can use: ${thread.id%0x%llx} // - // If there is no '%' in the format, then it is assumed to be a - // LLDB format name, or one of the extended formats specified in - // the switch statement below. + // If there is no '%' in the format, then it is assumed to be + // a LLDB format name, or one of the extended formats + // specified in the switch statement below. if (entry.printf_format.find('%') == std::string::npos) { bool clear_printf = false; @@ -2217,8 +2217,8 @@ return error; } - // Our format string turned out to not be a printf style format - // so lets clear the string + // Our format string turned out to not be a printf style + // format so lets clear the string if (clear_printf) entry.printf_format.clear(); } @@ -2255,8 +2255,8 @@ } break; default: - // Make sure someone didn't try to dereference anything but ${var} - // or ${svar} + // Make sure someone didn't try to dereference anything but + // ${var} or ${svar} if (entry.deref) { error.SetErrorStringWithFormat( "${%s} can't be dereferenced, only ${var} and ${svar} can.", Index: source/Core/IOHandler.cpp =================================================================== --- source/Core/IOHandler.cpp +++ source/Core/IOHandler.cpp @@ -91,7 +91,8 @@ : m_debugger(debugger), m_input_sp(input_sp), m_output_sp(output_sp), m_error_sp(error_sp), m_popped(false), m_flags(flags), m_type(type), m_user_data(nullptr), m_done(false), m_active(false) { - // If any files are not specified, then adopt them from the top input reader. + // If any files are not specified, then adopt them from the top input + // reader. if (!m_input_sp || !m_output_sp || !m_error_sp) debugger.AdoptTopIOHandlerFilesIfInvalid(m_input_sp, m_output_sp, m_error_sp); @@ -256,8 +257,8 @@ matches.LongestCommonPrefix(common_prefix); const size_t partial_name_len = strlen(word_start); - // If we matched a unique single command, add a space... - // Only do this if the completer told us this was a complete word, + // If we matched a unique single command, add a space... Only do + // this if the completer told us this was a complete word, // however... if (num_matches == 1 && word_complete) { common_prefix.push_back(' '); @@ -321,8 +322,8 @@ const char *indent_chars = delegate.IOHandlerGetFixIndentationCharacters(); if (indent_chars) { // The delegate does support indentation, hook it up so when any - // indentation - // character is typed, the delegate gets a chance to fix it + // indentation character is typed, the delegate gets a chance to fix + // it m_editline_ap->SetFixIndentationCallback(FixIndentationCallback, this, indent_chars); } @@ -408,8 +409,8 @@ } } m_editing = false; - // We might have gotten a newline on a line by itself - // make sure to return true in this case. + // We might have gotten a newline on a line by itself make sure to + // return true in this case. return got_line; } else { // No more input file, we are done... @@ -545,9 +546,8 @@ return success; } -// Each IOHandler gets to run until it is done. It should read data -// from the "in" and place output into "out" and "err and return -// when done. +// Each IOHandler gets to run until it is done. It should read data from +// the "in" and place output into "out" and "err and return when done. void IOHandlerEditline::Run() { std::string line; while (IsActive()) { @@ -635,8 +635,7 @@ } } -// we may want curses to be disabled for some builds -// for instance, windows +// we may want curses to be disabled for some builds for instance, windows #ifndef LLDB_DISABLE_CURSES #define KEY_RETURN 10 @@ -738,9 +737,9 @@ origin.y += h; } - // Return a status bar rectangle which is the last line of - // this rectangle. This rectangle will be modified to not - // include the status bar area. + // Return a status bar rectangle which is the last line of this + // rectangle. This rectangle will be modified to not include the status + // bar area. Rect MakeStatusBar() { Rect status_bar; if (size.height > 1) { @@ -753,9 +752,8 @@ return status_bar; } - // Return a menubar rectangle which is the first line of - // this rectangle. This rectangle will be modified to not - // include the menubar area. + // Return a menubar rectangle which is the first line of this rectangle. + // This rectangle will be modified to not include the menubar area. Rect MakeMenuBar() { Rect menubar; if (size.height > 1) { @@ -1204,12 +1202,10 @@ return result; } - // Then check for any windows that want any keys - // that weren't handled. This is typically only - // for a menubar. - // Make a copy of the subwindows in case any HandleChar() - // functions muck with the subwindows. If we don't do this, - // we can crash when iterating over the subwindows. + // Then check for any windows that want any keys that weren't handled. + // This is typically only for a menubar. Make a copy of the subwindows + // in case any HandleChar() functions muck with the subwindows. If we + // don't do this, we can crash when iterating over the subwindows. Windows subwindows(m_subwindows); for (auto subwindow_sp : subwindows) { if (!subwindow_sp->m_can_activate) { @@ -1245,7 +1241,8 @@ m_prev_active_window_idx = UINT32_MAX; m_curr_active_window_idx = UINT32_MAX; - // Find first window that wants to be active if this window is active + // 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) { if (m_subwindows[i]->GetCanBeActive()) { @@ -1396,8 +1393,8 @@ } MenuActionResult Action() { - // Call the recursive action so it can try to handle it - // with the menu delegate, and if not, try our parent menu + // Call the recursive action so it can try to handle it with the menu + // delegate, and if not, try our parent menu return ActionPrivate(*this); } @@ -1666,9 +1663,9 @@ } if (run_menu_sp) { - // Run the action on this menu in case we need to populate the - // menu with dynamic content and also in case check marks, and - // any other menu decorations need to be calculated + // Run the action on this menu in case we need to populate the menu + // with dynamic content and also in case check marks, and any other + // menu decorations need to be calculated if (run_menu_sp->Action() == MenuActionResult::Quit) return eQuitApplication; @@ -1784,10 +1781,10 @@ // Alas the threading model in curses is a bit lame so we need to // resort to polling every 0.5 seconds. We could poll for stdin - // ourselves and then pass the keys down but then we need to - // translate all of the escape sequences ourselves. So we resort to - // polling for input because we need to receive async process events - // while in this loop. + // ourselves and then pass the keys down but then we need to translate + // all of the escape sequences ourselves. So we resort to polling for + // input because we need to receive async process events while in this + // loop. halfdelay(delay_in_tenths_of_a_second); // Poll using some number of tenths // of seconds seconds when calling @@ -1809,12 +1806,12 @@ if (update) { m_window_sp->Draw(false); // All windows should be calling Window::DeferredRefresh() instead - // of Window::Refresh() so we can do a single update and avoid - // any screen blinking + // of Window::Refresh() so we can do a single update and avoid any + // screen blinking update_panels(); - // Cursor hiding isn't working on MacOSX, so hide it in the top left - // corner + // Cursor hiding isn't working on MacOSX, so hide it in the top + // left corner m_window_sp->MoveCursor(0, 0); doupdate(); @@ -1822,9 +1819,9 @@ } #if defined(__APPLE__) - // Terminal.app doesn't map its function keys correctly, F1-F4 default to: - // \033OP, \033OQ, \033OR, \033OS, so lets take care of this here if - // possible + // Terminal.app doesn't map its function keys correctly, F1-F4 + // default to: \033OP, \033OQ, \033OR, \033OS, so lets take care of + // this here if possible int ch; if (escape_chars.empty()) ch = m_window_sp->GetChar(); @@ -1986,8 +1983,8 @@ parent->DrawTreeForChild(window, this, 0); if (might_have_children) { - // It we can get UTF8 characters to work we should try to use the "symbol" - // UTF8 string below + // It we can get UTF8 characters to work we should try to use the + // "symbol" UTF8 string below // const char *symbol = ""; // if (row.expanded) // symbol = "\xe2\x96\xbd "; @@ -1995,8 +1992,8 @@ // symbol = "\xe2\x96\xb7 "; // window.PutCString (symbol); - // The ACS_DARROW and ACS_RARROW don't look very nice they are just a - // 'v' or '>' character... + // The ACS_DARROW and ACS_RARROW don't look very nice they are just + // a 'v' or '>' character... // if (expanded) // window.PutChar (ACS_DARROW); // else @@ -2102,9 +2099,8 @@ const bool expanded = IsExpanded(); - // The root item must calculate its children, - // or we must calculate the number of children - // if the item is expanded + // The root item must calculate its children, or we must calculate the + // number of children if the item is expanded if (m_parent == nullptr || expanded) GetNumChildren(); @@ -2137,8 +2133,7 @@ if (m_might_have_children) { // It we can get UTF8 characters to work we should try to use the - // "symbol" - // UTF8 string below + // "symbol" UTF8 string below // const char *symbol = ""; // if (row.expanded) // symbol = "\xe2\x96\xbd "; @@ -2146,8 +2141,8 @@ // symbol = "\xe2\x96\xb7 "; // window.PutCString (symbol); - // The ACS_DARROW and ACS_RARROW don't look very nice they are just a - // 'v' or '>' character... + // The ACS_DARROW and ACS_RARROW don't look very nice they are + // just a 'v' or '>' character... // if (expanded) // window.PutChar (ACS_DARROW); // else @@ -2176,8 +2171,8 @@ if (IsExpanded()) { for (auto &item : m_children) { - // If we displayed all the rows and item.Draw() returns - // false we are done drawing and can exit this for loop + // 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)) break; @@ -2287,10 +2282,9 @@ m_num_rows = 0; m_root.CalculateRowIndexes(m_num_rows); - // If we unexpanded while having something selected our - // total number of rows is less than the num visible rows, - // then make sure we show all the rows by setting the first - // visible row accordingly. + // If we unexpanded while having something selected our total number + // of rows is less than the num visible rows, then make sure we show + // all the rows by setting the first visible row accordingly. if (m_first_visible_row > 0 && m_num_rows < num_visible_rows) m_first_visible_row = 0; @@ -2696,10 +2690,9 @@ const int num_visible_rows = NumVisibleRows(); const int num_rows = CalculateTotalNumberRows(m_rows); - // If we unexpanded while having something selected our - // total number of rows is less than the num visible rows, - // then make sure we show all the rows by setting the first - // visible row accordingly. + // If we unexpanded while having something selected our total number + // of rows is less than the num visible rows, then make sure we show + // all the rows by setting the first visible row accordingly. if (m_first_visible_row > 0 && num_rows < num_visible_rows) m_first_visible_row = 0; @@ -3128,8 +3121,8 @@ if (process && process->IsAlive()) return true; // Don't do any updating if we are running else { - // Update the values with an empty list if there - // is no process or the process isn't alive anymore + // Update the values with an empty list if there is no process or + // the process isn't alive anymore SetValues(value_list); } } @@ -3393,8 +3386,8 @@ if (num_lines <= num_visible_lines) { done = true; - // If we have all lines visible and don't need scrolling, then any - // key press will cause us to exit + // If we have all lines visible and don't need scrolling, then any key + // press will cause us to exit } else { switch (key) { case KEY_UP: @@ -3606,9 +3599,9 @@ return MenuActionResult::Handled; case eMenuID_Process: { - // Populate the menu with all of the threads if the process is stopped - // when - // the Process menu gets selected and is about to display its submenu. + // Populate the menu with all of the threads if the process is + // stopped when the Process menu gets selected and is about to + // display its submenu. Menus &submenus = menu.GetSubmenus(); ExecutionContext exe_ctx = m_debugger.GetCommandInterpreter().GetExecutionContext(); @@ -3643,12 +3636,12 @@ nullptr, menu_char, thread_sp->GetID()))); } } else if (submenus.size() > 7) { - // Remove the separator and any other thread submenu items - // that were previously added + // Remove the separator and any other thread submenu items that + // were previously added submenus.erase(submenus.begin() + 7, submenus.end()); } - // Since we are adding and removing items we need to recalculate the name - // lengths + // Since we are adding and removing items we need to recalculate the + // name lengths menu.RecalculateNameLengths(); } return MenuActionResult::Handled; @@ -3672,8 +3665,8 @@ registers_bounds.size.width = source_bounds.size.width; registers_window_sp->SetBounds(registers_bounds); } else { - // We have no registers window showing so give the bottom - // area back to the source view + // We have no registers window showing so give the bottom area + // back to the source view source_window_sp->Resize(source_bounds.size.width, source_bounds.size.height + variables_bounds.size.height); @@ -3690,7 +3683,8 @@ new_registers_rect); registers_window_sp->SetBounds(new_registers_rect); } else { - // No variables window, grab the bottom part of the source window + // No variables window, grab the bottom part of the source + // window Rect new_source_rect; source_bounds.HorizontalSplitPercentage(0.70, new_source_rect, new_variables_rect); @@ -3722,8 +3716,8 @@ registers_window_sp->GetWidth(), variables_bounds.size.height); } else { - // We have no variables window showing so give the bottom - // area back to the source view + // We have no variables window showing so give the bottom area + // back to the source view source_window_sp->Resize(source_bounds.size.width, source_bounds.size.height + registers_window_sp->GetHeight()); @@ -3732,16 +3726,17 @@ } else { Rect new_regs_rect; if (variables_window_sp) { - // We have a variables window, split it into two columns - // where the left hand side will be the variables and the - // right hand side will be the registers + // We have a variables window, split it into two columns where + // the left hand side will be the variables and the right hand + // side will be the registers const Rect variables_bounds = variables_window_sp->GetBounds(); Rect new_vars_rect; variables_bounds.VerticalSplitPercentage(0.50, new_vars_rect, new_regs_rect); variables_window_sp->SetBounds(new_vars_rect); } else { - // No registers window, grab the bottom part of the source window + // No registers window, grab the bottom part of the source + // window Rect new_source_rect; source_bounds.HorizontalSplitPercentage(0.70, new_source_rect, new_regs_rect); @@ -3946,8 +3941,8 @@ m_selected_line = m_pc_line; if (m_file_sp && m_file_sp->FileSpecMatches(m_sc.line_entry.file)) { - // Same file, nothing to do, we should either have the - // lines or not (source file missing) + // Same file, nothing to do, we should either have the lines + // or not (source file missing) if (m_selected_line >= static_cast(m_first_visible_line)) { if (m_selected_line >= m_first_visible_line + num_visible_lines) m_first_visible_line = m_selected_line - 10; @@ -4071,8 +4066,8 @@ window.MoveCursor(1, line_y); const bool is_pc_line = curr_line == m_pc_line; const bool line_is_selected = m_selected_line == curr_line; - // Highlight the line as the PC line first, then if the selected line - // isn't the same as the PC line, highlight it differently + // Highlight the line as the PC line first, then if the selected + // line isn't the same as the PC line, highlight it differently attr_t highlight_attr = 0; attr_t bp_attr = 0; if (is_pc_line) @@ -4116,8 +4111,8 @@ size_t stop_description_len = strlen(stop_description); int desc_x = window_width - stop_description_len - 16; window.Printf("%*s", desc_x - window.GetCursorX(), ""); - // window.MoveCursor(window_width - stop_description_len - 15, - // line_y); + // window.MoveCursor(window_width - stop_description_len - + // 15, line_y); window.Printf("<<< Thread %u: %s ", thread->GetIndexID(), stop_description); } @@ -4196,8 +4191,8 @@ window.MoveCursor(1, line_y); const bool is_pc_line = frame_sp && inst_idx == pc_idx; const bool line_is_selected = m_selected_line == inst_idx; - // Highlight the line as the PC line first, then if the selected line - // isn't the same as the PC line, highlight it differently + // Highlight the line as the PC line first, then if the selected + // line isn't the same as the PC line, highlight it differently attr_t highlight_attr = 0; attr_t bp_attr = 0; if (is_pc_line) @@ -4263,8 +4258,8 @@ size_t stop_description_len = strlen(stop_description); int desc_x = window_width - stop_description_len - 16; window.Printf("%*s", desc_x - window.GetCursorX(), ""); - // window.MoveCursor(window_width - stop_description_len - 15, - // line_y); + // window.MoveCursor(window_width - stop_description_len - + // 15, line_y); window.Printf("<<< Thread %u: %s ", thread->GetIndexID(), stop_description); } @@ -4656,7 +4651,8 @@ status_window_sp->SetDelegate( WindowDelegateSP(new StatusBarWindowDelegate(m_debugger))); - // Show the main help window once the first time the curses GUI is launched + // Show the main help window once the first time the curses GUI is + // launched static bool g_showed_help = false; if (!g_showed_help) { g_showed_help = true; Index: source/Core/Listener.cpp =================================================================== --- source/Core/Listener.cpp +++ source/Core/Listener.cpp @@ -270,9 +270,8 @@ uint32_t num_broadcaster_names, uint32_t event_type_mask, EventSP &event_sp, bool remove) { // NOTE: callers of this function must lock m_events_mutex using a - // Mutex::Locker - // and pass the locker as the first argument. m_events_mutex is no longer - // recursive. + // Mutex::Locker and pass the locker as the first argument. + // m_events_mutex is no longer recursive. Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS)); if (m_events.empty()) @@ -304,11 +303,10 @@ if (remove) { m_events.erase(pos); - // Unlock the event queue here. We've removed this event and are about to - // return - // it so it should be okay to get the next event off the queue here - and - // it might - // be useful to do that in the "DoOnRemoval". + // Unlock the event queue here. We've removed this event and are + // about to return it so it should be okay to get the next event off + // the queue here - and it might be useful to do that in the + // "DoOnRemoval". lock.unlock(); event_sp->DoOnRemoval(); } @@ -434,8 +432,9 @@ if (!manager_sp) return 0; - // The BroadcasterManager mutex must be locked before m_broadcasters_mutex - // to avoid violating the lock hierarchy (manager before broadcasters). + // The BroadcasterManager mutex must be locked before + // m_broadcasters_mutex to avoid violating the lock hierarchy (manager + // before broadcasters). std::lock_guard manager_guard( manager_sp->m_manager_mutex); std::lock_guard guard(m_broadcasters_mutex); Index: source/Core/Mangled.cpp =================================================================== --- source/Core/Mangled.cpp +++ source/Core/Mangled.cpp @@ -17,8 +17,8 @@ #endif #ifdef LLDB_USE_BUILTIN_DEMANGLER -// Provide a fast-path demangler implemented in FastDemangle.cpp until it can -// replace the existing C++ demangler with a complete implementation +// Provide a fast-path demangler implemented in FastDemangle.cpp until it +// can replace the existing C++ demangler with a complete implementation #include "lldb/Utility/FastDemangle.h" #include "llvm/Demangle/Demangle.h" #else @@ -85,15 +85,14 @@ static const ConstString & get_demangled_name_without_arguments(ConstString mangled, ConstString demangled) { - // This pair is + // This pair is static std::pair g_most_recent_mangled_to_name_sans_args; - // Need to have the mangled & demangled names we're currently examining as - // statics - // so we can return a const ref to them at the end of the func if we don't - // have - // anything better. + // Need to have the mangled & demangled names we're currently examining + // as statics so we can return a const ref to them at the end of the + // func if we don't have anything better. static ConstString g_last_mangled; static ConstString g_last_demangled; @@ -184,8 +183,8 @@ } //---------------------------------------------------------------------- -// Logical NOT operator. This allows code to check any Mangled -// objects to see if they are invalid using code such as: +// Logical NOT operator. This allows code to check any Mangled objects to +// see if they are invalid using code such as: // // Mangled mangled(...); // if (!file_spec) @@ -211,9 +210,9 @@ } //---------------------------------------------------------------------- -// Set the string value in this objects. If "mangled" is true, then -// the mangled named is set with the new value in "s", else the -// demangled name is set. +// Set the string value in this objects. If "mangled" is true, then the +// mangled named is set with the new value in "s", else the demangled name +// is set. //---------------------------------------------------------------------- void Mangled::SetValue(const ConstString &s, bool mangled) { if (s) { @@ -246,16 +245,16 @@ } //---------------------------------------------------------------------- -// Generate the demangled name on demand using this accessor. Code in -// this class will need to use this accessor if it wishes to decode -// the demangled name. The result is cached and will be kept until a -// new string value is supplied to this object, or until the end of the +// Generate the demangled name on demand using this accessor. Code in this +// class will need to use this accessor if it wishes to decode the +// demangled name. The result is cached and will be kept until a new +// string value is supplied to this object, or until the end of the // object's lifetime. //---------------------------------------------------------------------- const ConstString & Mangled::GetDemangledName(lldb::LanguageType language) const { - // Check to make sure we have a valid mangled name and that we - // haven't already decoded our mangled name. + // Check to make sure we have a valid mangled name and that we haven't + // already decoded our mangled name. if (m_mangled && !m_demangled) { // We need to generate and cache the demangled name. static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); @@ -269,8 +268,8 @@ ManglingScheme mangling_scheme{cstring_mangling_scheme(mangled_name)}; if (mangling_scheme != eManglingSchemeNone && !m_mangled.GetMangledCounterpart(m_demangled)) { - // We didn't already mangle this name, demangle it and if all goes well - // add it to our map. + // We didn't already mangle this name, demangle it and if all goes + // well add it to our map. char *demangled_name = nullptr; switch (mangling_scheme) { case eManglingSchemeMSVC: { @@ -302,9 +301,8 @@ #ifdef LLDB_USE_BUILTIN_DEMANGLER if (log) log->Printf("demangle itanium: %s", mangled_name); - // Try to use the fast-path demangler first for the - // performance win, falling back to the full demangler only - // when necessary + // Try to use the fast-path demangler first for the performance + // win, falling back to the full demangler only when necessary demangled_name = FastDemangle(mangled_name, m_mangled.GetLength()); if (!demangled_name) demangled_name = @@ -331,8 +329,8 @@ } } if (!m_demangled) { - // Set the demangled string to the empty string to indicate we - // tried to parse it once and failed. + // Set the demangled string to the empty string to indicate we tried + // to parse it once and failed. m_demangled.SetCString(""); } } @@ -370,8 +368,8 @@ return get_demangled_name_without_arguments(m_mangled, demangled); } if (preference == ePreferDemangled) { - // Call the accessor to make sure we get a demangled name in case - // it hasn't been demangled yet... + // Call the accessor to make sure we get a demangled name in case it + // hasn't been demangled yet... if (demangled) return demangled; return m_mangled; @@ -380,8 +378,8 @@ } //---------------------------------------------------------------------- -// Dump a Mangled object to stream "s". We don't force our -// demangled name to be computed currently (we don't use the accessor). +// Dump a Mangled object to stream "s". We don't force our demangled name +// to be computed currently (we don't use the accessor). //---------------------------------------------------------------------- void Mangled::Dump(Stream *s) const { if (m_mangled) { @@ -407,8 +405,8 @@ //---------------------------------------------------------------------- // Return the size in byte that this object takes in memory. The size -// includes the size of the objects it owns, and not the strings that -// it references because they are shared strings. +// includes the size of the objects it owns, and not the strings that it +// references because they are shared strings. //---------------------------------------------------------------------- size_t Mangled::MemorySize() const { return m_mangled.MemorySize() + m_demangled.MemorySize(); @@ -433,8 +431,8 @@ return lldb::eLanguageTypeObjC; } } else { - // ObjC names aren't really mangled, so they won't necessarily be in the - // mangled name slot. + // ObjC names aren't really mangled, so they won't necessarily be in + // the mangled name slot. ConstString demangled_name = GetDemangledName(lldb::eLanguageTypeUnknown); if (demangled_name && ObjCLanguage::IsPossibleObjCMethodName(demangled_name.GetCString())) Index: source/Core/Module.cpp =================================================================== --- source/Core/Module.cpp +++ source/Core/Module.cpp @@ -79,21 +79,18 @@ using namespace lldb; using namespace lldb_private; -// Shared pointers to modules track module lifetimes in -// targets and in the global module, but this collection -// will track all module objects that are still alive +// Shared pointers to modules track module lifetimes in targets and in the +// global module, but this collection will track all module objects that +// are still alive typedef std::vector ModuleCollection; static ModuleCollection &GetModuleCollection() { - // This module collection needs to live past any module, so we could either - // make it a - // shared pointer in each module or just leak is. Since it is only an empty - // vector by - // the time all the modules have gone away, we just leak it for now. If we - // decide this - // is a big problem we can introduce a Finalize method that will tear - // everything down in - // a predictable order. + // This module collection needs to live past any module, so we could + // either make it a shared pointer in each module or just leak is. + // Since it is only an empty vector by the time all the modules have + // gone away, we just leak it for now. If we decide this is a big + // problem we can introduce a Finalize method that will tear everything + // down in a predictable order. static ModuleCollection *g_module_collection = nullptr; if (g_module_collection == nullptr) @@ -105,8 +102,8 @@ std::recursive_mutex &Module::GetAllocationModuleCollectionMutex() { // NOTE: The mutex below must be leaked since the global module list in // the ModuleList class will get torn at some point, and we can't know - // 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 + // 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 std::recursive_mutex *g_module_collection_mutex = nullptr; if (g_module_collection_mutex == nullptr) @@ -152,20 +149,19 @@ module_spec.GetObjectName().IsEmpty() ? "" : ")"); // First extract all module specifications from the file using the local - // file path. If there are no specifications, then don't fill anything in + // file path. If there are no specifications, then don't fill anything + // in ModuleSpecList modules_specs; if (ObjectFile::GetModuleSpecifications(module_spec.GetFileSpec(), 0, 0, modules_specs) == 0) return; - // Now make sure that one of the module specifications matches what we just - // extract. We might have a module specification that specifies a file - // "/usr/lib/dyld" - // with UUID XXX, but we might have a local version of "/usr/lib/dyld" that - // has - // UUID YYY and we don't want those to match. If they don't match, just don't - // fill any ivars in so we don't accidentally grab the wrong file later since - // they don't match... + // Now make sure that one of the module specifications matches what we + // just extract. We might have a module specification that specifies a + // file "/usr/lib/dyld" with UUID XXX, but we might have a local version + // of "/usr/lib/dyld" that has UUID YYY and we don't want those to + // match. If they don't match, just don't fill any ivars in so we don't + // accidentally grab the wrong file later since they don't match... ModuleSpec matching_module_spec; if (modules_specs.FindMatchingModuleSpec(module_spec, matching_module_spec) == 0) @@ -177,15 +173,15 @@ m_mod_time = FileSystem::GetModificationTime(matching_module_spec.GetFileSpec()); - // Copy the architecture from the actual spec if we got one back, else use the - // one that was specified + // Copy the architecture from the actual spec if we got one back, else + // use the one that was specified if (matching_module_spec.GetArchitecture().IsValid()) m_arch = matching_module_spec.GetArchitecture(); else if (module_spec.GetArchitecture().IsValid()) m_arch = module_spec.GetArchitecture(); - // Copy the file spec over and use the specified one (if there was one) so we - // don't use a path that might have gotten resolved a path in + // Copy the file spec over and use the specified one (if there was one) + // so we don't use a path that might have gotten resolved a path in // 'matching_module_spec' if (module_spec.GetFileSpec()) m_file = module_spec.GetFileSpec(); @@ -253,8 +249,8 @@ } Module::~Module() { - // Lock our module down while we tear everything down to make sure - // we don't get any access to the module while it is being destroyed + // Lock our module down while we tear everything down to make sure we + // don't get any access to the module while it is being destroyed std::lock_guard guard(m_mutex); // Scope for locker below... { @@ -276,9 +272,9 @@ m_object_name.IsEmpty() ? "" : ")"); // Release any auto pointers before we start tearing down our member // variables since the object file and symbol files might need to make - // function calls back into this module object. The ordering is important - // here because symbol files can require the module object file. So we tear - // down the symbol file first, then the object file. + // function calls back into this module object. The ordering is + // important here because symbol files can require the module object + // file. So we tear down the symbol file first, then the object file. m_sections_ap.reset(); m_symfile_ap.reset(); m_objfile_sp.reset(); @@ -307,10 +303,9 @@ s.Printf("0x%16.16" PRIx64, header_addr); m_object_name.SetString(s.GetString()); - // Once we get the object file, update our module with the object - // file's - // architecture since it might differ in vendor/os if some parts were - // unknown. + // Once we get the object file, update our module with the + // object file's architecture since it might differ in vendor/os + // if some parts were unknown. m_objfile_sp->GetArchitecture(m_arch); } else { error.SetErrorString("unable to find suitable object file plug-in"); @@ -432,17 +427,18 @@ std::lock_guard guard(m_mutex); uint32_t resolved_flags = 0; - // Clear the result symbol context in case we don't find anything, but don't - // clear the target + // Clear the result symbol context in case we don't find anything, but + // don't clear the target sc.Clear(false); // Get the section from the section/offset address. SectionSP section_sp(so_addr.GetSection()); - // Make sure the section matches this module before we try and match anything + // Make sure the section matches this module before we try and match + // anything if (section_sp && section_sp->GetModule().get() == this) { - // If the section offset based address resolved itself, then this - // is the right module. + // If the section offset based address resolved itself, then this is + // the right module. sc.module_sp = shared_from_this(); resolved_flags |= eSymbolContextModule; @@ -450,8 +446,8 @@ if (!sym_vendor) return resolved_flags; - // Resolve the compile unit, function, block, line table or line - // entry if requested. + // Resolve the compile unit, function, block, line table or line entry + // if requested. if (resolve_scope & eSymbolContextCompUnit || resolve_scope & eSymbolContextFunction || resolve_scope & eSymbolContextBlock || @@ -461,8 +457,8 @@ sym_vendor->ResolveSymbolContext(so_addr, resolve_scope, sc); } - // Resolve the symbol if requested, but don't re-look it up if we've already - // found it. + // Resolve the symbol if requested, but don't re-look it up if we've + // already found it. if (resolve_scope & eSymbolContextSymbol && !(resolved_flags & eSymbolContextSymbol)) { Symtab *symtab = sym_vendor->GetSymtab(); @@ -494,9 +490,9 @@ // We have a synthetic symbol so lets check if the object file // from the symbol file in the symbol vendor is different than // the object file for the module, and if so search its symbol - // table to see if we can come up with a better symbol. For example - // dSYM files on MacOSX have an unstripped symbol table inside of - // them. + // table to see if we can come up with a better symbol. For + // example dSYM files on MacOSX have an unstripped symbol + // table inside of them. ObjectFile *symtab_objfile = symtab->GetObjectFile(); if (symtab_objfile && symtab_objfile->IsStripped()) { SymbolFile *symfile = sym_vendor->GetSymbolFile(); @@ -521,11 +517,10 @@ } } - // For function symbols, so_addr may be off by one. This is a convention - // consistent - // with FDE row indices in eh_frame sections, but requires extra logic here - // to permit - // symbol lookup for disassembly and unwind. + // For function symbols, so_addr may be off by one. This is a + // convention consistent with FDE row indices in eh_frame sections, + // but requires extra logic here to permit symbol lookup for + // disassembly and unwind. if (resolve_scope & eSymbolContextSymbol && !(resolved_flags & eSymbolContextSymbol) && resolve_tail_call_address && so_addr.IsSectionOffset()) { @@ -542,9 +537,8 @@ if (addr_range.GetBaseAddress().GetSection() == so_addr.GetSection()) { // If the requested address is one past the address range of a - // function (i.e. a tail call), - // or the decremented address is the start of a function (i.e. some - // forms of trampoline), + // function (i.e. a tail call), or the decremented address is + // the start of a function (i.e. some forms of trampoline), // indicate that the symbol has been resolved. if (so_addr.GetOffset() == addr_range.GetBaseAddress().GetOffset() || @@ -676,26 +670,24 @@ m_name_type_mask = name_type_mask; if (name_type_mask & eFunctionNameTypeMethod || name_type_mask & eFunctionNameTypeBase) { - // If they've asked for a CPP method or function name and it can't be - // that, we don't - // even need to search for CPP methods or names. + // If they've asked for a CPP method or function name and it can't + // be that, we don't even need to search for CPP methods or names. CPlusPlusLanguage::MethodName cpp_method(name); if (cpp_method.IsValid()) { basename = cpp_method.GetBasename(); if (!cpp_method.GetQualifiers().empty()) { - // There is a "const" or other qualifier following the end of the - // function parens, - // this can't be a eFunctionNameTypeBase + // There is a "const" or other qualifier following the end of + // the function parens, this can't be a eFunctionNameTypeBase m_name_type_mask &= ~(eFunctionNameTypeBase); if (m_name_type_mask == eFunctionNameTypeNone) return; } } else { - // If the CPP method parser didn't manage to chop this up, try to fill - // in the base name if we can. - // If a::b::c is passed in, we need to just look up "c", and then we'll - // filter the result later. + // If the CPP method parser didn't manage to chop this up, try to + // fill in the base name if we can. If a::b::c is passed in, we + // need to just look up "c", and then we'll filter the result + // later. CPlusPlusLanguage::ExtractContextAndIdentifier(name_cstr, context, basename); } @@ -709,8 +701,8 @@ } } - // Still try and get a basename in case someone specifies a name type mask - // of eFunctionNameTypeFull and a name like "A::func" + // Still try and get a basename in case someone specifies a name type + // mask of eFunctionNameTypeFull and a name like "A::func" if (basename.empty()) { if (name_type_mask & eFunctionNameTypeFull && !CPlusPlusLanguage::IsCPPMangledName(name_cstr)) { @@ -724,19 +716,16 @@ } if (!basename.empty()) { - // The name supplied was a partial C++ path like "a::count". In this case we - // want to do a - // lookup on the basename "count" and then make sure any matching results - // contain "a::count" - // so that it would match "b::a::count" and "a::count". This is why we set - // "match_name_after_lookup" - // to true + // The name supplied was a partial C++ path like "a::count". In this + // case we want to do a lookup on the basename "count" and then make + // sure any matching results contain "a::count" so that it would match + // "b::a::count" and "a::count". This is why we set + // "match_name_after_lookup" to true m_lookup_name.SetString(basename); m_match_name_after_lookup = true; } else { - // The name is already correct, just use the exact name as supplied, and we - // won't need - // to check if any matches contain "name" + // The name is already correct, just use the exact name as supplied, + // and we won't need to check if any matches contain "name" m_lookup_name = name; m_match_name_after_lookup = false; } @@ -760,18 +749,18 @@ } } - // If we have only full name matches we might have tried to set breakpoint on - // "func" and specified eFunctionNameTypeFull, but we might have found - // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only - // "func()" and "func" should end up matching. + // If we have only full name matches we might have tried to set + // breakpoint on "func" and specified eFunctionNameTypeFull, but we + // might have found "a::func()", "a::b::func()", "c::func()", "func()" + // and "func". Only "func()" and "func" should end up matching. if (m_name_type_mask == eFunctionNameTypeFull) { SymbolContext sc; size_t i = start_idx; while (i < sc_list.GetSize()) { if (!sc_list.GetContextAtIndex(i, sc)) break; - // Make sure the mangled and demangled names don't match before we try - // to pull anything out + // Make sure the mangled and demangled names don't match before we + // try to pull anything out ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled)); ConstString full_name(sc.GetFunctionName()); if (mangled_name != m_name && full_name != m_name) @@ -812,7 +801,8 @@ const size_t old_size = sc_list.GetSize(); - // Find all the functions (not symbols, but debug information functions... + // Find all the functions (not symbols, but debug information + // functions... SymbolVendor *symbols = GetSymbolVendor(); if (name_type_mask & eFunctionNameTypeAuto) { @@ -867,7 +857,8 @@ if (symbols) { symbols->FindFunctions(regex, include_inlines, append, sc_list); - // Now check our symbol table for symbols that are code symbols if requested + // Now check our symbol table for symbols that are code symbols if + // requested if (include_symbols) { Symtab *symtab = symbols->GetSymtab(); if (symtab) { @@ -882,7 +873,8 @@ size_t num_functions_added_to_sc_list = end_functions_added_index - start_size; if (num_functions_added_to_sc_list == 0) { - // No functions were added, just symbols, so we can just append them + // No functions were added, just symbols, so we can just + // append them for (size_t i = 0; i < num_matches; ++i) { sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]); SymbolType sym_type = sc.symbol->GetType(); @@ -1003,10 +995,10 @@ TypeMap typesmap; if (Type::GetTypeScopeAndBasename(type_name_cstr, type_scope, type_basename, type_class)) { - // Check if "name" starts with "::" which means the qualified type starts - // from the root namespace and implies and exact match. The typenames we - // get back from clang do not start with "::" so we need to strip this off - // in order to get the qualified names to match + // Check if "name" starts with "::" which means the qualified type + // starts from the root namespace and implies and exact match. The + // typenames we get back from clang do not start with "::" so we need + // to strip this off in order to get the qualified names to match exact_match = type_scope.consume_front("::"); ConstString type_basename_const_str(type_basename); @@ -1020,9 +1012,9 @@ // The type is not in a namespace/class scope, just search for it by // basename if (type_class != eTypeClassAny) { - // The "type_name_cstr" will have been modified if we have a valid type - // class - // prefix (like "struct", "class", "union", "typedef" etc). + // 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_basename), nullptr, append, max_matches, searched_symbol_files, typesmap); typesmap.RemoveMismatchedTypes(type_class); @@ -1257,13 +1249,12 @@ shared_from_this(), &m_file, m_object_offset, file_size - m_object_offset, data_sp, data_offset); if (m_objfile_sp) { - // Once we get the object file, update our module with the object - // file's - // architecture since it might differ in vendor/os if some parts were - // unknown. But since the matching arch might already be more - // specific - // than the generic COFF architecture, only merge in those values that - // overwrite unspecified unknown values. + // Once we get the object file, update our module with the + // object file's architecture since it might differ in vendor/os + // if some parts were unknown. But since the matching arch + // might already be more specific than the generic COFF + // architecture, only merge in those values that overwrite + // unspecified unknown values. ArchSpec new_arch; m_objfile_sp->GetArchitecture(new_arch); m_arch.MergeFrom(new_arch); @@ -1406,7 +1397,8 @@ if (!sym_vendor) { return; } - // Prime the symbol file first, since it adds symbols to the symbol table. + // Prime the symbol file first, since it adds symbols to the symbol + // table. if (SymbolFile *symbol_file = sym_vendor->GetSymbolFile()) { symbol_file->PreloadSymbols(); } @@ -1426,35 +1418,33 @@ SymbolFile *symbol_file = m_symfile_ap->GetSymbolFile(); if (section_list && symbol_file) { ObjectFile *obj_file = symbol_file->GetObjectFile(); - // Make sure we have an object file and that the symbol vendor's objfile - // isn't - // the same as the module's objfile before we remove any sections for - // it... + // Make sure we have an object file and that the symbol vendor's + // objfile isn't the same as the module's objfile before we remove + // any sections for it... if (obj_file) { - // Check to make sure we aren't trying to specify the file we already - // have + // Check to make sure we aren't trying to specify the file we + // already have if (obj_file->GetFileSpec() == file) { - // We are being told to add the exact same file that we already have - // we don't have to do anything. + // We are being told to add the exact same file that we already + // have we don't have to do anything. return; } - // Cleare the current symtab as we are going to replace it with a new - // one + // Cleare the current symtab as we are going to replace it with a + // new one obj_file->ClearSymtab(); // The symbol file might be a directory bundle ("/tmp/a.out.dSYM") - // instead - // of a full path to the symbol file within the bundle - // ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to - // check this + // instead of a full path to the symbol file within the bundle + // ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need + // to check this if (llvm::sys::fs::is_directory(file.GetPath())) { std::string new_path(file.GetPath()); std::string old_path(obj_file->GetFileSpec().GetPath()); if (old_path.find(new_path) == 0) { - // We specified the same bundle as the symbol file that we already - // have + // We specified the same bundle as the symbol file that we + // already have return; } } @@ -1471,9 +1461,9 @@ } } } - // Keep all old symbol files around in case there are any lingering type - // references in - // any SBValue objects that might have been handed out. + // Keep all old symbol files around in case there are any lingering + // type references in any SBValue objects that might have been handed + // out. m_old_symfiles.push_back(std::move(m_symfile_ap)); } m_symfile_spec = file; @@ -1658,17 +1648,17 @@ ModuleSP Module::CreateJITModule(const lldb::ObjectFileJITDelegateSP &delegate_sp) { if (delegate_sp) { - // Must create a module and place it into a shared pointer before - // we can create an object file since it has a std::weak_ptr back - // to the module, so we need to control the creation carefully in - // this static function + // Must create a module and place it into a shared pointer before we + // can create an object file since it has a std::weak_ptr back to the + // module, so we need to control the creation carefully in this static + // function ModuleSP module_sp(new Module()); module_sp->m_objfile_sp = std::make_shared(module_sp, delegate_sp); if (module_sp->m_objfile_sp) { - // Once we get the object file, update our module with the object file's - // architecture since it might differ in vendor/os if some parts were - // unknown. + // Once we get the object file, update our module with the object + // file's architecture since it might differ in vendor/os if some + // parts were unknown. module_sp->m_objfile_sp->GetArchitecture(module_sp->m_arch); } return module_sp; Index: source/Core/ModuleList.cpp =================================================================== --- source/Core/ModuleList.cpp +++ source/Core/ModuleList.cpp @@ -132,8 +132,8 @@ // in thread A: | in thread B: // x = y; | y = x; // - // This establishes correct(same) lock taking order and thus - // avoids priority inversion. + // This establishes correct(same) lock taking order and thus avoids + // priority inversion. if (uintptr_t(this) > uintptr_t(&rhs)) { std::lock_guard lhs_guard(m_modules_mutex); std::lock_guard rhs_guard(rhs.m_modules_mutex); @@ -562,9 +562,10 @@ if (total_matches < max_matches) { SymbolContext world_sc; for (pos = m_modules.begin(); pos != end; ++pos) { - // 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 != nullptr). + // 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 != nullptr). if (sc.module_sp.get() != (*pos).get()) total_matches += (*pos)->FindTypes(world_sc, name, name_is_fully_qualified, @@ -733,9 +734,9 @@ static SharedModuleListInfo *g_shared_module_list_info = nullptr; static llvm::once_flag g_once_flag; llvm::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. + // 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_info == nullptr) g_shared_module_list_info = new SharedModuleListInfo(); }); @@ -815,8 +816,8 @@ shared_module_list.Remove(module_sp); module_sp.reset(); } else { - // The module matches and the module was not modified from - // when it was last loaded. + // The module matches and the module was not modified from when + // it was last loaded. return error; } } @@ -828,11 +829,12 @@ module_sp.reset(new Module(module_spec)); // Make sure there are a module and an object file since we can specify - // a valid file path with an architecture that might not be in that file. - // By getting the object file we can guarantee that the architecture matches + // a valid file path with an architecture that might not be in that + // file. By getting the object file we can guarantee that the + // architecture matches if (module_sp->GetObjectFile()) { - // If we get in here we got the correct arch, now we just need - // to verify the UUID if one was given + // If we get in here we got the correct arch, now we just need to + // verify the UUID if one was given if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) { module_sp.reset(); } else { @@ -871,8 +873,8 @@ resolved_module_spec.GetFileSpec() = search_path_spec; module_sp.reset(new Module(resolved_module_spec)); if (module_sp->GetObjectFile()) { - // If we get in here we got the correct arch, now we just need - // to verify the UUID if one was given + // If we get in here we got the correct arch, now we just need to + // verify the UUID if one was given if (uuid_ptr && *uuid_ptr != module_sp->GetUUID()) { module_sp.reset(); } else { @@ -893,9 +895,9 @@ } } - // Either the file didn't exist where at the path, or no path was given, so - // we now have to use more extreme measures to try and find the appropriate - // module. + // Either the file didn't exist where at the path, or no path was given, + // so we now have to use more extreme measures to try and find the + // appropriate module. // Fixup the incoming path in case the path points to a valid file, yet // the arch or UUID (if one was passed in) don't match. @@ -949,8 +951,9 @@ matching_module_list) > 0) { module_sp = matching_module_list.GetModuleAtIndex(0); - // 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 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() == nullptr) { auto file_spec_mod_time = FileSystem::GetModificationTime( located_binary_modulespec.GetFileSpec()); @@ -967,10 +970,10 @@ 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 - // a valid file path with an architecture that might not be in that file. - // By getting the object file we can guarantee that the architecture - // matches + // Make sure there are a module and an object file since we can + // specify a valid file path with an architecture that might not be + // in that file. By getting the object file we can guarantee that + // the architecture matches if (module_sp && module_sp->GetObjectFile()) { if (module_sp->GetObjectFile()->GetType() == ObjectFile::eTypeStubLibrary) { Index: source/Core/PluginManager.cpp =================================================================== --- source/Core/PluginManager.cpp +++ source/Core/PluginManager.cpp @@ -97,9 +97,9 @@ namespace fs = llvm::sys::fs; // If we have a regular file, a symbolic link or unknown file type, try - // and process the file. We must handle unknown as sometimes the directory - // enumeration might be enumerating a file system that doesn't have correct - // file type information. + // and process the file. We must handle unknown as sometimes the + // directory enumeration might be enumerating a file system that doesn't + // have correct file type information. if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) { FileSpec plugin_file_spec(file_spec); @@ -127,18 +127,15 @@ plugin_info.plugin_term_callback = CastToFPtr( plugin_info.library.getAddressOfSymbol("LLDBPluginTerminate")); } else { - // The initialize function returned FALSE which means the plug-in - // might not be - // compatible, or might be too new or too old, or might not want to - // run on this - // machine. Set it to a default-constructed instance to invalidate - // it. + // The initialize function returned FALSE which means the plug- + // in might not be compatible, or might be too new or too old, + // or might not want to run on this machine. Set it to a + // default-constructed instance to invalidate it. plugin_info = PluginInfo(); } - // Regardless of success or failure, cache the plug-in load - // in our plug-in info so we don't try to load it again and - // again. + // Regardless of success or failure, cache the plug-in load in our + // plug-in info so we don't try to load it again and again. SetPluginInfo(plugin_file_spec, plugin_info); return FileSpec::eEnumerateDirectoryResultNext; @@ -148,10 +145,10 @@ if (ft == fs::file_type::directory_file || ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) { - // Try and recurse into anything that a directory or symbolic link. - // We must also do this for unknown as sometimes the directory enumeration - // might be enumerating a file system that doesn't have correct file type - // information. + // Try and recurse into anything that a directory or symbolic link. We + // must also do this for unknown as sometimes the directory + // enumeration might be enumerating a file system that doesn't have + // correct file type information. return FileSpec::eEnumerateDirectoryResultEnter; } @@ -187,8 +184,8 @@ PluginTerminateMap::const_iterator pos, end = plugin_map.end(); for (pos = plugin_map.begin(); pos != end; ++pos) { - // Call the plug-in "void LLDBPluginTerminate (void)" function if there - // is one (if the symbol was not nullptr). + // Call the plug-in "void LLDBPluginTerminate (void)" function if + // there is one (if the symbol was not nullptr). if (pos->second.library.isValid()) { if (pos->second.plugin_term_callback) pos->second.plugin_term_callback(); @@ -1528,7 +1525,8 @@ return pos->create_callback(interpreter); } - // If we didn't find one, return the ScriptInterpreter for the null language. + // If we didn't find one, return the ScriptInterpreter for the null + // language. assert(none_instance != nullptr); return none_instance(interpreter); } @@ -2360,8 +2358,8 @@ } } -// This is the preferred new way to register plugin specific settings. e.g. -// This will put a plugin's settings under e.g. +// This is the preferred new way to register plugin specific settings. +// e.g. This will put a plugin's settings under e.g. // "plugin...SETTINGNAME". static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPlugins( Debugger &debugger, const ConstString &plugin_type_name, @@ -2397,8 +2395,8 @@ } // This is deprecated way to register plugin specific settings. e.g. -// ".plugin..SETTINGNAME" -// and Platform generic settings would be under "platform.SETTINGNAME". +// ".plugin..SETTINGNAME" and Platform +// generic settings would be under "platform.SETTINGNAME". static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle( Debugger &debugger, const ConstString &plugin_type_name, const ConstString &plugin_type_desc, bool can_create) { Index: source/Core/RegisterValue.cpp =================================================================== --- source/Core/RegisterValue.cpp +++ source/Core/RegisterValue.cpp @@ -41,8 +41,8 @@ DataExtractor data; if (GetData(data)) { bool name_printed = false; - // For simplicity, alignment of the register name printing applies only - // in the most common case where: + // For simplicity, alignment of the register name printing applies + // only in the most common case where: // // prefix_with_name^prefix_with_alt_name is true // @@ -69,8 +69,8 @@ s->Printf(fmt.c_str(), reg_info->alt_name); name_printed = true; } else if (!name_printed) { - // No alternate name but we were asked to display a name, so show the - // main name + // No alternate name but we were asked to display a name, so show + // the main name s->Printf(fmt.c_str(), reg_info->name); name_printed = true; } @@ -131,7 +131,8 @@ return 0; } - // Prepare a memory buffer that contains some or all of the register value + // Prepare a memory buffer that contains some or all of the register + // value const uint32_t bytes_copied = reg_data.CopyByteOrderedData(0, // src offset src_len, // src length @@ -185,8 +186,8 @@ return 0; } - // Use a data extractor to correctly copy and pad the bytes read into the - // register value + // Use a data extractor to correctly copy and pad the bytes read into + // the register value DataExtractor src_data(src, src_len, src_byte_order, 4); error = SetValueFromData(reg_info, src_data, 0, true); @@ -248,7 +249,8 @@ void RegisterValue::Clear() { m_type = eTypeInvalid; } RegisterValue::Type RegisterValue::SetType(const RegisterInfo *reg_info) { - // To change the type, we simply copy the data in again, using the new format + // To change the type, we simply copy the data in again, using the new + // format RegisterValue copy; DataExtractor copy_data; if (copy.CopyValue(*this) && copy.GetData(copy_data)) @@ -280,8 +282,8 @@ return error; } - // Cap the data length if there is more than enough bytes for this register - // value + // Cap the data length if there is more than enough bytes for this + // register value if (src_len > reg_info->byte_size) src_len = reg_info->byte_size; @@ -357,8 +359,8 @@ llvm::StringRef vector_str, const uint32_t byte_size, RegisterValue *reg_value) { - // Example: vector_str = "{0x2c 0x4b 0x2a 0x3e 0xd0 0x4f 0x2a 0x3e 0xac 0x4a - // 0x2a 0x3e 0x84 0x4f 0x2a 0x3e}". + // Example: vector_str = "{0x2c 0x4b 0x2a 0x3e 0xd0 0x4f 0x2a 0x3e 0xac + // 0x4a 0x2a 0x3e 0x84 0x4f 0x2a 0x3e}". vector_str = vector_str.trim(); vector_str.consume_front("{"); vector_str.consume_back("}"); @@ -367,16 +369,16 @@ char Sep = ' '; // The first split should give us: - // ('0x2c', '0x4b 0x2a 0x3e 0xd0 0x4f 0x2a 0x3e 0xac 0x4a 0x2a 0x3e 0x84 0x4f - // 0x2a 0x3e'). + // ('0x2c', '0x4b 0x2a 0x3e 0xd0 0x4f 0x2a 0x3e 0xac 0x4a 0x2a 0x3e 0x84 + // 0x4f 0x2a 0x3e'). llvm::StringRef car; llvm::StringRef cdr = vector_str; std::tie(car, cdr) = vector_str.split(Sep); std::vector bytes; unsigned byte = 0; - // Using radix auto-sensing by passing 0 as the radix. - // Keep on processing the vector elements as long as the parsing succeeds and + // Using radix auto-sensing by passing 0 as the radix. Keep on + // processing the vector elements as long as the parsing succeeds and // the vector size is < byte_size. while (!car.getAsInteger(0, byte) && bytes.size() < byte_size) { bytes.push_back(byte); @@ -813,9 +815,9 @@ void RegisterValue::SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order) { // If this assertion fires off we need to increase the size of - // buffer.bytes, or make it something that is allocated on - // the heap. Since the data buffer is in a union, we can't make it - // a collection class like SmallVector... + // buffer.bytes, or make it something that is allocated on the heap. + // Since the data buffer is in a union, we can't make it a collection + // class like SmallVector... if (bytes && length > 0) { assert(length <= sizeof(buffer.bytes) && "Storing too many bytes in a RegisterValue."); Index: source/Core/Scalar.cpp =================================================================== --- source/Core/Scalar.cpp +++ source/Core/Scalar.cpp @@ -41,10 +41,10 @@ // lhs/rhs will get promoted) ) { Scalar result; - // Initialize the promoted values for both the right and left hand side values - // to be the objects themselves. If no promotion is needed (both right and - // left - // have the same type), then the temp_value will not get used. + // Initialize the promoted values for both the right and left hand side + // values to be the objects themselves. If no promotion is needed (both + // right and left have the same type), then the temp_value will not get + // used. promoted_lhs_ptr = &lhs; promoted_rhs_ptr = &rhs; // Extract the types of both the right and left hand side values @@ -69,7 +69,8 @@ if (promoted_lhs_ptr->GetType() == promoted_rhs_ptr->GetType()) return promoted_lhs_ptr->GetType(); // Return the resulting max type - // Return the void type (zero) if we fail to promote either of the values. + // Return the void type (zero) if we fail to promote either of the + // values. return Scalar::e_void; } @@ -129,13 +130,13 @@ if (limit_byte_size < byte_size) { if (endian::InlHostByteOrder() == eByteOrderLittle) { // On little endian systems if we want fewer bytes from the - // current type we just specify fewer bytes since the LSByte - // is first... + // current type we just specify fewer bytes since the LSByte is + // first... byte_size = limit_byte_size; } else if (endian::InlHostByteOrder() == eByteOrderBig) { - // On big endian systems if we want fewer bytes from the - // current type have to advance our initial byte pointer and - // trim down the number of bytes since the MSByte is first + // On big endian systems if we want fewer bytes from the current + // type have to advance our initial byte pointer and trim down the + // number of bytes since the MSByte is first bytes += byte_size - limit_byte_size; byte_size = limit_byte_size; } @@ -164,9 +165,8 @@ case e_slonglong: case e_ulonglong: bytes = reinterpret_cast(m_integer.getRawData()); - // getRawData always returns a pointer to an uint64_t. If we have a smaller - // type, - // we need to update the pointer on big-endian systems. + // getRawData always returns a pointer to an uint64_t. If we have a + // smaller type, we need to update the pointer on big-endian systems. if (endian::InlHostByteOrder() == eByteOrderBig) { size_t byte_size = m_integer.getBitWidth() / 8; if (byte_size < 8) @@ -176,9 +176,9 @@ case e_sint128: case e_uint128: apint_words = m_integer.getRawData(); - // getRawData always returns a pointer to an array of two uint64_t values, - // where the least-significant word always comes first. On big-endian - // systems we need to swap the two words. + // getRawData always returns a pointer to an array of two uint64_t + // values, where the least-significant word always comes first. On + // big-endian systems we need to swap the two words. if (endian::InlHostByteOrder() == eByteOrderBig) { swapped_words[0] = apint_words[1]; swapped_words[1] = apint_words[0]; @@ -188,9 +188,9 @@ case e_sint256: case e_uint256: apint_words = m_integer.getRawData(); - // getRawData always returns a pointer to an array of four uint64_t values, - // where the least-significant word always comes first. On big-endian - // systems we need to swap the four words. + // getRawData always returns a pointer to an array of four uint64_t + // values, where the least-significant word always comes first. On + // big-endian systems we need to swap the four words. if (endian::InlHostByteOrder() == eByteOrderBig) { swapped_words[0] = apint_words[3]; swapped_words[1] = apint_words[2]; @@ -208,9 +208,9 @@ case e_long_double: llvm::APInt ldbl_val = m_float.bitcastToAPInt(); apint_words = ldbl_val.getRawData(); - // getRawData always returns a pointer to an array of two uint64_t values, - // where the least-significant word always comes first. On big-endian - // systems we need to swap the two words. + // getRawData always returns a pointer to an array of two uint64_t + // values, where the least-significant word always comes first. On + // big-endian systems we need to swap the two words. if (endian::InlHostByteOrder() == eByteOrderBig) { swapped_words[0] = apint_words[1]; swapped_words[1] = apint_words[0]; @@ -2064,9 +2064,8 @@ break; } } - // For division only, the only way it should make it here is if a promotion - // failed, - // or if we are trying to do a divide by zero. + // For division only, the only way it should make it here is if a + // promotion failed, or if we are trying to do a divide by zero. result.m_type = Scalar::e_void; return result; } @@ -2563,7 +2562,8 @@ const size_t src_len = data.GetByteSize(); - // Prepare a memory buffer that contains some or all of the register value + // Prepare a memory buffer that contains some or all of the register + // value const size_t bytes_copied = data.CopyByteOrderedData(0, // src offset src_len, // src length Index: source/Core/SearchFilter.cpp =================================================================== --- source/Core/SearchFilter.cpp +++ source/Core/SearchFilter.cpp @@ -261,8 +261,8 @@ size_t n_modules = target_images.GetSize(); for (size_t i = 0; i < n_modules; i++) { - // If this is the last level supplied, then call the callback directly, - // otherwise descend. + // If this is the last level supplied, then call the callback + // directly, otherwise descend. ModuleSP module_sp(target_images.GetModuleAtIndexUnlocked(i)); if (!ModulePasses(module_sp)) continue; @@ -428,8 +428,8 @@ } // If the module file spec is a full path, then we can just find the one - // filespec that passes. Otherwise, we need to go through all modules and - // find the ones that match the file name. + // filespec that passes. Otherwise, we need to go through all modules + // and find the ones that match the file name. const ModuleList &target_modules = m_target_sp->GetImages(); std::lock_guard guard(target_modules.GetMutex()); @@ -577,8 +577,8 @@ } // If the module file spec is a full path, then we can just find the one - // filespec that passes. Otherwise, we need to go through all modules and - // find the ones that match the file name. + // filespec that passes. Otherwise, we need to go through all modules + // and find the ones that match the file name. const ModuleList &target_modules = m_target_sp->GetImages(); std::lock_guard guard(target_modules.GetMutex()); @@ -780,8 +780,8 @@ } // If the module file spec is a full path, then we can just find the one - // filespec that passes. Otherwise, we need to go through all modules and - // find the ones that match the file name. + // filespec that passes. Otherwise, we need to go through all modules + // and find the ones that match the file name. ModuleList matching_modules; const ModuleList &target_images = m_target_sp->GetImages(); Index: source/Core/Section.cpp =================================================================== --- source/Core/Section.cpp +++ source/Core/Section.cpp @@ -176,8 +176,8 @@ SectionSP parent_sp(GetParent()); if (parent_sp) { // This section has a parent which means m_file_addr is an offset into - // the parent section, so the file address for this section is the file - // address of the parent plus the offset + // the parent section, so the file address for this section is the + // file address of the parent plus the offset return parent_sp->GetFileAddress() + m_file_addr; } // This section has no parent, so m_file_addr is the file base address @@ -239,8 +239,8 @@ so_addr.SetSection(const_cast
(this)->shared_from_this()); #ifdef LLDB_CONFIGURATION_DEBUG - // For debug builds, ensure that there are no orphaned (i.e., moduleless) - // sections. + // For debug builds, ensure that there are no orphaned (i.e., + // moduleless) sections. assert(GetModule().get()); #endif return true; @@ -556,11 +556,9 @@ sect_iter != end && sect_sp.get() == NULL; ++sect_iter) { Section *sect = sect_iter->get(); if (sect->ContainsFileAddress(vm_addr)) { - // The file address is in this section. We need to make sure one of our - // child - // sections doesn't contain this address as well as obeying the depth - // limit - // that was passed in. + // The file address is in this section. We need to make sure one of + // our child sections doesn't contain this address as well as + // obeying the depth limit that was passed in. if (depth > 0) sect_sp = sect->GetChildren().FindSectionContainingFileAddress( vm_addr, depth - 1); Index: source/Core/SourceManager.cpp =================================================================== --- source/Core/SourceManager.cpp +++ source/Core/SourceManager.cpp @@ -79,8 +79,8 @@ TargetSP target_sp(m_target_wp.lock()); - // It the target source path map has been updated, get this file again so we - // can successfully remap the source file + // It the target source path map has been updated, get this file again + // so we can successfully remap the source file if (target_sp && file_sp && file_sp->GetSourceMapModificationID() != target_sp->GetSourcePathMap().GetModificationID()) @@ -104,32 +104,32 @@ } static bool should_show_stop_column_with_ansi(DebuggerSP debugger_sp) { - // We don't use ANSI stop column formatting if we can't lookup values from - // the debugger. + // We don't use ANSI stop column formatting if we can't lookup values + // from the debugger. if (!debugger_sp) return false; - // We don't use ANSI stop column formatting if the debugger doesn't think - // it should be using color. + // We don't use ANSI stop column formatting if the debugger doesn't + // think it should be using color. if (!debugger_sp->GetUseColor()) return false; - // We only use ANSI stop column formatting if we're either supposed to show - // ANSI where available (which we know we have when we get to this point), or - // if we're only supposed to use ANSI. + // We only use ANSI stop column formatting if we're either supposed to + // show ANSI where available (which we know we have when we get to this + // point), or if we're only supposed to use ANSI. const auto value = debugger_sp->GetStopShowColumn(); return ((value == eStopShowColumnAnsiOrCaret) || (value == eStopShowColumnAnsi)); } static bool should_show_stop_column_with_caret(DebuggerSP debugger_sp) { - // We don't use text-based stop column formatting if we can't lookup values - // from the debugger. + // We don't use text-based stop column formatting if we can't lookup + // values from the debugger. if (!debugger_sp) return false; - // If we're asked to show the first available of ANSI or caret, then - // we do show the caret when ANSI is not available. + // If we're asked to show the first available of ANSI or caret, then we + // do show the caret when ANSI is not available. const auto value = debugger_sp->GetStopShowColumn(); if ((value == eStopShowColumnAnsiOrCaret) && !debugger_sp->GetUseColor()) return true; @@ -232,8 +232,8 @@ size_t SourceManager::DisplayMoreWithLineNumbers( Stream *s, uint32_t count, bool reverse, const SymbolContextList *bp_locs) { - // If we get called before anybody has set a default file and line, then try - // to figure it out here. + // If we get called before anybody has set a default file and line, then + // try to figure it out here. const bool have_default_file_line = m_last_file_sp && m_last_line > 0; if (!m_default_set) { FileSpec tmp_spec; @@ -255,9 +255,9 @@ if (m_last_line > 0) { if (reverse) { - // If this is the first time we've done a reverse, then back up one more - // time so we end - // up showing the chunk before the last one we've shown: + // If this is the first time we've done a reverse, then back up + // one more time so we end up showing the chunk before the last + // one we've shown: if (m_last_line > m_last_count) m_last_line -= m_last_count; else @@ -298,11 +298,11 @@ TargetSP target_sp(m_target_wp.lock()); if (target_sp) { - // If nobody has set the default file and line then try here. If there's - // no executable, then we - // will try again later when there is one. Otherwise, if we can't find it - // we won't look again, - // somebody will have to set it (for instance when we stop somewhere...) + // If nobody has set the default file and line then try here. If + // there's no executable, then we will try again later when there is + // one. Otherwise, if we can't find it we won't look again, + // somebody will have to set it (for instance when we stop + // somewhere...) Module *executable_ptr = target_sp->GetExecutableModulePointer(); if (executable_ptr) { SymbolContextList sc_list; @@ -405,14 +405,13 @@ } } } - // Try remapping if m_file_spec does not correspond to an existing file. + // Try remapping if m_file_spec does not correspond to an existing + // file. if (!m_file_spec.Exists()) { FileSpec new_file_spec; - // Check target specific source remappings first, then fall back to - // modules objects can have individual path remappings that were - // detected - // when the debug info for a module was found. - // then + // Check target specific source remappings first, then fall back + // to modules objects can have individual path remappings that + // were detected when the debug info for a module was found. then if (target->GetSourcePathMap().FindFile(m_file_spec, new_file_spec) || target->GetImages().FindSourceFile(m_file_spec, new_file_spec)) { m_file_spec = new_file_spec; @@ -493,9 +492,10 @@ } void SourceManager::File::UpdateIfNeeded() { - // TODO: use host API to sign up for file modifications to anything in our - // source cache and only update when we determine a file has been updated. - // For now we check each time we want to display info for the file. + // TODO: use host API to sign up for file modifications to anything in + // our source cache and only update when we determine a file has been + // updated. For now we check each time we want to display info for the + // file. auto curr_mod_time = FileSystem::GetModificationTime(m_file_spec); if (curr_mod_time != llvm::sys::TimePoint<>() && @@ -538,18 +538,18 @@ if (column && (column < count)) { auto debugger_sp = m_debugger_wp.lock(); if (should_show_stop_column_with_ansi(debugger_sp) && debugger_sp) { - // Check if we have any ANSI codes with which to mark this column. - // If not, no need to do this work. + // Check if we have any ANSI codes with which to mark this + // column. If not, no need to do this work. auto ansi_prefix_entry = debugger_sp->GetStopShowColumnAnsiPrefix(); auto ansi_suffix_entry = debugger_sp->GetStopShowColumnAnsiSuffix(); - // We only bother breaking up the line to format the marked column if - // there is any marking specified on both sides of the marked column. - // In ANSI-terminal-sequence land, there must be a post if there is a - // pre format, and vice versa. + // We only bother breaking up the line to format the marked + // column if there is any marking specified on both sides of the + // marked column. In ANSI-terminal-sequence land, there must be + // a post if there is a pre format, and vice versa. if (ansi_prefix_entry && ansi_suffix_entry) { - // Mark the current column with the desired escape sequence for - // formatting the column (e.g. underline, inverse, etc.) + // Mark the current column with the desired escape sequence + // for formatting the column (e.g. underline, inverse, etc.) // First print the part before the column to mark. bytes_written = s->Write(cstr, column - 1); @@ -581,8 +581,8 @@ } } - // If we didn't end up displaying the line with ANSI codes for whatever - // reason, display it now sans codes. + // If we didn't end up displaying the line with ANSI codes for + // whatever reason, display it now sans codes. if (!displayed_line) bytes_written = s->Write(cstr, count); Index: source/Core/Value.cpp =================================================================== --- source/Core/Value.cpp +++ source/Core/Value.cpp @@ -366,10 +366,10 @@ Target *target = exe_ctx->GetTargetPtr(); if (target) { // Allow expressions to run and evaluate things when the target - // has memory sections loaded. This allows you to use "target modules - // load" - // to load your executable and any shared libraries, then execute - // commands where you can look at types in data sections. + // has memory sections loaded. This allows you to use "target + // modules load" to load your executable and any shared + // libraries, then execute commands where you can look at types + // in data sections. const SectionLoadList &target_sections = target->GetSectionLoadList(); if (!target_sections.IsEmpty()) { address = m_value.ULongLong(LLDB_INVALID_ADDRESS); @@ -545,8 +545,8 @@ // section offset address so we might be able to read this from // the object files if we don't have a live process. Lets always // try and read from the process if we have one though since we - // want to read the actual value by setting "prefer_file_cache" - // to false. + // want to read the actual value by setting "prefer_file_cache" to + // false. const bool prefer_file_cache = false; if (exe_ctx->GetTargetRef().ReadMemory(file_so_addr, prefer_file_cache, dst, byte_size, @@ -555,10 +555,10 @@ "read memory from 0x%" PRIx64 " failed", (uint64_t)address); } } else { - // The execution context might have a NULL process, but it - // might have a valid process in the exe_ctx->target, so use - // the ExecutionContext::GetProcess accessor to ensure we - // get the process if there is one. + // The execution context might have a NULL process, but it might + // have a valid process in the exe_ctx->target, so use the + // ExecutionContext::GetProcess accessor to ensure we get the + // process if there is one. Process *process = exe_ctx->GetProcessPtr(); if (process) { Index: source/Core/ValueObject.cpp =================================================================== --- source/Core/ValueObject.cpp +++ source/Core/ValueObject.cpp @@ -146,16 +146,15 @@ if (update_format) did_change_formats = UpdateFormatsIfNeeded(); - // If this is a constant value, then our success is predicated on whether - // we have an error or not + // If this is a constant value, then our success is predicated on + // whether we have an error or not if (GetIsConstant()) { - // if you are constant, things might still have changed behind your back - // (e.g. you are a frozen object and things have changed deeper than you - // cared to freeze-dry yourself) - // in this case, your value has not changed, but "computed" entries might - // have, so you might now have - // a different summary, or a different object description. clear these so we - // will recompute them + // if you are constant, things might still have changed behind your + // back (e.g. you are a frozen object and things have changed deeper + // than you cared to freeze-dry yourself) in this case, your value has + // not changed, but "computed" entries might have, so you might now + // have a different summary, or a different object description. clear + // these so we will recompute them if (update_format && !did_change_formats) ClearUserVisibleData(eClearUserVisibleDataItemsSummary | eClearUserVisibleDataItemsDescription); @@ -167,8 +166,8 @@ if (NeedsUpdating()) { m_update_point.SetUpdated(); - // Save the old value using swap to avoid a string copy which - // also will clear our m_value_str + // Save the old value using swap to avoid a string copy which also + // will clear our m_value_str if (m_value_str.empty()) { m_old_value_valid = false; } else { @@ -215,8 +214,8 @@ if (first_update) SetValueDidChange(false); else if (!m_value_did_change && success == false) { - // The value wasn't gotten successfully, so we mark this - // as changed if the value used to be valid and now isn't + // The value wasn't gotten successfully, so we mark this as + // changed if the value used to be valid and now isn't SetValueDidChange(value_was_valid); } else if (need_compare_checksums) { SetValueDidChange(memcmp(&old_checksum[0], &m_value_checksum[0], @@ -260,9 +259,9 @@ void ValueObject::SetNeedsUpdate() { m_update_point.SetNeedsUpdate(); - // We have to clear the value string here so ConstResult children will notice - // if their values are - // changed by hand (i.e. with SetValueAsCString). + // We have to clear the value string here so ConstResult children will + // notice if their values are changed by hand (i.e. with + // SetValueAsCString). ClearUserVisibleData(eClearUserVisibleDataItemsValue); } @@ -557,8 +556,8 @@ ValueObjectSP ValueObject::GetChildMemberWithName(const ConstString &name, bool can_create) { // when getting a child by name, it could be buried inside some base - // classes (which really aren't part of the expression path), so we - // need a vector of indexes that can get us down to the correct child + // classes (which really aren't part of the expression path), so we need + // a vector of indexes that can get us down to the correct child ValueObjectSP child_sp; // We may need to update our value if we are dynamic @@ -682,8 +681,8 @@ const TypeSummaryOptions &options) { destination.clear(); - // ideally we would like to bail out if passing NULL, but if we do so - // we end up not providing the summary for function pointers anymore + // ideally we would like to bail out if passing NULL, but if we do so we + // end up not providing the summary for function pointers anymore if (/*summary_ptr == NULL ||*/ m_is_getting_summary) return false; @@ -694,10 +693,10 @@ if (actual_options.GetLanguage() == lldb::eLanguageTypeUnknown) actual_options.SetLanguage(GetPreferredDisplayLanguage()); - // this is a hot path in code and we prefer to avoid setting this string all - // too often also clearing out other - // information that we might care to see in a crash log. might be useful in - // very specific situations though. + // this is a hot path in code and we prefer to avoid setting this string + // all too often also clearing out other information that we might care + // to see in a crash log. might be useful in very specific situations + // though. /*Host::SetCrashDescriptionWithFormat("Trying to fetch a summary for %s %s. Summary provider's description is %s", GetTypeName().GetCString(), @@ -868,8 +867,8 @@ bool ValueObject::SetData(DataExtractor &data, Status &error) { error.Clear(); - // Make sure our value is up to date first so that our location and location - // type is valid. + // Make sure our value is up to date first so that our location and + // location type is valid. if (!UpdateValueIfNeeded(false)) { error.SetErrorString("unable to read value"); return false; @@ -894,8 +893,9 @@ } } break; case Value::eValueTypeLoadAddress: { - // If it is a load address, then the scalar value is the storage location - // of the data, and we have to shove this value down to that load location. + // If it is a load address, then the scalar value is the storage + // location of the data, and we have to shove this value down to that + // load location. ExecutionContext exe_ctx(GetExecutionContextRef()); Process *process = exe_ctx.GetProcessPtr(); if (process) { @@ -911,8 +911,8 @@ } } break; case Value::eValueTypeHostAddress: { - // If it is a host address, then we stuff the scalar as a DataBuffer into - // the Value's data. + // If it is a host address, then we stuff the scalar as a DataBuffer + // into the Value's data. DataBufferSP buffer_sp(new DataBufferHeap(byte_size, 0)); m_data.SetData(buffer_sp, 0); data.CopyByteOrderedData(0, byte_size, @@ -925,7 +925,8 @@ break; } - // If we have reached this point, then we have successfully changed the value. + // If we have reached this point, then we have successfully changed the + // value. SetNeedsUpdate(); return true; } @@ -1010,8 +1011,8 @@ DataExtractor data; if (cstr_len > 0 && honor_array) { // I am using GetPointeeData() here to abstract the fact that some - // ValueObjects are actually frozen pointers in the host - // but the pointed-to data lives in the debuggee, and GetPointeeData() + // ValueObjects are actually frozen pointers in the host but the + // pointed-to data lives in the debuggee, and GetPointeeData() // automatically takes care of this GetPointeeData(data, 0, cstr_len); @@ -1031,8 +1032,8 @@ int cstr_len_displayed = -1; bool capped_cstr = false; // I am using GetPointeeData() here to abstract the fact that some - // ValueObjects are actually frozen pointers in the host - // but the pointed-to data lives in the debuggee, and GetPointeeData() + // ValueObjects are actually frozen pointers in the host but the + // pointed-to data lives in the debuggee, and GetPointeeData() // automatically takes care of this while ((bytes_read = GetPointeeData(data, offset, k_max_buf_size)) > 0) { total_bytes_read += bytes_read; @@ -1113,8 +1114,8 @@ LanguageRuntime *runtime = process->GetLanguageRuntime(language); if (runtime == NULL) { - // Aw, hell, if the things a pointer, or even just an integer, let's try - // ObjC anyway... + // Aw, hell, if the things a pointer, or even just an integer, let's + // try ObjC anyway... CompilerType compiler_type = GetCompilerType(); if (compiler_type) { bool is_signed; @@ -1175,8 +1176,8 @@ format_sp.reset(new TypeFormatImpl_Format(my_format)); if (GetValueAsCString(*format_sp.get(), m_value_str)) { if (!m_value_did_change && m_old_value_valid) { - // The value was gotten successfully, so we consider the - // value as changed if the value string differs + // The value was gotten successfully, so we consider the value + // as changed if the value string differs SetValueDidChange(m_old_value_str != m_value_str); } } @@ -1187,8 +1188,8 @@ return m_value_str.c_str(); } -// if > 8bytes, 0 is returned. this method should mostly be used -// to read address values out of pointers +// if > 8bytes, 0 is returned. this method should mostly be used to read +// address values out of pointers uint64_t ValueObject::GetValueAsUnsigned(uint64_t fail_value, bool *success) { // If our byte size is zero this is an aggregate type that has children if (CanProvideValue()) { @@ -1224,10 +1225,10 @@ } // if any more "special cases" are added to -// ValueObject::DumpPrintableRepresentation() please keep -// this call up to date by returning true for your new special cases. We will -// eventually move -// to checking this call result before trying to display special cases +// ValueObject::DumpPrintableRepresentation() please keep this call up to +// date by returning true for your new special cases. We will eventually +// move to checking this call result before trying to display special +// cases bool ValueObject::HasSpecialPrintableRepresentation( ValueObjectRepresentationStyle val_obj_display, Format custom_format) { Flags flags(GetTypeInfo()); @@ -1275,9 +1276,8 @@ if (allow_special) { if (flags.AnySet(eTypeIsArray | eTypeIsPointer) && val_obj_display == ValueObject::eValueObjectRepresentationStyleValue) { - // when being asked to get a printable display an array or pointer type - // directly, - // try to "do the right thing" + // when being asked to get a printable display an array or pointer + // type directly, try to "do the right thing" if (IsCStringContainer(true) && (custom_format == eFormatCString || @@ -1405,10 +1405,11 @@ { llvm::StringRef str; - // this is a local stream that we are using to ensure that the data pointed - // to by cstr survives long enough for us to copy it to its destination - it - // is necessary to have this temporary storage area for cases where our - // desired output is not backed by some other longer-term storage + // this is a local stream that we are using to ensure that the data + // pointed to by cstr survives long enough for us to copy it to its + // destination - it is necessary to have this temporary storage area + // for cases where our desired output is not backed by some other + // longer-term storage StreamString strm; if (custom_format != eFormatInvalid) @@ -1485,9 +1486,9 @@ s.PutCString(""); } - // we should only return false here if we could not do *anything* - // even if we have an error message as output, that's a success - // from our callers' perspective, so return true + // we should only return false here if we could not do *anything* even + // if we have an error message as output, that's a success from our + // callers' perspective, so return true var_success = true; if (custom_format != eFormatInvalid) @@ -1563,8 +1564,8 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) { error.Clear(); - // Make sure our value is up to date first so that our location and location - // type is valid. + // Make sure our value is up to date first so that our location and + // location type is valid. if (!UpdateValueIfNeeded(false)) { error.SetErrorString("unable to read value"); return false; @@ -1578,21 +1579,21 @@ Value::ValueType value_type = m_value.GetValueType(); if (value_type == Value::eValueTypeScalar) { - // If the value is already a scalar, then let the scalar change itself: + // If the value is already a scalar, then let the scalar change + // itself: m_value.GetScalar().SetValueFromCString(value_str, encoding, byte_size); } else if (byte_size <= 16) { - // If the value fits in a scalar, then make a new scalar and again let the - // scalar code do the conversion, then figure out where to put the new - // value. + // If the value fits in a scalar, then make a new scalar and again let + // the scalar code do the conversion, then figure out where to put the + // new value. Scalar new_scalar; error = new_scalar.SetValueFromCString(value_str, encoding, byte_size); if (error.Success()) { switch (value_type) { case Value::eValueTypeLoadAddress: { // If it is a load address, then the scalar value is the storage - // location - // of the data, and we have to shove this value down to that load - // location. + // location of the data, and we have to shove this value down to + // that load location. ExecutionContext exe_ctx(GetExecutionContextRef()); Process *process = exe_ctx.GetProcessPtr(); if (process) { @@ -1609,8 +1610,8 @@ } } break; case Value::eValueTypeHostAddress: { - // If it is a host address, then we stuff the scalar as a DataBuffer - // into the Value's data. + // If it is a host address, then we stuff the scalar as a + // DataBuffer into the Value's data. DataExtractor new_data; new_data.SetByteOrder(m_data.GetByteOrder()); @@ -1639,7 +1640,8 @@ return false; } - // If we have reached this point, then we have successfully changed the value. + // If we have reached this point, then we have successfully changed the + // value. SetNeedsUpdate(); return true; } @@ -1734,16 +1736,14 @@ return false; } -// This allows you to create an array member using and index -// that doesn't not fall in the normal bounds of the array. -// Many times structure can be defined as: -// struct Collection -// { +// This allows you to create an array member using and index that doesn't +// not fall in the normal bounds of the array. Many times structure can be +// defined as: struct Collection { // uint32_t item_count; // Item item_array[0]; // }; -// The size of the "item_array" is 1, but many times in practice -// there are more items in "item_array". +// The size of the "item_array" is 1, but many times in practice there are +// more items in "item_array". ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index, bool can_create) { @@ -1757,8 +1757,8 @@ synthetic_child_sp = GetSyntheticChild(index_const_str); if (!synthetic_child_sp) { ValueObject *synthetic_child; - // We haven't made a synthetic array member for INDEX yet, so - // lets make one and cache it for any future reference. + // We haven't made a synthetic array member for INDEX yet, so lets + // make one and cache it for any future reference. synthetic_child = CreateChildAtIndex(0, true, index); // Cache the value if we got one back... @@ -1789,8 +1789,8 @@ if (GetDataExtractor().GetByteOrder() == eByteOrderBig) bit_field_offset = GetByteSize() * 8 - bit_field_size - bit_field_offset; - // We haven't made a synthetic array member for INDEX yet, so - // lets make one and cache it for any future reference. + // We haven't made a synthetic array member for INDEX yet, so lets + // make one and cache it for any future reference. ValueObjectChild *synthetic_child = new ValueObjectChild( *this, GetCompilerType(), index_const_str, GetByteSize(), 0, bit_field_size, bit_field_offset, false, false, eAddressTypeInvalid, @@ -1884,11 +1884,11 @@ return synthetic_child_sp; } -// your expression path needs to have a leading . or -> -// (unless it somehow "looks like" an array, in which case it has -// a leading [ symbol). while the [ is meaningful and should be shown -// to the user, . and -> are just parser design, but by no means -// added information for the user.. strip them off +// your expression path needs to have a leading . or -> (unless it somehow +// "looks like" an array, in which case it has a leading [ symbol). while +// the [ is meaningful and should be shown to the user, . and -> are just +// parser design, but by no means added information for the user.. strip +// them off static const char *SkipLeadingExpressionPathSeparators(const char *expression) { if (!expression || !expression[0]) return expression; @@ -1918,8 +1918,8 @@ // Cache the value if we got one back... if (synthetic_child_sp.get()) { - // FIXME: this causes a "real" child to end up with its name changed to - // the contents of expression + // FIXME: this causes a "real" child to end up with its name changed + // to the contents of expression AddSyntheticChild(name_const_string, synthetic_child_sp.get()); synthetic_child_sp->SetName( ConstString(SkipLeadingExpressionPathSeparators(expression))); @@ -2054,11 +2054,10 @@ void ValueObject::GetExpressionPath(Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat epformat) { - // synthetic children do not actually "exist" as part of the hierarchy, and - // sometimes they are consed up in ways - // that don't make sense from an underlying language/API standpoint. So, use a - // special code path here to return - // something that can hopefully be used in expression + // synthetic children do not actually "exist" as part of the hierarchy, + // and sometimes they are consed up in ways that don't make sense from + // an underlying language/API standpoint. So, use a special code path + // here to return something that can hopefully be used in expression if (m_is_synthetic_children_generated) { UpdateValueIfNeeded(); @@ -2091,12 +2090,11 @@ if (is_deref_of_parent && epformat == eGetExpressionPathFormatDereferencePointers) { - // this is the original format of GetExpressionPath() producing code like - // *(a_ptr).memberName, which is entirely - // fine, until you put this into - // StackFrame::GetValueForVariableExpressionPath() which prefers to see - // a_ptr->memberName. - // the eHonorPointers mode is meant to produce strings in this latter format + // this is the original format of GetExpressionPath() producing code + // like *(a_ptr).memberName, which is entirely fine, until you put + // this into StackFrame::GetValueForVariableExpressionPath() which + // prefers to see a_ptr->memberName. the eHonorPointers mode is meant + // to produce strings in this latter format s.PutCString("*("); } @@ -2106,8 +2104,8 @@ parent->GetExpressionPath(s, qualify_cxx_base_classes, epformat); // if we are a deref_of_parent just because we are synthetic array - // members made up to allow ptr[%d] syntax to work in variable - // printing, then add our name ([%d]) to the expression path + // members made up to allow ptr[%d] syntax to work in variable printing, + // then add our name ([%d]) to the expression path if (m_is_array_item_for_pointer && epformat == eGetExpressionPathFormatHonorPointers) s.PutCString(m_name.AsCString()); @@ -2355,8 +2353,8 @@ } // if we are here and options.m_no_synthetic_children is true, - // child_valobj_sp is going to be a NULL SP, - // so we hit the "else" branch, and return an error + // child_valobj_sp is going to be a NULL SP, so we hit the "else" + // branch, and return an error if (child_valobj_sp.get()) // if it worked, just return { *reason_to_stop = @@ -2424,8 +2422,8 @@ } // if we are here and options.m_no_synthetic_children is true, - // child_valobj_sp is going to be a NULL SP, - // so we hit the "else" branch, and return an error + // child_valobj_sp is going to be a NULL SP, so we hit the "else" + // branch, and return an error if (child_valobj_sp.get()) // if it worked, move on { root = child_valobj_sp; @@ -2501,14 +2499,14 @@ llvm::StringRef bracket_expr = temp_expression.slice(1, close_bracket_position); - // If this was an empty expression it would have been caught by the if - // above. + // If this was an empty expression it would have been caught by the + // if above. assert(!bracket_expr.empty()); if (!bracket_expr.contains('-')) { - // if no separator, this is of the form [N]. Note that this cannot - // be an unbounded range of the form [], because that case was handled - // above with an unconditional return. + // if no separator, this is of the form [N]. Note that this + // cannot be an unbounded range of the form [], because that case + // was handled above with an unconditional return. unsigned long index = 0; if (bracket_expr.getAsInteger(0, index)) { *reason_to_stop = @@ -2597,7 +2595,8 @@ *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return nullptr; } else // we do not know how to expand members of bitfields, so we - // just return and let the caller do any further processing + // just return and let the caller do any further + // processing { *reason_to_stop = ValueObject:: eExpressionPathScanEndReasonBitfieldRangeOperatorMet; @@ -2631,8 +2630,8 @@ *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return nullptr; } - // if we are here, then root itself is a synthetic VO.. should be good - // to go + // if we are here, then root itself is a synthetic VO.. should + // be good to go if (!root) { *reason_to_stop = @@ -3030,21 +3029,18 @@ ValueObject::EvaluationPoint::~EvaluationPoint() {} -// This function checks the EvaluationPoint against the current process state. -// If the current -// state matches the evaluation point, or the evaluation point is already -// invalid, then we return -// false, meaning "no change". If the current state is different, we update our -// state, and return -// true meaning "yes, change". If we did see a change, we also set -// m_needs_update to true, so -// future calls to NeedsUpdate will return true. -// exe_scope will be set to the current execution context scope. +// This function checks the EvaluationPoint against the current process +// state. If the current state matches the evaluation point, or the +// evaluation point is already invalid, then we return false, meaning "no +// change". If the current state is different, we update our state, and +// return true meaning "yes, change". If we did see a change, we also set +// m_needs_update to true, so future calls to NeedsUpdate will return +// true. exe_scope will be set to the current execution context scope. bool ValueObject::EvaluationPoint::SyncWithProcessState( bool accept_invalid_exe_ctx) { - // Start with the target, if it is NULL, then we're obviously not going to get - // any further: + // Start with the target, if it is NULL, then we're obviously not going + // to get any further: const bool thread_and_frame_only_if_stopped = true; ExecutionContext exe_ctx( m_exe_ctx_ref.Lock(thread_and_frame_only_if_stopped)); @@ -3060,9 +3056,9 @@ // If our stop id is the current stop ID, nothing has changed: ProcessModID current_mod_id = process->GetModID(); - // If the current stop id is 0, either we haven't run yet, or the process - // state has been cleared. - // In either case, we aren't going to be able to sync with the process state. + // If the current stop id is 0, either we haven't run yet, or the + // process state has been cleared. In either case, we aren't going to be + // able to sync with the process state. if (current_mod_id.GetStopID() == 0) return false; @@ -3080,11 +3076,10 @@ } } - // Now re-look up the thread and frame in case the underlying objects have - // gone away & been recreated. - // That way we'll be sure to return a valid exe_scope. - // If we used to have a thread or a frame but can't find it anymore, then mark - // ourselves as invalid. + // Now re-look up the thread and frame in case the underlying objects + // have gone away & been recreated. That way we'll be sure to return a + // valid exe_scope. If we used to have a thread or a frame but can't + // find it anymore, then mark ourselves as invalid. if (!accept_invalid_exe_ctx) { if (m_exe_ctx_ref.HasThreadRef()) { @@ -3300,10 +3295,8 @@ bool ValueObject::CanProvideValue() { // we need to support invalid types as providers of values because some - // bare-board - // debugging scenarios have no notion of types, but still manage to have raw - // numeric - // values for things like registers. sigh. + // bare-board debugging scenarios have no notion of types, but still + // manage to have raw numeric values for things like registers. sigh. const CompilerType &type(GetCompilerType()); return (false == type.IsValid()) || (0 != (type.GetTypeInfo() & eTypeHasValue)); @@ -3360,8 +3353,8 @@ m_use_synthetic(use_synthetic) { if (!in_valobj_sp) return; - // If the user passes in a value object that is dynamic or synthetic, then - // water it down to the static type. + // If the user passes in a value object that is dynamic or synthetic, + // then water it down to the static type. m_root_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(lldb::eNoDynamicValues, false); } Index: source/Core/ValueObjectCast.cpp =================================================================== --- source/Core/ValueObjectCast.cpp +++ source/Core/ValueObjectCast.cpp @@ -71,9 +71,9 @@ m_value.SetCompilerType(compiler_type); SetAddressTypeOfChildren(m_parent->GetAddressTypeOfChildren()); if (!CanProvideValue()) { - // this value object represents an aggregate type whose - // children have values, but this object does not. So we - // say we are changed if our location has changed. + // this value object represents an aggregate type whose children + // have values, but this object does not. So we say we are changed + // if our location has changed. SetValueDidChange(m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); } Index: source/Core/ValueObjectChild.cpp =================================================================== --- source/Core/ValueObjectChild.cpp +++ source/Core/ValueObjectChild.cpp @@ -172,8 +172,8 @@ } else if (addr == 0) { m_error.SetErrorString("parent is NULL"); } else { - // Set this object's scalar value to the address of its - // value by adding its byte offset to the parent address + // Set this object's scalar value to the address of its value + // by adding its byte offset to the parent address m_value.GetScalar() += GetByteOffset(); } } break; Index: source/Core/ValueObjectConstResult.cpp =================================================================== --- source/Core/ValueObjectConstResult.cpp +++ source/Core/ValueObjectConstResult.cpp @@ -268,8 +268,8 @@ lldb::ValueObjectSP ValueObjectConstResult::GetDynamicValue(lldb::DynamicValueType use_dynamic) { - // Always recalculate dynamic values for const results as the memory that - // they might point to might have changed at any time. + // Always recalculate dynamic values for const results as the memory + // that they might point to might have changed at any time. if (use_dynamic != eNoDynamicValues) { if (!IsDynamic()) { ExecutionContext exe_ctx(GetExecutionContextRef()); Index: source/Core/ValueObjectDynamicValue.cpp =================================================================== --- source/Core/ValueObjectDynamicValue.cpp +++ source/Core/ValueObjectDynamicValue.cpp @@ -172,9 +172,8 @@ } } - // Getting the dynamic value may have run the program a bit, and so marked us - // as needing updating, but we really - // don't... + // Getting the dynamic value may have run the program a bit, and so + // marked us as needing updating, but we really don't... m_update_point.SetUpdated(); @@ -191,9 +190,9 @@ m_type_impl.Clear(); } - // If we don't have a dynamic type, then make ourselves just a echo of our - // parent. - // Or we could return false, and make ourselves an echo of our parent? + // If we don't have a dynamic type, then make ourselves just a echo of + // our parent. Or we could return false, and make ourselves an echo of + // our parent? if (!found_dynamic_type) { if (m_dynamic_type_info) SetValueDidChange(true); @@ -248,14 +247,14 @@ static_cast(this), GetTypeName().GetCString()); if (m_address.IsValid() && m_dynamic_type_info) { - // The variable value is in the Scalar value inside the m_value. - // We can point our m_data right to it. + // The variable value is in the Scalar value inside the m_value. We + // can point our m_data right to it. m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get()); if (m_error.Success()) { if (!CanProvideValue()) { - // this value object represents an aggregate type whose - // children have values, but this object does not. So we - // say we are changed if our location has changed. + // this value object represents an aggregate type whose children + // have values, but this object does not. So we say we are changed + // if our location has changed. SetValueDidChange(m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); } @@ -287,13 +286,11 @@ return false; } - // if we are at an offset from our parent, in order to set ourselves correctly - // we would need - // to change the new value so that it refers to the correct dynamic type. we - // choose not to deal - // with that - if anything more than a value overwrite is required, you should - // be using the - // expression parser instead of the value editing facility + // if we are at an offset from our parent, in order to set ourselves + // correctly we would need to change the new value so that it refers to + // the correct dynamic type. we choose not to deal with that - if + // anything more than a value overwrite is required, you should be using + // the expression parser instead of the value editing facility if (my_value != parent_value) { // but NULL'ing out a value should always be allowed if (strcmp(value_str, "0")) { @@ -322,13 +319,11 @@ return false; } - // if we are at an offset from our parent, in order to set ourselves correctly - // we would need - // to change the new value so that it refers to the correct dynamic type. we - // choose not to deal - // with that - if anything more than a value overwrite is required, you should - // be using the - // expression parser instead of the value editing facility + // if we are at an offset from our parent, in order to set ourselves + // correctly we would need to change the new value so that it refers to + // the correct dynamic type. we choose not to deal with that - if + // anything more than a value overwrite is required, you should be using + // the expression parser instead of the value editing facility if (my_value != parent_value) { // but NULL'ing out a value should always be allowed lldb::offset_t offset = 0; Index: source/Core/ValueObjectList.cpp =================================================================== --- source/Core/ValueObjectList.cpp +++ source/Core/ValueObjectList.cpp @@ -87,8 +87,8 @@ collection::iterator pos, end = m_value_objects.end(); for (pos = m_value_objects.begin(); pos != end; ++pos) { - // Watch out for NULL objects in our list as the list - // might get resized to a specific size and lazily filled in + // Watch out for NULL objects in our list as the list might get + // resized to a specific size and lazily filled in ValueObject *valobj = (*pos).get(); if (valobj && valobj->GetID() == uid) { valobj_sp = *pos; Index: source/Core/ValueObjectMemory.cpp =================================================================== --- source/Core/ValueObjectMemory.cpp +++ source/Core/ValueObjectMemory.cpp @@ -165,8 +165,8 @@ llvm_unreachable("Unhandled expression result value kind..."); case Value::eValueTypeScalar: - // The variable value is in the Scalar value inside the m_value. - // We can point our m_data right to it. + // The variable value is in the Scalar value inside the m_value. We + // can point our m_data right to it. m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, GetModule().get()); break; @@ -174,14 +174,15 @@ case Value::eValueTypeLoadAddress: case Value::eValueTypeHostAddress: // The DWARF expression result was an address in the inferior - // process. If this variable is an aggregate type, we just need - // the address as the main value as all child variable objects - // will rely upon this location and add an offset and then read - // their own values as needed. If this variable is a simple - // type, we read all data for it into m_data. - // Make sure this type has a value before we try and read it - - // If we have a file address, convert it to a load address if we can. + // process. If this variable is an aggregate type, we just need the + // address as the main value as all child variable objects will rely + // upon this location and add an offset and then read their own + // values as needed. If this variable is a simple type, we read all + // data for it into m_data. Make sure this type has a value before + // we try and read it + + // If we have a file address, convert it to a load address if we + // can. if (value_type == Value::eValueTypeFileAddress && exe_ctx.GetProcessPtr()) { lldb::addr_t load_addr = m_address.GetLoadAddress(target); @@ -192,14 +193,14 @@ } if (!CanProvideValue()) { - // this value object represents an aggregate type whose - // children have values, but this object does not. So we - // say we are changed if our location has changed. + // this value object represents an aggregate type whose children + // have values, but this object does not. So we say we are changed + // if our location has changed. SetValueDidChange(value_type != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); } else { - // Copy the Value and set the context to use our Variable - // so it can extract read its value into m_data appropriately + // Copy the Value and set the context to use our Variable so it + // can extract read its value into m_data appropriately Value value(m_value); if (m_type_sp) value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get()); Index: source/Core/ValueObjectRegister.cpp =================================================================== --- source/Core/ValueObjectRegister.cpp +++ source/Core/ValueObjectRegister.cpp @@ -319,7 +319,8 @@ bool ValueObjectRegister::SetValueFromCString(const char *value_str, Status &error) { - // The new value will be in the m_data. Copy that into our register value. + // The new value will be in the m_data. Copy that into our register + // value. error = m_reg_value.SetValueFromString(&m_reg_info, llvm::StringRef(value_str)); if (error.Success()) { Index: source/Core/ValueObjectSyntheticFilter.cpp =================================================================== --- source/Core/ValueObjectSyntheticFilter.cpp +++ source/Core/ValueObjectSyntheticFilter.cpp @@ -141,8 +141,8 @@ m_error.Clear(); if (!m_parent->UpdateValueIfNeeded(false)) { - // our parent could not update.. as we are meaningless without a parent, - // just stop + // our parent could not update.. as we are meaningless without a + // parent, just stop if (m_parent->GetError().Fail()) m_error = m_parent->GetError(); return false; @@ -171,10 +171,9 @@ m_children_byindex.Clear(); m_name_toindex.Clear(); // usually, an object's value can change but this does not alter its - // children count - // for a synthetic VO that might indeed happen, so we need to tell the upper - // echelons - // that they need to come back to us asking for children + // children count for a synthetic VO that might indeed happen, so we + // need to tell the upper echelons that they need to come back to us + // asking for children m_children_count_valid = false; m_synthetic_children_cache.Clear(); m_synthetic_children_count = UINT32_MAX; Index: source/Core/ValueObjectVariable.cpp =================================================================== --- source/Core/ValueObjectVariable.cpp +++ source/Core/ValueObjectVariable.cpp @@ -174,26 +174,21 @@ switch (value_type) { case Value::eValueTypeFileAddress: - // If this type is a pointer, then its children will be considered load - // addresses - // if the pointer or reference is dereferenced, but only if the process - // is alive. + // If this type is a pointer, then its children will be considered + // load addresses if the pointer or reference is dereferenced, but + // only if the process is alive. // // There could be global variables like in the following code: - // struct LinkedListNode { Foo* foo; LinkedListNode* next; }; - // Foo g_foo1; - // Foo g_foo2; - // LinkedListNode g_second_node = { &g_foo2, NULL }; - // LinkedListNode g_first_node = { &g_foo1, &g_second_node }; + // struct LinkedListNode { Foo* foo; LinkedListNode* next; }; Foo + // g_foo1; Foo g_foo2; LinkedListNode g_second_node = { &g_foo2, + // NULL }; LinkedListNode g_first_node = { &g_foo1, &g_second_node + // }; // - // When we aren't running, we should be able to look at these variables - // using - // the "target variable" command. Children of the "g_first_node" always - // will - // be of the same address type as the parent. But children of the "next" - // member of - // LinkedListNode will become load addresses if we have a live process, - // or remain + // When we aren't running, we should be able to look at these + // variables using the "target variable" command. Children of the + // "g_first_node" always will be of the same address type as the + // parent. But children of the "next" member of LinkedListNode + // will become load addresses if we have a live process, or remain // what a file address if it what a file address. if (process_is_alive && is_pointer_or_ref) SetAddressTypeOfChildren(eAddressTypeLoad); @@ -201,13 +196,11 @@ SetAddressTypeOfChildren(eAddressTypeFile); break; case Value::eValueTypeHostAddress: - // Same as above for load addresses, except children of pointer or refs - // are always - // load addresses. Host addresses are used to store freeze dried - // variables. If this - // type is a struct, the entire struct contents will be copied into the - // heap of the - // LLDB process, but we do not currrently follow any pointers. + // Same as above for load addresses, except children of pointer or + // refs are always load addresses. Host addresses are used to + // store freeze dried variables. If this type is a struct, the + // entire struct contents will be copied into the heap of the LLDB + // process, but we do not currrently follow any pointers. if (is_pointer_or_ref) SetAddressTypeOfChildren(eAddressTypeLoad); else @@ -237,11 +230,12 @@ // process. If this variable is an aggregate type, we just need // the address as the main value as all child variable objects // will rely upon this location and add an offset and then read - // their own values as needed. If this variable is a simple - // type, we read all data for it into m_data. - // Make sure this type has a value before we try and read it + // their own values as needed. If this variable is a simple type, + // we read all data for it into m_data. Make sure this type has a + // value before we try and read it - // If we have a file address, convert it to a load address if we can. + // If we have a file address, convert it to a load address if we + // can. if (value_type == Value::eValueTypeFileAddress && process_is_alive) { lldb::addr_t file_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); @@ -263,14 +257,14 @@ } if (!CanProvideValue()) { - // this value object represents an aggregate type whose - // children have values, but this object does not. So we - // say we are changed if our location has changed. + // this value object represents an aggregate type whose children + // have values, but this object does not. So we say we are + // changed if our location has changed. SetValueDidChange(value_type != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); } else { - // Copy the Value and set the context to use our Variable - // so it can extract read its value into m_data appropriately + // Copy the Value and set the context to use our Variable so it + // can extract read its value into m_data appropriately Value value(m_value); value.SetContext(Value::eContextTypeVariable, variable); m_error = @@ -299,14 +293,13 @@ if (frame) { return m_variable_sp->IsInScope(frame); } else { - // This ValueObject had a frame at one time, but now we - // can't locate it, so return false since we probably aren't - // in scope. + // This ValueObject had a frame at one time, but now we can't locate + // it, so return false since we probably aren't in scope. return false; } } - // We have a variable that wasn't tied to a frame, which - // means it is a global and is always in scope. + // We have a variable that wasn't tied to a frame, which means it is a + // global and is always in scope. return true; } Index: source/DataFormatters/FormatManager.cpp =================================================================== --- source/DataFormatters/FormatManager.cpp +++ source/DataFormatters/FormatManager.cpp @@ -494,8 +494,8 @@ if (valobj.GetNumChildren() == 0) return false; - // ask the type if it has any opinion about this - // eLazyBoolCalculate == no opinion; other values should be self explanatory + // ask the type if it has any opinion about this eLazyBoolCalculate == + // no opinion; other values should be self explanatory CompilerType compiler_type(valobj.GetCompilerType()); if (compiler_type.IsValid()) { switch (compiler_type.ShouldPrintAsOneLiner(&valobj)) { @@ -531,9 +531,8 @@ } } - // if we decided to define synthetic children for a type, we probably care - // enough - // to show them, but avoid nesting children in children + // if we decided to define synthetic children for a type, we probably + // care enough to show them, but avoid nesting children in children if (child_sp->GetSyntheticChildren().get() != nullptr) { ValueObjectSP synth_sp(child_sp->GetSyntheticValue()); // wait.. wat? just get out of here.. @@ -549,9 +548,9 @@ total_children_name_len += child_sp->GetName().GetLength(); - // 50 itself is a "randomly" chosen number - the idea is that - // overly long structs should not get this treatment - // FIXME: maybe make this a user-tweakable setting? + // 50 itself is a "randomly" chosen number - the idea is that overly + // long structs should not get this treatment FIXME: maybe make this a + // user-tweakable setting? if (total_children_name_len > 50) return false; @@ -565,8 +564,8 @@ // if this child has children.. if (child_sp->GetNumChildren()) { // ...and no summary... - // (if it had a summary and the summary wanted children, we would have - // bailed out anyway + // (if it had a summary and the summary wanted children, we would + // have bailed out anyway // so this only makes us bail out if this has no summary and we would // then print children) if (!child_sp->GetSummaryFormat() && !is_synth_val) // but again only do Index: source/DataFormatters/StringPrinter.cpp =================================================================== --- source/DataFormatters/StringPrinter.cpp +++ source/DataFormatters/StringPrinter.cpp @@ -26,9 +26,9 @@ using namespace lldb_private; using namespace lldb_private::formatters; -// we define this for all values of type but only implement it for those we care -// about -// that's good because we get linker errors for any unsupported type +// we define this for all values of type but only implement it for those +// we care about that's good because we get linker errors for any +// unsupported type template static StringPrinter::StringPrinterBufferPointer<> GetPrintableImpl(uint8_t *buffer, uint8_t *buffer_end, uint8_t *&next); @@ -163,8 +163,8 @@ (unsigned char)*(buffer + 2), (unsigned char)*(buffer + 3)); break; default: - // this is probably some bogus non-character thing - // just print it as-is and hope to sync up again soon + // this is probably some bogus non-character thing just print it as-is + // and hope to sync up again soon retval = {buffer, 1}; next = buffer + 1; return retval; @@ -217,15 +217,16 @@ return retval; } - // this should not happen - but just in case.. try to resync at some point + // this should not happen - but just in case.. try to resync at some + // point retval = {buffer, 1}; next = buffer + 1; return retval; } -// Given a sequence of bytes, this function returns: -// a sequence of bytes to actually print out + a length -// the following unscanned position of the buffer is in next +// Given a sequence of bytes, this function returns: a sequence of bytes +// to actually print out + a length the following unscanned position of +// the buffer is in next static StringPrinter::StringPrinterBufferPointer<> GetPrintable(StringPrinter::StringElementType type, uint8_t *buffer, uint8_t *buffer_end, uint8_t *&next) { @@ -320,9 +321,9 @@ utf8_data_ptr = (llvm::UTF8 *)utf8_data_buffer_sp->GetBytes(); } else { - // just copy the pointers - the cast is necessary to make the compiler - // happy - // but this should only happen if we are reading UTF8 data + // just copy the pointers - the cast is necessary to make the + // compiler happy but this should only happen if we are reading UTF8 + // data utf8_data_ptr = const_cast( reinterpret_cast(data_ptr)); utf8_data_end_ptr = const_cast( @@ -343,9 +344,10 @@ GetPrintableElementType::UTF8); } - // since we tend to accept partial data (and even partially malformed data) - // we might end up with no NULL terminator before the end_ptr - // hence we need to take a slower route and ensure we stay within boundaries + // since we tend to accept partial data (and even partially malformed + // data) we might end up with no NULL terminator before the end_ptr + // hence we need to take a slower route and ensure we stay within + // boundaries for (; utf8_data_ptr < utf8_data_end_ptr;) { if (zero_is_terminator && !*utf8_data_ptr) break; @@ -357,8 +359,8 @@ auto printable_bytes = printable.GetBytes(); auto printable_size = printable.GetSize(); if (!printable_bytes || !next_data) { - // GetPrintable() failed on us - print one byte in a desperate resync - // attempt + // GetPrintable() failed on us - print one byte in a desperate + // resync attempt printable_bytes = utf8_data_ptr; printable_size = 1; next_data = utf8_data_ptr + 1; @@ -471,9 +473,10 @@ ASCII); } - // since we tend to accept partial data (and even partially malformed data) - // we might end up with no NULL terminator before the end_ptr - // hence we need to take a slower route and ensure we stay within boundaries + // since we tend to accept partial data (and even partially malformed + // data) we might end up with no NULL terminator before the end_ptr + // hence we need to take a slower route and ensure we stay within + // boundaries for (uint8_t *data = buffer_sp->GetBytes(); *data && (data < data_end);) { if (escape_non_printables) { uint8_t *next_data = nullptr; @@ -481,8 +484,8 @@ auto printable_bytes = printable.GetBytes(); auto printable_size = printable.GetSize(); if (!printable_bytes || !next_data) { - // GetPrintable() failed on us - print one byte in a desperate resync - // attempt + // GetPrintable() failed on us - print one byte in a desperate + // resync attempt printable_bytes = data; printable_size = 1; next_data = data + 1; Index: source/DataFormatters/TypeFormat.cpp =================================================================== --- source/DataFormatters/TypeFormat.cpp +++ source/DataFormatters/TypeFormat.cpp @@ -70,15 +70,15 @@ } else { CompilerType compiler_type = value.GetCompilerType(); if (compiler_type) { - // put custom bytes to display in the DataExtractor to override the - // default value logic + // put custom bytes to display in the DataExtractor to override + // the default value logic if (GetFormat() == eFormatCString) { lldb_private::Flags type_flags(compiler_type.GetTypeInfo( NULL)); // disambiguate w.r.t. TypeFormatImpl::Flags if (type_flags.Test(eTypeIsPointer) && !type_flags.Test(eTypeIsObjC)) { - // if we are dumping a pointer as a c-string, get the pointee data - // as a string + // if we are dumping a pointer as a c-string, get the pointee + // data as a string TargetSP target_sp(valobj->GetTargetSP()); if (target_sp) { size_t max_len = target_sp->GetMaximumSizeOfStringSummary(); @@ -111,12 +111,12 @@ valobj->GetBitfieldBitSize(), // Bitfield bit size valobj->GetBitfieldBitOffset(), // Bitfield bit offset exe_scope); - // Given that we do not want to set the ValueObject's m_error - // for a formatting error (or else we wouldn't be able to reformat + // Given that we do not want to set the ValueObject's m_error for + // a formatting error (or else we wouldn't be able to reformat // until a next update), an empty string is treated as a "false" // return from here, but that's about as severe as we get - // CompilerType::DumpTypeValue() should always return - // something, even if that something is an error message + // CompilerType::DumpTypeValue() should always return something, + // even if that something is an error message dest = sstr.GetString(); } } Index: source/DataFormatters/ValueObjectPrinter.cpp =================================================================== --- source/DataFormatters/ValueObjectPrinter.cpp +++ source/DataFormatters/ValueObjectPrinter.cpp @@ -230,13 +230,13 @@ void ValueObjectPrinter::PrintDecl() { bool show_type = true; - // if we are at the root-level and been asked to hide the root's type, then - // hide it + // if we are at the root-level and been asked to hide the root's type, + // then hide it if (m_curr_depth == 0 && m_options.m_hide_root_type) show_type = false; else - // otherwise decide according to the usual rules (asked to show types - - // always at the root level) + // otherwise decide according to the usual rules (asked to show types + // - always at the root level) show_type = m_options.m_show_types || (m_curr_depth == 0 && !m_options.m_flat_output); @@ -244,8 +244,8 @@ // always show the type at the root level if it is invalid if (show_type) { - // Some ValueObjects don't have types (like registers sets). Only print - // the type if there is one to print + // Some ValueObjects don't have types (like registers sets). Only + // print the type if there is one to print ConstString type_name; if (m_compiler_type.IsValid()) { if (m_options.m_use_type_display_name) @@ -289,8 +289,8 @@ bool decl_printed = false; if (!m_options.m_decl_printing_helper) { // if the user didn't give us a custom helper, pick one based upon the - // language, either the one that this printer is bound to, or the preferred - // one for the ValueObject + // language, either the one that this printer is bound to, or the + // preferred one for the ValueObject lldb::LanguageType lang_type = (m_options.m_varformat_language == lldb::eLanguageTypeUnknown) ? m_valobj->GetPreferredDisplayLanguage() @@ -356,8 +356,8 @@ std::string &summary, std::string &error) { lldb::Format format = m_options.m_format; - // if I am printing synthetized elements, apply the format to those elements - // only + // if I am printing synthetized elements, apply the format to those + // elements only if (m_options.m_pointer_as_array) m_valobj->GetValueAsCString(lldb::eFormatDefault, value); else if (format != eFormatDefault && format != m_valobj->GetFormat()) @@ -401,13 +401,11 @@ GetValueSummaryError(m_value, m_summary, m_error); } if (m_error.size()) { - // we need to support scenarios in which it is actually fine for a value - // to have no type - // but - on the other hand - if we get an error *AND* have no type, we try - // to get out - // gracefully, since most often that combination means "could not resolve - // a type" - // and the default failure mode is quite ugly + // we need to support scenarios in which it is actually fine for a + // value to have no type but - on the other hand - if we get an + // error *AND* have no type, we try to get out gracefully, since + // most often that combination means "could not resolve a type" and + // the default failure mode is quite ugly if (!m_compiler_type.IsValid()) { m_stream->Printf(" "); return false; @@ -418,8 +416,8 @@ } else { // Make sure we have a value and make sure the summary didn't // specify that the value should not be printed - and do not print - // the value if this thing is nil - // (but show the value if the user passes a format explicitly) + // the value if this thing is nil (but show the value if the user + // passes a format explicitly) TypeSummaryImpl *entry = GetSummaryFormatter(); if (!IsNil() && !IsUninitialized() && !m_value.empty() && (entry == NULL || (entry->DoesPrintValue(m_valobj) || @@ -457,7 +455,8 @@ else object_desc = GetDescriptionForDisplay(); if (object_desc && *object_desc) { - // If the description already ends with a \n don't add another one. + // If the description already ends with a \n don't add another + // one. size_t object_end = strlen(object_desc) - 1; if (object_desc[object_end] == '\n') m_stream->Printf("%s", object_desc); @@ -494,8 +493,8 @@ if (is_uninit) return false; - // if the user has specified an element count, always print children - // as it is explicit user demand being honored + // if the user has specified an element count, always print children as + // it is explicit user demand being honored if (m_options.m_pointer_as_array) return true; @@ -505,17 +504,17 @@ return false; if (is_failed_description || m_curr_depth < m_options.m_max_depth) { - // We will show children for all concrete types. We won't show - // pointer contents unless a pointer depth has been specified. - // We won't reference contents unless the reference is the - // root object (depth of zero). + // We will show children for all concrete types. We won't show pointer + // contents unless a pointer depth has been specified. We won't + // reference contents unless the reference is the root object (depth + // of zero). - // Use a new temporary pointer depth in case we override the - // current pointer depth below... + // Use a new temporary pointer depth in case we override the current + // pointer depth below... if (is_ptr || is_ref) { - // We have a pointer or reference whose value is an address. - // Make sure that address is not NULL + // We have a pointer or reference whose value is an address. Make + // sure that address is not NULL AddressType ptr_address_type; if (m_valobj->GetPointerValue(&ptr_address_type) == 0) return false; @@ -654,7 +653,8 @@ ValueObjectSP ValueObjectPrinter::GenerateChild(ValueObject *synth_valobj, size_t idx) { if (m_options.m_pointer_as_array) { - // if generating pointer-as-array children, use GetSyntheticArrayMember + // if generating pointer-as-array children, use + // GetSyntheticArrayMember return synth_valobj->GetSyntheticArrayMember( PhysicalIndexForLogicalIndex( m_options.m_pointer_as_array.m_base_element, @@ -759,8 +759,8 @@ void ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed, bool summary_printed) { // this flag controls whether we tried to display a description for this - // object and failed - // if that happens, we want to display the children, if any + // object and failed if that happens, we want to display the children, + // if any bool is_failed_description = !PrintObjectDescriptionIfNeeded(value_printed, summary_printed); @@ -779,7 +779,8 @@ if (print_children && is_instance_ptr) { instance_ptr_value = m_valobj->GetValueAsUnsigned(0); if (m_printed_instance_pointers->count(instance_ptr_value)) { - // we already printed this instance-is-pointer thing, so don't expand it + // we already printed this instance-is-pointer thing, so don't + // expand it m_stream->PutCString(" {...}\n"); // we're done here - get out fast Index: source/DataFormatters/VectorType.cpp =================================================================== --- source/DataFormatters/VectorType.cpp +++ source/DataFormatters/VectorType.cpp @@ -156,10 +156,9 @@ return eFormatHex; case lldb::eFormatDefault: { - // special case the (default, char) combination to actually display as an - // integer value - // most often, you won't want to see the ASCII characters... (and if you do, - // eFormatChar is a keystroke away) + // special case the (default, char) combination to actually display as + // an integer value most often, you won't want to see the ASCII + // characters... (and if you do, eFormatChar is a keystroke away) bool is_char = element_type.IsCharType(); bool is_signed = false; element_type.IsIntegerType(is_signed); Index: source/Expression/DWARFExpression.cpp =================================================================== --- source/Expression/DWARFExpression.cpp +++ source/Expression/DWARFExpression.cpp @@ -697,16 +697,16 @@ } // bool -// DWARFExpression::LocationListContainsLoadAddress (Process* process, const -// Address &addr) const +// DWARFExpression::LocationListContainsLoadAddress (Process* process, +// const Address &addr) const //{ // return LocationListContainsLoadAddress(process, // addr.GetLoadAddress(process)); //} // // bool -// DWARFExpression::LocationListContainsLoadAddress (Process* process, addr_t -// load_addr) const +// DWARFExpression::LocationListContainsLoadAddress (Process* process, +// addr_t load_addr) const //{ // if (load_addr == LLDB_INVALID_ADDRESS) // return false; @@ -991,10 +991,10 @@ if (op == DW_OP_addr) { const uint32_t addr_byte_size = m_data.GetAddressByteSize(); - // We have to make a copy of the data as we don't know if this - // data is from a read only memory mapped buffer, so we duplicate - // all of the data first, then modify it, and if all goes well, - // we then replace the data for this expression + // We have to make a copy of the data as we don't know if this data + // is from a read only memory mapped buffer, so we duplicate all of + // the data first, then modify it, and if all goes well, we then + // replace the data for this expression // So first we copy the data into a heap buffer std::unique_ptr head_data_ap( @@ -1010,8 +1010,8 @@ return false; // All went well, so now we can reset the data using a shared - // pointer to the heap data so "m_data" will now correctly - // manage the heap data. + // pointer to the heap data so "m_data" will now correctly manage + // the heap data. m_data.SetData(DataBufferSP(head_data_ap.release())); return true; } else { @@ -1025,9 +1025,9 @@ } bool DWARFExpression::ContainsThreadLocalStorage() const { - // We are assuming for now that any thread local variable will not - // have a location list. This has been true for all thread local - // variables we have seen so far produced by any compiler. + // We are assuming for now that any thread local variable will not have + // a location list. This has been true for all thread local variables we + // have seen so far produced by any compiler. if (IsLocationList()) return false; lldb::offset_t offset = 0; @@ -1048,24 +1048,24 @@ lldb::ModuleSP new_module_sp, std::function const &link_address_callback) { - // We are assuming for now that any thread local variable will not - // have a location list. This has been true for all thread local - // variables we have seen so far produced by any compiler. + // We are assuming for now that any thread local variable will not have + // a location list. This has been true for all thread local variables we + // have seen so far produced by any compiler. if (IsLocationList()) return false; const uint32_t addr_byte_size = m_data.GetAddressByteSize(); - // We have to make a copy of the data as we don't know if this - // data is from a read only memory mapped buffer, so we duplicate - // all of the data first, then modify it, and if all goes well, - // we then replace the data for this expression + // We have to make a copy of the data as we don't know if this data is + // from a read only memory mapped buffer, so we duplicate all of the + // data first, then modify it, and if all goes well, we then replace the + // data for this expression // So first we copy the data into a heap buffer std::shared_ptr heap_data_sp( new DataBufferHeap(m_data.GetDataStart(), m_data.GetByteSize())); - // Make en encoder so we can write the address into the buffer using - // the correct byte order (endianness) + // Make en encoder so we can write the address into the buffer using the + // correct byte order (endianness) DataEncoder encoder(heap_data_sp->GetBytes(), heap_data_sp->GetByteSize(), m_data.GetByteOrder(), addr_byte_size); @@ -1080,8 +1080,7 @@ switch (op) { case DW_OP_const4u: // Remember the const offset in case we later have a - // DW_OP_form_tls_address - // or DW_OP_GNU_push_tls_address + // DW_OP_form_tls_address or DW_OP_GNU_push_tls_address const_offset = offset; const_value = m_data.GetU32(&offset); decoded_data = true; @@ -1090,8 +1089,7 @@ case DW_OP_const8u: // Remember the const offset in case we later have a - // DW_OP_form_tls_address - // or DW_OP_GNU_push_tls_address + // DW_OP_form_tls_address or DW_OP_GNU_push_tls_address const_offset = offset; const_value = m_data.GetU64(&offset); decoded_data = true; @@ -1100,22 +1098,17 @@ case DW_OP_form_tls_address: case DW_OP_GNU_push_tls_address: - // DW_OP_form_tls_address and DW_OP_GNU_push_tls_address must be preceded - // by - // a file address on the stack. We assume that DW_OP_const4u or - // DW_OP_const8u - // is used for these values, and we check that the last opcode we got - // before - // either of these was DW_OP_const4u or DW_OP_const8u. If so, then we can - // link - // the value accodingly. For Darwin, the value in the DW_OP_const4u or + // DW_OP_form_tls_address and DW_OP_GNU_push_tls_address must be + // preceded by a file address on the stack. We assume that + // DW_OP_const4u or DW_OP_const8u is used for these values, and we + // check that the last opcode we got before either of these was + // DW_OP_const4u or DW_OP_const8u. If so, then we can link the value + // accodingly. For Darwin, the value in the DW_OP_const4u or // DW_OP_const8u is the file address of a structure that contains a - // function - // pointer, the pthread key and the offset into the data pointed to by the - // pthread key. So we must link this address and also set the module of - // this - // expression to the new_module_sp so we can resolve the file address - // correctly + // function pointer, the pthread key and the offset into the data + // pointed to by the pthread key. So we must link this address and + // also set the module of this expression to the new_module_sp so we + // can resolve the file address correctly if (const_byte_size > 0) { lldb::addr_t linked_file_addr = link_address_callback(const_value); if (linked_file_addr == LLDB_INVALID_ADDRESS) @@ -1143,10 +1136,9 @@ } } - // If we linked the TLS address correctly, update the module so that when the - // expression - // is evaluated it can resolve the file address to a load address and read the - // TLS data + // If we linked the TLS address correctly, update the module so that + // when the expression is evaluated it can resolve the file address to a + // load address and read the TLS data m_module_wp = new_module_sp; m_data.SetData(heap_data_sp); return true; @@ -1385,8 +1377,9 @@ } switch (op) { //---------------------------------------------------------------------- - // The DW_OP_addr operation has a single operand that encodes a machine - // address and whose size is the size of an address on the target machine. + // The DW_OP_addr operation has a single operand that encodes a + // machine address and whose size is the size of an address on the + // target machine. //---------------------------------------------------------------------- case DW_OP_addr: stack.push_back(Scalar(opcodes.GetAddress(&offset))); @@ -1399,9 +1392,9 @@ // DW_OP_addr(0x1000) // If this address resides in a shared library, then this virtual // address won't make sense when it is evaluated in the context of a - // running process where shared libraries have been slid. To account for - // this, this new address type where we can store the section pointer - // and a 4 byte offset. + // running process where shared libraries have been slid. To account + // for this, this new address type where we can store the section + // pointer and a 4 byte offset. //---------------------------------------------------------------------- // case DW_OP_addr_sect_offset4: // { @@ -1498,15 +1491,15 @@ // OPCODE: DW_OP_deref_size // OPERANDS: 1 // 1 - uint8_t that specifies the size of the data to dereference. - // DESCRIPTION: Behaves like the DW_OP_deref operation: it pops the top - // stack entry and treats it as an address. The value retrieved from that - // address is pushed. In the DW_OP_deref_size operation, however, the - // size in bytes of the data retrieved from the dereferenced address is - // specified by the single operand. This operand is a 1-byte unsigned - // integral constant whose value may not be larger than the size of an - // address on the target machine. The data retrieved is zero extended - // to the size of an address on the target machine before being pushed - // on the expression stack. + // DESCRIPTION: Behaves like the DW_OP_deref operation: it pops the + // top stack entry and treats it as an address. The value retrieved + // from that address is pushed. In the DW_OP_deref_size operation, + // however, the size in bytes of the data retrieved from the + // dereferenced address is specified by the single operand. This + // operand is a 1-byte unsigned integral constant whose value may not + // be larger than the size of an address on the target machine. The + // data retrieved is zero extended to the size of an address on the + // target machine before being pushed on the expression stack. //---------------------------------------------------------------------- case DW_OP_deref_size: { if (stack.empty()) { @@ -1522,11 +1515,10 @@ void *src = (void *)stack.back().GetScalar().ULongLong(); intptr_t ptr; ::memcpy(&ptr, src, sizeof(void *)); - // I can't decide whether the size operand should apply to the bytes in - // their - // lldb-host endianness or the target endianness.. I doubt this'll ever - // come up - // but I'll opt for assuming big endian regardless. + // I can't decide whether the size operand should apply to the + // bytes in their lldb-host endianness or the target endianness.. + // I doubt this'll ever come up but I'll opt for assuming big + // endian regardless. switch (size) { case 1: ptr = ptr & 0xff; @@ -1540,10 +1532,9 @@ case 4: ptr = ptr & 0xffffffff; break; - // the casts are added to work around the case where intptr_t is a 32 - // bit quantity; - // presumably we won't hit the 5..7 cases if (void*) is 32-bits in this - // program. + // the casts are added to work around the case where intptr_t is a + // 32 bit quantity; presumably we won't hit the 5..7 cases if + // (void*) is 32-bits in this program. case 5: ptr = (intptr_t)ptr & 0xffffffffffULL; break; @@ -1642,14 +1633,14 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_xderef // OPERANDS: none - // DESCRIPTION: Provides an extended dereference mechanism. The entry at - // the top of the stack is treated as an address. The second stack entry - // is treated as an "address space identifier" for those architectures - // that support multiple address spaces. The top two stack elements are - // popped, a data item is retrieved through an implementation-defined - // address calculation and pushed as the new stack top. The size of the - // data retrieved from the dereferenced address is the size of an address - // on the target machine. + // DESCRIPTION: Provides an extended dereference mechanism. The entry + // at the top of the stack is treated as an address. The second stack + // entry is treated as an "address space identifier" for those + // architectures that support multiple address spaces. The top two + // stack elements are popped, a data item is retrieved through an + // implementation-defined address calculation and pushed as the new + // stack top. The size of the data retrieved from the dereferenced + // address is the size of an address on the target machine. //---------------------------------------------------------------------- case DW_OP_xderef: if (error_ptr) @@ -1660,17 +1651,16 @@ // All DW_OP_constXXX opcodes have a single operand as noted below: // // Opcode Operand 1 - // --------------- ---------------------------------------------------- - // DW_OP_const1u 1-byte unsigned integer constant - // DW_OP_const1s 1-byte signed integer constant - // DW_OP_const2u 2-byte unsigned integer constant - // DW_OP_const2s 2-byte signed integer constant - // DW_OP_const4u 4-byte unsigned integer constant - // DW_OP_const4s 4-byte signed integer constant - // DW_OP_const8u 8-byte unsigned integer constant - // DW_OP_const8s 8-byte signed integer constant - // DW_OP_constu unsigned LEB128 integer constant - // DW_OP_consts signed LEB128 integer constant + // --------------- + // ---------------------------------------------------- DW_OP_const1u + // 1-byte unsigned integer constant DW_OP_const1s 1-byte signed + // integer constant DW_OP_const2u 2-byte unsigned integer constant + // DW_OP_const2s 2-byte signed integer constant DW_OP_const4u + // 4-byte unsigned integer constant DW_OP_const4s 4-byte signed + // integer constant DW_OP_const8u 8-byte unsigned integer constant + // DW_OP_const8s 8-byte signed integer constant DW_OP_constu + // unsigned LEB128 integer constant DW_OP_consts signed LEB128 + // integer constant //---------------------------------------------------------------------- case DW_OP_const1u: stack.push_back(Scalar((uint8_t)opcodes.GetU8(&offset))); @@ -1749,9 +1739,9 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_pick - // OPERANDS: uint8_t index into the current stack - // DESCRIPTION: The stack entry with the specified index (0 through 255, - // inclusive) is pushed on the stack + // OPERANDS: uint8_t index into the current stack DESCRIPTION: The + // stack entry with the specified index (0 through 255, inclusive) is + // pushed on the stack //---------------------------------------------------------------------- case DW_OP_pick: { uint8_t pick_idx = opcodes.GetU8(&offset); @@ -1790,8 +1780,8 @@ // OPERANDS: none // DESCRIPTION: Rotates the first three stack entries. The entry at // the top of the stack becomes the third stack entry, the second - // entry becomes the top of the stack, and the third entry becomes - // the second entry. + // entry becomes the top of the stack, and the third entry becomes the + // second entry. //---------------------------------------------------------------------- case DW_OP_rot: if (stack.size() < 3) { @@ -1812,8 +1802,8 @@ // OPCODE: DW_OP_abs // OPERANDS: none // DESCRIPTION: pops the top stack entry, interprets it as a signed - // value and pushes its absolute value. If the absolute value can not be - // represented, the result is undefined. + // value and pushes its absolute value. If the absolute value can not + // be represented, the result is undefined. //---------------------------------------------------------------------- case DW_OP_abs: if (stack.empty()) { @@ -1852,9 +1842,9 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_div // OPERANDS: none - // DESCRIPTION: pops the top two stack values, divides the former second - // entry by the former top of the stack using signed division, and - // pushes the result. + // DESCRIPTION: pops the top two stack values, divides the former + // second entry by the former top of the stack using signed division, + // and pushes the result. //---------------------------------------------------------------------- case DW_OP_div: if (stack.size() < 2) { @@ -1884,8 +1874,9 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_minus // OPERANDS: none - // DESCRIPTION: pops the top two stack values, subtracts the former top - // of the stack from the former second entry, and pushes the result. + // DESCRIPTION: pops the top two stack values, subtracts the former + // top of the stack from the former second entry, and pushes the + // result. //---------------------------------------------------------------------- case DW_OP_minus: if (stack.size() < 2) { @@ -2006,8 +1997,8 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_plus // OPERANDS: none - // DESCRIPTION: pops the top two stack entries, adds them together, and - // pushes the result. + // DESCRIPTION: pops the top two stack entries, adds them together, + // and pushes the result. //---------------------------------------------------------------------- case DW_OP_plus: if (stack.size() < 2) { @@ -2025,8 +2016,8 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_plus_uconst // OPERANDS: none - // DESCRIPTION: pops the top stack entry, adds it to the unsigned LEB128 - // constant operand and pushes the result. + // DESCRIPTION: pops the top stack entry, adds it to the unsigned + // LEB128 constant operand and pushes the result. //---------------------------------------------------------------------- case DW_OP_plus_uconst: if (stack.empty()) { @@ -2069,9 +2060,10 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_shr // OPERANDS: none - // DESCRIPTION: pops the top two stack entries, shifts the former second - // entry right logically (filling with zero bits) by the number of bits - // specified by the former top of the stack, and pushes the result. + // DESCRIPTION: pops the top two stack entries, shifts the former + // second entry right logically (filling with zero bits) by the number + // of bits specified by the former top of the stack, and pushes the + // result. //---------------------------------------------------------------------- case DW_OP_shr: if (stack.size() < 2) { @@ -2094,10 +2086,10 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_shra // OPERANDS: none - // DESCRIPTION: pops the top two stack entries, shifts the former second - // entry right arithmetically (divide the magnitude by 2, keep the same - // sign for the result) by the number of bits specified by the former - // top of the stack, and pushes the result. + // DESCRIPTION: pops the top two stack entries, shifts the former + // second entry right arithmetically (divide the magnitude by 2, keep + // the same sign for the result) by the number of bits specified by + // the former top of the stack, and pushes the result. //---------------------------------------------------------------------- case DW_OP_shra: if (stack.size() < 2) { @@ -2135,10 +2127,10 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_skip // OPERANDS: int16_t - // DESCRIPTION: An unconditional branch. Its single operand is a 2-byte - // signed integer constant. The 2-byte constant is the number of bytes - // of the DWARF expression to skip forward or backward from the current - // operation, beginning after the 2-byte constant. + // DESCRIPTION: An unconditional branch. Its single operand is a + // 2-byte signed integer constant. The 2-byte constant is the number + // of bytes of the DWARF expression to skip forward or backward from + // the current operation, beginning after the 2-byte constant. //---------------------------------------------------------------------- case DW_OP_skip: { int16_t skip_offset = (int16_t)opcodes.GetU16(&offset); @@ -2190,10 +2182,9 @@ // OPCODE: DW_OP_eq // OPERANDS: none // DESCRIPTION: pops the top two stack values, compares using the - // equals (==) operator. - // STACK RESULT: push the constant value 1 onto the stack if the result - // of the operation is true or the constant value 0 if the result of the - // operation is false. + // equals (==) operator. STACK RESULT: push the constant value 1 onto + // the stack if the result of the operation is true or the constant + // value 0 if the result of the operation is false. //---------------------------------------------------------------------- case DW_OP_eq: if (stack.size() < 2) { @@ -2213,10 +2204,10 @@ // OPCODE: DW_OP_ge // OPERANDS: none // DESCRIPTION: pops the top two stack values, compares using the - // greater than or equal to (>=) operator. - // STACK RESULT: push the constant value 1 onto the stack if the result - // of the operation is true or the constant value 0 if the result of the - // operation is false. + // greater than or equal to (>=) operator. STACK RESULT: push the + // constant value 1 onto the stack if the result of the operation is + // true or the constant value 0 if the result of the operation is + // false. //---------------------------------------------------------------------- case DW_OP_ge: if (stack.size() < 2) { @@ -2236,10 +2227,9 @@ // OPCODE: DW_OP_gt // OPERANDS: none // DESCRIPTION: pops the top two stack values, compares using the - // greater than (>) operator. - // STACK RESULT: push the constant value 1 onto the stack if the result - // of the operation is true or the constant value 0 if the result of the - // operation is false. + // greater than (>) operator. STACK RESULT: push the constant value 1 + // onto the stack if the result of the operation is true or the + // constant value 0 if the result of the operation is false. //---------------------------------------------------------------------- case DW_OP_gt: if (stack.size() < 2) { @@ -2258,11 +2248,10 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_le // OPERANDS: none - // DESCRIPTION: pops the top two stack values, compares using the - // less than or equal to (<=) operator. - // STACK RESULT: push the constant value 1 onto the stack if the result - // of the operation is true or the constant value 0 if the result of the - // operation is false. + // DESCRIPTION: pops the top two stack values, compares using the less + // than or equal to (<=) operator. STACK RESULT: push the constant + // value 1 onto the stack if the result of the operation is true or + // the constant value 0 if the result of the operation is false. //---------------------------------------------------------------------- case DW_OP_le: if (stack.size() < 2) { @@ -2281,11 +2270,10 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_lt // OPERANDS: none - // DESCRIPTION: pops the top two stack values, compares using the - // less than (<) operator. - // STACK RESULT: push the constant value 1 onto the stack if the result - // of the operation is true or the constant value 0 if the result of the - // operation is false. + // DESCRIPTION: pops the top two stack values, compares using the less + // than (<) operator. STACK RESULT: push the constant value 1 onto the + // stack if the result of the operation is true or the constant value + // 0 if the result of the operation is false. //---------------------------------------------------------------------- case DW_OP_lt: if (stack.size() < 2) { @@ -2304,11 +2292,10 @@ //---------------------------------------------------------------------- // OPCODE: DW_OP_ne // OPERANDS: none - // DESCRIPTION: pops the top two stack values, compares using the - // not equal (!=) operator. - // STACK RESULT: push the constant value 1 onto the stack if the result - // of the operation is true or the constant value 0 if the result of the - // operation is false. + // DESCRIPTION: pops the top two stack values, compares using the not + // equal (!=) operator. STACK RESULT: push the constant value 1 onto + // the stack if the result of the operation is true or the constant + // value 0 if the result of the operation is false. //---------------------------------------------------------------------- case DW_OP_ne: if (stack.size() < 2) { @@ -2428,8 +2415,8 @@ // OPCODE: DW_OP_bregN // OPERANDS: // SLEB128 offset from register N - // DESCRIPTION: Value is in memory at the address specified by register - // N plus an offset. + // DESCRIPTION: Value is in memory at the address specified by + // register N plus an offset. //---------------------------------------------------------------------- case DW_OP_breg0: case DW_OP_breg1: @@ -2480,8 +2467,8 @@ // OPERANDS: 2 // ULEB128 literal operand that encodes the register. // SLEB128 offset from register N - // DESCRIPTION: Value is in memory at the address specified by register - // N plus an offset. + // DESCRIPTION: Value is in memory at the address specified by + // register N plus an offset. //---------------------------------------------------------------------- case DW_OP_bregx: { reg_num = opcodes.GetULEB128(&offset); @@ -2536,14 +2523,14 @@ // OPCODE: DW_OP_piece // OPERANDS: 1 // ULEB128: byte size of the piece - // DESCRIPTION: The operand describes the size in bytes of the piece of - // the object referenced by the DWARF expression whose result is at the - // top of the stack. If the piece is located in a register, but does not - // occupy the entire register, the placement of the piece within that - // register is defined by the ABI. + // DESCRIPTION: The operand describes the size in bytes of the piece + // of the object referenced by the DWARF expression whose result is at + // the top of the stack. If the piece is located in a register, but + // does not occupy the entire register, the placement of the piece + // within that register is defined by the ABI. // - // Many compilers store a single variable in sets of registers, or store - // a variable partially in memory and partially in registers. + // Many compilers store a single variable in sets of registers, or + // store a variable partially in memory and partially in registers. // DW_OP_piece provides a way of describing how large a part of a // variable a particular DWARF expression refers to. //---------------------------------------------------------------------- @@ -2554,9 +2541,9 @@ Value curr_piece; if (stack.empty()) { - // In a multi-piece expression, this means that the current piece is - // not available. - // Fill with zeros for now by resizing the data and appending it + // In a multi-piece expression, this means that the current + // piece is not available. Fill with zeros for now by resizing + // the data and appending it curr_piece.ResizeData(piece_byte_size); ::memset(curr_piece.GetBuffer().GetBytes(), 0, piece_byte_size); pieces.AppendDataToHostBuffer(curr_piece); @@ -2646,17 +2633,17 @@ // Check if this is the first piece? if (op_piece_offset == 0) { - // This is the first piece, we should push it back onto the stack so - // subsequent - // pieces will be able to access this piece and add to it + // This is the first piece, we should push it back onto the + // stack so subsequent pieces will be able to access this + // piece and add to it if (pieces.AppendDataToHostBuffer(curr_piece) == 0) { if (error_ptr) error_ptr->SetErrorString("failed to append piece data"); return false; } } else { - // If this is the second or later piece there should be a value on - // the stack + // If this is the second or later piece there should be a + // value on the stack if (pieces.GetBuffer().GetByteSize() != op_piece_offset) { if (error_ptr) error_ptr->SetErrorStringWithFormat( @@ -2729,9 +2716,9 @@ // DESCRIPTION: Pushes the address of the object currently being // evaluated as part of evaluation of a user presented expression. // This object may correspond to an independent variable described by - // its own DIE or it may be a component of an array, structure, or class - // whose address has been dynamically determined by an earlier step - // during user expression evaluation. + // its own DIE or it may be a component of an array, structure, or + // class whose address has been dynamically determined by an earlier + // step during user expression evaluation. //---------------------------------------------------------------------- case DW_OP_push_object_address: if (object_address_ptr) @@ -2748,22 +2735,22 @@ // OPCODE: DW_OP_call2 // OPERANDS: // uint16_t compile unit relative offset of a DIE - // DESCRIPTION: Performs subroutine calls during evaluation - // of a DWARF expression. The operand is the 2-byte unsigned offset - // of a debugging information entry in the current compilation unit. + // DESCRIPTION: Performs subroutine calls during evaluation of a DWARF + // expression. The operand is the 2-byte unsigned offset of a + // debugging information entry in the current compilation unit. // // Operand interpretation is exactly like that for DW_FORM_ref2. // - // This operation transfers control of DWARF expression evaluation - // to the DW_AT_location attribute of the referenced DIE. If there is - // no such attribute, then there is no effect. Execution of the DWARF - // expression of a DW_AT_location attribute may add to and/or remove from - // values on the stack. Execution returns to the point following the call - // when the end of the attribute is reached. Values on the stack at the - // time of the call may be used as parameters by the called expression - // and values left on the stack by the called expression may be used as - // return values by prior agreement between the calling and called - // expressions. + // This operation transfers control of DWARF expression evaluation to + // the DW_AT_location attribute of the referenced DIE. If there is no + // such attribute, then there is no effect. Execution of the DWARF + // expression of a DW_AT_location attribute may add to and/or remove + // from values on the stack. Execution returns to the point following + // the call when the end of the attribute is reached. Values on the + // stack at the time of the call may be used as parameters by the + // called expression and values left on the stack by the called + // expression may be used as return values by prior agreement between + // the calling and called expressions. //---------------------------------------------------------------------- case DW_OP_call2: if (error_ptr) @@ -2773,23 +2760,24 @@ // OPCODE: DW_OP_call4 // OPERANDS: 1 // uint32_t compile unit relative offset of a DIE - // DESCRIPTION: Performs a subroutine call during evaluation of a DWARF - // expression. For DW_OP_call4, the operand is a 4-byte unsigned offset - // of a debugging information entry in the current compilation unit. + // DESCRIPTION: Performs a subroutine call during evaluation of a + // DWARF expression. For DW_OP_call4, the operand is a 4-byte unsigned + // offset of a debugging information entry in the current compilation + // unit. // // Operand interpretation DW_OP_call4 is exactly like that for // DW_FORM_ref4. // - // This operation transfers control of DWARF expression evaluation - // to the DW_AT_location attribute of the referenced DIE. If there is - // no such attribute, then there is no effect. Execution of the DWARF - // expression of a DW_AT_location attribute may add to and/or remove from - // values on the stack. Execution returns to the point following the call - // when the end of the attribute is reached. Values on the stack at the - // time of the call may be used as parameters by the called expression - // and values left on the stack by the called expression may be used as - // return values by prior agreement between the calling and called - // expressions. + // This operation transfers control of DWARF expression evaluation to + // the DW_AT_location attribute of the referenced DIE. If there is no + // such attribute, then there is no effect. Execution of the DWARF + // expression of a DW_AT_location attribute may add to and/or remove + // from values on the stack. Execution returns to the point following + // the call when the end of the attribute is reached. Values on the + // stack at the time of the call may be used as parameters by the + // called expression and values left on the stack by the called + // expression may be used as return values by prior agreement between + // the calling and called expressions. //---------------------------------------------------------------------- case DW_OP_call4: if (error_ptr) @@ -2812,13 +2800,14 @@ // OPCODE: DW_OP_call_frame_cfa // OPERANDS: None // DESCRIPTION: Specifies a DWARF expression that pushes the value of - // the canonical frame address consistent with the call frame information - // located in .debug_frame (or in the FDEs of the eh_frame section). + // the canonical frame address consistent with the call frame + // information located in .debug_frame (or in the FDEs of the eh_frame + // section). //---------------------------------------------------------------------- case DW_OP_call_frame_cfa: if (frame) { - // Note that we don't have to parse FDEs because this DWARF expression - // is commonly evaluated with a valid stack frame. + // Note that we don't have to parse FDEs because this DWARF + // expression is commonly evaluated with a valid stack frame. StackID id = frame->GetStackID(); addr_t cfa = id.GetCallFrameAddress(); if (cfa != LLDB_INVALID_ADDRESS) { @@ -2837,12 +2826,11 @@ break; //---------------------------------------------------------------------- - // OPCODE: DW_OP_form_tls_address (or the old pre-DWARFv3 vendor extension - // opcode, DW_OP_GNU_push_tls_address) - // OPERANDS: none - // DESCRIPTION: Pops a TLS offset from the stack, converts it to - // an address in the current thread's thread-local storage block, - // and pushes it on the stack. + // OPCODE: DW_OP_form_tls_address (or the old pre-DWARFv3 vendor + // extension opcode, DW_OP_GNU_push_tls_address) OPERANDS: none + // DESCRIPTION: Pops a TLS offset from the stack, converts it to an + // address in the current thread's thread-local storage block, and + // pushes it on the stack. //---------------------------------------------------------------------- case DW_OP_form_tls_address: case DW_OP_GNU_push_tls_address: { @@ -2918,10 +2906,10 @@ // OPCODE: DW_OP_GNU_const_index // OPERANDS: 1 // ULEB128: index to the .debug_addr section - // DESCRIPTION: Pushes an constant with the size of a machine address to - // the stack from the .debug_addr section with the base address specified - // by the DW_AT_addr_base attribute and the 0 based index is the ULEB128 - // encoded index. + // DESCRIPTION: Pushes an constant with the size of a machine address + // to the stack from the .debug_addr section with the base address + // specified by the DW_AT_addr_base attribute and the 0 based index is + // the ULEB128 encoded index. //---------------------------------------------------------------------- case DW_OP_GNU_const_index: { if (!dwarf_cu) { @@ -2958,8 +2946,8 @@ } if (stack.empty()) { - // Nothing on the stack, check if we created a piece value from DW_OP_piece - // or DW_OP_bit_piece opcodes + // Nothing on the stack, check if we created a piece value from + // DW_OP_piece or DW_OP_bit_piece opcodes if (pieces.GetBuffer().GetByteSize()) { result = pieces; } else { Index: source/Expression/DiagnosticManager.cpp =================================================================== --- source/Expression/DiagnosticManager.cpp +++ source/Expression/DiagnosticManager.cpp @@ -22,9 +22,8 @@ std::string str = GetString(); - // GetString() puts a separator after each diagnostic. - // We want to remove the last '\n' because log->PutCString will add one for - // us. + // GetString() puts a separator after each diagnostic. We want to remove + // the last '\n' because log->PutCString will add one for us. if (str.size() && str.back() == '\n') { str.pop_back(); Index: source/Expression/ExpressionSourceCode.cpp =================================================================== --- source/Expression/ExpressionSourceCode.cpp +++ source/Expression/ExpressionSourceCode.cpp @@ -93,15 +93,15 @@ m_state = CURRENT_FILE_POPPED; } - // An entry is valid if it occurs before the current line in - // the current file. + // An entry is valid if it occurs before the current line in the current + // file. bool IsValidEntry(uint32_t line) { switch (m_state) { case CURRENT_FILE_NOT_YET_PUSHED: return true; case CURRENT_FILE_PUSHED: - // If we are in file included in the current file, - // the entry should be added. + // If we are in file included in the current file, the entry should + // be added. if (m_file_stack.back() != m_current_file) return true; @@ -281,8 +281,8 @@ debug_macros_stream.GetData(), g_expression_prefix, target_specific_defines, m_prefix.c_str()); - // First construct a tagged form of the user expression so we can find it - // later: + // First construct a tagged form of the user expression so we can find + // it later: std::string tagged_body; switch (wrapping_language) { default: Index: source/Expression/ExpressionVariable.cpp =================================================================== --- source/Expression/ExpressionVariable.cpp +++ source/Expression/ExpressionVariable.cpp @@ -69,9 +69,9 @@ for (const IRExecutionUnit::JittedGlobalVariable &global_var : execution_unit_sp->GetJittedGlobalVariables()) { if (global_var.m_remote_addr != LLDB_INVALID_ADDRESS) { - // Demangle the name before inserting it, so that lookups by the ConstStr - // of the demangled name - // will find the mangled one (needed for looking up metadata pointers.) + // Demangle the name before inserting it, so that lookups by the + // ConstStr of the demangled name will find the mangled one (needed + // for looking up metadata pointers.) Mangled mangler(global_var.m_name); mangler.GetDemangledName(lldb::eLanguageTypeUnknown); m_symbol_map[global_var.m_name.GetCString()] = global_var.m_remote_addr; Index: source/Expression/FunctionCaller.cpp =================================================================== --- source/Expression/FunctionCaller.cpp +++ source/Expression/FunctionCaller.cpp @@ -120,8 +120,8 @@ diagnostic_manager); } -// FIXME: Assure that the ValueList we were passed in is consistent with the one -// that defined this function. +// FIXME: Assure that the ValueList we were passed in is consistent with +// the one that defined this function. bool FunctionCaller::WriteFunctionArguments( ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, @@ -191,8 +191,8 @@ // FIXME: For now just do scalars: - // Special case: if it's a pointer, don't do anything (the ABI supports - // passing cstrings) + // Special case: if it's a pointer, don't do anything (the ABI + // supports passing cstrings) if (arg_value->GetValueType() == Value::eValueTypeHostAddress && arg_value->GetContextType() == Value::eContextTypeInvalid && @@ -264,12 +264,11 @@ bool FunctionCaller::FetchFunctionResults(ExecutionContext &exe_ctx, lldb::addr_t args_addr, Value &ret_value) { - // Read the return value - it is the last field in the struct: - // FIXME: How does clang tell us there's no return value? We need to handle - // that case. - // FIXME: Create our ThreadPlanCallFunction with the return CompilerType, and - // then use GetReturnValueObject - // to fetch the value. That way we can fetch any values we need. + // Read the return value - it is the last field in the struct: FIXME: + // How does clang tell us there's no return value? We need to handle + // that case. FIXME: Create our ThreadPlanCallFunction with the return + // CompilerType, and then use GetReturnValueObject to fetch the value. + // That way we can fetch any values we need. Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP)); @@ -318,9 +317,9 @@ DiagnosticManager &diagnostic_manager, Value &results) { lldb::ExpressionResults return_value = lldb::eExpressionSetupError; - // FunctionCaller::ExecuteFunction execution is always just to get the result. - // Do make sure we ignore - // breakpoints, unwind on error, and don't try to debug it. + // FunctionCaller::ExecuteFunction execution is always just to get the + // result. Do make sure we ignore breakpoints, unwind on error, and + // don't try to debug it. EvaluateExpressionOptions real_options = options; real_options.SetDebug(false); real_options.SetUnwindOnError(true); @@ -354,10 +353,9 @@ if (!call_plan_sp) return lldb::eExpressionSetupError; - // We need to make sure we record the fact that we are running an expression - // here - // otherwise this fact will fail to be recorded when fetching an Objective-C - // object description + // We need to make sure we record the fact that we are running an + // expression here otherwise this fact will fail to be recorded when + // fetching an Objective-C object description if (exe_ctx.GetProcessPtr()) exe_ctx.GetProcessPtr()->SetRunningUserExpression(true); Index: source/Expression/IRDynamicChecks.cpp =================================================================== --- source/Expression/IRDynamicChecks.cpp +++ source/Expression/IRDynamicChecks.cpp @@ -82,9 +82,8 @@ bool DynamicCheckerFunctions::DoCheckersExplainStop(lldb::addr_t addr, Stream &message) { - // FIXME: We have to get the checkers to know why they scotched the call in - // more detail, - // so we can print a better message here. + // FIXME: We have to get the checkers to know why they scotched the call + // in more detail, so we can print a better message here. if (m_valid_pointer_check && m_valid_pointer_check->ContainsAddress(addr)) { message.Printf("Attempted to dereference an invalid pointer."); return true; Index: source/Expression/IRExecutionUnit.cpp =================================================================== --- source/Expression/IRExecutionUnit.cpp +++ source/Expression/IRExecutionUnit.cpp @@ -316,8 +316,8 @@ std::unique_ptr getObject(const llvm::Module *module) override { - // Return nothing - we're just abusing the object-cache mechanism to dump - // objects. + // Return nothing - we're just abusing the object-cache mechanism to + // dump objects. return nullptr; } }; @@ -361,13 +361,11 @@ CommitAllocations(process_sp); ReportAllocations(*m_execution_engine_ap); - // We have to do this after calling ReportAllocations because for the MCJIT, - // getGlobalValueAddress - // will cause the JIT to perform all relocations. That can only be done once, - // and has to happen - // after we do the remapping from local -> remote. - // That means we don't know the local address of the Variables, but we don't - // need that for anything, + // We have to do this after calling ReportAllocations because for the + // MCJIT, getGlobalValueAddress will cause the JIT to perform all + // relocations. That can only be done once, and has to happen after we + // do the remapping from local -> remote. That means we don't know the + // local address of the Variables, but we don't need that for anything, // so that's okay. std::function RegisterOneValue = [this]( @@ -378,9 +376,10 @@ lldb::addr_t remote_addr = GetRemoteAddressForLocal(var_ptr_addr); - // This is a really unfortunae API that sometimes returns local addresses - // and sometimes returns remote addresses, based on whether - // the variable was relocated during ReportAllocations or not. + // This is a really unfortunae API that sometimes returns local + // addresses and sometimes returns remote addresses, based on + // whether the variable was relocated during ReportAllocations or + // not. if (remote_addr == LLDB_INVALID_ADDRESS) { remote_addr = var_ptr_addr; @@ -755,8 +754,8 @@ void IRExecutionUnit::CollectFallbackNames( std::vector &fallback_specs, const std::vector &C_specs) { - // As a last-ditch fallback, try the base name for C++ names. It's terrible, - // but the DWARF doesn't always encode "extern C" correctly. + // As a last-ditch fallback, try the base name for C++ names. It's + // terrible, but the DWARF doesn't always encode "extern C" correctly. for (const SearchSpec &C_spec : C_specs) { const ConstString &name = C_spec.name; @@ -882,8 +881,8 @@ if (get_external_load_address(load_address, sc_list, sc)) { return load_address; } - // if there are any searches we try after this, add an sc_list.Clear() in an - // "else" clause here + // if there are any searches we try after this, add an sc_list.Clear() + // in an "else" clause here if (best_internal_load_address != LLDB_INVALID_ADDRESS) { return best_internal_load_address; Index: source/Expression/IRInterpreter.cpp =================================================================== --- source/Expression/IRInterpreter.cpp +++ source/Expression/IRInterpreter.cpp @@ -443,8 +443,8 @@ "Interpreter doesn't handle one of the expression's opcodes"; static const char *unsupported_operand_error = "Interpreter doesn't handle one of the expression's operands"; -// static const char *interpreter_initialization_error = "Interpreter couldn't -// be initialized"; +// static const char *interpreter_initialization_error = "Interpreter +// couldn't be initialized"; static const char *interpreter_internal_error = "Interpreter encountered an internal error"; static const char *bad_value_error = @@ -454,8 +454,8 @@ static const char *memory_write_error = "Interpreter couldn't write to memory"; static const char *memory_read_error = "Interpreter couldn't read from memory"; static const char *infinite_loop_error = "Interpreter ran for too many cycles"; -// static const char *bad_result_error = "Result of expression -// is in bad memory"; +// static const char *bad_result_error = "Result of +// expression is in bad memory"; static const char *too_many_functions_error = "Interpreter doesn't handle modules with multiple function bodies."; @@ -1559,7 +1559,8 @@ // Find number of arguments const int numArgs = call_inst->getNumArgOperands(); - // We work with a fixed array of 16 arguments which is our upper limit + // We work with a fixed array of 16 arguments which is our upper + // limit static lldb_private::ABI::CallArgument rawArgs[16]; if (numArgs >= 16) { error.SetErrorToGenericError(); @@ -1567,8 +1568,8 @@ return false; } - // Push all function arguments to the argument list that will - // be passed to the call function thread plan + // Push all function arguments to the argument list that will be + // passed to the call function thread plan for (int i = 0; i < numArgs; i++) { // Get details of this argument llvm::Value *arg_op = call_inst->getArgOperand(i); Index: source/Expression/IRMemoryMap.cpp =================================================================== --- source/Expression/IRMemoryMap.cpp +++ source/Expression/IRMemoryMap.cpp @@ -47,14 +47,14 @@ // The FindSpace algorithm's job is to find a region of memory that the // underlying process is unlikely to be using. // - // The memory returned by this function will never be written to. The only - // point is that it should not shadow process memory if possible, so that - // expressions processing real values from the process do not use the - // wrong data. + // The memory returned by this function will never be written to. The + // only point is that it should not shadow process memory if possible, + // so that expressions processing real values from the process do not + // use the wrong data. // - // If the process can in fact allocate memory (CanJIT() lets us know this) - // then this can be accomplished just be allocating memory in the inferior. - // Then no guessing is required. + // If the process can in fact allocate memory (CanJIT() lets us know + // this) then this can be accomplished just be allocating memory in the + // inferior. Then no guessing is required. lldb::TargetSP target_sp = m_target_wp.lock(); lldb::ProcessSP process_sp = m_process_wp.lock(); @@ -80,8 +80,8 @@ // At this point we know that we need to hunt. // - // First, go to the end of the existing allocations we've made if there are - // any allocations. Otherwise start at the beginning of memory. + // First, go to the end of the existing allocations we've made if there + // are any allocations. Otherwise start at the beginning of memory. if (m_allocations.empty()) { ret = 0x0; @@ -92,9 +92,9 @@ ret = llvm::alignTo(addr + alloc_size, 4096); } - // Now, if it's possible to use the GetMemoryRegionInfo API to detect mapped - // regions, walk forward through memory until a region is found that - // has adequate space for our allocation. + // Now, if it's possible to use the GetMemoryRegionInfo API to detect + // mapped regions, walk forward through memory until a region is found + // that has adequate space for our allocation. if (process_is_alive) { const uint64_t end_of_memory = process_sp->GetAddressByteSize() == 8 ? 0xffffffffffffffffull @@ -134,9 +134,9 @@ } } - // We've tried our algorithm, and it didn't work. Now we have to reset back - // to the end of the allocations we've already reported, or use a 'sensible' - // default if this is our first allocation. + // We've tried our algorithm, and it didn't work. Now we have to reset + // back to the end of the allocations we've already reported, or use a + // 'sensible' default if this is our first allocation. if (m_allocations.empty()) { uint32_t address_byte_size = GetAddressByteSize(); @@ -187,17 +187,13 @@ AllocationMap::const_iterator iter = m_allocations.lower_bound(addr); - // Since we only know that the returned interval begins at a location greater - // than or - // equal to where the given interval begins, it's possible that the given - // interval - // intersects either the returned interval or the previous interval. Thus, we - // need to - // check both. Note that we only need to check these two intervals. Since all - // intervals + // Since we only know that the returned interval begins at a location + // greater than or equal to where the given interval begins, it's + // possible that the given interval intersects either the returned + // interval or the previous interval. Thus, we need to check both. Note + // that we only need to check these two intervals. Since all intervals // are disjoint it is not possible that an adjacent interval does not - // intersect, but a - // non-adjacent interval does intersect. + // intersect, but a non-adjacent interval does intersect. if (iter != m_allocations.end()) { if (AllocationsIntersect(addr, size, iter->second.m_process_start, iter->second.m_size)) @@ -216,17 +212,11 @@ bool IRMemoryMap::AllocationsIntersect(lldb::addr_t addr1, size_t size1, lldb::addr_t addr2, size_t size2) { - // Given two half open intervals [A, B) and [X, Y), the only 6 permutations - // that satisfy - // Am_live_sp) { // If the reference comes from the program, then the - // ClangExpressionVariable's - // live variable data hasn't been set up yet. Do this now. + // ClangExpressionVariable's live variable data hasn't been set up + // yet. Do this now. lldb::addr_t location; Status read_error; @@ -256,10 +257,8 @@ frame_bottom != LLDB_INVALID_ADDRESS && location >= frame_bottom && location <= frame_top) { // If the variable is resident in the stack frame created by the - // expression, - // then it cannot be relied upon to stay around. We treat it as - // needing - // reallocation. + // expression, then it cannot be relied upon to stay around. We + // treat it as needing reallocation. m_persistent_variable_sp->m_flags |= ExpressionVariable::EVIsLLDBAllocated; m_persistent_variable_sp->m_flags |= @@ -330,8 +329,8 @@ lldb::ProcessSP process_sp = map.GetBestExecutionContextScope()->CalculateProcess(); if (!process_sp || !process_sp->CanJIT()) { - // Allocations are not persistent so persistent variables cannot stay - // materialized. + // Allocations are not persistent so persistent variables cannot + // stay materialized. m_persistent_variable_sp->m_flags |= ExpressionVariable::EVNeedsAllocation; @@ -1269,8 +1268,8 @@ if (!memcmp(register_data.GetDataStart(), m_register_contents->GetBytes(), register_data.GetByteSize())) { - // No write required, and in particular we avoid errors if the register - // wasn't writable + // No write required, and in particular we avoid errors if the + // register wasn't writable m_register_contents.reset(); return; Index: source/Expression/REPL.cpp =================================================================== --- source/Expression/REPL.cpp +++ source/Expression/REPL.cpp @@ -219,8 +219,8 @@ // Strip the ':' code.erase(0, 1); if (Args::StripSpaces(code)) { - // "lldb" was followed by arguments, so just execute the command dump - // the results + // "lldb" was followed by arguments, so just execute the command + // dump the results // Turn off prompt on quit in case the user types ":quit" const bool saved_prompt_on_quit = ci.GetPromptOnQuit(); @@ -241,28 +241,28 @@ io_handler.SetIsDone(true); if (debugger.CheckTopIOHandlerTypes( IOHandler::Type::REPL, IOHandler::Type::CommandInterpreter)) { - // We typed "quit" or an alias to quit so we need to check if the - // command interpreter is above us and tell it that it is done as - // well - // so we don't drop back into the command interpreter if we have - // already - // quit + // We typed "quit" or an alias to quit so we need to check if + // the command interpreter is above us and tell it that it is + // done as well so we don't drop back into the command + // interpreter if we have already quit lldb::IOHandlerSP io_handler_sp(ci.GetIOHandler()); if (io_handler_sp) io_handler_sp->SetIsDone(true); } } } else { - // ":" was followed by no arguments, so push the LLDB command prompt + // ":" was followed by no arguments, so push the LLDB command + // prompt if (debugger.CheckTopIOHandlerTypes( IOHandler::Type::REPL, IOHandler::Type::CommandInterpreter)) { - // If the user wants to get back to the command interpreter and the - // command interpreter is what launched the REPL, then just let the - // REPL exit and fall back to the command interpreter. + // If the user wants to get back to the command interpreter and + // the command interpreter is what launched the REPL, then just + // let the REPL exit and fall back to the command interpreter. io_handler.SetIsDone(true); } else { - // The REPL wasn't launched the by the command interpreter, it is the - // base IOHandler, so we need to get the command interpreter and + // The REPL wasn't launched the by the command interpreter, it + // is the base IOHandler, so we need to get the command + // interpreter and lldb::IOHandlerSP io_handler_sp(ci.GetIOHandler()); if (io_handler_sp) { io_handler_sp->SetIsDone(false); @@ -444,8 +444,8 @@ } } - // Don't complain about the REPL process going away if we are in the process - // of quitting. + // Don't complain about the REPL process going away if we are in the + // process of quitting. if (!did_quit && (!process_sp || !process_sp->IsAlive())) { error_sp->Printf( "error: REPL process is no longer alive, exiting REPL\n"); @@ -543,13 +543,11 @@ debugger.PushIOHandler(io_handler_sp); // Check if we are in dedicated REPL mode where LLDB was start with the - // "--repl" option - // from the command line. Currently we know this by checking if the debugger - // already - // has a IOHandler thread. + // "--repl" option from the command line. Currently we know this by + // checking if the debugger already has a IOHandler thread. if (!debugger.HasIOHandlerThread()) { - // The debugger doesn't have an existing IOHandler thread, so this must be - // dedicated REPL mode... + // The debugger doesn't have an existing IOHandler thread, so this + // must be dedicated REPL mode... m_dedicated_repl_mode = true; debugger.StartIOHandlerThread(); llvm::StringRef command_name_str("quit"); @@ -572,8 +570,8 @@ if (process_sp && process_sp->IsAlive()) process_sp->Destroy(false); - // Wait for the IO handler thread to exit (TODO: don't do this if the IO - // handler thread already exists...) + // Wait for the IO handler thread to exit (TODO: don't do this if the + // IO handler thread already exists...) debugger.JoinIOHandlerThread(); } Index: source/Expression/UserExpression.cpp =================================================================== --- source/Expression/UserExpression.cpp +++ source/Expression/UserExpression.cpp @@ -178,10 +178,9 @@ if (process == NULL || !process->CanJIT()) execution_policy = eExecutionPolicyNever; - // We need to set the expression execution thread here, turns out parse can - // call functions in the process of - // looking up symbols, which will escape the context set by exe_ctx passed to - // Execute. + // We need to set the expression execution thread here, turns out parse + // can call functions in the process of looking up symbols, which will + // escape the context set by exe_ctx passed to Execute. lldb::ThreadSP thread_sp = exe_ctx.GetThreadSP(); ThreadList::ExpressionExecutionThreadPusher execution_thread_pusher( thread_sp); @@ -198,9 +197,9 @@ else full_prefix = option_prefix; - // If the language was not specified in the expression command, - // set it to the language in the target's properties if - // specified, else default to the langage for the frame. + // If the language was not specified in the expression command, set it + // to the language in the target's properties if specified, else default + // to the langage for the frame. if (language == lldb::eLanguageTypeUnknown) { if (target->GetLanguage() != lldb::eLanguageTypeUnknown) language = target->GetLanguage(); @@ -264,8 +263,8 @@ diagnostic_manager.Clear(); user_expression_sp = fixed_expression_sp; } else { - // If the fixed expression failed to parse, don't tell the user about, - // that won't help. + // If the fixed expression failed to parse, don't tell the user + // about, that won't help. fixed_expression->clear(); } } @@ -288,8 +287,8 @@ } if (parse_success) { - // If a pointer to a lldb::ModuleSP was passed in, return the JIT'ed module - // if one was created + // If a pointer to a lldb::ModuleSP was passed in, return the JIT'ed + // module if one was created if (jit_module_sp_ptr) *jit_module_sp_ptr = user_expression_sp->GetJITModule(); Index: source/Expression/UtilityFunction.cpp =================================================================== --- source/Expression/UtilityFunction.cpp +++ source/Expression/UtilityFunction.cpp @@ -60,8 +60,8 @@ } } -// FIXME: We should check that every time this is called it is called with the -// same return type & arguments... +// FIXME: We should check that every time this is called it is called with +// the same return type & arguments... FunctionCaller *UtilityFunction::MakeFunctionCaller( const CompilerType &return_type, const ValueList &arg_value_list, Index: source/Host/android/HostInfoAndroid.cpp =================================================================== --- source/Host/android/HostInfoAndroid.cpp +++ source/Host/android/HostInfoAndroid.cpp @@ -78,12 +78,10 @@ bool HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec &file_spec) { bool success = HostInfoLinux::ComputeTempFileBaseDirectory(file_spec); - // On Android, there is no path which is guaranteed to be writable. If the - // user has not - // provided a path via an environment variable, the generic algorithm will - // deduce /tmp, which - // is plain wrong. In that case we have an invalid directory, we substitute - // the path with + // On Android, there is no path which is guaranteed to be writable. If + // the user has not provided a path via an environment variable, the + // generic algorithm will deduce /tmp, which is plain wrong. In that + // case we have an invalid directory, we substitute the path with // /data/local/tmp, which is correct at least in some cases (i.e., when // running as shell user). if (!success || !file_spec.Exists()) Index: source/Host/android/LibcGlue.cpp =================================================================== --- source/Host/android/LibcGlue.cpp +++ source/Host/android/LibcGlue.cpp @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// -// This files adds functions missing from libc on earlier versions of Android +// This files adds functions missing from libc on earlier versions of +// Android #include Index: source/Host/common/Editline.cpp =================================================================== --- source/Host/common/Editline.cpp +++ source/Host/common/Editline.cpp @@ -28,13 +28,14 @@ using namespace lldb_private; using namespace lldb_private::line_editor; -// Workaround for what looks like an OS X-specific issue, but other platforms -// may benefit from something similar if issues arise. The libedit library -// doesn't explicitly initialize the curses termcap library, which it gets away -// with until TERM is set to VT100 where it stumbles over an implementation -// assumption that may not exist on other platforms. The setupterm() function -// would normally require headers that don't work gracefully in this context, so -// the function declaraction has been hoisted here. +// Workaround for what looks like an OS X-specific issue, but other +// platforms may benefit from something similar if issues arise. The +// libedit library doesn't explicitly initialize the curses termcap +// library, which it gets away with until TERM is set to VT100 where it +// stumbles over an implementation assumption that may not exist on other +// platforms. The setupterm() function would normally require headers +// that don't work gracefully in this context, so the function +// declaraction has been hoisted here. #if defined(__APPLE__) extern "C" { int setupterm(char *term, int fildes, int *errret); @@ -42,13 +43,12 @@ #define USE_SETUPTERM_WORKAROUND #endif -// Editline uses careful cursor management to achieve the illusion of editing a -// multi-line block of text -// with a single line editor. Preserving this illusion requires fairly careful -// management of cursor +// Editline uses careful cursor management to achieve the illusion of +// editing a multi-line block of text with a single line editor. +// Preserving this illusion requires fairly careful management of cursor // state. Read and understand the relationship between DisplayInput(), -// MoveCursor(), SetCurrentLine(), -// and SaveEditedLine() before making changes. +// MoveCursor(), SetCurrentLine(), and SaveEditedLine() before making +// changes. #define ESCAPE "\x1b" #define ANSI_FAINT ESCAPE "[2m" @@ -70,8 +70,7 @@ #define EditLineStringFormatSpec "%s" // use #defines so wide version functions and structs will resolve to old -// versions -// for case of libedit not built with wide char support +// versions for case of libedit not built with wide char support #define history_w history #define history_winit history_init #define history_wend history_end @@ -142,12 +141,10 @@ } bool IsInputPending(FILE *file) { - // FIXME: This will be broken on Windows if we ever re-enable Editline. You - // can't use select - // on something that isn't a socket. This will have to be re-written to not - // use a FILE*, but - // instead use some kind of yet-to-be-created abstraction that select-like - // functionality on + // FIXME: This will be broken on Windows if we ever re-enable Editline. + // You can't use select on something that isn't a socket. This will + // have to be re-written to not use a FILE*, but instead use some kind + // of yet-to-be-created abstraction that select-like functionality on // non-socket objects. const int fd = fileno(file); SelectHelper select_helper; @@ -160,13 +157,13 @@ namespace line_editor { typedef std::weak_ptr EditlineHistoryWP; -// EditlineHistory objects are sometimes shared between multiple -// Editline instances with the same program name. +// EditlineHistory objects are sometimes shared between multiple Editline +// instances with the same program name. class EditlineHistory { private: - // Use static GetHistory() function to get a EditlineHistorySP to one of these - // objects + // Use static GetHistory() function to get a EditlineHistorySP to one of + // these objects EditlineHistory(const std::string &prefix, uint32_t size, bool unique_entries) : m_history(NULL), m_event(), m_prefix(prefix), m_path() { m_history = history_winit(); @@ -436,11 +433,10 @@ if (history_w(pHistory, &history_event, H_FIRST) == -1) return CC_ERROR; - // Save any edits to the "live" entry in case we return by moving forward in - // history - // (it would be more bash-like to save over any current entry, but libedit - // doesn't - // offer the ability to add entries anywhere except the end.) + // Save any edits to the "live" entry in case we return by moving + // forward in history (it would be more bash-like to save over any + // current entry, but libedit doesn't offer the ability to add entries + // anywhere except the end.) SaveEditedLine(); m_live_history_lines = m_input_lines; m_in_history = true; @@ -465,9 +461,8 @@ m_input_lines = new_input_lines; DisplayInput(); - // Prepare to edit the last line when moving to previous entry, or the first - // line - // when moving to next entry + // Prepare to edit the last line when moving to previous entry, or the + // first line when moving to next entry SetCurrentLine(m_current_line_index = earlier ? (int)m_input_lines.size() - 1 : 0); MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt); @@ -477,8 +472,8 @@ int Editline::GetCharacter(EditLineGetCharType *c) { const LineInfoW *info = el_wline(m_editline); - // Paint a faint version of the desired prompt over the version libedit draws - // (will only be requested if colors are supported) + // Paint a faint version of the desired prompt over the version libedit + // draws (will only be requested if colors are supported) if (m_needs_prompt_repaint) { MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingPrompt); fprintf(m_output_file, "%s" @@ -490,8 +485,8 @@ } if (m_multiline_enabled) { - // Detect when the number of rows used for this input line changes due to an - // edit + // Detect when the number of rows used for this input line changes due + // to an edit int lineLength = (int)((info->lastchar - info->buffer) + GetPromptWidth()); int new_line_rows = (lineLength / m_terminal_width) + 1; if (m_current_line_rows != -1 && new_line_rows != m_current_line_rows) { @@ -509,13 +504,11 @@ lldb::ConnectionStatus status = lldb::eConnectionStatusSuccess; char ch = 0; - // This mutex is locked by our caller (GetLine). Unlock it while we read a - // character - // (blocking operation), so we do not hold the mutex indefinitely. This - // gives a chance - // for someone to interrupt us. After Read returns, immediately lock the - // mutex again and - // check if we were interrupted. + // This mutex is locked by our caller (GetLine). Unlock it while we + // read a character (blocking operation), so we do not hold the mutex + // indefinitely. This gives a chance for someone to interrupt us. + // After Read returns, immediately lock the mutex again and check if + // we were interrupted. m_output_mutex.unlock(); int read_count = m_input_connection.Read(&ch, 1, llvm::None, status, NULL); m_output_mutex.lock(); @@ -558,7 +551,8 @@ } unsigned char Editline::BreakLineCommand(int ch) { - // Preserve any content beyond the cursor, truncate and save the current line + // Preserve any content beyond the cursor, truncate and save the current + // line const LineInfoW *info = el_wline(m_editline); auto current_line = EditLineStringType(info->buffer, info->cursor - info->buffer); @@ -570,8 +564,8 @@ if (::IsOnlySpaces(new_line_fragment)) new_line_fragment = EditLineConstString(""); - // Establish the new cursor position at the start of a line when inserting a - // line break + // Establish the new cursor position at the start of a line when + // inserting a line break m_revert_cursor_index = 0; // Don't perform automatic formatting when pasting @@ -592,21 +586,23 @@ } } - // Insert the new line and repaint everything from the split line on down + // Insert the new line and repaint everything from the split line on + // down m_input_lines.insert(m_input_lines.begin() + m_current_line_index + 1, new_line_fragment); MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingPrompt); DisplayInput(m_current_line_index); - // Reposition the cursor to the right line and prepare to edit the new line + // Reposition the cursor to the right line and prepare to edit the new + // line SetCurrentLine(m_current_line_index + 1); MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt); return CC_NEWLINE; } unsigned char Editline::EndOrAddLineCommand(int ch) { - // Don't perform end of input detection when pasting, always treat this as a - // line break + // Don't perform end of input detection when pasting, always treat this + // as a line break if (IsInputPending(m_input_file)) { return BreakLineCommand(ch); } @@ -614,7 +610,8 @@ // Save any edits to this line SaveEditedLine(); - // If this is the end of the last line, consider whether to add a line instead + // If this is the end of the last line, consider whether to add a line + // instead const LineInfoW *info = el_wline(m_editline); if (m_current_line_index == m_input_lines.size() - 1 && info->cursor == info->lastchar) { @@ -625,7 +622,8 @@ return BreakLineCommand(ch); } - // The completion test is allowed to change the input lines when complete + // The completion test is allowed to change the input lines when + // complete m_input_lines.clear(); for (unsigned index = 0; index < lines.GetSize(); index++) { #if LLDB_EDITLINE_USE_WCHAR @@ -667,7 +665,8 @@ // Prepare to combine this line with the one below MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingPrompt); - // Insert the next line of text at the cursor and restore the cursor position + // Insert the next line of text at the cursor and restore the cursor + // position const EditLineCharType *cursor = info->cursor; el_winsertstr(m_editline, m_input_lines[m_current_line_index + 1].c_str()); info->cursor = cursor; @@ -685,7 +684,8 @@ unsigned char Editline::DeletePreviousCharCommand(int ch) { LineInfoW *info = const_cast(el_wline(m_editline)); - // Just delete the previous character normally when not at the start of a line + // Just delete the previous character normally when not at the start of + // a line if (info->cursor > info->buffer) { el_deletestr(m_editline, 1); return CC_REFRESH; @@ -708,9 +708,8 @@ CountRowsForLine(priorLine), 1); DisplayInput(m_current_line_index); - // Put the cursor back where libedit expects it to be before returning to - // editing - // by telling libedit about the newly inserted text + // Put the cursor back where libedit expects it to be before returning + // to editing by telling libedit about the newly inserted text MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt); el_winsertstr(m_editline, priorLine.c_str()); return CC_REDISPLAY; @@ -743,8 +742,8 @@ // Handle attempts to move down from the last line if (m_current_line_index == m_input_lines.size() - 1) { - // Don't add an extra line if the existing last line is blank, move through - // history instead + // Don't add an extra line if the existing last line is blank, move + // through history instead if (IsOnlySpaces()) { return RecallHistory(false); } @@ -762,7 +761,8 @@ EditLineStringType(indentation, EditLineCharType(' '))); } - // Move down past the current line using newlines to force scrolling if needed + // Move down past the current line using newlines to force scrolling if + // needed SetCurrentLine(m_current_line_index + 1); const LineInfoW *info = el_wline(m_editline); int cursor_position = (int)((info->cursor - info->buffer) + GetPromptWidth()); @@ -823,9 +823,8 @@ MoveCursor(CursorLocation::EditingCursor, CursorLocation::EditingPrompt); DisplayInput(m_current_line_index); - // Reposition the cursor back on the original line and prepare to restart - // editing - // with a new cursor position + // Reposition the cursor back on the original line and prepare to + // restart editing with a new cursor position SetCurrentLine(m_current_line_index); MoveCursor(CursorLocation::BlockEnd, CursorLocation::EditingPrompt); m_revert_cursor_index = cursor_position + indent_correction; @@ -946,8 +945,8 @@ if (m_editline) { // Disable edit mode to stop the terminal from flushing all input - // during the call to el_end() since we expect to have multiple editline - // instances in this program. + // during the call to el_end() since we expect to have multiple + // editline instances in this program. el_set(m_editline, EL_EDITMODE, 0); el_end(m_editline); } @@ -973,7 +972,8 @@ return Editline::InstanceFor(editline)->GetCharacter(c); })); - // Commands used for multiline support, registered whether or not they're used + // Commands used for multiline support, registered whether or not + // they're used el_wset(m_editline, EL_ADDFN, EditLineConstString("lldb-break-line"), EditLineConstString("Insert a line break"), (EditlineCommandCallbackType)([](EditLine *editline, int ch) { @@ -1031,13 +1031,11 @@ return Editline::InstanceFor(editline)->FixIndentationCommand(ch); })); - // Register the complete callback under two names for compatibility with older - // clients using - // custom .editrc files (largely because libedit has a bad bug where if you - // have a bind command - // that tries to bind to a function name that doesn't exist, it can corrupt - // the heap and - // crash your process later.) + // Register the complete callback under two names for compatibility with + // older clients using custom .editrc files (largely because libedit has + // a bad bug where if you have a bind command that tries to bind to a + // function name that doesn't exist, it can corrupt the heap and crash + // your process later.) EditlineCommandCallbackType complete_callback = [](EditLine *editline, int ch) { return Editline::InstanceFor(editline)->TabCommand(ch); @@ -1118,8 +1116,7 @@ NULL); // Escape is absorbed exiting edit mode, so re-register important - // sequences - // without the prefix + // sequences without the prefix el_set(m_editline, EL_BIND, "-a", "[A", "lldb-previous-line", NULL); el_set(m_editline, EL_BIND, "-a", "[B", "lldb-next-line", NULL); el_set(m_editline, EL_BIND, "-a", "[\\^", "lldb-revert-line", NULL); @@ -1161,8 +1158,9 @@ // issues }); - // We must make sure to initialize the terminal a given file descriptor - // only once. If we do this multiple times, we start leaking memory. + // We must make sure to initialize the terminal a given file + // descriptor only once. If we do this multiple times, we start + // leaking memory. std::lock_guard guard(*g_init_terminal_fds_mutex_ptr); if (g_init_terminal_fds_ptr->find(term_fd) == g_init_terminal_fds_ptr->end()) { @@ -1177,17 +1175,17 @@ Editline::~Editline() { if (m_editline) { // Disable edit mode to stop the terminal from flushing all input - // during the call to el_end() since we expect to have multiple editline - // instances in this program. + // during the call to el_end() since we expect to have multiple + // editline instances in this program. el_set(m_editline, EL_EDITMODE, 0); el_end(m_editline); m_editline = nullptr; } // EditlineHistory objects are sometimes shared between multiple - // Editline instances with the same program name. So just release - // our shared pointer and if we are the last owner, it will save the - // history to the history save file automatically. + // Editline instances with the same program name. So just release our + // shared pointer and if we are the last owner, it will save the history + // to the history save file automatically. m_history_sp.reset(); } @@ -1204,8 +1202,8 @@ if (m_editline != nullptr) { el_resize(m_editline); int columns; - // Despite the man page claiming non-zero indicates success, it's actually - // zero + // Despite the man page claiming non-zero indicates success, it's + // actually zero if (el_get(m_editline, EL_GETTC, "co", &columns) == 0) { m_terminal_width = columns; if (m_current_line_rows != -1) { @@ -1313,8 +1311,8 @@ bool &interrupted) { ConfigureEditor(true); - // Print the initial input lines, then move the cursor back up to the start of - // input + // Print the initial input lines, then move the cursor back up to the + // start of input SetBaseLineNumber(first_line_number); m_input_lines = std::vector(); m_input_lines.insert(m_input_lines.begin(), EditLineConstString("")); Index: source/Host/common/File.cpp =================================================================== --- source/Host/common/File.cpp +++ source/Host/common/File.cpp @@ -97,8 +97,8 @@ if (DescriptorIsValid()) return m_descriptor; - // Don't open the file descriptor if we don't need to, just get it from the - // stream if we have one. + // Don't open the file descriptor if we don't need to, just get it from + // the stream if we have one. if (StreamIsValid()) { #if defined(_WIN32) return _fileno(m_stream); @@ -126,8 +126,8 @@ const char *mode = GetStreamOpenModeFromOptions(m_options); if (mode) { if (!m_should_close_fd) { -// We must duplicate the file descriptor if we don't own it because -// when you call fdopen, the stream will own the fd +// We must duplicate the file descriptor if we don't own it because when +// you call fdopen, the stream will own the fd #ifdef _WIN32 m_descriptor = ::_dup(GetDescriptor()); #else @@ -139,8 +139,8 @@ m_stream = llvm::sys::RetryAfterSignal(nullptr, ::fdopen, m_descriptor, mode); - // If we got a stream, then we own the stream and should no - // longer own the descriptor because fclose() will close it for us + // If we got a stream, then we own the stream and should no longer + // own the descriptor because fclose() will close it for us if (m_stream) { m_own_stream = true; Index: source/Host/common/Host.cpp =================================================================== --- source/Host/common/Host.cpp +++ source/Host/common/Host.cpp @@ -119,9 +119,9 @@ #ifndef __linux__ //------------------------------------------------------------------ -// Scoped class that will disable thread canceling when it is -// constructed, and exception safely restore the previous value it -// when it goes out of scope. +// Scoped class that will disable thread canceling when it is constructed, +// and exception safely restore the previous value it when it goes out of +// scope. //------------------------------------------------------------------ class ScopedPThreadCancelDisabler { public: @@ -332,8 +332,8 @@ return "SIGABRT"; // 6 abort() #if defined(SIGPOLL) #if !defined(SIGIO) || (SIGPOLL != SIGIO) - // Under some GNU/Linux, SIGPOLL and SIGIO are the same. Causing the build to - // fail with 'multiple define cases with same value' + // Under some GNU/Linux, SIGPOLL and SIGIO are the same. Causing the + // build to fail with 'multiple define cases with same value' case SIGPOLL: return "SIGPOLL"; // 7 pollable event ([XSR] generated, not supported) #endif @@ -544,7 +544,8 @@ if (timed_out) { error.SetErrorString("timed out waiting for shell command to complete"); - // Kill the process since it didn't complete within the timeout specified + // Kill the process since it didn't complete within the timeout + // specified Kill(pid, SIGKILL); // Wait for the monitor callback to get the message timed_out = false; @@ -580,7 +581,8 @@ return error; } -// The functions below implement process launching for non-Apple-based platforms +// The functions below implement process launching for non-Apple-based +// platforms #if !defined(__APPLE__) Status Host::LaunchProcess(ProcessLaunchInfo &launch_info) { std::unique_ptr delegate_launcher; @@ -594,9 +596,8 @@ Status error; HostProcess process = launcher.LaunchProcess(launch_info, error); - // TODO(zturner): It would be better if the entire HostProcess were returned - // instead of writing - // it into this structure. + // TODO(zturner): It would be better if the entire HostProcess were + // returned instead of writing it into this structure. launch_info.SetProcessID(process.GetProcessId()); return error; Index: source/Host/common/HostInfoBase.cpp =================================================================== --- source/Host/common/HostInfoBase.cpp +++ source/Host/common/HostInfoBase.cpp @@ -36,16 +36,16 @@ // The HostInfoBaseFields is a work around for windows not supporting // static variables correctly in a thread safe way. Really each of the // variables in HostInfoBaseFields should live in the functions in which -// they are used and each one should be static, but the work around is -// in place to avoid this restriction. Ick. +// they are used and each one should be static, but the work around is in +// place to avoid this restriction. Ick. //---------------------------------------------------------------------- struct HostInfoBaseFields { ~HostInfoBaseFields() { if (m_lldb_process_tmp_dir.Exists()) { - // Remove the LLDB temporary directory if we have one. Set "recurse" to - // true to all files that were created for the LLDB process can be cleaned - // up. + // Remove the LLDB temporary directory if we have one. Set "recurse" + // to true to all files that were created for the LLDB process can + // be cleaned up. llvm::sys::fs::remove_directories(m_lldb_process_tmp_dir.GetPath()); } } @@ -282,18 +282,20 @@ bool HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec) { // To get paths related to LLDB we get the path to the executable that - // contains this function. On MacOSX this will be "LLDB.framework/.../LLDB". - // On other posix systems, we will get .../lib(64|32)?/liblldb.so. + // contains this function. On MacOSX this will be + // "LLDB.framework/.../LLDB". On other posix systems, we will get + // .../lib(64|32)?/liblldb.so. FileSpec lldb_file_spec( Host::GetModuleFileSpecForHostAddress(reinterpret_cast( reinterpret_cast(HostInfoBase::GetLLDBPath)))); - // This is necessary because when running the testsuite the shlib might be a - // symbolic link inside the Python resource dir. + // This is necessary because when running the testsuite the shlib might + // be a symbolic link inside the Python resource dir. FileSystem::ResolveSymbolicLink(lldb_file_spec, lldb_file_spec); - // Remove the filename so that this FileSpec only represents the directory. + // Remove the filename so that this FileSpec only represents the + // directory. file_spec.GetDirectory() = lldb_file_spec.GetDirectory(); return (bool)file_spec.GetDirectory(); @@ -346,16 +348,16 @@ } bool HostInfoBase::ComputeSystemPluginsDirectory(FileSpec &file_spec) { - // TODO(zturner): Figure out how to compute the system plugins directory for - // all platforms. + // TODO(zturner): Figure out how to compute the system plugins directory + // for all platforms. return false; } bool HostInfoBase::ComputeClangDirectory(FileSpec &file_spec) { return false; } bool HostInfoBase::ComputeUserPluginsDirectory(FileSpec &file_spec) { - // TODO(zturner): Figure out how to compute the user plugins directory for all - // platforms. + // TODO(zturner): Figure out how to compute the user plugins directory + // for all platforms. return false; } Index: source/Host/common/MainLoop.cpp =================================================================== --- source/Host/common/MainLoop.cpp +++ source/Host/common/MainLoop.cpp @@ -19,10 +19,10 @@ #include #include -// Multiplexing is implemented using kqueue on systems that support it (BSD -// variants including OSX). On linux we use ppoll, while android uses pselect -// (ppoll is present but not implemented properly). On windows we use WSApoll -// (which does not support signals). +// Multiplexing is implemented using kqueue on systems that support it +// (BSD variants including OSX). On linux we use ppoll, while android uses +// pselect (ppoll is present but not implemented properly). On windows we +// use WSApoll (which does not support signals). #if HAVE_SYS_EVENT_H #include @@ -155,10 +155,10 @@ #ifdef __ANDROID__ Status MainLoop::RunImpl::Poll() { // ppoll(2) is not supported on older all android versions. Also, older - // versions android (API <= 19) implemented pselect in a non-atomic way, as a - // combination of pthread_sigmask and select. This is not sufficient for us, - // as we rely on the atomicity to correctly implement signal polling, so we - // call the underlying syscall ourselves. + // versions android (API <= 19) implemented pselect in a non-atomic way, + // as a combination of pthread_sigmask and select. This is not + // sufficient for us, as we rely on the atomicity to correctly implement + // signal polling, so we call the underlying syscall ourselves. FD_ZERO(&read_fd_set); int nfds = 0; @@ -209,8 +209,8 @@ void MainLoop::RunImpl::ProcessEvents() { #ifdef __ANDROID__ - // Collect first all readable file descriptors into a separate vector and then - // iterate over it to invoke callbacks. Iterating directly over + // Collect first all readable file descriptors into a separate vector + // and then iterate over it to invoke callbacks. Iterating directly over // loop.m_read_fds is not possible because the callbacks can modify the // container which could invalidate the iterator. std::vector fds; @@ -284,9 +284,8 @@ return CreateReadHandle(object_sp); } -// We shall block the signal, then install the signal handler. The signal will -// be unblocked in -// the Run() function to check for signal delivery. +// We shall block the signal, then install the signal handler. The signal +// will be unblocked in the Run() function to check for signal delivery. MainLoop::SignalHandleUP MainLoop::RegisterSignal(int signo, const Callback &callback, Status &error) { #ifdef SIGNAL_POLLING_UNSUPPORTED @@ -309,8 +308,8 @@ g_signal_flags[signo] = 0; - // Even if using kqueue, the signal handler will still be invoked, so it's - // important to replace it with our "bening" handler. + // Even if using kqueue, the signal handler will still be invoked, so + // it's important to replace it with our "bening" handler. int ret = sigaction(signo, &new_action, &info.old_action); assert(ret == 0 && "sigaction failed"); @@ -321,9 +320,9 @@ assert(ret == 0); #endif - // If we're using kqueue, the signal needs to be unblocked in order to recieve - // it. If using pselect/ppoll, we need to block it, and later unblock it as a - // part of the system call. + // If we're using kqueue, the signal needs to be unblocked in order to + // recieve it. If using pselect/ppoll, we need to block it, and later + // unblock it as a part of the system call. ret = pthread_sigmask(HAVE_SYS_EVENT_H ? SIG_UNBLOCK : SIG_BLOCK, &new_action.sa_mask, &old_set); assert(ret == 0 && "pthread_sigmask failed"); Index: source/Host/common/NativeBreakpointList.cpp =================================================================== --- source/Host/common/NativeBreakpointList.cpp +++ source/Host/common/NativeBreakpointList.cpp @@ -104,8 +104,8 @@ return error; } - // Breakpoint has no more references. Disable it if it's not - // already disabled. + // Breakpoint has no more references. Disable it if it's not already + // disabled. if (log) log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- removing due to no remaining references", @@ -123,7 +123,8 @@ log->Printf("NativeBreakpointList::%s addr = 0x%" PRIx64 " -- removal FAILED: %s", __FUNCTION__, addr, error.AsCString()); - // Continue since we still want to take it out of the breakpoint list. + // Continue since we still want to take it out of the breakpoint + // list. } } else { if (log) Index: source/Host/common/NativeProcessProtocol.cpp =================================================================== --- source/Host/common/NativeProcessProtocol.cpp +++ source/Host/common/NativeProcessProtocol.cpp @@ -137,29 +137,29 @@ Status NativeProcessProtocol::SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) { - // This default implementation assumes setting the watchpoint for - // the process will require setting the watchpoint for each of the - // threads. Furthermore, it will track watchpoints set for the - // process and will add them to each thread that is attached to - // via the (FIXME implement) OnThreadAttached () method. + // This default implementation assumes setting the watchpoint for the + // process will require setting the watchpoint for each of the threads. + // Furthermore, it will track watchpoints set for the process and will + // add them to each thread that is attached to via the (FIXME implement) + // OnThreadAttached () method. Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); // Update the thread list UpdateThreads(); - // Keep track of the threads we successfully set the watchpoint - // for. If one of the thread watchpoint setting operations fails, - // back off and remove the watchpoint for all the threads that - // were successfully set so we get back to a consistent state. + // Keep track of the threads we successfully set the watchpoint for. If + // one of the thread watchpoint setting operations fails, back off and + // remove the watchpoint for all the threads that were successfully set + // so we get back to a consistent state. std::vector watchpoint_established_threads; - // Tell each thread to set a watchpoint. In the event that - // hardware watchpoints are requested but the SetWatchpoint fails, - // try to set a software watchpoint as a fallback. It's - // conceivable that if there are more threads than hardware - // watchpoints available, some of the threads will fail to set - // hardware watchpoints while software ones may be available. + // Tell each thread to set a watchpoint. In the event that hardware + // watchpoints are requested but the SetWatchpoint fails, try to set a + // software watchpoint as a fallback. It's conceivable that if there + // are more threads than hardware watchpoints available, some of the + // threads will fail to set hardware watchpoints while software ones may + // be available. std::lock_guard guard(m_threads_mutex); for (const auto &thread : m_threads) { assert(thread && "thread list should not have a NULL thread!"); @@ -167,8 +167,8 @@ Status thread_error = thread->SetWatchpoint(addr, size, watch_flags, hardware); if (thread_error.Fail() && hardware) { - // Try software watchpoints since we failed on hardware watchpoint setting - // and we may have just run out of hardware watchpoints. + // Try software watchpoints since we failed on hardware watchpoint + // setting and we may have just run out of hardware watchpoints. thread_error = thread->SetWatchpoint(addr, size, watch_flags, false); if (thread_error.Success()) LLDB_LOG(log, @@ -176,13 +176,13 @@ } if (thread_error.Success()) { - // Remember that we set this watchpoint successfully in - // case we need to clear it later. + // Remember that we set this watchpoint successfully in case we need + // to clear it later. watchpoint_established_threads.push_back(thread.get()); } else { - // Unset the watchpoint for each thread we successfully - // set so that we get back to a consistent state of "not - // set" for the watchpoint. + // Unset the watchpoint for each thread we successfully set so that + // we get back to a consistent state of "not set" for the + // watchpoint. for (auto unwatch_thread_sp : watchpoint_established_threads) { Status remove_error = unwatch_thread_sp->RemoveWatchpoint(addr); if (remove_error.Fail()) @@ -208,9 +208,9 @@ const Status thread_error = thread->RemoveWatchpoint(addr); if (thread_error.Fail()) { - // Keep track of the first thread error if any threads - // fail. We want to try to remove the watchpoint from - // every thread, though, even if one or more have errors. + // Keep track of the first thread error if any threads fail. We want + // to try to remove the watchpoint from every thread, though, even + // if one or more have errors. if (!overall_error.Fail()) overall_error = thread_error; } @@ -234,33 +234,36 @@ // Update the thread list UpdateThreads(); - // Exit here if target does not have required hardware breakpoint capability. + // Exit here if target does not have required hardware breakpoint + // capability. auto hw_debug_cap = GetHardwareDebugSupportInfo(); if (hw_debug_cap == llvm::None || hw_debug_cap->first == 0 || hw_debug_cap->first <= m_hw_breakpoints_map.size()) return Status("Target does not have required no of hardware breakpoints"); - // Vector below stores all thread pointer for which we have we successfully - // set this hardware breakpoint. If any of the current process threads fails - // to set this hardware breakpoint then roll back and remove this breakpoint - // for all the threads that had already set it successfully. + // Vector below stores all thread pointer for which we have we + // successfully set this hardware breakpoint. If any of the current + // process threads fails to set this hardware breakpoint then roll back + // and remove this breakpoint for all the threads that had already set + // it successfully. std::vector breakpoint_established_threads; - // Request to set a hardware breakpoint for each of current process threads. + // Request to set a hardware breakpoint for each of current process + // threads. std::lock_guard guard(m_threads_mutex); for (const auto &thread : m_threads) { assert(thread && "thread list should not have a NULL thread!"); Status thread_error = thread->SetHardwareBreakpoint(addr, size); if (thread_error.Success()) { - // Remember that we set this breakpoint successfully in - // case we need to clear it later. + // Remember that we set this breakpoint successfully in case we need + // to clear it later. breakpoint_established_threads.push_back(thread.get()); } else { - // Unset the breakpoint for each thread we successfully - // set so that we get back to a consistent state of "not - // set" for this hardware breakpoint. + // Unset the breakpoint for each thread we successfully set so that + // we get back to a consistent state of "not set" for this hardware + // breakpoint. for (auto rollback_thread_sp : breakpoint_established_threads) { Status remove_error = rollback_thread_sp->RemoveHardwareBreakpoint(addr); @@ -274,8 +277,8 @@ } } - // Register new hardware breakpoint into hardware breakpoints map of current - // process. + // Register new hardware breakpoint into hardware breakpoints map of + // current process. m_hw_breakpoints_map[addr] = {addr, size}; return Status(); @@ -409,9 +412,9 @@ ++m_stop_id; // Give process a chance to do any stop id bump processing, such as - // clearing cached data that is invalidated each time the process runs. - // Note if/when we support some threads running, we'll end up needing - // to manage this per thread and per process. + // clearing cached data that is invalidated each time the process + // runs. Note if/when we support some threads running, we'll end up + // needing to manage this per thread and per process. DoStopIDBumped(m_stop_id); } Index: source/Host/common/NativeRegisterContext.cpp =================================================================== --- source/Host/common/NativeRegisterContext.cpp +++ source/Host/common/NativeRegisterContext.cpp @@ -33,8 +33,7 @@ // NativeRegisterContext. // void -// NativeRegisterContext::InvalidateIfNeeded (bool force) -// { +// NativeRegisterContext::InvalidateIfNeeded (bool force) { // ProcessSP process_sp (m_thread.GetProcess()); // bool invalidate = force; // uint32_t process_stop_id = UINT32_MAX; @@ -102,8 +101,8 @@ const uint32_t reg_num = reg_set->registers[reg_num_index]; // FIXME double check we're checking the right register kind here. if (reg_info->kinds[RegisterKind::eRegisterKindLLDB] == reg_num) { - // The given register is a member of this register set. Return the - // register set name. + // The given register is a member of this register set. Return + // the register set name. return reg_set->name; } } @@ -362,11 +361,11 @@ return error; } - // We now have a memory buffer that contains the part or all of the register - // value. Set the register value using this memory data. - // TODO: we might need to add a parameter to this function in case the byte - // order of the memory data doesn't match the process. For now we are assuming - // they are the same. + // We now have a memory buffer that contains the part or all of the + // register value. Set the register value using this memory data. TODO: + // we might need to add a parameter to this function in case the byte + // order of the memory data doesn't match the process. For now we are + // assuming they are the same. reg_value.SetFromMemoryData(reg_info, src, src_len, process.GetByteOrder(), error); @@ -383,10 +382,9 @@ NativeProcessProtocol &process = m_thread.GetProcess(); - // TODO: we might need to add a parameter to this function in case the byte - // order of the memory data doesn't match the process. For now we are - // assuming - // they are the same. + // TODO: we might need to add a parameter to this function in case the + // byte order of the memory data doesn't match the process. For now we + // are assuming they are the same. const size_t bytes_copied = reg_value.GetAsMemoryData( reg_info, dst, dst_len, process.GetByteOrder(), error); Index: source/Host/common/PseudoTerminal.cpp =================================================================== --- source/Host/common/PseudoTerminal.cpp +++ source/Host/common/PseudoTerminal.cpp @@ -35,10 +35,10 @@ //---------------------------------------------------------------------- // Destructor // -// The destructor will close the master and slave file descriptors -// if they are valid and ownership has not been released using the -// ReleaseMasterFileDescriptor() or the ReleaseSaveFileDescriptor() -// member functions. +// The destructor will close the master and slave file descriptors if they +// are valid and ownership has not been released using the +// ReleaseMasterFileDescriptor() or the ReleaseSaveFileDescriptor() member +// functions. //---------------------------------------------------------------------- PseudoTerminal::~PseudoTerminal() { CloseMasterFileDescriptor(); @@ -66,15 +66,15 @@ } //---------------------------------------------------------------------- -// Open the first available pseudo terminal with OFLAG as the -// permissions. The file descriptor is stored in this object and can -// be accessed with the MasterFileDescriptor() accessor. The -// ownership of the master file descriptor can be released using -// the ReleaseMasterFileDescriptor() accessor. If this object has -// a valid master files descriptor when its destructor is called, it -// will close the master file descriptor, therefore clients must -// call ReleaseMasterFileDescriptor() if they wish to use the master -// file descriptor after this object is out of scope or destroyed. +// Open the first available pseudo terminal with OFLAG as the permissions. +// The file descriptor is stored in this object and can be accessed with +// the MasterFileDescriptor() accessor. The ownership of the master file +// descriptor can be released using the ReleaseMasterFileDescriptor() +// accessor. If this object has a valid master files descriptor when its +// destructor is called, it will close the master file descriptor, +// therefore clients must call ReleaseMasterFileDescriptor() if they wish +// to use the master file descriptor after this object is out of scope or +// destroyed. // // RETURNS: // True when successful, false indicating an error occurred. @@ -118,11 +118,11 @@ } //---------------------------------------------------------------------- -// Open the slave pseudo terminal for the current master pseudo -// terminal. A master pseudo terminal should already be valid prior to -// calling this function (see OpenFirstAvailableMaster()). -// The file descriptor is stored this object's member variables and can -// be accessed via the GetSlaveFileDescriptor(), or released using the +// Open the slave pseudo terminal for the current master pseudo terminal. +// A master pseudo terminal should already be valid prior to calling this +// function (see OpenFirstAvailableMaster()). The file descriptor is +// stored this object's member variables and can be accessed via the +// GetSlaveFileDescriptor(), or released using the // ReleaseSlaveFileDescriptor() member function. // // RETURNS: @@ -185,18 +185,17 @@ // Fork a child process and have its stdio routed to a pseudo terminal. // // In the parent process when a valid pid is returned, the master file -// descriptor can be used as a read/write access to stdio of the -// child process. +// descriptor can be used as a read/write access to stdio of the child +// process. // -// In the child process the stdin/stdout/stderr will already be routed -// to the slave pseudo terminal and the master file descriptor will be -// closed as it is no longer needed by the child process. +// In the child process the stdin/stdout/stderr will already be routed to +// the slave pseudo terminal and the master file descriptor will be closed +// as it is no longer needed by the child process. // -// This class will close the file descriptors for the master/slave -// when the destructor is called, so be sure to call +// This class will close the file descriptors for the master/slave when +// the destructor is called, so be sure to call // ReleaseMasterFileDescriptor() or ReleaseSlaveFileDescriptor() if any -// file descriptors are going to be used past the lifespan of this -// object. +// file descriptors are going to be used past the lifespan of this object. // // RETURNS: // in the parent process: the pid of the child, or -1 if fork fails @@ -235,7 +234,8 @@ ::strerror_r(errno, error_str, error_len); } #endif - // Duplicate all stdio file descriptors to the slave pseudo terminal + // Duplicate all stdio file descriptors to the slave pseudo + // terminal if (::dup2(m_slave_fd, STDIN_FILENO) != STDIN_FILENO) { if (error_str && !error_str[0]) ::strerror_r(errno, error_str, error_len); @@ -261,49 +261,49 @@ } //---------------------------------------------------------------------- -// The master file descriptor accessor. This object retains ownership -// of the master file descriptor when this accessor is used. Use +// The master file descriptor accessor. This object retains ownership of +// the master file descriptor when this accessor is used. Use // ReleaseMasterFileDescriptor() if you wish this object to release // ownership of the master file descriptor. // -// Returns the master file descriptor, or -1 if the master file -// descriptor is not currently valid. +// Returns the master file descriptor, or -1 if the master file descriptor +// is not currently valid. //---------------------------------------------------------------------- int PseudoTerminal::GetMasterFileDescriptor() const { return m_master_fd; } //---------------------------------------------------------------------- // The slave file descriptor accessor. // -// Returns the slave file descriptor, or -1 if the slave file -// descriptor is not currently valid. +// Returns the slave file descriptor, or -1 if the slave file descriptor +// is not currently valid. //---------------------------------------------------------------------- int PseudoTerminal::GetSlaveFileDescriptor() const { return m_slave_fd; } //---------------------------------------------------------------------- -// Release ownership of the master pseudo terminal file descriptor -// without closing it. The destructor for this class will close the -// master file descriptor if the ownership isn't released using this -// call and the master file descriptor has been opened. +// Release ownership of the master pseudo terminal file descriptor without +// closing it. The destructor for this class will close the master file +// descriptor if the ownership isn't released using this call and the +// master file descriptor has been opened. //---------------------------------------------------------------------- int PseudoTerminal::ReleaseMasterFileDescriptor() { - // Release ownership of the master pseudo terminal file - // descriptor without closing it. (the destructor for this - // class will close it otherwise!) + // Release ownership of the master pseudo terminal file descriptor + // without closing it. (the destructor for this class will close it + // otherwise!) int fd = m_master_fd; m_master_fd = invalid_fd; return fd; } //---------------------------------------------------------------------- -// Release ownership of the slave pseudo terminal file descriptor -// without closing it. The destructor for this class will close the -// slave file descriptor if the ownership isn't released using this -// call and the slave file descriptor has been opened. +// Release ownership of the slave pseudo terminal file descriptor without +// closing it. The destructor for this class will close the slave file +// descriptor if the ownership isn't released using this call and the +// slave file descriptor has been opened. //---------------------------------------------------------------------- int PseudoTerminal::ReleaseSlaveFileDescriptor() { - // Release ownership of the slave pseudo terminal file - // descriptor without closing it (the destructor for this - // class will close it otherwise!) + // Release ownership of the slave pseudo terminal file descriptor + // without closing it (the destructor for this class will close it + // otherwise!) int fd = m_slave_fd; m_slave_fd = invalid_fd; return fd; Index: source/Host/common/Socket.cpp =================================================================== --- source/Host/common/Socket.cpp +++ source/Host/common/Socket.cpp @@ -160,18 +160,17 @@ error = listen_socket->Listen(host_and_port, backlog); if (error.Success()) { - // We were asked to listen on port zero which means we - // must now read the actual port that was given to us - // as port zero is a special code for "find an open port - // for me". + // We were asked to listen on port zero which means we must now read + // the actual port that was given to us as port zero is a special code + // for "find an open port for me". if (port == 0) port = listen_socket->GetLocalPortNumber(); - // Set the port predicate since when doing a listen://: - // it often needs to accept the incoming connection which is a blocking - // system call. Allowing access to the bound port using a predicate allows - // us to wait for the port predicate to be set to a non-zero value from - // another thread in an efficient manor. + // Set the port predicate since when doing a listen://: it + // often needs to accept the incoming connection which is a blocking + // system call. Allowing access to the bound port using a predicate + // allows us to wait for the port predicate to be set to a non-zero + // value from another thread in an efficient manor. if (predicate) predicate->SetValue(port, eBroadcastAlways); socket = listen_socket.release(); @@ -282,8 +281,7 @@ } // If this was unsuccessful, then check if it's simply a signed 32-bit - // integer, representing - // a port with an empty host. + // integer, representing a port with an empty host. host_str.clear(); port_str.clear(); bool ok = false; @@ -436,11 +434,11 @@ error.Clear(); #if defined(ANDROID_USE_ACCEPT_WORKAROUND) // Hack: - // This enables static linking lldb-server to an API 21 libc, but still having - // it run on older devices. It is necessary because API 21 libc's + // This enables static linking lldb-server to an API 21 libc, but still + // having it run on older devices. It is necessary because API 21 libc's // implementation of accept() uses the accept4 syscall(), which is not - // available in older kernels. Using an older libc would fix this issue, but - // introduce other ones, as the old libraries were quite buggy. + // available in older kernels. Using an older libc would fix this issue, + // but introduce other ones, as the old libraries were quite buggy. int fd = syscall(__NR_accept, sockfd, addr, addrlen); if (fd >= 0 && !child_processes_inherit) { int flags = ::fcntl(fd, F_GETFD); Index: source/Host/common/SocketAddress.cpp =================================================================== --- source/Host/common/SocketAddress.cpp +++ source/Host/common/SocketAddress.cpp @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// // -// Note: This file is used on Darwin by debugserver, so it needs to remain as +// Note: This file is used on Darwin by debugserver, so it needs to remain +// as // self contained as possible, and devoid of references to LLVM unless // there is compelling reason. // Index: source/Host/common/SoftwareBreakpoint.cpp =================================================================== --- source/Host/common/SoftwareBreakpoint.cpp +++ source/Host/common/SoftwareBreakpoint.cpp @@ -33,9 +33,8 @@ return Status("SoftwareBreakpoint::%s invalid load address specified.", __FUNCTION__); - // Ask the NativeProcessProtocol subclass to fill in the correct software - // breakpoint - // trap for the breakpoint site. + // Ask the NativeProcessProtocol subclass to fill in the correct + // software breakpoint trap for the breakpoint site. size_t bp_opcode_size = 0; const uint8_t *bp_opcode_bytes = NULL; Status error = process.GetSoftwareBreakpointTrapOpcode( @@ -98,9 +97,8 @@ log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64 " -- SUCCESS", __FUNCTION__, addr); - // Set the breakpoint and verified it was written properly. Now - // create a breakpoint remover that understands how to undo this - // breakpoint. + // Set the breakpoint and verified it was written properly. Now create + // a breakpoint remover that understands how to undo this breakpoint. breakpoint_sp.reset(new SoftwareBreakpoint(process, addr, saved_opcode_bytes, bp_opcode_bytes, bp_opcode_size)); return Status(); @@ -297,8 +295,8 @@ } else { error.SetErrorString( "Original breakpoint trap is no longer in memory."); - // Set verify to true and so we can check if the original opcode has - // already been restored + // Set verify to true and so we can check if the original opcode + // has already been restored verify = true; } Index: source/Host/common/Symbols.cpp =================================================================== --- source/Host/common/Symbols.cpp +++ source/Host/common/Symbols.cpp @@ -111,19 +111,19 @@ // Add a ".dSYM" name to each directory component of the path, // stripping off components. e.g. we may have a binary like - // /S/L/F/Foundation.framework/Versions/A/Foundation - // and + // /S/L/F/Foundation.framework/Versions/A/Foundation and // /S/L/F/Foundation.framework.dSYM // - // so we'll need to start with /S/L/F/Foundation.framework/Versions/A, - // add the .dSYM part to the "A", and if that doesn't exist, strip off - // the "A" and try it again with "Versions", etc., until we find a - // dSYM bundle or we've stripped off enough path components that - // there's no need to continue. + // so we'll need to start with + // /S/L/F/Foundation.framework/Versions/A, add the .dSYM part to + // the "A", and if that doesn't exist, strip off the "A" and try + // it again with "Versions", etc., until we find a dSYM bundle + // or we've stripped off enough path components that there's no + // need to continue. for (int i = 0; i < 4; i++) { - // Does this part of the path have a "." character - could it be a - // bundle's top level directory? + // Does this part of the path have a "." character - could it + // be a bundle's top level directory? const char *fn = parent_dirs.GetFilename().AsCString(); if (fn == nullptr) break; @@ -131,7 +131,8 @@ dsym_fspec = parent_dirs; dsym_fspec.RemoveLastPathComponent(); - // If the current directory name is "Foundation.framework", see if + // If the current directory name is "Foundation.framework", + // see if // "Foundation.framework.dSYM/Contents/Resources/DWARF/Foundation" // exists & has the right uuid. std::string dsym_fn = fn; @@ -177,8 +178,8 @@ FileSpec symbol_fspec; ModuleSpec dsym_module_spec; - // First try and find the dSYM in the same directory as the executable or in - // an appropriate parent directory + // First try and find the dSYM in the same directory as the executable + // or in an appropriate parent directory if (LocateDSYMInVincinityOfExecutable(module_spec, symbol_fspec) == false) { // We failed to easily find the dSYM above, so use DebugSymbols LocateMacOSXFilesUsingDebugSymbols(module_spec, dsym_module_spec); @@ -293,10 +294,9 @@ if (num_specs == 1) { ModuleSpec mspec; if (specs.GetModuleSpecAtIndex(0, mspec)) { - // Skip the uuids check if module_uuid is invalid. - // For example, this happens for *.dwp files since - // at the moment llvm-dwp doesn't output build ids, - // nor does binutils dwp. + // Skip the uuids check if module_uuid is invalid. For + // example, this happens for *.dwp files since at the moment + // llvm-dwp doesn't output build ids, nor does binutils dwp. if (!module_uuid.IsValid() || module_uuid == mspec.GetUUID()) return file_spec; } Index: source/Host/common/TCPSocket.cpp =================================================================== --- source/Host/common/TCPSocket.cpp +++ source/Host/common/TCPSocket.cpp @@ -85,8 +85,8 @@ } std::string TCPSocket::GetLocalIPAddress() const { - // We bound to port zero, so we need to figure out which port we actually - // bound to + // We bound to port zero, so we need to figure out which port we + // actually bound to if (m_socket != kInvalidSocketValue) { SocketAddress sock_addr; socklen_t sock_addr_len = sock_addr.GetMaxLength(); @@ -107,8 +107,8 @@ } std::string TCPSocket::GetRemoteIPAddress() const { - // We bound to port zero, so we need to figure out which port we actually - // bound to + // We bound to port zero, so we need to figure out which port we + // actually bound to if (m_socket != kInvalidSocketValue) { SocketAddress sock_addr; socklen_t sock_addr_len = sock_addr.GetMaxLength(); Index: source/Host/common/TaskPool.cpp =================================================================== --- source/Host/common/TaskPool.cpp +++ source/Host/common/TaskPool.cpp @@ -49,8 +49,8 @@ TaskPoolImpl::TaskPoolImpl() : m_thread_count(0) {} unsigned GetHardwareConcurrencyHint() { - // std::thread::hardware_concurrency may return 0 - // if the value is not well defined or not computable. + // std::thread::hardware_concurrency may return 0 if the value is not + // well defined or not computable. static const unsigned g_hardware_concurrency = std::max(1u, std::thread::hardware_concurrency()); return g_hardware_concurrency; @@ -63,9 +63,9 @@ m_tasks.emplace(std::move(task_fn)); if (m_thread_count < GetHardwareConcurrencyHint()) { m_thread_count++; - // Note that this detach call needs to happen with the m_tasks_mutex held. - // This prevents the thread - // from exiting prematurely and triggering a linux libc bug + // Note that this detach call needs to happen with the m_tasks_mutex + // held. This prevents the thread from exiting prematurely and + // triggering a linux libc bug // (https://sourceware.org/bugzilla/show_bug.cgi?id=19951). lldb_private::ThreadLauncher::LaunchThread("task-pool.worker", WorkerPtr, this, nullptr, min_stack_size) Index: source/Host/common/Terminal.cpp =================================================================== --- source/Host/common/Terminal.cpp +++ source/Host/common/Terminal.cpp @@ -107,9 +107,9 @@ } //---------------------------------------------------------------------- -// Save the current state of the TTY for the file descriptor "fd" -// and if "save_process_group" is true, attempt to save the process -// group info for the TTY. +// Save the current state of the TTY for the file descriptor "fd" and if +// "save_process_group" is true, attempt to save the process group info +// for the TTY. //---------------------------------------------------------------------- bool TerminalState::Save(int fd, bool save_process_group) { m_tty.SetFileDescriptor(fd); @@ -142,8 +142,8 @@ } //---------------------------------------------------------------------- -// Restore the state of the TTY using the cached values from a -// previous call to Save(). +// Restore the state of the TTY using the cached values from a previous +// call to Save(). //---------------------------------------------------------------------- bool TerminalState::Restore() const { #ifndef LLDB_DISABLE_POSIX @@ -173,8 +173,8 @@ } //---------------------------------------------------------------------- -// Returns true if this object has valid saved TTY state settings -// that can be used to restore a previous state. +// Returns true if this object has valid saved TTY state settings that can +// be used to restore a previous state. //---------------------------------------------------------------------- bool TerminalState::IsValid() const { return m_tty.FileDescriptorIsValid() && @@ -249,8 +249,8 @@ } //------------------------------------------------------------------ -// Save the state at index "idx" for file descriptor "fd" and -// save the process group if requested. +// Save the state at index "idx" for file descriptor "fd" and save the +// process group if requested. // // Returns true if the restore was successful, false otherwise. //------------------------------------------------------------------ Index: source/Host/common/ThreadLauncher.cpp =================================================================== --- source/Host/common/ThreadLauncher.cpp +++ source/Host/common/ThreadLauncher.cpp @@ -42,7 +42,8 @@ error.SetError(::GetLastError(), eErrorTypeWin32); #else -// ASAN instrumentation adds a lot of bookkeeping overhead on stack frames. +// ASAN instrumentation adds a lot of bookkeeping overhead on stack +// frames. #if __has_feature(address_sanitizer) const size_t eight_megabytes = 8 * 1024 * 1024; if (min_stack_byte_size < eight_megabytes) { Index: source/Host/common/UDPSocket.cpp =================================================================== --- source/Host/common/UDPSocket.cpp +++ source/Host/common/UDPSocket.cpp @@ -69,8 +69,8 @@ if (!DecodeHostAndPort(name, host_str, port_str, port, &error)) return error; - // At this point we have setup the receive port, now we need to - // setup the UDP send socket + // At this point we have setup the receive port, now we need to setup + // the UDP send socket struct addrinfo hints; struct addrinfo *service_info_list = nullptr; @@ -112,8 +112,8 @@ SocketAddress bind_addr; - // Only bind to the loopback address if we are expecting a connection from - // localhost to avoid any firewall issues. + // Only bind to the loopback address if we are expecting a connection + // from localhost to avoid any firewall issues. const bool bind_addr_success = (host_str == "127.0.0.1" || host_str == "localhost") ? bind_addr.SetToLocalhost(kDomain, port) : bind_addr.SetToAnyAddress(kDomain, port); Index: source/Host/common/XML.cpp =================================================================== --- source/Host/common/XML.cpp +++ source/Host/common/XML.cpp @@ -252,8 +252,8 @@ if (node->type != XML_ELEMENT_NODE) continue; - // If name is nullptr, we take all nodes of type "t", else - // just the ones whose name matches + // If name is nullptr, we take all nodes of type "t", else just the + // ones whose name matches if (name) { if (strcmp((const char *)node->name, name) != 0) continue; // Name mismatch, ignore this one Index: source/Host/freebsd/Host.cpp =================================================================== --- source/Host/freebsd/Host.cpp +++ source/Host/freebsd/Host.cpp @@ -191,10 +191,10 @@ kinfo.ki_flag & P_WEXIT) // Working on exiting continue; - // Every thread is a process in FreeBSD, but all the threads of a single - // process have the same pid. Do not store the process info in the - // result list if a process with given identifier is already registered - // there. + // Every thread is a process in FreeBSD, but all the threads of a + // single process have the same pid. Do not store the process info in + // the result list if a process with given identifier is already + // registered there. bool already_registered = false; for (uint32_t pi = 0; !already_registered && (const int)kinfo.ki_numthreads > 1 && Index: source/Host/linux/Host.cpp =================================================================== --- source/Host/linux/Host.cpp +++ source/Host/linux/Host.cpp @@ -61,7 +61,8 @@ std::tie(Line, Rest) = Rest.split('\n'); if (Line.consume_front("Gid:")) { - // Real, effective, saved set, and file system GIDs. Read the first two. + // Real, effective, saved set, and file system GIDs. Read the first + // two. Line = Line.ltrim(); uint32_t RGid, EGid; Line.consumeInteger(10, RGid); @@ -71,7 +72,8 @@ ProcessInfo.SetGroupID(RGid); ProcessInfo.SetEffectiveGroupID(EGid); } else if (Line.consume_front("Uid:")) { - // Real, effective, saved set, and file system UIDs. Read the first two. + // Real, effective, saved set, and file system UIDs. Read the first + // two. Line = Line.ltrim(); uint32_t RUid, EUid; Line.consumeInteger(10, RUid); @@ -153,7 +155,8 @@ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); - // We can't use getProcFile here because proc/[pid]/exe is a symbolic link. + // We can't use getProcFile here because proc/[pid]/exe is a symbolic + // link. llvm::SmallString<64> ProcExe; (llvm::Twine("/proc/") + llvm::Twine(pid) + "/exe").toVector(ProcExe); std::string ExePath(PATH_MAX, '\0'); @@ -166,8 +169,8 @@ } ExePath.resize(len); - // If the binary has been deleted, the link name has " (deleted)" appended. - // Remove if there. + // If the binary has been deleted, the link name has " (deleted)" + // appended. Remove if there. llvm::StringRef PathRef = ExePath; PathRef.consume_back(" (deleted)"); @@ -246,8 +249,8 @@ if (State == ProcessState::Zombie) continue; - // Check for user match if we're not matching all users and not running as - // root. + // Check for user match if we're not matching all users and not + // running as root. if (!all_users && (our_uid != 0) && (process_info.GetUserID() != our_uid)) continue; Index: source/Host/linux/HostInfoLinux.cpp =================================================================== --- source/Host/linux/HostInfoLinux.cpp +++ source/Host/linux/HostInfoLinux.cpp @@ -56,9 +56,8 @@ if (status == 3) success = true; else { - // Some kernels omit the update version, so try looking for just "X.Y" - // and - // set update to 0. + // Some kernels omit the update version, so try looking for just + // "X.Y" and set update to 0. g_fields->m_os_update = 0; status = sscanf(un.release, "%u.%u", &g_fields->m_os_major, &g_fields->m_os_minor); @@ -100,8 +99,8 @@ } llvm::StringRef HostInfoLinux::GetDistributionId() { - // Try to run 'lbs_release -i', and use that response - // for the distribution id. + // Try to run 'lbs_release -i', and use that response for the + // distribution id. static llvm::once_flag g_once_flag; llvm::call_once(g_once_flag, []() { @@ -109,8 +108,8 @@ if (log) log->Printf("attempting to determine Linux distribution..."); - // check if the lsb_release command exists at one of the - // following paths + // check if the lsb_release command exists at one of the following + // paths const char *const exe_paths[] = {"/bin/lsb_release", "/usr/bin/lsb_release"}; @@ -212,8 +211,9 @@ bool HostInfoLinux::ComputeUserPluginsDirectory(FileSpec &file_spec) { // XDG Base Directory Specification - // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html - // If XDG_DATA_HOME exists, use that, otherwise use ~/.local/share/lldb. + // http://standards.freedesktop.org/basedir-spec/basedir-spec- + // latest.html If XDG_DATA_HOME exists, use that, otherwise use + // ~/.local/share/lldb. const char *xdg_data_home = getenv("XDG_DATA_HOME"); if (xdg_data_home && xdg_data_home[0]) { std::string user_plugin_dir(xdg_data_home); @@ -230,8 +230,8 @@ const char *distribution_id = GetDistributionId().data(); - // On Linux, "unknown" in the vendor slot isn't what we want for the default - // triple. It's probably an artifact of config.guess. + // On Linux, "unknown" in the vendor slot isn't what we want for the + // default triple. It's probably an artifact of config.guess. if (arch_32.IsValid()) { arch_32.SetDistributionId(distribution_id); if (arch_32.GetTriple().getVendor() == llvm::Triple::UnknownVendor) Index: source/Host/macosx/Symbols.cpp =================================================================== --- source/Host/macosx/Symbols.cpp +++ source/Host/macosx/Symbols.cpp @@ -157,8 +157,8 @@ } if (!success) { - // No dictionary, check near the dSYM bundle for an executable that - // matches... + // No dictionary, check near the dSYM bundle for an executable + // that matches... if (::CFURLGetFileSystemRepresentation( dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) { char *dsym_extension_pos = ::strstr(path, ".dSYM"); @@ -340,14 +340,13 @@ std::string DBGBuildSourcePath; std::string DBGSourcePath; - // If DBGVersion value 2 or higher, look for - // DBGSourcePathRemapping dictionary and append the key-value pairs - // to our remappings. + // If DBGVersion value 2 or higher, look for DBGSourcePathRemapping + // dictionary and append the key-value pairs to our remappings. cf_dict = (CFDictionaryRef)CFDictionaryGetValue( (CFDictionaryRef)uuid_dict, CFSTR("DBGSourcePathRemapping")); if (cf_dict && CFGetTypeID(cf_dict) == CFDictionaryGetTypeID()) { - // If we see DBGVersion with a value of 2 or higher, this is a new style - // DBGSourcePathRemapping dictionary + // If we see DBGVersion with a value of 2 or higher, this is a new + // style DBGSourcePathRemapping dictionary bool new_style_source_remapping_dictionary = false; bool do_truncate_remapping_names = false; std::string original_DBGSourcePath_value = DBGSourcePath; @@ -389,10 +388,9 @@ } if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) { // In the "old style" DBGSourcePathRemapping dictionary, the - // DBGSourcePath values - // (the "values" half of key-value path pairs) were wrong. Ignore - // them and use the - // universal DBGSourcePath string from earlier. + // DBGSourcePath values (the "values" half of key-value path + // pairs) were wrong. Ignore them and use the universal + // DBGSourcePath string from earlier. if (new_style_source_remapping_dictionary == true && !original_DBGSourcePath_value.empty()) { DBGSourcePath = original_DBGSourcePath_value; @@ -401,10 +399,11 @@ FileSpec resolved_source_path(DBGSourcePath.c_str(), true); DBGSourcePath = resolved_source_path.GetPath(); } - // With version 2 of DBGSourcePathRemapping, we can chop off the - // last two filename parts from the source remapping and get a - // more general source remapping that still works. Add this as - // another option in addition to the full source path remap. + // With version 2 of DBGSourcePathRemapping, we can chop off + // the last two filename parts from the source remapping and + // get a more general source remapping that still works. Add + // this as another option in addition to the full source path + // remap. module_spec.GetSourceMappingList().Append( ConstString(DBGBuildSourcePath.c_str()), ConstString(DBGSourcePath.c_str()), true); @@ -429,8 +428,8 @@ } - // If we have a DBGBuildSourcePath + DBGSourcePath pair, - // append them to the source remappings list. + // If we have a DBGBuildSourcePath + DBGSourcePath pair, append them + // to the source remappings list. cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict, CFSTR("DBGBuildSourcePath")); @@ -463,9 +462,8 @@ const UUID *uuid_ptr = module_spec.GetUUIDPtr(); const FileSpec *file_spec_ptr = module_spec.GetFileSpecPtr(); - // It's expensive to check for the DBGShellCommands defaults setting, only do - // it once per - // lldb run and cache the result. + // It's expensive to check for the DBGShellCommands defaults setting, + // only do it once per lldb run and cache the result. static bool g_have_checked_for_dbgshell_command = false; static const char *g_dbgshell_command = NULL; if (g_have_checked_for_dbgshell_command == false) { @@ -486,9 +484,8 @@ } } - // When g_dbgshell_command is NULL, the user has not enabled the use of an - // external program - // to find the symbols, don't run it for them. + // When g_dbgshell_command is NULL, the user has not enabled the use of + // an external program to find the symbols, don't run it for them. if (force_lookup == false && g_dbgshell_command == NULL) { return false; } Index: source/Host/macosx/cfcpp/CFCMutableDictionary.cpp =================================================================== --- source/Host/macosx/cfcpp/CFCMutableDictionary.cpp +++ source/Host/macosx/cfcpp/CFCMutableDictionary.cpp @@ -243,8 +243,8 @@ bool can_create) { CFMutableDictionaryRef dict = Dictionary(can_create); if (dict != NULL) { - // Have to promote to the next size type so things don't appear negative of - // the MSBit is set... + // Have to promote to the next size type so things don't appear + // negative of the MSBit is set... int16_t sval = value; CFCReleaser cf_number( ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &sval)); @@ -261,8 +261,8 @@ bool can_create) { CFMutableDictionaryRef dict = Dictionary(can_create); if (dict != NULL) { - // Have to promote to the next size type so things don't appear negative of - // the MSBit is set... + // Have to promote to the next size type so things don't appear + // negative of the MSBit is set... int16_t sval = value; CFCReleaser cf_number( ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &sval)); @@ -279,8 +279,8 @@ bool can_create) { CFMutableDictionaryRef dict = Dictionary(can_create); if (dict != NULL) { - // Have to promote to the next size type so things don't appear negative of - // the MSBit is set... + // Have to promote to the next size type so things don't appear + // negative of the MSBit is set... int32_t sval = value; CFCReleaser cf_number( ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &sval)); @@ -297,8 +297,8 @@ bool can_create) { CFMutableDictionaryRef dict = Dictionary(can_create); if (dict != NULL) { - // Have to promote to the next size type so things don't appear negative of - // the MSBit is set... + // Have to promote to the next size type so things don't appear + // negative of the MSBit is set... int32_t sval = value; CFCReleaser cf_number( ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &sval)); @@ -315,8 +315,8 @@ bool can_create) { CFMutableDictionaryRef dict = Dictionary(can_create); if (dict != NULL) { - // Have to promote to the next size type so things don't appear negative of - // the MSBit is set... + // Have to promote to the next size type so things don't appear + // negative of the MSBit is set... int64_t sval = value; CFCReleaser cf_number( ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &sval)); @@ -333,8 +333,8 @@ bool can_create) { CFMutableDictionaryRef dict = Dictionary(can_create); if (dict != NULL) { - // Have to promote to the next size type so things don't appear negative of - // the MSBit is set... + // Have to promote to the next size type so things don't appear + // negative of the MSBit is set... int64_t sval = value; CFCReleaser cf_number( ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &sval)); @@ -351,10 +351,9 @@ bool can_create) { CFMutableDictionaryRef dict = Dictionary(can_create); if (dict != NULL) { - // The number may appear negative if the MSBit is set in "value". Due to a - // limitation of - // CFNumber, there isn't a way to have it show up otherwise as of this - // writing. + // The number may appear negative if the MSBit is set in "value". Due + // to a limitation of CFNumber, there isn't a way to have it show up + // otherwise as of this writing. CFCReleaser cf_number( ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value)); if (cf_number.get()) { @@ -370,10 +369,9 @@ bool can_create) { CFMutableDictionaryRef dict = Dictionary(can_create); if (dict != NULL) { - // The number may appear negative if the MSBit is set in "value". Due to a - // limitation of - // CFNumber, there isn't a way to have it show up otherwise as of this - // writing. + // The number may appear negative if the MSBit is set in "value". Due + // to a limitation of CFNumber, there isn't a way to have it show up + // otherwise as of this writing. CFCReleaser cf_number( ::CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value)); if (cf_number.get()) { @@ -389,10 +387,9 @@ bool can_create) { CFMutableDictionaryRef dict = Dictionary(can_create); if (dict != NULL) { - // The number may appear negative if the MSBit is set in "value". Due to a - // limitation of - // CFNumber, there isn't a way to have it show up otherwise as of this - // writing. + // The number may appear negative if the MSBit is set in "value". Due + // to a limitation of CFNumber, there isn't a way to have it show up + // otherwise as of this writing. CFCReleaser cf_number( ::CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &value)); if (cf_number.get()) { @@ -408,10 +405,9 @@ bool can_create) { CFMutableDictionaryRef dict = Dictionary(can_create); if (dict != NULL) { - // The number may appear negative if the MSBit is set in "value". Due to a - // limitation of - // CFNumber, there isn't a way to have it show up otherwise as of this - // writing. + // The number may appear negative if the MSBit is set in "value". Due + // to a limitation of CFNumber, there isn't a way to have it show up + // otherwise as of this writing. CFCReleaser cf_number( ::CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &value)); if (cf_number.get()) { Index: source/Host/macosx/cfcpp/CFCString.cpp =================================================================== --- source/Host/macosx/cfcpp/CFCString.cpp +++ source/Host/macosx/cfcpp/CFCString.cpp @@ -88,13 +88,11 @@ return CFCString::UTF8(get(), str); } -// Static function that puts a copy of the UTF8 contents of CF_STR into STR -// and returns the C string pointer that is contained in STR when successful, -// else -// NULL is returned. This allows the std::string parameter to own the extracted -// string, -// and also allows that string to be returned as a C string pointer that can be -// used. +// Static function that puts a copy of the UTF8 contents of CF_STR into +// STR and returns the C string pointer that is contained in STR when +// successful, else NULL is returned. This allows the std::string +// parameter to own the extracted string, and also allows that string to +// be returned as a C string pointer that can be used. const char *CFCString::UTF8(CFStringRef cf_str, std::string &str) { if (cf_str) { @@ -127,11 +125,11 @@ return expanded_path.c_str(); } -// Static function that puts a copy of the file system representation of CF_STR -// into STR and returns the C string pointer that is contained in STR when -// successful, else NULL is returned. This allows the std::string parameter -// to own the extracted string, and also allows that string to be returned as -// a C string pointer that can be used. +// Static function that puts a copy of the file system representation of +// CF_STR into STR and returns the C string pointer that is contained in +// STR when successful, else NULL is returned. This allows the std::string +// parameter to own the extracted string, and also allows that string to +// be returned as a C string pointer that can be used. const char *CFCString::FileSystemRepresentation(CFStringRef cf_str, std::string &str) { Index: source/Host/netbsd/Host.cpp =================================================================== --- source/Host/netbsd/Host.cpp +++ source/Host/netbsd/Host.cpp @@ -160,7 +160,8 @@ const bool all_users = match_info.GetMatchAllUsers() || - // Special case, if lldb is being run as root we can attach to anything + // Special case, if lldb is being run as root we can attach to + // anything (our_uid == 0); kvm_t *kdp; @@ -191,10 +192,10 @@ proc_kinfo[i].p_flag & P_WEXIT) // Working on exiting continue; - // Every thread is a process in NetBSD, but all the threads of a single - // process have the same pid. Do not store the process info in the - // result list if a process with given identifier is already registered - // there. + // Every thread is a process in NetBSD, but all the threads of a + // single process have the same pid. Do not store the process info in + // the result list if a process with given identifier is already + // registered there. if (proc_kinfo[i].p_nlwps > 1) { bool already_registered = false; for (size_t pi = 0; pi < process_infos.GetSize(); pi++) { Index: source/Host/posix/ConnectionFileDescriptorPosix.cpp =================================================================== --- source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// #if defined(__APPLE__) -// Enable this special support for Apple builds where we can have unlimited -// select bounds. We tried switching to poll() and kqueue and we were panicing -// the kernel, so we have to stick with select for now. +// Enable this special support for Apple builds where we can have +// unlimited select bounds. We tried switching to poll() and kqueue and we +// were panicing the kernel, so we have to stick with select for now. #define _DARWIN_UNLIMITED_SELECT #endif @@ -194,10 +194,10 @@ int fd = -1; if (!addr->getAsInteger(0, fd)) { - // We have what looks to be a valid file descriptor, but we - // should make sure it is. We currently are doing this by trying to - // get the flags from the file descriptor and making sure it - // isn't a bad fd. + // We have what looks to be a valid file descriptor, but we should + // make sure it is. We currently are doing this by trying to get + // the flags from the file descriptor and making sure it isn't a + // bad fd. errno = 0; int flags = ::fcntl(fd, F_GETFL, 0); if (flags == -1 || errno == EBADF) { @@ -208,20 +208,19 @@ m_write_sp.reset(); return eConnectionStatusError; } else { - // Don't take ownership of a file descriptor that gets passed - // to us since someone else opened the file descriptor and - // handed it to us. - // TODO: Since are using a URL to open connection we should - // eventually parse options using the web standard where we - // have "fd://123?opt1=value;opt2=value" and we can have an + // Don't take ownership of a file descriptor that gets passed to + // us since someone else opened the file descriptor and handed + // it to us. TODO: Since are using a URL to open connection we + // should eventually parse options using the web standard where + // we have "fd://123?opt1=value;opt2=value" and we can have an // option be "owns=1" or "owns=0" or something like this to - // allow us to specify this. For now, we assume we must - // assume we don't own it. + // allow us to specify this. For now, we assume we must assume + // we don't own it. std::unique_ptr tcp_socket; tcp_socket.reset(new TCPSocket(fd, false, false)); - // Try and get a socket option from this file descriptor to - // see if this is a socket and set m_is_socket accordingly. + // Try and get a socket option from this file descriptor to see + // if this is a socket and set m_is_socket accordingly. int resuse; bool is_socket = !!tcp_socket->GetOption(SOL_SOCKET, SO_REUSEADDR, resuse); @@ -320,13 +319,11 @@ m_read_sp->GetFdType() == IOObject::eFDTypeSocket) static_cast(*m_read_sp).PreDisconnect(); - // Try to get the ConnectionFileDescriptor's mutex. If we fail, that is quite - // likely - // because somebody is doing a blocking read on our file descriptor. If - // that's the case, - // then send the "q" char to the command file channel so the read will wake up - // and the connection - // will then know to shut down. + // Try to get the ConnectionFileDescriptor's mutex. If we fail, that is + // quite likely because somebody is doing a blocking read on our file + // descriptor. If that's the case, then send the "q" char to the + // command file channel so the read will wake up and the connection will + // then know to shut down. m_shutting_down = true; @@ -445,7 +442,8 @@ case EBADF: // fildes is not a valid file or socket descriptor open for // reading. case ENXIO: // An action is requested of a device that does not exist.. - // A requested action cannot be performed by the device. + // A requested action cannot be performed by the + // device. case ECONNRESET: // The connection is closed by the peer during a read // attempt on a socket. case ENOTCONN: // A read is attempted on an unconnected socket. @@ -549,16 +547,16 @@ ConnectionStatus ConnectionFileDescriptor::BytesAvailable(const Timeout &timeout, Status *error_ptr) { - // Don't need to take the mutex here separately since we are only called from - // Read. If we - // ever get used more generally we will need to lock here as well. + // Don't need to take the mutex here separately since we are only called + // from Read. If we ever get used more generally we will need to lock + // here as well. Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_CONNECTION)); LLDB_LOG(log, "this = {0}, timeout = {1}", this, timeout); - // Make a copy of the file descriptors to make sure we don't - // have another thread change these values out from under us - // and cause problems in the loop below where like in FS_SET() + // Make a copy of the file descriptors to make sure we don't have + // another thread change these values out from under us and cause + // problems in the loop below where like in FS_SET() const IOObject::WaitableHandle handle = m_read_sp->GetWaitableHandle(); const int pipe_fd = m_pipe.GetReadFileDescriptor(); @@ -569,11 +567,10 @@ select_helper.FDSetRead(handle); #if defined(_MSC_VER) - // select() won't accept pipes on Windows. The entire Windows codepath - // needs to be - // converted over to using WaitForMultipleObjects and event HANDLEs, but for - // now at least - // this will allow ::select() to not return an error. + // select() won't accept pipes on Windows. The entire Windows + // codepath needs to be converted over to using WaitForMultipleObjects + // and event HANDLEs, but for now at least this will allow ::select() + // to not return an error. const bool have_pipe_fd = false; #else const bool have_pipe_fd = pipe_fd >= 0; @@ -606,8 +603,7 @@ // allocate the requested number of file descriptors, // or we have non-blocking IO case EINTR: // A signal was delivered before the time limit - // expired and before any of the selected events - // occurred. + // expired and before any of the selected events occurred. break; // Lets keep reading to until we timeout } } else { Index: source/Host/posix/DomainSocket.cpp =================================================================== --- source/Host/posix/DomainSocket.cpp +++ source/Host/posix/DomainSocket.cpp @@ -42,8 +42,8 @@ memcpy(saddr_un->sun_path + name_offset, name.data(), name.size()); // For domain sockets we can use SUN_LEN in order to calculate size of - // sockaddr_un, but for abstract sockets we have to calculate size manually - // because of leading null symbol. + // sockaddr_un, but for abstract sockets we have to calculate size + // manually because of leading null symbol. if (name_offset == 0) saddr_un_len = SUN_LEN(saddr_un); else Index: source/Host/posix/HostInfoPosix.cpp =================================================================== --- source/Host/posix/HostInfoPosix.cpp +++ source/Host/posix/HostInfoPosix.cpp @@ -102,9 +102,8 @@ return group_name.c_str(); } } else { - // The threadsafe version isn't currently working for me on darwin, but the - // non-threadsafe version - // is, so I am calling it below. + // The threadsafe version isn't currently working for me on darwin, + // but the non-threadsafe version is, so I am calling it below. group_info_ptr = ::getgrgid(gid); if (group_info_ptr) { group_name.assign(group_info_ptr->gr_name); @@ -140,9 +139,10 @@ // drop library directory llvm::StringRef parent_path = llvm::sys::path::parent_path(raw_path); - // Most Posix systems (e.g. Linux/*BSD) will attempt to replace a */lib with - // */bin as the base directory for helper exe programs. This will fail if the - // /lib and /bin directories are rooted in entirely different trees. + // Most Posix systems (e.g. Linux/*BSD) will attempt to replace a */lib + // with */bin as the base directory for helper exe programs. This will + // fail if the /lib and /bin directories are rooted in entirely + // different trees. if (log) log->Printf("HostInfoPosix::ComputePathRelativeToLibrary() attempting to " "derive the %s path from this path: %s", @@ -192,9 +192,9 @@ lldb_file_spec.GetPath(raw_path, sizeof(raw_path)); #if defined(LLDB_PYTHON_RELATIVE_LIBDIR) - // Build the path by backing out of the lib dir, then building - // with whatever the real python interpreter uses. (e.g. lib - // for most, lib64 on RHEL x86_64). + // Build the path by backing out of the lib dir, then building with + // whatever the real python interpreter uses. (e.g. lib for most, lib64 + // on RHEL x86_64). char python_path[PATH_MAX]; ::snprintf(python_path, sizeof(python_path), "%s/../%s", raw_path, LLDB_PYTHON_RELATIVE_LIBDIR); @@ -210,7 +210,8 @@ os << "/python" << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << "/site-packages"; - // We may get our string truncated. Should we protect this with an assert? + // We may get our string truncated. Should we protect this with an + // assert? ::strncat(raw_path, python_version_dir.c_str(), sizeof(raw_path) - strlen(raw_path) - 1); Index: source/Host/posix/HostProcessPosix.cpp =================================================================== --- source/Host/posix/HostProcessPosix.cpp +++ source/Host/posix/HostProcessPosix.cpp @@ -66,8 +66,8 @@ if (!error.Success()) return error; - // If the binary has been deleted, the link name has " (deleted)" appended. - // Remove if there. + // If the binary has been deleted, the link name has " (deleted)" + // appended. Remove if there. if (file_spec.GetFilename().GetStringRef().endswith(" (deleted)")) { const char *filename = file_spec.GetFilename().GetCString(); static const size_t deleted_len = strlen(" (deleted)"); @@ -83,7 +83,8 @@ if (m_process == kInvalidPosixProcess) return false; - // Send this process the null signal. If it succeeds the process is running. + // Send this process the null signal. If it succeeds the process is + // running. Status error = Signal(0); return error.Success(); } Index: source/Host/posix/PipePosix.cpp =================================================================== --- source/Host/posix/PipePosix.cpp +++ source/Host/posix/PipePosix.cpp @@ -36,8 +36,8 @@ enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE -// pipe2 is supported by a limited set of platforms -// TODO: Add more platforms that support pipe2. +// pipe2 is supported by a limited set of platforms TODO: Add more +// platforms that support pipe2. #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10) || \ defined(__NetBSD__) #define PIPE2_SUPPORTED 1 @@ -136,9 +136,9 @@ tmpdir_file_spec.AppendPathComponent(pipe_spec.c_str()); } - // It's possible that another process creates the target path after we've - // verified it's available but before we create it, in which case we - // should try again. + // It's possible that another process creates the target path after + // we've verified it's available but before we create it, in which case + // we should try again. Status error; do { llvm::sys::fs::createUniqueFile(tmpdir_file_spec.GetPath(), Index: source/Host/posix/ProcessLauncherPosixFork.cpp =================================================================== --- source/Host/posix/ProcessLauncherPosixFork.cpp +++ source/Host/posix/ProcessLauncherPosixFork.cpp @@ -40,9 +40,9 @@ static void FixupEnvironment(Environment &env) { #ifdef __ANDROID__ - // If there is no PATH variable specified inside the environment then set the - // path to /system/bin. It is required because the default path used by - // execve() is wrong on android. + // If there is no PATH variable specified inside the environment then + // set the path to /system/bin. It is required because the default path + // used by execve() is wrong on android. env.try_emplace("PATH", "/system/bin"); #endif } @@ -131,8 +131,8 @@ FixupEnvironment(env); Environment::Envp envp = env.getEnvp(); - // Clear the signal mask to prevent the child from being affected by - // any masking done by the parent. + // Clear the signal mask to prevent the child from being affected by any + // masking done by the parent. sigset_t set; if (sigemptyset(&set) != 0 || pthread_sigmask(SIG_SETMASK, &set, nullptr) != 0) @@ -141,9 +141,8 @@ if (info.GetFlags().Test(eLaunchFlagDebug)) { // HACK: // Close everything besides stdin, stdout, and stderr that has no file - // action to avoid leaking. Only do this when debugging, as elsewhere we - // actually rely on - // passing open descriptors to child processes. + // action to avoid leaking. Only do this when debugging, as elsewhere + // we actually rely on passing open descriptors to child processes. for (int fd = 3; fd < sysconf(_SC_OPEN_MAX); ++fd) if (!info.GetFileActionForFD(fd) && fd != error_fd) close(fd); @@ -158,25 +157,21 @@ #if defined(__linux__) if (errno == ETXTBSY) { - // On android M and earlier we can get this error because the adb deamon can - // hold a write - // handle on the executable even after it has finished uploading it. This - // state lasts - // only a short time and happens only when there are many concurrent adb - // commands being - // issued, such as when running the test suite. (The file remains open when - // someone does - // an "adb shell" command in the fork() child before it has had a chance to - // exec.) Since - // this state should clear up quickly, wait a while and then give it one - // more go. + // On android M and earlier we can get this error because the adb + // deamon can hold a write handle on the executable even after it has + // finished uploading it. This state lasts only a short time and + // happens only when there are many concurrent adb commands being + // issued, such as when running the test suite. (The file remains open + // when someone does an "adb shell" command in the fork() child before + // it has had a chance to exec.) Since this state should clear up + // quickly, wait a while and then give it one more go. usleep(50000); execve(argv[0], const_cast(argv), envp); } #endif - // ...unless exec fails. In which case we definitely need to end the child - // here. + // ...unless exec fails. In which case we definitely need to end the + // child here. ExitWithError(error_fd, "execve"); } Index: source/Host/windows/ConnectionGenericFileWindows.cpp =================================================================== --- source/Host/windows/ConnectionGenericFileWindows.cpp +++ source/Host/windows/ConnectionGenericFileWindows.cpp @@ -20,13 +20,11 @@ using namespace lldb_private; namespace { -// This is a simple helper class to package up the information needed to return -// from a Read/Write -// operation function. Since there is a lot of code to be run before exit -// regardless of whether the -// operation succeeded or failed, combined with many possible return paths, this -// is the cleanest -// way to represent it. +// This is a simple helper class to package up the information needed to +// return from a Read/Write operation function. Since there is a lot of +// code to be run before exit regardless of whether the operation +// succeeded or failed, combined with many possible return paths, this is +// the cleanest way to represent it. class ReturnInfo { public: void Set(size_t bytes, ConnectionStatus status, DWORD error_code) { @@ -77,14 +75,13 @@ void ConnectionGenericFile::InitializeEventHandles() { m_event_handles[kInterruptEvent] = CreateEvent(NULL, FALSE, FALSE, NULL); - // Note, we should use a manual reset event for the hEvent argument of the - // OVERLAPPED. This - // is because both WaitForMultipleObjects and GetOverlappedResult (if you set - // the bWait - // argument to TRUE) will wait for the event to be signalled. If we use an - // auto-reset event, - // WaitForMultipleObjects will reset the event, return successfully, and then - // GetOverlappedResult will block since the event is no longer signalled. + // Note, we should use a manual reset event for the hEvent argument of + // the OVERLAPPED. This is because both WaitForMultipleObjects and + // GetOverlappedResult (if you set the bWait argument to TRUE) will wait + // for the event to be signalled. If we use an auto-reset event, + // WaitForMultipleObjects will reset the event, return successfully, and + // then GetOverlappedResult will block since the event is no longer + // signalled. m_event_handles[kBytesAvailableEvent] = ::CreateEvent(NULL, TRUE, FALSE, NULL); } @@ -113,10 +110,10 @@ return status; } - // Open the file for overlapped access. If it does not exist, create it. We - // open it overlapped so that we can issue asynchronous reads and then use - // WaitForMultipleObjects to allow the read to be interrupted by an event - // object. + // Open the file for overlapped access. If it does not exist, create + // it. We open it overlapped so that we can issue asynchronous reads + // and then use WaitForMultipleObjects to allow the read to be + // interrupted by an event object. std::wstring wpath; if (!llvm::ConvertUTF8toWide(path, wpath)) { if (error_ptr) @@ -146,19 +143,17 @@ if (!IsConnected()) return eConnectionStatusSuccess; - // Reset the handle so that after we unblock any pending reads, subsequent - // calls to Read() will - // see a disconnected state. + // Reset the handle so that after we unblock any pending reads, + // subsequent calls to Read() will see a disconnected state. HANDLE old_file = m_file; m_file = INVALID_HANDLE_VALUE; - // Set the disconnect event so that any blocking reads unblock, then cancel - // any pending IO operations. + // Set the disconnect event so that any blocking reads unblock, then + // cancel any pending IO operations. ::CancelIoEx(old_file, &m_overlapped); - // Close the file handle if we owned it, but don't close the event handles. - // We could always - // reconnect with the same Connection instance. + // Close the file handle if we owned it, but don't close the event + // handles. We could always reconnect with the same Connection instance. if (m_owns_file) ::CloseHandle(old_file); @@ -189,9 +184,8 @@ result = ::ReadFile(m_file, dst, dst_len, NULL, &m_overlapped); if (result || ::GetLastError() == ERROR_IO_PENDING) { if (!result) { - // The expected return path. The operation is pending. Wait for the - // operation to complete - // or be interrupted. + // The expected return path. The operation is pending. Wait for + // the operation to complete or be interrupted. DWORD milliseconds = timeout ? std::chrono::duration_cast(*timeout) @@ -200,8 +194,8 @@ DWORD wait_result = ::WaitForMultipleObjects(llvm::array_lengthof(m_event_handles), m_event_handles, FALSE, milliseconds); - // All of the events are manual reset events, so make sure we reset them - // to non-signalled. + // All of the events are manual reset events, so make sure we reset + // them to non-signalled. switch (wait_result) { case WAIT_OBJECT_0 + kBytesAvailableEvent: break; @@ -219,11 +213,10 @@ // The data is ready. Figure out how much was read and return; if (!::GetOverlappedResult(m_file, &m_overlapped, &bytes_read, FALSE)) { DWORD result_error = ::GetLastError(); - // ERROR_OPERATION_ABORTED occurs when someone calls Disconnect() during a - // blocking read. - // This triggers a call to CancelIoEx, which causes the operation to - // complete and the - // result to be ERROR_OPERATION_ABORTED. + // ERROR_OPERATION_ABORTED occurs when someone calls Disconnect() + // during a blocking read. This triggers a call to CancelIoEx, which + // causes the operation to complete and the result to be + // ERROR_OPERATION_ABORTED. if (result_error == ERROR_HANDLE_EOF || result_error == ERROR_OPERATION_ABORTED || result_error == ERROR_BROKEN_PIPE) @@ -250,9 +243,9 @@ if (error_ptr) *error_ptr = return_info.GetError(); - // kBytesAvailableEvent is a manual reset event. Make sure it gets reset here - // so that any - // subsequent operations don't immediately see bytes available. + // kBytesAvailableEvent is a manual reset event. Make sure it gets + // reset here so that any subsequent operations don't immediately see + // bytes available. ResetEvent(m_event_handles[kBytesAvailableEvent]); IncrementFilePointer(return_info.GetBytes()); @@ -284,7 +277,8 @@ m_overlapped.hEvent = NULL; - // Writes are not interruptible like reads are, so just block until it's done. + // Writes are not interruptible like reads are, so just block until it's + // done. result = ::WriteFile(m_file, src, src_len, NULL, &m_overlapped); if (!result && ::GetLastError() != ERROR_IO_PENDING) { return_info.Set(0, eConnectionStatusError, ::GetLastError()); Index: source/Host/windows/EditLineWin.cpp =================================================================== --- source/Host/windows/EditLineWin.cpp +++ source/Host/windows/EditLineWin.cpp @@ -35,7 +35,8 @@ // stored key bindings static std::vector _bindings; -// TODO: this should in fact be related to the exact edit line context we create +// TODO: this should in fact be related to the exact edit line context we +// create static void *clientData = NULL; // store the current prompt string @@ -316,8 +317,8 @@ } int el_source(EditLine *el, const char *file) { - // init edit line by reading the contents of 'file' - // nothing to do here on windows... + // init edit line by reading the contents of 'file' nothing to do here + // on windows... return 0; } @@ -342,8 +343,8 @@ } int history(History *, HistEvent *, int op, ...) { - // perform operation 'op' on the history list with - // optional arguments as needed by the operation. + // perform operation 'op' on the history list with optional arguments as + // needed by the operation. return 0; } Index: source/Host/windows/FileSystem.cpp =================================================================== --- source/Host/windows/FileSystem.cpp +++ source/Host/windows/FileSystem.cpp @@ -65,8 +65,8 @@ } std::vector buf(PATH_MAX + 1); - // Subtract 1 from the path length since this function does not add a null - // terminator. + // Subtract 1 from the path length since this function does not add a + // null terminator. DWORD result = ::GetFinalPathNameByHandleW( h, buf.data(), buf.size() - 1, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS); std::string path; Index: source/Host/windows/Host.cpp =================================================================== --- source/Host/windows/Host.cpp +++ source/Host/windows/Host.cpp @@ -34,9 +34,8 @@ namespace { bool GetTripleForProcess(const FileSpec &executable, llvm::Triple &triple) { - // Open the PE File as a binary file, and parse just enough information to - // determine the - // machine type. + // Open the PE File as a binary file, and parse just enough information + // to determine the machine type. File imageBinary(executable.GetPath().c_str(), File::eOpenOptionRead, lldb::eFilePermissionsUserRead); imageBinary.SeekFromStart(0x3c); @@ -63,8 +62,8 @@ } bool GetExecutableForProcess(const AutoHandle &handle, std::string &path) { - // Get the process image path. MAX_PATH isn't long enough, paths can actually - // be up to 32KB. + // Get the process image path. MAX_PATH isn't long enough, paths can + // actually be up to 32KB. std::vector buffer(PATH_MAX); DWORD dwSize = buffer.size(); if (!::QueryFullProcessImageNameW(handle.get(), 0, &buffer[0], &dwSize)) @@ -74,11 +73,10 @@ void GetProcessExecutableAndTriple(const AutoHandle &handle, ProcessInstanceInfo &process) { - // We may not have permissions to read the path from the process. So start - // off by - // setting the executable file to whatever Toolhelp32 gives us, and then try - // to - // enhance this with more detailed information, but fail gracefully. + // We may not have permissions to read the path from the process. So + // start off by setting the executable file to whatever Toolhelp32 gives + // us, and then try to enhance this with more detailed information, but + // fail gracefully. std::string executable; llvm::Triple triple; triple.setVendor(llvm::Triple::PC); @@ -171,7 +169,8 @@ process_info.SetProcessID(pid); GetProcessExecutableAndTriple(handle, process_info); - // Need to read the PEB to get parent process and command line arguments. + // Need to read the PEB to get parent process and command line + // arguments. return true; } @@ -260,9 +259,9 @@ Environment Host::GetEnvironment() { Environment env; - // The environment block on Windows is a contiguous buffer of NULL terminated - // strings, where the end of the environment block is indicated by two - // consecutive NULLs. + // The environment block on Windows is a contiguous buffer of NULL + // terminated strings, where the end of the environment block is + // indicated by two consecutive NULLs. LPWCH environment_block = ::GetEnvironmentStringsW(); while (*environment_block != L'\0') { std::string current_var; Index: source/Host/windows/HostInfoWindows.cpp =================================================================== --- source/Host/windows/HostInfoWindows.cpp +++ source/Host/windows/HostInfoWindows.cpp @@ -50,11 +50,10 @@ info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); #pragma warning(push) #pragma warning(disable : 4996) - // Starting with Microsoft SDK for Windows 8.1, this function is deprecated in - // favor of the - // new Windows Version Helper APIs. Since we don't specify a minimum SDK - // version, it's easier - // to simply disable the warning rather than try to support both APIs. + // Starting with Microsoft SDK for Windows 8.1, this function is + // deprecated in favor of the new Windows Version Helper APIs. Since we + // don't specify a minimum SDK version, it's easier to simply disable + // the warning rather than try to support both APIs. if (GetVersionEx((LPOSVERSIONINFO)&info) == 0) { return false; } Index: source/Host/windows/HostProcessWindows.cpp =================================================================== --- source/Host/windows/HostProcessWindows.cpp +++ source/Host/windows/HostProcessWindows.cpp @@ -87,9 +87,9 @@ MonitorInfo *info = new MonitorInfo; info->callback = callback; - // Since the life of this HostProcessWindows instance and the life of the - // process may be different, duplicate the handle so that - // the monitor thread can have ownership over its own copy of the handle. + // Since the life of this HostProcessWindows instance and the life of + // the process may be different, duplicate the handle so that the + // monitor thread can have ownership over its own copy of the handle. HostThread result; if (::DuplicateHandle(GetCurrentProcess(), m_process, GetCurrentProcess(), &info->process_handle, 0, FALSE, DUPLICATE_SAME_ACCESS)) Index: source/Host/windows/PipeWindows.cpp =================================================================== --- source/Host/windows/PipeWindows.cpp +++ source/Host/windows/PipeWindows.cpp @@ -40,11 +40,9 @@ PipeWindows::~PipeWindows() { Close(); } Status PipeWindows::CreateNew(bool child_process_inherit) { - // Even for anonymous pipes, we open a named pipe. This is because you cannot - // get - // overlapped i/o on Windows without using a named pipe. So we synthesize a - // unique - // name. + // Even for anonymous pipes, we open a named pipe. This is because you + // cannot get overlapped i/o on Windows without using a named pipe. So + // we synthesize a unique name. uint32_t serial = g_pipe_serial.fetch_add(1); std::string pipe_name; llvm::raw_string_ostream pipe_name_stream(pipe_name); @@ -65,8 +63,8 @@ std::string pipe_path = "\\\\.\\Pipe\\"; pipe_path.append(name); - // Always open for overlapped i/o. We implement blocking manually in Read and - // Write. + // Always open for overlapped i/o. We implement blocking manually in + // Read and Write. DWORD read_mode = FILE_FLAG_OVERLAPPED; m_read = ::CreateNamedPipeA( pipe_path.c_str(), PIPE_ACCESS_INBOUND | read_mode, @@ -249,14 +247,12 @@ : duration.count() * 1000; DWORD wait_result = ::WaitForSingleObject(m_read_overlapped.hEvent, timeout); if (wait_result != WAIT_OBJECT_0) { - // The operation probably failed. However, if it timed out, we need to - // cancel the I/O. - // Between the time we returned from WaitForSingleObject and the time we - // call CancelIoEx, - // the operation may complete. If that hapens, CancelIoEx will fail and - // return ERROR_NOT_FOUND. - // If that happens, the original operation should be considered to have been - // successful. + // The operation probably failed. However, if it timed out, we need + // to cancel the I/O. Between the time we returned from + // WaitForSingleObject and the time we call CancelIoEx, the operation + // may complete. If that hapens, CancelIoEx will fail and return + // ERROR_NOT_FOUND. If that happens, the original operation should be + // considered to have been successful. bool failed = true; DWORD failure_error = ::GetLastError(); if (wait_result == WAIT_TIMEOUT) { @@ -268,9 +264,8 @@ return Status(failure_error, eErrorTypeWin32); } - // Now we call GetOverlappedResult setting bWait to false, since we've already - // waited - // as long as we're willing to. + // Now we call GetOverlappedResult setting bWait to false, since we've + // already waited as long as we're willing to. if (!GetOverlappedResult(m_read, &m_read_overlapped, &sys_bytes_read, FALSE)) return Status(::GetLastError(), eErrorTypeWin32); Index: source/Host/windows/ProcessLauncherWindows.cpp =================================================================== --- source/Host/windows/ProcessLauncherWindows.cpp +++ source/Host/windows/ProcessLauncherWindows.cpp @@ -26,7 +26,8 @@ if (env.size() == 0) return; - // Environment buffer is a null terminated list of null terminated strings + // Environment buffer is a null terminated list of null terminated + // strings for (const auto &KV : env) { std::wstring warg; if (llvm::ConvertUTF8toWide(Environment::compose(KV), warg)) { @@ -97,8 +98,8 @@ wworkingDirectory.size() == 0 ? NULL : wworkingDirectory.c_str(), &startupinfo, &pi); if (result) { - // Do not call CloseHandle on pi.hProcess, since we want to pass that back - // through the HostProcess. + // Do not call CloseHandle on pi.hProcess, since we want to pass that + // back through the HostProcess. ::CloseHandle(pi.hThread); } Index: source/Initialization/SystemInitializerCommon.cpp =================================================================== --- source/Initialization/SystemInitializerCommon.cpp +++ source/Initialization/SystemInitializerCommon.cpp @@ -51,12 +51,10 @@ const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG"); if (disable_crash_dialog_var && llvm::StringRef(disable_crash_dialog_var).equals_lower("true")) { - // This will prevent Windows from displaying a dialog box requiring user - // interaction when - // LLDB crashes. This is mostly useful when automating LLDB, for example - // via the test - // suite, so that a crash in LLDB does not prevent completion of the test - // suite. + // This will prevent Windows from displaying a dialog box requiring + // user interaction when LLDB crashes. This is mostly useful when + // automating LLDB, for example via the test suite, so that a crash in + // LLDB does not prevent completion of the test suite. ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); Index: source/Interpreter/CommandAlias.cpp =================================================================== --- source/Interpreter/CommandAlias.cpp +++ source/Interpreter/CommandAlias.cpp @@ -32,11 +32,12 @@ Args args(options_args); std::string options_string(options_args); CommandReturnObject result; - // Check to see if the command being aliased can take any command options. + // Check to see if the command being aliased can take any command + // options. Options *options = cmd_obj_sp->GetOptions(); if (options) { - // See if any options were specified as part of the alias; if so, handle - // them appropriately. + // See if any options were specified as part of the alias; if so, + // handle them appropriately. ExecutionContext exe_ctx = cmd_obj_sp->GetCommandInterpreter().GetExecutionContext(); options->NotifyOptionParsingStarting(&exe_ctx); @@ -227,9 +228,9 @@ return {underlying, GetOptionArguments()}; } -// allow CommandAlias objects to provide their own help, but fallback to the -// info -// for the underlying command if no customization has been provided +// allow CommandAlias objects to provide their own help, but fallback to +// the info for the underlying command if no customization has been +// provided void CommandAlias::SetHelp(llvm::StringRef str) { this->CommandObject::SetHelp(str); m_did_set_help = true; Index: source/Interpreter/CommandInterpreter.cpp =================================================================== --- source/Interpreter/CommandInterpreter.cpp +++ source/Interpreter/CommandInterpreter.cpp @@ -539,8 +539,8 @@ if (tbreak_regex_cmd_ap.get()) { bool success = true; for (size_t i = 0; i < num_regexes; i++) { - // If you add a resultant command string longer than 1024 characters be - // sure to increase the size of this buffer. + // If you add a resultant command string longer than 1024 characters + // be sure to increase the size of this buffer. char buffer[1024]; int num_printed = snprintf(buffer, 1024, "%s %s", break_regexes[i][1], "-o"); @@ -681,10 +681,9 @@ "bt [ | all]", 2, 0, false)); if (bt_regex_cmd_ap.get()) { // accept but don't document "bt -c " -- before bt was a regex - // command if you wanted to backtrace - // three frames you would do "bt -c 3" but the intention is to have this - // emulate the gdb "bt" command and - // so now "bt 3" is the preferred form, in line with gdb. + // command if you wanted to backtrace three frames you would do "bt -c + // 3" but the intention is to have this emulate the gdb "bt" command + // and so now "bt 3" is the preferred form, in line with gdb. if (bt_regex_cmd_ap->AddRegexCommand("^([[:digit:]]+)$", "thread backtrace -c %1") && bt_regex_cmd_ap->AddRegexCommand("^-c ([[:digit:]]+)$", @@ -824,10 +823,9 @@ unsigned int num_alias_matches = 0; unsigned int num_user_matches = 0; - // Look through the command dictionaries one by one, and if we get only one - // match from any of - // them in toto, then return that, otherwise return an empty CommandObjectSP - // and the list of matches. + // Look through the command dictionaries one by one, and if we get + // only one match from any of them in toto, then return that, + // otherwise return an empty CommandObjectSP and the list of matches. if (HasCommands()) { num_cmd_matches = @@ -867,8 +865,8 @@ user_match_sp = pos->second; } - // If we got exactly one match, return that, otherwise return the match - // list. + // If we got exactly one match, return that, otherwise return the + // match list. if (num_user_matches + num_cmd_matches + num_alias_matches == 1) { if (num_cmd_matches) @@ -948,32 +946,31 @@ if (cmd_words.GetArgumentCount() == 1) return GetCommandSP(cmd_str, include_aliases, true, nullptr); else { - // We have a multi-word command (seemingly), so we need to do more work. - // First, get the cmd_obj_sp for the first word in the command. + // We have a multi-word command (seemingly), so we need to do more + // work. First, get the cmd_obj_sp for the first word in the command. CommandObjectSP cmd_obj_sp = GetCommandSP(llvm::StringRef(cmd_words.GetArgumentAtIndex(0)), include_aliases, true, nullptr); if (cmd_obj_sp.get() != nullptr) { - // Loop through the rest of the words in the command (everything passed in - // was supposed to be part of a - // command name), and find the appropriate sub-command SP for each command - // word.... + // Loop through the rest of the words in the command (everything + // passed in was supposed to be part of a command name), and find + // the appropriate sub-command SP for each command word.... size_t end = cmd_words.GetArgumentCount(); for (size_t j = 1; j < end; ++j) { if (cmd_obj_sp->IsMultiwordObject()) { cmd_obj_sp = cmd_obj_sp->GetSubcommandSP(cmd_words.GetArgumentAtIndex(j)); if (cmd_obj_sp.get() == nullptr) - // The sub-command name was invalid. Fail and return the empty - // 'ret_val'. + // The sub-command name was invalid. Fail and return the + // empty 'ret_val'. return ret_val; } else // We have more words in the command name, but we don't have a // multiword object. Fail and return empty 'ret_val'. return ret_val; } - // We successfully looped through all the command words and got valid - // command objects for them. Assign the last object retrieved to - // 'ret_val'. + // We successfully looped through all the command words and got + // valid command objects for them. Assign the last object retrieved + // to 'ret_val'. ret_val = cmd_obj_sp; } } @@ -985,9 +982,8 @@ CommandObject *command_obj = GetCommandSP(cmd_str, false, true, matches).get(); - // If we didn't find an exact match to the command string in the commands, - // look in - // the aliases. + // If we didn't find an exact match to the command string in the + // commands, look in the aliases. if (command_obj) return command_obj; @@ -997,13 +993,12 @@ if (command_obj) return command_obj; - // If there wasn't an exact match then look for an inexact one in just the - // commands + // If there wasn't an exact match then look for an inexact one in just + // the commands command_obj = GetCommandSP(cmd_str, false, false, nullptr).get(); - // Finally, if there wasn't an inexact match among the commands, look for an - // inexact - // match in both the commands and aliases. + // Finally, if there wasn't an inexact match among the commands, look + // for an inexact match in both the commands and aliases. if (command_obj) { if (matches) @@ -1030,7 +1025,8 @@ num_alias_matches = AddNamesMatchingPartialString(m_alias_dict, cmd, matches); if (num_alias_matches == 1) { - // Make sure this isn't shadowing a command in the regular command space: + // Make sure this isn't shadowing a command in the regular command + // space: StringList regular_matches; const bool include_aliases = false; const bool exact = false; @@ -1165,9 +1161,9 @@ CommandObject *CommandInterpreter::GetCommandObjectForCommand( llvm::StringRef &command_string) { - // This function finds the final, lowest-level, alias-resolved command object - // whose 'Execute' function will - // eventually be invoked by the given command line. + // This function finds the final, lowest-level, alias-resolved command + // object whose 'Execute' function will eventually be invoked by the + // given command line. CommandObject *cmd_obj = nullptr; size_t start = command_string.find_first_not_of(k_white_space); @@ -1182,12 +1178,12 @@ std::string cmd_word = command_string.substr(start, end - start); if (cmd_obj == nullptr) - // Since cmd_obj is NULL we are on our first time through this loop. - // Check to see if cmd_word is a valid command or alias. + // Since cmd_obj is NULL we are on our first time through this + // loop. Check to see if cmd_word is a valid command or alias. cmd_obj = GetCommandObject(cmd_word); else if (cmd_obj->IsMultiwordObject()) { - // Our current object is a multi-word object; see if the cmd_word is a - // valid sub-command for our object. + // Our current object is a multi-word object; see if the cmd_word + // is a valid sub-command for our object. CommandObject *sub_cmd_obj = cmd_obj->GetSubcommandObject(cmd_word.c_str()); if (sub_cmd_obj) @@ -1195,12 +1191,14 @@ else // cmd_word was not a valid sub-command word, so we are done done = true; } else - // We have a cmd_obj and it is not a multi-word object, so we are done. + // We have a cmd_obj and it is not a multi-word object, so we are + // done. done = true; - // If we didn't find a valid command object, or our command object is not - // a multi-word object, or we are at the end of the command_string, then - // we are done. Otherwise, find the start of the next word. + // If we didn't find a valid command object, or our command object + // is not a multi-word object, or we are at the end of the + // command_string, then we are done. Otherwise, find the start of + // the next word. if (!cmd_obj || !cmd_obj->IsMultiwordObject() || end >= command_string.size()) @@ -1374,13 +1372,12 @@ } Status CommandInterpreter::PreprocessCommand(std::string &command) { - // The command preprocessor needs to do things to the command - // line before any parsing of arguments or anything else is done. - // The only current stuff that gets preprocessed is anything enclosed - // in backtick ('`') characters is evaluated as an expression and - // the result of the expression must be a scalar that can be substituted - // into the command. An example would be: - // (lldb) memory read `$rsp + 20` + // The command preprocessor needs to do things to the command line + // before any parsing of arguments or anything else is done. The only + // current stuff that gets preprocessed is anything enclosed in backtick + // ('`') characters is evaluated as an expression and the result of the + // expression must be a scalar that can be substituted into the command. + // An example would be: (lldb) memory read `$rsp + 20` Status error; // Status for any expressions that might not evaluate size_t start_backtick; size_t pos = 0; @@ -1405,9 +1402,9 @@ ExecutionContext exe_ctx(GetExecutionContext()); Target *target = exe_ctx.GetTargetPtr(); - // Get a dummy target to allow for calculator mode while processing - // backticks. - // This also helps break the infinite loop caused when target is null. + // Get a dummy target to allow for calculator mode while + // processing backticks. This also helps break the infinite loop + // caused when target is null. if (!target) target = m_debugger.GetDummyTarget(); if (target) { @@ -1559,8 +1556,8 @@ const char *k_space_characters = "\t\n\v\f\r "; size_t non_space = command_string.find_first_not_of(k_space_characters); - // Check for empty line or comment line (lines whose first - // non-space character is the comment character for this interpreter) + // Check for empty line or comment line (lines whose first non-space + // character is the comment character for this interpreter) if (non_space == std::string::npos) empty_command = true; else if (command_string[non_space] == m_comment_char) @@ -1617,13 +1614,13 @@ // Phase 1. - // Before we do ANY kind of argument processing, we need to figure out what - // the real/final command object is for the specified command. This gets - // complicated by the fact that the user could have specified an alias, and, - // in translating the alias, there may also be command options and/or even - // data (including raw text strings) that need to be found and inserted into - // the command line as part of the translation. So this first step is plain - // look-up and replacement, resulting in: + // Before we do ANY kind of argument processing, we need to figure out + // what the real/final command object is for the specified command. + // This gets complicated by the fact that the user could have specified + // an alias, and, in translating the alias, there may also be command + // options and/or even data (including raw text strings) that need to be + // found and inserted into the command line as part of the translation. + // So this first step is plain look-up and replacement, resulting in: // 1. the command object whose Execute method will actually be called // 2. a revised command string, with all substitutions and replacements // taken care of @@ -1632,9 +1629,10 @@ CommandObject *cmd_obj = ResolveCommandImpl(command_string, result); - // Although the user may have abbreviated the command, the command_string now - // has the command expanded to the full name. For example, if the input - // was "br s -n main", command_string is now "breakpoint set -n main". + // Although the user may have abbreviated the command, the + // command_string now has the command expanded to the full name. For + // example, if the input was "br s -n main", command_string is now + // "breakpoint set -n main". if (log) { llvm::StringRef command_name = cmd_obj ? cmd_obj->GetCommandName() : ""; log->Printf("HandleCommand, cmd_obj : '%s'", command_name.str().c_str()); @@ -1648,8 +1646,8 @@ // Phase 2. // Take care of things like setting up the history command & calling the - // appropriate Execute method on the - // CommandObject, with the appropriate arguments. + // appropriate Execute method on the CommandObject, with the appropriate + // arguments. if (cmd_obj != nullptr) { if (add_to_history) { @@ -1680,7 +1678,8 @@ cmd_obj->Execute(remainder.c_str(), result); } else { - // We didn't find the first command object, so complete the first argument. + // We didn't find the first command object, so complete the first + // argument. Args command_args(command_string); StringList matches; int num_matches; @@ -1725,7 +1724,8 @@ int num_command_matches = 0; bool look_for_subcommand = false; - // For any of the command completions a unique match will be a complete word. + // For any of the command completions a unique match will be a complete + // word. word_complete = true; if (cursor_index == -1) { @@ -1759,9 +1759,8 @@ if (cursor_index > 0 || look_for_subcommand) { // We are completing further on into a commands arguments, so find the - // command and tell it - // to complete the command. - // First see if there is a matching initial command: + // command and tell it to complete the command. First see if there is + // a matching initial command: CommandObject *command_object = GetCommandObject(parsed_line.GetArgumentAtIndex(0)); if (command_object == nullptr) { @@ -1781,17 +1780,17 @@ int CommandInterpreter::HandleCompletion( const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, StringList &matches) { - // We parse the argument up to the cursor, so the last argument in parsed_line - // is - // the one containing the cursor, and the cursor is after the last character. + // We parse the argument up to the cursor, so the last argument in + // parsed_line is the one containing the cursor, and the cursor is after + // the last character. Args parsed_line(llvm::StringRef(current_line, last_char - current_line)); Args partial_parsed_line( llvm::StringRef(current_line, cursor - current_line)); - // Don't complete comments, and if the line we are completing is just the - // history repeat character, - // substitute the appropriate history line. + // Don't complete comments, and if the line we are completing is just + // the history repeat character, substitute the appropriate history + // line. const char *first_arg = parsed_line.GetArgumentAtIndex(0); if (first_arg) { if (first_arg[0] == m_comment_char) @@ -1818,13 +1817,10 @@ if (cursor > current_line && cursor[-1] == ' ') { // We are just after a space. If we are in an argument, then we will - // continue - // parsing, but if we are between arguments, then we have to complete - // whatever the next - // element would be. - // We can distinguish the two cases because if we are in an argument (e.g. - // because the space is - // protected by a quote) then the space will also be in the parsed + // continue parsing, but if we are between arguments, then we have to + // complete whatever the next element would be. We can distinguish the + // two cases because if we are in an argument (e.g. because the space + // is protected by a quote) then the space will also be in the parsed // argument... const char *current_elem = @@ -1856,9 +1852,8 @@ // If we got an empty string, insert nothing. matches.InsertStringAtIndex(0, ""); } else { - // Now figure out if there is a common substring, and if so put that in - // element 0, otherwise - // put an empty string in element 0. + // Now figure out if there is a common substring, and if so put that + // in element 0, otherwise put an empty string in element 0. std::string command_partial_str; if (cursor_index >= 0) command_partial_str = @@ -1869,9 +1864,8 @@ const size_t partial_name_len = command_partial_str.size(); common_prefix.erase(0, partial_name_len); - // If we matched a unique single command, add a space... - // Only do this if the completer told us this was a complete word, - // however... + // If we matched a unique single command, add a space... Only do this + // if the completer told us this was a complete word, however... if (num_command_matches == 1 && word_complete) { char quote_char = parsed_line[cursor_index].quote; common_prefix = @@ -1948,12 +1942,13 @@ if (option_arg_vector_sp.get()) { if (wants_raw_input) { - // We have a command that both has command options and takes raw input. - // Make *sure* it has a - // " -- " in the right place in the raw_input_string. + // We have a command that both has command options and takes raw + // input. Make *sure* it has a " -- " in the right place in the + // raw_input_string. size_t pos = raw_input_string.find(" -- "); if (pos == std::string::npos) { - // None found; assume it goes at the beginning of the raw input string + // None found; assume it goes at the beginning of the raw input + // string raw_input_string.insert(0, " -- "); } } @@ -1971,7 +1966,8 @@ std::tie(option, value_type, value) = option_entry; if (option == "") { if (!wants_raw_input || (value != "--")) { - // Since we inserted this above, make sure we don't insert it twice + // Since we inserted this above, make sure we don't insert it + // twice new_args.AppendArgument(value); } continue; @@ -2003,7 +1999,8 @@ result.SetStatus(eReturnStatusFailed); return; } else { - // Find and remove cmd_args.GetArgumentAtIndex(i) from raw_input_string + // Find and remove cmd_args.GetArgumentAtIndex(i) from + // raw_input_string size_t strpos = raw_input_string.find(cmd_args.GetArgumentAtIndex(index)); if (strpos != std::string::npos) { @@ -2033,11 +2030,10 @@ new_args.GetConstArgumentVector()); } else { result.SetStatus(eReturnStatusSuccessFinishNoResult); - // This alias was not created with any options; nothing further needs to be - // done, unless it is a command that - // wants raw input, in which case we need to clear the rest of the data from - // cmd_args, since its in the raw - // input string. + // This alias was not created with any options; nothing further needs + // to be done, unless it is a command that wants raw input, in which + // case we need to clear the rest of the data from cmd_args, since its + // in the raw input string. if (wants_raw_input) { cmd_args.Clear(); cmd_args.SetArguments(new_args.GetArgumentCount(), @@ -2067,7 +2063,8 @@ while (isdigit(cptr[0])) ++cptr; - // We've gotten to the end of the digits; are we at the end of the string? + // We've gotten to the end of the digits; are we at the end of the + // string? if (cptr[0] == '\0') position = atoi(start); } @@ -2083,8 +2080,8 @@ ExecutionContext exe_ctx(GetExecutionContext()); Target *target = exe_ctx.GetTargetPtr(); if (target) { - // In the current working directory we don't load any program specific - // .lldbinit files, we only look for a ".lldbinit" file. + // In the current working directory we don't load any program + // specific .lldbinit files, we only look for a ".lldbinit" file. if (m_skip_lldbinit_files) return; @@ -2119,12 +2116,12 @@ } } } else { - // If we aren't looking in the current working directory we are looking - // in the home directory. We will first see if there is an application - // specific ".lldbinit" file whose name is "~/.lldbinit" followed by a - // "-" and the name of the program. If this file doesn't exist, we fall - // back to just the "~/.lldbinit" file. We also obey any requests to not - // load the init files. + // If we aren't looking in the current working directory we are + // looking in the home directory. We will first see if there is an + // application specific ".lldbinit" file whose name is "~/.lldbinit" + // followed by a "-" and the name of the program. If this file doesn't + // exist, we fall back to just the "~/.lldbinit" file. We also obey + // any requests to not load the init files. llvm::SmallString<64> home_dir_path; llvm::sys::path::home_directory(home_dir_path); FileSpec profilePath(home_dir_path.c_str(), false); @@ -2149,10 +2146,9 @@ init_file.SetFile(init_file_path, false); } - // If the file exists, tell HandleCommand to 'source' it; this will do the - // actual broadcasting - // of the commands back to any appropriate listener (see - // CommandObjectSource::Execute for more details). + // If the file exists, tell HandleCommand to 'source' it; this will do + // the actual broadcasting of the commands back to any appropriate + // listener (see CommandObjectSource::Execute for more details). if (init_file.Exists()) { const bool saved_batch = SetBatchCommandMode(true); @@ -2197,15 +2193,15 @@ size_t num_lines = commands.GetSize(); // If we are going to continue past a "continue" then we need to run the - // commands synchronously. - // Make sure you reset this value anywhere you return from the function. + // commands synchronously. Make sure you reset this value anywhere you + // return from the function. bool old_async_execution = m_debugger.GetAsyncExecution(); - // If we've been given an execution context, set it at the start, but don't - // keep resetting it or we will - // cause series of commands that change the context, then do an operation that - // relies on that context to fail. + // If we've been given an execution context, set it at the start, but + // don't keep resetting it or we will cause series of commands that + // change the context, then do an operation that relies on that context + // to fail. if (override_context != nullptr) UpdateExecutionContext(override_context); @@ -2226,13 +2222,13 @@ } CommandReturnObject tmp_result; - // If override_context is not NULL, pass no_context_switching = true for - // HandleCommand() since we updated our context already. + // If override_context is not NULL, pass no_context_switching = true + // for HandleCommand() since we updated our context already. // We might call into a regex or alias command, in which case the - // add_to_history will get lost. This - // m_command_source_depth dingus is the way we turn off adding to the - // history in that case, so set it up here. + // add_to_history will get lost. This m_command_source_depth dingus + // is the way we turn off adding to the history in that case, so set + // it up here. if (!options.GetAddToHistory()) m_command_source_depth++; bool success = @@ -2273,18 +2269,17 @@ if (result.GetImmediateErrorStream()) result.GetImmediateErrorStream()->Flush(); - // N.B. Can't depend on DidChangeProcessState, because the state coming into - // the command execution - // could be running (for instance in Breakpoint Commands. - // So we check the return value to see if it is has running in it. + // N.B. Can't depend on DidChangeProcessState, because the state + // coming into the command execution could be running (for instance in + // Breakpoint Commands. So we check the return value to see if it is + // has running in it. if ((tmp_result.GetStatus() == eReturnStatusSuccessContinuingNoResult) || (tmp_result.GetStatus() == eReturnStatusSuccessContinuingResult)) { if (options.GetStopOnContinue()) { - // If we caused the target to proceed, and we're going to stop in that - // case, set the - // status in our real result before returning. This is an error if the - // continue was not the - // last command in the set of commands to be run. + // If we caused the target to proceed, and we're going to stop in + // that case, set the status in our real result before returning. + // This is an error if the continue was not the last command in + // the set of commands to be run. if (idx != num_lines - 1) result.AppendErrorWithFormat( "Aborting reading of commands after command #%" PRIu64 @@ -2344,8 +2339,8 @@ return; } -// Make flags that we can pass into the IOHandler so our delegates can do the -// right thing +// Make flags that we can pass into the IOHandler so our delegates can do +// the right thing enum { eHandleCommandFlagStopOnContinue = (1u << 0), eHandleCommandFlagStopOnError = (1u << 1), @@ -2432,8 +2427,8 @@ cmd_file_path.c_str()); } - // Used for inheriting the right settings when "command source" might have - // nested "command source" commands + // Used for inheriting the right settings when "command source" + // might have nested "command source" commands lldb::StreamFileSP empty_stream_sp; m_command_source_flags.push_back(flags); IOHandlerSP io_handler_sp(new IOHandlerEditline( @@ -2521,7 +2516,8 @@ // Always break on an explicit newline. std::size_t first_newline = this_line.find_first_of("\n"); - // Don't break on space/tab unless the text is too long to fit on one line. + // Don't break on space/tab unless the text is too long to fit on one + // line. std::size_t last_space = llvm::StringRef::npos; if (this_line.size() != help_text.size()) last_space = this_line.find_last_of(" \t"); @@ -2744,20 +2740,17 @@ const bool is_interactive = io_handler.GetIsInteractive(); if (is_interactive == false) { - // When we are not interactive, don't execute blank lines. This will happen - // sourcing a commands file. We don't want blank lines to repeat the - // previous - // command and cause any errors to occur (like redefining an alias, get an - // error - // and stop parsing the commands file). + // When we are not interactive, don't execute blank lines. This will + // happen sourcing a commands file. We don't want blank lines to + // repeat the previous command and cause any errors to occur (like + // redefining an alias, get an error and stop parsing the commands + // file). if (line.empty()) return; - // When using a non-interactive file handle (like when sourcing commands - // from a file) - // we need to echo the command out so we don't just see the command output - // and no - // command... + // When using a non-interactive file handle (like when sourcing + // commands from a file) we need to echo the command out so we don't + // just see the command output and no command... if (io_handler.GetFlags().Test(eHandleCommandFlagEchoCommand)) io_handler.GetOutputStreamFile()->Printf("%s%s\n", io_handler.GetPrompt(), line.c_str()); @@ -2770,7 +2763,8 @@ // Now emit the command output text from the command we just executed if (io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) { - // Display any STDOUT/STDERR _prior_ to emitting the command result text + // Display any STDOUT/STDERR _prior_ to emitting the command result + // text GetProcessOutput(); if (!result.GetImmediateOutputStream()) { @@ -2914,13 +2908,13 @@ lldb::IOHandlerSP CommandInterpreter::GetIOHandler(bool force_create, CommandInterpreterRunOptions *options) { - // Always re-create the IOHandlerEditline in case the input - // changed. The old instance might have had a non-interactive - // input and now it does or vice versa. + // Always re-create the IOHandlerEditline in case the input changed. The + // old instance might have had a non-interactive input and now it does + // or vice versa. if (force_create || !m_command_io_handler_sp) { - // Always re-create the IOHandlerEditline in case the input - // changed. The old instance might have had a non-interactive - // input and now it does or vice versa. + // Always re-create the IOHandlerEditline in case the input changed. + // The old instance might have had a non-interactive input and now it + // does or vice versa. uint32_t flags = 0; if (options) { @@ -2954,8 +2948,8 @@ void CommandInterpreter::RunCommandInterpreter( bool auto_handle_events, bool spawn_thread, CommandInterpreterRunOptions &options) { - // Always re-create the command interpreter when we run it in case - // any file handles have changed. + // Always re-create the command interpreter when we run it in case any + // file handles have changed. bool force_create = true; m_debugger.PushIOHandler(GetIOHandler(force_create, &options)); m_stopped_for_crash = false; @@ -3023,8 +3017,8 @@ CommandObject *sub_cmd_obj = cmd_obj->GetSubcommandObject(next_word.c_str()); if (sub_cmd_obj) { - // The subcommand's name includes the parent command's name, - // so restart rather than append to the revised_command_line. + // The subcommand's name includes the parent command's name, so + // restart rather than append to the revised_command_line. llvm::StringRef sub_cmd_name = sub_cmd_obj->GetCommandName(); actual_cmd_name_len = sub_cmd_name.size() + 1; revised_command_line.Clear(); @@ -3102,8 +3096,8 @@ std::string cmd = revised_command_line.GetString(); size_t arg_terminator_idx = FindArgumentTerminator(cmd); if (arg_terminator_idx != std::string::npos) { - // Insert the gdb format option before the "--" that terminates - // options + // Insert the gdb format option before the "--" that + // terminates options gdb_format_option.append(1, ' '); cmd.insert(arg_terminator_idx, gdb_format_option); revised_command_line.Clear(); Index: source/Interpreter/CommandObject.cpp =================================================================== --- source/Interpreter/CommandObject.cpp +++ source/Interpreter/CommandObject.cpp @@ -20,8 +20,8 @@ #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ArchSpec.h" -// These are for the Sourcename completers. -// FIXME: Make a separate file for the completers. +// These are for the Sourcename completers. FIXME: Make a separate file +// for the completers. #include "lldb/Core/FileSpecList.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Target/Process.h" @@ -138,11 +138,11 @@ bool CommandObject::CheckRequirements(CommandReturnObject &result) { #ifdef LLDB_CONFIGURATION_DEBUG - // Nothing should be stored in m_exe_ctx between running commands as m_exe_ctx - // has shared pointers to the target, process, thread and frame and we don't - // want any CommandObject instances to keep any of these objects around - // longer than for a single command. Every command should call - // CommandObject::Cleanup() after it has completed + // Nothing should be stored in m_exe_ctx between running commands as + // m_exe_ctx has shared pointers to the target, process, thread and + // frame and we don't want any CommandObject instances to keep any of + // these objects around longer than for a single command. Every command + // should call CommandObject::Cleanup() after it has completed assert(m_exe_ctx.GetTargetPtr() == NULL); assert(m_exe_ctx.GetProcessPtr() == NULL); assert(m_exe_ctx.GetThreadPtr() == NULL); @@ -150,8 +150,8 @@ #endif // Lock down the interpreter's execution context prior to running the - // command so we guarantee the selected target, process, thread and frame - // can't go away during the execution + // command so we guarantee the selected target, process, thread and + // frame can't go away during the execution m_exe_ctx = m_interpreter.GetExecutionContext(); const uint32_t flags = GetFlags().Get(); @@ -265,10 +265,10 @@ int match_start_point, int max_return_elements, bool &word_complete, StringList &matches) { - // Default implementation of WantsCompletion() is !WantsRawCommandString(). - // Subclasses who want raw command string but desire, for example, - // argument completion should override WantsCompletion() to return true, - // instead. + // Default implementation of WantsCompletion() is + // !WantsRawCommandString(). Subclasses who want raw command string but + // desire, for example, argument completion should override + // WantsCompletion() to return true, instead. if (WantsRawCommandString() && !WantsCompletion()) { // FIXME: Abstract telling the completion to insert the completion // character. @@ -292,7 +292,8 @@ return matches.GetSize(); } - // If we got here, the last word is not an option or an option argument. + // If we got here, the last word is not an option or an option + // argument. return HandleArgumentCompletion( input, cursor_index, cursor_char_position, opt_element_vector, match_start_point, max_return_elements, word_complete, matches); @@ -360,8 +361,8 @@ const ArgumentTableEntry *table = CommandObject::GetArgumentTable(); const ArgumentTableEntry *entry = &(table[arg_type]); - // The table is *supposed* to be kept in arg_type order, but someone *could* - // have messed it up... + // The table is *supposed* to be kept in arg_type order, but someone + // *could* have messed it up... if (entry->arg_type != arg_type) entry = CommandObject::FindArgumentDataByType(arg_type); @@ -390,8 +391,8 @@ const ArgumentTableEntry *entry = &(CommandObject::GetArgumentTable()[arg_type]); - // The table is *supposed* to be kept in arg_type order, but someone *could* - // have messed it up... + // The table is *supposed* to be kept in arg_type order, but someone + // *could* have messed it up... if (entry->arg_type != arg_type) entry = CommandObject::FindArgumentDataByType(arg_type); @@ -424,9 +425,10 @@ return ret_val; } -// Default parameter value of opt_set_mask is LLDB_OPT_SET_ALL, which means take -// all the argument data into account. On rare cases where some argument sticks -// with certain option sets, this function returns the option set filtered args. +// Default parameter value of opt_set_mask is LLDB_OPT_SET_ALL, which +// means take all the argument data into account. On rare cases where +// some argument sticks with certain option sets, this function returns +// the option set filtered args. void CommandObject::GetFormattedCommandArguments(Stream &str, uint32_t opt_set_mask) { int num_args = m_arguments.size(); @@ -465,16 +467,15 @@ str.Printf("[<%s_1> <%s_1> ... <%s_n> <%s_n>]", first_name, second_name, first_name, second_name); break; - // Explicitly test for all the rest of the cases, so if new types get - // added we will notice the - // missing case statement(s). + // Explicitly test for all the rest of the cases, so if new types + // get added we will notice the missing case statement(s). case eArgRepeatPlain: case eArgRepeatOptional: case eArgRepeatPlus: case eArgRepeatStar: case eArgRepeatRange: - // These should not be reached, as they should fail the IsPairType test - // above. + // These should not be reached, as they should fail the IsPairType + // test above. break; } } else { @@ -502,18 +503,17 @@ case eArgRepeatRange: str.Printf("<%s_1> .. <%s_n>", name_str.c_str(), name_str.c_str()); break; - // Explicitly test for all the rest of the cases, so if new types get - // added we will notice the - // missing case statement(s). + // Explicitly test for all the rest of the cases, so if new types + // get added we will notice the missing case statement(s). case eArgRepeatPairPlain: case eArgRepeatPairOptional: case eArgRepeatPairPlus: case eArgRepeatPairStar: case eArgRepeatPairRange: case eArgRepeatPairRangeOptional: - // These should not be hit, as they should pass the IsPairType test - // above, and control should - // have gone into the other branch of the if statement. + // These should not be hit, as they should pass the IsPairType + // test above, and control should have gone into the other branch + // of the if statement. break; } } @@ -856,10 +856,9 @@ } if (!IsDashDashCommand() && options && options->NumCommandOptions() > 0) { if (WantsRawCommandString() && !WantsCompletion()) { - // Emit the message about using ' -- ' between the end of the command - // options and the raw input - // conditionally, i.e., only if the command object does not want - // completion. + // Emit the message about using ' -- ' between the end of the + // command options and the raw input conditionally, i.e., only if + // the command object does not want completion. interpreter.OutputFormattedHelpText( output_strm, "", "", "\nImportant Note: Because this command takes 'raw' input, if you " @@ -868,8 +867,8 @@ "beginning of the raw input.", 1); } else if (GetNumArgumentEntries() > 0) { - // Also emit a warning about using "--" in case you are using a command - // that takes options and arguments. + // Also emit a warning about using "--" in case you are using a + // command that takes options and arguments. interpreter.OutputFormattedHelpText( output_strm, "", "", "\nThis command takes options and free-form arguments. If your " @@ -898,9 +897,9 @@ id_range_arg.arg_type = IDRange; id_range_arg.arg_repetition = eArgRepeatOptional; - // The first (and only) argument for this command could be either an id or an - // id_range. - // Push both variants into the entry for the first argument for this command. + // The first (and only) argument for this command could be either an id + // or an id_range. Push both variants into the entry for the first + // argument for this command. arg.push_back(id_arg); arg.push_back(id_range_arg); } Index: source/Interpreter/CommandObjectRegexCommand.cpp =================================================================== --- source/Interpreter/CommandObjectRegexCommand.cpp +++ source/Interpreter/CommandObjectRegexCommand.cpp @@ -62,9 +62,9 @@ // Interpret the new command and return this as the result! if (m_interpreter.GetExpandRegexAliases()) result.GetOutputStream().Printf("%s\n", new_command.c_str()); - // Pass in true for "no context switching". The command that called us - // should have set up the context - // appropriately, we shouldn't have to redo that. + // Pass in true for "no context switching". The command that + // called us should have set up the context appropriately, we + // shouldn't have to redo that. return m_interpreter.HandleCommand(new_command.c_str(), eLazyBoolCalculate, result, nullptr, true, true); Index: source/Interpreter/CommandObjectScript.cpp =================================================================== --- source/Interpreter/CommandObjectScript.cpp +++ source/Interpreter/CommandObjectScript.cpp @@ -43,8 +43,8 @@ bool CommandObjectScript::DoExecute(const char *command, CommandReturnObject &result) { #ifdef LLDB_DISABLE_PYTHON - // if we ever support languages other than Python this simple #ifdef won't - // work + // if we ever support languages other than Python this simple #ifdef + // won't work result.AppendError("your copy of LLDB does not support scripting."); result.SetStatus(eReturnStatusFailed); return false; @@ -66,8 +66,8 @@ } DataVisualization::ForceUpdate(); // script might change Python code we use - // for formatting.. make sure we keep up to - // date with it + // for formatting.. make sure we keep + // up to date with it if (command == nullptr || command[0] == '\0') { script_interpreter->ExecuteInterpreterLoop(); @@ -75,7 +75,8 @@ return result.Succeeded(); } - // We can do better when reporting the status of one-liner script execution. + // We can do better when reporting the status of one-liner script + // execution. if (script_interpreter->ExecuteOneLine(command, &result)) result.SetStatus(eReturnStatusSuccessFinishNoResult); else Index: source/Interpreter/CommandReturnObject.cpp =================================================================== --- source/Interpreter/CommandReturnObject.cpp +++ source/Interpreter/CommandReturnObject.cpp @@ -25,8 +25,8 @@ if (s.empty()) { add_newline = add_newline_if_empty; } else { - // We already checked for empty above, now make sure there is a newline - // in the error, and if there isn't one, add one. + // We already checked for empty above, now make sure there is a + // newline in the error, and if there isn't one, add one. strm.Write(s.c_str(), s.size()); const char last_char = *s.rbegin(); @@ -96,8 +96,8 @@ GetErrorStream() << "warning: " << in_string << "\n"; } -// Similar to AppendWarning, but do not prepend 'warning: ' to message, and -// don't append "\n" to the end of it. +// Similar to AppendWarning, but do not prepend 'warning: ' to message, +// and don't append "\n" to the end of it. void CommandReturnObject::AppendRawWarning(llvm::StringRef in_string) { if (in_string.empty()) Index: source/Interpreter/OptionArgParser.cpp =================================================================== --- source/Interpreter/OptionArgParser.cpp +++ source/Interpreter/OptionArgParser.cpp @@ -206,8 +206,8 @@ } else { // Since the compiler can't handle things like "main + 12" we should - // try to do this for now. The compiler doesn't like adding offsets - // to function pointer types. + // try to do this for now. The compiler doesn't like adding offsets to + // function pointer types. static RegularExpression g_symbol_plus_offset_regex( "^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$"); RegularExpression::Match regex_match(3); Index: source/Interpreter/OptionGroupBoolean.cpp =================================================================== --- source/Interpreter/OptionGroupBoolean.cpp +++ source/Interpreter/OptionGroupBoolean.cpp @@ -45,8 +45,8 @@ ExecutionContext *execution_context) { Status error; if (m_option_definition.option_has_arg == OptionParser::eNoArgument) { - // Not argument, toggle the default value and mark the option as having been - // set + // Not argument, toggle the default value and mark the option as + // having been set m_value.SetCurrentValue(!m_value.GetDefaultValue()); m_value.SetOptionWasSet(); } else { Index: source/Interpreter/OptionGroupFormat.cpp =================================================================== --- source/Interpreter/OptionGroupFormat.cpp +++ source/Interpreter/OptionGroupFormat.cpp @@ -100,10 +100,10 @@ gdb_format_str = gdb_format_str.drop_front(); } - // We the first character of the "gdb_format_str" is not the - // NULL terminator, we didn't consume the entire string and - // something is wrong. Also, if none of the format, size or count - // was specified correctly, then abort. + // We the first character of the "gdb_format_str" is not the NULL + // terminator, we didn't consume the entire string and something is + // wrong. Also, if none of the format, size or count was specified + // correctly, then abort. if (!gdb_format_str.empty() || (format == eFormatInvalid && byte_size == 0 && count == 0)) { // Nothing got set correctly @@ -113,8 +113,8 @@ } // At least one of the format, size or count was set correctly. - // Anything that wasn't set correctly should be set to the - // previous default + // Anything that wasn't set correctly should be set to the previous + // default if (format == eFormatInvalid) ParserGDBFormatLetter(execution_context, m_prev_gdb_format, format, byte_size); @@ -127,9 +127,9 @@ ParserGDBFormatLetter(execution_context, m_prev_gdb_size, format, byte_size); } else { - // Byte size is disabled, make sure it wasn't specified - // but if this is an address, it's actually necessary to - // specify one so don't error out + // Byte size is disabled, make sure it wasn't specified but if this + // is an address, it's actually necessary to specify one so don't + // error out if (byte_size > 0 && format != lldb::eFormatAddressInfo) { error.SetErrorString( "this command doesn't support specifying a byte size"); @@ -138,8 +138,8 @@ } if (count_enabled) { - // Count is enabled and was not set, set it to the default for gdb format - // statements (which is 1). + // Count is enabled and was not set, set it to the default for gdb + // format statements (which is 1). if (count == 0) count = 1; } else { @@ -235,11 +235,10 @@ case 'w': case 'g': { - // Size isn't used for printing instructions, so if a size is specified, and - // the previous format was - // 'i', then we should reset it to the default ('x'). Otherwise we'll - // continue to print as instructions, - // which isn't expected. + // Size isn't used for printing instructions, so if a size is + // specified, and the previous format was 'i', then we should reset + // it to the default ('x'). Otherwise we'll continue to print as + // instructions, which isn't expected. if (format_letter == 'b') byte_size = 1; else if (format_letter == 'h') Index: source/Interpreter/OptionGroupValueObjectDisplay.cpp =================================================================== --- source/Interpreter/OptionGroupValueObjectDisplay.cpp +++ source/Interpreter/OptionGroupValueObjectDisplay.cpp @@ -187,7 +187,8 @@ if (target_sp) use_dynamic = target_sp->GetPreferDynamicValue(); else { - // If we don't have any targets, then dynamic values won't do us much good. + // If we don't have any targets, then dynamic values won't do us much + // good. use_dynamic = lldb::eNoDynamicValues; } } Index: source/Interpreter/OptionGroupVariable.cpp =================================================================== --- source/Interpreter/OptionGroupVariable.cpp +++ source/Interpreter/OptionGroupVariable.cpp @@ -132,12 +132,12 @@ llvm::ArrayRef OptionGroupVariable::GetDefinitions() { auto result = llvm::makeArrayRef(g_variable_options); - // Show the "--no-args", "--no-locals" and "--show-globals" - // options if we are showing frame specific options + // Show the "--no-args", "--no-locals" and "--show-globals" options if + // we are showing frame specific options if (include_frame_options) return result; - // Skip the "--no-args", "--no-locals" and "--show-globals" - // options if we are not showing frame specific options (globals only) + // Skip the "--no-args", "--no-locals" and "--show-globals" options if + // we are not showing frame specific options (globals only) return result.drop_front(NUM_FRAME_OPTS); } Index: source/Interpreter/OptionValue.cpp =================================================================== --- source/Interpreter/OptionValue.cpp +++ source/Interpreter/OptionValue.cpp @@ -21,8 +21,7 @@ //------------------------------------------------------------------------- // Get this value as a uint64_t value if it is encoded as a boolean, -// uint64_t or int64_t. Other types will cause "fail_value" to be -// returned +// uint64_t or int64_t. Other types will cause "fail_value" to be returned //------------------------------------------------------------------------- uint64_t OptionValue::GetUInt64Value(uint64_t fail_value, bool *success_ptr) { if (success_ptr) @@ -508,8 +507,8 @@ lldb::OptionValueSP OptionValue::CreateValueFromCStringForTypeMask( const char *value_cstr, uint32_t type_mask, Status &error) { - // If only 1 bit is set in the type mask for a dictionary or array - // then we know how to decode a value from a cstring + // If only 1 bit is set in the type mask for a dictionary or array then + // we know how to decode a value from a cstring lldb::OptionValueSP value_sp; switch (type_mask) { case 1u << eTypeArch: Index: source/Interpreter/OptionValueDictionary.cpp =================================================================== --- source/Interpreter/OptionValueDictionary.cpp +++ source/Interpreter/OptionValueDictionary.cpp @@ -128,9 +128,7 @@ if (key.front() == '[') { // Key name starts with '[', so the key value must be in single or - // double quotes like: - // [''] - // [""] + // double quotes like: [''] [""] if ((key.size() > 2) && (key.back() == ']')) { // Strip leading '[' and trailing ']' key = key.substr(1, key.size() - 2); @@ -286,8 +284,8 @@ bool OptionValueDictionary::SetValueForKey(const ConstString &key, const lldb::OptionValueSP &value_sp, bool can_replace) { - // Make sure the value_sp object is allowed to contain - // values of the type passed in... + // Make sure the value_sp object is allowed to contain values of the + // type passed in... if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) { if (!can_replace) { collection::const_iterator pos = m_values.find(key); Index: source/Interpreter/OptionValueFileSpec.cpp =================================================================== --- source/Interpreter/OptionValueFileSpec.cpp +++ source/Interpreter/OptionValueFileSpec.cpp @@ -66,16 +66,13 @@ case eVarSetOperationReplace: case eVarSetOperationAssign: if (value.size() > 0) { - // The setting value may have whitespace, double-quotes, or single-quotes - // around the file - // path to indicate that internal spaces are not word breaks. Strip off - // any ws & quotes - // from the start and end of the file path - we aren't doing any word // - // breaking here so - // the quoting is unnecessary. NB this will cause a problem if someone - // tries to specify - // a file path that legitimately begins or ends with a " or ' character, - // or whitespace. + // The setting value may have whitespace, double-quotes, or single- + // quotes around the file path to indicate that internal spaces are + // not word breaks. Strip off any ws & quotes from the start and + // end of the file path - we aren't doing any word // breaking here + // so the quoting is unnecessary. NB this will cause a problem if + // someone tries to specify a file path that legitimately begins or + // ends with a " or ' character, or whitespace. value = value.trim("\"' \t"); m_value_was_set = true; m_current_value.SetFile(value.str(), m_resolve); Index: source/Interpreter/OptionValueFormatEntity.cpp =================================================================== --- source/Interpreter/OptionValueFormatEntity.cpp +++ source/Interpreter/OptionValueFormatEntity.cpp @@ -63,13 +63,11 @@ case eVarSetOperationReplace: case eVarSetOperationAssign: { - // Check if the string starts with a quote character after removing leading - // and trailing spaces. - // If it does start with a quote character, make sure it ends with the same - // quote character - // and remove the quotes before we parse the format string. If the string - // doesn't start with - // a quote, leave the string alone and parse as is. + // Check if the string starts with a quote character after removing + // leading and trailing spaces. If it does start with a quote + // character, make sure it ends with the same quote character and + // remove the quotes before we parse the format string. If the string + // doesn't start with a quote, leave the string alone and parse as is. llvm::StringRef trimmed_value_str = value_str.trim(); if (!trimmed_value_str.empty()) { const char first_char = trimmed_value_str[0]; Index: source/Interpreter/OptionValuePathMappings.cpp =================================================================== --- source/Interpreter/OptionValuePathMappings.cpp +++ source/Interpreter/OptionValuePathMappings.cpp @@ -53,8 +53,8 @@ break; case eVarSetOperationReplace: - // Must be at least one index + 1 pair of paths, and the pair count must be - // even + // Must be at least one index + 1 pair of paths, and the pair count + // must be even if (argc >= 3 && (((argc - 1) & 1) == 0)) { uint32_t idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX); @@ -125,8 +125,8 @@ case eVarSetOperationInsertBefore: case eVarSetOperationInsertAfter: - // Must be at least one index + 1 pair of paths, and the pair count must be - // even + // Must be at least one index + 1 pair of paths, and the pair count + // must be even if (argc >= 3 && (((argc - 1) & 1) == 0)) { uint32_t idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), UINT32_MAX); Index: source/Interpreter/OptionValueProperties.cpp =================================================================== --- source/Interpreter/OptionValueProperties.cpp +++ source/Interpreter/OptionValueProperties.cpp @@ -35,15 +35,13 @@ m_name(global_properties.m_name), m_properties(global_properties.m_properties), m_name_to_index(global_properties.m_name_to_index) { - // We now have an exact copy of "global_properties". We need to now - // find all non-global settings and copy the property values so that - // all non-global settings get new OptionValue instances created for - // them. + // We now have an exact copy of "global_properties". We need to now find + // all non-global settings and copy the property values so that all non- + // global settings get new OptionValue instances created for them. const size_t num_properties = m_properties.size(); for (size_t i = 0; i < num_properties; ++i) { - // Duplicate any values that are not global when constructing properties - // from - // a global copy + // Duplicate any values that are not global when constructing + // properties from a global copy if (m_properties[i].IsGlobal() == false) { lldb::OptionValueSP new_value_sp(m_properties[i].GetValue()->DeepCopy()); m_properties[i].SetOptionValue(new_value_sp); @@ -157,15 +155,14 @@ case '{': // Predicate matching for predicates like // "{}" - // strings are parsed by the current OptionValueProperties subclass - // to mean whatever they want to. For instance a subclass of + // strings are parsed by the current OptionValueProperties subclass to + // mean whatever they want to. For instance a subclass of // OptionValueProperties for a lldb_private::Target might implement: // "target.run-args{arch==i386}" -- only set run args if the arch is - // i386 - // "target.run-args{path=/tmp/a/b/c/a.out}" -- only set run args if the - // path matches - // "target.run-args{basename==test&&arch==x86_64}" -- only set run args - // if executable basename is "test" and arch is "x86_64" + // i386 "target.run-args{path=/tmp/a/b/c/a.out}" -- only set run args + // if the path matches "target.run-args{basename==test&&arch==x86_64}" + // -- only set run args if executable basename is "test" and arch is + // "x86_64" if (sub_name[1]) { llvm::StringRef predicate_start = sub_name.drop_front(); size_t pos = predicate_start.find_first_of('}'); @@ -189,9 +186,9 @@ break; case '[': - // Array or dictionary access for subvalues like: - // "[12]" -- access 12th array element - // "['hello']" -- dictionary access of key named hello + // Array or dictionary access for subvalues like: "[12]" -- + // access 12th array element "['hello']" -- dictionary access of key + // named hello return value_sp->GetSubValue(exe_ctx, sub_name, will_modify, error); default: Index: source/Interpreter/OptionValueSInt64.cpp =================================================================== --- source/Interpreter/OptionValueSInt64.cpp +++ source/Interpreter/OptionValueSInt64.cpp @@ -21,8 +21,8 @@ void OptionValueSInt64::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) { - // printf ("%p: DumpValue (exe_ctx=%p, strm, mask) m_current_value = %" PRIi64 - // "\n", this, exe_ctx, m_current_value); + // printf ("%p: DumpValue (exe_ctx=%p, strm, mask) m_current_value = %" + // PRIi64 "\n", this, exe_ctx, m_current_value); if (dump_mask & eDumpOptionType) strm.Printf("(%s)", GetTypeAsCString()); // if (dump_mask & eDumpOptionName) Index: source/Interpreter/Options.cpp =================================================================== --- source/Interpreter/Options.cpp +++ source/Interpreter/Options.cpp @@ -56,8 +56,8 @@ OptionSet::const_iterator pos_a; OptionSet::const_iterator pos_b; - // set_a is a subset of set_b if every member of set_a is also a member of - // set_b + // set_a is a subset of set_b if every member of set_a is also a member + // of set_b for (pos_a = set_a.begin(); pos_a != set_a.end() && is_a_subset; ++pos_a) { pos_b = set_b.find(*pos_a); @@ -68,8 +68,8 @@ return is_a_subset; } -// Returns the set difference set_a - set_b, i.e. { x | ElementOf (x, set_a) && -// !ElementOf (x, set_b) } +// Returns the set difference set_a - set_b, i.e. { x | ElementOf (x, +// set_a) && !ElementOf (x, set_b) } size_t Options::OptionsSetDiff(const OptionSet &set_a, const OptionSet &set_b, OptionSet &diffs) { @@ -88,8 +88,8 @@ return num_diffs; } -// Returns the union of set_a and set_b. Does not put duplicate members into -// the union. +// Returns the union of set_a and set_b. Does not put duplicate members +// into the union. void Options::OptionsSetUnion(const OptionSet &set_a, const OptionSet &set_b, OptionSet &union_set) { @@ -101,7 +101,8 @@ for (pos = set_a.begin(); pos != set_a.end(); ++pos) union_set.insert(*pos); - // Put all the elements of set_b that are not already there into the union. + // Put all the elements of set_b that are not already there into the + // union. for (pos = set_b.begin(); pos != set_b.end(); ++pos) { pos_union = union_set.find(*pos); if (pos_union == union_set.end()) @@ -115,19 +116,18 @@ int num_levels = GetRequiredOptions().size(); if (num_levels) { for (int i = 0; i < num_levels && !options_are_valid; ++i) { - // This is the correct set of options if: 1). m_seen_options contains all - // of m_required_options[i] - // (i.e. all the required options at this level are a subset of - // m_seen_options); AND - // 2). { m_seen_options - m_required_options[i] is a subset of - // m_options_options[i] (i.e. all the rest of - // m_seen_options are in the set of optional options at this level. + // This is the correct set of options if: 1). m_seen_options + // contains all of m_required_options[i] (i.e. all the required + // options at this level are a subset of m_seen_options); AND 2). { + // m_seen_options - m_required_options[i] is a subset of + // m_options_options[i] (i.e. all the rest of m_seen_options are in + // the set of optional options at this level. // Check to see if all of m_required_options[i] are a subset of // m_seen_options if (IsASubset(GetRequiredOptions()[i], m_seen_options)) { - // Construct the set difference: remaining_options = {m_seen_options} - - // {m_required_options[i]} + // Construct the set difference: remaining_options = + // {m_seen_options} - {m_required_options[i]} OptionSet remaining_options; OptionsSetDiff(m_seen_options, GetRequiredOptions()[i], remaining_options); @@ -151,9 +151,8 @@ return options_are_valid; } -// This is called in the Options constructor, though we could call it lazily if -// that ends up being -// a performance problem. +// This is called in the Options constructor, though we could call it +// lazily if that ends up being a performance problem. void Options::BuildValidOptionSets() { // Check to see if we already did this. @@ -264,15 +263,14 @@ return &m_getopt_table.front(); } -// This function takes INDENT, which tells how many spaces to output at the -// front of each line; SPACES, which is -// a string containing 80 spaces; and TEXT, which is the text that is to be -// output. It outputs the text, on -// multiple lines if necessary, to RESULT, with INDENT spaces at the front of -// each line. It breaks lines on spaces, -// tabs or newlines, shortening the line if necessary to not break in the middle -// of a word. It assumes that each -// output line should contain a maximum of OUTPUT_MAX_COLUMNS characters. +// This function takes INDENT, which tells how many spaces to output at +// the front of each line; SPACES, which is a string containing 80 spaces; +// and TEXT, which is the text that is to be output. It outputs the +// text, on multiple lines if necessary, to RESULT, with INDENT spaces at +// the front of each line. It breaks lines on spaces, tabs or newlines, +// shortening the line if necessary to not break in the middle of a word. +// It assumes that each output line should contain a maximum of +// OUTPUT_MAX_COLUMNS characters. void Options::OutputFormattedUsageText(Stream &strm, const OptionDefinition &option_def, @@ -305,8 +303,8 @@ int sub_len; while (end < final_end) { - // Don't start the 'text' on a space, since we're already outputting the - // indentation. + // Don't start the 'text' on a space, since we're already outputting + // the indentation. while ((start < final_end) && (actual_text[start] == ' ')) start++; @@ -314,8 +312,8 @@ if (end > final_end) end = final_end; else { - // If we're not at the end of the text, make sure we break the line on - // white space. + // If we're not at the end of the text, make sure we break the + // line on white space. while (end > start && actual_text[end] != ' ' && actual_text[end] != '\t' && actual_text[end] != '\n') end--; @@ -421,8 +419,8 @@ strm.IndentMore(2); - // First, show each usage level set of options, e.g. - // [options-for-level-0] + // First, show each usage level set of options, e.g. [options-for- + // level-0] // // [options-for-level-1] // etc. @@ -450,8 +448,8 @@ cmd->GetFormattedCommandArguments(args_str, opt_set_mask); // First go through and print all options that take no arguments as - // a single string. If a command has "-a" "-b" and "-c", this will show - // up as [-abc] + // a single string. If a command has "-a" "-b" and "-c", this will + // show up as [-abc] std::set options; std::set::const_iterator options_pos, options_end; @@ -506,7 +504,8 @@ strm.PutChar(']'); } - // First go through and print the required options (list them up front). + // First go through and print the required options (list them up + // front). for (auto &def : opt_defs) { if (def.usage_mask & opt_set_mask && isprint8(def.short_option)) { @@ -515,7 +514,8 @@ } } - // Now go through again, and this time only print the optional options. + // Now go through again, and this time only print the optional + // options. for (auto &def : opt_defs) { if (def.usage_mask & opt_set_mask) { @@ -548,30 +548,30 @@ strm.Printf("\n\n"); if (!only_print_args) { - // Now print out all the detailed information about the various options: - // long form, short form and help text: + // Now print out all the detailed information about the various + // options: long form, short form and help text: // -short ( --long_name ) // help text - // This variable is used to keep track of which options' info we've printed - // out, because some options can be in - // more than one usage level, but we only want to print the long form of its - // information once. + // This variable is used to keep track of which options' info we've + // printed out, because some options can be in more than one usage + // level, but we only want to print the long form of its information + // once. std::multimap options_seen; strm.IndentMore(5); - // Put the unique command options in a vector & sort it, so we can output - // them alphabetically (by short_option) - // when writing out detailed help for each option. + // Put the unique command options in a vector & sort it, so we can + // output them alphabetically (by short_option) when writing out + // detailed help for each option. i = 0; for (auto &def : opt_defs) options_seen.insert(std::make_pair(def.short_option, i++)); - // Go through the unique'd and alphabetically sorted vector of options, find - // the table entry for each option - // and write out the detailed help information for that option. + // Go through the unique'd and alphabetically sorted vector of + // options, find the table entry for each option and write out the + // detailed help information for that option. bool first_option_printed = false; @@ -626,15 +626,12 @@ strm.SetIndentLevel(save_indent_level); } -// This function is called when we have been given a potentially incomplete set -// of -// options, such as when an alias has been defined (more options might be added -// at -// at the time the alias is invoked). We need to verify that the options in the -// set -// m_seen_options are all part of a set that may be used together, but -// m_seen_options -// may be missing some of the "required" options. +// This function is called when we have been given a potentially +// incomplete set of options, such as when an alias has been defined (more +// options might be added at at the time the alias is invoked). We need +// to verify that the options in the set m_seen_options are all part of a +// set that may be used together, but m_seen_options may be missing some +// of the "required" options. bool Options::VerifyPartialOptions(CommandReturnObject &result) { bool options_are_valid = false; @@ -643,10 +640,9 @@ if (num_levels) { for (int i = 0; i < num_levels && !options_are_valid; ++i) { // In this case we are treating all options as optional rather than - // required. - // Therefore a set of options is correct if m_seen_options is a subset of - // the - // union of m_required_options and m_optional_options. + // required. Therefore a set of options is correct if m_seen_options + // is a subset of the union of m_required_options and + // m_optional_options. OptionSet union_set; OptionsSetUnion(GetRequiredOptions()[i], GetOptionalOptions()[i], union_set); @@ -665,9 +661,10 @@ lldb_private::StringList &matches) { word_complete = true; - // For now we just scan the completions to see if the cursor position is in - // an option or its argument. Otherwise we'll call HandleArgumentCompletion. - // In the future we can use completion to validate options as well if we want. + // For now we just scan the completions to see if the cursor position is + // in an option or its argument. Otherwise we'll call + // HandleArgumentCompletion. In the future we can use completion to + // validate options as well if we want. auto opt_defs = GetDefinitions(); @@ -684,9 +681,8 @@ if (opt_defs_index == OptionArgElement::eBareDash) { // We're completing a bare dash. That means all options are open. - // FIXME: We should scan the other options provided and only complete - // options - // within the option group they belong to. + // FIXME: We should scan the other options provided and only + // complete options within the option group they belong to. char opt_str[3] = {'-', 'a', '\0'}; for (auto &def : opt_defs) { @@ -709,12 +705,11 @@ } return true; } else if (opt_defs_index != OptionArgElement::eUnrecognizedArg) { - // We recognized it, if it an incomplete long option, complete it anyway - // (getopt_long_only is - // happy with shortest unique string, but it's still a nice thing to - // do.) Otherwise return - // The string so the upper level code will know this is a full match and - // add the " ". + // We recognized it, if it an incomplete long option, complete it + // anyway (getopt_long_only is happy with shortest unique string, + // but it's still a nice thing to do.) Otherwise return The + // string so the upper level code will know this is a full match + // and add the " ". if (cur_opt_str && strlen(cur_opt_str) > 2 && cur_opt_str[0] == '-' && cur_opt_str[1] == '-' && strcmp(opt_defs[opt_defs_index].long_option, cur_opt_str) != 0) { @@ -728,12 +723,11 @@ } } else { // FIXME - not handling wrong options yet: - // Check to see if they are writing a long option & complete it. - // I think we will only get in here if the long option table has two - // elements - // that are not unique up to this point. getopt_long_only does shortest - // unique match - // for long options already. + // Check to see if they are writing a long option & complete it. I + // think we will only get in here if the long option table has two + // elements that are not unique up to this point. + // getopt_long_only does shortest unique match for long options + // already. if (cur_opt_str && strlen(cur_opt_str) > 2 && cur_opt_str[0] == '-' && cur_opt_str[1] == '-') { @@ -744,8 +738,9 @@ if (strstr(def.long_option, cur_opt_str + 2) == def.long_option) { std::string full_name("--"); full_name.append(def.long_option); - // The options definitions table has duplicates because of the - // way the grouping information is stored, so only add once. + // The options definitions table has duplicates because of + // the way the grouping information is stored, so only add + // once. bool duplicate = false; for (size_t k = 0; k < matches.GetSize(); k++) { if (matches.GetStringAtIndex(k) == full_name) { @@ -762,8 +757,8 @@ } } else if (opt_arg_pos == cursor_index) { - // Okay the cursor is on the completion of an argument. - // See if it has a completion, otherwise return no matches. + // Okay the cursor is on the completion of an argument. See if it + // has a completion, otherwise return no matches. if (opt_defs_index != -1) { HandleOptionArgumentCompletion( @@ -796,7 +791,8 @@ int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos; int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index; - // See if this is an enumeration type option, and if so complete it here: + // See if this is an enumeration type option, and if so complete it + // here: OptionEnumValueElement *enum_values = opt_defs[opt_defs_index].enum_values; if (enum_values != nullptr) { @@ -815,10 +811,8 @@ // If this is a source file or symbol type completion, and there is a // -shlib option somewhere in the supplied arguments, then make a search - // filter - // for that shared library. - // FIXME: Do we want to also have an "OptionType" so we don't have to match - // string names? + // filter for that shared library. FIXME: Do we want to also have an + // "OptionType" so we don't have to match string names? uint32_t completion_mask = opt_defs[opt_defs_index].completion_type; @@ -908,8 +902,8 @@ Status OptionGroupOptions::SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) { - // After calling OptionGroupOptions::Append(...), you must finalize the groups - // by calling OptionGroupOptions::Finlize() + // After calling OptionGroupOptions::Append(...), you must finalize the + // groups by calling OptionGroupOptions::Finlize() assert(m_did_finalize); Status error; if (option_idx < m_option_infos.size()) { @@ -952,20 +946,22 @@ return error; } -// OptionParser permutes the arguments while processing them, so we create a -// temporary array holding to avoid modification of the input arguments. The -// options themselves are never modified, but the API expects a char * anyway, -// hence the const_cast. +// OptionParser permutes the arguments while processing them, so we create +// a temporary array holding to avoid modification of the input arguments. +// The options themselves are never modified, but the API expects a char * +// anyway, hence the const_cast. static std::vector GetArgvForParsing(const Args &args) { std::vector result; - // OptionParser always skips the first argument as it is based on getopt(). + // OptionParser always skips the first argument as it is based on + // getopt(). result.push_back(const_cast("")); for (const Args::ArgEntry &entry : args) result.push_back(const_cast(entry.c_str())); return result; } -// Given a permuted argument, find it's position in the original Args vector. +// Given a permuted argument, find it's position in the original Args +// vector. static Args::const_iterator FindOriginalIter(const char *arg, const Args &original) { return llvm::find_if( @@ -977,8 +973,8 @@ return std::distance(original.begin(), FindOriginalIter(arg, original)); } -// Construct a new Args object, consisting of the entries from the original -// arguments, but in the permuted order. +// Construct a new Args object, consisting of the entries from the +// original arguments, but in the permuted order. static Args ReconstituteArgsAfterParsing(llvm::ArrayRef parsed, const Args &original) { Args result; @@ -1111,10 +1107,10 @@ option_arg_vector->emplace_back(option_str.GetString(), has_arg, option_arg); - // Find option in the argument list; also see if it was supposed to take - // an argument and if one was supplied. Remove option (and argument, if - // given) from the argument list. Also remove them from the - // raw_input_string, if one was passed in. + // Find option in the argument list; also see if it was supposed to + // take an argument and if one was supplied. Remove option (and + // argument, if given) from the argument list. Also remove them from + // the raw_input_string, if one was passed in. size_t idx = FindArgumentIndexForOption(args_copy, long_options[long_options_index]); if (idx == size_t(-1)) @@ -1155,8 +1151,8 @@ if (long_options == nullptr) return option_element_vector; - // Leading : tells getopt to return a : for a missing option argument AND - // to suppress error messages. + // Leading : tells getopt to return a : for a missing option argument + // AND to suppress error messages. sstr << ":"; for (int i = 0; long_options[i].definition != nullptr; ++i) { @@ -1185,8 +1181,9 @@ std::vector dummy_vec = GetArgvForParsing(args); - // I stick an element on the end of the input, because if the last element - // is option that requires an argument, getopt_long_only will freak out. + // I stick an element on the end of the input, because if the last + // element is option that requires an argument, getopt_long_only will + // freak out. dummy_vec.push_back(const_cast("")); bool failed_once = false; @@ -1207,16 +1204,16 @@ failed_once = true; // If this is a bare "--" we mark it as such so we can complete it - // successfully later. Handling the "--" is a little tricky, since that - // may mean end of options or arguments, or the user might want to - // complete options by long name. I make this work by checking whether - // the cursor is in the "--" argument, and if so I assume we're - // completing the long option, otherwise I let it pass to - // OptionParser::Parse which will terminate the option parsing. Note, in - // either case we continue parsing the line so we can figure out what - // other options were passed. This will be useful when we come to - // restricting completions based on what other options we've seen on the - // line. + // successfully later. Handling the "--" is a little tricky, since + // that may mean end of options or arguments, or the user might want + // to complete options by long name. I make this work by checking + // whether the cursor is in the "--" argument, and if so I assume + // we're completing the long option, otherwise I let it pass to + // OptionParser::Parse which will terminate the option parsing. + // Note, in either case we continue parsing the line so we can + // figure out what other options were passed. This will be useful + // when we come to restricting completions based on what other + // options we've seen on the line. if (static_cast(OptionParser::GetOptionIndex()) < dummy_vec.size() && @@ -1339,11 +1336,10 @@ } // Finally we have to handle the case where the cursor index points at a - // single "-". We want to mark that in - // the option_element_vector, but only if it is not after the "--". But it - // turns out that OptionParser::Parse just ignores - // an isolated "-". So we have to look it up by hand here. We only care if - // it is AT the cursor position. + // single "-". We want to mark that in the option_element_vector, but + // only if it is not after the "--". But it turns out that + // OptionParser::Parse just ignores an isolated "-". So we have to look + // it up by hand here. We only care if it is AT the cursor position. // Note, a single quoted dash is not the same as a single dash... const Args::ArgEntry &cursor = args[cursor_index]; @@ -1426,8 +1422,8 @@ const OptionDefinition *def = long_options[long_options_index].definition; if (!platform_sp) { - // User did not pass in an explicit platform. Try to grab - // from the execution context. + // User did not pass in an explicit platform. Try to grab from + // the execution context. TargetSP target_sp = execution_context ? execution_context->GetTargetSP() : TargetSP(); platform_sp = target_sp ? target_sp->GetPlatform() : PlatformSP(); @@ -1435,9 +1431,8 @@ OptionValidator *validator = def->validator; if (!platform_sp && require_validation) { - // Caller requires validation but we cannot validate as we - // don't have the mandatory platform against which to - // validate. + // Caller requires validation but we cannot validate as we don't + // have the mandatory platform against which to validate. return llvm::make_error( "cannot validate options: no platform available", llvm::inconvertibleErrorCode()); Index: source/Interpreter/Property.cpp =================================================================== --- source/Interpreter/Property.cpp +++ source/Interpreter/Property.cpp @@ -32,8 +32,8 @@ break; case OptionValue::eTypeArch: // "definition.default_uint_value" is not used - // "definition.default_cstr_value" as a string value that represents the - // default string value for the architecture/triple + // "definition.default_cstr_value" as a string value that represents + // the default string value for the architecture/triple m_value_sp.reset(new OptionValueArch(definition.default_cstr_value)); break; @@ -51,8 +51,8 @@ case OptionValue::eTypeBoolean: // "definition.default_uint_value" is the default boolean value if // "definition.default_cstr_value" is NULL, otherwise interpret - // "definition.default_cstr_value" as a string value that represents the - // default value. + // "definition.default_cstr_value" as a string value that represents + // the default value. if (definition.default_cstr_value) m_value_sp.reset(new OptionValueBoolean(OptionArgParser::ToBoolean( llvm::StringRef(definition.default_cstr_value), false, nullptr))); @@ -76,9 +76,8 @@ case OptionValue::eTypeEnum: // "definition.default_uint_value" is the default enumeration value if // "definition.default_cstr_value" is NULL, otherwise interpret - // "definition.default_cstr_value" as a string value that represents the - // default - // value. + // "definition.default_cstr_value" as a string value that represents + // the default value. { OptionValueEnumeration *enum_value = new OptionValueEnumeration( definition.enum_values, definition.default_uint_value); @@ -91,8 +90,8 @@ enum_value->SetDefaultValue(enum_value->GetCurrentValue()); // Call Clear() since we don't want the value to appear as // having been set since we called SetValueFromString() above. - // Clear will set the current value to the default and clear - // the boolean that says that the value has been set. + // Clear will set the current value to the default and clear the + // boolean that says that the value has been set. enum_value->Clear(); } } @@ -101,8 +100,7 @@ case OptionValue::eTypeFileSpec: { // "definition.default_uint_value" represents if the - // "definition.default_cstr_value" should - // be resolved or not + // "definition.default_cstr_value" should be resolved or not const bool resolve = definition.default_uint_value != 0; m_value_sp.reset(new OptionValueFileSpec( FileSpec(definition.default_cstr_value, resolve), resolve)); @@ -116,12 +114,10 @@ break; case OptionValue::eTypeFormat: - // "definition.default_uint_value" is the default format enumeration value - // if - // "definition.default_cstr_value" is NULL, otherwise interpret - // "definition.default_cstr_value" as a string value that represents the - // default - // value. + // "definition.default_uint_value" is the default format enumeration + // value if "definition.default_cstr_value" is NULL, otherwise + // interpret "definition.default_cstr_value" as a string value that + // represents the default value. { Format new_format = eFormatInvalid; if (definition.default_cstr_value) @@ -134,12 +130,10 @@ break; case OptionValue::eTypeLanguage: - // "definition.default_uint_value" is the default language enumeration value - // if - // "definition.default_cstr_value" is NULL, otherwise interpret - // "definition.default_cstr_value" as a string value that represents the - // default - // value. + // "definition.default_uint_value" is the default language enumeration + // value if "definition.default_cstr_value" is NULL, otherwise + // interpret "definition.default_cstr_value" as a string value that + // represents the default value. { LanguageType new_lang = eLanguageTypeUnknown; if (definition.default_cstr_value) @@ -152,33 +146,31 @@ break; case OptionValue::eTypeFormatEntity: - // "definition.default_cstr_value" as a string value that represents the - // default + // "definition.default_cstr_value" as a string value that represents + // the default m_value_sp.reset( new OptionValueFormatEntity(definition.default_cstr_value)); break; case OptionValue::eTypePathMap: - // "definition.default_uint_value" tells us if notifications should occur - // for - // path mappings + // "definition.default_uint_value" tells us if notifications should + // occur for path mappings m_value_sp.reset( new OptionValuePathMappings(definition.default_uint_value != 0)); break; case OptionValue::eTypeRegex: - // "definition.default_uint_value" is used to the regular expression flags - // "definition.default_cstr_value" the default regular expression value - // value. + // "definition.default_uint_value" is used to the regular expression + // flags "definition.default_cstr_value" the default regular + // expression value value. m_value_sp.reset(new OptionValueRegex(definition.default_cstr_value)); break; case OptionValue::eTypeSInt64: // "definition.default_uint_value" is the default integer value if // "definition.default_cstr_value" is NULL, otherwise interpret - // "definition.default_cstr_value" as a string value that represents the - // default - // value. + // "definition.default_cstr_value" as a string value that represents + // the default value. m_value_sp.reset(new OptionValueSInt64( definition.default_cstr_value ? StringConvert::ToSInt64(definition.default_cstr_value) @@ -186,11 +178,10 @@ break; case OptionValue::eTypeUInt64: - // "definition.default_uint_value" is the default unsigned integer value if - // "definition.default_cstr_value" is NULL, otherwise interpret - // "definition.default_cstr_value" as a string value that represents the - // default - // value. + // "definition.default_uint_value" is the default unsigned integer + // value if "definition.default_cstr_value" is NULL, otherwise + // interpret "definition.default_cstr_value" as a string value that + // represents the default value. m_value_sp.reset(new OptionValueUInt64( definition.default_cstr_value ? StringConvert::ToUInt64(definition.default_cstr_value) @@ -198,8 +189,9 @@ break; case OptionValue::eTypeUUID: - // "definition.default_uint_value" is not used for a OptionValue::eTypeUUID - // "definition.default_cstr_value" can contain a default UUID value + // "definition.default_uint_value" is not used for a + // OptionValue::eTypeUUID "definition.default_cstr_value" can contain + // a default UUID value { UUID uuid; if (definition.default_cstr_value) @@ -209,9 +201,9 @@ break; case OptionValue::eTypeString: - // "definition.default_uint_value" can contain the string option flags OR'ed - // together - // "definition.default_cstr_value" can contain a default string value + // "definition.default_uint_value" can contain the string option flags + // OR'ed together "definition.default_cstr_value" can contain a + // default string value { OptionValueString *string_value = new OptionValueString(definition.default_cstr_value); Index: source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp =================================================================== --- source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -1301,9 +1301,9 @@ const lldb_private::RegisterInfo * ABIMacOSX_arm::GetRegisterInfoArray(uint32_t &count) { - // Make the C-string names and alt_names for the register infos into const - // C-string values by having the ConstString unique the names in the global - // constant C-string pool. + // Make the C-string names and alt_names for the register infos into + // const C-string values by having the ConstString unique the names in + // the global constant C-string pool. if (!g_register_info_names_constified) { g_register_info_names_constified = true; for (uint32_t i = 0; i < k_num_register_infos; ++i) { @@ -1404,8 +1404,8 @@ Address so_addr; // Figure out if our return address is ARM or Thumb by using the - // Address::GetCallableLoadAddress(Target*) which will figure out the ARM - // thumb-ness and set the correct address bits for us. + // Address::GetCallableLoadAddress(Target*) which will figure out the + // ARM thumb-ness and set the correct address bits for us. so_addr.SetLoadAddress(return_addr, target_sp.get()); return_addr = so_addr.GetCallableLoadAddress(target_sp.get()); @@ -1413,8 +1413,8 @@ if (!reg_ctx->WriteRegisterFromUnsigned(ra_reg_num, return_addr)) return false; - // If bit zero or 1 is set, this must be a thumb function, no need to figure - // this out from the symbols. + // If bit zero or 1 is set, this must be a thumb function, no need to + // figure this out from the symbols. so_addr.SetLoadAddress(function_addr, target_sp.get()); function_addr = so_addr.GetCallableLoadAddress(target_sp.get()); @@ -1453,8 +1453,8 @@ uint32_t num_values = values.GetSize(); ExecutionContext exe_ctx(thread.shared_from_this()); - // For now, assume that the types in the AST values come from the Target's - // scratch AST. + // For now, assume that the types in the AST values come from the + // Target's scratch AST. // Extract the register context so we can read arguments from registers @@ -1482,7 +1482,8 @@ } else if (compiler_type.IsPointerOrReferenceType()) { bit_width = compiler_type.GetBitSize(&thread); } else { - // We only handle integer, pointer and reference types currently... + // We only handle integer, pointer and reference types + // currently... return false; } @@ -1576,8 +1577,8 @@ bool is_signed; - // Get the pointer to the first stack argument so we have a place to start - // when reading data + // Get the pointer to the first stack argument so we have a place to + // start when reading data const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0); if (compiler_type.IsIntegerOrEnumerationType(is_signed)) { @@ -1588,11 +1589,10 @@ return return_valobj_sp; case 128: if (IsArmv7kProcess()) { - // "A composite type not larger than 16 bytes is returned in r0-r3. The - // format is - // as if the result had been stored in memory at a word-aligned address - // and then - // loaded into r0-r3 with an ldm instruction" + // "A composite type not larger than 16 bytes is returned in + // r0-r3. The format is as if the result had been stored in memory + // at a word-aligned address and then loaded into r0-r3 with an + // ldm instruction" { const RegisterInfo *r1_reg_info = reg_ctx->GetRegisterInfoByName("r1", 0); @@ -1694,7 +1694,8 @@ return return_valobj_sp; } - // If we get here, we have a valid Value, so make our ValueObject out of it: + // If we get here, we have a valid Value, so make our ValueObject out of + // it: return_valobj_sp = ValueObjectConstResult::Create( thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); @@ -1755,11 +1756,10 @@ } } } else if (num_bytes <= 16 && IsArmv7kProcess()) { - // "A composite type not larger than 16 bytes is returned in r0-r3. The - // format is - // as if the result had been stored in memory at a word-aligned address - // and then - // loaded into r0-r3 with an ldm instruction" + // "A composite type not larger than 16 bytes is returned in r0-r3. + // The format is as if the result had been stored in memory at a + // word-aligned address and then loaded into r0-r3 with an ldm + // instruction" const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("r0", 0); const RegisterInfo *r1_info = reg_ctx->GetRegisterInfoByName("r1", 0); Index: source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp =================================================================== --- source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -1641,9 +1641,9 @@ const lldb_private::RegisterInfo * ABIMacOSX_arm64::GetRegisterInfoArray(uint32_t &count) { - // Make the C-string names and alt_names for the register infos into const - // C-string values by having the ConstString unique the names in the global - // constant C-string pool. + // Make the C-string names and alt_names for the register infos into + // const C-string values by having the ConstString unique the names in + // the global constant C-string pool. if (!g_register_info_names_constified) { g_register_info_names_constified = true; for (uint32_t i = 0; i < k_num_register_infos; ++i) { @@ -1776,7 +1776,8 @@ } else if (value_type.IsPointerOrReferenceType()) { bit_width = value_type.GetBitSize(&thread); } else { - // We only handle integer, pointer and reference types currently... + // We only handle integer, pointer and reference types + // currently... return false; } @@ -1892,7 +1893,8 @@ const uint32_t type_flags = return_value_type.GetTypeInfo(nullptr); if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) { if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { - // Extract the register context so we can read arguments from registers + // Extract the register context so we can read arguments from + // registers lldb::offset_t offset = 0; if (byte_size <= 16) { const RegisterInfo *x0_info = reg_ctx->GetRegisterInfoByName("x0", 0); @@ -2022,10 +2024,9 @@ } // AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture) says -// registers x19 through x28 and sp are callee preserved. -// v8-v15 are non-volatile (and specifically only the lower 8 bytes of these -// regs), -// the rest of the fp/SIMD registers are volatile. +// registers x19 through x28 and sp are callee preserved. v8-v15 are non- +// volatile (and specifically only the lower 8 bytes of these regs), the +// rest of the fp/SIMD registers are volatile. // We treat x29 as callee preserved also, else the unwinder won't try to // retrieve fp saves. @@ -2034,8 +2035,8 @@ if (reg_info) { const char *name = reg_info->name; - // Sometimes we'll be called with the "alternate" name for these registers; - // recognize them as non-volatile. + // Sometimes we'll be called with the "alternate" name for these + // registers; recognize them as non-volatile. if (name[0] == 'p' && name[1] == 'c') // pc return false; @@ -2048,7 +2049,8 @@ if (name[0] == 'x') { // Volatile registers: x0-x18, x30 (lr) - // Return false for the non-volatile gpr regs, true for everything else + // Return false for the non-volatile gpr regs, true for everything + // else switch (name[1]) { case '1': switch (name[2]) { @@ -2084,7 +2086,8 @@ } } else if (name[0] == 'v' || name[0] == 's' || name[0] == 'd') { // Volatile registers: v0-7, v16-v31 - // Return false for non-volatile fp/SIMD regs, true for everything else + // Return false for non-volatile fp/SIMD regs, true for everything + // else switch (name[1]) { case '8': case '9': @@ -2210,13 +2213,14 @@ const RegisterInfo *reg_info = nullptr; if (is_return_value) { // We are assuming we are decoding this immediately after returning - // from a function call and that the address of the structure is in x8 + // from a function call and that the address of the structure is in + // x8 reg_info = reg_ctx->GetRegisterInfoByName("x8", 0); } else { - // We are assuming we are stopped at the first instruction in a function - // and that the ABI is being respected so all parameters appear where they - // should be (functions with no external linkage can legally violate the - // ABI). + // We are assuming we are stopped at the first instruction in a + // function and that the ABI is being respected so all parameters + // appear where they should be (functions with no external linkage + // can legally violate the ABI). if (NGRN >= 8) return false; @@ -2261,7 +2265,8 @@ if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr) return return_valobj_sp; - // value.SetContext (Value::eContextTypeClangType, return_compiler_type); + // value.SetContext (Value::eContextTypeClangType, + // return_compiler_type); value.SetCompilerType(return_compiler_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); @@ -2276,7 +2281,8 @@ bool success = false; if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { - // Extract the register context so we can read arguments from registers + // Extract the register context so we can read arguments from + // registers if (byte_size <= 8) { const RegisterInfo *x0_reg_info = reg_ctx->GetRegisterInfoByName("x0", 0); Index: source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp =================================================================== --- source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -688,9 +688,9 @@ const lldb_private::RegisterInfo * ABIMacOSX_i386::GetRegisterInfoArray(uint32_t &count) { - // Make the C-string names and alt_names for the register infos into const - // C-string values by having the ConstString unique the names in the global - // constant C-string pool. + // Make the C-string names and alt_names for the register infos into + // const C-string values by having the ConstString unique the names in + // the global constant C-string pool. if (!g_register_info_names_constified) { g_register_info_names_constified = true; for (uint32_t i = 0; i < k_num_register_infos; ++i) { @@ -737,9 +737,9 @@ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); // When writing a register value down to memory, the register info used - // to write memory just needs to have the correct size of a 32 bit register, - // the actual register it pertains to is not important, just the size needs - // to be correct. Here we use "eax"... + // to write memory just needs to have the correct size of a 32 bit + // register, the actual register it pertains to is not important, just + // the size needs to be correct. Here we use "eax"... const RegisterInfo *reg_info_32 = reg_ctx->GetRegisterInfoByName("eax"); if (!reg_info_32) return false; // TODO this should actually never happen @@ -766,8 +766,8 @@ arg_pos += 4; } - // The return address is pushed onto the stack (yes after we just set the - // alignment above!). + // The return address is pushed onto the stack (yes after we just set + // the alignment above!). sp -= 4; reg_value.SetUInt32(return_addr); error = reg_ctx->WriteRegisterValueToMemory( @@ -807,8 +807,8 @@ unsigned int num_values = values.GetSize(); unsigned int value_index; - // Get the pointer to the first stack argument so we have a place to start - // when reading data + // Get the pointer to the first stack argument so we have a place to + // start when reading data RegisterContext *reg_ctx = thread.GetRegisterContext().get(); @@ -1012,7 +1012,8 @@ return return_valobj_sp; } - // If we get here, we have a valid Value, so make our ValueObject out of it: + // If we get here, we have a valid Value, so make our ValueObject out of + // it: return_valobj_sp = ValueObjectConstResult::Create( thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); @@ -1075,12 +1076,13 @@ } // v. -// http://developer.apple.com/library/mac/#documentation/developertools/Conceptual/LowLevelABI/130-IA-32_Function_Calling_Conventions/IA32.html#//apple_ref/doc/uid/TP40002492-SW4 +// http://developer.apple.com/library/mac/#documentation/developertools/Conceptual/LowLevelABI/130 +// -IA- +// 32_Function_Calling_Conventions/IA32.html#//apple_ref/doc/uid/TP40002492-SW4 // // This document ("OS X ABI Function Call Guide", chapter "IA-32 Function -// Calling Conventions") -// says that the following registers on i386 are preserved aka non-volatile aka -// callee-saved: +// Calling Conventions") says that the following registers on i386 are +// preserved aka non-volatile aka callee-saved: // // ebx, ebp, esi, edi, esp Index: source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp =================================================================== --- source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp +++ source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp @@ -1302,9 +1302,9 @@ const lldb_private::RegisterInfo * ABISysV_arm::GetRegisterInfoArray(uint32_t &count) { - // Make the C-string names and alt_names for the register infos into const - // C-string values by having the ConstString unique the names in the global - // constant C-string pool. + // Make the C-string names and alt_names for the register infos into + // const C-string values by having the ConstString unique the names in + // the global constant C-string pool. if (!g_register_info_names_constified) { g_register_info_names_constified = true; for (uint32_t i = 0; i < k_num_register_infos; ++i) { @@ -1408,8 +1408,8 @@ Address so_addr; // Figure out if our return address is ARM or Thumb by using the - // Address::GetCallableLoadAddress(Target*) which will figure out the ARM - // thumb-ness and set the correct address bits for us. + // Address::GetCallableLoadAddress(Target*) which will figure out the + // ARM thumb-ness and set the correct address bits for us. so_addr.SetLoadAddress(return_addr, target_sp.get()); return_addr = so_addr.GetCallableLoadAddress(target_sp.get()); @@ -1421,8 +1421,8 @@ if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_num, sp)) return false; - // If bit zero or 1 is set, this must be a thumb function, no need to figure - // this out from the symbols. + // If bit zero or 1 is set, this must be a thumb function, no need to + // figure this out from the symbols. so_addr.SetLoadAddress(function_addr, target_sp.get()); function_addr = so_addr.GetCallableLoadAddress(target_sp.get()); @@ -1457,8 +1457,8 @@ uint32_t num_values = values.GetSize(); ExecutionContext exe_ctx(thread.shared_from_this()); - // For now, assume that the types in the AST values come from the Target's - // scratch AST. + // For now, assume that the types in the AST values come from the + // Target's scratch AST. // Extract the register context so we can read arguments from registers @@ -1486,7 +1486,8 @@ } else if (compiler_type.IsPointerOrReferenceType()) { bit_width = compiler_type.GetBitSize(&thread); } else { - // We only handle integer, pointer and reference types currently... + // We only handle integer, pointer and reference types + // currently... return false; } @@ -1585,8 +1586,8 @@ uint8_t vfp_count = 0; uint8_t vfp_byte_size = 0; - // Get the pointer to the first stack argument so we have a place to start - // when reading data + // Get the pointer to the first stack argument so we have a place to + // start when reading data const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1); @@ -1839,7 +1840,8 @@ } } - // If we get here, we have a valid Value, so make our ValueObject out of it: + // If we get here, we have a valid Value, so make our ValueObject out of + // it: return_valobj_sp = ValueObjectConstResult::Create( thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); Index: source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp =================================================================== --- source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -1640,9 +1640,9 @@ const lldb_private::RegisterInfo * ABISysV_arm64::GetRegisterInfoArray(uint32_t &count) { - // Make the C-string names and alt_names for the register infos into const - // C-string values by having the ConstString unique the names in the global - // constant C-string pool. + // Make the C-string names and alt_names for the register infos into + // const C-string values by having the ConstString unique the names in + // the global constant C-string pool. if (!g_register_info_names_constified) { g_register_info_names_constified = true; for (uint32_t i = 0; i < k_num_register_infos; ++i) { @@ -1779,7 +1779,8 @@ } else if (value_type.IsPointerOrReferenceType()) { bit_width = value_type.GetBitSize(&thread); } else { - // We only handle integer, pointer and reference types currently... + // We only handle integer, pointer and reference types + // currently... return false; } @@ -1864,7 +1865,8 @@ const uint32_t type_flags = return_value_type.GetTypeInfo(nullptr); if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) { if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { - // Extract the register context so we can read arguments from registers + // Extract the register context so we can read arguments from + // registers lldb::offset_t offset = 0; if (byte_size <= 16) { const RegisterInfo *x0_info = reg_ctx->GetRegisterInfo( @@ -1994,10 +1996,9 @@ } // AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture) says -// registers x19 through x28 and sp are callee preserved. -// v8-v15 are non-volatile (and specifically only the lower 8 bytes of these -// regs), -// the rest of the fp/SIMD registers are volatile. +// registers x19 through x28 and sp are callee preserved. v8-v15 are non- +// volatile (and specifically only the lower 8 bytes of these regs), the +// rest of the fp/SIMD registers are volatile. // We treat x29 as callee preserved also, else the unwinder won't try to // retrieve fp saves. @@ -2006,8 +2007,8 @@ if (reg_info) { const char *name = reg_info->name; - // Sometimes we'll be called with the "alternate" name for these registers; - // recognize them as non-volatile. + // Sometimes we'll be called with the "alternate" name for these + // registers; recognize them as non-volatile. if (name[0] == 'p' && name[1] == 'c') // pc return false; @@ -2020,10 +2021,10 @@ if (name[0] == 'x' || name[0] == 'r') { // Volatile registers: x0-x18 - // Although documentation says only x19-28 + sp are callee saved - // We ll also have to treat x30 as non-volatile. - // Each dwarf frame has its own value of lr. - // Return false for the non-volatile gpr regs, true for everything else + // Although documentation says only x19-28 + sp are callee saved We + // ll also have to treat x30 as non-volatile. Each dwarf frame has + // its own value of lr. Return false for the non-volatile gpr regs, + // true for everything else switch (name[1]) { case '1': switch (name[2]) { @@ -2059,7 +2060,8 @@ } } else if (name[0] == 'v' || name[0] == 's' || name[0] == 'd') { // Volatile registers: v0-7, v16-v31 - // Return false for non-volatile fp/SIMD regs, true for everything else + // Return false for non-volatile fp/SIMD regs, true for everything + // else switch (name[1]) { case '8': case '9': @@ -2181,13 +2183,14 @@ const RegisterInfo *reg_info = nullptr; if (is_return_value) { // We are assuming we are decoding this immediately after returning - // from a function call and that the address of the structure is in x8 + // from a function call and that the address of the structure is in + // x8 reg_info = reg_ctx->GetRegisterInfoByName("x8", 0); } else { - // We are assuming we are stopped at the first instruction in a function - // and that the ABI is being respected so all parameters appear where they - // should be (functions with no external linkage can legally violate the - // ABI). + // We are assuming we are stopped at the first instruction in a + // function and that the ABI is being respected so all parameters + // appear where they should be (functions with no external linkage + // can legally violate the ABI). if (NGRN >= 8) return false; @@ -2229,7 +2232,8 @@ if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr) return return_valobj_sp; - // value.SetContext (Value::eContextTypeClangType, return_compiler_type); + // value.SetContext (Value::eContextTypeClangType, + // return_compiler_type); value.SetCompilerType(return_compiler_type); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); @@ -2244,7 +2248,8 @@ bool success = false; if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { - // Extract the register context so we can read arguments from registers + // Extract the register context so we can read arguments from + // registers if (byte_size <= 8) { const RegisterInfo *x0_reg_info = nullptr; x0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric, Index: source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp =================================================================== --- source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp +++ source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp @@ -981,9 +981,9 @@ const lldb_private::RegisterInfo * ABISysV_hexagon::GetRegisterInfoArray(uint32_t &count) { - // Make the C-string names and alt_names for the register infos into const - // C-string values by having the ConstString unique the names in the global - // constant C-string pool. + // Make the C-string names and alt_names for the register infos into + // const C-string values by having the ConstString unique the names in + // the global constant C-string pool. if (!g_register_info_names_constified) { g_register_info_names_constified = true; for (uint32_t i = 0; i < k_num_register_infos; ++i) { @@ -1115,8 +1115,8 @@ if (error.Fail()) return false; - // update the argument with the target pointer - // XXX: This is a gross hack for getting around the const + // update the argument with the target pointer XXX: This is a gross + // hack for getting around the const *const_cast(&arg.value) = sp; } @@ -1214,8 +1214,8 @@ return return_valobj_sp; } -// called when we are on the first instruction of a new function -// for hexagon the return address is in RA (R31) +// called when we are on the first instruction of a new function for +// hexagon the return address is in RA (R31) bool ABISysV_hexagon::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) { unwind_plan.Clear(); unwind_plan.SetRegisterKind(eRegisterKindGeneric); Index: source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp =================================================================== --- source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp +++ source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp @@ -3,8 +3,7 @@ // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source -// License. -// See LICENSE.TXT for details. +// License. See LICENSE.TXT for details. //===----------------------------------------------------------------------===// #include "ABISysV_i386.h" @@ -55,9 +54,9 @@ //==================================================================== // DWARF Register Number Mapping -// See Table 2.14 of the reference document (specified on top of this file) -// Comment: Table 2.14 is followed till 'mm' entries. -// After that, all entries are ignored here. +// See Table 2.14 of the reference document (specified on top of this +// file) Comment: Table 2.14 is followed till 'mm' entries. After that, +// all entries are ignored here. enum dwarf_regnums { dwarf_eax = 0, @@ -180,9 +179,9 @@ const lldb_private::RegisterInfo * ABISysV_i386::GetRegisterInfoArray(uint32_t &count) { - // Make the C-string names and alt_names for the register infos into const - // C-string values by having the ConstString unique the names in the global - // constant C-string pool. + // Make the C-string names and alt_names for the register infos into + // const C-string values by having the ConstString unique the names in + // the global constant C-string pool. if (!g_register_info_names_constified) { g_register_info_names_constified = true; for (uint32_t i = 0; i < k_num_register_infos; ++i) { @@ -228,12 +227,10 @@ uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); - // While using register info to write a register value to memory, the register - // info - // just needs to have the correct size of a 32 bit register, the actual - // register it - // pertains to is not important, just the size needs to be correct. - // "eax" is used here for this purpose. + // While using register info to write a register value to memory, the + // register info just needs to have the correct size of a 32 bit + // register, the actual register it pertains to is not important, just + // the size needs to be correct. "eax" is used here for this purpose. const RegisterInfo *reg_info_32 = reg_ctx->GetRegisterInfoByName("eax"); if (!reg_info_32) return false; // TODO this should actually never happen @@ -363,9 +360,10 @@ return error; } - // Following "IF ELSE" block categorizes various 'Fundamental Data Types'. - // The terminology 'Fundamental Data Types' used here is adopted from - // Table 2.1 of the reference document (specified on top of this file) + // Following "IF ELSE" block categorizes various 'Fundamental Data + // Types'. The terminology 'Fundamental Data Types' used here is adopted + // from Table 2.1 of the reference document (specified on top of this + // file) if (type_flags & eTypeIsPointer) // 'Pointer' { @@ -390,8 +388,8 @@ default: break; case 16: - // For clang::BuiltinType::UInt128 & Int128 - // ToDo: Need to decide how to handle it + // For clang::BuiltinType::UInt128 & Int128 ToDo: Need to decide + // how to handle it break; case 8: { uint32_t raw_value_low = data.GetMaxU32(&offset, 4); @@ -507,9 +505,10 @@ unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB]; - // Following "IF ELSE" block categorizes various 'Fundamental Data Types'. - // The terminology 'Fundamental Data Types' used here is adopted from - // Table 2.1 of the reference document (specified on top of this file) + // Following "IF ELSE" block categorizes various 'Fundamental Data + // Types'. The terminology 'Fundamental Data Types' used here is adopted + // from Table 2.1 of the reference document (specified on top of this + // file) if (type_flags & eTypeIsPointer) // 'Pointer' { @@ -543,8 +542,8 @@ break; case 16: - // For clang::BuiltinType::UInt128 & Int128 - // ToDo: Need to decide how to handle it + // For clang::BuiltinType::UInt128 & Int128 ToDo: Need to decide + // how to handle it break; case 8: @@ -612,8 +611,8 @@ success = true; } else if (byte_size == 8) // double is 8 bytes { - // On Android Platform: long double is also 8 bytes - // It will be handled here only. + // On Android Platform: long double is also 8 bytes It will + // be handled here only. double value_double = (double)value_long_double; value.GetScalar() = value_double; success = true; @@ -639,8 +638,8 @@ } } else // Neither 'Integral' nor 'Floating Point' { - // If flow reaches here then check type_flags - // This type_flags is unhandled + // If flow reaches here then check type_flags This type_flags is + // unhandled } } else if (type_flags & eTypeIsComplex) // 'Complex Floating Point' { Index: source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp =================================================================== --- source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp +++ source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp @@ -698,8 +698,8 @@ if (log) log->Printf("Writing r25: 0x%" PRIx64, (uint64_t)func_addr); - // All callers of position independent functions must place the address of the - // called function in t9 (r25) + // All callers of position independent functions must place the address + // of the called function in t9 (r25) if (!reg_ctx->WriteRegisterFromUnsigned(r25_info, func_addr)) return false; @@ -867,8 +867,8 @@ UINT32_MAX; value.GetScalar() = ptr; } else if (return_compiler_type.IsAggregateType()) { - // Structure/Vector is always passed in memory and pointer to that memory is - // passed in r2. + // Structure/Vector is always passed in memory and pointer to that + // memory is passed in r2. uint64_t mem_address = reg_ctx->ReadRegisterAsUnsigned( reg_ctx->GetRegisterInfoByName("r2", 0), 0); // We have got the address. Create a memory object out of it @@ -963,7 +963,8 @@ return return_valobj_sp; } - // If we get here, we have a valid Value, so make our ValueObject out of it: + // If we get here, we have a valid Value, so make our ValueObject out of + // it: return_valobj_sp = ValueObjectConstResult::Create( thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); Index: source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp =================================================================== --- source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -661,8 +661,8 @@ if (log) log->Printf("Writing r25: 0x%" PRIx64, (uint64_t)func_addr); - // All callers of position independent functions must place the address of the - // called function in t9 (r25) + // All callers of position independent functions must place the address + // of the called function in t9 (r25) if (!reg_ctx->WriteRegisterFromUnsigned(r25_info, func_addr)) return false; @@ -782,8 +782,9 @@ bool success = false; if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) { - // Extract the register context so we can read arguments from registers - // In MIPS register "r2" (v0) holds the integer function return values + // Extract the register context so we can read arguments from + // registers In MIPS register "r2" (v0) holds the integer function + // return values uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_info, 0); @@ -916,14 +917,16 @@ thread.GetStackFrameAtIndex(0).get(), value, ConstString("")); } else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass || type_flags & eTypeIsVector) { - // Any structure of up to 16 bytes in size is returned in the registers. + // Any structure of up to 16 bytes in size is returned in the + // registers. if (byte_size <= 16) { DataBufferSP data_sp(new DataBufferHeap(16, 0)); DataExtractor return_ext(data_sp, target_byte_order, target->GetArchitecture().GetAddressByteSize()); RegisterValue r2_value, r3_value, f0_value, f1_value, f2_value; - // Tracks how much bytes of r2 and r3 registers we've consumed so far + // Tracks how much bytes of r2 and r3 registers we've consumed so + // far uint32_t integer_bytes = 0; // True if return values are in FP return registers. @@ -941,8 +944,9 @@ uint32_t count; const uint32_t num_children = return_compiler_type.GetNumFields(); - // A structure consisting of one or two FP values (and nothing else) will - // be returned in the two FP return-value registers i.e fp0 and fp2. + // A structure consisting of one or two FP values (and nothing else) + // will be returned in the two FP return-value registers i.e fp0 and + // fp2. if (num_children <= 2) { uint64_t field_bit_offset = 0; @@ -959,8 +963,8 @@ } if (use_fp_regs && !found_non_fp_field) { - // We have one or two FP-only values in this structure. Get it from - // f0/f2 registers. + // We have one or two FP-only values in this structure. Get it + // from f0/f2 registers. DataExtractor f0_data, f1_data, f2_data; const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0); const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0); @@ -986,8 +990,8 @@ // This case is for long double type. if (field_byte_width == 16) { - // If structure contains long double type, then it is returned - // in fp0/fp1 registers. + // If structure contains long double type, then it is + // returned in fp0/fp1 registers. if (target_byte_order == eByteOrderLittle) { return_value[0] = f0_data.GetU64(&offset); reg_ctx->ReadRegister(f1_info, f1_value); @@ -1026,8 +1030,8 @@ target_byte_order); } - // The result is in our data buffer. Create a variable object out of - // it + // The result is in our data buffer. Create a variable object + // out of it return_valobj_sp = ValueObjectConstResult::Create( &thread, return_compiler_type, ConstString(""), return_ext); @@ -1035,10 +1039,10 @@ } } - // If we reach here, it means this structure either contains more than two - // fields or - // it contains at least one non floating point type. - // In that case, all fields are returned in GP return registers. + // If we reach here, it means this structure either contains more + // than two fields or it contains at least one non floating point + // type. In that case, all fields are returned in GP return + // registers. for (uint32_t idx = 0; idx < num_children; idx++) { uint64_t field_bit_offset = 0; bool is_signed; @@ -1049,8 +1053,8 @@ const size_t field_byte_width = field_compiler_type.GetByteSize(nullptr); - // if we don't know the size of the field (e.g. invalid type), just bail - // out + // if we don't know the size of the field (e.g. invalid type), + // just bail out if (field_byte_width == 0) break; @@ -1064,30 +1068,30 @@ if (integer_bytes < 8) { // We have not yet consumed r2 completely. if (integer_bytes + field_byte_width + padding <= 8) { - // This field fits in r2, copy its value from r2 to our result - // structure + // This field fits in r2, copy its value from r2 to our + // result structure integer_bytes = integer_bytes + field_byte_width + padding; // Increase the consumed bytes. use_r2 = 1; } else { - // There isn't enough space left in r2 for this field, so this - // will be in r3. + // There isn't enough space left in r2 for this field, so + // this will be in r3. integer_bytes = integer_bytes + field_byte_width + padding; // Increase the consumed bytes. use_r3 = 1; } } - // We already have consumed at-least 8 bytes that means r2 is done, - // and this field will be in r3. - // Check if this field can fit in r3. + // We already have consumed at-least 8 bytes that means r2 is + // done, and this field will be in r3. Check if this field can + // fit in r3. else if (integer_bytes + field_byte_width + padding <= 16) { integer_bytes = integer_bytes + field_byte_width + padding; use_r3 = 1; } else { - // There isn't any space left for this field, this should not happen - // as we have already checked - // the overall size is not greater than 16 bytes. For now, return a - // nullptr return value object. + // There isn't any space left for this field, this should not + // happen as we have already checked the overall size is not + // greater than 16 bytes. For now, return a nullptr return + // value object. return return_valobj_sp; } } @@ -1123,15 +1127,16 @@ sucess = 1; } if (sucess) { - // The result is in our data buffer. Create a variable object out of it + // The result is in our data buffer. Create a variable object out + // of it return_valobj_sp = ValueObjectConstResult::Create( &thread, return_compiler_type, ConstString(""), return_ext); } return return_valobj_sp; } - // Any structure/vector greater than 16 bytes in size is returned in memory. - // The pointer to that memory is returned in r2. + // Any structure/vector greater than 16 bytes in size is returned in + // memory. The pointer to that memory is returned in r2. uint64_t mem_address = reg_ctx->ReadRegisterAsUnsigned( reg_ctx->GetRegisterInfoByName("r2", 0), 0); Index: source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp =================================================================== --- source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -111,7 +111,8 @@ dwarf_cfa, }; -// Note that the size and offset will be updated by platform-specific classes. +// Note that the size and offset will be updated by platform-specific +// classes. #define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \ { \ #reg, alt, 8, 0, eEncodingUint, eFormatHex, {kind1, kind2, kind3, kind4 }, \ @@ -119,8 +120,8 @@ } static const RegisterInfo g_register_infos[] = { - // General purpose registers. eh_frame, DWARF, - // Generic, Process Plugin + // General purpose registers. eh_frame, + // DWARF, Generic, Process Plugin DEFINE_GPR(r0, nullptr, dwarf_r0, dwarf_r0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), DEFINE_GPR(r1, "sp", dwarf_r1, dwarf_r1, LLDB_REGNUM_GENERIC_SP, @@ -357,8 +358,8 @@ if (!reg_ctx) return false; - // Get the pointer to the first stack argument so we have a place to start - // when reading data + // Get the pointer to the first stack argument so we have a place to + // start when reading data addr_t sp = reg_ctx->GetSP(0); @@ -500,9 +501,9 @@ } if (!set_it_simple) { - // Okay we've got a structure or something that doesn't fit in a simple - // register. - // We should figure out where it really goes, but we don't support this yet. + // Okay we've got a structure or something that doesn't fit in a + // simple register. We should figure out where it really goes, but we + // don't support this yet. error.SetErrorString("We only support setting simple integer and float " "return types at present."); } @@ -531,7 +532,8 @@ bool success = false; if (type_flags & eTypeIsInteger) { - // Extract the register context so we can read arguments from registers + // Extract the register context so we can read arguments from + // registers const size_t byte_size = return_compiler_type.GetByteSize(nullptr); uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( @@ -689,7 +691,8 @@ const uint32_t num_children = return_compiler_type.GetNumFields(); - // Since we are in the small struct regime, assume we are not in memory. + // Since we are in the small struct regime, assume we are not in + // memory. is_memory = false; for (uint32_t idx = 0; idx < num_children; idx++) { @@ -719,7 +722,8 @@ field_compiler_type.IsPointerType()) { if (integer_bytes < 8) { if (integer_bytes + field_byte_width <= 8) { - // This is in RAX, copy from register to our result structure: + // This is in RAX, copy from register to our result + // structure: copy_from_extractor = &r3_data; copy_from_offset = integer_bytes; integer_bytes += field_byte_width; @@ -735,10 +739,9 @@ copy_from_offset = integer_bytes - 8; integer_bytes += field_byte_width; } else { - // The last field didn't fit. I can't see how that would happen w/o - // the overall size being - // greater than 16 bytes. For now, return a nullptr return value - // object. + // The last field didn't fit. I can't see how that would + // happen w/o the overall size being greater than 16 bytes. + // For now, return a nullptr return value object. return return_valobj_sp; } } else if (field_compiler_type.IsFloatingPointType(count, is_complex)) { @@ -750,15 +753,15 @@ copy_from_offset = 0; fp_bytes += field_byte_width; } else if (field_bit_width == 32) { - // This one is kind of complicated. If we are in an "eightbyte" - // with another float, we'll - // be stuffed into an xmm register with it. If we are in an - // "eightbyte" with one or more ints, - // then we will be stuffed into the appropriate GPR with them. + // This one is kind of complicated. If we are in an + // "eightbyte" with another float, we'll be stuffed into an + // xmm register with it. If we are in an "eightbyte" with one + // or more ints, then we will be stuffed into the appropriate + // GPR with them. bool in_gpr; if (field_byte_offset % 8 == 0) { - // We are at the beginning of one of the eightbytes, so check the - // next element (if any) + // We are at the beginning of one of the eightbytes, so + // check the next element (if any) if (idx == num_children - 1) in_gpr = false; else { @@ -776,9 +779,9 @@ } } } else if (field_byte_offset % 4 == 0) { - // We are inside of an eightbyte, so see if the field before us is - // floating point: - // This could happen if somebody put padding in the structure. + // We are inside of an eightbyte, so see if the field before + // us is floating point: This could happen if somebody put + // padding in the structure. if (idx == 0) in_gpr = false; else { @@ -800,11 +803,12 @@ continue; } - // Okay, we've figured out whether we are in GPR or XMM, now figure - // out which one. + // Okay, we've figured out whether we are in GPR or XMM, now + // figure out which one. if (in_gpr) { if (integer_bytes < 8) { - // This is in RAX, copy from register to our result structure: + // This is in RAX, copy from register to our result + // structure: copy_from_extractor = &r3_data; copy_from_offset = integer_bytes; integer_bytes += field_byte_width; @@ -820,8 +824,8 @@ } // These two tests are just sanity checks. If I somehow get the - // type calculation wrong above it is better to just return nothing - // than to assert or crash. + // type calculation wrong above it is better to just return + // nothing than to assert or crash. if (!copy_from_extractor) return return_valobj_sp; if (copy_from_offset + field_byte_width > @@ -835,20 +839,19 @@ } if (!is_memory) { - // The result is in our data buffer. Let's make a variable object out - // of it: + // The result is in our data buffer. Let's make a variable object + // out of it: return_valobj_sp = ValueObjectConstResult::Create( &thread, return_compiler_type, ConstString(""), return_ext); } } - // FIXME: This is just taking a guess, r3 may very well no longer hold the - // return storage location. - // If we are going to do this right, when we make a new frame we should - // check to see if it uses a memory - // return, and if we are at the first instruction and if so stash away the - // return location. Then we would - // only return the memory return value if we know it is valid. + // FIXME: This is just taking a guess, r3 may very well no longer hold + // the return storage location. If we are going to do this right, when + // we make a new frame we should check to see if it uses a memory + // return, and if we are at the first instruction and if so stash away + // the return location. Then we would only return the memory return + // value if we know it is valid. if (is_memory) { unsigned r3_id = @@ -918,8 +921,8 @@ // See "Register Usage" in the // "System V Application Binary Interface" -// "64-bit PowerPC ELF Application Binary Interface Supplement" -// current version is 1.9 released 2004 at +// "64-bit PowerPC ELF Application Binary Interface Supplement" current +// version is 1.9 released 2004 at // http://refspecs.linuxfoundation.org/ELF/ppc/PPC-elf64abi-1.9.pdf bool ABISysV_ppc::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { Index: source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp =================================================================== --- source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -247,8 +247,8 @@ if (!reg_ctx) return false; - // Get the pointer to the first stack argument so we have a place to start - // when reading data + // Get the pointer to the first stack argument so we have a place to + // start when reading data addr_t sp = reg_ctx->GetSP(0); @@ -379,9 +379,9 @@ } if (!set_it_simple) { - // Okay we've got a structure or something that doesn't fit in a simple - // register. - // We should figure out where it really goes, but we don't support this yet. + // Okay we've got a structure or something that doesn't fit in a + // simple register. We should figure out where it really goes, but we + // don't support this yet. error.SetErrorString("We only support setting simple integer and float " "return types at present."); } @@ -402,8 +402,8 @@ // // It may be constructed by directly specifying its index (where 0 is // the first register used to return values) or by specifying the offset - // of a given struct field, in which case the appropriated register index - // will be calculated. + // of a given struct field, in which case the appropriated register + // index will be calculated. class Register { public: enum Type { @@ -720,8 +720,8 @@ } } - // Get the whole contents of vector registers and let the - // logic here arrange the data properly. + // Get the whole contents of vector registers and let the logic here + // arrange the data properly. RegisterValue vr_val[MAX_VRS]; Status error; @@ -741,8 +741,8 @@ } // The compiler generated code seems to always put the vector elements - // at the end of the vector register, in case they don't occupy all of it. - // This offset variable handles this. + // at the end of the vector register, in case they don't occupy all of + // it. This offset variable handles this. uint32_t offs = 0; if (m_byte_size < vr_size) offs = vr_size - m_byte_size; @@ -1025,8 +1025,8 @@ // See "Register Usage" in the // "System V Application Binary Interface" -// "64-bit PowerPC ELF Application Binary Interface Supplement" -// current version is 2 released 2015 at +// "64-bit PowerPC ELF Application Binary Interface Supplement" current +// version is 2 released 2015 at // https://members.openpowerfoundation.org/document/dl/576 bool ABISysV_ppc64::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { if (reg_info) { Index: source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp =================================================================== --- source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp +++ source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp @@ -180,9 +180,9 @@ const lldb_private::RegisterInfo * ABISysV_s390x::GetRegisterInfoArray(uint32_t &count) { - // Make the C-string names and alt_names for the register infos into const - // C-string values by having the ConstString unique the names in the global - // constant C-string pool. + // Make the C-string names and alt_names for the register infos into + // const C-string values by having the ConstString unique the names in + // the global constant C-string pool. if (!g_register_info_names_constified) { g_register_info_names_constified = true; for (uint32_t i = 0; i < k_num_register_infos; ++i) { @@ -344,8 +344,8 @@ if (!reg_ctx) return false; - // Get the pointer to the first stack argument so we have a place to start - // when reading data + // Get the pointer to the first stack argument so we have a place to + // start when reading data addr_t sp = reg_ctx->GetSP(0); @@ -482,9 +482,9 @@ } if (!set_it_simple) { - // Okay we've got a structure or something that doesn't fit in a simple - // register. - // We should figure out where it really goes, but we don't support this yet. + // Okay we've got a structure or something that doesn't fit in a + // simple register. We should figure out where it really goes, but we + // don't support this yet. error.SetErrorString("We only support setting simple integer and float " "return types at present."); } @@ -513,7 +513,8 @@ bool success = false; if (type_flags & eTypeIsInteger) { - // Extract the register context so we can read arguments from registers + // Extract the register context so we can read arguments from + // registers const size_t byte_size = return_compiler_type.GetByteSize(nullptr); uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( @@ -615,13 +616,12 @@ return return_valobj_sp; if (return_compiler_type.IsAggregateType()) { - // FIXME: This is just taking a guess, r2 may very well no longer hold the - // return storage location. - // If we are going to do this right, when we make a new frame we should - // check to see if it uses a memory - // return, and if we are at the first instruction and if so stash away the - // return location. Then we would - // only return the memory return value if we know it is valid. + // FIXME: This is just taking a guess, r2 may very well no longer hold + // the return storage location. If we are going to do this right, when + // we make a new frame we should check to see if it uses a memory + // return, and if we are at the first instruction and if so stash away + // the return location. Then we would only return the memory return + // value if we know it is valid. unsigned r2_id = reg_ctx_sp->GetRegisterInfoByName("r2", 0)->kinds[eRegisterKindLLDB]; @@ -654,17 +654,17 @@ } bool ABISysV_s390x::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) { - // There's really no default way to unwind on s390x. - // Trust the .eh_frame CFI, which should always be good. + // There's really no default way to unwind on s390x. Trust the .eh_frame + // CFI, which should always be good. return false; } bool ABISysV_s390x::GetFallbackRegisterLocation( const RegisterInfo *reg_info, UnwindPlan::Row::RegisterLocation &unwind_regloc) { - // If a volatile register is being requested, we don't want to forward the - // next frame's register contents - // up the stack -- the register is not retrievable at this frame. + // If a volatile register is being requested, we don't want to forward + // the next frame's register contents up the stack -- the register is + // not retrievable at this frame. if (RegisterIsVolatile(reg_info)) { unwind_regloc.SetUndefined(); return true; Index: source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp =================================================================== --- source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -1064,9 +1064,9 @@ const lldb_private::RegisterInfo * ABISysV_x86_64::GetRegisterInfoArray(uint32_t &count) { - // Make the C-string names and alt_names for the register infos into const - // C-string values by having the ConstString unique the names in the global - // constant C-string pool. + // Make the C-string names and alt_names for the register infos into + // const C-string values by having the ConstString unique the names in + // the global constant C-string pool. if (!g_register_info_names_constified) { g_register_info_names_constified = true; for (uint32_t i = 0; i < k_num_register_infos; ++i) { @@ -1228,8 +1228,8 @@ if (!reg_ctx) return false; - // Get the pointer to the first stack argument so we have a place to start - // when reading data + // Get the pointer to the first stack argument so we have a place to + // start when reading data addr_t sp = reg_ctx->GetSP(0); @@ -1370,9 +1370,9 @@ } if (!set_it_simple) { - // Okay we've got a structure or something that doesn't fit in a simple - // register. - // We should figure out where it really goes, but we don't support this yet. + // Okay we've got a structure or something that doesn't fit in a + // simple register. We should figure out where it really goes, but we + // don't support this yet. error.SetErrorString("We only support setting simple integer and float " "return types at present."); } @@ -1401,7 +1401,8 @@ bool success = false; if (type_flags & eTypeIsInteger) { - // Extract the register context so we can read arguments from registers + // Extract the register context so we can read arguments from + // registers const size_t byte_size = return_compiler_type.GetByteSize(nullptr); uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned( @@ -1463,8 +1464,8 @@ value.GetScalar() = (double)data.GetDouble(&offset); success = true; } else if (byte_size == sizeof(long double)) { - // Don't handle long double since that can be encoded as 80 bit - // floats... + // Don't handle long double since that can be encoded as + // 80 bit floats... } } } @@ -1610,7 +1611,8 @@ const uint32_t num_children = return_compiler_type.GetNumFields(); - // Since we are in the small struct regime, assume we are not in memory. + // Since we are in the small struct regime, assume we are not in + // memory. is_memory = false; for (uint32_t idx = 0; idx < num_children; idx++) { @@ -1624,8 +1626,8 @@ idx, name, &field_bit_offset, nullptr, nullptr); const size_t field_bit_width = field_compiler_type.GetBitSize(&thread); - // if we don't know the size of the field (e.g. invalid type), just bail - // out + // if we don't know the size of the field (e.g. invalid type), + // just bail out if (field_bit_width == 0) break; @@ -1645,7 +1647,8 @@ field_compiler_type.IsPointerType()) { if (integer_bytes < 8) { if (integer_bytes + field_byte_width <= 8) { - // This is in RAX, copy from register to our result structure: + // This is in RAX, copy from register to our result + // structure: copy_from_extractor = &rax_data; copy_from_offset = integer_bytes; integer_bytes += field_byte_width; @@ -1661,10 +1664,9 @@ copy_from_offset = integer_bytes - 8; integer_bytes += field_byte_width; } else { - // The last field didn't fit. I can't see how that would happen w/o - // the overall size being - // greater than 16 bytes. For now, return a nullptr return value - // object. + // The last field didn't fit. I can't see how that would + // happen w/o the overall size being greater than 16 bytes. + // For now, return a nullptr return value object. return return_valobj_sp; } } else if (field_compiler_type.IsFloatingPointType(count, is_complex)) { @@ -1682,15 +1684,15 @@ copy_from_offset = 0; fp_bytes += field_byte_width; } else if (field_bit_width == 32) { - // This one is kind of complicated. If we are in an "eightbyte" - // with another float, we'll - // be stuffed into an xmm register with it. If we are in an - // "eightbyte" with one or more ints, - // then we will be stuffed into the appropriate GPR with them. + // This one is kind of complicated. If we are in an + // "eightbyte" with another float, we'll be stuffed into an + // xmm register with it. If we are in an "eightbyte" with one + // or more ints, then we will be stuffed into the appropriate + // GPR with them. bool in_gpr; if (field_byte_offset % 8 == 0) { - // We are at the beginning of one of the eightbytes, so check the - // next element (if any) + // We are at the beginning of one of the eightbytes, so + // check the next element (if any) if (idx == num_children - 1) in_gpr = false; else { @@ -1708,9 +1710,9 @@ } } } else if (field_byte_offset % 4 == 0) { - // We are inside of an eightbyte, so see if the field before us is - // floating point: - // This could happen if somebody put padding in the structure. + // We are inside of an eightbyte, so see if the field before + // us is floating point: This could happen if somebody put + // padding in the structure. if (idx == 0) in_gpr = false; else { @@ -1732,11 +1734,12 @@ continue; } - // Okay, we've figured out whether we are in GPR or XMM, now figure - // out which one. + // Okay, we've figured out whether we are in GPR or XMM, now + // figure out which one. if (in_gpr) { if (integer_bytes < 8) { - // This is in RAX, copy from register to our result structure: + // This is in RAX, copy from register to our result + // structure: copy_from_extractor = &rax_data; copy_from_offset = integer_bytes; integer_bytes += field_byte_width; @@ -1757,8 +1760,8 @@ } // These two tests are just sanity checks. If I somehow get the - // type calculation wrong above it is better to just return nothing - // than to assert or crash. + // type calculation wrong above it is better to just return + // nothing than to assert or crash. if (!copy_from_extractor) return return_valobj_sp; if (copy_from_offset + field_byte_width > @@ -1772,20 +1775,19 @@ } if (!is_memory) { - // The result is in our data buffer. Let's make a variable object out - // of it: + // The result is in our data buffer. Let's make a variable object + // out of it: return_valobj_sp = ValueObjectConstResult::Create( &thread, return_compiler_type, ConstString(""), return_ext); } } - // FIXME: This is just taking a guess, rax may very well no longer hold the - // return storage location. - // If we are going to do this right, when we make a new frame we should - // check to see if it uses a memory - // return, and if we are at the first instruction and if so stash away the - // return location. Then we would - // only return the memory return value if we know it is valid. + // FIXME: This is just taking a guess, rax may very well no longer + // hold the return storage location. If we are going to do this right, + // when we make a new frame we should check to see if it uses a memory + // return, and if we are at the first instruction and if so stash away + // the return location. Then we would only return the memory return + // value if we know it is valid. if (is_memory) { unsigned rax_id = @@ -1858,13 +1860,13 @@ // See "Register Usage" in the // "System V Application Binary Interface" -// "AMD64 Architecture Processor Supplement" -// (or "x86-64(tm) Architecture Processor Supplement" in earlier revisions) -// (this doc is also commonly referred to as the x86-64/AMD64 psABI) -// Edited by Michael Matz, Jan Hubicka, Andreas Jaeger, and Mark Mitchell -// current version is 0.99.6 released 2012-07-02 at -// http://refspecs.linuxfoundation.org/elf/x86-64-abi-0.99.pdf -// It's being revised & updated at https://github.com/hjl-tools/x86-psABI/ +// "AMD64 Architecture Processor Supplement" (or "x86-64(tm) Architecture +// Processor Supplement" in earlier revisions) (this doc is also commonly +// referred to as the x86-64/AMD64 psABI) Edited by Michael Matz, Jan +// Hubicka, Andreas Jaeger, and Mark Mitchell current version is 0.99.6 +// released 2012-07-02 at +// http://refspecs.linuxfoundation.org/elf/x86-64-abi-0.99.pdf It's being +// revised & updated at https://github.com/hjl-tools/x86-psABI/ bool ABISysV_x86_64::RegisterIsCalleeSaved(const RegisterInfo *reg_info) { if (!reg_info) Index: source/Plugins/Architecture/Arm/ArchitectureArm.cpp =================================================================== --- source/Plugins/Architecture/Arm/ArchitectureArm.cpp +++ source/Plugins/Architecture/Arm/ArchitectureArm.cpp @@ -43,10 +43,10 @@ void ArchitectureArm::OverrideStopInfo(Thread &thread) { // We need to check if we are stopped in Thumb mode in a IT instruction - // and detect if the condition doesn't pass. If this is the case it means - // we won't actually execute this instruction. If this happens we need to - // clear the stop reason to no thread plans think we are stopped for a - // reason and the plans should keep going. + // and detect if the condition doesn't pass. If this is the case it + // means we won't actually execute this instruction. If this happens we + // need to clear the stop reason to no thread plans think we are stopped + // for a reason and the plans should keep going. // // We do this because when single stepping many ARM processes, debuggers // often use the BVR/BCR registers that says "stop when the PC is not @@ -54,22 +54,22 @@ // up stopping on instructions inside an if/then block that wouldn't get // executed. By fixing this we can stop the debugger from seeming like // you stepped through both the "if" _and_ the "else" clause when source - // level stepping because the debugger stops regardless due to the BVR/BCR - // triggering a stop. + // level stepping because the debugger stops regardless due to the + // BVR/BCR triggering a stop. // // It also means we can set breakpoints on instructions inside an an // if/then block and correctly skip them if we use the BKPT instruction. - // The ARM and Thumb BKPT instructions are unconditional even when executed - // in a Thumb IT block. + // The ARM and Thumb BKPT instructions are unconditional even when + // executed in a Thumb IT block. // // If your debugger inserts software traps in ARM/Thumb code, it will // need to use 16 and 32 bit instruction for 16 and 32 bit thumb // instructions respectively. If your debugger inserts a 16 bit thumb - // trap on top of a 32 bit thumb instruction for an opcode that is inside - // an if/then, it will change the it/then to conditionally execute your - // 16 bit trap and then cause your program to crash if it executes the - // trailing 16 bits (the second half of the 32 bit thumb instruction you - // partially overwrote). + // trap on top of a 32 bit thumb instruction for an opcode that is + // inside an if/then, it will change the it/then to conditionally + // execute your 16 bit trap and then cause your program to crash if it + // executes the trailing 16 bits (the second half of the 32 bit thumb + // instruction you partially overwrote). RegisterContextSP reg_ctx_sp(thread.GetRegisterContext()); if (!reg_ctx_sp) @@ -84,33 +84,31 @@ const uint32_t T = Bit32(cpsr, 5); const uint32_t ISETSTATE = J << 1 | T; if (ISETSTATE == 0) { -// NOTE: I am pretty sure we want to enable the code below -// that detects when we stop on an instruction in ARM mode -// that is conditional and the condition doesn't pass. This -// can happen if you set a breakpoint on an instruction that -// is conditional. We currently will _always_ stop on the -// instruction which is bad. You can also run into this while -// single stepping and you could appear to run code in the "if" -// and in the "else" clause because it would stop at all of the -// conditional instructions in both. -// In such cases, we really don't want to stop at this location. -// I will check with the lldb-dev list first before I enable this. +// NOTE: I am pretty sure we want to enable the code below that detects +// when we stop on an instruction in ARM mode that is conditional and the +// condition doesn't pass. This can happen if you set a breakpoint on an +// instruction that is conditional. We currently will _always_ stop on the +// instruction which is bad. You can also run into this while single +// stepping and you could appear to run code in the "if" and in the "else" +// clause because it would stop at all of the conditional instructions in +// both. In such cases, we really don't want to stop at this location. I +// will check with the lldb-dev list first before I enable this. #if 0 // ARM mode: check for condition on intsruction const addr_t pc = reg_ctx_sp->GetPC(); Status error; - // If we fail to read the opcode we will get UINT64_MAX as the - // result in "opcode" which we can use to detect if we read a - // valid opcode. + // If we fail to read the opcode we will get UINT64_MAX as the result + // in "opcode" which we can use to detect if we read a valid opcode. const uint64_t opcode = thread.GetProcess()->ReadUnsignedIntegerFromMemory(pc, 4, UINT64_MAX, error); if (opcode <= UINT32_MAX) { const uint32_t condition = Bits32((uint32_t)opcode, 31, 28); if (!ARMConditionPassed(condition, cpsr)) { - // We ARE stopped on an ARM instruction whose condition doesn't - // pass so this instruction won't get executed. - // Regardless of why it stopped, we need to clear the stop info + // We ARE stopped on an ARM instruction whose condition + // doesn't pass so this instruction won't get executed. + // Regardless of why it stopped, we need to clear the stop + // info thread.SetStopInfo (StopInfoSP()); } } @@ -121,9 +119,10 @@ if (ITSTATE != 0) { const uint32_t condition = Bits32(ITSTATE, 7, 4); if (!ARMConditionPassed(condition, cpsr)) { - // We ARE stopped in a Thumb IT instruction on an instruction whose - // condition doesn't pass so this instruction won't get executed. - // Regardless of why it stopped, we need to clear the stop info + // We ARE stopped in a Thumb IT instruction on an instruction + // whose condition doesn't pass so this instruction won't get + // executed. Regardless of why it stopped, we need to clear the + // stop info thread.SetStopInfo(StopInfoSP()); } } Index: source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp =================================================================== --- source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp +++ source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp @@ -113,8 +113,8 @@ llvm::MCInst inst; const size_t inst_size = mc_disasm_ptr->GetMCInst(opcode_data, opcode_data_len, pc, inst); - // Be conservative, if we didn't understand the instruction, say it - // might branch... + // Be conservative, if we didn't understand the instruction, say + // it might branch... if (inst_size == 0) m_does_branch = eLazyBoolYes; else { @@ -148,8 +148,8 @@ llvm::MCInst inst; const size_t inst_size = mc_disasm_ptr->GetMCInst(opcode_data, opcode_data_len, pc, inst); - // if we didn't understand the instruction, say it doesn't have a - // delay slot... + // if we didn't understand the instruction, say it doesn't have + // a delay slot... if (inst_size == 0) m_has_delay_slot = eLazyBoolNo; else { @@ -253,8 +253,8 @@ m_is_valid = true; } } else { - // The opcode isn't evenly sized, so we need to actually use the llvm - // disassembler to parse it and get the size. + // The opcode isn't evenly sized, so we need to actually use the + // llvm disassembler to parse it and get the size. uint8_t *opcode_data = const_cast(data.PeekData(data_offset, 1)); const size_t opcode_data_len = data.BytesLeft(data_offset); @@ -1081,9 +1081,8 @@ unsigned flavor = ~0U; llvm::Triple triple = arch.GetTriple(); - // So far the only supported flavor is "intel" on x86. The base class will - // set this - // correctly coming in. + // So far the only supported flavor is "intel" on x86. The base class + // will set this correctly coming in. if (triple.getArch() == llvm::Triple::x86 || triple.getArch() == llvm::Triple::x86_64) { if (m_flavor == "intel") { @@ -1106,13 +1105,11 @@ thumb_arch.GetTriple().setArchName(llvm::StringRef(thumb_arch_name)); } - // If no sub architecture specified then use the most recent arm architecture - // so the - // disassembler will return all instruction. Without it we will see a lot of - // unknow opcode - // in case the code uses instructions which are not available in the oldest - // arm version - // (used when no sub architecture is specified) + // If no sub architecture specified then use the most recent arm + // architecture so the disassembler will return all instruction. Without + // it we will see a lot of unknow opcode in case the code uses + // instructions which are not available in the oldest arm version (used + // when no sub architecture is specified) if (triple.getArch() == llvm::Triple::arm && triple.getSubArch() == llvm::Triple::NoSubArch) triple.setArchName("armv8.2a"); @@ -1186,21 +1183,21 @@ features_str += "+dspr2,"; } - // If any AArch64 variant, enable the ARMv8.2 ISA - // extensions so we can disassemble newer instructions. + // If any AArch64 variant, enable the ARMv8.2 ISA extensions so we can + // disassemble newer instructions. if (triple.getArch() == llvm::Triple::aarch64) features_str += "+v8.2a"; - // We use m_disasm_ap.get() to tell whether we are valid or not, - // so if this isn't good for some reason, - // we won't be valid and FindPlugin will fail and we won't get used. + // We use m_disasm_ap.get() to tell whether we are valid or not, so if + // this isn't good for some reason, we won't be valid and FindPlugin + // will fail and we won't get used. m_disasm_up = MCDisasmInstance::Create(triple_str, cpu, features_str.c_str(), flavor, *this); llvm::Triple::ArchType llvm_arch = triple.getArch(); - // For arm CPUs that can execute arm or thumb instructions, also create a - // thumb instruction disassembler. + // For arm CPUs that can execute arm or thumb instructions, also create + // a thumb instruction disassembler. if (llvm_arch == llvm::Triple::arm) { std::string thumb_triple(thumb_arch.GetTriple().getTriple()); m_alternate_disasm_up = @@ -1393,8 +1390,8 @@ // If the "value" address (the target address we're symbolicating) // is inside the same SymbolContext as the current instruction pc - // (pc_so_addr), don't print the full function name - just print it - // with DumpStyleNoFunctionName style, e.g. "<+36>". + // (pc_so_addr), don't print the full function name - just print + // it with DumpStyleNoFunctionName style, e.g. "<+36>". if (format_omitting_current_func_name) { value_so_addr.Dump(&ss, target, Address::DumpStyleNoFunctionName, Address::DumpStyleSectionNameOffset); @@ -1406,10 +1403,9 @@ } if (!ss.GetString().empty()) { - // If Address::Dump returned a multi-line description, most commonly - // seen when we - // have multiple levels of inlined functions at an address, only show - // the first line. + // If Address::Dump returned a multi-line description, most + // commonly seen when we have multiple levels of inlined + // functions at an address, only show the first line. std::string str = ss.GetString(); size_t first_eol_char = str.find_first_of("\r\n"); if (first_eol_char != std::string::npos) { Index: source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp =================================================================== --- source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -45,10 +45,10 @@ using namespace lldb; using namespace lldb_private; -// Progressively greater amounts of scanning we will allow -// For some targets very early in startup, we can't do any random reads of -// memory or we can crash the device -// so a setting is needed that can completely disable the KASLR scans. +// Progressively greater amounts of scanning we will allow For some +// targets very early in startup, we can't do any random reads of memory +// or we can crash the device so a setting is needed that can completely +// disable the KASLR scans. enum KASLRScanType { eKASLRScanNone = 0, // No reading into the inferior at all @@ -122,9 +122,9 @@ } //---------------------------------------------------------------------- -// Create an instance of this class. This function is filled into -// the plugin info class that gets handed out by the plugin factory and -// allows the lldb to instantiate an instance of this class. +// Create an instance of this class. This function is filled into the +// plugin info class that gets handed out by the plugin factory and allows +// the lldb to instantiate an instance of this class. //---------------------------------------------------------------------- DynamicLoader *DynamicLoaderDarwinKernel::CreateInstance(Process *process, bool force) { @@ -141,8 +141,8 @@ } } - // If the target's architecture does not look like an Apple environment, - // this plugin should not create an instance. + // If the target's architecture does not look like an Apple + // environment, this plugin should not create an instance. const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple(); switch (triple_ref.getOS()) { @@ -155,8 +155,8 @@ return NULL; } break; - // If we have triple like armv7-unknown-unknown, we should try looking for a - // Darwin kernel. + // If we have triple like armv7-unknown-unknown, we should try looking + // for a Darwin kernel. case llvm::Triple::UnknownOS: break; default: @@ -166,9 +166,9 @@ } // At this point if there is an ExecutableModule, it is a kernel and the - // Target is some variant of an Apple system. - // If the Process hasn't provided the kernel load address, we need to look - // around in memory to find it. + // Target is some variant of an Apple system. If the Process hasn't + // provided the kernel load address, we need to look around in memory to + // find it. const addr_t kernel_load_address = SearchForDarwinKernel(process); if (CheckForKernelImageAtAddress(kernel_load_address, process).IsValid()) { @@ -197,10 +197,9 @@ } //---------------------------------------------------------------------- -// Check if the kernel binary is loaded in memory without a slide. -// First verify that the ExecutableModule is a kernel before we proceed. -// Returns the address of the kernel if one was found, else -// LLDB_INVALID_ADDRESS. +// Check if the kernel binary is loaded in memory without a slide. First +// verify that the ExecutableModule is a kernel before we proceed. Returns +// the address of the kernel if one was found, else LLDB_INVALID_ADDRESS. //---------------------------------------------------------------------- lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelAtSameLoadAddr(Process *process) { @@ -228,10 +227,9 @@ } //---------------------------------------------------------------------- -// If the debug flag is included in the boot-args nvram setting, the kernel's -// load address -// will be noted in the lowglo page at a fixed address -// Returns the address of the kernel if one was found, else +// If the debug flag is included in the boot-args nvram setting, the +// kernel's load address will be noted in the lowglo page at a fixed +// address Returns the address of the kernel if one was found, else // LLDB_INVALID_ADDRESS. //---------------------------------------------------------------------- lldb::addr_t @@ -282,11 +280,11 @@ } //---------------------------------------------------------------------- -// If the kernel is currently executing when lldb attaches, and we don't have -// a better way of finding the kernel's load address, try searching backwards -// from the current pc value looking for the kernel's Mach header in memory. -// Returns the address of the kernel if one was found, else -// LLDB_INVALID_ADDRESS. +// If the kernel is currently executing when lldb attaches, and we don't +// have a better way of finding the kernel's load address, try searching +// backwards from the current pc value looking for the kernel's Mach +// header in memory. Returns the address of the kernel if one was found, +// else LLDB_INVALID_ADDRESS. //---------------------------------------------------------------------- lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelNearPC(Process *process) { @@ -303,17 +301,16 @@ if (pc == LLDB_INVALID_ADDRESS) return LLDB_INVALID_ADDRESS; - // The kernel will load at at one megabyte boundary (0x100000), or at that - // boundary plus - // an offset of one page (0x1000) or two, or four (0x4000), depending on the - // device. + // The kernel will load at at one megabyte boundary (0x100000), or at + // that boundary plus an offset of one page (0x1000) or two, or four + // (0x4000), depending on the device. - // Round the current pc down to the nearest one megabyte boundary - the place - // where we will start searching. + // Round the current pc down to the nearest one megabyte boundary - the + // place where we will start searching. addr_t addr = pc & ~0xfffff; - // Search backwards 32 megabytes, looking for the start of the kernel at each - // one-megabyte boundary. + // Search backwards 32 megabytes, looking for the start of the kernel at + // each one-megabyte boundary. for (int i = 0; i < 32; i++, addr -= 0x100000) { if (CheckForKernelImageAtAddress(addr, process).IsValid()) return addr; @@ -329,11 +326,10 @@ } //---------------------------------------------------------------------- -// Scan through the valid address range for a kernel binary. -// This is uselessly slow in 64-bit environments so we don't even try it. -// This scan is not enabled by default even for 32-bit targets. -// Returns the address of the kernel if one was found, else -// LLDB_INVALID_ADDRESS. +// Scan through the valid address range for a kernel binary. This is +// uselessly slow in 64-bit environments so we don't even try it. This +// scan is not enabled by default even for 32-bit targets. Returns the +// address of the kernel if one was found, else LLDB_INVALID_ADDRESS. //---------------------------------------------------------------------- lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelViaExhaustiveSearch( Process *process) { @@ -350,10 +346,11 @@ kernel_range_high = UINT32_MAX; } - // Stepping through memory at one-megabyte resolution looking for a kernel - // rarely works (fast enough) with a 64-bit address space -- for now, let's - // not even bother. We may be attaching to something which *isn't* a kernel - // and we don't want to spin for minutes on-end looking for a kernel. + // Stepping through memory at one-megabyte resolution looking for a + // kernel rarely works (fast enough) with a 64-bit address space -- for + // now, let's not even bother. We may be attaching to something which + // *isn't* a kernel and we don't want to spin for minutes on-end looking + // for a kernel. if (process->GetTarget().GetArchitecture().GetAddressByteSize() == 8) return LLDB_INVALID_ADDRESS; @@ -374,10 +371,9 @@ } //---------------------------------------------------------------------- -// Given an address in memory, look to see if there is a kernel image at that -// address. -// Returns a UUID; if a kernel was not found at that address, UUID.IsValid() -// will be false. +// Given an address in memory, look to see if there is a kernel image at +// that address. Returns a UUID; if a kernel was not found at that +// address, UUID.IsValid() will be false. //---------------------------------------------------------------------- lldb_private::UUID DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress(lldb::addr_t addr, @@ -391,9 +387,9 @@ "looking for kernel binary at 0x%" PRIx64, addr); - // First try a quick test -- read the first 4 bytes and see if there is a - // valid Mach-O magic field there - // (the first field of the mach_header/mach_header_64 struct). + // First try a quick test -- read the first 4 bytes and see if there is + // a valid Mach-O magic field there (the first field of the + // mach_header/mach_header_64 struct). Status read_error; uint8_t magicbuf[4]; @@ -427,8 +423,8 @@ header.flags = llvm::ByteSwap_32(header.flags); } - // A kernel is an executable which does not have the dynamic link object flag - // set. + // A kernel is an executable which does not have the dynamic link object + // flag set. if (header.filetype == llvm::MachO::MH_EXECUTE && (header.flags & llvm::MachO::MH_DYLDLINK) == 0) { // Create a full module to get the UUID @@ -486,9 +482,9 @@ Status error; PlatformSP platform_sp( Platform::Create(PlatformDarwinKernel::GetPluginNameStatic(), error)); - // Only select the darwin-kernel Platform if we've been asked to load kexts. - // It can take some time to scan over all of the kext info.plists and that - // shouldn't be done if kext loading is explicitly disabled. + // Only select the darwin-kernel Platform if we've been asked to load + // kexts. It can take some time to scan over all of the kext info.plists + // and that shouldn't be done if kext loading is explicitly disabled. if (platform_sp.get() && GetGlobalProperties()->GetLoadKexts()) { process->GetTarget().SetPlatform(platform_sp); } @@ -629,11 +625,10 @@ return m_uuid; } -// Given the m_load_address from the kext summaries, and a UUID, try to create -// an in-memory -// Module at that address. Require that the MemoryModule have a matching UUID -// and detect -// if this MemoryModule is a kernel or a kext. +// Given the m_load_address from the kext summaries, and a UUID, try to +// create an in-memory Module at that address. Require that the +// MemoryModule have a matching UUID and detect if this MemoryModule is a +// kernel or a kext. // // Returns true if m_memory_module_sp is now set to a valid Module. @@ -667,11 +662,9 @@ } } - // If this is a kext, and the kernel specified what UUID we should find at - // this - // load address, require that the memory module have a matching UUID or - // something - // has gone wrong and we should discard it. + // If this is a kext, and the kernel specified what UUID we should find + // at this load address, require that the memory module have a matching + // UUID or something has gone wrong and we should discard it. if (m_uuid.IsValid()) { if (m_uuid != memory_module_sp->GetUUID()) { if (log) { @@ -705,9 +698,9 @@ ModuleSP exe_module_sp = process->GetTarget().GetExecutableModule(); if (exe_module_sp.get() && exe_module_sp->GetUUID().IsValid()) { if (m_uuid != exe_module_sp->GetUUID()) { - // The user specified a kernel binary that has a different UUID than - // the kernel actually running in memory. This never ends well; - // clear the user specified kernel binary from the Target. + // The user specified a kernel binary that has a different UUID + // than the kernel actually running in memory. This never ends + // well; clear the user specified kernel binary from the Target. m_module_sp.reset(); @@ -737,9 +730,8 @@ Target &target = process->GetTarget(); - // If we don't have / can't create a memory module for this kext, don't try to - // load it - we won't - // have the correct segment load addresses. + // If we don't have / can't create a memory module for this kext, don't + // try to load it - we won't have the correct segment load addresses. if (!ReadMemoryModule(process)) { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); if (log) @@ -761,8 +753,8 @@ } if (!m_module_sp) { - // See if the kext has already been loaded into the target, probably by the - // user doing target modules add. + // See if the kext has already been loaded into the target, probably + // by the user doing target modules add. const ModuleList &target_images = target.GetImages(); m_module_sp = target_images.FindModule(m_uuid); @@ -772,9 +764,8 @@ module_spec.GetUUID() = m_uuid; module_spec.GetArchitecture() = target.GetArchitecture(); - // For the kernel, we really do need an on-disk file copy of the binary to - // do anything useful. - // This will force a clal to + // For the kernel, we really do need an on-disk file copy of the + // binary to do anything useful. This will force a clal to if (IsKernel()) { if (Symbols::DownloadObjectAndSymbolFile(module_spec, true)) { if (module_spec.GetFileSpec().Exists()) { @@ -790,10 +781,9 @@ } } - // If the current platform is PlatformDarwinKernel, create a ModuleSpec - // with the filename set - // to be the bundle ID for this kext, e.g. - // "com.apple.filesystems.msdosfs", and ask the platform + // If the current platform is PlatformDarwinKernel, create a + // ModuleSpec with the filename set to be the bundle ID for this + // kext, e.g. "com.apple.filesystems.msdosfs", and ask the platform // to find it. PlatformSP platform_sp(target.GetPlatform()); if (!m_module_sp && platform_sp) { @@ -810,11 +800,11 @@ } } - // Ask the Target to find this file on the local system, if possible. - // This will search in the list of currently-loaded files, look in the - // standard search paths on the system, and on a Mac it will try calling - // the DebugSymbols framework with the UUID to find the binary via its - // search methods. + // Ask the Target to find this file on the local system, if + // possible. This will search in the list of currently-loaded files, + // look in the standard search paths on the system, and on a Mac it + // will try calling the DebugSymbols framework with the UUID to find + // the binary via its search methods. if (!m_module_sp) { m_module_sp = target.GetSharedModule(module_spec); } @@ -828,8 +818,9 @@ } } - // If we managed to find a module, append it to the target's list of images. - // If we also have a memory module, require that they have matching UUIDs + // If we managed to find a module, append it to the target's list of + // images. If we also have a memory module, require that they have + // matching UUIDs if (m_module_sp) { bool uuid_match_ok = true; if (m_memory_module_sp) { @@ -863,8 +854,8 @@ ObjectFile *memory_object_file = m_memory_module_sp->GetObjectFile(); if (memory_object_file && ondisk_object_file) { - // The memory_module for kexts may have an invalid __LINKEDIT seg; skip - // it. + // The memory_module for kexts may have an invalid __LINKEDIT seg; + // skip it. const bool ignore_linkedit = !IsKernel(); SectionList *ondisk_section_list = ondisk_object_file->GetSectionList(); @@ -872,25 +863,25 @@ if (memory_section_list && ondisk_section_list) { const uint32_t num_ondisk_sections = ondisk_section_list->GetSize(); // There may be CTF sections in the memory image so we can't - // always just compare the number of sections (which are actually - // segments in mach-o parlance) + // always just compare the number of sections (which are + // actually segments in mach-o parlance) uint32_t sect_idx = 0; // Use the memory_module's addresses for each section to set the - // file module's load address as appropriate. We don't want to use - // a single slide value for the entire kext - different segments may - // be slid different amounts by the kext loader. + // file module's load address as appropriate. We don't want to + // use a single slide value for the entire kext - different + // segments may be slid different amounts by the kext loader. uint32_t num_sections_loaded = 0; for (sect_idx = 0; sect_idx < num_ondisk_sections; ++sect_idx) { SectionSP ondisk_section_sp( ondisk_section_list->GetSectionAtIndex(sect_idx)); if (ondisk_section_sp) { - // Don't ever load __LINKEDIT as it may or may not be actually - // mapped into memory and there is no current way to tell. - // I filed rdar://problem/12851706 to track being able to tell - // if the __LINKEDIT is actually mapped, but until then, we need - // to not load the __LINKEDIT + // Don't ever load __LINKEDIT as it may or may not be + // actually mapped into memory and there is no current way + // to tell. I filed rdar://problem/12851706 to track being + // able to tell if the __LINKEDIT is actually mapped, but + // until then, we need to not load the __LINKEDIT if (ignore_linkedit && ondisk_section_sp->GetName() == g_section_name_LINKEDIT) continue; @@ -996,9 +987,9 @@ m_kernel.SetLoadAddress(m_kernel_load_address); if (m_kernel.GetLoadAddress() == LLDB_INVALID_ADDRESS && m_kernel.GetModule()) { - // We didn't get a hint from the process, so we will - // try the kernel at the address that it exists at in - // the file if we have one + // We didn't get a hint from the process, so we will try the + // kernel at the address that it exists at in the file if we have + // one ObjectFile *kernel_object_file = m_kernel.GetModule()->GetObjectFile(); if (kernel_object_file) { addr_t load_address = @@ -1009,10 +1000,9 @@ if (load_address != LLDB_INVALID_ADDRESS && load_address != 0) { m_kernel.SetLoadAddress(load_address); if (load_address != file_address) { - // Don't accidentally relocate the kernel to the File address -- - // the Load address has already been set to its actual in-memory - // address. - // Mark it as IsLoaded. + // Don't accidentally relocate the kernel to the File + // address -- the Load address has already been set to its + // actual in-memory address. Mark it as IsLoaded. m_kernel.SetProcessStopId(m_process->GetStopID()); } } else { @@ -1028,10 +1018,11 @@ } } - // The operating system plugin gets loaded and initialized in + // The operating system plugin gets loaded and initialized in // LoadImageUsingMemoryModule when we discover the kernel dSYM. For a - // core file in particular, that's the wrong place to do this, since - // we haven't fixed up the section addresses yet. So let's redo it here. + // core file in particular, that's the wrong place to do this, since + // we haven't fixed up the section addresses yet. So let's redo it + // here. LoadOperatingSystemPlugin(false); if (m_kernel.IsLoaded() && m_kernel.GetModule()) { @@ -1052,9 +1043,9 @@ //---------------------------------------------------------------------- // Static callback function that gets called when our DYLD notification -// breakpoint gets hit. We update all of our image infos and then -// let our super class DynamicLoader class decide if we should stop -// or not (based on global preference). +// breakpoint gets hit. We update all of our image infos and then let our +// super class DynamicLoader class decide if we should stop or not (based +// on global preference). //---------------------------------------------------------------------- bool DynamicLoaderDarwinKernel::BreakpointHitCallback( void *baton, StoppointCallbackContext *context, user_id_t break_id, @@ -1096,8 +1087,8 @@ if (m_process->GetTarget().ReadPointerFromMemory( m_kext_summary_header_ptr_addr, prefer_file_cache, error, m_kext_summary_header_addr)) { - // We got a valid address for our kext summary header and make sure it - // isn't NULL + // We got a valid address for our kext summary header and make sure + // it isn't NULL if (m_kext_summary_header_addr.IsValid() && m_kext_summary_header_addr.GetFileAddress() != 0) { const size_t bytes_read = m_process->GetTarget().ReadMemory( @@ -1111,8 +1102,8 @@ s->Printf("WARNING: Unable to read kext summary header, got " "improbable version number %u\n", m_kext_summary_header.version); - // If we get an improbably large version number, we're probably - // getting bad memory. + // If we get an improbably large version number, we're + // probably getting bad memory. m_kext_summary_header_addr.Clear(); return false; } @@ -1130,14 +1121,15 @@ return false; } } else { - // Versions less than 2 didn't have an entry size, it was hard coded + // Versions less than 2 didn't have an entry size, it was hard + // coded m_kext_summary_header.entry_size = KERNEL_MODULE_ENTRY_SIZE_VERSION_1; } m_kext_summary_header.entry_count = data.GetU32(&offset); if (m_kext_summary_header.entry_count > 10000) { - // If we get an improbably large number of kexts, we're probably - // getting bad memory. + // If we get an improbably large number of kexts, we're + // probably getting bad memory. Stream *s = m_process->GetTarget().GetDebugger().GetOutputFile().get(); s->Printf("WARNING: Unable to read kext summary header, got " @@ -1155,14 +1147,11 @@ return false; } -// We've either (a) just attached to a new kernel, or (b) the kexts-changed -// breakpoint was hit -// and we need to figure out what kexts have been added or removed. -// Read the kext summaries from the inferior kernel memory, compare them against -// the -// m_known_kexts vector and update the m_known_kexts vector as needed to keep in -// sync with the -// inferior. +// We've either (a) just attached to a new kernel, or (b) the kexts- +// changed breakpoint was hit and we need to figure out what kexts have +// been added or removed. Read the kext summaries from the inferior kernel +// memory, compare them against the m_known_kexts vector and update the +// m_known_kexts vector as needed to keep in sync with the inferior. bool DynamicLoaderDarwinKernel::ParseKextSummaries( const Address &kext_summary_addr, uint32_t count) { @@ -1177,15 +1166,14 @@ if (!ReadKextSummaries(kext_summary_addr, count, kext_summaries)) return false; - // read the plugin.dynamic-loader.darwin-kernel.load-kexts setting -- if the - // user requested no - // kext loading, don't print any messages about kexts & don't try to read - // them. + // read the plugin.dynamic-loader.darwin-kernel.load-kexts setting -- if + // the user requested no kext loading, don't print any messages about + // kexts & don't try to read them. const bool load_kexts = GetGlobalProperties()->GetLoadKexts(); - // By default, all kexts we've loaded in the past are marked as "remove" and - // all of the kexts - // we just found out about from ReadKextSummaries are marked as "add". + // By default, all kexts we've loaded in the past are marked as "remove" + // and all of the kexts we just found out about from ReadKextSummaries + // are marked as "add". std::vector to_be_removed(m_known_kexts.size(), true); std::vector to_be_added(count, true); @@ -1195,8 +1183,8 @@ const uint32_t new_kexts_size = kext_summaries.size(); const uint32_t old_kexts_size = m_known_kexts.size(); - // The m_known_kexts vector may have entries that have been Cleared, - // or are a kernel. + // The m_known_kexts vector may have entries that have been Cleared, or + // are a kernel. for (uint32_t old_kext = 0; old_kext < old_kexts_size; old_kext++) { bool ignore = false; KextImageInfo &image_info = m_known_kexts[old_kext]; @@ -1213,8 +1201,8 @@ } } - // Scan over the list of kexts we just read from the kernel, note those that - // need to be added and those already loaded. + // Scan over the list of kexts we just read from the kernel, note those + // that need to be added and those already loaded. for (uint32_t new_kext = 0; new_kext < new_kexts_size; new_kext++) { bool add_this_one = true; for (uint32_t old_kext = 0; old_kext < old_kexts_size; old_kext++) { @@ -1229,10 +1217,10 @@ break; } } - // If this "kext" entry is actually an alias for the kernel -- - // the kext was compiled into the kernel or something -- then - // we don't want to load the kernel's text section at a different - // address. Ignore this kext entry. + // If this "kext" entry is actually an alias for the kernel -- the + // kext was compiled into the kernel or something -- then we don't + // want to load the kernel's text section at a different address. + // Ignore this kext entry. if (kext_summaries[new_kext].GetUUID().IsValid() && m_kernel.GetUUID().IsValid() && kext_summaries[new_kext].GetUUID() == m_kernel.GetUUID()) { @@ -1321,10 +1309,10 @@ if (s) s->Printf("."); image_info.Clear(); - // should pull it out of the KextImageInfos vector but that would - // mutate the list and invalidate - // the to_be_removed bool vector; leaving it in place once Cleared() - // is relatively harmless. + // should pull it out of the KextImageInfos vector but that + // would mutate the list and invalidate the to_be_removed bool + // vector; leaving it in place once Cleared() is relatively + // harmless. } } m_process->GetTarget().ModulesDidUnload(unloaded_module_list, false); @@ -1433,8 +1421,8 @@ } //---------------------------------------------------------------------- -// Dump the _dyld_all_image_infos members and all current image infos -// that we have parsed to the file handle provided. +// Dump the _dyld_all_image_infos members and all current image infos that +// we have parsed to the file handle provided. //---------------------------------------------------------------------- void DynamicLoaderDarwinKernel::PutToLog(Log *log) const { if (log == NULL) Index: source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp +++ source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp @@ -157,10 +157,10 @@ // Callback for the target to give it the loaded module list m_process->GetTarget().ModulesDidLoad(module_list); - // Try to set a breakpoint at the rendezvous breakpoint. - // DidLaunch uses ProbeEntry() instead. That sets a breakpoint, - // at the dyld breakpoint address, with a callback so that when hit, - // the dyld structure can be parsed. + // Try to set a breakpoint at the rendezvous breakpoint. DidLaunch uses + // ProbeEntry() instead. That sets a breakpoint, at the dyld breakpoint + // address, with a callback so that when hit, the dyld structure can be + // parsed. if (!SetRendezvousBreakpoint()) { // fail } @@ -187,8 +187,8 @@ executable->GetArchitecture()); ModuleSP module_sp(new Module(module_spec)); - // Check if the executable has changed and set it to the target executable if - // they differ. + // Check if the executable has changed and set it to the target + // executable if they differ. if (module_sp.get() && module_sp->GetUUID().IsValid() && executable->GetUUID().IsValid()) { // if the executable has changed ?? @@ -268,12 +268,11 @@ bool DynamicLoaderHexagonDYLD::SetRendezvousBreakpoint() { Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); - // This is the original code, which want to look in the rendezvous structure - // to find the breakpoint address. Its backwards for us, since we can easily - // find the breakpoint address, since it is exported in our executable. - // We however know that we cant read the Rendezvous structure until we have - // hit - // the breakpoint once. + // This is the original code, which want to look in the rendezvous + // structure to find the breakpoint address. Its backwards for us, + // since we can easily find the breakpoint address, since it is exported + // in our executable. We however know that we cant read the Rendezvous + // structure until we have hit the breakpoint once. const ConstString dyldBpName("_rtld_debug_state"); addr_t break_addr = findSymbolAddress(m_process, dyldBpName); @@ -326,8 +325,8 @@ DynamicLoaderHexagonDYLD *dyld_instance = nullptr; dyld_instance = static_cast(baton); - // if the dyld_instance is still not valid then - // try to locate it on the symbol table + // if the dyld_instance is still not valid then try to locate it on the + // symbol table if (!dyld_instance->m_rendezvous.IsValid()) { Process *proc = dyld_instance->m_process; @@ -410,7 +409,7 @@ } } -// AD: This is very different to the Static Loader code. +// AD: This is very different to the Static Loader code. // It may be wise to look over this and its relation to stack // unwinding. ThreadPlanSP @@ -480,8 +479,8 @@ return; } - // The rendezvous class doesn't enumerate the main module, so track - // that ourselves here. + // The rendezvous class doesn't enumerate the main module, so track that + // ourselves here. ModuleSP executable = GetTargetExecutable(); m_loaded_modules[executable] = m_rendezvous.GetLinkMapAddress(); @@ -517,13 +516,13 @@ return 0; } -// Here we must try to read the entry point directly from -// the elf header. This is possible if the process is not -// relocatable or dynamically linked. +// Here we must try to read the entry point directly from the elf header. +// This is possible if the process is not relocatable or dynamically +// linked. // -// an alternative is to look at the PC if we can be sure -// that we have connected when the process is at the entry point. -// I dont think that is reliable for us. +// an alternative is to look at the PC if we can be sure that we have +// connected when the process is at the entry point. I dont think that is +// reliable for us. addr_t DynamicLoaderHexagonDYLD::GetEntryPoint() { if (m_entry_point != LLDB_INVALID_ADDRESS) return m_entry_point; @@ -534,7 +533,8 @@ Module &module = *(m_process->GetTarget().GetExecutableModule().get()); // Get the object file (elf file) for this module lldb_private::ObjectFile &object = *(module.GetObjectFile()); - // Check if the file is executable (ie, not shared object or relocatable) + // Check if the file is executable (ie, not shared object or + // relocatable) if (object.IsExecutable()) { // Get the entry point address for this object lldb_private::Address entry = object.GetEntryPointAddress(); Index: source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp =================================================================== --- source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp +++ source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp @@ -116,18 +116,18 @@ return false; // When the previous and current states are consistent this is the first - // time we have been asked to update. Just take a snapshot of the currently - // loaded modules. + // time we have been asked to update. Just take a snapshot of the + // currently loaded modules. if (m_previous.state == eConsistent && m_current.state == eConsistent) return TakeSnapshot(m_soentries); - // If we are about to add or remove a shared object clear out the current - // state and take a snapshot of the currently loaded images. + // If we are about to add or remove a shared object clear out the + // current state and take a snapshot of the currently loaded images. if (m_current.state == eAdd || m_current.state == eDelete) { // this is a fudge so that we can clear the assert below. m_previous.state = eConsistent; - // We hit this assert on the 2nd run of this function after running the calc - // example + // We hit this assert on the 2nd run of this function after running + // the calc example assert(m_previous.state == eConsistent); m_soentries.clear(); m_added_soentries.clear(); @@ -136,8 +136,8 @@ } assert(m_current.state == eConsistent); - // Otherwise check the previous state to determine what to expect and update - // accordingly. + // Otherwise check the previous state to determine what to expect and + // update accordingly. if (m_previous.state == eAdd) return UpdateSOEntriesForAddition(); else if (m_previous.state == eDelete) @@ -159,9 +159,9 @@ if (!ReadSOEntryFromMemory(cursor, entry)) return false; - // Only add shared libraries and not the executable. - // On Linux this is indicated by an empty path in the entry. - // On FreeBSD it is the name of the executable. + // Only add shared libraries and not the executable. On Linux this is + // indicated by an empty path in the entry. On FreeBSD it is the name + // of the executable. if (entry.path.empty() || ::strcmp(entry.path.c_str(), m_exe_path) == 0) continue; @@ -204,9 +204,9 @@ if (!ReadSOEntryFromMemory(cursor, entry)) return false; - // Only add shared libraries and not the executable. - // On Linux this is indicated by an empty path in the entry. - // On FreeBSD it is the name of the executable. + // Only add shared libraries and not the executable. On Linux this is + // indicated by an empty path in the entry. On FreeBSD it is the name + // of the executable. if (entry.path.empty() || ::strcmp(entry.path.c_str(), m_exe_path) == 0) continue; Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -112,8 +112,8 @@ if (module_sp && !module_spec.GetUUID().IsValid() && !module_sp->GetUUID().IsValid()) { - // No UUID, we must rely upon the cached module modification - // time and the modification time of the file on disk + // No UUID, we must rely upon the cached module modification time and + // the modification time of the file on disk if (module_sp->GetModificationTime() != FileSystem::GetModificationTime(module_sp->GetFileSpec())) module_sp.reset(); @@ -197,9 +197,8 @@ for (size_t i = 0; i < num_modules; i++) { ModuleSP module_sp = target_modules.GetModuleAtIndexUnlocked(i); - // Don't remove dyld - else we'll lose our breakpoint notifying us about - // libraries - // being re-loaded... + // Don't remove dyld - else we'll lose our breakpoint notifying us + // about libraries being re-loaded... if (module_sp.get() != nullptr && module_sp.get() != dyld_sp.get()) { UnloadSections(module_sp); unloaded_modules_list.Append(module_sp); @@ -219,8 +218,8 @@ } //---------------------------------------------------------------------- -// Update the load addresses for all segments in MODULE using the -// updated INFO that is passed in. +// Update the load addresses for all segments in MODULE using the updated +// INFO that is passed in. //---------------------------------------------------------------------- bool DynamicLoaderDarwin::UpdateImageLoadAddress(Module *module, ImageInfo &info) { @@ -231,13 +230,13 @@ SectionList *section_list = image_object_file->GetSectionList(); if (section_list) { std::vector inaccessible_segment_indexes; - // We now know the slide amount, so go through all sections - // and update the load addresses with the correct values. + // We now know the slide amount, so go through all sections and + // update the load addresses with the correct values. const size_t num_segments = info.segments.size(); for (size_t i = 0; i < num_segments; ++i) { // Only load a segment if it has protections. Things like - // __PAGEZERO don't have any protections, and they shouldn't - // be slid + // __PAGEZERO don't have any protections, and they shouldn't be + // slid SectionSP section_sp( section_list->FindSectionByName(info.segments[i].name)); @@ -249,10 +248,10 @@ static ConstString g_section_name_LINKEDIT("__LINKEDIT"); if (section_sp) { - // __LINKEDIT sections from files in the shared cache - // can overlap so check to see what the segment name is - // and pass "false" so we don't warn of overlapping - // "Section" objects, and "true" for all other sections. + // __LINKEDIT sections from files in the shared cache can + // overlap so check to see what the segment name is and pass + // "false" so we don't warn of overlapping "Section" + // objects, and "true" for all other sections. const bool warn_multiple = section_sp->GetName() != g_section_name_LINKEDIT; @@ -272,11 +271,11 @@ // If the loaded the file (it changed) and we have segments that // are not readable or writeable, add them to the invalid memory - // region cache for the process. This will typically only be - // the __PAGEZERO segment in the main executable. We might be able - // to apply this more generally to more sections that have no - // protections in the future, but for now we are going to just - // do __PAGEZERO. + // region cache for the process. This will typically only be the + // __PAGEZERO segment in the main executable. We might be able to + // apply this more generally to more sections that have no + // protections in the future, but for now we are going to just do + // __PAGEZERO. if (changed && !inaccessible_segment_indexes.empty()) { for (uint32_t i = 0; i < inaccessible_segment_indexes.size(); ++i) { const uint32_t seg_idx = inaccessible_segment_indexes[i]; @@ -298,7 +297,8 @@ } } } - // We might have an in memory image that was loaded as soon as it was created + // We might have an in memory image that was loaded as soon as it was + // created if (info.load_stop_id == m_process->GetStopID()) changed = true; else if (changed) { @@ -343,9 +343,9 @@ return changed; } -// Given a JSON dictionary (from debugserver, most likely) of binary images -// loaded in the inferior -// process, add the images to the ImageInfo collection. +// Given a JSON dictionary (from debugserver, most likely) of binary +// images loaded in the inferior process, add the images to the ImageInfo +// collection. bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo( StructuredData::ObjectSP image_details, @@ -411,9 +411,8 @@ ->GetValue(); } - // Fields that aren't used by DynamicLoaderDarwin so debugserver doesn't - // currently send them - // in the reply. + // Fields that aren't used by DynamicLoaderDarwin so debugserver + // doesn't currently send them in the reply. if (mh->HasKey("flags")) image_infos[i].header.flags = @@ -453,9 +452,8 @@ segment.maxprot = seg->GetValueForKey("maxprot")->GetAsInteger()->GetValue(); - // Fields that aren't used by DynamicLoaderDarwin so debugserver doesn't - // currently send them - // in the reply. + // Fields that aren't used by DynamicLoaderDarwin so debugserver + // doesn't currently send them in the reply. if (seg->HasKey("initprot")) segment.initprot = @@ -483,23 +481,22 @@ // All sections listed in the dyld image info structure will all // either be fixed up already, or they will all be off by a single - // slide amount that is determined by finding the first segment - // that is at file offset zero which also has bytes (a file size - // that is greater than zero) in the object file. + // slide amount that is determined by finding the first segment that + // is at file offset zero which also has bytes (a file size that is + // greater than zero) in the object file. // Determine the slide amount (if any) const size_t num_sections = image_infos[i].segments.size(); for (size_t k = 0; k < num_sections; ++k) { - // Iterate through the object file sections to find the - // first section that starts of file offset zero and that - // has bytes in the file... + // Iterate through the object file sections to find the first + // section that starts of file offset zero and that has bytes in the + // file... if ((image_infos[i].segments[k].fileoff == 0 && image_infos[i].segments[k].filesize > 0) || (image_infos[i].segments[k].name == ConstString("__TEXT"))) { image_infos[i].slide = image_infos[i].address - image_infos[i].segments[k].vmaddr; - // We have found the slide amount, so we can exit - // this for loop. + // We have found the slide amount, so we can exit this for loop. break; } } @@ -520,12 +517,12 @@ const size_t image_infos_size = image_infos.size(); for (size_t i = 0; i < image_infos_size; i++) { if (image_infos[i].header.filetype == llvm::MachO::MH_DYLINKER) { - // In a "simulator" process (an x86 process that is ios/tvos/watchos) - // we will have two dyld modules -- a "dyld" that we want to keep track - // of, - // and a "dyld_sim" which we don't need to keep track of here. - // If the target is an x86 system and the OS of the dyld binary is - // ios/tvos/watchos, then we are looking at dyld_sym. + // In a "simulator" process (an x86 process that is + // ios/tvos/watchos) we will have two dyld modules -- a "dyld" that + // we want to keep track of, and a "dyld_sim" which we don't need to + // keep track of here. If the target is an x86 system and the OS of + // the dyld binary is ios/tvos/watchos, then we are looking at + // dyld_sym. // debugserver has only recently (late 2016) started sending up the // os type for each binary it sees -- so if we don't have an os @@ -543,7 +540,8 @@ } } else { - // catch-all for any other environment -- trust that dyld is actually dyld + // catch-all for any other environment -- trust that dyld is + // actually dyld dyld_idx = i; } } else if (image_infos[i].header.filetype == llvm::MachO::MH_EXECUTE) { @@ -651,10 +649,10 @@ commpage_image_module_sp->GetObjectFile() == NULL) { commpage_image_module_sp = m_process->ReadModuleFromMemory( image_infos[idx].file_spec, image_infos[idx].address); - // Always load a memory image right away in the target in case - // we end up trying to read the symbol table from memory... The - // __LINKEDIT will need to be mapped so we can figure out where - // the symbol table bits are... + // Always load a memory image right away in the target in + // case we end up trying to read the symbol table from + // memory... The __LINKEDIT will need to be mapped so we + // can figure out where the symbol table bits are... bool changed = false; UpdateImageLoadAddress(commpage_image_module_sp.get(), image_infos[idx]); @@ -669,11 +667,11 @@ } } - // UpdateImageLoadAddress will return true if any segments - // change load address. We need to check this so we don't - // mention that all loaded shared libraries are newly loaded - // each time we hit out dyld breakpoint since dyld will list all - // shared libraries each time. + // UpdateImageLoadAddress will return true if any segments change + // load address. We need to check this so we don't mention that all + // loaded shared libraries are newly loaded each time we hit out + // dyld breakpoint since dyld will list all shared libraries each + // time. if (UpdateImageLoadAddress(image_module_sp.get(), image_infos[idx])) { target_images.AppendIfNeeded(image_module_sp); loaded_module_list.AppendIfNeeded(image_module_sp); @@ -691,18 +689,19 @@ } //---------------------------------------------------------------------- -// On Mac OS X libobjc (the Objective-C runtime) has several critical dispatch -// functions written in hand-written assembly, and also have hand-written unwind -// information in the eh_frame section. Normally we prefer analyzing the -// assembly instructions of a currently executing frame to unwind from that -// frame -- -// but on hand-written functions this profiling can fail. We should use the -// eh_frame instructions for these functions all the time. +// On Mac OS X libobjc (the Objective-C runtime) has several critical +// dispatch functions written in hand-written assembly, and also have +// hand-written unwind information in the eh_frame section. Normally we +// prefer analyzing the assembly instructions of a currently executing +// frame to unwind from that frame -- but on hand-written functions this +// profiling can fail. We should use the eh_frame instructions for these +// functions all the time. // -// As an aside, it would be better if the eh_frame entries had a flag (or were -// extensible so they could have an Apple-specific flag) which indicates that -// the instructions are asynchronous -- accurate at every instruction, instead -// of our normal default assumption that they are not. +// As an aside, it would be better if the eh_frame entries had a flag (or +// were extensible so they could have an Apple-specific flag) which +// indicates that the instructions are asynchronous -- accurate at every +// instruction, instead of our normal default assumption that they are +// not. //---------------------------------------------------------------------- bool DynamicLoaderDarwin::AlwaysRelyOnEHUnwindInfo(SymbolContext &sym_ctx) { @@ -935,8 +934,8 @@ } } } else if (current_symbol->GetType() == eSymbolTypeReExported) { - // I am not sure we could ever end up stopped AT a re-exported symbol. - // But just in case: + // I am not sure we could ever end up stopped AT a re-exported + // symbol. But just in case: const Symbol *actual_symbol = current_symbol->ResolveReExportedSymbol(*(target_sp.get())); @@ -956,8 +955,8 @@ } if (addresses.size() > 0) { - // First check whether any of the addresses point to Indirect symbols, and - // if they do, resolve them: + // First check whether any of the addresses point to Indirect + // symbols, and if they do, resolve them: std::vector load_addrs; for (Address address : addresses) { Symbol *symbol = address.CalculateSymbolContextSymbol(); Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp @@ -29,9 +29,9 @@ using namespace lldb_private; //---------------------------------------------------------------------- -// Create an instance of this class. This function is filled into -// the plugin info class that gets handed out by the plugin factory and -// allows the lldb to instantiate an instance of this class. +// Create an instance of this class. This function is filled into the +// plugin info class that gets handed out by the plugin factory and allows +// the lldb to instantiate an instance of this class. //---------------------------------------------------------------------- DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process *process, bool force) { @@ -144,17 +144,18 @@ } //---------------------------------------------------------------------- -// Try and figure out where dyld is by first asking the Process -// if it knows (which currently calls down in the lldb::Process -// to get the DYLD info (available on SnowLeopard only). If that fails, -// then check in the default addresses. +// Try and figure out where dyld is by first asking the Process if it +// knows (which currently calls down in the lldb::Process to get the DYLD +// info (available on SnowLeopard only). If that fails, then check in the +// default addresses. //---------------------------------------------------------------------- void DynamicLoaderMacOS::DoInitialImageFetch() { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); - // Remove any binaries we pre-loaded in the Target before launching/attaching. - // If the same binaries are present in the process, we'll get them from the - // shared module cache, we won't need to re-load them from disk. + // Remove any binaries we pre-loaded in the Target before + // launching/attaching. If the same binaries are present in the process, + // we'll get them from the shared module cache, we won't need to re-load + // them from disk. UnloadAllImages(); StructuredData::ObjectSP all_image_info_json_sp( @@ -184,20 +185,19 @@ //---------------------------------------------------------------------- // Static callback function that gets called when our DYLD notification -// breakpoint gets hit. We update all of our image infos and then -// let our super class DynamicLoader class decide if we should stop -// or not (based on global preference). +// breakpoint gets hit. We update all of our image infos and then let our +// super class DynamicLoader class decide if we should stop or not (based +// on global preference). //---------------------------------------------------------------------- bool DynamicLoaderMacOS::NotifyBreakpointHit(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id) { - // Let the event know that the images have changed - // DYLD passes three arguments to the notification breakpoint. - // Arg1: enum dyld_notify_mode mode - 0 = adding, 1 = removing, 2 = remove all - // Arg2: unsigned long icount - Number of shared libraries - // added/removed - // Arg3: uint64_t mach_headers[] - Array of load addresses of binaries + // Let the event know that the images have changed DYLD passes three + // arguments to the notification breakpoint. Arg1: enum dyld_notify_mode + // mode - 0 = adding, 1 = removing, 2 = remove all Arg2: unsigned long + // icount - Number of shared libraries added/removed Arg3: + // uint64_t mach_headers[] - Array of load addresses of binaries // added/removed DynamicLoaderMacOS *dyld_instance = (DynamicLoaderMacOS *)baton; @@ -217,15 +217,16 @@ const lldb::ABISP &abi = process->GetABI(); if (abi) { - // Build up the value array to store the three arguments given above, then - // get the values from the ABI: + // Build up the value array to store the three arguments given above, + // then get the values from the ABI: ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext(); ValueList argument_values; Value mode_value; // enum dyld_notify_mode { dyld_notify_adding=0, - // dyld_notify_removing=1, dyld_notify_remove_all=2 }; + // dyld_notify_removing=1, + // dyld_notify_remove_all=2 }; Value count_value; // unsigned long count Value headers_value; // uint64_t machHeaders[] (aka void*) @@ -260,8 +261,8 @@ uint32_t dyld_mode = argument_values.GetValueAtIndex(0)->GetScalar().UInt(-1); if (dyld_mode != static_cast(-1)) { - // Okay the mode was right, now get the number of elements, and the - // array of new elements... + // Okay the mode was right, now get the number of elements, and + // the array of new elements... uint32_t image_infos_count = argument_values.GetValueAtIndex(1)->GetScalar().UInt(-1); if (image_infos_count != static_cast(-1)) { @@ -328,8 +329,8 @@ } } -// Dump the _dyld_all_image_infos members and all current image infos -// that we have parsed to the file handle provided. +// Dump the _dyld_all_image_infos members and all current image infos that +// we have parsed to the file handle provided. //---------------------------------------------------------------------- void DynamicLoaderMacOS::PutToLog(Log *log) const { if (log == NULL) @@ -406,7 +407,8 @@ const size_t num_modules = target_modules.GetSize(); ConstString g_libdyld_name("libdyld.dylib"); - // Find any modules named "libdyld.dylib" and look for the symbol there first + // Find any modules named "libdyld.dylib" and look for the symbol there + // first for (size_t i = 0; i < num_modules; i++) { Module *module_pointer = target_modules.GetModulePointerAtIndexUnlocked(i); if (module_pointer) { @@ -432,9 +434,9 @@ } } - // Default assumption is that it is OK to load images. - // Only say that we cannot load images if we find the symbol in libdyld and it - // indicates that we cannot. + // Default assumption is that it is OK to load images. Only say that we + // cannot load images if we find the symbol in libdyld and it indicates + // that we cannot. if (symbol_address != LLDB_INVALID_ADDRESS) { { @@ -445,11 +447,11 @@ } } } else { - // If we were unable to find _dyld_global_lock_held in any modules, or it is - // not loaded into memory yet, we may be at process startup (sitting - // at _dyld_start) - so we should not allow dlopen calls. - // But if we found more than one module then we are clearly past _dyld_start - // so in that case we'll default to "it's safe". + // If we were unable to find _dyld_global_lock_held in any modules, or + // it is not loaded into memory yet, we may be at process startup + // (sitting at _dyld_start) - so we should not allow dlopen calls. + // But if we found more than one module then we are clearly past + // _dyld_start so in that case we'll default to "it's safe". if (num_modules <= 1) error.SetErrorString("could not find the dyld library or " "the dyld lock symbol"); @@ -472,7 +474,9 @@ info_dict = info->GetAsDictionary(); } - // {"shared_cache_base_address":140735683125248,"shared_cache_uuid":"DDB8D70C-C9A2-3561-B2C8-BE48A4F33F96","no_shared_cache":false,"shared_cache_private_cache":false} + // {"shared_cache_base_address":140735683125248,"shared_cache_uuid + // ":"DDB8D70C- + // C9A2-3561-B2C8-BE48A4F33F96","no_shared_cache":false,"shared_cache_private_cache":false} if (info_dict && info_dict->HasKey("shared_cache_uuid") && info_dict->HasKey("no_shared_cache") && Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -49,9 +49,9 @@ using namespace lldb_private; //---------------------------------------------------------------------- -// Create an instance of this class. This function is filled into -// the plugin info class that gets handed out by the plugin factory and -// allows the lldb to instantiate an instance of this class. +// Create an instance of this class. This function is filled into the +// plugin info class that gets handed out by the plugin factory and allows +// the lldb to instantiate an instance of this class. //---------------------------------------------------------------------- DynamicLoader *DynamicLoaderMacOSXDYLD::CreateInstance(Process *process, bool force) { @@ -117,14 +117,15 @@ if (m_process) { // If we are stopped after an exec, we will have only one thread... if (m_process->GetThreadList().GetSize() == 1) { - // We know if a process has exec'ed if our "m_dyld_all_image_infos_addr" - // value differs from the Process' image info address. When a process - // execs itself it might cause a change if ASLR is enabled. + // We know if a process has exec'ed if our + // "m_dyld_all_image_infos_addr" value differs from the Process' + // image info address. When a process execs itself it might cause a + // change if ASLR is enabled. const addr_t shlib_addr = m_process->GetImageInfoAddress(); if (m_process_image_addr_is_all_images_infos == true && shlib_addr != m_dyld_all_image_infos_addr) { - // The image info address from the process is the 'dyld_all_image_infos' - // address and it has changed. + // The image info address from the process is the + // 'dyld_all_image_infos' address and it has changed. did_exec = true; } else if (m_process_image_addr_is_all_images_infos == false && shlib_addr == m_dyld.address) { @@ -133,7 +134,8 @@ did_exec = true; } else { // ASLR might be disabled and dyld could have ended up in the same - // location. We should try and detect if we are stopped at '_dyld_start' + // location. We should try and detect if we are stopped at + // '_dyld_start' ThreadSP thread_sp(m_process->GetThreadList().GetThreadAtIndex(0)); if (thread_sp) { lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0)); @@ -185,16 +187,15 @@ } //---------------------------------------------------------------------- -// Try and figure out where dyld is by first asking the Process -// if it knows (which currently calls down in the lldb::Process -// to get the DYLD info (available on SnowLeopard only). If that fails, -// then check in the default addresses. +// Try and figure out where dyld is by first asking the Process if it +// knows (which currently calls down in the lldb::Process to get the DYLD +// info (available on SnowLeopard only). If that fails, then check in the +// default addresses. //---------------------------------------------------------------------- void DynamicLoaderMacOSXDYLD::DoInitialImageFetch() { if (m_dyld_all_image_infos_addr == LLDB_INVALID_ADDRESS) { - // Check the image info addr as it might point to the - // mach header for dyld, or it might point to the - // dyld_all_image_infos struct + // Check the image info addr as it might point to the mach header for + // dyld, or it might point to the dyld_all_image_infos struct const addr_t shlib_addr = m_process->GetImageInfoAddress(); if (shlib_addr != LLDB_INVALID_ADDRESS) { ByteOrder byte_order = @@ -295,8 +296,8 @@ if (dyld_module_sp) { target.GetImages().AppendIfNeeded(dyld_module_sp); - // At this point we should have read in dyld's module, and so we should - // set breakpoints in it: + // At this point we should have read in dyld's module, and so we + // should set breakpoints in it: ModuleList modules; modules.Append(dyld_module_sp); target.ModulesDidLoad(modules); @@ -315,18 +316,18 @@ //---------------------------------------------------------------------- // Static callback function that gets called when our DYLD notification -// breakpoint gets hit. We update all of our image infos and then -// let our super class DynamicLoader class decide if we should stop -// or not (based on global preference). +// breakpoint gets hit. We update all of our image infos and then let our +// super class DynamicLoader class decide if we should stop or not (based +// on global preference). //---------------------------------------------------------------------- bool DynamicLoaderMacOSXDYLD::NotifyBreakpointHit( void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id) { - // Let the event know that the images have changed - // DYLD passes three arguments to the notification breakpoint. - // Arg1: enum dyld_image_mode mode - 0 = adding, 1 = removing - // Arg2: uint32_t infoCount - Number of shared libraries added - // Arg3: dyld_image_info info[] - Array of structs of the form: + // Let the event know that the images have changed DYLD passes three + // arguments to the notification breakpoint. Arg1: enum dyld_image_mode + // mode - 0 = adding, 1 = removing Arg2: uint32_t infoCount - + // Number of shared libraries added Arg3: dyld_image_info info[] - + // Array of structs of the form: // const struct mach_header // *imageLoadAddress // const char *imageFilePath @@ -334,12 +335,11 @@ DynamicLoaderMacOSXDYLD *dyld_instance = (DynamicLoaderMacOSXDYLD *)baton; - // First step is to see if we've already initialized the all image infos. If - // we haven't then this function - // will do so and return true. In the course of initializing the - // all_image_infos it will read the complete - // current state, so we don't need to figure out what has changed from the - // data passed in to us. + // First step is to see if we've already initialized the all image + // infos. If we haven't then this function will do so and return true. + // In the course of initializing the all_image_infos it will read the + // complete current state, so we don't need to figure out what has + // changed from the data passed in to us. ExecutionContext exe_ctx(context->exe_ctx_ref); Process *process = exe_ctx.GetProcessPtr(); @@ -354,8 +354,8 @@ const lldb::ABISP &abi = process->GetABI(); if (abi) { - // Build up the value array to store the three arguments given above, then - // get the values from the ABI: + // Build up the value array to store the three arguments given above, + // then get the values from the ABI: ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext(); @@ -382,17 +382,16 @@ uint32_t dyld_mode = argument_values.GetValueAtIndex(0)->GetScalar().UInt(-1); if (dyld_mode != static_cast(-1)) { - // Okay the mode was right, now get the number of elements, and the - // array of new elements... + // Okay the mode was right, now get the number of elements, and + // the array of new elements... uint32_t image_infos_count = argument_values.GetValueAtIndex(1)->GetScalar().UInt(-1); if (image_infos_count != static_cast(-1)) { - // Got the number added, now go through the array of added elements, - // putting out the mach header - // address, and adding the image. - // Note, I'm not putting in logging here, since the AddModules & - // RemoveModules functions do - // all the logging internally. + // Got the number added, now go through the array of added + // elements, putting out the mach header address, and adding the + // image. Note, I'm not putting in logging here, since the + // AddModules & RemoveModules functions do all the logging + // internally. lldb::addr_t image_infos_addr = argument_values.GetValueAtIndex(2)->GetScalar().ULongLong(); @@ -468,11 +467,11 @@ 4) { m_dyld_all_image_infos.version = data.GetU32(&offset); // If anything in the high byte is set, we probably got the byte - // order incorrect (the process might not have it set correctly - // yet due to attaching to a program without a specified file). + // order incorrect (the process might not have it set correctly yet + // due to attaching to a program without a specified file). if (m_dyld_all_image_infos.version & 0xff000000) { - // We have guessed the wrong byte order. Swap it and try - // reading the version again. + // We have guessed the wrong byte order. Swap it and try reading + // the version again. if (byte_order == eByteOrderLittle) byte_order = eByteOrderBig; else @@ -508,21 +507,18 @@ uint64_t dyld_all_image_infos_addr = data.GetPointer(&offset); // When we started, we were given the actual address of the - // all_image_infos - // struct (probably via TASK_DYLD_INFO) in memory - this address is - // stored in - // m_dyld_all_image_infos_addr and is the most accurate address we have. - - // We read the dyld_all_image_infos struct from memory; it contains its - // own address. - // If the address in the struct does not match the actual address, - // the dyld we're looking at has been loaded at a different location - // (slid) from - // where it intended to load. The addresses in the dyld_all_image_infos - // struct - // are the original, non-slid addresses, and need to be adjusted. Most - // importantly - // the address of dyld and the notification address need to be adjusted. + // all_image_infos struct (probably via TASK_DYLD_INFO) in memory + // - this address is stored in m_dyld_all_image_infos_addr and is + // the most accurate address we have. + + // We read the dyld_all_image_infos struct from memory; it + // contains its own address. If the address in the struct does not + // match the actual address, the dyld we're looking at has been + // loaded at a different location (slid) from where it intended to + // load. The addresses in the dyld_all_image_infos struct are the + // original, non-slid addresses, and need to be adjusted. Most + // importantly the address of dyld and the notification address + // need to be adjusted. if (dyld_all_image_infos_addr != m_dyld_all_image_infos_addr) { uint64_t image_infos_offset = @@ -596,8 +592,8 @@ if (m_process->GetStopID() == m_dyld_image_infos_stop_id) return true; - // First read in the image_infos for the removed modules, and their headers & - // load commands. + // First read in the image_infos for the removed modules, and their + // headers & load commands. if (!ReadImageInfos(image_infos_addr, image_infos_count, image_infos)) { if (log) log->PutCString("Failed reading image infos array."); @@ -615,29 +611,28 @@ image_infos[idx].PutToLog(log); } - // Remove this image_infos from the m_all_image_infos. We do the comparison - // by address - // rather than by file spec because we can have many modules with the same - // "file spec" in the - // case that they are modules loaded from memory. + // Remove this image_infos from the m_all_image_infos. We do the + // comparison by address rather than by file spec because we can have + // many modules with the same "file spec" in the case that they are + // modules loaded from memory. // - // Also copy over the uuid from the old entry to the removed entry so we can - // use it to lookup the module in the module list. + // Also copy over the uuid from the old entry to the removed entry so + // we can use it to lookup the module in the module list. ImageInfo::collection::iterator pos, end = m_dyld_image_infos.end(); for (pos = m_dyld_image_infos.begin(); pos != end; pos++) { if (image_infos[idx].address == (*pos).address) { image_infos[idx].uuid = (*pos).uuid; - // Add the module from this image_info to the "unloaded_module_list". - // We'll remove them all at - // one go later on. + // Add the module from this image_info to the + // "unloaded_module_list". We'll remove them all at one go later + // on. ModuleSP unload_image_module_sp( FindTargetModuleForImageInfo(image_infos[idx], false, NULL)); if (unload_image_module_sp.get()) { - // When we unload, be sure to use the image info from the old list, - // since that has sections correctly filled in. + // When we unload, be sure to use the image info from the old + // list, since that has sections correctly filled in. UnloadModuleSections(unload_image_module_sp.get(), *pos); unloaded_module_list.AppendIfNeeded(unload_image_module_sp); } else { @@ -714,10 +709,10 @@ //---------------------------------------------------------------------- // If we have found where the "_dyld_all_image_infos" lives in memory, -// read the current info from it, and then update all image load -// addresses (or lack thereof). Only do this if this is the first time -// we're reading the dyld infos. Return true if we actually read anything, -// and false otherwise. +// read the current info from it, and then update all image load addresses +// (or lack thereof). Only do this if this is the first time we're +// reading the dyld infos. Return true if we actually read anything, and +// false otherwise. //---------------------------------------------------------------------- bool DynamicLoaderMacOSXDYLD::InitializeFromAllImageInfos() { Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER)); @@ -734,9 +729,9 @@ return true; if (m_dyld_all_image_infos.dylib_info_addr == 0) { - // DYLD is updating the images now. So we should say we have no images, - // and then we'll - // figure it out when we hit the added breakpoint. + // DYLD is updating the images now. So we should say we have no + // images, and then we'll figure it out when we hit the added + // breakpoint. return false; } else { if (!AddModulesUsingImageInfosAddress( @@ -747,15 +742,13 @@ } } - // Now we have one more bit of business. If there is a library left in the - // images for our target that - // doesn't have a load address, then it must be something that we were - // expecting to load (for instance we - // read a load command for it) but it didn't in fact load - probably because - // DYLD_*_PATH pointed - // to an equivalent version. We don't want it to stay in the target's - // module list or it will confuse - // us, so unload it here. + // Now we have one more bit of business. If there is a library left + // in the images for our target that doesn't have a load address, then + // it must be something that we were expecting to load (for instance + // we read a load command for it) but it didn't in fact load - + // probably because DYLD_*_PATH pointed to an equivalent version. We + // don't want it to stay in the target's module list or it will + // confuse us, so unload it here. Target &target = m_process->GetTarget(); const ModuleList &target_modules = target.GetImages(); ModuleList not_loaded_modules; @@ -800,8 +793,8 @@ lldb::offset_t offset = 0; ::memset(header, 0, sizeof(llvm::MachO::mach_header)); - // Get the magic byte unswapped so we can figure out what we are dealing - // with + // Get the magic byte unswapped so we can figure out what we are + // dealing with DataExtractor data(header_bytes.GetBytes(), header_bytes.GetByteSize(), endian::InlHostByteOrder(), 4); header->magic = data.GetU32(&offset); @@ -840,8 +833,8 @@ load_cmd_data_sp->GetByteSize(), error); if (load_cmd_bytes_read == header->sizeofcmds) { - // Set the load command data and also set the correct endian - // swap settings and the correct address size + // Set the load command data and also set the correct endian swap + // settings and the correct address size load_command_data->SetData(load_cmd_data_sp, 0, header->sizeofcmds); load_command_data->SetByteOrder(data.GetByteOrder()); load_command_data->SetAddressByteSize(data.GetAddressByteSize()); @@ -867,8 +860,8 @@ dylib_info.Clear(true); for (cmd_idx = 0; cmd_idx < dylib_info.header.ncmds; cmd_idx++) { - // Clear out any load command specific data from DYLIB_INFO since - // we are about to read it. + // Clear out any load command specific data from DYLIB_INFO since we + // are about to read it. if (data.ValidOffsetForDataOfSize(offset, sizeof(llvm::MachO::load_command))) { @@ -880,8 +873,8 @@ case llvm::MachO::LC_SEGMENT: { segment.name.SetTrimmedCStringWithLength( (const char *)data.GetData(&offset, 16), 16); - // We are putting 4 uint32_t values 4 uint64_t values so - // we have to use multiple 32 bit gets below. + // We are putting 4 uint32_t values 4 uint64_t values so we have + // to use multiple 32 bit gets below. segment.vmaddr = data.GetU32(&offset); segment.vmsize = data.GetU32(&offset); segment.fileoff = data.GetU32(&offset); @@ -922,24 +915,22 @@ } } - // All sections listed in the dyld image info structure will all - // either be fixed up already, or they will all be off by a single - // slide amount that is determined by finding the first segment - // that is at file offset zero which also has bytes (a file size - // that is greater than zero) in the object file. + // All sections listed in the dyld image info structure will all either + // be fixed up already, or they will all be off by a single slide amount + // that is determined by finding the first segment that is at file + // offset zero which also has bytes (a file size that is greater than + // zero) in the object file. // Determine the slide amount (if any) const size_t num_sections = dylib_info.segments.size(); for (size_t i = 0; i < num_sections; ++i) { - // Iterate through the object file sections to find the - // first section that starts of file offset zero and that - // has bytes in the file... + // Iterate through the object file sections to find the first section + // that starts of file offset zero and that has bytes in the file... if ((dylib_info.segments[i].fileoff == 0 && dylib_info.segments[i].filesize > 0) || (dylib_info.segments[i].name == ConstString("__TEXT"))) { dylib_info.slide = dylib_info.address - dylib_info.segments[i].vmaddr; - // We have found the slide amount, so we can exit - // this for loop. + // We have found the slide amount, so we can exit this for loop. break; } } @@ -981,14 +972,15 @@ UpdateImageLoadAddress(exe_module_sp.get(), image_infos[exe_idx]); if (exe_module_sp.get() != target.GetExecutableModulePointer()) { - // Don't load dependent images since we are in dyld where we will know - // and find out about all images that are loaded. Also when setting the - // executable module, it will clear the targets module list, and if we - // have an in memory dyld module, it will get removed from the list - // so we will need to add it back after setting the executable module, - // so we first try and see if we already have a weak pointer to the - // dyld module, make it into a shared pointer, then add the executable, - // then re-add it back to make sure it is always in the list. + // Don't load dependent images since we are in dyld where we will + // know and find out about all images that are loaded. Also when + // setting the executable module, it will clear the targets module + // list, and if we have an in memory dyld module, it will get + // removed from the list so we will need to add it back after + // setting the executable module, so we first try and see if we + // already have a weak pointer to the dyld module, make it into a + // shared pointer, then add the executable, then re-add it back to + // make sure it is always in the list. ModuleSP dyld_module_sp(GetDYLDModule()); const bool get_dependent_images = false; @@ -1009,8 +1001,8 @@ } //---------------------------------------------------------------------- -// Dump the _dyld_all_image_infos members and all current image infos -// that we have parsed to the file handle provided. +// Dump the _dyld_all_image_infos members and all current image infos that +// we have parsed to the file handle provided. //---------------------------------------------------------------------- void DynamicLoaderMacOSXDYLD::PutToLog(Log *log) const { if (log == NULL) @@ -1039,10 +1031,10 @@ if (m_break_id == LLDB_INVALID_BREAK_ID) { if (m_dyld_all_image_infos.notification != LLDB_INVALID_ADDRESS) { Address so_addr; - // Set the notification breakpoint and install a breakpoint - // callback function that will get called each time the - // breakpoint gets hit. We will use this to track when shared - // libraries get loaded/unloaded. + // Set the notification breakpoint and install a breakpoint callback + // function that will get called each time the breakpoint gets hit. + // We will use this to track when shared libraries get + // loaded/unloaded. bool resolved = m_process->GetTarget().ResolveLoadAddress( m_dyld_all_image_infos.notification, so_addr); if (!resolved) { @@ -1071,14 +1063,14 @@ Status DynamicLoaderMacOSXDYLD::CanLoadImage() { Status error; - // In order for us to tell if we can load a shared library we verify that - // the dylib_info_addr isn't zero (which means no shared libraries have - // been set yet, or dyld is currently mucking with the shared library list). + // In order for us to tell if we can load a shared library we verify + // that the dylib_info_addr isn't zero (which means no shared libraries + // have been set yet, or dyld is currently mucking with the shared + // library list). if (ReadAllImageInfosStructure()) { // TODO: also check the _dyld_global_lock_held variable in - // libSystem.B.dylib? - // TODO: check the malloc lock? - // TODO: check the objective C lock? + // libSystem.B.dylib? TODO: check the malloc lock? TODO: check the + // objective C lock? if (m_dyld_all_image_infos.dylib_info_addr != 0) return error; // Success } @@ -1098,14 +1090,12 @@ if (m_process) { addr_t all_image_infos = m_process->GetImageInfoAddress(); - // The address returned by GetImageInfoAddress may be the address of dyld - // (don't want) - // or it may be the address of the dyld_all_image_infos structure (want). - // The first four - // bytes will be either the version field (all_image_infos) or a Mach-O file - // magic constant. - // Version 13 and higher of dyld_all_image_infos is required to get the - // sharedCacheUUID field. + // The address returned by GetImageInfoAddress may be the address of + // dyld (don't want) or it may be the address of the + // dyld_all_image_infos structure (want). The first four bytes will be + // either the version field (all_image_infos) or a Mach-O file magic + // constant. Version 13 and higher of dyld_all_image_infos is required + // to get the sharedCacheUUID field. Status err; uint32_t version_or_magic = @@ -1153,10 +1143,9 @@ // // add - // NB: sharedCacheBaseAddress is the next field in dyld_all_image_infos - // after - // sharedCacheUUID -- that is, 16 bytes after it, if we wanted to fetch - // it. + // NB: sharedCacheBaseAddress is the next field in + // dyld_all_image_infos after sharedCacheUUID -- that is, 16 bytes + // after it, if we wanted to fetch it. } } return false; Index: source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp =================================================================== --- source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp +++ source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp @@ -39,14 +39,14 @@ return LLDB_INVALID_ADDRESS; } - // Try to get it from our process. This might be a remote process and might - // grab it via some remote-specific mechanism. + // Try to get it from our process. This might be a remote process and + // might grab it via some remote-specific mechanism. info_location = process->GetImageInfoAddress(); if (log) log->Printf("%s info_location = 0x%" PRIx64, __FUNCTION__, info_location); - // If the process fails to return an address, fall back to seeing if the local - // object file can help us find it. + // If the process fails to return an address, fall back to seeing if the + // local object file can help us find it. if (info_location == LLDB_INVALID_ADDRESS) { Target *target = &process->GetTarget(); if (target) { @@ -191,18 +191,18 @@ return false; // When the previous and current states are consistent this is the first - // time we have been asked to update. Just take a snapshot of the currently - // loaded modules. + // time we have been asked to update. Just take a snapshot of the + // currently loaded modules. if (m_previous.state == eConsistent && m_current.state == eConsistent) return fromRemote ? SaveSOEntriesFromRemote(module_list) : TakeSnapshot(m_soentries); - // If we are about to add or remove a shared object clear out the current - // state and take a snapshot of the currently loaded images. + // If we are about to add or remove a shared object clear out the + // current state and take a snapshot of the currently loaded images. if (m_current.state == eAdd || m_current.state == eDelete) { // Some versions of the android dynamic linker might send two - // notifications with state == eAdd back to back. Ignore them - // until we get an eConsistent notification. + // notifications with state == eAdd back to back. Ignore them until we + // get an eConsistent notification. if (!(m_previous.state == eConsistent || (m_previous.state == eAdd && m_current.state == eDelete))) return false; @@ -217,8 +217,8 @@ } assert(m_current.state == eConsistent); - // Otherwise check the previous state to determine what to expect and update - // accordingly. + // Otherwise check the previous state to determine what to expect and + // update accordingly. if (m_previous.state == eAdd) return fromRemote ? AddSOEntriesFromRemote(module_list) : AddSOEntries(); else if (m_previous.state == eDelete) @@ -376,8 +376,8 @@ } bool DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry &entry) { - // On some systes the executable is indicated by an empty path in the entry. - // On others it is the full path to the executable. + // On some systes the executable is indicated by an empty path in the + // entry. On others it is the full path to the executable. auto triple = m_process->GetTarget().GetArchitecture().GetTriple(); switch (triple.getOS()) { @@ -399,7 +399,8 @@ if (m_current.map_addr == 0) return false; - // Clear previous entries since we are about to obtain an up to date list. + // Clear previous entries since we are about to obtain an up to date + // list. entry_list.clear(); for (addr_t cursor = m_current.map_addr; cursor != 0; cursor = entry.next) { @@ -448,14 +449,12 @@ return str; } -// Returns true if the load bias reported by the linker is incorrect for the -// given entry. This -// function is used to handle cases where we want to work around a bug in the -// system linker. +// Returns true if the load bias reported by the linker is incorrect for +// the given entry. This function is used to handle cases where we want to +// work around a bug in the system linker. static bool isLoadBiasIncorrect(Target &target, const std::string &file_path) { - // On Android L (API 21, 22) the load address of the "/system/bin/linker" - // isn't filled in - // correctly. + // On Android L (API 21, 22) the load address of the + // "/system/bin/linker" isn't filled in correctly. uint32_t os_major = 0, os_minor = 0, os_update = 0; if (target.GetArchitecture().GetTriple().isAndroid() && target.GetPlatform()->GetOSVersion(os_major, os_minor, os_update) && @@ -470,9 +469,8 @@ void DYLDRendezvous::UpdateBaseAddrIfNecessary(SOEntry &entry, std::string const &file_path) { - // If the load bias reported by the linker is incorrect then fetch the load - // address of the file - // from the proc file system. + // If the load bias reported by the linker is incorrect then fetch the + // load address of the file from the proc file system. if (isLoadBiasIncorrect(m_process->GetTarget(), file_path)) { lldb::addr_t load_addr = LLDB_INVALID_ADDRESS; bool is_loaded = false; Index: source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -155,8 +155,8 @@ LoadAllCurrentModules(); if (!SetRendezvousBreakpoint()) { - // If we cannot establish rendezvous breakpoint right now - // we'll try again at entry point. + // If we cannot establish rendezvous breakpoint right now we'll try + // again at entry point. ProbeEntry(); } @@ -199,8 +199,8 @@ __FUNCTION__); if (!SetRendezvousBreakpoint()) { - // If we cannot establish rendezvous breakpoint right now - // we'll try again at entry point. + // If we cannot establish rendezvous breakpoint right now we'll try + // again at entry point. ProbeEntry(); } @@ -258,12 +258,12 @@ } } -// The runtime linker has run and initialized the rendezvous structure once the -// process has hit its entry point. When we hit the corresponding breakpoint we -// interrogate the rendezvous structure to get the load addresses of all -// dependent modules for the process. Similarly, we can discover the runtime -// linker function and setup a breakpoint to notify us of any dynamically loaded -// modules (via dlopen). +// The runtime linker has run and initialized the rendezvous structure +// once the process has hit its entry point. When we hit the +// corresponding breakpoint we interrogate the rendezvous structure to get +// the load addresses of all dependent modules for the process. +// Similarly, we can discover the runtime linker function and setup a +// breakpoint to notify us of any dynamically loaded modules (via dlopen). bool DynamicLoaderPOSIXDYLD::EntryBreakpointHit( void *baton, StoppointCallbackContext *context, user_id_t break_id, user_id_t break_loc_id) { @@ -280,14 +280,12 @@ dyld_instance->m_process ? dyld_instance->m_process->GetID() : LLDB_INVALID_PROCESS_ID); - // Disable the breakpoint --- if a stop happens right after this, which we've - // seen on occasion, we don't - // want the breakpoint stepping thread-plan logic to show a breakpoint - // instruction at the disassembled - // entry point to the program. Disabling it prevents it. (One-shot is not - // enough - one-shot removal logic - // only happens after the breakpoint goes public, which wasn't happening in - // our scenario). + // Disable the breakpoint --- if a stop happens right after this, which + // we've seen on occasion, we don't want the breakpoint stepping thread- + // plan logic to show a breakpoint instruction at the disassembled entry + // point to the program. Disabling it prevents it. (One-shot is not + // enough - one-shot removal logic only happens after the breakpoint + // goes public, which wasn't happening in our scenario). if (dyld_instance->m_process) { BreakpointSP breakpoint_sp = dyld_instance->m_process->GetTarget().GetBreakpointByID(break_id); @@ -345,8 +343,8 @@ return false; } - // Function names from different dynamic loaders that are known - // to be used as rendezvous between the loader and debuggers. + // Function names from different dynamic loaders that are known to be + // used as rendezvous between the loader and debuggers. static std::vector DebugStateCandidates{ "_dl_debug_state", "rtld_db_dlactivity", "__dl_rtld_db_dlactivity", "r_debug_state", "_r_debug_state", "_rtld_debug_state", @@ -572,8 +570,8 @@ return; } - // The rendezvous class doesn't enumerate the main module, so track - // that ourselves here. + // The rendezvous class doesn't enumerate the main module, so track that + // ourselves here. ModuleSP executable = GetTargetExecutable(); m_loaded_modules[executable] = m_rendezvous.GetLinkMapAddress(); Index: source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp =================================================================== --- source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp +++ source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp @@ -19,9 +19,9 @@ using namespace lldb_private; //---------------------------------------------------------------------- -// Create an instance of this class. This function is filled into -// the plugin info class that gets handed out by the plugin factory and -// allows the lldb to instantiate an instance of this class. +// Create an instance of this class. This function is filled into the +// plugin info class that gets handed out by the plugin factory and allows +// the lldb to instantiate an instance of this class. //---------------------------------------------------------------------- DynamicLoader *DynamicLoaderStatic::CreateInstance(Process *process, bool force) { @@ -96,18 +96,18 @@ SectionList *section_list = image_object_file->GetSectionList(); if (section_list) { // All sections listed in the dyld image info structure will all - // either be fixed up already, or they will all be off by a single - // slide amount that is determined by finding the first segment - // that is at file offset zero which also has bytes (a file size - // that is greater than zero) in the object file. + // either be fixed up already, or they will all be off by a + // single slide amount that is determined by finding the first + // segment that is at file offset zero which also has bytes (a + // file size that is greater than zero) in the object file. // Determine the slide amount (if any) const size_t num_sections = section_list->GetSize(); size_t sect_idx = 0; for (sect_idx = 0; sect_idx < num_sections; ++sect_idx) { - // Iterate through the object file sections to find the - // first section that starts of file offset zero and that - // has bytes in the file... + // Iterate through the object file sections to find the first + // section that starts of file offset zero and that has bytes + // in the file... SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx)); if (section_sp) { if (m_process->GetTarget().SetSectionLoadAddress( Index: source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp +++ source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp @@ -96,9 +96,9 @@ return ThreadPlanSP(); } - // First instruction in a x86 Windows trampoline is going to be an indirect - // jump through the IAT and the next one will be a nop (usually there for - // alignment purposes). e.g.: + // First instruction in a x86 Windows trampoline is going to be an + // indirect jump through the IAT and the next one will be a nop (usually + // there for alignment purposes). e.g.: // 0x70ff4cfc <+956>: jmpl *0x7100c2a8 // 0x70ff4d02 <+962>: nop Index: source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp +++ source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp @@ -225,9 +225,8 @@ // No auxiliary variable necessary; expression returns void return true; - // In C++11, last_expr can be a LValueToRvalue implicit cast. Strip that off - // if that's the - // case. + // In C++11, last_expr can be a LValueToRvalue implicit cast. Strip + // that off if that's the case. do { ImplicitCastExpr *implicit_cast = dyn_cast(last_expr); @@ -241,9 +240,9 @@ last_expr = implicit_cast->getSubExpr(); } while (0); - // is_lvalue is used to record whether the expression returns an assignable - // Lvalue or an - // Rvalue. This is relevant because they are handled differently. + // is_lvalue is used to record whether the expression returns an + // assignable Lvalue or an Rvalue. This is relevant because they are + // handled differently. // // For Lvalues // Index: source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -33,8 +33,8 @@ using namespace lldb_private; //------------------------------------------------------------------ -// Scoped class that will remove an active lexical decl from the set -// when it goes out of scope. +// Scoped class that will remove an active lexical decl from the set when +// it goes out of scope. //------------------------------------------------------------------ namespace { class ScopedLexicalDeclEraser { @@ -65,10 +65,10 @@ m_ast_context = &ast_context; m_file_manager = &file_manager; if (m_target->GetUseModernTypeLookup()) { - // Configure the ExternalASTMerger. The merger needs to be able to import - // types from any source that we would do lookups in, which includes the - // persistent AST context as well as the modules and Objective-C runtime - // AST contexts. + // Configure the ExternalASTMerger. The merger needs to be able to + // import types from any source that we would do lookups in, which + // includes the persistent AST context as well as the modules and + // Objective-C runtime AST contexts. lldbassert(!m_merger_up); clang::ExternalASTMerger::ImporterTarget target = {ast_context, @@ -116,8 +116,9 @@ } while (0); if (!is_shared_context) { - // Update the scratch AST context's merger to reflect any new sources we - // might have come across since the last time an expression was parsed. + // Update the scratch AST context's merger to reflect any new + // sources we might have come across since the last time an + // expression was parsed. auto scratch_ast_context = static_cast( m_target->GetScratchClangASTContext()); @@ -140,9 +141,9 @@ if (m_ast_importer_sp) m_ast_importer_sp->ForgetDestination(m_ast_context); - // We are in the process of destruction, don't create clang ast context on - // demand - // by passing false to Target::GetScratchClangASTContext(create_on_demand). + // We are in the process of destruction, don't create clang ast context + // on demand by passing false to + // Target::GetScratchClangASTContext(create_on_demand). ClangASTContext *scratch_clang_ast_context = m_target->GetScratchClangASTContext(false); @@ -231,8 +232,9 @@ } if (!GetLookupsEnabled()) { - // Wait until we see a '$' at the start of a name before we start doing - // any lookups so we can avoid lookup up all of the builtin types. + // Wait until we see a '$' at the start of a name before we start + // doing any lookups so we can avoid lookup up all of the builtin + // types. if (!decl_name.empty() && decl_name[0] == '$') { SetLookupsEnabled(true); } else { @@ -397,9 +399,9 @@ TagDecl *candidate_tag_decl = const_cast(tag_type->getDecl()); - // We have found a type by basename and we need to make sure the decl - // contexts - // are the same before we can try to complete this type with another + // We have found a type by basename and we need to make sure the + // decl contexts are the same before we can try to complete this + // type with another if (!ClangASTContext::DeclsAreEquivalent(tag_decl, candidate_tag_decl)) continue; @@ -946,8 +948,8 @@ if (!context.m_found.type) { do { - // Couldn't find any types elsewhere. Try the Objective-C runtime if - // one exists. + // Couldn't find any types elsewhere. Try the Objective-C runtime + // if one exists. lldb::ProcessSP process(m_target->GetProcessSP()); @@ -1242,9 +1244,9 @@ if (sc_list.GetSize()) break; - // Fall back and check for methods in categories. If we find methods this - // way, we need to check that they're actually in - // categories on the desired class. + // Fall back and check for methods in categories. If we find methods + // this way, we need to check that they're actually in categories on + // the desired class. SymbolContextList candidate_sc_list; @@ -1349,8 +1351,8 @@ if (!complete_interface_decl) break; - // We found the complete interface. The runtime never needs to be queried - // in this scenario. + // We found the complete interface. The runtime never needs to be + // queried in this scenario. DeclFromUser complete_iface_decl( complete_interface_decl); @@ -1371,8 +1373,8 @@ } while (0); do { - // Check the modules only if the debug information didn't have a complete - // interface. + // Check the modules only if the debug information didn't have a + // complete interface. if (ClangModulesDeclVendor *modules_decl_vendor = m_target->GetClangModulesDeclVendor()) { @@ -1398,8 +1400,8 @@ } while (0); do { - // Check the runtime only if the debug information didn't have a complete - // interface and the modules don't get us anywhere. + // Check the runtime only if the debug information didn't have a + // complete interface and the modules don't get us anywhere. lldb::ProcessSP process(m_target->GetProcessSP()); @@ -1531,8 +1533,8 @@ if (!complete_interface_decl) break; - // We found the complete interface. The runtime never needs to be queried - // in this scenario. + // We found the complete interface. The runtime never needs to be + // queried in this scenario. DeclFromUser complete_iface_decl( complete_interface_decl); @@ -1554,8 +1556,8 @@ } while (0); do { - // Check the modules only if the debug information didn't have a complete - // interface. + // Check the modules only if the debug information didn't have a + // complete interface. ClangModulesDeclVendor *modules_decl_vendor = m_target->GetClangModulesDeclVendor(); @@ -1590,9 +1592,8 @@ } while (0); do { - // Check the runtime only if the debug information didn't have a complete - // interface - // and nothing was in the modules. + // Check the runtime only if the debug information didn't have a + // complete interface and nothing was in the modules. lldb::ProcessSP process(m_target->GetProcessSP()); @@ -1643,14 +1644,12 @@ static bool ImportOffsetMap(llvm::DenseMap &destination_map, llvm::DenseMap &source_map, ClangASTSource &source) { - // When importing fields into a new record, clang has a hard requirement that - // fields be imported in field offset order. Since they are stored in a - // DenseMap - // with a pointer as the key type, this means we cannot simply iterate over - // the - // map, as the order will be non-deterministic. Instead we have to sort by - // the offset - // and then insert in sorted order. + // When importing fields into a new record, clang has a hard requirement + // that fields be imported in field offset order. Since they are stored + // in a DenseMap with a pointer as the key type, this means we cannot + // simply iterate over the map, as the order will be non-deterministic. + // Instead we have to sort by the offset and then insert in sorted + // order. typedef llvm::DenseMap MapType; typedef typename MapType::value_type PairType; std::vector sorted_items; @@ -2012,7 +2011,8 @@ } else if (m_merger_up) { return false; // Implement this correctly in ExternalASTMerger } else { - // this can happen early enough that no ExternalASTSource is installed. + // this can happen early enough that no ExternalASTSource is + // installed. return false; } } @@ -2051,9 +2051,8 @@ if (copied_qual_type.getAsOpaquePtr() && copied_qual_type->getCanonicalTypeInternal().isNull()) - // this shouldn't happen, but we're hardening because the AST importer seems - // to be generating bad types - // on occasion. + // this shouldn't happen, but we're hardening because the AST importer + // seems to be generating bad types on occasion. return CompilerType(); return CompilerType(m_ast_context, copied_qual_type); @@ -2128,8 +2127,8 @@ isConstexprSpecified); // We have to do more than just synthesize the FunctionDecl. We have to - // synthesize ParmVarDecls for all of the FunctionDecl's arguments. To do - // this, we raid the function's FunctionProtoType for types. + // synthesize ParmVarDecls for all of the FunctionDecl's arguments. To + // do this, we raid the function's FunctionProtoType for types. const FunctionProtoType *func_proto_type = qual_type.getTypePtr()->getAs(); @@ -2157,10 +2156,10 @@ } // If this is an operator (e.g. operator new or operator==), only insert - // the declaration we inferred from the symbol if we can provide the correct - // number of arguments. We shouldn't really inject random decl(s) for - // functions that are analyzed semantically in a special way, otherwise we - // will crash in clang. + // the declaration we inferred from the symbol if we can provide the + // correct number of arguments. We shouldn't really inject random + // decl(s) for functions that are analyzed semantically in a special + // way, otherwise we will crash in clang. clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS; if (func_proto_type && ClangASTContext::IsOperator(decl_name.getAsString().c_str(), op_kind)) { Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -74,7 +74,8 @@ } ClangExpressionDeclMap::~ClangExpressionDeclMap() { - // Note: The model is now that the parser's AST context and all associated + // Note: The model is now that the parser's AST context and all + // associated // data does not vanish until the expression has been executed. This means // that valuable lookup data (like namespaces) doesn't vanish, but @@ -213,8 +214,8 @@ m_exporter.getFromContext().getSourceManager().getFileID(loc); if (file != m_file) return false; - // We are assuming the Decl was parsed in this very expression, so it should - // not have external storage. + // We are assuming the Decl was parsed in this very expression, so it + // should not have external storage. lldbassert(!llvm::cast(decl)->hasExternalLexicalStorage()); return true; } @@ -238,9 +239,9 @@ Completer(clang::ASTImporter &exporter, clang::FileID file) : m_exporter(exporter), m_file(file) {} - // Implements the RecursiveASTVisitor's core API. It is called on each Decl - // that the RecursiveASTVisitor encounters, and returns true if the traversal - // should continue. + // Implements the RecursiveASTVisitor's core API. It is called on each + // Decl that the RecursiveASTVisitor encounters, and returns true if the + // traversal should continue. bool VisitDecl(clang::Decl *decl) { MaybeComplete(decl); return true; @@ -457,8 +458,8 @@ static_cast(decl), name.GetCString(), var->GetName().GetCString()); - // We know entity->m_parser_vars is valid because we used a parser variable - // to find it + // We know entity->m_parser_vars is valid because we used a parser + // variable to find it ClangExpressionVariable::ParserVars *parser_vars = llvm::cast(var)->GetParserVars(GetParserID()); @@ -977,16 +978,13 @@ m_struct_vars->m_object_pointer_type = self_user_type; } } else { - // This branch will get hit if we are executing code in the context of a - // function that - // claims to have an object pointer (through DW_AT_object_pointer?) but - // is not formally a - // method of the class. In that case, just look up the "this" variable - // in the current - // scope and use its type. - // FIXME: This code is formally correct, but clang doesn't currently - // emit DW_AT_object_pointer - // for C++ so it hasn't actually been tested. + // This branch will get hit if we are executing code in the + // context of a function that claims to have an object pointer + // (through DW_AT_object_pointer?) but is not formally a method of + // the class. In that case, just look up the "this" variable in + // the current scope and use its type. FIXME: This code is + // formally correct, but clang doesn't currently emit + // DW_AT_object_pointer for C++ so it hasn't actually been tested. VariableList *vars = frame->GetVariableList(false); @@ -1093,13 +1091,11 @@ return; } else { - // This branch will get hit if we are executing code in the context of a - // function that - // claims to have an object pointer (through DW_AT_object_pointer?) but - // is not formally a - // method of the class. In that case, just look up the "self" variable - // in the current - // scope and use its type. + // This branch will get hit if we are executing code in the + // context of a function that claims to have an object pointer + // (through DW_AT_object_pointer?) but is not formally a method of + // the class. In that case, just look up the "self" variable in + // the current scope and use its type. VariableList *vars = frame->GetVariableList(false); @@ -1216,10 +1212,9 @@ for (size_t i = 0; i < vars->GetSize(); i++) vars->GetVariableAtIndex(i)->GetDecl(); - // Search for declarations matching the name. Do not include imported - // decls - // in the search if we are looking for decls in the artificial namespace - // $__lldb_local_vars. + // Search for declarations matching the name. Do not include + // imported decls in the search if we are looking for decls in the + // artificial namespace $__lldb_local_vars. std::vector found_decls = compiler_decl_context.FindDeclByName(name, namespace_decl.IsValid()); @@ -1285,9 +1280,9 @@ append, sc_list); } - // If we found more than one function, see if we can use the - // frame's decl context to remove functions that are shadowed - // by other functions which match in type but are nearer in scope. + // If we found more than one function, see if we can use the frame's + // decl context to remove functions that are shadowed by other + // functions which match in type but are nearer in scope. // // AddOneFunction will not add a function whose type has already been // added, so if there's another function in the list with a matching @@ -1323,9 +1318,9 @@ // First, symplify things by looping through the symbol contexts // to remove unwanted functions and separate out the functions we - // want to compare and prune into a separate list. - // Cache the info needed about the function declarations in a - // vector for efficiency. + // want to compare and prune into a separate list. Cache the info + // needed about the function declarations in a vector for + // efficiency. SymbolContextList sc_sym_list; uint32_t num_indices = sc_list.GetSize(); std::vector fdi_cache; @@ -1335,16 +1330,16 @@ SymbolContext sym_ctx; sc_list.GetContextAtIndex(index, sym_ctx); - // We don't know enough about symbols to compare them, - // but we should keep them in the list. + // We don't know enough about symbols to compare them, but we + // should keep them in the list. Function *function = sym_ctx.function; if (!function) { sc_sym_list.Append(sym_ctx); continue; } // Filter out functions without declaration contexts, as well as - // class/instance methods, since they'll be skipped in the - // code that follows anyway. + // class/instance methods, since they'll be skipped in the code + // that follows anyway. CompilerDeclContext func_decl_context = function->GetDeclContext(); if (!func_decl_context || func_decl_context.IsClassMethod(nullptr, nullptr, nullptr)) @@ -1364,10 +1359,10 @@ fdi.m_decl_lvl = LLDB_INVALID_DECL_LEVEL; if (fdi.m_copied_type && func_decl_context) { // Call CountDeclLevels to get the number of parent scopes we - // have to look through before we find the function declaration. - // When comparing functions of the same type, the one with a - // lower count will be closer to us in the lookup scope and - // shadows the other. + // have to look through before we find the function + // declaration. When comparing functions of the same type, the + // one with a lower count will be closer to us in the lookup + // scope and shadows the other. clang::DeclContext *func_decl_ctx = (clang::DeclContext *)func_decl_context.GetOpaqueDeclContext(); fdi.m_decl_lvl = ast->CountDeclLevels( @@ -1376,8 +1371,8 @@ fdi_cache.emplace_back(fdi); } - // Loop through the functions in our cache looking for matching types, - // then compare their scope levels to see which is closer. + // Loop through the functions in our cache looking for matching + // types, then compare their scope levels to see which is closer. std::multimap matches; for (const FuncDeclInfo &fdi : fdi_cache) { const CompilerType t = fdi.m_copied_type; @@ -1393,7 +1388,8 @@ matches.insert(std::make_pair(t, &fdi)); } - // Loop through our matches and add their symbol contexts to our list. + // Loop through our matches and add their symbol contexts to our + // list. SymbolContextList sc_func_list; for (const auto &q : matches) sc_func_list.Append(q.second->m_sym_ctx); @@ -1536,9 +1532,9 @@ } if (target && !context.m_found.variable && !namespace_decl) { - // We couldn't find a non-symbol variable for this. Now we'll hunt for - // a generic - // data symbol, and -- if it is found -- treat it as a variable. + // We couldn't find a non-symbol variable for this. Now we'll hunt + // for a generic data symbol, and -- if it is found -- treat it as a + // variable. Status error; const Symbol *data_symbol = @@ -2189,9 +2185,9 @@ if (!type_source_info) return; - // Construct a typedef type because if "*this" is a templated type we can't - // just return ClassTemplateSpecializationDecls in response to name queries. - // Using a typedef makes this much more robust. + // Construct a typedef type because if "*this" is a templated type we + // can't just return ClassTemplateSpecializationDecls in response to + // name queries. Using a typedef makes this much more robust. TypedefDecl *typedef_decl = TypedefDecl::Create( *m_ast_context, m_ast_context->getTranslationUnitDecl(), SourceLocation(), Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -181,11 +181,10 @@ new ClangDiagnostic(data, severity, Info.getID()); m_manager->AddDiagnostic(new_diagnostic); - // Don't store away warning fixits, since the compiler doesn't have - // enough - // context in an expression for the warning to be useful. - // FIXME: Should we try to filter out FixIts that apply to our generated - // code, and not the user's expression? + // Don't store away warning fixits, since the compiler doesn't + // have enough context in an expression for the warning to be + // useful. FIXME: Should we try to filter out FixIts that apply to + // our generated code, and not the user's expression? if (severity == eDiagnosticSeverityError) { size_t num_fixit_hints = Info.getNumFixItHints(); for (size_t i = 0; i < num_fixit_hints; i++) { @@ -226,13 +225,11 @@ m_code_generator(), m_pp_callbacks(nullptr) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); - // We can't compile expressions without a target. So if the exe_scope is null - // or doesn't have a target, - // then we just need to get out of here. I'll lldb_assert and not make any of - // the compiler objects since - // I can't return errors directly from the constructor. Further calls will - // check if the compiler was made and - // bag out if it wasn't. + // We can't compile expressions without a target. So if the exe_scope + // is null or doesn't have a target, then we just need to get out of + // here. I'll lldb_assert and not make any of the compiler objects + // since I can't return errors directly from the constructor. Further + // calls will check if the compiler was made and bag out if it wasn't. if (!exe_scope) { lldb_assert(exe_scope, "Can't make an expression parser with a null scope.", @@ -263,7 +260,8 @@ const auto target_machine = target_arch.GetMachine(); // If the expression is being evaluated in the context of an existing - // stack frame, we introspect to see if the language runtime is available. + // stack frame, we introspect to see if the language runtime is + // available. lldb::StackFrameSP frame_sp = exe_scope->CalculateStackFrame(); lldb::ProcessSP process_sp = exe_scope->CalculateProcess(); @@ -281,8 +279,7 @@ } // 2. Configure the compiler with a set of default options that are - // appropriate - // for most situations. + // appropriate for most situations. if (target_arch.IsValid()) { std::string triple = target_arch.GetTriple().str(); m_compiler->getTargetOpts().Triple = triple; @@ -291,20 +288,19 @@ m_compiler->getTargetOpts().Triple.c_str()); } else { // If we get here we don't have a valid target and just have to guess. - // Sometimes this will be ok to just use the host target triple (when we - // evaluate say "2+3", but other - // expressions like breakpoint conditions and other things that _are_ target - // specific really shouldn't just be - // using the host triple. In such a case the language runtime should expose - // an overridden options set (3), + // Sometimes this will be ok to just use the host target triple (when + // we evaluate say "2+3", but other expressions like breakpoint + // conditions and other things that _are_ target specific really + // shouldn't just be using the host triple. In such a case the + // language runtime should expose an overridden options set (3), // below. m_compiler->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple(); if (log) log->Printf("Using default target triple of %s", m_compiler->getTargetOpts().Triple.c_str()); } - // Now add some special fixes for known architectures: - // Any arm32 iOS environment, but not on arm64 + // Now add some special fixes for known architectures: Any arm32 iOS + // environment, but not on arm64 if (m_compiler->getTargetOpts().Triple.find("arm64") == std::string::npos && m_compiler->getTargetOpts().Triple.find("arm") != std::string::npos && m_compiler->getTargetOpts().Triple.find("ios") != std::string::npos) { @@ -317,9 +313,8 @@ m_compiler->getTargetOpts().Features.push_back("+sse2"); } - // Set the target CPU to generate code for. - // This will be empty for any CPU that doesn't really need to make a special - // CPU string. + // Set the target CPU to generate code for. This will be empty for any + // CPU that doesn't really need to make a special CPU string. m_compiler->getTargetOpts().CPU = target_arch.GetClangTargetCPU(); // Set the target ABI @@ -327,12 +322,11 @@ if (!abi.empty()) m_compiler->getTargetOpts().ABI = abi; - // 3. Now allow the runtime to provide custom configuration options for the - // target. - // In this case, a specialized language runtime is available and we can query - // it for extra options. - // For 99% of use cases, this will not be needed and should be provided when - // basic platform detection is not enough. + // 3. Now allow the runtime to provide custom configuration options for + // the target. In this case, a specialized language runtime is available + // and we can query it for extra options. For 99% of use cases, this + // will not be needed and should be provided when basic platform + // detection is not enough. if (lang_rt) overridden_target_opts = lang_rt->GetOverrideExprOptions(m_compiler->getTargetOpts()); @@ -376,26 +370,25 @@ case lldb::eLanguageTypeC89: case lldb::eLanguageTypeC99: case lldb::eLanguageTypeC11: - // FIXME: the following language option is a temporary workaround, - // to "ask for C, get C++." - // For now, the expression parser must use C++ anytime the - // language is a C family language, because the expression parser - // uses features of C++ to capture values. + // FIXME: the following language option is a temporary workaround, to + // "ask for C, get C++." For now, the expression parser must use C++ + // anytime the language is a C family language, because the expression + // parser uses features of C++ to capture values. m_compiler->getLangOpts().CPlusPlus = true; break; case lldb::eLanguageTypeObjC: m_compiler->getLangOpts().ObjC1 = true; m_compiler->getLangOpts().ObjC2 = true; - // FIXME: the following language option is a temporary workaround, - // to "ask for ObjC, get ObjC++" (see comment above). + // FIXME: the following language option is a temporary workaround, to + // "ask for ObjC, get ObjC++" (see comment above). m_compiler->getLangOpts().CPlusPlus = true; - // Clang now sets as default C++14 as the default standard (with - // GNU extensions), so we do the same here to avoid mismatches that - // cause compiler error when evaluating expressions (e.g. nullptr - // not found as it's a C++11 feature). Currently lldb evaluates - // C++14 as C++11 (see two lines below) so we decide to be consistent - // with that, but this could be re-evaluated in the future. + // Clang now sets as default C++14 as the default standard (with GNU + // extensions), so we do the same here to avoid mismatches that cause + // compiler error when evaluating expressions (e.g. nullptr not found + // as it's a C++11 feature). Currently lldb evaluates C++14 as C++11 + // (see two lines below) so we decide to be consistent with that, but + // this could be re-evaluated in the future. m_compiler->getLangOpts().CPlusPlus11 = true; break; case lldb::eLanguageTypeC_plus_plus: @@ -406,8 +399,8 @@ LLVM_FALLTHROUGH; case lldb::eLanguageTypeC_plus_plus_03: m_compiler->getLangOpts().CPlusPlus = true; - // FIXME: the following language option is a temporary workaround, - // to "ask for C++, get ObjC++". Apple hopes to remove this requirement + // FIXME: the following language option is a temporary workaround, to + // "ask for C++, get ObjC++". Apple hopes to remove this requirement // on non-Apple platforms, but for now it is needed. m_compiler->getLangOpts().ObjC1 = true; break; @@ -434,10 +427,9 @@ ArchSpec(m_compiler->getTargetOpts().Triple.c_str()) .CharIsSignedByDefault(); - // Spell checking is a nice feature, but it ends up completing a - // lot of types that we didn't strictly speaking need to complete. - // As a result, we spend a long time parsing and importing debug - // information. + // Spell checking is a nice feature, but it ends up completing a lot of + // types that we didn't strictly speaking need to complete. As a result, + // we spend a long time parsing and importing debug information. m_compiler->getLangOpts().SpellChecking = false; if (process_sp && m_compiler->getLangOpts().ObjC1) { @@ -481,8 +473,8 @@ // Inform the target of the language options // - // FIXME: We shouldn't need to do this, the target should be immutable once - // created. This complexity should be lifted elsewhere. + // FIXME: We shouldn't need to do this, the target should be immutable + // once created. This complexity should be lifted elsewhere. m_compiler->getTarget().adjust(m_compiler->getLangOpts()); // 6. Set up the diagnostic buffer for reporting errors @@ -513,8 +505,8 @@ m_compiler->getPreprocessor().addPPCallbacks(std::move(pp_callbacks)); } - // 8. Most of this we get from the CompilerInstance, but we - // also want to give the context an ExternalASTSource. + // 8. Most of this we get from the CompilerInstance, but we also want to + // give the context an ExternalASTSource. m_selector_table.reset(new SelectorTable()); m_builtin_context.reset(new Builtin::Context()); @@ -734,7 +726,8 @@ else if (!editor.commit(commit)) return false; - // Now play all the edits, and stash the result in the diagnostic manager. + // Now play all the edits, and stash the result in the diagnostic + // manager. editor.applyRewrites(rewrites_receiver); RewriteBuffer &main_file_buffer = rewriter.getEditBuffer(source_manager.getMainFileID()); Index: source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp +++ source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp @@ -75,21 +75,22 @@ if (m_compiled) return 0; - // Compilation might call code, make sure to keep on the thread the caller - // indicated. + // Compilation might call code, make sure to keep on the thread the + // caller indicated. ThreadList::ExpressionExecutionThreadPusher execution_thread_pusher( thread_to_use_sp); - // FIXME: How does clang tell us there's no return value? We need to handle - // that case. + // FIXME: How does clang tell us there's no return value? We need to + // handle that case. unsigned num_errors = 0; std::string return_type_str( m_function_return_type.GetTypeName().AsCString("")); - // Cons up the function we're going to wrap our call in, then compile it... - // We declare the function "extern "C"" because the compiler might be in C++ - // mode which would mangle the name and then we couldn't find it again... + // Cons up the function we're going to wrap our call in, then compile + // it... We declare the function "extern "C"" because the compiler might + // be in C++ mode which would mangle the name and then we couldn't find + // it again... m_wrapper_function_text.clear(); m_wrapper_function_text.append("extern \"C\" void "); m_wrapper_function_text.append(m_wrapper_function_name); @@ -101,14 +102,11 @@ m_wrapper_function_text.append(" (*fn_ptr) ("); // Get the number of arguments. If we have a function type and it is - // prototyped, - // trust that, otherwise use the values we were given. - - // FIXME: This will need to be extended to handle Variadic functions. We'll - // need - // to pull the defined arguments out of the function, then add the types from - // the - // arguments list for the variable arguments. + // prototyped, trust that, otherwise use the values we were given. + + // FIXME: This will need to be extended to handle Variadic functions. + // We'll need to pull the defined arguments out of the function, then + // add the types from the arguments list for the variable arguments. uint32_t num_args = UINT32_MAX; bool trust_function = false; Index: source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -40,9 +40,9 @@ using namespace lldb_private; namespace { -// Any Clang compiler requires a consumer for diagnostics. This one stores them -// as strings -// so we can provide them to the user in case a module failed to load. +// Any Clang compiler requires a consumer for diagnostics. This one +// stores them as strings so we can provide them to the user in case a +// module failed to load. class StoringDiagnosticConsumer : public clang::DiagnosticConsumer { public: StoringDiagnosticConsumer(); @@ -61,9 +61,8 @@ Log *m_log; }; -// The private implementation of our ClangModulesDeclVendor. Contains all the -// Clang state required -// to load modules. +// The private implementation of our ClangModulesDeclVendor. Contains all +// the Clang state required to load modules. class ClangModulesDeclVendorImpl : public ClangModulesDeclVendor { public: ClangModulesDeclVendorImpl( @@ -562,9 +561,8 @@ lldb_private::ClangModulesDeclVendor * ClangModulesDeclVendor::Create(Target &target) { // FIXME we should insure programmatically that the expression parser's - // compiler and the modules runtime's - // compiler are both initialized in the same way – preferably by the same - // code. + // compiler and the modules runtime's compiler are both initialized in + // the same way – preferably by the same code. if (!target.GetPlatform()->SupportsModules()) return nullptr; @@ -588,7 +586,8 @@ compiler_invocation_arguments.push_back(ModuleImportBufferName); - // Add additional search paths with { "-I", path } or { "-F", path } here. + // Add additional search paths with { "-I", path } or { "-F", path } + // here. { llvm::SmallString<128> path; Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -195,13 +195,11 @@ } } else if (clang::FunctionDecl *function_decl = ClangASTContext::DeclContextGetAsFunctionDecl(decl_context)) { - // We might also have a function that said in the debug information that it - // captured an - // object pointer. The best way to deal with getting to the ivars at - // present is by pretending - // that this is a method of a class in whatever runtime the debug info says - // the object pointer - // belongs to. Do that here. + // We might also have a function that said in the debug information + // that it captured an object pointer. The best way to deal with + // getting to the ivars at present is by pretending that this is a + // method of a class in whatever runtime the debug info says the + // object pointer belongs to. Do that here. ClangASTMetadata *metadata = ClangASTContext::DeclContextGetMetaData(decl_context, function_decl); @@ -291,10 +289,10 @@ } } -// This is a really nasty hack, meant to fix Objective-C expressions of the form -// (int)[myArray count]. Right now, because the type information for count is -// not available, [myArray count] returns id, which can't be directly cast to -// int without causing a clang error. +// This is a really nasty hack, meant to fix Objective-C expressions of +// the form (int)[myArray count]. Right now, because the type information +// for count is not available, [myArray count] returns id, which can't be +// directly cast to int without causing a clang error. static void ApplyObjcCastHack(std::string &expr) { #define OBJC_CAST_HACK_FROM "(int)[" #define OBJC_CAST_HACK_TO "(int)(long long)[" @@ -463,18 +461,16 @@ if (!exe_scope) exe_scope = exe_ctx.GetTargetPtr(); - // We use a shared pointer here so we can use the original parser - if it - // succeeds - // or the rewrite parser we might make if it fails. But the parser_sp will - // never be empty. + // We use a shared pointer here so we can use the original parser - if + // it succeeds or the rewrite parser we might make if it fails. But the + // parser_sp will never be empty. ClangExpressionParser parser(exe_scope, *this, generate_debug_info); unsigned num_errors = parser.Parse(diagnostic_manager); - // Check here for FixItHints. If there are any try to apply the fixits and - // set the fixed text in m_fixed_text - // before returning an error. + // Check here for FixItHints. If there are any try to apply the fixits + // and set the fixed text in m_fixed_text before returning an error. if (num_errors) { if (diagnostic_manager.HasFixIts()) { if (parser.RewriteExpression(diagnostic_manager)) { @@ -496,8 +492,8 @@ } ////////////////////////////////////////////////////////////////////////////////////////// - // Prepare the output of the parser for execution, evaluating it statically if - // possible + // Prepare the output of the parser for execution, evaluating it + // statically if possible // { @@ -540,9 +536,9 @@ register_execution_unit = true; } - // If there is more than one external function in the execution - // unit, it needs to keep living even if it's not top level, because - // the result could refer to that function. + // If there is more than one external function in the execution unit, + // it needs to keep living even if it's not top level, because the + // result could refer to that function. if (m_execution_unit_sp->GetJittedFunctions().size() > 1) { register_execution_unit = true; Index: source/Plugins/ExpressionParser/Clang/IRForTarget.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -160,7 +160,8 @@ if (!m_resolve_vars) return true; - // Find the result variable. If it doesn't exist, we can give up right here. + // Find the result variable. If it doesn't exist, we can give up right + // here. ValueSymbolTable &value_symbol_table = m_module->getValueSymbolTable(); @@ -263,8 +264,7 @@ } // Get the next available result name from m_decl_map and create the - // persistent - // variable for it + // persistent variable for it // If the result is an Lvalue, it is emitted as a pointer; see // ASTResultSynthesizer::SynthesizeBodyResult. @@ -345,12 +345,12 @@ GlobalValue::ExternalLinkage, NULL, /* no initializer */ m_result_name.GetCString()); - // It's too late in compilation to create a new VarDecl for this, but we don't - // need to. We point the metadata at the old VarDecl. This creates an odd - // anomaly: a variable with a Value whose name is something like $0 and a - // Decl whose name is $__lldb_expr_result. This condition is handled in - // ClangExpressionDeclMap::DoMaterialize, and the name of the variable is - // fixed up. + // It's too late in compilation to create a new VarDecl for this, but we + // don't need to. We point the metadata at the old VarDecl. This + // creates an odd anomaly: a variable with a Value whose name is + // something like $0 and a Decl whose name is $__lldb_expr_result. This + // condition is handled in ClangExpressionDeclMap::DoMaterialize, and + // the name of the variable is fixed up. ConstantInt *new_constant_int = ConstantInt::get(llvm::Type::getInt64Ty(m_module->getContext()), @@ -463,10 +463,8 @@ // CFStringRef -> i8* // CFAllocatorRef -> i8* // UInt8 * -> i8* - // CFIndex -> long (i32 or i64, as appropriate; we ask the module for its - // pointer size for now) - // CFStringEncoding -> i32 - // Boolean -> i8 + // CFIndex -> long (i32 or i64, as appropriate; we ask the module for + // its pointer size for now) CFStringEncoding -> i32 Boolean -> i8 Type *arg_type_array[5]; @@ -740,8 +738,8 @@ if (log) log->PutCString("Error rewriting the constant string"); - // We don't print an error message here because RewriteObjCConstString - // has done so for us. + // We don't print an error message here because + // RewriteObjCConstString has done so for us. return false; } @@ -798,12 +796,12 @@ if (!load) return false; - // Unpack the message name from the selector. In LLVM IR, an objc_msgSend - // gets represented as + // Unpack the message name from the selector. In LLVM IR, an + // objc_msgSend gets represented as // - // %tmp = load i8** @"OBJC_SELECTOR_REFERENCES_" ; - // %call = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %obj, i8* %tmp, ...) - // ; + // %tmp = load i8** @"OBJC_SELECTOR_REFERENCES_" ; %call = + // call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %obj, i8* %tmp, ...) ; + // // // where %obj is the object pointer and %tmp is the selector. // @@ -811,8 +809,8 @@ // @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_". // @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_" contains the string. - // Find the pointer's initializer (a ConstantExpr with opcode GetElementPtr) - // and get the string from its target + // Find the pointer's initializer (a ConstantExpr with opcode + // GetElementPtr) and get the string from its target GlobalVariable *_objc_selector_references_ = dyn_cast(load->getPointerOperand()); @@ -834,7 +832,8 @@ if (!osr_initializer_base) return false; - // Find the string's initializer (a ConstantArray) and get the string from it + // Find the string's initializer (a ConstantArray) and get the string + // from it GlobalVariable *_objc_meth_var_name_ = dyn_cast(osr_initializer_base); @@ -870,12 +869,13 @@ log->Printf("Found sel_registerName at 0x%" PRIx64, sel_registerName_addr); - // Build the function type: struct objc_selector *sel_registerName(uint8_t*) + // Build the function type: struct objc_selector + // *sel_registerName(uint8_t*) - // The below code would be "more correct," but in actuality what's required - // is uint8_t* - // Type *sel_type = StructType::get(m_module->getContext()); - // Type *sel_ptr_type = PointerType::getUnqual(sel_type); + // The below code would be "more correct," but in actuality what's + // required is uint8_t* Type *sel_type = + // StructType::get(m_module->getContext()); Type *sel_ptr_type = + // PointerType::getUnqual(sel_type); Type *sel_ptr_type = Type::getInt8PtrTy(m_module->getContext()); Type *type_array[1]; @@ -973,15 +973,14 @@ if (!load) return false; - // Unpack the class name from the reference. In LLVM IR, a reference to an - // Objective-C class gets represented as + // Unpack the class name from the reference. In LLVM IR, a reference to + // an Objective-C class gets represented as // // %tmp = load %struct._objc_class*, // %struct._objc_class** @OBJC_CLASS_REFERENCES_, align 4 // // @"OBJC_CLASS_REFERENCES_ is a bitcast of a character array called - // @OBJC_CLASS_NAME_. - // @OBJC_CLASS_NAME contains the string. + // @OBJC_CLASS_NAME_. @OBJC_CLASS_NAME contains the string. // Find the pointer's initializer (a ConstantExpr with opcode BitCast) // and get the string from its target @@ -1006,7 +1005,8 @@ if (!ocr_initializer_base) return false; - // Find the string's initializer (a ConstantArray) and get the string from it + // Find the string's initializer (a ConstantArray) and get the string + // from it GlobalVariable *_objc_class_name_ = dyn_cast(ocr_initializer_base); @@ -1137,7 +1137,8 @@ if (!constant_int) return false; - // We attempt to register this as a new persistent variable with the DeclMap. + // We attempt to register this as a new persistent variable with the + // DeclMap. uintptr_t ptr = constant_int->getZExtValue(); @@ -1159,8 +1160,8 @@ GlobalValue::ExternalLinkage, NULL, /* no initializer */ alloc->getName().str()); - // What we're going to do here is make believe this was a regular old external - // variable. That means we need to make the metadata valid. + // What we're going to do here is make believe this was a regular old + // external variable. That means we need to make the metadata valid. NamedMDNode *named_metadata = m_module->getOrInsertNamedMetadata("clang.global.decl.ptrs"); @@ -1174,9 +1175,8 @@ MDNode *persistent_global_md = MDNode::get(m_module->getContext(), value_ref); named_metadata->addOperand(persistent_global_md); - // Now, since the variable is a pointer variable, we will drop in a load of - // that - // pointer variable. + // Now, since the variable is a pointer variable, we will drop in a load + // of that pointer variable. LoadInst *persistent_load = new LoadInst(persistent_global, "", alloc); @@ -1365,17 +1365,16 @@ const Type *value_type = NULL; if (name[0] == '$') { - // The $__lldb_expr_result name indicates the return value has allocated - // as - // a static variable. Per the comment at - // ASTResultSynthesizer::SynthesizeBodyResult, - // accesses to this static variable need to be redirected to the result of - // dereferencing - // a pointer that is passed in as one of the arguments. + // The $__lldb_expr_result name indicates the return value has + // allocated as a static variable. Per the comment at + // ASTResultSynthesizer::SynthesizeBodyResult, accesses to this + // static variable need to be redirected to the result of + // dereferencing a pointer that is passed in as one of the + // arguments. // - // Consequently, when reporting the size of the type, we report a pointer - // type pointing - // to the type of $__lldb_expr_result, not the type itself. + // Consequently, when reporting the size of the type, we report a + // pointer type pointing to the type of $__lldb_expr_result, not the + // type itself. // // We also do this for any user-declared persistent variables. compiler_type = compiler_type.GetPointerType(); @@ -1541,7 +1540,8 @@ CallInst *call = dyn_cast(&inst); - // MaybeHandleCallArguments handles error reporting; we are silent here + // MaybeHandleCallArguments handles error reporting; we are silent + // here if (!call) continue; @@ -1582,7 +1582,8 @@ CallInst *call = dyn_cast(&inst); - // MaybeHandleCallArguments handles error reporting; we are silent here + // MaybeHandleCallArguments handles error reporting; we are silent + // here if (call && !MaybeHandleCallArguments(call)) return false; } @@ -1721,8 +1722,8 @@ lldb_private::Stream &error_stream) { SmallVector users; - // We do this because the use list might change, invalidating our iterator. - // Much better to keep a work list ourselves. + // We do this because the use list might change, invalidating our + // iterator. Much better to keep a work list ourselves. for (llvm::User *u : old_constant->users()) users.push_back(u); @@ -1965,12 +1966,12 @@ FunctionValueCache body_result_maker( [this, name, offset_type, offset, argument, value](llvm::Function *function) -> llvm::Value * { - // Per the comment at ASTResultSynthesizer::SynthesizeBodyResult, in - // cases where the result - // variable is an rvalue, we have to synthesize a dereference of the - // appropriate structure - // entry in order to produce the static variable that the AST thinks - // it is accessing. + // Per the comment at + // ASTResultSynthesizer::SynthesizeBodyResult, in cases where + // the result variable is an rvalue, we have to synthesize a + // dereference of the appropriate structure entry in order to + // produce the static variable that the AST thinks it is + // accessing. llvm::Instruction *entry_instruction = llvm::cast( m_entry_instruction_finder.GetValue(function)); @@ -2112,7 +2113,8 @@ if (log) log->Printf("CreateResultVariable() failed"); - // CreateResultVariable() reports its own errors, so we don't do so here + // CreateResultVariable() reports its own errors, so we don't do so + // here return false; } @@ -2153,8 +2155,8 @@ if (log) log->Printf("RewritePersistentAllocs() failed"); - // RewritePersistentAllocs() reports its own errors, so we don't do so - // here + // RewritePersistentAllocs() reports its own errors, so we don't + // do so here return false; } @@ -2163,7 +2165,8 @@ if (log) log->Printf("RemoveCXAAtExit() failed"); - // RemoveCXAAtExit() reports its own errors, so we don't do so here + // RemoveCXAAtExit() reports its own errors, so we don't do so + // here return false; } @@ -2171,14 +2174,16 @@ } /////////////////////////////////////////////////////////////////////////////// - // Fix all Objective-C constant strings to use NSStringWithCString:encoding: + // Fix all Objective-C constant strings to use + // NSStringWithCString:encoding: // if (!RewriteObjCConstStrings()) { if (log) log->Printf("RewriteObjCConstStrings() failed"); - // RewriteObjCConstStrings() reports its own errors, so we don't do so here + // RewriteObjCConstStrings() reports its own errors, so we don't do so + // here return false; } @@ -2194,7 +2199,8 @@ if (log) log->Printf("RewriteObjCSelectors() failed"); - // RewriteObjCSelectors() reports its own errors, so we don't do so here + // RewriteObjCSelectors() reports its own errors, so we don't do + // so here return false; } @@ -2203,7 +2209,8 @@ if (log) log->Printf("RewriteObjCClassReferences() failed"); - // RewriteObjCClasses() reports its own errors, so we don't do so here + // RewriteObjCClasses() reports its own errors, so we don't do so + // here return false; } Index: source/Plugins/ExpressionParser/Go/GoUserExpression.cpp =================================================================== --- source/Plugins/ExpressionParser/Go/GoUserExpression.cpp +++ source/Plugins/ExpressionParser/Go/GoUserExpression.cpp @@ -400,9 +400,8 @@ if (var_sp) val = m_frame->GetValueObjectForFrameVariable(var_sp, m_use_dynamic); else { - // When a variable is on the heap instead of the stack, go records a - // variable - // '&x' instead of 'x'. + // When a variable is on the heap instead of the stack, go records + // a variable '&x' instead of 'x'. var_sp = var_list_sp->FindVariable(ConstString("&" + varname)); if (var_sp) { val = m_frame->GetValueObjectForFrameVariable(var_sp, m_use_dynamic); Index: source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp =================================================================== --- source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -258,8 +258,8 @@ reg_info.name = "f7"; break; - // Intel wireless MMX general purpose registers 0 - 7 - // XScale accumulator register 0 - 7 (they do overlap with wCGR0 - wCGR7) + // Intel wireless MMX general purpose registers 0 - 7 XScale accumulator + // register 0 - 7 (they do overlap with wCGR0 - wCGR7) case dwarf_wCGR0: reg_info.name = "wCGR0/ACC0"; break; @@ -602,7 +602,8 @@ } // A8.6.50 -// Valid return values are {1, 2, 3, 4}, with 0 signifying an error condition. +// Valid return values are {1, 2, 3, 4}, with 0 signifying an error +// condition. static uint32_t CountITSize(uint32_t ITMask) { // First count the trailing zeros of the IT mask. uint32_t TZ = llvm::countTrailingZeros(ITMask); @@ -767,8 +768,8 @@ return false; } -// Write "bits (32) UNKNOWN" to memory address "address". Helper function for -// many ARM instructions. +// Write "bits (32) UNKNOWN" to memory address "address". Helper function +// for many ARM instructions. bool EmulateInstructionARM::WriteBits32UnknownToMemory(addr_t address) { EmulateInstruction::Context context; context.type = EmulateInstruction::eContextWriteMemoryRandomBits; @@ -900,9 +901,9 @@ return fp_regnum; } -// Push Multiple Registers stores multiple registers to the stack, storing to -// consecutive memory locations ending just below the address in SP, and updates -// SP to point to the start of the stored data. +// Push Multiple Registers stores multiple registers to the stack, storing +// to consecutive memory locations ending just below the address in SP, +// and updates SP to point to the start of the stored data. bool EmulateInstructionARM::EmulatePUSH(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -1022,9 +1023,9 @@ return true; } -// Pop Multiple Registers loads multiple registers from the stack, loading from -// consecutive memory locations staring at the address in SP, and updates -// SP to point just above the loaded data. +// Pop Multiple Registers loads multiple registers from the stack, loading +// from consecutive memory locations staring at the address in SP, and +// updates SP to point just above the loaded data. bool EmulateInstructionARM::EmulatePOP(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -1151,8 +1152,8 @@ return true; } -// Set r7 or ip to point to saved value residing within the stack. -// ADD (SP plus immediate) +// Set r7 or ip to point to saved value residing within the stack. ADD (SP +// plus immediate) bool EmulateInstructionARM::EmulateADDRdSPImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -1212,8 +1213,7 @@ return true; } -// Set r7 or ip to the current stack pointer. -// MOV (register) +// Set r7 or ip to the current stack pointer. MOV (register) bool EmulateInstructionARM::EmulateMOVRdSP(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -1267,8 +1267,8 @@ return true; } -// Move from high register (r8-r15) to low register (r0-r7). -// MOV (register) +// Move from high register (r8-r15) to low register (r0-r7). MOV +// (register) bool EmulateInstructionARM::EmulateMOVLowHigh(const uint32_t opcode, const ARMEncoding encoding) { return EmulateMOVRdRm(opcode, encoding); @@ -1362,9 +1362,9 @@ return true; } -// Move (immediate) writes an immediate value to the destination register. It -// can optionally update the condition flags based on the value. -// MOV (immediate) +// Move (immediate) writes an immediate value to the destination register. +// It can optionally update the condition flags based on the value. MOV +// (immediate) bool EmulateInstructionARM::EmulateMOVRdImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -1412,8 +1412,8 @@ break; case eEncodingT3: { - // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm4:i:imm3:imm8, - // 32); + // d = UInt(Rd); setflags = FALSE; imm32 = + // ZeroExtend(imm4:i:imm3:imm8, 32); Rd = Bits32(opcode, 11, 8); setflags = false; uint32_t imm4 = Bits32(opcode, 19, 16); @@ -1442,7 +1442,8 @@ break; case eEncodingA2: { - // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm4:imm12, 32); + // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm4:imm12, + // 32); Rd = Bits32(opcode, 15, 12); setflags = false; uint32_t imm4 = Bits32(opcode, 19, 16); @@ -1470,15 +1471,14 @@ return true; } -// MUL multiplies two register values. The least significant 32 bits of the -// result are written to the destination -// register. These 32 bits do not depend on whether the source register values -// are considered to be signed values or -// unsigned values. +// MUL multiplies two register values. The least significant 32 bits of +// the result are written to the destination register. These 32 bits do +// not depend on whether the source register values are considered to be +// signed values or unsigned values. // -// Optionally, it can update the condition flags based on the result. In the -// Thumb instruction set, this option is -// limited to only a few forms of the instruction. +// Optionally, it can update the condition flags based on the result. In +// the Thumb instruction set, this option is limited to only a few forms +// of the instruction. bool EmulateInstructionARM::EmulateMUL(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -1506,7 +1506,8 @@ // EncodingSpecificOperations(); switch (encoding) { case eEncodingT1: - // d = UInt(Rdm); n = UInt(Rn); m = UInt(Rdm); setflags = !InITBlock(); + // d = UInt(Rdm); n = UInt(Rn); m = UInt(Rdm); setflags = + // !InITBlock(); d = Bits32(opcode, 2, 0); n = Bits32(opcode, 5, 3); m = Bits32(opcode, 2, 0); @@ -1554,15 +1555,15 @@ bool success = false; - // operand1 = SInt(R[n]); // operand1 = UInt(R[n]) produces the same final - // results + // operand1 = SInt(R[n]); // operand1 = UInt(R[n]) produces the same + // final results uint64_t operand1 = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_r0 + n, 0, &success); if (!success) return false; - // operand2 = SInt(R[m]); // operand2 = UInt(R[m]) produces the same final - // results + // operand2 = SInt(R[m]); // operand2 = UInt(R[m]) produces the same + // final results uint64_t operand2 = ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_r0 + m, 0, &success); if (!success) @@ -1605,9 +1606,9 @@ return true; } -// Bitwise NOT (immediate) writes the bitwise inverse of an immediate value to -// the destination register. -// It can optionally update the condition flags based on the value. +// Bitwise NOT (immediate) writes the bitwise inverse of an immediate +// value to the destination register. It can optionally update the +// condition flags based on the value. bool EmulateInstructionARM::EmulateMVNImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -1665,9 +1666,9 @@ return true; } -// Bitwise NOT (register) writes the bitwise inverse of a register value to the -// destination register. -// It can optionally update the condition flags based on the result. +// Bitwise NOT (register) writes the bitwise inverse of a register value +// to the destination register. It can optionally update the condition +// flags based on the result. bool EmulateInstructionARM::EmulateMVNReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -1746,9 +1747,8 @@ return true; } -// PC relative immediate load into register, possibly followed by ADD (SP plus -// register). -// LDR (literal) +// PC relative immediate load into register, possibly followed by ADD (SP +// plus register). LDR (literal) bool EmulateInstructionARM::EmulateLDRRtPCRelative(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -1868,7 +1868,8 @@ bool setflags; switch (encoding) { case eEncodingT1: - // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm8:'00', 32); + // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(imm8:'00', + // 32); d = Bits32(opcode, 10, 8); imm32 = (Bits32(opcode, 7, 0) << 2); setflags = false; @@ -1899,7 +1900,8 @@ case eEncodingT4: { // if Rn == '1111' then SEE ADR; - // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(i:imm3:imm8, 32); + // d = UInt(Rd); setflags = FALSE; imm32 = ZeroExtend(i:imm3:imm8, + // 32); d = Bits32(opcode, 11, 8); setflags = false; uint32_t i = Bit32(opcode, 26); @@ -2005,10 +2007,9 @@ return true; } -// Branch with Link and Exchange Instruction Sets (immediate) calls a subroutine -// at a PC-relative address, and changes instruction set from ARM to Thumb, or -// from Thumb to ARM. -// BLX (immediate) +// Branch with Link and Exchange Instruction Sets (immediate) calls a +// subroutine at a PC-relative address, and changes instruction set from +// ARM to Thumb, or from Thumb to ARM. BLX (immediate) bool EmulateInstructionARM::EmulateBLXImmediate(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -2110,9 +2111,8 @@ return true; } -// Branch with Link and Exchange (register) calls a subroutine at an address and -// instruction set specified by a register. -// BLX (register) +// Branch with Link and Exchange (register) calls a subroutine at an +// address and instruction set specified by a register. BLX (register) bool EmulateInstructionARM::EmulateBLXRm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -2220,9 +2220,8 @@ } // Branch and Exchange Jazelle attempts to change to Jazelle state. If the -// attempt fails, it branches to an -// address and instruction set specified by a register as though it were a BX -// instruction. +// attempt fails, it branches to an address and instruction set specified +// by a register as though it were a BX instruction. // // TODO: Emulate Jazelle architecture? // We currently assume that switching to Jazelle state fails, thus @@ -2378,11 +2377,11 @@ return true; } -// This instruction subtracts an immediate value from the SP value, and writes -// the result to the destination register. +// This instruction subtracts an immediate value from the SP value, and +// writes the result to the destination register. // -// If Rd == 13 => A sub operation to adjust the SP -- allocate space for local -// storage. +// If Rd == 13 => A sub operation to adjust the SP -- allocate space for +// local storage. bool EmulateInstructionARM::EmulateSUBSPImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -2561,8 +2560,8 @@ return true; } -// Vector Push stores multiple extension registers to the stack. -// It also updates SP to point to the start of the stored data. +// Vector Push stores multiple extension registers to the stack. It also +// updates SP to point to the start of the stored data. bool EmulateInstructionARM::EmulateVPUSH(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -2577,7 +2576,8 @@ MemA[address,4] = S[d+r]; address = address+4; else for r = 0 to regs-1 - // Store as two word-aligned words in the correct order for current endianness. + // Store as two word-aligned words in the correct order + // for current endianness. MemA[address,4] = if BigEndian() then D[d+r]<63:32> else D[d+r]<31:0>; MemA[address+4,4] = if BigEndian() then D[d+r]<31:0> else D[d+r]<63:32>; address = address+8; @@ -2653,8 +2653,8 @@ return true; } -// Vector Pop loads multiple extension registers from the stack. -// It also updates SP to point just above the loaded data. +// Vector Pop loads multiple extension registers from the stack. It also +// updates SP to point just above the loaded data. bool EmulateInstructionARM::EmulateVPOP(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -2670,7 +2670,8 @@ else for r = 0 to regs-1 word1 = MemA[address,4]; word2 = MemA[address+4,4]; address = address+8; - // Combine the word-aligned words in the correct order for current endianness. + // Combine the word-aligned words in the correct order for + // current endianness. D[d+r] = if BigEndian() then word1:word2 else word2:word1; } #endif @@ -2790,7 +2791,8 @@ return true; } -// If Then makes up to four following instructions (the IT block) conditional. +// If Then makes up to four following instructions (the IT block) +// conditional. bool EmulateInstructionARM::EmulateIT(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -2833,7 +2835,8 @@ int32_t imm32; // PC-relative offset switch (encoding) { case eEncodingT1: - // The 'cond' field is handled in EmulateInstructionARM::CurrentCond(). + // The 'cond' field is handled in + // EmulateInstructionARM::CurrentCond(). imm32 = llvm::SignExtend32<9>(Bits32(opcode, 7, 0) << 1); target = pc + imm32; context.SetISAAndImmediateSigned(eModeThumb, 4 + imm32); @@ -2844,7 +2847,8 @@ context.SetISAAndImmediateSigned(eModeThumb, 4 + imm32); break; case eEncodingT3: - // The 'cond' field is handled in EmulateInstructionARM::CurrentCond(). + // The 'cond' field is handled in + // EmulateInstructionARM::CurrentCond(). { if (Bits32(opcode, 25, 23) == 7) return false; // See Branches and miscellaneous control on page @@ -2891,11 +2895,9 @@ return true; } -// Compare and Branch on Nonzero and Compare and Branch on Zero compare the -// value in a register with -// zero and conditionally branch forward a constant value. They do not affect -// the condition flags. -// CBNZ, CBZ +// Compare and Branch on Nonzero and Compare and Branch on Zero compare +// the value in a register with zero and conditionally branch forward a +// constant value. They do not affect the condition flags. CBNZ, CBZ bool EmulateInstructionARM::EmulateCB(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -2938,18 +2940,16 @@ return true; } -// Table Branch Byte causes a PC-relative forward branch using a table of single -// byte offsets. -// A base register provides a pointer to the table, and a second register -// supplies an index into the table. -// The branch length is twice the value of the byte returned from the table. +// Table Branch Byte causes a PC-relative forward branch using a table of +// single byte offsets. A base register provides a pointer to the table, +// and a second register supplies an index into the table. The branch +// length is twice the value of the byte returned from the table. // -// Table Branch Halfword causes a PC-relative forward branch using a table of -// single halfword offsets. -// A base register provides a pointer to the table, and a second register -// supplies an index into the table. -// The branch length is twice the value of the halfword returned from the table. -// TBB, TBH +// Table Branch Halfword causes a PC-relative forward branch using a table +// of single halfword offsets. A base register provides a pointer to the +// table, and a second register supplies an index into the table. The +// branch length is twice the value of the halfword returned from the +// table. TBB, TBH bool EmulateInstructionARM::EmulateTB(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -2984,8 +2984,8 @@ return false; } - // Read the address of the table from the operand register Rn. - // The PC can be used, in which case the table immediately follows this + // Read the address of the table from the operand register Rn. The PC + // can be used, in which case the table immediately follows this // instruction. uint32_t base = ReadCoreReg(Rn, &success); if (!success) @@ -3022,9 +3022,9 @@ return true; } -// This instruction adds an immediate value to a register value, and writes the -// result to the destination register. -// It can optionally update the condition flags based on the result. +// This instruction adds an immediate value to a register value, and +// writes the result to the destination register. It can optionally update +// the condition flags based on the result. bool EmulateInstructionARM::EmulateADDImmThumb(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3071,8 +3071,8 @@ break; case eEncodingT3: - // if Rd == '1111' && S == '1' then SEE CMN (immediate); - // d = UInt(Rd); n = UInt(Rn); setflags = (S == '1'); imm32 = + // if Rd == '1111' && S == '1' then SEE CMN (immediate); d = + // UInt(Rd); n = UInt(Rn); setflags = (S == '1'); imm32 = // ThumbExpandImm(i:imm3:imm8); d = Bits32(opcode, 11, 8); n = Bits32(opcode, 19, 16); @@ -3144,9 +3144,9 @@ return true; } -// This instruction adds an immediate value to a register value, and writes the -// result to the destination -// register. It can optionally update the condition flags based on the result. +// This instruction adds an immediate value to a register value, and +// writes the result to the destination register. It can optionally +// update the condition flags based on the result. bool EmulateInstructionARM::EmulateADDImmARM(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3209,10 +3209,9 @@ return true; } -// This instruction adds a register value and an optionally-shifted register -// value, and writes the result -// to the destination register. It can optionally update the condition flags -// based on the result. +// This instruction adds a register value and an optionally-shifted +// register value, and writes the result to the destination register. It +// can optionally update the condition flags based on the result. bool EmulateInstructionARM::EmulateADDReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3300,8 +3299,9 @@ return true; } -// Compare Negative (immediate) adds a register value and an immediate value. -// It updates the condition flags based on the result, and discards the result. +// Compare Negative (immediate) adds a register value and an immediate +// value. It updates the condition flags based on the result, and discards +// the result. bool EmulateInstructionARM::EmulateCMNImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3349,9 +3349,9 @@ return true; } -// Compare Negative (register) adds a register value and an optionally-shifted -// register value. -// It updates the condition flags based on the result, and discards the result. +// Compare Negative (register) adds a register value and an optionally- +// shifted register value. It updates the condition flags based on the +// result, and discards the result. bool EmulateInstructionARM::EmulateCMNReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3420,7 +3420,8 @@ } // Compare (immediate) subtracts an immediate value from a register value. -// It updates the condition flags based on the result, and discards the result. +// It updates the condition flags based on the result, and discards the +// result. bool EmulateInstructionARM::EmulateCMPImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3472,9 +3473,9 @@ return true; } -// Compare (register) subtracts an optionally-shifted register value from a -// register value. -// It updates the condition flags based on the result, and discards the result. +// Compare (register) subtracts an optionally-shifted register value from +// a register value. It updates the condition flags based on the result, +// and discards the result. bool EmulateInstructionARM::EmulateCMPReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3552,10 +3553,9 @@ } // Arithmetic Shift Right (immediate) shifts a register value right by an -// immediate number of bits, -// shifting in copies of its sign bit, and writes the result to the destination -// register. It can -// optionally update the condition flags based on the result. +// immediate number of bits, shifting in copies of its sign bit, and +// writes the result to the destination register. It can optionally +// update the condition flags based on the result. bool EmulateInstructionARM::EmulateASRImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3577,13 +3577,11 @@ return EmulateShiftImm(opcode, encoding, SRType_ASR); } -// Arithmetic Shift Right (register) shifts a register value right by a variable -// number of bits, -// shifting in copies of its sign bit, and writes the result to the destination -// register. -// The variable number of bits is read from the bottom byte of a register. It -// can optionally update -// the condition flags based on the result. +// Arithmetic Shift Right (register) shifts a register value right by a +// variable number of bits, shifting in copies of its sign bit, and writes +// the result to the destination register. The variable number of bits is +// read from the bottom byte of a register. It can optionally update the +// condition flags based on the result. bool EmulateInstructionARM::EmulateASRReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3603,11 +3601,10 @@ return EmulateShiftReg(opcode, encoding, SRType_ASR); } -// Logical Shift Left (immediate) shifts a register value left by an immediate -// number of bits, -// shifting in zeros, and writes the result to the destination register. It can -// optionally -// update the condition flags based on the result. +// Logical Shift Left (immediate) shifts a register value left by an +// immediate number of bits, shifting in zeros, and writes the result to +// the destination register. It can optionally update the condition flags +// based on the result. bool EmulateInstructionARM::EmulateLSLImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3629,13 +3626,11 @@ return EmulateShiftImm(opcode, encoding, SRType_LSL); } -// Logical Shift Left (register) shifts a register value left by a variable -// number of bits, -// shifting in zeros, and writes the result to the destination register. The -// variable number -// of bits is read from the bottom byte of a register. It can optionally update -// the condition -// flags based on the result. +// Logical Shift Left (register) shifts a register value left by a +// variable number of bits, shifting in zeros, and writes the result to +// the destination register. The variable number of bits is read from the +// bottom byte of a register. It can optionally update the condition flags +// based on the result. bool EmulateInstructionARM::EmulateLSLReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3655,11 +3650,10 @@ return EmulateShiftReg(opcode, encoding, SRType_LSL); } -// Logical Shift Right (immediate) shifts a register value right by an immediate -// number of bits, -// shifting in zeros, and writes the result to the destination register. It can -// optionally -// update the condition flags based on the result. +// Logical Shift Right (immediate) shifts a register value right by an +// immediate number of bits, shifting in zeros, and writes the result to +// the destination register. It can optionally update the condition flags +// based on the result. bool EmulateInstructionARM::EmulateLSRImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3681,13 +3675,11 @@ return EmulateShiftImm(opcode, encoding, SRType_LSR); } -// Logical Shift Right (register) shifts a register value right by a variable -// number of bits, -// shifting in zeros, and writes the result to the destination register. The -// variable number -// of bits is read from the bottom byte of a register. It can optionally update -// the condition -// flags based on the result. +// Logical Shift Right (register) shifts a register value right by a +// variable number of bits, shifting in zeros, and writes the result to +// the destination register. The variable number of bits is read from the +// bottom byte of a register. It can optionally update the condition flags +// based on the result. bool EmulateInstructionARM::EmulateLSRReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3707,11 +3699,10 @@ return EmulateShiftReg(opcode, encoding, SRType_LSR); } -// Rotate Right (immediate) provides the value of the contents of a register -// rotated by a constant value. -// The bits that are rotated off the right end are inserted into the vacated bit -// positions on the left. -// It can optionally update the condition flags based on the result. +// Rotate Right (immediate) provides the value of the contents of a +// register rotated by a constant value. The bits that are rotated off the +// right end are inserted into the vacated bit positions on the left. It +// can optionally update the condition flags based on the result. bool EmulateInstructionARM::EmulateRORImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3733,13 +3724,12 @@ return EmulateShiftImm(opcode, encoding, SRType_ROR); } -// Rotate Right (register) provides the value of the contents of a register -// rotated by a variable number of bits. -// The bits that are rotated off the right end are inserted into the vacated bit -// positions on the left. -// The variable number of bits is read from the bottom byte of a register. It -// can optionally update the condition -// flags based on the result. +// Rotate Right (register) provides the value of the contents of a +// register rotated by a variable number of bits. The bits that are +// rotated off the right end are inserted into the vacated bit positions +// on the left. The variable number of bits is read from the bottom byte +// of a register. It can optionally update the condition flags based on +// the result. bool EmulateInstructionARM::EmulateRORReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3759,12 +3749,12 @@ return EmulateShiftReg(opcode, encoding, SRType_ROR); } -// Rotate Right with Extend provides the value of the contents of a register -// shifted right by one place, -// with the carry flag shifted into bit [31]. +// Rotate Right with Extend provides the value of the contents of a +// register shifted right by one place, with the carry flag shifted into +// bit [31]. // -// RRX can optionally update the condition flags based on the result. -// In that case, bit [0] is shifted into the carry flag. +// RRX can optionally update the condition flags based on the result. In +// that case, bit [0] is shifted into the carry flag. bool EmulateInstructionARM::EmulateRRX(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3808,10 +3798,9 @@ // A8.6.139 ROR (immediate) -- Encoding T1 ARMEncoding use_encoding = encoding; if (shift_type == SRType_ROR && use_encoding == eEncodingT1) { - // Morph the T1 encoding from the ARM Architecture Manual into T2 encoding - // to - // have the same decoding of bit fields as the other Thumb2 shift - // operations. + // Morph the T1 encoding from the ARM Architecture Manual into T2 + // encoding to have the same decoding of bit fields as the other + // Thumb2 shift operations. use_encoding = eEncodingT2; } @@ -3948,10 +3937,9 @@ return true; } -// LDM loads multiple registers from consecutive memory locations, using an -// address from a base register. Optionally the address just above the highest -// of those locations -// can be written back to the base register. +// LDM loads multiple registers from consecutive memory locations, using +// an address from a base register. Optionally the address just above the +// highest of those locations can be written back to the base register. bool EmulateInstructionARM::EmulateLDM(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -3990,15 +3978,15 @@ return false; break; case eEncodingT2: - // if W == '1' && Rn == '1101' then SEE POP; - // n = UInt(Rn); registers = P:M:'0':register_list; wback = (W == '1'); + // if W == '1' && Rn == '1101' then SEE POP; n = UInt(Rn); registers + // = P:M:'0':register_list; wback = (W == '1'); n = Bits32(opcode, 19, 16); registers = Bits32(opcode, 15, 0); registers = registers & 0xdfff; // Make sure bit 13 is zero. wback = BitIsSet(opcode, 21); - // if n == 15 || BitCount(registers) < 2 || (P == '1' && M == '1') then - // UNPREDICTABLE; + // if n == 15 || BitCount(registers) < 2 || (P == '1' && M == '1') + // then UNPREDICTABLE; if ((n == 15) || (BitCount(registers) < 2) || (BitIsSet(opcode, 14) && BitIsSet(opcode, 15))) return false; @@ -4090,11 +4078,10 @@ return true; } -// LDMDA loads multiple registers from consecutive memory locations using an -// address from a base register. -// The consecutive memory locations end at this address and the address just -// below the lowest of those locations -// can optionally be written back to the base register. +// LDMDA loads multiple registers from consecutive memory locations using +// an address from a base register. The consecutive memory locations end +// at this address and the address just below the lowest of those +// locations can optionally be written back to the base register. bool EmulateInstructionARM::EmulateLDMDA(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -4186,7 +4173,8 @@ return false; } - // if wback && registers == '0' then R[n] = R[n] - 4*BitCount(registers); + // if wback && registers == '0' then R[n] = R[n] - + // 4*BitCount(registers); if (wback && BitIsClear(registers, n)) { if (!success) return false; @@ -4207,11 +4195,10 @@ return true; } -// LDMDB loads multiple registers from consecutive memory locations using an -// address from a base register. The -// consecutive memory locations end just below this address, and the address of -// the lowest of those locations can -// be optionally written back to the base register. +// LDMDB loads multiple registers from consecutive memory locations using +// an address from a base register. The consecutive memory locations end +// just below this address, and the address of the lowest of those +// locations can be optionally written back to the base register. bool EmulateInstructionARM::EmulateLDMDB(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -4239,14 +4226,15 @@ const uint32_t addr_byte_size = GetAddressByteSize(); switch (encoding) { case eEncodingT1: - // n = UInt(Rn); registers = P:M:'0':register_list; wback = (W == '1'); + // n = UInt(Rn); registers = P:M:'0':register_list; wback = (W == + // '1'); n = Bits32(opcode, 19, 16); registers = Bits32(opcode, 15, 0); registers = registers & 0xdfff; // Make sure bit 13 is a zero. wback = BitIsSet(opcode, 21); - // if n == 15 || BitCount(registers) < 2 || (P == '1' && M == '1') then - // UNPREDICTABLE; + // if n == 15 || BitCount(registers) < 2 || (P == '1' && M == '1') + // then UNPREDICTABLE; if ((n == 15) || (BitCount(registers) < 2) || (BitIsSet(opcode, 14) && BitIsSet(opcode, 15))) return false; @@ -4324,7 +4312,8 @@ return false; } - // if wback && registers == '0' then R[n] = R[n] - 4*BitCount(registers); + // if wback && registers == '0' then R[n] = R[n] - + // 4*BitCount(registers); if (wback && BitIsClear(registers, n)) { if (!success) return false; @@ -4338,19 +4327,18 @@ return false; } - // if wback && registers == '1' then R[n] = bits(32) UNKNOWN; // Only - // possible for encoding A1 + // if wback && registers == '1' then R[n] = bits(32) UNKNOWN; // + // Only possible for encoding A1 if (wback && BitIsSet(registers, n)) return WriteBits32Unknown(n); } return true; } -// LDMIB loads multiple registers from consecutive memory locations using an -// address from a base register. The -// consecutive memory locations start just above this address, and thea ddress -// of the last of those locations can -// optinoally be written back to the base register. +// LDMIB loads multiple registers from consecutive memory locations using +// an address from a base register. The consecutive memory locations +// start just above this address, and thea ddress of the last of those +// locations can optinoally be written back to the base register. bool EmulateInstructionARM::EmulateLDMIB(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -4438,7 +4426,8 @@ return false; } - // if wback && registers == '0' then R[n] = R[n] + 4*BitCount(registers); + // if wback && registers == '0' then R[n] = R[n] + + // 4*BitCount(registers); if (wback && BitIsClear(registers, n)) { if (!success) return false; @@ -4452,18 +4441,17 @@ return false; } - // if wback && registers == '1' then R[n] = bits(32) UNKNOWN; // Only - // possible for encoding A1 + // if wback && registers == '1' then R[n] = bits(32) UNKNOWN; // + // Only possible for encoding A1 if (wback && BitIsSet(registers, n)) return WriteBits32Unknown(n); } return true; } -// Load Register (immediate) calculates an address from a base register value -// and -// an immediate offset, loads a word from memory, and writes to a register. -// LDR (immediate, Thumb) +// Load Register (immediate) calculates an address from a base register +// value and an immediate offset, loads a word from memory, and writes to +// a register. LDR (immediate, Thumb) bool EmulateInstructionARM::EmulateLDRRtRnImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -4538,10 +4526,9 @@ case eEncodingT4: // if Rn == '1111' then SEE LDR (literal); - // if P == '1' && U == '1' && W == '0' then SEE LDRT; - // if Rn == '1101' && P == '0' && U == '1' && W == '1' && imm8 == - // '00000100' then SEE POP; - // if P == '0' && W == '0' then UNDEFINED; + // if P == '1' && U == '1' && W == '0' then SEE LDRT; if Rn == + // '1101' && P == '0' && U == '1' && W == '1' && imm8 == '00000100' + // then SEE POP; if P == '0' && W == '0' then UNDEFINED; if (BitIsClear(opcode, 10) && BitIsClear(opcode, 8)) return false; @@ -4555,8 +4542,8 @@ add = BitIsSet(opcode, 9); wback = BitIsSet(opcode, 8); - // if (wback && n == t) || (t == 15 && InITBlock() && !LastInITBlock()) - // then UNPREDICTABLE; + // if (wback && n == t) || (t == 15 && InITBlock() && + // !LastInITBlock()) then UNPREDICTABLE; if ((wback && (Rn == Rt)) || ((Rt == 15) && InITBlock() && !LastInITBlock())) return false; @@ -4622,11 +4609,11 @@ return true; } -// STM (Store Multiple Increment After) stores multiple registers to consecutive -// memory locations using an address -// from a base register. The consecutive memory locations start at this -// address, and the address just above the last -// of those locations can optionally be written back to the base register. +// STM (Store Multiple Increment After) stores multiple registers to +// consecutive memory locations using an address from a base register. +// The consecutive memory locations start at this address, and the address +// just above the last of those locations can optionally be written back +// to the base register. bool EmulateInstructionARM::EmulateSTM(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -4671,7 +4658,8 @@ break; case eEncodingT2: - // n = UInt(Rn); registers = '0':M:'0':register_list; wback = (W == '1'); + // n = UInt(Rn); registers = '0':M:'0':register_list; wback = (W == + // '1'); n = Bits32(opcode, 19, 16); registers = Bits32(opcode, 15, 0); registers = registers & 0x5fff; // Make sure bits 15 & 13 are zeros. @@ -4724,8 +4712,8 @@ lowest_set_bit = i; // if i == n && wback && i != LowestSetBit(registers) then if ((i == n) && wback && (i != lowest_set_bit)) - // MemA[address,4] = bits(32) UNKNOWN; // Only possible for encodings - // T1 and A1 + // MemA[address,4] = bits(32) UNKNOWN; // Only possible for + // encodings T1 and A1 WriteBits32UnknownToMemory(address + offset); else { // MemA[address,4] = R[i]; @@ -4775,10 +4763,10 @@ } // STMDA (Store Multiple Decrement After) stores multiple registers to -// consecutive memory locations using an address -// from a base register. The consecutive memory locations end at this address, -// and the address just below the lowest -// of those locations can optionally be written back to the base register. +// consecutive memory locations using an address from a base register. +// The consecutive memory locations end at this address, and the address +// just below the lowest of those locations can optionally be written back +// to the base register. bool EmulateInstructionARM::EmulateSTMDA(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -4897,10 +4885,10 @@ } // STMDB (Store Multiple Decrement Before) stores multiple registers to -// consecutive memory locations using an address -// from a base register. The consecutive memory locations end just below this -// address, and the address of the first of -// those locations can optionally be written back to the base register. +// consecutive memory locations using an address from a base register. +// The consecutive memory locations end just below this address, and the +// address of the first of those locations can optionally be written back +// to the base register. bool EmulateInstructionARM::EmulateSTMDB(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -4937,7 +4925,8 @@ if ((BitIsSet(opcode, 21)) && (Bits32(opcode, 19, 16) == 13)) { // See PUSH } - // n = UInt(Rn); registers = '0':M:'0':register_list; wback = (W == '1'); + // n = UInt(Rn); registers = '0':M:'0':register_list; wback = (W == + // '1'); n = Bits32(opcode, 19, 16); registers = Bits32(opcode, 15, 0); registers = registers & 0x5fff; // Make sure bits 15 & 13 are zeros. @@ -4951,8 +4940,8 @@ break; case eEncodingA1: - // if W == '1' && Rn == '1101' && BitCount(register_list) >= 2 then SEE - // PUSH; + // if W == '1' && Rn == '1101' && BitCount(register_list) >= 2 then + // SEE PUSH; if (BitIsSet(opcode, 21) && (Bits32(opcode, 19, 16) == 13) && BitCount(Bits32(opcode, 15, 0)) >= 2) { // See Push @@ -4994,8 +4983,8 @@ lowest_set_bit = i; // if i == n && wback && i != LowestSetBit(registers) then if ((i == n) && wback && (i != lowest_set_bit)) - // MemA[address,4] = bits(32) UNKNOWN; // Only possible for encoding - // A1 + // MemA[address,4] = bits(32) UNKNOWN; // Only possible for + // encoding A1 WriteBits32UnknownToMemory(address + offset); else { // MemA[address,4] = R[i]; @@ -5046,10 +5035,10 @@ } // STMIB (Store Multiple Increment Before) stores multiple registers to -// consecutive memory locations using an address -// from a base register. The consecutive memory locations start just above this -// address, and the address of the last -// of those locations can optionally be written back to the base register. +// consecutive memory locations using an address from a base register. +// The consecutive memory locations start just above this address, and the +// address of the last of those locations can optionally be written back +// to the base register. bool EmulateInstructionARM::EmulateSTMIB(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -5168,10 +5157,9 @@ return true; } -// STR (store immediate) calculates an address from a base register value and an -// immediate offset, and stores a word -// from a register to memory. It can use offset, post-indexed, or pre-indexed -// addressing. +// STR (store immediate) calculates an address from a base register value +// and an immediate offset, and stores a word from a register to memory. +// It can use offset, post-indexed, or pre-indexed addressing. bool EmulateInstructionARM::EmulateSTRThumb(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -5244,10 +5232,10 @@ break; case eEncodingT4: - // if P == '1' && U == '1' && W == '0' then SEE STRT; - // if Rn == '1101' && P == '1' && U == '0' && W == '1' && imm8 == - // '00000100' then SEE PUSH; - // if Rn == '1111' || (P == '0' && W == '0') then UNDEFINED; + // if P == '1' && U == '1' && W == '0' then SEE STRT; if Rn == + // '1101' && P == '1' && U == '0' && W == '1' && imm8 == '00000100' + // then SEE PUSH; if Rn == '1111' || (P == '0' && W == '0') then + // UNDEFINED; if ((Bits32(opcode, 19, 16) == 15) || (BitIsClear(opcode, 10) && BitIsClear(opcode, 8))) return false; @@ -5335,10 +5323,9 @@ return true; } -// STR (Store Register) calculates an address from a base register value and an -// offset register value, stores a -// word from a register to memory. The offset register value can optionally be -// shifted. +// STR (Store Register) calculates an address from a base register value +// and an offset register value, stores a word from a register to memory. +// The offset register value can optionally be shifted. bool EmulateInstructionARM::EmulateSTRRegister(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -5375,9 +5362,8 @@ // EncodingSpecificOperations (); NullCheckIfThumbEE(n); switch (encoding) { case eEncodingT1: - // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified operation - // in ThumbEE"; - // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified + // operation in ThumbEE"; t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32(opcode, 2, 0); n = Bits32(opcode, 5, 3); m = Bits32(opcode, 8, 6); @@ -5423,8 +5409,8 @@ n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || - // (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == + // '0') || (W == '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = (BitIsClear(opcode, 24) || BitIsSet(opcode, 21)); @@ -5495,8 +5481,8 @@ EmulateInstruction::Context context; context.type = eContextRegisterStore; - // if UnalignedSupport() || address<1:0> == '00' || CurrentInstrSet() == - // InstrSet_ARM then + // if UnalignedSupport() || address<1:0> == '00' || CurrentInstrSet() + // == InstrSet_ARM then if (UnalignedSupport() || (BitIsClear(address, 1) && BitIsClear(address, 0)) || CurrentInstrSet() == eModeARM) { @@ -5584,8 +5570,8 @@ break; case eEncodingT3: - // if P == '1' && U == '1' && W == '0' then SEE STRBT; - // if Rn == '1111' || (P == '0' && W == '0') then UNDEFINED; + // if P == '1' && U == '1' && W == '0' then SEE STRBT; if Rn == + // '1111' || (P == '0' && W == '0') then UNDEFINED; if (Bits32(opcode, 19, 16) == 15) return false; @@ -5663,9 +5649,8 @@ } // STRH (register) calculates an address from a base register value and an -// offset register value, and stores a -// halfword from a register to memory. The offset register value can be shifted -// left by 0, 1, 2, or 3 bits. +// offset register value, and stores a halfword from a register to memory. +// The offset register value can be shifted left by 0, 1, 2, or 3 bits. bool EmulateInstructionARM::EmulateSTRHRegister(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -5696,9 +5681,8 @@ // EncodingSpecificOperations(); NullCheckIfThumbEE(n); switch (encoding) { case eEncodingT1: - // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified operation - // in ThumbEE"; - // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified + // operation in ThumbEE"; t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32(opcode, 2, 0); n = Bits32(opcode, 5, 3); m = Bits32(opcode, 8, 6); @@ -5745,8 +5729,8 @@ n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || - // (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == + // '0') || (W == '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = (BitIsClear(opcode, 24) || BitIsSet(opcode, 21)); @@ -5841,11 +5825,10 @@ return true; } -// Add with Carry (immediate) adds an immediate value and the carry flag value -// to a register value, -// and writes the result to the destination register. It can optionally update -// the condition flags -// based on the result. +// Add with Carry (immediate) adds an immediate value and the carry flag +// value to a register value, and writes the result to the destination +// register. It can optionally update the condition flags based on the +// result. bool EmulateInstructionARM::EmulateADCImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -5911,11 +5894,10 @@ return true; } -// Add with Carry (register) adds a register value, the carry flag value, and an -// optionally-shifted -// register value, and writes the result to the destination register. It can -// optionally update the -// condition flags based on the result. +// Add with Carry (register) adds a register value, the carry flag value, +// and an optionally-shifted register value, and writes the result to the +// destination register. It can optionally update the condition flags +// based on the result. bool EmulateInstructionARM::EmulateADCReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -5999,9 +5981,8 @@ return true; } -// This instruction adds an immediate value to the PC value to form a -// PC-relative address, -// and writes the result to the destination register. +// This instruction adds an immediate value to the PC value to form a PC- +// relative address, and writes the result to the destination register. bool EmulateInstructionARM::EmulateADR(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -6062,10 +6043,9 @@ return true; } -// This instruction performs a bitwise AND of a register value and an immediate -// value, and writes the result -// to the destination register. It can optionally update the condition flags -// based on the result. +// This instruction performs a bitwise AND of a register value and an +// immediate value, and writes the result to the destination register. It +// can optionally update the condition flags based on the result. bool EmulateInstructionARM::EmulateANDImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -6139,9 +6119,8 @@ } // This instruction performs a bitwise AND of a register value and an -// optionally-shifted register value, -// and writes the result to the destination register. It can optionally update -// the condition flags +// optionally-shifted register value, and writes the result to the +// destination register. It can optionally update the condition flags // based on the result. bool EmulateInstructionARM::EmulateANDReg(const uint32_t opcode, const ARMEncoding encoding) { @@ -6229,11 +6208,10 @@ return true; } -// Bitwise Bit Clear (immediate) performs a bitwise AND of a register value and -// the complement of an -// immediate value, and writes the result to the destination register. It can -// optionally update the -// condition flags based on the result. +// Bitwise Bit Clear (immediate) performs a bitwise AND of a register +// value and the complement of an immediate value, and writes the result +// to the destination register. It can optionally update the condition +// flags based on the result. bool EmulateInstructionARM::EmulateBICImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -6305,11 +6283,10 @@ return true; } -// Bitwise Bit Clear (register) performs a bitwise AND of a register value and -// the complement of an -// optionally-shifted register value, and writes the result to the destination -// register. -// It can optionally update the condition flags based on the result. +// Bitwise Bit Clear (register) performs a bitwise AND of a register value +// and the complement of an optionally-shifted register value, and writes +// the result to the destination register. It can optionally update the +// condition flags based on the result. bool EmulateInstructionARM::EmulateBICReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -6395,10 +6372,9 @@ return true; } -// LDR (immediate, ARM) calculates an address from a base register value and an -// immediate offset, loads a word -// from memory, and writes it to a register. It can use offset, post-indexed, -// or pre-indexed addressing. +// LDR (immediate, ARM) calculates an address from a base register value +// and an immediate offset, loads a word from memory, and writes it to a +// register. It can use offset, post-indexed, or pre-indexed addressing. bool EmulateInstructionARM::EmulateLDRImmediateARM(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -6433,14 +6409,14 @@ // if Rn == '1111' then SEE LDR (literal); // if P == '0' && W == '1' then SEE LDRT; // if Rn == '1101' && P == '0' && U == '1' && W == '0' && imm12 == - // '000000000100' then SEE POP; - // t == UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); + // '000000000100' then SEE POP; t == UInt(Rt); n = UInt(Rn); imm32 = + // ZeroExtend(imm12, 32); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); imm32 = Bits32(opcode, 11, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || - // (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == + // '0') || (W == '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = (BitIsClear(opcode, 24) || BitIsSet(opcode, 21)); @@ -6497,7 +6473,8 @@ // if t == 15 then if (t == 15) { - // if address<1:0> == '00' then LoadWritePC(data); else UNPREDICTABLE; + // if address<1:0> == '00' then LoadWritePC(data); else + // UNPREDICTABLE; if (BitIsClear(address, 1) && BitIsClear(address, 0)) { // LoadWritePC (data); context.type = eContextRegisterLoad; @@ -6532,10 +6509,9 @@ return true; } -// LDR (register) calculates an address from a base register value and an offset -// register value, loads a word -// from memory, and writes it to a register. The offset register value can -// optionally be shifted. +// LDR (register) calculates an address from a base register value and an +// offset register value, loads a word from memory, and writes it to a +// register. The offset register value can optionally be shifted. bool EmulateInstructionARM::EmulateLDRRegister(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -6573,9 +6549,8 @@ switch (encoding) { case eEncodingT1: - // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified operation - // in ThumbEE"; - // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified + // operation in ThumbEE"; t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32(opcode, 2, 0); n = Bits32(opcode, 5, 3); m = Bits32(opcode, 8, 6); @@ -6624,8 +6599,8 @@ n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || - // (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == + // '0') || (W == '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = (BitIsClear(opcode, 24) || BitIsSet(opcode, 21)); @@ -6661,8 +6636,8 @@ addr_t offset_addr; addr_t address; - // offset = Shift(R[m], shift_t, shift_n, APSR.C); -- Note "The APSR is an - // application level alias for the CPSR". + // offset = Shift(R[m], shift_t, shift_n, APSR.C); -- Note "The APSR + // is an application level alias for the CPSR". addr_t offset = Shift(Rm, shift_t, shift_n, Bit32(m_opcode_cpsr, APSR_C), &success); if (!success) @@ -6703,7 +6678,8 @@ // if t == 15 then if (t == 15) { - // if address<1:0> == '00' then LoadWritePC(data); else UNPREDICTABLE; + // if address<1:0> == '00' then LoadWritePC(data); else + // UNPREDICTABLE; if (BitIsClear(address, 1) && BitIsClear(address, 0)) { context.type = eContextRegisterLoad; context.SetRegisterPlusOffset(base_reg, address - Rn); @@ -6805,8 +6781,8 @@ break; case eEncodingT3: - // if P == '1' && U == '1' && W == '0' then SEE LDRBT; - // if P == '0' && W == '0' then UNDEFINED; + // if P == '1' && U == '1' && W == '0' then SEE LDRBT; if P == '0' + // && W == '0' then UNDEFINED; if (BitIsClear(opcode, 10) && BitIsClear(opcode, 8)) return false; @@ -6888,8 +6864,8 @@ } // LDRB (literal) calculates an address from the PC value and an immediate -// offset, loads a byte from memory, -// zero-extends it to form a 32-bit word and writes it to a register. +// offset, loads a byte from memory, zero-extends it to form a 32-bit word +// and writes it to a register. bool EmulateInstructionARM::EmulateLDRBLiteral(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -6968,10 +6944,9 @@ } // LDRB (register) calculates an address from a base register value and an -// offset rigister value, loads a byte from -// memory, zero-extends it to form a 32-bit word, and writes it to a register. -// The offset register value can -// optionally be shifted. +// offset rigister value, loads a byte from memory, zero-extends it to +// form a 32-bit word, and writes it to a register. The offset register +// value can optionally be shifted. bool EmulateInstructionARM::EmulateLDRBRegister(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -7049,8 +7024,8 @@ n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || - // (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == + // '0') || (W == '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = (BitIsClear(opcode, 24) || BitIsSet(opcode, 21)); @@ -7130,11 +7105,10 @@ return true; } -// LDRH (immediate, Thumb) calculates an address from a base register value and -// an immediate offset, loads a -// halfword from memory, zero-extends it to form a 32-bit word, and writes it to -// a register. It can use offset, -// post-indexed, or pre-indexed addressing. +// LDRH (immediate, Thumb) calculates an address from a base register +// value and an immediate offset, loads a halfword from memory, zero- +// extends it to form a 32-bit word, and writes it to a register. It can +// use offset, post-indexed, or pre-indexed addressing. bool EmulateInstructionARM::EmulateLDRHImmediate(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -7176,9 +7150,9 @@ break; case eEncodingT2: - // if Rt == '1111' then SEE "Unallocated memory hints"; - // if Rn == '1111' then SEE LDRH (literal); - // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); + // if Rt == '1111' then SEE "Unallocated memory hints"; if Rn == + // '1111' then SEE LDRH (literal); t = UInt(Rt); n = UInt(Rn); imm32 + // = ZeroExtend(imm12, 32); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); imm32 = Bits32(opcode, 11, 0); @@ -7194,11 +7168,10 @@ break; case eEncodingT3: - // if Rn == '1111' then SEE LDRH (literal); - // if Rt == '1111' && P == '1' && U == '0' && W == '0' then SEE - // "Unallocated memory hints"; - // if P == '1' && U == '1' && W == '0' then SEE LDRHT; - // if P == '0' && W == '0' then UNDEFINED; + // if Rn == '1111' then SEE LDRH (literal); if Rt == '1111' && P == + // '1' && U == '0' && W == '0' then SEE "Unallocated memory hints"; + // if P == '1' && U == '1' && W == '0' then SEE LDRHT; if P == '0' + // && W == '0' then UNDEFINED; if (BitIsClear(opcode, 10) && BitIsClear(opcode, 8)) return false; @@ -7280,8 +7253,8 @@ } // LDRH (literal) caculates an address from the PC value and an immediate -// offset, loads a halfword from memory, -// zero-extends it to form a 32-bit word, and writes it to a register. +// offset, loads a halfword from memory, zero-extends it to form a 32-bit +// word, and writes it to a register. bool EmulateInstructionARM::EmulateLDRHLiteral(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -7306,8 +7279,8 @@ // EncodingSpecificOperations(); NullCheckIfThumbEE(15); switch (encoding) { case eEncodingT1: - // if Rt == '1111' then SEE "Unallocated memory hints"; - // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == '1'); + // if Rt == '1111' then SEE "Unallocated memory hints"; t = + // UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == '1'); t = Bits32(opcode, 15, 12); imm32 = Bits32(opcode, 11, 0); add = BitIsSet(opcode, 23); @@ -7322,7 +7295,8 @@ uint32_t imm4H = Bits32(opcode, 11, 8); uint32_t imm4L = Bits32(opcode, 3, 0); - // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == '1'); + // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == + // '1'); t = Bits32(opcode, 15, 12); imm32 = (imm4H << 4) | imm4L; add = BitIsSet(opcode, 23); @@ -7381,11 +7355,10 @@ return true; } -// LDRH (literal) calculates an address from a base register value and an offset -// register value, loads a halfword -// from memory, zero-extends it to form a 32-bit word, and writes it to a -// register. The offset register value can -// be shifted left by 0, 1, 2, or 3 bits. +// LDRH (literal) calculates an address from a base register value and an +// offset register value, loads a halfword from memory, zero-extends it to +// form a 32-bit word, and writes it to a register. The offset register +// value can be shifted left by 0, 1, 2, or 3 bits. bool EmulateInstructionARM::EmulateLDRHRegister(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -7417,9 +7390,8 @@ // EncodingSpecificOperations(); NullCheckIfThumbEE(n); switch (encoding) { case eEncodingT1: - // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified operation - // in ThumbEE"; - // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified + // operation in ThumbEE"; t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32(opcode, 2, 0); n = Bits32(opcode, 5, 3); m = Bits32(opcode, 8, 6); @@ -7436,9 +7408,9 @@ break; case eEncodingT2: - // if Rn == '1111' then SEE LDRH (literal); - // if Rt == '1111' then SEE "Unallocated memory hints"; - // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + // if Rn == '1111' then SEE LDRH (literal); if Rt == '1111' then SEE + // "Unallocated memory hints"; t = UInt(Rt); n = UInt(Rn); m = + // UInt(Rm); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); @@ -7464,8 +7436,8 @@ n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || - // (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == + // '0') || (W == '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = (BitIsClear(opcode, 24) || BitIsSet(opcode, 21)); @@ -7558,11 +7530,10 @@ return true; } -// LDRSB (immediate) calculates an address from a base register value and an -// immediate offset, loads a byte from -// memory, sign-extends it to form a 32-bit word, and writes it to a register. -// It can use offset, post-indexed, -// or pre-indexed addressing. +// LDRSB (immediate) calculates an address from a base register value and +// an immediate offset, loads a byte from memory, sign-extends it to form +// a 32-bit word, and writes it to a register. It can use offset, post- +// indexed, or pre-indexed addressing. bool EmulateInstructionARM::EmulateLDRSBImmediate(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -7588,8 +7559,8 @@ switch (encoding) { case eEncodingT1: // if Rt == '1111' then SEE PLI; - // if Rn == '1111' then SEE LDRSB (literal); - // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); + // if Rn == '1111' then SEE LDRSB (literal); t = UInt(Rt); n = + // UInt(Rn); imm32 = ZeroExtend(imm12, 32); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); imm32 = Bits32(opcode, 11, 0); @@ -7607,9 +7578,9 @@ case eEncodingT2: // if Rt == '1111' && P == '1' && U == '0' && W == '0' then SEE PLI; - // if Rn == '1111' then SEE LDRSB (literal); - // if P == '1' && U == '1' && W == '0' then SEE LDRSBT; - // if P == '0' && W == '0' then UNDEFINED; + // if Rn == '1111' then SEE LDRSB (literal); if P == '1' && U == '1' + // && W == '0' then SEE LDRSBT; if P == '0' && W == '0' then + // UNDEFINED; if (BitIsClear(opcode, 10) && BitIsClear(opcode, 8)) return false; @@ -7633,9 +7604,9 @@ break; case eEncodingA1: { - // if Rn == '1111' then SEE LDRSB (literal); - // if P == '0' && W == '1' then SEE LDRSBT; - // t == UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, 32); + // if Rn == '1111' then SEE LDRSB (literal); if P == '0' && W == '1' + // then SEE LDRSBT; t == UInt(Rt); n = UInt(Rn); imm32 = + // ZeroExtend(imm4H:imm4L, 32); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); @@ -7643,8 +7614,8 @@ uint32_t imm4L = Bits32(opcode, 3, 0); imm32 = (imm4H << 4) | imm4L; - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || - // (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == + // '0') || (W == '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = (BitIsClear(opcode, 24) || BitIsSet(opcode, 21)); @@ -7709,9 +7680,9 @@ return true; } -// LDRSB (literal) calculates an address from the PC value and an immediate -// offset, loads a byte from memory, -// sign-extends it to form a 32-bit word, and writes tit to a register. +// LDRSB (literal) calculates an address from the PC value and an +// immediate offset, loads a byte from memory, sign-extends it to form a +// 32-bit word, and writes tit to a register. bool EmulateInstructionARM::EmulateLDRSBLiteral(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -7745,7 +7716,8 @@ break; case eEncodingA1: { - // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == '1'); + // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == + // '1'); t = Bits32(opcode, 15, 12); uint32_t imm4H = Bits32(opcode, 11, 8); uint32_t imm4L = Bits32(opcode, 3, 0); @@ -7796,11 +7768,10 @@ return true; } -// LDRSB (register) calculates an address from a base register value and an -// offset register value, loadsa byte from -// memory, sign-extends it to form a 32-bit word, and writes it to a register. -// The offset register value can be -// shifted left by 0, 1, 2, or 3 bits. +// LDRSB (register) calculates an address from a base register value and +// an offset register value, loadsa byte from memory, sign-extends it to +// form a 32-bit word, and writes it to a register. The offset register +// value can be shifted left by 0, 1, 2, or 3 bits. bool EmulateInstructionARM::EmulateLDRSBRegister(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -7846,8 +7817,8 @@ case eEncodingT2: // if Rt == '1111' then SEE PLI; - // if Rn == '1111' then SEE LDRSB (literal); - // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + // if Rn == '1111' then SEE LDRSB (literal); t = UInt(Rt); n = + // UInt(Rn); m = UInt(Rm); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); @@ -7867,14 +7838,14 @@ break; case eEncodingA1: - // if P == '0' && W == '1' then SEE LDRSBT; - // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + // if P == '0' && W == '1' then SEE LDRSBT; t = UInt(Rt); n = + // UInt(Rn); m = UInt(Rm); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || - // (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == + // '0') || (W == '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = BitIsClear(opcode, 24) || BitIsSet(opcode, 21); @@ -7957,11 +7928,10 @@ return true; } -// LDRSH (immediate) calculates an address from a base register value and an -// immediate offset, loads a halfword from -// memory, sign-extends it to form a 32-bit word, and writes it to a register. -// It can use offset, post-indexed, or -// pre-indexed addressing. +// LDRSH (immediate) calculates an address from a base register value and +// an immediate offset, loads a halfword from memory, sign-extends it to +// form a 32-bit word, and writes it to a register. It can use offset, +// post-indexed, or pre-indexed addressing. bool EmulateInstructionARM::EmulateLDRSHImmediate(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -7990,9 +7960,9 @@ // EncodingSpecificOperations(); NullCheckIfThumbEE(n); switch (encoding) { case eEncodingT1: - // if Rn == '1111' then SEE LDRSH (literal); - // if Rt == '1111' then SEE "Unallocated memory hints"; - // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); + // if Rn == '1111' then SEE LDRSH (literal); if Rt == '1111' then + // SEE "Unallocated memory hints"; t = UInt(Rt); n = UInt(Rn); imm32 + // = ZeroExtend(imm12, 32); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); imm32 = Bits32(opcode, 11, 0); @@ -8009,11 +7979,10 @@ break; case eEncodingT2: - // if Rn == '1111' then SEE LDRSH (literal); - // if Rt == '1111' && P == '1' && U == '0' && W == '0' then SEE - // "Unallocated memory hints"; - // if P == '1' && U == '1' && W == '0' then SEE LDRSHT; - // if P == '0' && W == '0' then UNDEFINED; + // if Rn == '1111' then SEE LDRSH (literal); if Rt == '1111' && P == + // '1' && U == '0' && W == '0' then SEE "Unallocated memory hints"; + // if P == '1' && U == '1' && W == '0' then SEE LDRSHT; if P == '0' + // && W == '0' then UNDEFINED; if (BitIsClear(opcode, 10) && BitIsClear(opcode, 8)) return false; @@ -8034,17 +8003,17 @@ break; case eEncodingA1: { - // if Rn == '1111' then SEE LDRSH (literal); - // if P == '0' && W == '1' then SEE LDRSHT; - // t == UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, 32); + // if Rn == '1111' then SEE LDRSH (literal); if P == '0' && W == '1' + // then SEE LDRSHT; t == UInt(Rt); n = UInt(Rn); imm32 = + // ZeroExtend(imm4H:imm4L, 32); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); uint32_t imm4H = Bits32(opcode, 11, 8); uint32_t imm4L = Bits32(opcode, 3, 0); imm32 = (imm4H << 4) | imm4L; - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || - // (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == + // '0') || (W == '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = BitIsClear(opcode, 24) || BitIsSet(opcode, 21); @@ -8118,9 +8087,9 @@ return true; } -// LDRSH (literal) calculates an address from the PC value and an immediate -// offset, loads a halfword from memory, -// sign-extends it to from a 32-bit word, and writes it to a register. +// LDRSH (literal) calculates an address from the PC value and an +// immediate offset, loads a halfword from memory, sign-extends it to from +// a 32-bit word, and writes it to a register. bool EmulateInstructionARM::EmulateLDRSHLiteral(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -8145,8 +8114,8 @@ // EncodingSpecificOperations(); NullCheckIfThumbEE(15); switch (encoding) { case eEncodingT1: - // if Rt == '1111' then SEE "Unallocated memory hints"; - // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == '1'); + // if Rt == '1111' then SEE "Unallocated memory hints"; t = + // UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == '1'); t = Bits32(opcode, 15, 12); imm32 = Bits32(opcode, 11, 0); add = BitIsSet(opcode, 23); @@ -8158,7 +8127,8 @@ break; case eEncodingA1: { - // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == '1'); + // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == + // '1'); t = Bits32(opcode, 15, 12); uint32_t imm4H = Bits32(opcode, 11, 8); uint32_t imm4L = Bits32(opcode, 3, 0); @@ -8217,11 +8187,10 @@ return true; } -// LDRSH (register) calculates an address from a base register value and an -// offset register value, loads a halfword -// from memory, sign-extends it to form a 32-bit word, and writes it to a -// register. The offset register value can be -// shifted left by 0, 1, 2, or 3 bits. +// LDRSH (register) calculates an address from a base register value and +// an offset register value, loads a halfword from memory, sign-extends it +// to form a 32-bit word, and writes it to a register. The offset +// register value can be shifted left by 0, 1, 2, or 3 bits. bool EmulateInstructionARM::EmulateLDRSHRegister(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -8253,9 +8222,8 @@ // EncodingSpecificOperations(); NullCheckIfThumbEE(n); switch (encoding) { case eEncodingT1: - // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified operation - // in ThumbEE"; - // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + // if CurrentInstrSet() == InstrSet_ThumbEE then SEE "Modified + // operation in ThumbEE"; t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); t = Bits32(opcode, 2, 0); n = Bits32(opcode, 5, 3); m = Bits32(opcode, 8, 6); @@ -8272,9 +8240,9 @@ break; case eEncodingT2: - // if Rn == '1111' then SEE LDRSH (literal); - // if Rt == '1111' then SEE "Unallocated memory hints"; - // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + // if Rn == '1111' then SEE LDRSH (literal); if Rt == '1111' then + // SEE "Unallocated memory hints"; t = UInt(Rt); n = UInt(Rn); m = + // UInt(Rm); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); @@ -8295,14 +8263,14 @@ break; case eEncodingA1: - // if P == '0' && W == '1' then SEE LDRSHT; - // t = UInt(Rt); n = UInt(Rn); m = UInt(Rm); + // if P == '0' && W == '1' then SEE LDRSHT; t = UInt(Rt); n = + // UInt(Rn); m = UInt(Rm); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || - // (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == + // '0') || (W == '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = BitIsClear(opcode, 24) || BitIsSet(opcode, 21); @@ -8398,10 +8366,10 @@ return true; } -// SXTB extracts an 8-bit value from a register, sign-extends it to 32 bits, and -// writes the result to the destination -// register. You can specifiy a rotation by 0, 8, 16, or 24 bits before -// extracting the 8-bit value. +// SXTB extracts an 8-bit value from a register, sign-extends it to 32 +// bits, and writes the result to the destination register. You can +// specifiy a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit +// value. bool EmulateInstructionARM::EmulateSXTB(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -8483,10 +8451,10 @@ return true; } -// SXTH extracts a 16-bit value from a register, sign-extends it to 32 bits, and -// writes the result to the destination -// register. You can specify a rotation by 0, 8, 16, or 24 bits before -// extracting the 16-bit value. +// SXTH extracts a 16-bit value from a register, sign-extends it to 32 +// bits, and writes the result to the destination register. You can +// specify a rotation by 0, 8, 16, or 24 bits before extracting the 16-bit +// value. bool EmulateInstructionARM::EmulateSXTH(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -8568,10 +8536,10 @@ return true; } -// UXTB extracts an 8-bit value from a register, zero-extneds it to 32 bits, and -// writes the result to the destination -// register. You can specify a rotation by 0, 8, 16, or 24 bits before -// extracting the 8-bit value. +// UXTB extracts an 8-bit value from a register, zero-extneds it to 32 +// bits, and writes the result to the destination register. You can +// specify a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit +// value. bool EmulateInstructionARM::EmulateUXTB(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -8651,10 +8619,10 @@ return true; } -// UXTH extracts a 16-bit value from a register, zero-extends it to 32 bits, and -// writes the result to the destination -// register. You can specify a rotation by 0, 8, 16, or 24 bits before -// extracting the 16-bit value. +// UXTH extracts a 16-bit value from a register, zero-extends it to 32 +// bits, and writes the result to the destination register. You can +// specify a rotation by 0, 8, 16, or 24 bits before extracting the 16-bit +// value. bool EmulateInstructionARM::EmulateUXTH(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -8733,9 +8701,8 @@ return true; } -// RFE (Return From Exception) loads the PC and the CPSR from the word at the -// specified address and the following -// word respectively. +// RFE (Return From Exception) loads the PC and the CPSR from the word at +// the specified address and the following word respectively. bool EmulateInstructionARM::EmulateRFE(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -8780,7 +8747,8 @@ break; case eEncodingT2: - // n = UInt(Rn); wback = (W == '1'); increment = TRUE; wordhigher = FALSE; + // n = UInt(Rn); wback = (W == '1'); increment = TRUE; wordhigher = + // FALSE; n = Bits32(opcode, 19, 16); wback = BitIsSet(opcode, 21); increment = true; @@ -8815,8 +8783,8 @@ return false; } - // if !CurrentModeIsPrivileged() || CurrentInstrSet() == InstrSet_ThumbEE - // then + // if !CurrentModeIsPrivileged() || CurrentInstrSet() == + // InstrSet_ThumbEE then if (!CurrentModeIsPrivileged()) // UNPREDICTABLE; return false; @@ -8879,10 +8847,9 @@ } // Bitwise Exclusive OR (immediate) performs a bitwise exclusive OR of a -// register value and an immediate value, -// and writes the result to the destination register. It can optionally update -// the condition flags based on -// the result. +// register value and an immediate value, and writes the result to the +// destination register. It can optionally update the condition flags +// based on the result. bool EmulateInstructionARM::EmulateEORImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -8957,11 +8924,10 @@ return true; } -// Bitwise Exclusive OR (register) performs a bitwise exclusive OR of a register -// value and an -// optionally-shifted register value, and writes the result to the destination -// register. -// It can optionally update the condition flags based on the result. +// Bitwise Exclusive OR (register) performs a bitwise exclusive OR of a +// register value and an optionally-shifted register value, and writes the +// result to the destination register. It can optionally update the +// condition flags based on the result. bool EmulateInstructionARM::EmulateEORReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9050,11 +9016,10 @@ return true; } -// Bitwise OR (immediate) performs a bitwise (inclusive) OR of a register value -// and an immediate value, and -// writes the result to the destination register. It can optionally update the -// condition flags based -// on the result. +// Bitwise OR (immediate) performs a bitwise (inclusive) OR of a register +// value and an immediate value, and writes the result to the destination +// register. It can optionally update the condition flags based on the +// result. bool EmulateInstructionARM::EmulateORRImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9127,11 +9092,10 @@ return true; } -// Bitwise OR (register) performs a bitwise (inclusive) OR of a register value -// and an optionally-shifted register -// value, and writes the result to the destination register. It can optionally -// update the condition flags based -// on the result. +// Bitwise OR (register) performs a bitwise (inclusive) OR of a register +// value and an optionally-shifted register value, and writes the result +// to the destination register. It can optionally update the condition +// flags based on the result. bool EmulateInstructionARM::EmulateORRReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9218,10 +9182,9 @@ return true; } -// Reverse Subtract (immediate) subtracts a register value from an immediate -// value, and writes the result to -// the destination register. It can optionally update the condition flags based -// on the result. +// Reverse Subtract (immediate) subtracts a register value from an +// immediate value, and writes the result to the destination register. It +// can optionally update the condition flags based on the result. bool EmulateInstructionARM::EmulateRSBImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9295,9 +9258,9 @@ } // Reverse Subtract (register) subtracts a register value from an -// optionally-shifted register value, and writes the -// result to the destination register. It can optionally update the condition -// flags based on the result. +// optionally-shifted register value, and writes the result to the +// destination register. It can optionally update the condition flags +// based on the result. bool EmulateInstructionARM::EmulateRSBReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9376,11 +9339,10 @@ return true; } -// Reverse Subtract with Carry (immediate) subtracts a register value and the -// value of NOT (Carry flag) from -// an immediate value, and writes the result to the destination register. It can -// optionally update the condition -// flags based on the result. +// Reverse Subtract with Carry (immediate) subtracts a register value and +// the value of NOT (Carry flag) from an immediate value, and writes the +// result to the destination register. It can optionally update the +// condition flags based on the result. bool EmulateInstructionARM::EmulateRSCImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9439,11 +9401,10 @@ return true; } -// Reverse Subtract with Carry (register) subtracts a register value and the -// value of NOT (Carry flag) from an -// optionally-shifted register value, and writes the result to the destination -// register. It can optionally update the -// condition flags based on the result. +// Reverse Subtract with Carry (register) subtracts a register value and +// the value of NOT (Carry flag) from an optionally-shifted register +// value, and writes the result to the destination register. It can +// optionally update the condition flags based on the result. bool EmulateInstructionARM::EmulateRSCReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9512,10 +9473,10 @@ return true; } -// Subtract with Carry (immediate) subtracts an immediate value and the value of -// NOT (Carry flag) from a register value, and writes the result to the -// destination register. -// It can optionally update the condition flags based on the result. +// Subtract with Carry (immediate) subtracts an immediate value and the +// value of NOT (Carry flag) from a register value, and writes the result +// to the destination register. It can optionally update the condition +// flags based on the result. bool EmulateInstructionARM::EmulateSBCImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9582,11 +9543,10 @@ return true; } -// Subtract with Carry (register) subtracts an optionally-shifted register value -// and the value of -// NOT (Carry flag) from a register value, and writes the result to the -// destination register. -// It can optionally update the condition flags based on the result. +// Subtract with Carry (register) subtracts an optionally-shifted register +// value and the value of NOT (Carry flag) from a register value, and +// writes the result to the destination register. It can optionally update +// the condition flags based on the result. bool EmulateInstructionARM::EmulateSBCReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9671,10 +9631,9 @@ return true; } -// This instruction subtracts an immediate value from a register value, and -// writes the result -// to the destination register. It can optionally update the condition flags -// based on the result. +// This instruction subtracts an immediate value from a register value, +// and writes the result to the destination register. It can optionally +// update the condition flags based on the result. bool EmulateInstructionARM::EmulateSUBImmThumb(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9765,10 +9724,9 @@ return true; } -// This instruction subtracts an immediate value from a register value, and -// writes the result -// to the destination register. It can optionally update the condition flags -// based on the result. +// This instruction subtracts an immediate value from a register value, +// and writes the result to the destination register. It can optionally +// update the condition flags based on the result. bool EmulateInstructionARM::EmulateSUBImmARM(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9843,10 +9801,9 @@ return true; } -// Test Equivalence (immediate) performs a bitwise exclusive OR operation on a -// register value and an -// immediate value. It updates the condition flags based on the result, and -// discards the result. +// Test Equivalence (immediate) performs a bitwise exclusive OR operation +// on a register value and an immediate value. It updates the condition +// flags based on the result, and discards the result. bool EmulateInstructionARM::EmulateTEQImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9903,11 +9860,10 @@ return true; } -// Test Equivalence (register) performs a bitwise exclusive OR operation on a -// register value and an -// optionally-shifted register value. It updates the condition flags based on -// the result, and discards -// the result. +// Test Equivalence (register) performs a bitwise exclusive OR operation +// on a register value and an optionally-shifted register value. It +// updates the condition flags based on the result, and discards the +// result. bool EmulateInstructionARM::EmulateTEQReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -9971,9 +9927,9 @@ return true; } -// Test (immediate) performs a bitwise AND operation on a register value and an -// immediate value. -// It updates the condition flags based on the result, and discards the result. +// Test (immediate) performs a bitwise AND operation on a register value +// and an immediate value. It updates the condition flags based on the +// result, and discards the result. bool EmulateInstructionARM::EmulateTSTImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -10030,9 +9986,9 @@ return true; } -// Test (register) performs a bitwise AND operation on a register value and an -// optionally-shifted register value. -// It updates the condition flags based on the result, and discards the result. +// Test (register) performs a bitwise AND operation on a register value +// and an optionally-shifted register value. It updates the condition +// flags based on the result, and discards the result. bool EmulateInstructionARM::EmulateTSTReg(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -10327,7 +10283,8 @@ switch (encoding) { case eEncodingT1: - // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = !InITBlock(); + // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = + // !InITBlock(); d = Bits32(opcode, 2, 0); n = Bits32(opcode, 5, 3); m = Bits32(opcode, 8, 6); @@ -10366,8 +10323,8 @@ break; case eEncodingA1: - // if Rn == '1101' then SEE SUB (SP minus register); - // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == '1'); + // if Rn == '1101' then SEE SUB (SP minus register); d = UInt(Rd); n + // = UInt(Rn); m = UInt(Rm); setflags = (S == '1'); d = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); @@ -10404,14 +10361,9 @@ AddWithCarryResult res = AddWithCarry(Rn, ~shifted, 1); // if d == 15 then // Can only occur for ARM encoding - // ALUWritePC(result); // setflags is always FALSE here - // else - // R[d] = result; - // if setflags then - // APSR.N = result<31>; - // APSR.Z = IsZeroBit(result); - // APSR.C = carry; - // APSR.V = overflow; + // ALUWritePC(result); // setflags is always FALSE here else R[d] = + // result; if setflags then APSR.N = result<31>; APSR.Z = + // IsZeroBit(result); APSR.C = carry; APSR.V = overflow; EmulateInstruction::Context context; context.type = eContextArithmetic; @@ -10429,10 +10381,10 @@ } // A8.6.202 STREX -// Store Register Exclusive calculates an address from a base register value and -// an immediate offset, and stores a -// word from a register to memory if the executing processor has exclusive -// access to the memory addressed. +// Store Register Exclusive calculates an address from a base register +// value and an immediate offset, and stores a word from a register to +// memory if the executing processor has exclusive access to the memory +// addressed. bool EmulateInstructionARM::EmulateSTREX(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -10457,8 +10409,8 @@ switch (encoding) { case eEncodingT1: - // d = UInt(Rd); t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm8:'00', - // 32); + // d = UInt(Rd); t = UInt(Rt); n = UInt(Rn); imm32 = + // ZeroExtend(imm8:'00', 32); d = Bits32(opcode, 11, 8); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); @@ -10475,8 +10427,8 @@ break; case eEncodingA1: - // d = UInt(Rd); t = UInt(Rt); n = UInt(Rn); imm32 = Zeros(32); // Zero - // offset + // d = UInt(Rd); t = UInt(Rt); n = UInt(Rn); imm32 = Zeros(32); // + // Zero offset d = Bits32(opcode, 15, 12); t = Bits32(opcode, 3, 0); n = Bits32(opcode, 19, 16); @@ -10511,9 +10463,9 @@ context.type = eContextRegisterStore; context.SetRegisterToRegisterPlusOffset(data_reg, base_reg, imm32); - // if ExclusiveMonitorsPass(address,4) then - // if (ExclusiveMonitorsPass (address, addr_byte_size)) -- For now, for the - // sake of emulation, we will say this + // if ExclusiveMonitorsPass(address,4) then if (ExclusiveMonitorsPass + // (address, addr_byte_size)) -- For now, for the sake of emulation, + // we will say this // always return // true. if (true) { @@ -10572,7 +10524,8 @@ n = Bits32(opcode, 19, 16); imm32 = Bits32(opcode, 11, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == + // '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = BitIsClear(opcode, 24) || BitIsSet(opcode, 21); @@ -10663,13 +10616,14 @@ case eEncodingA1: // if P == '0' && W == '1' then SEE STRT; // if Rn == '1101' && P == '1' && U == '0' && W == '1' && imm12 == - // '000000000100' then SEE PUSH; - // t = UInt(Rt); n = UInt(Rn); imm32 = ZeroExtend(imm12, 32); + // '000000000100' then SEE PUSH; t = UInt(Rt); n = UInt(Rn); imm32 = + // ZeroExtend(imm12, 32); t = Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); imm32 = Bits32(opcode, 11, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == + // '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = BitIsClear(opcode, 24) || BitIsSet(opcode, 21); @@ -10741,10 +10695,10 @@ } // A8.6.66 LDRD (immediate) -// Load Register Dual (immediate) calculates an address from a base register -// value and an immediate offset, loads two -// words from memory, and writes them to two registers. It can use offset, -// post-indexed, or pre-indexed addressing. +// Load Register Dual (immediate) calculates an address from a base +// register value and an immediate offset, loads two words from memory, +// and writes them to two registers. It can use offset, post-indexed, or +// pre-indexed addressing. bool EmulateInstructionARM::EmulateLDRDImmediate(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -10770,10 +10724,9 @@ switch (encoding) { case eEncodingT1: - // if P == '0' && W == '0' then SEE 'Related encodings'; - // if Rn == '1111' then SEE LDRD (literal); - // t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = - // ZeroExtend(imm8:'00', 32); + // if P == '0' && W == '0' then SEE 'Related encodings'; if Rn == + // '1111' then SEE LDRD (literal); t = UInt(Rt); t2 = UInt(Rt2); n = + // UInt(Rn); imm32 = ZeroExtend(imm8:'00', 32); t = Bits32(opcode, 15, 12); t2 = Bits32(opcode, 11, 8); n = Bits32(opcode, 19, 16); @@ -10795,10 +10748,9 @@ break; case eEncodingA1: - // if Rn == '1111' then SEE LDRD (literal); - // if Rt<0> == '1' then UNPREDICTABLE; - // t = UInt(Rt); t2 = t+1; n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, - // 32); + // if Rn == '1111' then SEE LDRD (literal); if Rt<0> == '1' then + // UNPREDICTABLE; t = UInt(Rt); t2 = t+1; n = UInt(Rn); imm32 = + // ZeroExtend(imm4H:imm4L, 32); t = Bits32(opcode, 15, 12); if (BitIsSet(t, 0)) return false; @@ -10806,7 +10758,8 @@ n = Bits32(opcode, 19, 16); imm32 = (Bits32(opcode, 11, 8) << 4) | Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == + // '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = BitIsClear(opcode, 24) || BitIsSet(opcode, 21); @@ -10890,10 +10843,10 @@ } // A8.6.68 LDRD (register) -// Load Register Dual (register) calculates an address from a base register -// value and a register offset, loads two -// words from memory, and writes them to two registers. It can use offset, -// post-indexed or pre-indexed addressing. +// Load Register Dual (register) calculates an address from a base +// register value and a register offset, loads two words from memory, and +// writes them to two registers. It can use offset, post-indexed or pre- +// indexed addressing. bool EmulateInstructionARM::EmulateLDRDRegister(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -10928,7 +10881,8 @@ n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == + // '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = BitIsClear(opcode, 24) || BitIsSet(opcode, 21); @@ -11020,10 +10974,10 @@ } // A8.6.200 STRD (immediate) -// Store Register Dual (immediate) calculates an address from a base register -// value and an immediate offset, and -// stores two words from two registers to memory. It can use offset, -// post-indexed, or pre-indexed addressing. +// Store Register Dual (immediate) calculates an address from a base +// register value and an immediate offset, and stores two words from two +// registers to memory. It can use offset, post-indexed, or pre-indexed +// addressing. bool EmulateInstructionARM::EmulateSTRDImm(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -11049,8 +11003,8 @@ switch (encoding) { case eEncodingT1: - // if P == '0' && W == '0' then SEE 'Related encodings'; - // t = UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = + // if P == '0' && W == '0' then SEE 'Related encodings'; t = + // UInt(Rt); t2 = UInt(Rt2); n = UInt(Rn); imm32 = // ZeroExtend(imm8:'00', 32); t = Bits32(opcode, 15, 12); t2 = Bits32(opcode, 11, 8); @@ -11074,8 +11028,8 @@ case eEncodingA1: // if Rt<0> == '1' then UNPREDICTABLE; - // t = UInt(Rt); t2 = t+1; n = UInt(Rn); imm32 = ZeroExtend(imm4H:imm4L, - // 32); + // t = UInt(Rt); t2 = t+1; n = UInt(Rn); imm32 = + // ZeroExtend(imm4H:imm4L, 32); t = Bits32(opcode, 15, 12); if (BitIsSet(t, 0)) return false; @@ -11084,7 +11038,8 @@ n = Bits32(opcode, 19, 16); imm32 = (Bits32(opcode, 11, 8) << 4) | Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == + // '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = BitIsClear(opcode, 24) || BitIsSet(opcode, 21); @@ -11212,7 +11167,8 @@ n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == '1'); + // index = (P == '1'); add = (U == '1'); wback = (P == '0') || (W == + // '1'); index = BitIsSet(opcode, 24); add = BitIsSet(opcode, 23); wback = BitIsClear(opcode, 24) || BitIsSet(opcode, 21); @@ -11313,9 +11269,9 @@ } // A8.6.319 VLDM -// Vector Load Multiple loads multiple extension registers from consecutive -// memory locations using an address from -// an ARM core register. +// Vector Load Multiple loads multiple extension registers from +// consecutive memory locations using an address from an ARM core +// register. bool EmulateInstructionARM::EmulateVLDM(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -11328,7 +11284,8 @@ S[d+r] = MemA[address,4]; address = address+4; else word1 = MemA[address,4]; word2 = MemA[address+4,4]; address = address+8; - // Combine the word-aligned words in the correct order for current endianness. + // Combine the word-aligned words in the correct order for + // current endianness. D[d+r] = if BigEndian() then word1:word2 else word2:word1; #endif @@ -11347,15 +11304,15 @@ case eEncodingT1: case eEncodingA1: // if P == '0' && U == '0' && W == '0' then SEE 'Related encodings'; - // if P == '0' && U == '1' && W == '1' && Rn == '1101' then SEE VPOP; - // if P == '1' && W == '0' then SEE VLDR; - // if P == U && W == '1' then UNDEFINED; + // if P == '0' && U == '1' && W == '1' && Rn == '1101' then SEE + // VPOP; if P == '1' && W == '0' then SEE VLDR; if P == U && W == + // '1' then UNDEFINED; if ((Bit32(opcode, 24) == Bit32(opcode, 23)) && BitIsSet(opcode, 21)) return false; - // // Remaining combinations are PUW = 010 (IA without !), 011 (IA with - // !), 101 (DB with !) - // single_regs = FALSE; add = (U == '1'); wback = (W == '1'); + // // Remaining combinations are PUW = 010 (IA without !), 011 (IA + // with !), 101 (DB with !) single_regs = FALSE; add = (U == '1'); + // wback = (W == '1'); single_regs = false; add = BitIsSet(opcode, 23); wback = BitIsSet(opcode, 21); @@ -11382,16 +11339,15 @@ case eEncodingT2: case eEncodingA2: // if P == '0' && U == '0' && W == '0' then SEE 'Related encodings'; - // if P == '0' && U == '1' && W == '1' && Rn == '1101' then SEE VPOP; - // if P == '1' && W == '0' then SEE VLDR; - // if P == U && W == '1' then UNDEFINED; + // if P == '0' && U == '1' && W == '1' && Rn == '1101' then SEE + // VPOP; if P == '1' && W == '0' then SEE VLDR; if P == U && W == + // '1' then UNDEFINED; if ((Bit32(opcode, 24) == Bit32(opcode, 23)) && BitIsSet(opcode, 21)) return false; - // // Remaining combinations are PUW = 010 (IA without !), 011 (IA with - // !), 101 (DB with !) - // single_regs = TRUE; add = (U == '1'); wback = (W == '1'); d = - // UInt(Vd:D); n = UInt(Rn); + // // Remaining combinations are PUW = 010 (IA without !), 011 (IA + // with !), 101 (DB with !) single_regs = TRUE; add = (U == '1'); + // wback = (W == '1'); d = UInt(Vd:D); n = UInt(Rn); single_regs = true; add = BitIsSet(opcode, 23); wback = BitIsSet(opcode, 21); @@ -11483,9 +11439,9 @@ return false; address = address + 8; - // // Combine the word-aligned words in the correct order for current - // endianness. - // D[d+r] = if BigEndian() then word1:word2 else word2:word1; + // // Combine the word-aligned words in the correct order for + // current endianness. D[d+r] = if BigEndian() then word1:word2 + // else word2:word1; uint64_t data; if (GetByteOrder() == eByteOrderBig) { data = word1; @@ -11505,9 +11461,9 @@ } // A8.6.399 VSTM -// Vector Store Multiple stores multiple extension registers to consecutive -// memory locations using an address from an -// ARM core register. +// Vector Store Multiple stores multiple extension registers to +// consecutive memory locations using an address from an ARM core +// register. bool EmulateInstructionARM::EmulateVSTM(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -11519,7 +11475,8 @@ if single_regs then MemA[address,4] = S[d+r]; address = address+4; else - // Store as two word-aligned words in the correct order for current endianness. + // Store as two word-aligned words in the correct order + // for current endianness. MemA[address,4] = if BigEndian() then D[d+r]<63:32> else D[d+r]<31:0>; MemA[address+4,4] = if BigEndian() then D[d+r]<31:0> else D[d+r]<63:32>; address = address+8; @@ -11540,15 +11497,15 @@ case eEncodingT1: case eEncodingA1: // if P == '0' && U == '0' && W == '0' then SEE 'Related encodings'; - // if P == '1' && U == '0' && W == '1' && Rn == '1101' then SEE VPUSH; - // if P == '1' && W == '0' then SEE VSTR; - // if P == U && W == '1' then UNDEFINED; + // if P == '1' && U == '0' && W == '1' && Rn == '1101' then SEE + // VPUSH; if P == '1' && W == '0' then SEE VSTR; if P == U && W == + // '1' then UNDEFINED; if ((Bit32(opcode, 24) == Bit32(opcode, 23)) && BitIsSet(opcode, 21)) return false; - // // Remaining combinations are PUW = 010 (IA without !), 011 (IA with - // !), 101 (DB with !) - // single_regs = FALSE; add = (U == '1'); wback = (W == '1'); + // // Remaining combinations are PUW = 010 (IA without !), 011 (IA + // with !), 101 (DB with !) single_regs = FALSE; add = (U == '1'); + // wback = (W == '1'); single_regs = false; add = BitIsSet(opcode, 23); wback = BitIsSet(opcode, 21); @@ -11575,16 +11532,15 @@ case eEncodingT2: case eEncodingA2: // if P == '0' && U == '0' && W == '0' then SEE 'Related encodings'; - // if P == '1' && U == '0' && W == '1' && Rn == '1101' then SEE VPUSH; - // if P == '1' && W == '0' then SEE VSTR; - // if P == U && W == '1' then UNDEFINED; + // if P == '1' && U == '0' && W == '1' && Rn == '1101' then SEE + // VPUSH; if P == '1' && W == '0' then SEE VSTR; if P == U && W == + // '1' then UNDEFINED; if ((Bit32(opcode, 24) == Bit32(opcode, 23)) && BitIsSet(opcode, 21)) return false; - // // Remaining combinations are PUW = 010 (IA without !), 011 (IA with - // !), 101 (DB with !) - // single_regs = TRUE; add = (U == '1'); wback = (W == '1'); d = - // UInt(Vd:D); n = UInt(Rn); + // // Remaining combinations are PUW = 010 (IA without !), 011 (IA + // with !), 101 (DB with !) single_regs = TRUE; add = (U == '1'); + // wback = (W == '1'); d = UInt(Vd:D); n = UInt(Rn); single_regs = true; add = BitIsSet(opcode, 23); wback = BitIsSet(opcode, 21); @@ -11664,12 +11620,10 @@ address = address + 4; } else { - // // Store as two word-aligned words in the correct order for current - // endianness. - // MemA[address,4] = if BigEndian() then D[d+r]<63:32> else - // D[d+r]<31:0>; - // MemA[address+4,4] = if BigEndian() then D[d+r]<31:0> else - // D[d+r]<63:32>; + // // Store as two word-aligned words in the correct order for + // current endianness. MemA[address,4] = if BigEndian() then + // D[d+r]<63:32> else D[d+r]<31:0>; MemA[address+4,4] = if + // BigEndian() then D[d+r]<31:0> else D[d+r]<63:32>; uint64_t data = ReadRegisterUnsigned(eRegisterKindDWARF, start_reg + d + r, 0, &success); if (!success) @@ -11711,9 +11665,8 @@ } // A8.6.320 -// This instruction loads a single extension register from memory, using an -// address from an ARM core register, with -// an optional offset. +// This instruction loads a single extension register from memory, using +// an address from an ARM core register, with an optional offset. bool EmulateInstructionARM::EmulateVLDR(const uint32_t opcode, ARMEncoding encoding) { #if 0 @@ -11725,7 +11678,8 @@ S[d] = MemA[address,4]; else word1 = MemA[address,4]; word2 = MemA[address+4,4]; - // Combine the word-aligned words in the correct order for current endianness. + // Combine the word-aligned words in the correct order for + // current endianness. D[d] = if BigEndian() then word1:word2 else word2:word1; #endif @@ -11741,8 +11695,8 @@ switch (encoding) { case eEncodingT1: case eEncodingA1: - // single_reg = FALSE; add = (U == '1'); imm32 = ZeroExtend(imm8:'00', - // 32); + // single_reg = FALSE; add = (U == '1'); imm32 = + // ZeroExtend(imm8:'00', 32); single_reg = false; add = BitIsSet(opcode, 23); imm32 = Bits32(opcode, 7, 0) << 2; @@ -11755,7 +11709,8 @@ case eEncodingT2: case eEncodingA2: - // single_reg = TRUE; add = (U == '1'); imm32 = ZeroExtend(imm8:'00', 32); + // single_reg = TRUE; add = (U == '1'); imm32 = + // ZeroExtend(imm8:'00', 32); single_reg = true; add = BitIsSet(opcode, 23); imm32 = Bits32(opcode, 7, 0) << 2; @@ -11817,9 +11772,9 @@ MemARead(context, address + 4, addr_byte_size, 0, &success); if (!success) return false; - // // Combine the word-aligned words in the correct order for current - // endianness. - // D[d] = if BigEndian() then word1:word2 else word2:word1; + // // Combine the word-aligned words in the correct order for + // current endianness. D[d] = if BigEndian() then word1:word2 else + // word2:word1; uint64_t data64; if (GetByteOrder() == eByteOrderBig) { data64 = word1; @@ -11839,8 +11794,7 @@ // A8.6.400 VSTR // This instruction stores a signle extension register to memory, using an -// address from an ARM core register, with an -// optional offset. +// address from an ARM core register, with an optional offset. bool EmulateInstructionARM::EmulateVSTR(const uint32_t opcode, ARMEncoding encoding) { #if 0 @@ -11850,7 +11804,8 @@ if single_reg then MemA[address,4] = S[d]; else - // Store as two word-aligned words in the correct order for current endianness. + // Store as two word-aligned words in the correct order for + // current endianness. MemA[address,4] = if BigEndian() then D[d]<63:32> else D[d]<31:0>; MemA[address+4,4] = if BigEndian() then D[d]<31:0> else D[d]<63:32>; #endif @@ -11867,8 +11822,8 @@ switch (encoding) { case eEncodingT1: case eEncodingA1: - // single_reg = FALSE; add = (U == '1'); imm32 = ZeroExtend(imm8:'00', - // 32); + // single_reg = FALSE; add = (U == '1'); imm32 = + // ZeroExtend(imm8:'00', 32); single_reg = false; add = BitIsSet(opcode, 23); imm32 = Bits32(opcode, 7, 0) << 2; @@ -11877,7 +11832,8 @@ d = (Bit32(opcode, 22) << 4) | Bits32(opcode, 15, 12); n = Bits32(opcode, 19, 16); - // if n == 15 && CurrentInstrSet() != InstrSet_ARM then UNPREDICTABLE; + // if n == 15 && CurrentInstrSet() != InstrSet_ARM then + // UNPREDICTABLE; if ((n == 15) && (CurrentInstrSet() != eModeARM)) return false; @@ -11885,7 +11841,8 @@ case eEncodingT2: case eEncodingA2: - // single_reg = TRUE; add = (U == '1'); imm32 = ZeroExtend(imm8:'00', 32); + // single_reg = TRUE; add = (U == '1'); imm32 = + // ZeroExtend(imm8:'00', 32); single_reg = true; add = BitIsSet(opcode, 23); imm32 = Bits32(opcode, 7, 0) << 2; @@ -11894,7 +11851,8 @@ d = (Bits32(opcode, 15, 12) << 1) | Bit32(opcode, 22); n = Bits32(opcode, 19, 16); - // if n == 15 && CurrentInstrSet() != InstrSet_ARM then UNPREDICTABLE; + // if n == 15 && CurrentInstrSet() != InstrSet_ARM then + // UNPREDICTABLE; if ((n == 15) && (CurrentInstrSet() != eModeARM)) return false; @@ -11937,10 +11895,10 @@ if (!MemAWrite(context, address, data, addr_byte_size)) return false; } else { - // // Store as two word-aligned words in the correct order for current - // endianness. - // MemA[address,4] = if BigEndian() then D[d]<63:32> else D[d]<31:0>; - // MemA[address+4,4] = if BigEndian() then D[d]<31:0> else D[d]<63:32>; + // // Store as two word-aligned words in the correct order for + // current endianness. MemA[address,4] = if BigEndian() then + // D[d]<63:32> else D[d]<31:0>; MemA[address+4,4] = if BigEndian() + // then D[d]<31:0> else D[d]<63:32>; uint64_t data = ReadRegisterUnsigned(eRegisterKindDWARF, start_reg + d, 0, &success); if (!success) @@ -11970,10 +11928,9 @@ return true; } -// A8.6.307 VLDI1 (multiple single elements) -// This instruction loads elements from memory into one, two, three or four -// registers, without de-interleaving. Every -// element of each register is loaded. +// A8.6.307 VLDI1 (multiple single elements) This instruction loads +// elements from memory into one, two, three or four registers, without +// de-interleaving. Every element of each register is loaded. bool EmulateInstructionARM::EmulateVLD1Multiple(const uint32_t opcode, ARMEncoding encoding) { #if 0 @@ -12006,14 +11963,9 @@ case eEncodingA1: { // case type of // when '0111' - // regs = 1; if align<1> == '1' then UNDEFINED; - // when '1010' - // regs = 2; if align == '11' then UNDEFINED; - // when '0110' - // regs = 3; if align<1> == '1' then UNDEFINED; - // when '0010' - // regs = 4; - // otherwise + // regs = 1; if align<1> == '1' then UNDEFINED; when '1010' regs = + // 2; if align == '11' then UNDEFINED; when '0110' regs = 3; if + // align<1> == '1' then UNDEFINED; when '0010' regs = 4; otherwise // SEE 'Related encodings'; uint32_t type = Bits32(opcode, 11, 8); uint32_t align = Bits32(opcode, 5, 4); @@ -12045,7 +11997,8 @@ else alignment = 4 << align; - // ebytes = 1 << UInt(size); esize = 8 * ebytes; elements = 8 DIV ebytes; + // ebytes = 1 << UInt(size); esize = 8 * ebytes; elements = 8 DIV + // ebytes; ebytes = 1 << Bits32(opcode, 7, 6); esize = 8 * ebytes; elements = 8 / ebytes; @@ -12082,7 +12035,8 @@ return false; EmulateInstruction::Context context; - // if wback then R[n] = R[n] + (if register_index then R[m] else 8*regs); + // if wback then R[n] = R[n] + (if register_index then R[m] else + // 8*regs); if (wback) { uint32_t Rm = ReadCoreReg(m, &success); if (!success) @@ -12170,7 +12124,8 @@ if (BitIsClear(index_align, 0)) return false; - // ebytes = 1; esize = 8; index = UInt(index_align<3:1>); alignment = 1; + // ebytes = 1; esize = 8; index = UInt(index_align<3:1>); + // alignment = 1; ebytes = 1; esize = 8; index = Bits32(index_align, 3, 1); @@ -12221,8 +12176,8 @@ n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // wback = (m != 15); register_index = (m != 15 && m != 13); if n == 15 - // then UNPREDICTABLE; + // wback = (m != 15); register_index = (m != 15 && m != 13); if n == + // 15 then UNPREDICTABLE; wback = (m != 15); register_index = ((m != 15) && (m != 13)); @@ -12249,7 +12204,8 @@ return false; EmulateInstruction::Context context; - // if wback then R[n] = R[n] + (if register_index then R[m] else ebytes); + // if wback then R[n] = R[n] + (if register_index then R[m] else + // ebytes); if (wback) { uint32_t Rm = ReadCoreReg(m, &success); if (!success) @@ -12291,8 +12247,7 @@ if (index > 0) mask = mask | Bits64(all_ones, (index * esize) - 1, 0); // add 1's to the right of where 'element' goes. - // now mask should be 0's where element goes & 1's - // everywhere else. + // now mask should be 0's where element goes & 1's everywhere else. uint64_t masked_reg = reg_data & mask; // Take original reg value & zero out 'element' bits @@ -12307,10 +12262,10 @@ return true; } -// A8.6.391 VST1 (multiple single elements) -// Vector Store (multiple single elements) stores elements to memory from one, -// two, three, or four registers, without -// interleaving. Every element of each register is stored. +// A8.6.391 VST1 (multiple single elements) Vector Store (multiple single +// elements) stores elements to memory from one, two, three, or four +// registers, without interleaving. Every element of each register is +// stored. bool EmulateInstructionARM::EmulateVST1Multiple(const uint32_t opcode, ARMEncoding encoding) { #if 0 @@ -12376,7 +12331,8 @@ else alignment = 4 << align; - // ebytes = 1 << UInt(size); esize = 8 * ebytes; elements = 8 DIV ebytes; + // ebytes = 1 << UInt(size); esize = 8 * ebytes; elements = 8 DIV + // ebytes; ebytes = 1 << Bits32(opcode, 7, 6); esize = 8 * ebytes; elements = 8 / ebytes; @@ -12417,7 +12373,8 @@ return false; EmulateInstruction::Context context; - // if wback then R[n] = R[n] + (if register_index then R[m] else 8*regs); + // if wback then R[n] = R[n] + (if register_index then R[m] else + // 8*regs); if (wback) { uint32_t Rm = ReadCoreReg(m, &success); if (!success) @@ -12465,8 +12422,8 @@ return true; } -// A8.6.392 VST1 (single element from one lane) -// This instruction stores one element to memory from one element of a register. +// A8.6.392 VST1 (single element from one lane) This instruction stores +// one element to memory from one element of a register. bool EmulateInstructionARM::EmulateVST1Single(const uint32_t opcode, ARMEncoding encoding) { #if 0 @@ -12506,7 +12463,8 @@ // if index_align<0> != '0' then UNDEFINED; if (BitIsClear(index_align, 0)) return false; - // ebytes = 1; esize = 8; index = UInt(index_align<3:1>); alignment = 1; + // ebytes = 1; esize = 8; index = UInt(index_align<3:1>); + // alignment = 1; ebytes = 1; esize = 8; index = Bits32(index_align, 3, 1); @@ -12557,8 +12515,8 @@ n = Bits32(opcode, 19, 16); m = Bits32(opcode, 3, 0); - // wback = (m != 15); register_index = (m != 15 && m != 13); if n == 15 - // then UNPREDICTABLE; + // wback = (m != 15); register_index = (m != 15 && m != 13); if n + // == 15 then UNPREDICTABLE; wback = (m != 15); register_index = ((m != 15) && (m != 13)); @@ -12584,7 +12542,8 @@ return false; EmulateInstruction::Context context; - // if wback then R[n] = R[n] + (if register_index then R[m] else ebytes); + // if wback then R[n] = R[n] + (if register_index then R[m] else + // ebytes); if (wback) { uint32_t Rm = ReadCoreReg(m, &success); if (!success) @@ -12624,9 +12583,8 @@ return true; } -// A8.6.309 VLD1 (single element to all lanes) -// This instruction loads one element from memory into every element of one or -// two vectors. +// A8.6.309 VLD1 (single element to all lanes) This instruction loads one +// element from memory into every element of one or two vectors. bool EmulateInstructionARM::EmulateVLD1SingleAll(const uint32_t opcode, const ARMEncoding encoding) { #if 0 @@ -12660,8 +12618,8 @@ if ((size == 3) || ((size == 0) && BitIsSet(opcode, 4))) return false; - // ebytes = 1 << UInt(size); elements = 8 DIV ebytes; regs = if T == '0' - // then 1 else 2; + // ebytes = 1 << UInt(size); elements = 8 DIV ebytes; regs = if T == + // '0' then 1 else 2; ebytes = 1 << size; elements = 8 / ebytes; if (BitIsClear(opcode, 5)) @@ -12710,7 +12668,8 @@ return false; EmulateInstruction::Context context; - // if wback then R[n] = R[n] + (if register_index then R[m] else ebytes); + // if wback then R[n] = R[n] + (if register_index then R[m] else + // ebytes); if (wback) { uint32_t Rm = ReadCoreReg(m, &success); if (!success) @@ -12754,11 +12713,10 @@ return true; } -// B6.2.13 SUBS PC, LR and related instructions -// The SUBS PC, LR, #" should come before "b #imm24" and - // "bl