Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 705680 - sys-devel/gdb should call python_optimize()
Summary: sys-devel/gdb should call python_optimize()
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-17 16:33 UTC by Alexander Tsoy
Modified: 2020-01-20 19:38 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
sys-devel-gdb-call-python_optimize.patch (0001-sys-devel-gdb-call-python_optimize.patch,8.12 KB, text/plain)
2020-01-20 11:00 UTC, Alexander Tsoy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Tsoy 2020-01-17 16:33:49 UTC
$subj. Otherwise after running gdb as root there are orphaned files inside /usr/share/gdb/python/gdb:

$ find /usr/share/gdb/ | xargs qfile -o
/usr/share/gdb/python/gdb/command/__pycache__
/usr/share/gdb/python/gdb/command/__pycache__/__init__.cpython-36.pyc
/usr/share/gdb/python/gdb/command/__pycache__/explore.cpython-36.pyc
/usr/share/gdb/python/gdb/command/__pycache__/frame_filters.cpython-36.pyc
/usr/share/gdb/python/gdb/command/__pycache__/pretty_printers.cpython-36.pyc
/usr/share/gdb/python/gdb/command/__pycache__/prompt.cpython-36.pyc
/usr/share/gdb/python/gdb/command/__pycache__/type_printers.cpython-36.pyc
/usr/share/gdb/python/gdb/command/__pycache__/unwinders.cpython-36.pyc
/usr/share/gdb/python/gdb/command/__pycache__/xmethods.cpython-36.pyc
/usr/share/gdb/python/gdb/function/__pycache__
/usr/share/gdb/python/gdb/function/__pycache__/__init__.cpython-36.pyc
/usr/share/gdb/python/gdb/function/__pycache__/caller_is.cpython-36.pyc
/usr/share/gdb/python/gdb/function/__pycache__/strfns.cpython-36.pyc
/usr/share/gdb/python/gdb/function/__pycache__/as_string.cpython-36.pyc
/usr/share/gdb/python/gdb/printer/__pycache__
/usr/share/gdb/python/gdb/printer/__pycache__/__init__.cpython-36.pyc
/usr/share/gdb/python/gdb/printer/__pycache__/bound_registers.cpython-36.pyc
/usr/share/gdb/python/gdb/__pycache__
/usr/share/gdb/python/gdb/__pycache__/__init__.cpython-36.pyc
/usr/share/gdb/python/gdb/__pycache__/FrameIterator.cpython-36.pyc
/usr/share/gdb/python/gdb/__pycache__/FrameDecorator.cpython-36.pyc
/usr/share/gdb/python/gdb/__pycache__/frames.cpython-36.pyc
/usr/share/gdb/python/gdb/__pycache__/prompt.cpython-36.pyc
/usr/share/gdb/python/gdb/__pycache__/printing.cpython-36.pyc
/usr/share/gdb/python/gdb/__pycache__/types.cpython-36.pyc
/usr/share/gdb/python/gdb/__pycache__/xmethod.cpython-36.pyc
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2020-01-17 23:47:21 UTC
Sounds reasonable. How about:
  /usr/share/gdb/system-gdbinit/elinos.py
  /usr/share/gdb/system-gdbinit/wrs-linux.py

Would you like to write a patch yourself?
Comment 2 Arfrever Frehtes Taifersar Arahesis 2020-01-18 03:07:44 UTC
(In reply to Sergei Trofimovich from comment #1)
>   /usr/share/gdb/system-gdbinit/elinos.py
>   /usr/share/gdb/system-gdbinit/wrs-linux.py

Both of these files are incompatible with Python 3.
They are not used by default.


A file would be used by default if GDB was configured at build time with --with-system-gdbinit=FILE option. Example:
--with-system-gdbinit=/usr/share/gdb/system-gdbinit/wrs-linux.py


Otherwise, --command / -x / --init-command / -ix can be used:

$ gdb -x /usr/share/gdb/system-gdbinit/wrs-linux.py
...
  File "/usr/share/gdb/system-gdbinit/wrs-linux.py", line 24
    print "warning: ENV_PREFIX environment variable missing."
                                                            ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(int "warning: ENV_PREFIX environment variable missing.")?
(gdb) 


Testing with a valid file shows that Python cache file is not created:

$ echo 'print(123456)' > /tmp/aaa.py
$ gdb -x /tmp/aaa.py
...
123456
(gdb) quit
$ ls /tmp/__pycache__
ls: cannot access '/tmp/__pycache__': No such file or directory


So python_optimize() is not needed for /usr/share/gdb/system-gdbinit.
Comment 3 Alexander Tsoy 2020-01-20 11:00:00 UTC
Created attachment 603794 [details]
sys-devel-gdb-call-python_optimize.patch

I've bumped 8.3.1 because the patch changes installed files.
Comment 4 Larry the Git Cow gentoo-dev 2020-01-20 19:38:22 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=abc12b4d6fc5a276cdf82cf92066a27a9b5020a6

commit abc12b4d6fc5a276cdf82cf92066a27a9b5020a6
Author:     Alexander Tsoy <alexander@tsoy.me>
AuthorDate: 2020-01-20 10:48:41 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2020-01-20 19:38:16 +0000

    sys-devel/gdb: call python_optimize, bug #705680
    
    Closes: https://bugs.gentoo.org/705680
    Signed-off-by: Alexander Tsoy <alexander@tsoy.me>
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-devel/gdb/gdb-8.3.1-r1.ebuild | 264 ++++++++++++++++++++++++++++++++++++++
 sys-devel/gdb/gdb-9999.ebuild     |   4 +
 2 files changed, 268 insertions(+)