Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 82837 Details for
Bug 126442
portage-2.1_pre6-* returns to shell just after 'compile' operation
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
portage debug patch for python tracing
portage_debug.patch (text/plain), 3.56 KB, created by
Zac Medico
on 2006-03-21 21:03:52 UTC
(
hide
)
Description:
portage debug patch for python tracing
Filename:
MIME Type:
Creator:
Zac Medico
Created:
2006-03-21 21:03:52 UTC
Size:
3.56 KB
patch
obsolete
>=== added file 'pym/portage_debug.py' >--- /dev/null >+++ pym/portage_debug.py >@@ -0,0 +1,104 @@ >+#!/usr/bin/python >+ >+import os, sys, threading >+ >+import portage_const >+from portage_util import writemsg >+ >+class prefix_trimmer(object): >+ def __init__(self, prefix): >+ self.prefix = prefix >+ self.cut_index = len(prefix) >+ self.previous = None >+ self.previous_trimmed = None >+ >+ def trim(self, s): >+ """Remove a prefix from the string and return the result. >+ The previous result is automatically cached.""" >+ if s is self.previous: >+ return self.previous_trimmed >+ else: >+ if s.startswith(self.prefix): >+ self.previous_trimmed = s[self.cut_index:] >+ else: >+ self.previous_trimmed = s >+ return self.previous_trimmed >+ >+class trace_handler(object): >+ >+ def __init__(self): >+ python_base = None >+ for x in sys.path: >+ if os.path.basename(x).startswith("python2."): >+ python_base = x >+ break >+ >+ self.ignore_prefixes = [] >+ if python_base is not None: >+ self.ignore_prefixes.append(python_base + os.sep) >+ >+ self.trimmer = prefix_trimmer(portage_const.PORTAGE_BASE_PATH + os.sep) >+ self.show_local_lines = False >+ self.max_repr_length = 200 >+ >+ def event_handler(self, *args): >+ frame, event, arg = args >+ if "line" == event: >+ if self.show_local_lines: >+ self.trace_line(*args) >+ else: >+ filename = frame.f_code.co_filename >+ if not self.ignore_filename(filename): >+ self.trace_event(*args) >+ return self.event_handler >+ >+ def trace_event(self, frame, event, arg): >+ writemsg("%s line=%d event=%s name=%s locals=%s\n" % \ >+ (self.trimmer.trim(frame.f_code.co_filename), >+ frame.f_lineno, >+ event, >+ frame.f_code.co_name, >+ self.locals_repr(frame, event, arg))) >+ >+ def trace_line(self, frame, event, arg): >+ filename = self.trimmer.trim(frame.f_code.co_filename) >+ writemsg("%s line=%d\n" % (filename, frame.f_lineno)) >+ >+ def ignore_filename(self, filename): >+ if filename: >+ for x in self.ignore_prefixes: >+ if filename.startswith(x): >+ return True >+ return False >+ >+ def locals_repr(self, frame, event, arg): >+ """Create a representation of the locals dict that is suitable for >+ tracing output.""" >+ >+ my_locals = frame.f_locals.copy() >+ >+ # prevent unsafe __repr__ call on self when __init__ is called >+ # (method calls aren't save until after __init__ has completed). >+ if frame.f_code.co_name == "__init__" and "self" in my_locals: >+ my_locals["self"] = "omitted" >+ >+ # We omit items that will lead to unreasonable bloat of the trace >+ # output (and resulting log file). >+ for k, v in my_locals.iteritems(): >+ my_repr = repr(v) >+ if len(my_repr) < self.max_repr_length: >+ my_locals[k] = my_repr >+ else: >+ my_locals[k] = "omitted" >+ return my_locals >+ >+def set_trace(on=True): >+ if on: >+ t = trace_handler() >+ threading.settrace(t.event_handler) >+ sys.settrace(t.event_handler) >+ else: >+ sys.settrace(None) >+ threading.settrace(None) >+ >+ > >=== modified file 'bin/ebuild' >--- bin/ebuild >+++ bin/ebuild >@@ -24,6 +24,11 @@ > sys.path = ["/usr/lib/portage/pym"]+sys.path > > import portage, portage_util, portage_const >+ >+# do this _after_ 'import portage' to prevent unnecessary tracing >+if debug: >+ import portage_debug >+ portage_debug.set_trace(True) > > if portage.settings["NOCOLOR"] in ("yes","true") or not sys.stdout.isatty(): > import output > >=== modified file 'bin/emerge' >--- bin/emerge >+++ bin/emerge >@@ -398,6 +398,8 @@ > portage.settings.backup_changes("PORTAGE_DEBUG") > portage.debug=1 > portage.settings.lock() >+ import portage_debug >+ portage_debug.set_trace(True) > > if ("--resume" in myopts): > if "--tree" in myopts: >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 126442
:
82476
|
82556
|
82557
| 82837 |
82849
|
82855