Index: /trunk/src/VBox/ValidationKit/testdriver/vbox.py
===================================================================
--- /trunk/src/VBox/ValidationKit/testdriver/vbox.py	(revision 61566)
+++ /trunk/src/VBox/ValidationKit/testdriver/vbox.py	(revision 61567)
@@ -2565,4 +2565,16 @@
         asMiscInfos = [];
         if self.fAlwaysUploadLogs or reporter.testErrorCount() > 0:
+            # Dump the guest stack for all CPUs.
+            cCpus = oSession.getCpuCount();
+            if cCpus > 0:
+                for iCpu in xrange(0, cCpus):
+                    sThis = oSession.queryDbgGuestStack(iCpu);
+                    if sThis is not None and len(sThis) > 0:
+                        asMiscInfos += [
+                            '================ start guest stack VCPU %s ================\n' % (iCpu,),
+                            sThis,
+                            '================ end guest stack VCPU %s ==================\n' % (iCpu,),
+                        ];
+
             for sInfo, sArg in [ ('mode', 'all'),
                                  ('fflags', ''),
Index: /trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py
===================================================================
--- /trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py	(revision 61566)
+++ /trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py	(revision 61567)
@@ -1526,4 +1526,18 @@
         return fRc;
 
+    def getCpuCount(self):
+        """
+        Returns the number of CPUs.
+        Returns the number of CPUs on success and 0 on failure. Error information is logged.
+        """
+        cCpus = 0;
+        try:
+            cCpus = self.o.machine.CPUCount;
+        except:
+            reporter.errorXcpt('failed to get the CPU count of "%s"' % (self.sName,));
+
+        self.oTstDrv.processPendingEvents();
+        return cCpus;
+
     def ensureControllerAttached(self, sController):
         """
@@ -2427,4 +2441,34 @@
             reporter.logXcpt('Unable to query vgatext with arg "%s"' % (sArg,));
         return sVgaText;
+
+    def queryDbgGuestStack(self, iCpu = 0):
+        """
+        Returns the guest stack for the given VCPU.
+
+        Returns string containing the guest stack for the selected VCPU on success.
+        Returns None on failure.
+        """
+
+        #
+        # Load all plugins first and try to detect the OS so we can
+        # get nicer stack traces.
+        #
+        try:
+            self.o.console.debugger.loadPlugIn('all');
+        except:
+            reporter.logXcpt('Unable to load debugger plugins');
+        else:
+            try:
+                sOsDetected = self.o.console.debugger.detectOS();
+            except:
+                reporter.logXcpt('Failed to detect the guest OS');
+
+        sGuestStack = None;
+        try:
+            sGuestStack = self.o.console.debugger.dumpGuestStack(iCpu);
+        except:
+            reporter.logXcpt('Unable to query guest stack for CPU %s' % (iCpu, ));
+
+        return sGuestStack;
 
 
