From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D3EC83858005; Fri, 15 Oct 2021 08:25:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3EC83858005 From: "andrey.lesnikov at jetbrains dot com" To: gdb-prs@sourceware.org Subject: [Bug mi/28454] New: MI -var-list-children bad performance with simple pretty printers Date: Fri, 15 Oct 2021 08:25:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: mi X-Bugzilla-Version: 9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: andrey.lesnikov at jetbrains dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Oct 2021 08:25:03 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28454 Bug ID: 28454 Summary: MI -var-list-children bad performance with simple pretty printers Product: gdb Version: 9.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: mi Assignee: unassigned at sourceware dot org Reporter: andrey.lesnikov at jetbrains dot com Target Milestone: --- Created attachment 13722 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D13722&action=3Ded= it a zip copy of the https://github.com/ozkriff/gdb_slow_var_list_children repo A sample project (sadly, I wasn't able to minimize the sample project furth= er) is based on https://vulkan-tutorial.com/Multisampling Vulkan demo with minor tweaks: https://github.com/ozkriff/gdb_slow_var_list_children (a zip copy is also attached) Steps to reproduce the issue: - clone the gdb_slow_var_list_children repo and cd into it - `cmake -DCMAKE_BUILD_TYPE=3DDebug -Btarget` - `cd target` - `cmake --build .` - `gdb -q -ex "source -v ../gdb-commands"` The gdb-commands GDB script basically sets up a simple pretty-printer from printers.py, sets a breakpoint, launches the executable and calls -var-list-children that take unexpectedly significant time (up to 6 seconds= on my machine with i9-9980HK) to execute despite not doing that much work. Additional info: - Ubuntu 20.04.3 LTS - Linux 5.4.0-88-generic #99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux - GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2 - gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 - cmake version 3.16.3 The gdb-commands script: ``` # run with something like "gdb -q -ex "source -v gdb-commands" | gnomon -h = 1" interpreter-exec mi2 "-gdb-set print elements 250" interpreter-exec mi2 "-gdb-set print repeats 0" interpreter-exec mi2 "-gdb-set print object on" interpreter-exec mi2 "-gdb-set print asm-demangle on" interpreter-exec mi2 "-gdb-set python print-stack full" interpreter-exec mi2 "-gdb-set backtrace past-main on" interpreter-exec mi2 "-gdb-show mi-async" interpreter-exec mi2 "handle SIGSTOP stop nopass" interpreter-exec mi2 "info pretty-printer" interpreter-exec mi2 "python import sys; sys.dont_write_bytecode =3D True;" interpreter-exec mi2 "python import sys; sys.path.insert(0, \"..\"); from printers import register_default_printers; register_default_printers(None);" interpreter-exec mi2 "-enable-pretty-printing" interpreter-exec mi2 "-file-exec-and-symbols "vksample"" interpreter-exec mi2 "-break-insert -f "src/main.cpp:357"" interpreter-exec mi2 "-gdb-set charset UTF-8" interpreter-exec mi2 "-exec-run" interpreter-exec mi2 "0-gdb-set $__poke_gdb=3D1" interpreter-exec mi2 "-stack-list-frames --thread 1 0 100" interpreter-exec mi2 "-stack-list-variables --thread 1 --frame 0 --no-value= s" interpreter-exec mi2 "-interpreter-exec --thread 1 --frame 0 console \"whatis/mt this\"" interpreter-exec mi2 "-data-evaluate-expression --thread 1 --frame 0 $fp" interpreter-exec mi2 "-stack-list-frames --thread 1 1 101" interpreter-exec mi2 "-var-create var1_this * \"this\"" interpreter-exec mi2 "-var-list-children --all-values "var1_this" -1 -1" interpreter-exec mi2 "-var-list-children --all-values "var1_this.private" 0= 44" quit ``` printers.py: ``` import gdb def untypedef(type_obj): if (type_obj.code =3D=3D gdb.TYPE_CODE_REF or type_obj.code =3D=3D getattr(gdb, 'TYPE_CODE_RVALUE_REF', No= ne)): type_obj =3D type_obj.target() if type_obj.code =3D=3D gdb.TYPE_CODE_TYPEDEF: type_obj =3D type_obj.strip_typedefs() return type_obj def lookup(val): type =3D untypedef(val.type) if type.code =3D=3D gdb.TYPE_CODE_PTR: try: dereferenced =3D val.dereference() dereferenced.fetch_lazy() except gdb.error as e: print('ERROR: ', str(e)) else: delegate =3D gdb.default_visualizer(dereferenced) assert(delegate is None) # normally, the delegate would be passed into a custom pretty printer next return None def register_default_printers(obj): gdb.printing.register_pretty_printer(obj, lookup) ``` The main.cpp is too big to inline as a text so I'm leaving it in the repo/attachment. --=20 You are receiving this mail because: You are on the CC list for the bug.=