public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* Find right frame index in TestDebugInfoStackTrace.java
@ 2007-10-26 15:42 Mark Wielaard
  2007-10-26 15:53 ` Sami Wagiaalla
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2007-10-26 15:42 UTC (permalink / raw)
  To: frysk

[-- Attachment #1: Type: text/plain, Size: 635 bytes --]

Hi,

On a multi-core machine the TestDebugInfoStackTrace would sometimes fail
because the "signal_parent" task could still be in kernel, glibc signal
or kill helper functions. The following patch tries to find the right
index in that thread and uses that for the tests.

2007-10-26  Mark Wielaard  <mwielaard@redhat.com>

    * TestDebugInfoStackTrace.java (frameAssertions): Find and use
    correct thread_parent task frame index.

This makes this test reliably pass on my machine now even with different
frame index depths. But I found the test really hard to read so I
wouldn't mind someone double checking the fix.

Cheers,

Mark

[-- Attachment #2: TestDebugInfoStackTrace.patch --]
[-- Type: text/x-patch, Size: 3140 bytes --]

diff --git a/frysk-core/frysk/debuginfo/TestDebugInfoStackTrace.java b/frysk-core/frysk/debuginfo/TestDebugInfoStackTrace.java
index bbeb433..91a697b 100644
--- a/frysk-core/frysk/debuginfo/TestDebugInfoStackTrace.java
+++ b/frysk-core/frysk/debuginfo/TestDebugInfoStackTrace.java
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, 2006, Red Hat Inc.
+// Copyright 2005, 2006, 2007, Red Hat Inc.
 //
 // FRYSK is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -400,17 +400,28 @@ public class TestDebugInfoStackTrace
     assertNotNull(this.frameTracker[lowest][8][3]);
     assertEquals(0, Integer.parseInt(this.frameTracker[lowest][8][4]));
     
-    int index = 1;
+    int index = 0;
     for (int i = 0; i < 3; i++)
       {
-        if (this.frameTracker[i][1][2].equals("signal_parent"))
-          next = i;
-        else if (this.frameTracker[i][1][2].equals("kill"))
-          {
-            index = 2;
-            next = i;
-            break;
-          }
+	index = 0;
+	// We are looking for the thread that has signal_parent,
+	// but could still be in the kernel/syscall/kill.
+	String frameName =  this.frameTracker[i][index][2];
+	
+	while (frameName == null
+	       || frameName.indexOf("kill") > 0
+	       || frameName.indexOf("syscall") > 0)
+	  {
+	    index++;
+	    frameName = this.frameTracker[i][index][2];
+	  }
+
+        if (frameName.equals("signal_parent"))
+	  {
+	    next = i;
+	    break;
+	  }
+
       }
     
     /* Second thread assertions */
@@ -470,19 +481,22 @@ public class TestDebugInfoStackTrace
     assertNotNull(this.frameTracker[last][4][3]);
     assertEquals(130, Integer.parseInt(this.frameTracker[last][4][4]));
     
-    assertEquals("", this.frameTracker[next][2][1]);
-    assertEquals("start_thread", this.frameTracker[next][2][2]);
-    assertNotNull(this.frameTracker[next][2][3]);
-    assertEquals(0, Integer.parseInt(this.frameTracker[next][2][4]));
+    assertEquals("", this.frameTracker[next][index][1]);
+
+    index--;
+    assertEquals("start_thread", this.frameTracker[next][index][2]);
+    assertNotNull(this.frameTracker[next][index][3]);
+    assertEquals(0, Integer.parseInt(this.frameTracker[next][index][4]));
     
-    assertEquals("", this.frameTracker[next][3][1]);
+    index++;
+    assertEquals("", this.frameTracker[next][index][1]);
 //    if (MachineType.getMachineType() == MachineType.IA32)
 //      assertEquals("__clone", this.frameTracker[next][3][2]);
 //    if (MachineType.getMachineType() == MachineType.X8664)
 //      assertEquals("(__)?clone", this.frameTracker[next][3][2]);
-    assertTrue(this.frameTracker[next][3][2].matches("(__)?clone"));
-    assertNotNull(this.frameTracker[next][3][3]);
-    assertEquals(0, Integer.parseInt(this.frameTracker[next][3][4]));
+    assertTrue(this.frameTracker[next][index][2].matches("(__)?clone"));
+    assertNotNull(this.frameTracker[next][index][3]);
+    assertEquals(0, Integer.parseInt(this.frameTracker[next][index][4]));
     
     Manager.eventLoop.requestStop();
   }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Find right frame index in TestDebugInfoStackTrace.java
  2007-10-26 15:42 Find right frame index in TestDebugInfoStackTrace.java Mark Wielaard
@ 2007-10-26 15:53 ` Sami Wagiaalla
  0 siblings, 0 replies; 2+ messages in thread
From: Sami Wagiaalla @ 2007-10-26 15:53 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: frysk

Thanks mark I so annoyed with this test :)

Mark Wielaard wrote:
> Hi,
>
> On a multi-core machine the TestDebugInfoStackTrace would sometimes fail
> because the "signal_parent" task could still be in kernel, glibc signal
> or kill helper functions. The following patch tries to find the right
> index in that thread and uses that for the tests.
>
> 2007-10-26  Mark Wielaard  <mwielaard@redhat.com>
>
>     * TestDebugInfoStackTrace.java (frameAssertions): Find and use
>     correct thread_parent task frame index.
>
> This makes this test reliably pass on my machine now even with different
> frame index depths. But I found the test really hard to read so I
> wouldn't mind someone double checking the fix.
>
> Cheers,
>
> Mark
>   

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-26 15:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-26 15:42 Find right frame index in TestDebugInfoStackTrace.java Mark Wielaard
2007-10-26 15:53 ` Sami Wagiaalla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).