|
1 | 1 | # -*- coding: utf-8 -*- |
2 | | -# Copyright (C) 2015, 2023-2025 Rocky Bernstein <rocky@gnu.org> |
| 2 | +# Copyright (C) 2015, 2023-2026 Rocky Bernstein <rocky@gnu.org> |
3 | 3 | # |
4 | 4 | # This program is free software: you can redistribute it and/or modify |
5 | 5 | # it under the terms of the GNU General Public License as published by |
|
21 | 21 | from trepan.lib.complete import complete_token |
22 | 22 | from trepan.lib.disassemble import PYTHON_OPCODES as python_opcodes |
23 | 23 | from trepan.lib.format import Function, Keyword, format_token |
24 | | -from trepan.lib.stack import format_function_name, get_column_start_from_frame |
| 24 | +from trepan.lib.stack import ( |
| 25 | + format_function_name, |
| 26 | + get_column_start_from_frame, |
| 27 | + get_exec_or_eval_string, |
| 28 | + is_eval_or_exec_stmt |
| 29 | +) |
25 | 30 | from trepan.lib.thred import current_thread_name |
26 | 31 | from trepan.processor import frame as Mframe |
27 | 32 | from trepan.processor.print import format_code, format_frame |
@@ -123,9 +128,12 @@ def run(self, args): |
123 | 128 | function_name, formatted_func_name = format_function_name(frame, style=style) |
124 | 129 | if function_name is None: |
125 | 130 | formatted_func_name = "??" |
126 | | - f_args, f_varargs, f_keywords, f_locals = inspect.getargvalues(frame) |
127 | 131 | self.msg(f" function name: {formatted_func_name}") |
128 | | - func_args = inspect.formatargvalues(f_args, f_varargs, f_keywords, f_locals) |
| 132 | + if is_eval_or_exec_stmt(frame): |
| 133 | + func_args = get_exec_or_eval_string(frame) |
| 134 | + else: |
| 135 | + f_args, f_varargs, f_keywords, f_locals = inspect.getargvalues(frame) |
| 136 | + func_args = inspect.formatargvalues(f_args, f_varargs, f_keywords, f_locals) |
129 | 137 | formatted_func_signature = highlight_string(func_args, style=style).strip() |
130 | 138 | self.msg(f" function args: {formatted_func_signature}") |
131 | 139 |
|
@@ -161,7 +169,9 @@ def run(self, args): |
161 | 169 | if f_lasti >= 0: |
162 | 170 | opname = python_opcodes.opname[code.co_code[f_lasti]] |
163 | 171 | opname_formatted = format_token(Keyword, opname, style=style) |
164 | | - self.msg(f" instruction offset and opname: {frame.f_lasti} {opname_formatted}") |
| 172 | + self.msg( |
| 173 | + f" instruction offset and opname: {frame.f_lasti} {opname_formatted}" |
| 174 | + ) |
165 | 175 | else: |
166 | 176 | self.msg(f" instruction offset: {frame.f_lasti}") |
167 | 177 |
|
|
0 commit comments