Merge lp:~darkxst/apport/sandbox-autoload into lp:~apport-hackers/apport/trunk

Proposed by Tim Lunn
Status: Needs review
Proposed branch: lp:~darkxst/apport/sandbox-autoload
Merge into: lp:~apport-hackers/apport/trunk
Diff against target: 68 lines (+23/-2)
2 files modified
apport/report.py (+22/-2)
bin/apport-retrace (+1/-0)
To merge this branch: bzr merge lp:~darkxst/apport/sandbox-autoload
Reviewer Review Type Date Requested Status
Martin Pitt (community) Needs Information
Review via email: mp+252686@code.launchpad.net

Description of the change

This is mostly useful for glib based apps to get the pretty printers working, which gives improved output on gobjects and signals. Though there are a few other packages that ship them as well.

apport-retrace when run against the system filesystem would already pick up these scripts.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Very nice, thanks! Will that append to the default search path, or completely replace it? https://sourceware.org/gdb/onlinedocs/gdb/objfile_002dgdbdotext-file.html#set%20auto-load%20scripts-directory doesn't really tell.. We certainly do want to keep gdb's scripts on the host, just additionally load the ones in the sandbox.

review: Needs Information
Revision history for this message
Tim Lunn (darkxst) wrote :

It currently replaces the search path, which seems fine to me since the scripts are always versioned with soname, so doesnt make sense to load them from the host. (actually thats not entirely true, python has a wrapper for the binary which obviously not versioned.)

auto-load: Attempted file "/lib/x86_64-linux-gnu/libglib-2.0.so.0.4391.0-gdb.gdb" does not exist.
auto-load: Attempted file "sandbox/usr/share/gdb/auto-load/lib/x86_64-linux-gnu/libglib-2.0.so.0.4391.0-gdb.gdb" does not exist.
auto-load: Attempted file "/lib/x86_64-linux-gnu/libglib-2.0.so.0.4391.0-gdb.py" does not exist.
auto-load: Attempted file "sandbox/usr/share/gdb/auto-load/lib/x86_64-linux-gnu/libglib-2.0.so.0.4391.0-gdb.py" exists.
auto-load: Loading python script "sandbox/usr/share/gdb/auto-load/lib/x86_64-linux-gnu/libglib-2.0.so.0.4391.0-gdb.py" by extension for objfile "/lib/x86_64-linux-gnu/libglib-2.0.so.0".
auto-load: Matching file "sandbox/usr/share/gdb/auto-load/lib/x86_64-linux-gnu/libglib-2.0.so.0.4391.0-gdb.py" to pattern "sandbox/usr/share/gdb/auto-load"
auto-load: File "sandbox/usr/share/gdb/auto-load/lib/x86_64-linux-gnu/libglib-2.0.so.0.4391.0-gdb.py" matches directory "sandbox/usr/share/gdb/auto-load".

The default search path is
(gdb) show auto-load scripts-directory
List of directories from which to load auto-loaded scripts is $debugdir:$datadir/auto-load

So could use the following to append to the default search paths
set auto-load scripts-directory $debugdir:$datadir/auto-load:sandbox/$debugdir:sandbox/$datadir/auto-load

lp:~darkxst/apport/sandbox-autoload updated
2931. By Tim Lunn

search both host and sandbox for scripts

Revision history for this message
Tim Lunn (darkxst) wrote :

actually the solib prefix gets inserted in the path, so we will never match a script on the system $debugdir is already sandbox-ified. we also need to insert a symlink into the sandbox so the path can match

auto-load: Attempted file "/tmp/apport_sandbox_74lv3Y//usr/share/gdb/auto-load/tmp/apport_sandbox_74lv3Y/lib/x86_64-linux-gnu/libglib-2.0.so.0.4391.0-gdb.py" exists.

lp:~darkxst/apport/sandbox-autoload updated
2932. By Tim Lunn

clean up search path and insert a symlinnk into the sandbox so we match full solib path

Revision history for this message
Tim Lunn (darkxst) wrote :

This is better:
$ apport-retrace -g -S config /var/crash/_usr_bin_gjs-console.1000.crash
(gdb) info auto-load python-scripts
Loaded Script
Yes /tmp/apport_sandbox_eMbqCa//usr/share/gdb/auto-load/tmp/apport_sandbox_eMbqCa/lib/x86_64-linux-gnu/libglib-2.0.so.0.4391.0-gdb.py
Yes /tmp/apport_sandbox_eMbqCa//usr/share/gdb/auto-load/tmp/apport_sandbox_eMbqCa/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4391.0-gdb.py
Yes /tmp/apport_sandbox_eMbqCa//usr/share/gdb/auto-load/tmp/apport_sandbox_eMbqCa/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20-gdb.py

Unmerged revisions

2932. By Tim Lunn

clean up search path and insert a symlinnk into the sandbox so we match full solib path

2931. By Tim Lunn

search both host and sandbox for scripts

2930. By Tim Lunn

use sandbox for gdb auto-load scripts

This allows for the pretty printers to work

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'apport/report.py'
--- apport/report.py 2015-02-10 10:21:40 +0000
+++ apport/report.py 2015-03-13 02:05:48 +0000
@@ -9,7 +9,7 @@
9# option) any later version. See http://www.gnu.org/copyleft/gpl.html for9# option) any later version. See http://www.gnu.org/copyleft/gpl.html for
10# the full text of the license.10# the full text of the license.
1111
12import subprocess, tempfile, os.path, re, pwd, grp, os, time12import subprocess, tempfile, os.path, re, pwd, grp, os, time, shutil
13import fnmatch, glob, traceback, errno, sys, atexit, locale13import fnmatch, glob, traceback, errno, sys, atexit, locale
1414
15import xml.dom, xml.dom.minidom15import xml.dom, xml.dom.minidom
@@ -688,6 +688,7 @@
688 # call gdb688 # call gdb
689 try:689 try:
690 out = _command_output(gdb_cmd).decode('UTF-8', errors='replace')690 out = _command_output(gdb_cmd).decode('UTF-8', errors='replace')
691 self.autoload_clean(rootdir)
691 except OSError:692 except OSError:
692 return693 return
693694
@@ -1461,6 +1462,21 @@
1461 else:1462 else:
1462 self[k] = pattern.sub(repl, self[k])1463 self[k] = pattern.sub(repl, self[k])
14631464
1465 def autoload_links(self, sandbox):
1466 rel_sandbox = sandbox.lstrip(os.path.sep)
1467 base = rel_sandbox.rsplit(os.path.sep,1)[0]
1468 autoload_path = os.path.join(sandbox, 'usr', 'share', 'gdb', 'auto-load')
1469 base_path = os.path.join(autoload_path, base)
1470 if not os.path.exists(base_path) and len(base) > 1:
1471 os.makedirs(base_path)
1472 if not os.path.exists(os.path.join(autoload_path, rel_sandbox)):
1473 os.symlink(autoload_path, os.path.join(autoload_path, rel_sandbox))
1474
1475 def autoload_clean(self,sandbox):
1476 if sandbox:
1477 rel_sandbox = sandbox.lstrip('/')
1478 shutil.rmtree(os.path.join(sandbox, 'usr', 'share', 'gdb', 'auto-load', rel_sandbox.split(os.path.sep)[0]))
1479
1464 def gdb_command(self, sandbox):1480 def gdb_command(self, sandbox):
1465 '''Build gdb command for this report.1481 '''Build gdb command for this report.
14661482
@@ -1501,8 +1517,12 @@
1501 # note, i386 vs. x86_64 is auto-detected just fine1517 # note, i386 vs. x86_64 is auto-detected just fine
15021518
1503 if sandbox:1519 if sandbox:
1520 self.autoload_links(sandbox)
1521 scripts_path = '$debugdir:%s/$datadir/auto-load' % sandbox
1504 command += ['--ex', 'set debug-file-directory %s/usr/lib/debug' % sandbox,1522 command += ['--ex', 'set debug-file-directory %s/usr/lib/debug' % sandbox,
1505 '--ex', 'set solib-absolute-prefix ' + sandbox]1523 '--ex', 'set solib-absolute-prefix ' + sandbox,
1524 '--ex', 'set auto-load scripts-directory ' + scripts_path,
1525 '--ex', 'set auto-load safe-path ' + scripts_path]
1506 executable = sandbox + '/' + executable1526 executable = sandbox + '/' + executable
15071527
1508 assert os.path.exists(executable)1528 assert os.path.exists(executable)
15091529
=== modified file 'bin/apport-retrace'
--- bin/apport-retrace 2014-08-29 10:32:33 +0000
+++ bin/apport-retrace 2015-03-13 02:05:48 +0000
@@ -316,6 +316,7 @@
316 apport.log('Calling gdb command: ' + cmd, log_timestamps)316 apport.log('Calling gdb command: ' + cmd, log_timestamps)
317 apport.memdbg('before calling gdb')317 apport.memdbg('before calling gdb')
318 subprocess.call(gdb_cmd)318 subprocess.call(gdb_cmd)
319 report.autoload_clean(sandbox)
319else:320else:
320 # regenerate gdb info321 # regenerate gdb info
321 apport.memdbg('before collecting gdb info')322 apport.memdbg('before collecting gdb info')

Subscribers

People subscribed via source and target branches