From d4638fe6dcd1fb98d3be6661cd001b84a5c42c50 Mon Sep 17 00:00:00 2001 From: Riccardo Schirone Date: Tue, 23 Feb 2021 18:04:48 +0100 Subject: [PATCH] Fix cmd on bp hit cons handling --- librz/cons/cons.c | 10 ++++++++++ librz/core/cmd_debug.c | 2 -- librz/core/cmd_print.c | 6 ------ librz/core/core.c | 1 + librz/debug/p/debug_io.c | 1 + librz/include/rz_cons.h | 1 + 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/librz/cons/cons.c b/librz/cons/cons.c index 00008ee352a..65690e8a1f8 100644 --- a/librz/cons/cons.c +++ b/librz/cons/cons.c @@ -1960,3 +1960,13 @@ RZ_API void rz_cons_clear_buffer(void) { 6); } } + +/** + * \brief Set whether RzCons should flush content to screen or not + * + * \param flush If true, calls to \p rz_cons_flush and \p rz_cons_visual_flush + * would flush cons content to the screen, otherwise they will not. + */ +RZ_API void rz_cons_set_flush(bool flush) { + CTX(noflush) = !flush; +} \ No newline at end of file diff --git a/librz/core/cmd_debug.c b/librz/core/cmd_debug.c index 5e3e0d0c63e..8332816b1be 100644 --- a/librz/core/cmd_debug.c +++ b/librz/core/cmd_debug.c @@ -5138,9 +5138,7 @@ RZ_IPI int rz_cmd_debug(void *data, const char *input) { case 's': // "dxs" if (input[2]) { char *str; - rz_cons_push(); str = rz_core_cmd_str(core, sdb_fmt("gs %s", input + 2)); - rz_cons_pop(); rz_core_cmdf(core, "dx %s", str); //`gs %s`", input + 2); free(str); } else { diff --git a/librz/core/cmd_print.c b/librz/core/cmd_print.c index 7410d40cfbe..8d53a6c95d5 100644 --- a/librz/core/cmd_print.c +++ b/librz/core/cmd_print.c @@ -1100,7 +1100,6 @@ static void cmd_pCd(RzCore *core, const char *input) { if (user_rows > 0) { rows = user_rows + 1; } - rz_cons_push(); RzConsCanvas *c = rz_cons_canvas_new(w, rows); ut64 osek = core->offset; c->color = rz_config_get_i(core->config, "scr.color"); @@ -1116,7 +1115,6 @@ static void cmd_pCd(RzCore *core, const char *input) { rz_core_block_size(core, obsz); rz_core_seek(core, osek, true); - rz_cons_pop(); rz_cons_canvas_print(c); rz_cons_canvas_free(c); if (asm_minicols) { @@ -1183,7 +1181,6 @@ static void cmd_pCD(RzCore *core, const char *input) { if (user_rows > 0) { rows = user_rows + 1; } - rz_cons_push(); RzConsCanvas *c = rz_cons_canvas_new(w, rows); ut64 osek = core->offset; c->color = rz_config_get_i(core->config, "scr.color"); @@ -1210,7 +1207,6 @@ static void cmd_pCD(RzCore *core, const char *input) { rz_core_block_size(core, obsz); rz_core_seek(core, osek, true); - rz_cons_pop(); rz_cons_canvas_print(c); rz_cons_canvas_free(c); if (asm_minicols) { @@ -2796,7 +2792,6 @@ static void disasm_strings(RzCore *core, const char *input, RzAnalysisFunction * rz_config_set_i(core->config, "scr.html", 0); rz_config_set_i(core->config, "asm.cmt.right", true); - rz_cons_push(); line = NULL; s = NULL; if (!strncmp(input, "dsb", 3)) { @@ -2819,7 +2814,6 @@ static void disasm_strings(RzCore *core, const char *input, RzAnalysisFunction * } else { line = s = rz_core_cmd_str(core, "pd"); } - rz_cons_pop(); rz_config_set_i(core->config, "scr.html", scr_html); rz_config_set_i(core->config, "scr.color", use_color); diff --git a/librz/core/core.c b/librz/core/core.c index c9f0f494d61..d4f23a9bee9 100644 --- a/librz/core/core.c +++ b/librz/core/core.c @@ -76,6 +76,7 @@ static void rz_core_debug_breakpoint_hit(RzCore *core, RzBreakpointItem *bpi) { rz_core_cmd0(core, bpi->data); } if (may_output) { + rz_cons_set_flush(true); rz_cons_flush(); rz_cons_pop(); } diff --git a/librz/debug/p/debug_io.c b/librz/debug/p/debug_io.c index e929c19dcfc..611adeef877 100644 --- a/librz/debug/p/debug_io.c +++ b/librz/debug/p/debug_io.c @@ -85,6 +85,7 @@ static char *__io_reg_profile(RzDebug *dbg) { rz_cons_pop(); return ret; } + rz_cons_pop(); return rz_analysis_get_reg_profile(dbg->analysis); } diff --git a/librz/include/rz_cons.h b/librz/include/rz_cons.h index 3a69c3e8734..71e3ee2d550 100644 --- a/librz/include/rz_cons.h +++ b/librz/include/rz_cons.h @@ -915,6 +915,7 @@ RZ_API int rz_cons_memcat(const char *str, int len); RZ_API void rz_cons_newline(void); RZ_API void rz_cons_filter(void); RZ_API void rz_cons_flush(void); +RZ_API void rz_cons_set_flush(bool flush); RZ_API void rz_cons_print_fps(int col); RZ_API void rz_cons_last(void); RZ_API int rz_cons_less_str(const char *str, const char *exitkeys);