[PATCH] have anaconda write anacdump.txt on demand

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm working on automatic data collection for bug reports.  Part of this
involves writing a little command line tool so we can tell users "Hey
switch to tty2 and run this command to get everything we need", instead
of having to walk them through it.

I thought it'd be nice if we could generate an anacdump.txt on demand,
to help debug where anaconda's stuck but hasn't crashed.  The attached
patch causes anaconda to write /tmp/anacdump.txt when SIGUSR2 is
received.  It requires the stuff Peter just mailed.

I'm thinking it is probably better to do this via dbus, but that
involves making anaconda a dbus-aware thing (whatever that involves) and
seems like a battle for another day.

- Chris


diff --git a/anaconda b/anaconda
index 2731c43..34628a0 100755
--- a/anaconda
+++ b/anaconda
@@ -502,6 +502,12 @@ class Anaconda:
         # *sigh* we still need to be able to write this out
         self.xdriver = None
 
+    def dumpState(self):
+        from exception import AnacondaExceptionDump
+        # Skip the frames for isys.traceback, dumpState, and the signal handler.
+        exn = AnacondaExceptionDump(None, None, isys.traceback(2))
+        exn.write(anaconda)
+
     def writeXdriver(self, instPath="/"):
         # this should go away at some point, but until it does, we
         # need to keep it around.  it could go into instdata but this
@@ -588,7 +594,7 @@ if __name__ == "__main__":
     # this handles setting up updates for pypackages to minimize the set needed
     setupPythonUpdates()
 
-    import signal, traceback, string, isys, iutil, time
+    import signal, string, isys, iutil, time
     from exception import handleException
     import dispatch
     import warnings
@@ -611,6 +617,9 @@ if __name__ == "__main__":
     signal.signal(signal.SIGINT, signal.SIG_DFL)
     signal.signal(signal.SIGSEGV, isys.handleSegv)
 
+    # add our own additional signal handlers
+    signal.signal(signal.SIGUSR2, lambda signum, frame: anaconda.dumpState())
+
     setupEnvironment()
 
     # we need to do this really early so we make sure its done before rpm
diff --git a/exception.py b/exception.py
index b146315..4cc5983 100644
--- a/exception.py
+++ b/exception.py
@@ -63,7 +63,10 @@ class AnacondaExceptionDump:
         lst.reverse()
         lst.insert(0, "anaconda %s exception report\n" % os.getenv("ANACONDAVERSION"))
         lst.insert(1, 'Traceback (most recent call first):\n')
-        lst.extend(traceback.format_exception_only(self.type, self.value))
+
+        if self.type is not None and self.value is not None:
+            lst.extend(traceback.format_exception_only(self.type, self.value))
+
         return joinfields(lst, "")
 
     # Create a string representation of a class and write it to fd.  This

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux