Bug 1015419 - For scripted use, "disassemble" command needs sanity size limiting
For scripted use, "disassemble" command needs sanity size limiting
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gdb (Show other bugs)
rawhide
Unspecified Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Phil Muldoon
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-04 04:02 EDT by Denys Vlasenko
Modified: 2013-10-06 14:23 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-10-04 04:34:24 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Sourceware 16007 None None None Never
Sourceware 16008 None None None Never

  None (edit)
Description Denys Vlasenko 2013-10-04 04:02:53 EDT
We have a user report where coredump contains $pc pointing into .bss

gdb "disassemble", consequently, tries to disassemble *entire* .bss.

Since it is done by automated gdb run (gdb -batch -ex disassemble),
there is no user at the keyboard who can realize that this isn't useful
and can produce many megabytes of output.

Please add a parameter or an option to "disassemble" command
which can be used to cap the output size. Something along the lines of

(gdb) disassemble /maxlines:20000
Comment 1 Jan Kratochvil 2013-10-04 04:34:24 EDT
Such simple usage is really scriptable with Python.  For example first 3 lines:

(gdb) python import re;print re.compile("^([^\n]*\n){3}").match(gdb.execute("disassemble main",False,True)).group()
Comment 2 Denys Vlasenko 2013-10-04 06:09:26 EDT
(In reply to Jan Kratochvil from comment #1)
> Such simple usage is really scriptable with Python.  For example first 3
> lines:
> 
> (gdb) python import re;print
> re.compile("^([^\n]*\n){3}").match(gdb.execute("disassemble
> main",False,True)).group()

See bug 995889:

"""
Generating core_backtrace
Lock file './.lock' is locked by process 6567
Generating backtrace
Backtrace is too big (33564131 bytes), reducing depth to 512
Backtrace is too big (33564131 bytes), reducing depth to 256
Backtrace is too big (33564131 bytes), reducing depth to 128
etc.

The backtrace never decreases in size and I am unable to submit the bug. On a Core-i7, it is very slow and can easily take 30+ minutes to run through the gamut before giving up. 
"""

IOW: the execution time and possible memory exhaustion temporarily storing megabytes of disasm is also the problem here.
Comment 3 Jan Kratochvil 2013-10-04 08:31:02 EDT
disassemble main,+20000

Just it is in bytes and not lines but that should not matter much.
Comment 4 Jan Kratochvil 2013-10-04 08:32:05 EDT
oops, not right, it does not stop at the end of main.
Comment 5 Jan Kratochvil 2013-10-04 08:54:08 EDT
This one should work:


import re
f="main"
l=1
r=20000
# Is there \Q in Python?
p=re.compile("^%s [+] "%f)
while l<r:
    m=(l+r)/2
    if p.match(gdb.execute("info symbol %s+%d"%(f,m),False,True)):
        l=m+1
    else:
        r=m
gdb.execute("disassemble %s,+%d"%(f,r))

Note You need to log in before you can comment on or make changes to this bug.