* proposed patch
@ 2007-05-19 1:48 Sami Wagiaalla
2007-05-21 20:49 ` Stan Cox
0 siblings, 1 reply; 3+ messages in thread
From: Sami Wagiaalla @ 2007-05-19 1:48 UTC (permalink / raw)
To: Stan Cox, Andrew Cagney; +Cc: frysk
[-- Attachment #1: Type: text/plain, Size: 264 bytes --]
Hi Andrew and Stan,
After a huge learning curve here is a patch of me getting started on the
stack work.
Please take a close look. I just want to make sure I am on the right
track specifics can be sorted out later.
Any guidance is appreciated.
Thanx,
Sami
[-- Attachment #2: RichFrame.patch --]
[-- Type: text/x-patch, Size: 15610 bytes --]
? RichFrame.patch
Index: .classpath
===================================================================
RCS file: /cvs/frysk/frysk-top/.classpath,v
retrieving revision 1.14
diff -u -r1.14 .classpath
--- .classpath 4 May 2007 18:26:54 -0000 1.14
+++ .classpath 18 May 2007 20:22:57 -0000
@@ -16,5 +16,6 @@
<classpathentry kind="lib" path="/usr/share/java/libgcj-4.1.1.jar"/>
<classpathentry kind="lib" path="/usr/share/java/jdom.jar"/>
<classpathentry kind="lib" path="/usr/local/share/java/frysk-core.jar"/>
+ <classpathentry kind="lib" path="/usr/local/share/java/frysk-imports.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Index: .settings/org.eclipse.jdt.core.prefs
===================================================================
RCS file: /cvs/frysk/frysk-top/.settings/org.eclipse.jdt.core.prefs,v
retrieving revision 1.5
diff -u -r1.5 org.eclipse.jdt.core.prefs
--- .settings/org.eclipse.jdt.core.prefs 5 Apr 2007 19:55:13 -0000 1.5
+++ .settings/org.eclipse.jdt.core.prefs 18 May 2007 20:22:57 -0000
@@ -1,4 +1,4 @@
-#Mon Apr 02 11:16:02 EDT 2007
+#Fri May 18 15:21:49 EDT 2007
eclipse.preferences.version=1
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=18
@@ -34,13 +34,13 @@
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_block=next_line_shifted
-org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line
-org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line_shifted
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines=true
org.eclipse.jdt.core.formatter.comment.format_comments=true
Index: frysk-core/frysk/pkglibdir/funit-stacks.c
===================================================================
RCS file: frysk-core/frysk/pkglibdir/funit-stacks.c
diff -N frysk-core/frysk/pkglibdir/funit-stacks.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ frysk-core/frysk/pkglibdir/funit-stacks.c 18 May 2007 20:22:57 -0000
@@ -0,0 +1,32 @@
+#include <stdlib.h>
+
+void third(){
+ if(1+1){
+ while(1){
+ {
+ exit(1);
+ }
+ }
+ }
+}
+
+void second(){
+
+ third();
+
+}
+
+void first(){
+
+ second();
+
+}
+
+
+int main(){
+
+ first ();
+
+ return 0;
+}
+
Index: frysk-core/frysk/proc/TestLib.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/proc/TestLib.java,v
retrieving revision 1.154
diff -u -r1.154 TestLib.java
--- frysk-core/frysk/proc/TestLib.java 18 May 2007 19:27:47 -0000 1.154
+++ frysk-core/frysk/proc/TestLib.java 18 May 2007 20:22:58 -0000
@@ -840,6 +840,11 @@
{
mainTask.requestUnblock(execBlockingObserver);
}
+
+ public Task getMainTask ()
+ {
+ return this.mainTask;
+ }
}
/**
Index: frysk-core/frysk/rt/Frame.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/rt/Frame.java,v
retrieving revision 1.13
diff -u -r1.13 Frame.java
--- frysk-core/frysk/rt/Frame.java 15 May 2007 21:38:20 -0000 1.13
+++ frysk-core/frysk/rt/Frame.java 18 May 2007 20:22:58 -0000
@@ -123,7 +123,7 @@
*/
public abstract Line[] getLines ();
- public final Subprogram getSubprogram ()
+ public Subprogram getSubprogram ()
{
return subprogram;
}
Index: frysk-core/frysk/rt/RichFrame.java
===================================================================
RCS file: frysk-core/frysk/rt/RichFrame.java
diff -N frysk-core/frysk/rt/RichFrame.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ frysk-core/frysk/rt/RichFrame.java 18 May 2007 20:22:58 -0000
@@ -0,0 +1,144 @@
+// This file is part of the program FRYSK.
+//
+// Copyright 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
+// the Free Software Foundation; version 2 of the License.
+//
+// FRYSK is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with FRYSK; if not, write to the Free Software Foundation,
+// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// In addition, as a special exception, Red Hat, Inc. gives You the
+// additional right to link the code of FRYSK with code not covered
+// under the GNU General Public License ("Non-GPL Code") and to
+// distribute linked combinations including the two, subject to the
+// limitations in this paragraph. Non-GPL Code permitted under this
+// exception must only link to the code of FRYSK through those well
+// defined interfaces identified in the file named EXCEPTION found in
+// the source code files (the "Approved Interfaces"). The files of
+// Non-GPL Code may instantiate templates or use macros or inline
+// functions from the Approved Interfaces without causing the
+// resulting work to be covered by the GNU General Public
+// License. Only Red Hat, Inc. may make changes or additions to the
+// list of Approved Interfaces. You must obey the GNU General Public
+// License in all respects for all of the FRYSK code and other code
+// used in conjunction with FRYSK except the Non-GPL Code covered by
+// this exception. If you modify this file, you may extend this
+// exception to your version of the file, but you are not obligated to
+// do so. If you do not wish to provide this exception without
+// modification, you must delete this exception statement from your
+// version and license this file solely under the GPL without
+// exception.
+
+
+package frysk.rt;
+
+import lib.dw.DwTagEncodings;
+import lib.dw.DwarfDie;
+import lib.dw.Dwfl;
+import lib.dw.DwflDieBias;
+import lib.unwind.Cursor;
+import frysk.proc.Task;
+
+public class RichFrame
+ extends RemoteFrame
+{
+
+ RichFrame (Cursor cursor, Task task)
+ {
+ super(cursor, task);
+ }
+
+ public final Subprogram getSubprogram ()
+ {
+ Subprogram subprogram = super.getSubprogram();
+
+ if (subprogram == null) {
+
+ Dwfl dwfl = new Dwfl(this.getTask().getProc().getPid());
+ DwflDieBias bias = dwfl.getDie(getAdjustedAddress());
+
+ if (bias != null) {
+
+ DwarfDie[] scopes = bias.die.getScopes(getAdjustedAddress());
+
+ for (int i = 0; i < scopes.length; i++) {
+ if (scopes[i].getTag() == DwTagEncodings.DW_TAG_subprogram_) {
+ subprogram = new Subprogram(scopes[i]);
+ }
+ }
+ }
+ this.setSubprogram(subprogram);
+ }
+
+ return subprogram;
+ }
+
+ public Frame getOuter ()
+ {
+ if (outer == null) {
+ Cursor newCursor = this.cursor.unwind();
+ if (newCursor != null) {
+ outer = new RichFrame(newCursor, task);
+ outer.inner = this;
+ }
+ }
+ return outer;
+ }
+
+ /**
+ * Return a simple string representation of this stack frame. The
+ * returned string is suitable for display to the user.
+ */
+ public String toPrint (boolean name)
+ {
+ // XXX: There is always an inner cursor.
+ if (this.cursor == null)
+ return "Empty stack trace";
+
+ // Pad the address based on the task's word size.
+ StringBuffer builder = new StringBuffer("0x");
+ String addr = Long.toHexString(getAddress());
+ int padding = 2 * task.getIsa().getWordSize() - addr.length();
+ for (int i = 0; i < padding; ++i)
+ builder.append('0');
+ builder.append(addr);
+
+ if (getSubprogram() != null) {
+ builder.append(" dwarf: " + getSubprogram().getName());
+ }
+ else {
+ // Print the symbol, if known append ().
+ Symbol symbol = getSymbol();
+ builder.append(" in ");
+ builder.append(symbol.getDemangledName());
+ if (symbol != Symbol.UNKNOWN)
+ builder.append(" ()");
+ }
+
+ // If there's line number information append that.
+ Line[] lines = getLines();
+ for (int i = 0; i < lines.length; i++) {
+ Line line = lines[i];
+ builder.append(" from: ");
+ if (name) {
+ builder.append(line.getFile().getName());
+ builder.append(": line #");
+ builder.append(line.getLine());
+ }
+ else {
+ builder.append(line.getFile().getPath());
+ builder.append("#");
+ builder.append(line.getLine());
+ }
+ }
+ return builder.toString();
+ }
+}
Index: frysk-core/frysk/rt/StackFactory.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/rt/StackFactory.java,v
retrieving revision 1.26
diff -u -r1.26 StackFactory.java
--- frysk-core/frysk/rt/StackFactory.java 11 May 2007 15:32:11 -0000 1.26
+++ frysk-core/frysk/rt/StackFactory.java 18 May 2007 20:22:58 -0000
@@ -142,7 +142,7 @@
buffer.append(new StringBuffer("Task #" + task.getTid() + "\n"));
int count = 0;
- for (Frame frame = StackFactory.createFrame(task); frame != null; frame = frame.getOuter())
+ for (Frame frame = StackFactory.createRichFrame(task,0); frame != null; frame = frame.getOuter())
{
// FIXME: do valgrind-like '=== PID ===' ?
StringBuffer output = new StringBuffer("#" + count + " "
@@ -171,5 +171,20 @@
return string;
}
+
+ public static RichFrame createRichFrame (Task task, int i)
+ {
+ Unwind unwinder;
+ if (task.getIsa().getWordSize() == 4)
+ unwinder = new UnwindX86();
+ else
+ unwinder = new UnwindNative();
+ AddressSpace addressSpace = new AddressSpace(unwinder, lib.unwind.ByteOrder.DEFAULT);
+ StackAccessors accessors = new StackAccessors(addressSpace, task,
+ lib.unwind.ByteOrder.DEFAULT);
+
+ Cursor cursor = new Cursor(addressSpace, accessors);
+ return new RichFrame(cursor, task);
+ }
}
Index: frysk-core/frysk/rt/Subprogram.java
===================================================================
RCS file: /cvs/frysk/frysk-core/frysk/rt/Subprogram.java,v
retrieving revision 1.2
diff -u -r1.2 Subprogram.java
--- frysk-core/frysk/rt/Subprogram.java 11 May 2007 11:43:52 -0000 1.2
+++ frysk-core/frysk/rt/Subprogram.java 18 May 2007 20:22:58 -0000
@@ -43,6 +43,7 @@
package frysk.rt;
+import lib.dw.DwarfDie;
import frysk.value.Value;
public class Subprogram
@@ -51,7 +52,22 @@
Subprogram outer;
LexicalBlock block;
Value[] parameters;
+ private DwarfDie die;
+ public Subprogram (DwarfDie die)
+ {
+ this.die = die;
+ }
+
+ public Subprogram ()
+ {
+
+ }
+
+ public String getName(){
+ return this.die.getName();
+ }
+
public LexicalBlock getBlock ()
{
return block;
Index: frysk-core/frysk/rt/TestRichFrame.java
===================================================================
RCS file: frysk-core/frysk/rt/TestRichFrame.java
diff -N frysk-core/frysk/rt/TestRichFrame.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ frysk-core/frysk/rt/TestRichFrame.java 18 May 2007 20:22:58 -0000
@@ -0,0 +1,107 @@
+// This file is part of the program FRYSK.
+//
+// Copyright 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
+// the Free Software Foundation; version 2 of the License.
+//
+// FRYSK is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with FRYSK; if not, write to the Free Software Foundation,
+// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// In addition, as a special exception, Red Hat, Inc. gives You the
+// additional right to link the code of FRYSK with code not covered
+// under the GNU General Public License ("Non-GPL Code") and to
+// distribute linked combinations including the two, subject to the
+// limitations in this paragraph. Non-GPL Code permitted under this
+// exception must only link to the code of FRYSK through those well
+// defined interfaces identified in the file named EXCEPTION found in
+// the source code files (the "Approved Interfaces"). The files of
+// Non-GPL Code may instantiate templates or use macros or inline
+// functions from the Approved Interfaces without causing the
+// resulting work to be covered by the GNU General Public
+// License. Only Red Hat, Inc. may make changes or additions to the
+// list of Approved Interfaces. You must obey the GNU General Public
+// License in all respects for all of the FRYSK code and other code
+// used in conjunction with FRYSK except the Non-GPL Code covered by
+// this exception. If you modify this file, you may extend this
+// exception to your version of the file, but you are not obligated to
+// do so. If you do not wish to provide this exception without
+// modification, you must delete this exception statement from your
+// version and license this file solely under the GPL without
+// exception.
+
+
+package frysk.rt;
+
+import java.util.logging.Logger;
+
+import frysk.proc.Action;
+import frysk.proc.Manager;
+import frysk.proc.Task;
+import frysk.proc.TestLib;
+import frysk.proc.TaskObserver.Terminating;
+
+public class TestRichFrame
+ extends TestLib
+{
+
+ Logger logger = Logger.getLogger("frysk");
+
+ public void testRichFrame ()
+ {
+ Task task = getStoppedTask();
+
+ RichFrame richFrame = StackFactory.createRichFrame(task, 0);
+ String string = StackFactory.printStackTrace(richFrame);
+ System.out.println("TestRichFrame.testRichFrame()\n"+string);
+
+ assertTrue("first", string.contains("first"));
+ assertTrue("second", string.contains("second"));
+ assertTrue("third",string.contains("third"));
+
+ }
+
+ public Task getStoppedTask ()
+ {
+
+ AttachedDaemonProcess ackProc = new AttachedDaemonProcess(
+ new String[] { getExecPath("funit-stacks") });
+
+ Task task = ackProc.getMainTask();
+
+ task.requestAddTerminatingObserver(new Terminating()
+ {
+
+ public void deletedFrom (Object observable)
+ {
+ }
+
+ public void addedTo (Object observable)
+ {
+ }
+
+ public Action updateTerminating (Task task, boolean signal, int value)
+ {
+ Manager.eventLoop.requestStop();
+ return Action.BLOCK;
+ }
+
+ public void addFailed (Object observable, Throwable w)
+ {
+ throw new RuntimeException(w);
+ }
+ });
+ ackProc.resume();
+ assertRunUntilStop("Attach to process");
+
+ return task;
+ }
+
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: proposed patch
2007-05-19 1:48 proposed patch Sami Wagiaalla
@ 2007-05-21 20:49 ` Stan Cox
2007-05-22 14:28 ` Sami Wagiaalla
0 siblings, 1 reply; 3+ messages in thread
From: Stan Cox @ 2007-05-21 20:49 UTC (permalink / raw)
To: Sami Wagiaalla; +Cc: Frysk List
Maybe we can just keep the subprogram name directly instead of using
DwarfDie in Subprogram.java? Will RichFrame be wired into the
Frame->Subprogram->LexicalBlock heirarchy?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: proposed patch
2007-05-21 20:49 ` Stan Cox
@ 2007-05-22 14:28 ` Sami Wagiaalla
0 siblings, 0 replies; 3+ messages in thread
From: Sami Wagiaalla @ 2007-05-22 14:28 UTC (permalink / raw)
To: Stan Cox; +Cc: Frysk List
Stan Cox wrote:
> Maybe we can just keep the subprogram name directly instead of using
> DwarfDie in Subprogram.java?
Thats fine, I just didnt know what other information than the name will
be needed in the future
> Will RichFrame be wired into the
> Frame->Subprogram->LexicalBlock heirarchy?
Yes, RichFrame extends Frame, and returns a subprogram.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-22 13:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-19 1:48 proposed patch Sami Wagiaalla
2007-05-21 20:49 ` Stan Cox
2007-05-22 14:28 ` 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).