diff --git a/pwndbg/commands/context.py b/pwndbg/commands/context.py index 41f78c00c..2ae94a4ce 100644 --- a/pwndbg/commands/context.py +++ b/pwndbg/commands/context.py @@ -627,6 +627,9 @@ theme.add_param("highlight-source", True, "whether to highlight the closest sour source_code_lines = pwndbg.gdblib.config.add_param( "context-source-code-lines", 10, "number of source code lines to print by the context command" ) +pwndbg.gdblib.config.add_param( + "context-source-code-tabstop", 8, "number of spaces that a in the source code counts for" +) theme.add_param("code-prefix", "►", "prefix marker for 'context code' command") @@ -684,6 +687,8 @@ def get_filename_and_formatted_source(): # Format the output formatted_source = [] for line_number, code in enumerate(source, start=start + 1): + if pwndbg.gdblib.config.context_source_code_tabstop > 0: + code = code.replace("\t", " " * pwndbg.gdblib.config.context_source_code_tabstop) fmt = " {prefix_sign:{prefix_width}} {line_number:>{num_width}} {code}" if pwndbg.gdblib.config.highlight_source and line_number == closest_line: fmt = C.highlight(fmt)