X-Git-Url: http://git.jankratochvil.net/?p=llgdb.git;a=blobdiff_plain;f=src%2FLLGDBMain.cpp;h=2e99a2fd21f88e20a3e832b192d4445926ff2911;hp=08f852e6c755fbf59382dcf17a7735ce91e6bae5;hb=ff8cf176ea7fb19f543ed6731c6fa825d18b7ecf;hpb=2824fefdfb08c63720eea88440e6c89aff9eaaca diff --git a/src/LLGDBMain.cpp b/src/LLGDBMain.cpp index 08f852e..2e99a2f 100644 --- a/src/LLGDBMain.cpp +++ b/src/LLGDBMain.cpp @@ -3,23 +3,23 @@ // //===----------------------------------------------------------------------===// +#include +#include +#include +#include +#include +#include #include +#include +#include #include #include -#include -#include #include -#include -#include -#include -#include -#include #include -#include -#include +#include #include #include -#include +#include using namespace lldb; using namespace lldb_private; @@ -115,16 +115,24 @@ static void history_save(int rc, void *arg) { write_history(history_filename); } -static std::string settings_show_raw(SBDebugger &dbg, const char *setting, const char *type) { +static std::string settings_show_raw(SBDebugger &dbg, const char *setting, + const char *type) { SBCommandReturnObject Result; - dbg.GetCommandInterpreter().HandleCommand(("settings show " + std::string(setting)).c_str(), Result, /*add_to_history*/ false); + dbg.GetCommandInterpreter().HandleCommand( + ("settings show " + std::string(setting)).c_str(), Result, + /*add_to_history*/ false); assert(Result.Succeeded()); // (malloc(strlen(cs)+1)); + char *s = static_cast(malloc(strlen(cs) + 1)); assert(s); - strcpy(s,cs); + strcpy(s, cs); return s; } @@ -314,26 +328,30 @@ static char *completion_entry_function(const char *text, int matches) { if (matches == 0) { found_vec.clear(); SBStringList matches; - // LLDB: FIXME: These two values are not implemented. m_match_start_point; m_max_return_elements; + // LLDB: FIXME: These two values are not implemented. m_match_start_point; + // m_max_return_elements; const int match_start_point = 0; // LLDB: Only max_return_elements == -1 is supported at present: const int max_return_elements = -1; - int got=dbg.GetCommandInterpreter().HandleCompletion(text, strlen(text)/*cursor_pos*/, match_start_point, max_return_elements, matches); + int got = dbg.GetCommandInterpreter().HandleCompletion( + text, strlen(text) /*cursor_pos*/, match_start_point, + max_return_elements, matches); assert(matches.IsValid()); - if (unsigned(got+1)!=matches.GetSize()) - error(1,0,"HandleCompletion=%d +1 != %u=matches.GetSize()",got,matches.GetSize()); - //for (size_t ix=0;ix\n",ix,matches.GetStringAtIndex(ix)); - const char *first=matches.GetStringAtIndex(0); - assert(matches.GetSize()>=1); + const char *first = matches.GetStringAtIndex(0); + assert(matches.GetSize() >= 1); if (first[0]) { std::string str(first); - while (!str.empty()&&str.back()==' ') - str.pop_back(); + while (!str.empty() && str.back() == ' ') + str.pop_back(); found_vec.push_back(text + str); } else - for (size_t ix=1;ix 0) opt_pid = str_to_pid(arg); else if (!opt_core) - opt_core=std::move(arg); + opt_core = std::move(arg); else - error(1,0,"Excessive argument: %s",arg.c_str()); + error(1, 0, "Excessive argument: %s", arg.c_str()); } SBDebugger::Initialize(); SBDebugger dbg = SBDebugger::Create(); dbg.HandleCommand("settings set symbols.enable-external-lookup false"); - completion_entry_function_dbgp=&dbg; + completion_entry_function_dbgp = &dbg; rl_completion_entry_function = completion_entry_function; rl_readline_name = "llgdb"; - if (true/*settings_show_bool(dbg, "history save")*/) { - int history_size = 1000000; //settings_show_int(dbg, "history size"); + if (true /*settings_show_bool(dbg, "history save")*/) { + int history_size = 1000000; // settings_show_int(dbg, "history size"); const char *HOME = getenv("HOME"); assert(HOME); - static const std::string history_filename = std::string(HOME) + "/.llgdb_history"; // settings_show_string(dbg, "history filename"); - //gdb_set_bool(dbg, "history save", false); + static const std::string history_filename = + std::string(HOME) + + "/.llgdb_history"; // settings_show_string(dbg, "history filename"); + // gdb_set_bool(dbg, "history save", false); stifle_history(history_size); read_history(history_filename.c_str()); - on_exit(history_save, static_cast(const_cast(history_filename.c_str()))); + on_exit(history_save, + static_cast(const_cast(history_filename.c_str()))); /* Do not free HISTORY_FILENAME. */ } @@ -496,8 +519,8 @@ Report bugs to jan.kratochvil -at- redhat.com.\n\ if (!arg) { char *cmd_s = llgdb_readline(prompt.c_str()); if (cmd_s) - add_history(cmd_s); - cmd = cmd_s?:"quit"; + add_history(cmd_s); + cmd = cmd_s ?: "quit"; free(cmd_s); } else { puts((prompt + *arg).c_str());