Author: jingham Date: Fri Dec 19 13:20:44 2014 New Revision: 224602 URL: http://llvm.org/viewvc/llvm-project?rev=224602&view=rev Log: Audit uses of ConstString::AsCString() to make sure they weren't assuming they would always get a non-NULL string back.
<rdar://problem/19298575> Modified: lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/AddressRange.cpp lldb/trunk/source/Core/AddressResolverFileLine.cpp lldb/trunk/source/Core/SearchFilter.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=224602&r1=224601&r2=224602&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Fri Dec 19 13:20:44 2014 @@ -433,7 +433,9 @@ Address::Dump (Stream *s, ExecutionConte case DumpStyleModuleWithFileAddress: if (section_sp) - s->Printf("%s[", section_sp->GetModule()->GetFileSpec().GetFilename().AsCString()); + { + s->Printf("%s[", section_sp->GetModule()->GetFileSpec().GetFilename().AsCString("<Unknown>")); + } // Fall through case DumpStyleFileAddress: { Modified: lldb/trunk/source/Core/AddressRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressRange.cpp?rev=224602&r1=224601&r2=224602&view=diff ============================================================================== --- lldb/trunk/source/Core/AddressRange.cpp (original) +++ lldb/trunk/source/Core/AddressRange.cpp Fri Dec 19 13:20:44 2014 @@ -179,7 +179,7 @@ AddressRange::Dump(Stream *s, Target *ta { ModuleSP module_sp (GetBaseAddress().GetModule()); if (module_sp) - s->Printf("%s", module_sp->GetFileSpec().GetFilename().AsCString()); + s->Printf("%s", module_sp->GetFileSpec().GetFilename().AsCString("<Unknown>")); } s->AddressRange(vmaddr, vmaddr + GetByteSize(), addr_size); return true; Modified: lldb/trunk/source/Core/AddressResolverFileLine.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressResolverFileLine.cpp?rev=224602&r1=224601&r2=224602&view=diff ============================================================================== --- lldb/trunk/source/Core/AddressResolverFileLine.cpp (original) +++ lldb/trunk/source/Core/AddressResolverFileLine.cpp Fri Dec 19 13:20:44 2014 @@ -96,7 +96,7 @@ AddressResolverFileLine::GetDepth() void AddressResolverFileLine::GetDescription (Stream *s) { - s->Printf ("File and line address - file: \"%s\" line: %u", m_file_spec.GetFilename().AsCString(), m_line_number); + s->Printf ("File and line address - file: \"%s\" line: %u", m_file_spec.GetFilename().AsCString("<Unknown>"), m_line_number); } Modified: lldb/trunk/source/Core/SearchFilter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SearchFilter.cpp?rev=224602&r1=224601&r2=224602&view=diff ============================================================================== --- lldb/trunk/source/Core/SearchFilter.cpp (original) +++ lldb/trunk/source/Core/SearchFilter.cpp Fri Dec 19 13:20:44 2014 @@ -450,7 +450,7 @@ SearchFilterByModule::GetDescription (St } else { - s->PutCString(m_module_spec.GetFilename().AsCString("<unknown>")); + s->PutCString(m_module_spec.GetFilename().AsCString("<Unknown>")); } } @@ -612,7 +612,7 @@ SearchFilterByModuleList::GetDescription } else { - s->PutCString(m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString("<unknown>")); + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString("<Unknown>")); } } else @@ -628,7 +628,7 @@ SearchFilterByModuleList::GetDescription } else { - s->PutCString(m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString("<unknown>")); + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString("<Unknown>")); } if (i != num_modules - 1) s->PutCString (", "); @@ -811,7 +811,7 @@ SearchFilterByModuleListAndCU::GetDescri } else { - s->PutCString(m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString("<unknown>")); + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString("<Unknown>")); } } else if (num_modules > 0) @@ -827,7 +827,7 @@ SearchFilterByModuleListAndCU::GetDescri } else { - s->PutCString(m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString("<unknown>")); + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString("<Unknown>")); } if (i != num_modules - 1) s->PutCString (", "); Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=224602&r1=224601&r2=224602&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Dec 19 13:20:44 2014 @@ -2776,7 +2776,7 @@ CommandInterpreter::HandleCommandsFromFi else { result.AppendErrorWithFormat ("Error reading commands from file %s - file not found.\n", - cmd_file.GetFilename().AsCString()); + cmd_file.GetFilename().AsCString("<Unknown>")); result.SetStatus (eReturnStatusFailed); return; } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=224602&r1=224601&r2=224602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Fri Dec 19 13:20:44 2014 @@ -1030,7 +1030,7 @@ DWARFDebugInfoEntry::DumpLocation const char *obj_file_name = NULL; ObjectFile *obj_file = dwarf2Data->GetObjectFile(); if (obj_file) - obj_file_name = obj_file->GetFileSpec().GetFilename().AsCString(); + obj_file_name = obj_file->GetFileSpec().GetFilename().AsCString("<Unknown>"); const char *die_name = GetName (dwarf2Data, cu); s.Printf ("0x%8.8x/0x%8.8x: %-30s (from %s in %s)", cu->GetOffset(), Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=224602&r1=224601&r2=224602&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Dec 19 13:20:44 2014 @@ -3033,7 +3033,7 @@ SymbolFileDWARF::Index () m_indexed = true; Timer scoped_timer (__PRETTY_FUNCTION__, "SymbolFileDWARF::Index (%s)", - GetObjectFile()->GetFileSpec().GetFilename().AsCString()); + GetObjectFile()->GetFileSpec().GetFilename().AsCString("<Unknown>")); DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) @@ -4929,7 +4929,7 @@ SymbolFileDWARF::FindCompleteObjCDefinit { DEBUG_PRINTF ("resolved 0x%8.8" PRIx64 " from %s to 0x%8.8" PRIx64 " (cu 0x%8.8" PRIx64 ")\n", MakeUserID(die->GetOffset()), - m_obj_file->GetFileSpec().GetFilename().AsCString(), + m_obj_file->GetFileSpec().GetFilename().AsCString("<Unknown>"), MakeUserID(type_die->GetOffset()), MakeUserID(type_cu->GetOffset())); Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=224602&r1=224601&r2=224602&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Fri Dec 19 13:20:44 2014 @@ -1383,9 +1383,9 @@ Target::ReadMemory (const Address& addr, ModuleSP addr_module_sp (resolved_addr.GetModule()); if (addr_module_sp && addr_module_sp->GetFileSpec()) error.SetErrorStringWithFormat("%s[0x%" PRIx64 "] can't be resolved, %s in not currently loaded", - addr_module_sp->GetFileSpec().GetFilename().AsCString(), + addr_module_sp->GetFileSpec().GetFilename().AsCString("<Unknown>"), resolved_addr.GetFileAddress(), - addr_module_sp->GetFileSpec().GetFilename().AsCString()); + addr_module_sp->GetFileSpec().GetFilename().AsCString("<Unknonw>")); else error.SetErrorStringWithFormat("0x%" PRIx64 " can't be resolved", resolved_addr.GetFileAddress()); } _______________________________________________ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits