public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: frysk <frysk@sourceware.org>
Subject: Find right frame index in TestDebugInfoStackTrace.java
Date: Fri, 26 Oct 2007 15:42:00 -0000	[thread overview]
Message-ID: <1193413323.2931.15.camel@hermans.wildebeest.org> (raw)

[-- 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();
   }

             reply	other threads:[~2007-10-26 15:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-26 15:42 Mark Wielaard [this message]
2007-10-26 15:53 ` Sami Wagiaalla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1193413323.2931.15.camel@hermans.wildebeest.org \
    --to=mark@klomp.org \
    --cc=frysk@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).