Skip to content

Improve stack trace from where command in pdb #104316

Closed as not planned
Closed as not planned
@ironyman

Description

@ironyman

Feature or enhancement

(A clear and concise description of your proposal.)
The most useful information should be printed first so it's easier to find. Currently the printed stack frame is in the format

full path to source file(line number)function name

The function name is probably what people care about the most since full path could contain a lot of redundant information if all the source files in the same directory and even more redundant information if the functions are in the same file. So I motion that the function name be printed closer to the front of the line for each stack frame.

Pitch

When there's an excess of redundant source file path information the most useful information (function name) which is at the end of the line

  1. the function names are not aligned visually with function names from stack frames above or below
  2. and function names could also wrap to the next line if the line is too long
  3. both of which make the stack frame output difficult to read.

Having the most useful information at the front of the line where it can be aligned with function names from frames above and below makes this a lot easier to read.

Previous discussion

Unrelated but another suggestion to improve stack trace formatting.
https://discuss.python.org/t/add-indentation-to-pdb-output/23252

This is how gdb formats stack frame output

#0  m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
    at builtin.c:993
#1  0x6e38 in expand_macro (sym=0x2b600, data=...) at macro.c:242
#2  0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
    at macro.c:71
(More stack frames follow...)

from https://sourceware.org/gdb/onlinedocs/gdb/Backtrace.html

Source file is wrapped rather than the function name.

This is how windbg formats stack frame output

kp
 # Child-SP          RetAddr           Call Site
00 00000000`0015eed0 00000000`77732ef5 ntdll!LdrpDoDebuggerBreak+0x30
01 00000000`0015ef10 00000000`77711a17 ntdll!LdrpInitializeProcess+0x1b4f
02 00000000`0015f400 00000000`776fc32e ntdll! ?? ::FNODOBFM::`string'+0x29220
03 00000000`0015f470 00000000`00000000 ntdll!LdrInitializeThunk+0xe

function name is aligned, source file is at the end (hidden because there's no source file information)

Metadata

Metadata

Labels

stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions