Exemplo 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)
        {
            // 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);
    }
}
Exemplo n.º 2
0
void SBBreakpointName::SetCommandLineCommands(SBStringList &commands) {
  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
  BreakpointName *bp_name = GetBreakpointName();
  if (!bp_name)
    return;
  if (commands.GetSize() == 0)
    return;

  LLDB_LOG(log, "Name: {0} commands\n", bp_name->GetName());

  std::lock_guard<std::recursive_mutex> guard(
        m_impl_up->GetTarget()->GetAPIMutex());
  std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
      new BreakpointOptions::CommandData(*commands, eScriptLanguageNone));

  bp_name->GetOptions().SetCommandDataCallback(cmd_data_up);
  UpdateName(*bp_name);
}