install gdb pretty printers for standalone build

NEW
Unassigned

Status

()

5 years ago
4 years ago

People

(Reporter: darkxst, Unassigned)

Tracking

24 Branch
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

(Reporter)

Description

5 years ago
It would be nice to have the GDB pretty-printers installed for standalone spidermonkey build.

This would require installing a 'libmozjs-24.1.so-gdb.py' wrapper under /usr/share/gdb/auto-load and install the python scripts somewhere as well.

also on Ubuntu atleast gdb runs using python3, so the scripts would need some minor changes to work.
(Reporter)

Comment 1

5 years ago
Trying to get the pretty printers running under python3, fixed most of the obvious changes, however

dummy = gdb.Value(0).cast(cache.JSString_ptr_t)

throws

Python Exception <class 'TypeError'> 'gdb.Value' object cannot be interpreted as an integer:

no idea how to fix this ;(

Comment 2

5 years ago
Does GDB support Python 3 now? It didn't last I checked, and there's no mention of Python 3 support in the NEWS file.

> no idea how to fix this ;(

That doesn't look familiar to me, either.
(Reporter)

Comment 3

5 years ago
It certainly is using python3 on Ubuntu 13.10 and later, no idea about other distros though.
(Reporter)

Comment 4

5 years ago
Created attachment 8344927 [details] [diff] [review]
changes required for python3
(Reporter)

Comment 5

5 years ago
Created attachment 8344975 [details] [diff] [review]
mozjs-gdb-install.patch

this patch is against js24

Comment 6

5 years ago
Will these patches also work with Python 2.7?

$ /usr/bin/gdb
GNU gdb (GDB) Fedora 7.6.1-46.fc19
...
(gdb) python print sys.version
2.7.5 (default, Nov 12 2013, 16:18:42) 
[GCC 4.8.2 20131017 (Red Hat 4.8.2-1)]
(gdb)

Comment 7

5 years ago
Ted, are these build patches the right way to get this done, or can we accomplish the same thing with moz.build?
Flags: needinfo?(ted)
I don't think there's a better way at the moment, which is sort of unfortunate.
Flags: needinfo?(ted)
(Reporter)

Comment 9

5 years ago
Jim, The python patch will need to be reworked slightly to work on both python 2 and 3.

The build patch will work with both
(Reporter)

Comment 10

5 years ago
Created attachment 8345512 [details] [diff] [review]
mozjs-gdb-py3-v2.patch

Updated python3 patch to maintain compatibilty with python2. 

I am pretty sure this will work, however I don't actually have a machine with gdb/python2 to test it.
Attachment #8344927 - Attachment is obsolete: true
(Reporter)

Comment 11

5 years ago
So are these ok to land? I will rebase against m-c if so...

I may also look at adding frame filters sometime before the next standalone release, since we now have a new enough gdb in Ubuntu.

Comment 12

5 years ago
(In reply to darkxst from comment #11)
> So are these ok to land? I will rebase against m-c if so...

You need to flag them for review.
(Reporter)

Updated

5 years ago
Attachment #8345512 - Flags: review?(jimb)
(Reporter)

Updated

5 years ago
Attachment #8344975 - Flags: review?(jimb)
(Reporter)

Comment 13

5 years ago
have checked and patches apply cleanly against m-c

Comment 14

5 years ago
So this is a good idea in general, however we'll need to work out how to support gdb/python2 and gdb/python3 together; assuming python3 isn't safe, not only because of the version requirements (7.7 and above iirc) but also because even that version might be linked to python2.

I suggest we duplicate this particular portion of the source tree into a python2 and python3 version, if we can't make the code generic enough that it will support both (and even with py3.3 i think that's unlikely)

Thoughts?
(Reporter)

Comment 15

5 years ago
Ian, patch 8345512 maintains compatibility with python2 see comment #10. And the install patch is in no way dependant on the version of python.
(Reporter)

Comment 16

5 years ago
also python3 support came with 7.6 or perhaps earlier? 7.7 introduced the the new frame-filter api, but adding support for that will be a different bug.

Comment 17

4 years ago
Comment on attachment 8344975 [details] [diff] [review]
mozjs-gdb-install.patch

Review of attachment 8344975 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks very much for the patch; I apologize for dropping the review.

Could you make sure this patch works with the current sources? I think the stand-alone build process is broken at the moment.

::: js/src/Makefile.in
@@ +555,5 @@
> +	$(SYSINSTALL) $^ $(DESTDIR)$(prefix)/share/gdb/auto-load$(libdir)
> +
> +install:: gdb/mozilla
> +	$(SYSINSTALL) $^ $(DESTDIR)$(prefix)/share/mozilla/gdb
> +endif

I think this should be done with the PP_TARGETS and INSTALL_TARGETS variables, as it was done here: 

https://hg.mozilla.org/mozilla-central/file/7f81be7db528/js/src/shell/Makefile.in#l26

The more we can avoid putting shell commands in Makefiles, the easier it is for the folks working on our build system to automatically migrate Makefile contents into moz.build files.

::: js/src/libmozjs-gdb.py.in
@@ +1,1 @@
> +"""GDB Python customization auto-loader for GDB spidermoneky library"""

"SpiderMonkey"

@@ +3,5 @@
> +
> +import sys
> +
> +import os.path
> +sys.path[0:0] = [os.path.join('@autoloaddir@', 'gdb')]

The name "@autoloaddir@" suggests $prefix/share/gdb/auto-load, but this is actually $(prefix)/share/mozilla; that's confusing. Could we call it @mozillasharedir@?
Attachment #8344975 - Flags: review?(jimb)

Comment 18

4 years ago
Comment on attachment 8345512 [details] [diff] [review]
mozjs-gdb-py3-v2.patch

Review of attachment 8345512 [details] [diff] [review]:
-----------------------------------------------------------------

Thank you for the patch! I think this patch was taken care of by bug 1014479.
Attachment #8345512 - Flags: review?(jimb)
(Reporter)

Comment 19

4 years ago
I can use  PP_TARGETS and INSTALL_TARGETS however I will still need a shell command to rename the python wrapper, atleast I don't see how that is possible using _TARGETS... 

i.e the template 'libmozjs-gdb.py.in' needs to end up installed as 'libmozjs-34a1.so-gdb.py'
(Reporter)

Comment 20

4 years ago
also INSTALL_TARGETS doesn't seem to support installing directories, i.e.

MOZJS_INSTALL_GDB_FILES := gdb/mozilla

creates the folder but doesn’t install the python files in that directory
You need to log in before you can comment on or make changes to this bug.