Esempio n. 1
0
void
Driver::WriteCommandsForSourcing (CommandPlacement placement, SBStream &strm)
{
    std::vector<OptionData::InitialCmdEntry> *command_set;
    switch (placement)
    {
    case eCommandPlacementBeforeFile:
        command_set = &m_option_data.m_initial_commands;
        break;
    case eCommandPlacementAfterFile:
        command_set = &m_option_data.m_after_file_commands;
        break;
    case eCommandPlacementAfterCrash:
        command_set = &m_option_data.m_after_crash_commands;
        break;
    }
    
    for (const auto &command_entry : *command_set)
    {
        const char *command = command_entry.contents.c_str();
        if (command_entry.is_file)
        {
            bool source_quietly = m_option_data.m_source_quietly || command_entry.source_quietly;
            strm.Printf("command source -s %i '%s'\n", source_quietly, command);
        }
        else
            strm.Printf("%s\n", command);
    }
}
Esempio n. 2
0
void
Driver::WriteCommandsForSourcing (CommandPlacement placement, SBStream &strm)
{
    std::vector<OptionData::InitialCmdEntry> *command_set;
    switch (placement)
    {
    case eCommandPlacementBeforeFile:
        command_set = &m_option_data.m_initial_commands;
        break;
    case eCommandPlacementAfterFile:
        command_set = &m_option_data.m_after_file_commands;
        break;
    case eCommandPlacementAfterCrash:
        command_set = &m_option_data.m_after_crash_commands;
        break;
    }
    
    for (const auto &command_entry : *command_set)
    {
        const char *command = command_entry.contents.c_str();
        if (command_entry.is_file)
        {
            // If this command_entry is a file to be sourced, and it's the ./.lldbinit file (the .lldbinit
            // file in the current working directory), only read it if target.load-cwd-lldbinit is 'true'.
            if (command_entry.is_cwd_lldbinit_file_read)
            {
                SBStringList strlist = m_debugger.GetInternalVariableValue ("target.load-cwd-lldbinit", 
                                                                            m_debugger.GetInstanceName());
                if (strlist.GetSize() == 1 && strcmp (strlist.GetStringAtIndex(0), "warn") == 0)
                {
                    FILE *output = m_debugger.GetOutputFileHandle ();
                    ::fprintf (output, 
                            "There is a .lldbinit file in the current directory which is not being read.\n"
                            "To silence this warning without sourcing in the local .lldbinit,\n"
                            "add the following to the lldbinit file in your home directory:\n"
                            "    settings set target.load-cwd-lldbinit false\n"
                            "To allow lldb to source .lldbinit files in the current working directory,\n"
                            "set the value of this variable to true.  Only do so if you understand and\n"
                            "accept the security risk.\n");
                    return;
                }
                if (strlist.GetSize() == 1 && strcmp (strlist.GetStringAtIndex(0), "false") == 0)
                {
                    return;
                }
            }
            bool source_quietly = m_option_data.m_source_quietly || command_entry.source_quietly;
            strm.Printf("command source -s %i '%s'\n", source_quietly, command);
        }
        else
            strm.Printf("%s\n", command);
    }
}
Esempio n. 3
0
bool
SBFileSpec::GetDescription (SBStream &description) const
{
    if (m_opaque_ap.get())
    {
        char path[PATH_MAX];
        if (m_opaque_ap->GetPath(path, sizeof(path)))
            description.Printf ("%s", path);
    }
    else
        description.Printf ("No value");
    
    return true;
}
Esempio n. 4
0
void
Driver::WriteInitialCommands (bool before_file, SBStream &strm)
{
    std::vector<std::pair<bool, std::string> > &command_set = before_file ? m_option_data.m_initial_commands :
                                                                            m_option_data.m_after_file_commands;
    
    for (const auto &command_pair : command_set)
    {
        const char *command = command_pair.second.c_str();
        if (command_pair.first)
            strm.Printf("command source -s %i '%s'\n", m_option_data.m_source_quietly, command);
        else
            strm.Printf("%s\n", command);
    }
}
Esempio n. 5
0
bool
SBBreakpoint::GetDescription (SBStream &s)
{
    if (m_opaque_sp)
    {
        std::lock_guard<std::recursive_mutex> guard(m_opaque_sp->GetTarget().GetAPIMutex());
        s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID());
        m_opaque_sp->GetResolverDescription (s.get());
        m_opaque_sp->GetFilterDescription (s.get());
        const size_t num_locations = m_opaque_sp->GetNumLocations ();
        s.Printf(", locations = %" PRIu64, (uint64_t)num_locations);
        return true;
    }
    s.Printf ("No value");
    return false;
}
bool
SBCommandReturnObject::GetDescription (SBStream &description)
{
    Stream &strm = description.ref();

    if (m_opaque_ap.get())
    {
        description.Printf ("Status:  ");
        lldb::ReturnStatus status = m_opaque_ap->GetStatus();
        if (status == lldb::eReturnStatusStarted)
            strm.PutCString ("Started");
        else if (status == lldb::eReturnStatusInvalid)
            strm.PutCString ("Invalid");
        else if (m_opaque_ap->Succeeded())
            strm.PutCString ("Success");
        else
            strm.PutCString ("Fail");

        if (GetOutputSize() > 0)
            strm.Printf ("\nOutput Message:\n%s", GetOutput());

        if (GetErrorSize() > 0)
            strm.Printf ("\nError Message:\n%s", GetError());
    }
    else
        strm.PutCString ("No value");

    return true;
}
Esempio n. 7
0
bool
SBLineEntry::GetDescription (SBStream &description)
{
    if (m_opaque_ap.get())
    {
        char file_path[PATH_MAX*2];
        m_opaque_ap->file.GetPath (file_path, sizeof (file_path));
        description.Printf ("%s:%u", file_path, GetLine());
        if (GetColumn() > 0)
            description.Printf (":%u", GetColumn());
    }
    else
        description.Printf ("No value");

    return true;
}
Esempio n. 8
0
bool
SBBreakpoint::GetDescription (SBStream &s)
{
    if (m_opaque_sp)
    {
        Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex());
        s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID());
        m_opaque_sp->GetResolverDescription (s.get());
        m_opaque_sp->GetFilterDescription (s.get());
        const size_t num_locations = m_opaque_sp->GetNumLocations ();
        s.Printf(", locations = %zu", num_locations);
        return true;
    }
    s.Printf ("No value");
    return false;
}
Esempio n. 9
0
bool
SBFunction::GetDescription (SBStream &s)
{
    if (m_opaque_ptr)
    {
        s.Printf ("SBFunction: id = 0x%8.8x, name = %s", 
                            m_opaque_ptr->GetID(),
                            m_opaque_ptr->GetName().AsCString());
        Type *func_type = m_opaque_ptr->GetType();
        if (func_type)
            s.Printf(", type = %s", func_type->GetName().AsCString());
        return true;
    }
    s.Printf ("No value");
    return false;
}
Esempio n. 10
0
bool
SBError::GetDescription (SBStream &description)
{
    if (m_opaque_ap.get())
    {
        if (m_opaque_ap->Success())
            description.Printf ("success");
        else
        {
            const char * err_string = GetCString();
            description.Printf ("error: %s",  (err_string != NULL ? err_string : ""));
        }
    }
    else
        description.Printf ("error: <NULL>");

    return true;
} 
Esempio n. 11
0
bool
SBSymbolContext::GetDescription (SBStream &description)
{
    if (m_opaque_ap.get())
    {
        description.ref();
        m_opaque_ap->GetDescription (description.get(), lldb::eDescriptionLevelFull, NULL);
    }
    else
        description.Printf ("No value");

    return true;
}
Esempio n. 12
0
bool
SBCompileUnit::GetDescription (SBStream &description)
{
    if (m_opaque_ptr)
    {
        description.ref();
        m_opaque_ptr->Dump (description.get(), false);
    }
    else
        description.Printf ("No Value");

    return true;
}
Esempio n. 13
0
bool
SBProcess::GetDescription (SBStream &description)
{
    if (m_opaque_sp)
    {
        char path[PATH_MAX];
        GetTarget().GetExecutable().GetPath (path, sizeof(path));
        Module *exe_module = m_opaque_sp->GetTarget().GetExecutableModule ().get();
        const char *exe_name = NULL;
        if (exe_module)
            exe_name = exe_module->GetFileSpec().GetFilename().AsCString();

        description.Printf ("SBProcess: pid = %d, state = %s, threads = %d%s%s", 
                            m_opaque_sp->GetID(),
                            lldb_private::StateAsCString (GetState()), 
                            GetNumThreads(),
                            exe_name ? ", executable = " : "",
                            exe_name ? exe_name : "");
    }
    else
        description.Printf ("No value");

    return true;
}
Esempio n. 14
0
bool SBBreakpointName::GetDescription(SBStream &s) {
  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
  
  BreakpointName *bp_name = GetBreakpointName();
  if (!bp_name)
  {
    s.Printf("No value");
    return false;
  }
 
  LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
  std::lock_guard<std::recursive_mutex> guard(
        m_impl_up->GetTarget()->GetAPIMutex());
  bp_name->GetDescription(s.get(), eDescriptionLevelFull);
  return true;
}
Esempio n. 15
0
bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
  bool success = false;
  std::unique_lock<std::recursive_mutex> lock;
  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);

  if (exe_ctx.HasThreadScope()) {
    Process::StopLocker stop_locker;
    if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
      Thread *thread = exe_ctx.GetThreadPtr();
      StructuredData::ObjectSP info_root_sp = thread->GetExtendedInfo();
      if (info_root_sp) {
        StructuredData::ObjectSP node =
            info_root_sp->GetObjectForDotSeparatedPath(path);
        if (node) {
          if (node->GetType() == eStructuredDataTypeString) {
            strm.Printf("%s", node->GetAsString()->GetValue().str().c_str());
            success = true;
          }
          if (node->GetType() == eStructuredDataTypeInteger) {
            strm.Printf("0x%" PRIx64, node->GetAsInteger()->GetValue());
            success = true;
          }
          if (node->GetType() == eStructuredDataTypeFloat) {
            strm.Printf("0x%f", node->GetAsFloat()->GetValue());
            success = true;
          }
          if (node->GetType() == eStructuredDataTypeBoolean) {
            if (node->GetAsBoolean()->GetValue() == true)
              strm.Printf("true");
            else
              strm.Printf("false");
            success = true;
          }
          if (node->GetType() == eStructuredDataTypeNull) {
            strm.Printf("null");
            success = true;
          }
        }
      }
    } else {
      if (log)
        log->Printf("SBThread(%p)::GetInfoItemByPathAsString() => error: "
                    "process is running",
                    static_cast<void *>(exe_ctx.GetThreadPtr()));
    }
  }

  if (log)
    log->Printf("SBThread(%p)::GetInfoItemByPathAsString (\"%s\") => \"%s\"",
                static_cast<void *>(exe_ctx.GetThreadPtr()), path, strm.GetData());

  return success;
}