+2008-06-10 Andrew Cagney <cagney@redhat.com>
+
+ * TestFstack.java (testBackTraceWithRich()): Mark as unresolved;
+ bug 6616.
+ * ferror.java: Use PrintDebugInfoStackOptions; don't specify the
+ default stack options.
+ * ftrace.java: Ditto.
+ * fstack.java: Ditto.
+
2008-06-04 Sami Wagiaalla <swagiaal@redhat.com>
* TestFstep.java: Marked tests are unresolved.
TearDownExpect e = fstack("funit-stack-outlined", new String[] {
"-print", "debug-names,params"
});
- e.expect("\\#0 .* in third\\(int arg3\\) .*\\/funit-stack-outlined\\.c#");
+ e.expect("\\#0 .* in third\\(int arg3\\) at funit-stack-outlined\\.c#");
e.expect("\\#1");
}
}
public void testBackTraceWithRich() {
+ if (unresolved(6616))
+ return;
TearDownExpect e = fstack("funit-stack-inlined",
new String[] { "-rich" });
- e.expect("\\#0 .* third\\(int arg3.*\\)");
- e.expect("\\#1 .* second\\(int arg2.*\\)");
- e.expect("\\#2 .* first\\(int arg1.*\\)");
+ e.expect("\\#0 .* third\\(int arg3\\)");
+ e.expect("\\#1 .* second\\(int arg2\\)");
+ e.expect("\\#2 .* first\\(int arg1\\)");
e.expect("\\#3 .* main\\(\\)");
}
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.isa.syscalls.Syscall;
import frysk.proc.Action;
import frysk.proc.Task;
public class ferror {
- private static final PrintStackOptions stackPrintOptions
- = new PrintStackOptions().setRich();
+ private static final PrintDebugInfoStackOptions stackPrintOptions
+ = new PrintDebugInfoStackOptions();
private static final PrintWriter printWriter = new PrintWriter(System.out);
private static Pattern writePattern;
private static OptionGroup[] options() {
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.TreeMap;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.event.Event;
import frysk.event.ProcEvent;
import frysk.proc.Proc;
public final class fstack {
private static PrintWriter printWriter = new PrintWriter(System.out);
- private static PrintStackOptions stackPrintOptions
- = new PrintStackOptions();
+ private static PrintDebugInfoStackOptions stackPrintOptions
+ = new PrintDebugInfoStackOptions();
private static final Log fine = Log.fine(fstack.class);
public static void main(String[] args) {
import gnu.classpath.tools.getopt.OptionGroup;
import inua.util.PrintWriter;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.expr.FQIdentParser;
import frysk.expr.FQIdentifier;
import frysk.ftrace.AddrRule;
private final FtraceController controller = new FtraceController();
private boolean allowInterpTracing = false;
- private final PrintStackOptions stackPrintOptions
- = new PrintStackOptions();
+ private final PrintDebugInfoStackOptions stackPrintOptions
+ = new PrintDebugInfoStackOptions();
private final Ftrace tracer = new Ftrace(stackPrintOptions);
private interface RuleMatcher {
+2008-06-10 Andrew Cagney <cagney@redhat.com>
+
+ * DebugInfoFrame.java (toPrint(PrintWriter,boolean,boolean)): Delete.
+ (toPrint(PrintWriter,DebugInfoStackOptions)): New.
+ * PrintParameterOptions.java: New.
+ * VirtualDebugInfoFrame.java: Ditto.
+ * PrintDebugInfoStackOptions.java: Rename PrintStackOptions,
+ extend frysk.stack.PrintStackOptions.
+ * TestFrameDebugInfo.java: Update.
+
2008-06-06 Andrew Cagney <cagney@redhat.com>
* DebugInfo.java: Let DwflDie adjust for bias.
package frysk.debuginfo;
+import frysk.util.ArchFormatter;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.LinkedList;
-
import lib.dwfl.DwarfDie;
import lib.dwfl.Dwfl;
import lib.dwfl.DwflDie;
}
private LineXXX lineXXX;
- public void toPrint(PrintWriter writer, boolean printParameters,
- boolean fullpath){
+ public void toPrint(PrintWriter writer,
+ PrintDebugInfoStackOptions options) {
Function subprogram = this.getSubprogram();
-
if (subprogram != null) {
- writer.print("0x");
- String addr = Long.toHexString(this.getAddress());
- int padding = 2 * this.getTask().getISA().wordSize() - addr.length();
-
- for (int i = 0; i < padding; ++i)
- writer.print('0');
-
- writer.print(addr);
- writer.print(" in " + subprogram.getName() + "(");
- if (printParameters) {
- subprogram.printParameters(writer, this);
+ writer.write(ArchFormatter.toHexString(getTask(), getAddress()));
+ writer.print(" in ");
+ writer.print(subprogram.getName());
+ writer.print("(");
+ if (options.printParameters()) {
+ subprogram.printParameters(writer, this, options.printValues());
}
- writer.print(") ");
-
- if (fullpath) {
+ writer.print(") at ");
+ if (options.printFullPaths()) {
SourceLocation line = this.getLine();
writer.print(line.getFile().getPath());
writer.print("#");
writer.print(line.getLine());
} else {
SourceLocation line = this.getLine();
- writer.print(".../"+line.getFile().getName());
+ writer.print(line.getFile().getName());
writer.print("#");
writer.print(line.getLine());
}
-
} else {
- super.toPrint(writer, true, fullpath);
+ super.toPrint(writer, options);
}
}
*/
public class DebugInfoStackFactory {
- public static final PrintStackOptions DEFAULT
- = new PrintStackOptions().setRich();
-
/**
* Create an ABI stack backtrace, make the simpler debug-info
* methods.
return innermostFrame;
}
- public static final void printTaskStackTrace (PrintWriter printWriter, Task task, PrintStackOptions options)
- {
- if (task != null){
- printWriter.println("Task #" + task.getTid());
- DebugInfoFrame frame = createDebugInfoStackTrace(task);
- printStackTrace(printWriter, frame, options);
- }
- printWriter.flush();
+ public static final void printTaskStackTrace(PrintWriter printWriter,
+ Task task,
+ PrintDebugInfoStackOptions options) {
+ if (task != null) {
+ printWriter.println("Task #" + task.getTid());
+ DebugInfoFrame frame = createDebugInfoStackTrace(task);
+ printStackTrace(printWriter, frame, options);
+ }
+ printWriter.flush();
}
- public static final void printVirtualTaskStackTrace (PrintWriter printWriter, Task task, PrintStackOptions options)
- {
- if (task != null){
- printWriter.println("Task #" + task.getTid());
- DebugInfoFrame frame = createVirtualStackTrace(task);
- printStackTrace(printWriter,frame, options);
- }
- printWriter.flush();
+ public static final void printVirtualTaskStackTrace(PrintWriter printWriter,
+ Task task,
+ PrintDebugInfoStackOptions options) {
+ if (task != null) {
+ printWriter.println("Task #" + task.getTid());
+ DebugInfoFrame frame = createVirtualStackTrace(task);
+ printStackTrace(printWriter,frame, options);
+ }
+ printWriter.flush();
}
public static void printStackTrace(PrintWriter writer,
DebugInfoFrame topFrame,
- PrintStackOptions options) {
+ PrintDebugInfoStackOptions options) {
int count = 0;
for (DebugInfoFrame frame = topFrame; frame != null;
frame.printLevel(writer);
writer.print(" ");
- frame.toPrint(writer, options.printParams(),
- options.printFullPaths());
+ frame.toPrint(writer, options);
writer.println();
if (options.printLocals()) {
frame.printScopes(writer);
package frysk.debuginfo;
-public class PrintStackOptions {
+import frysk.stack.PrintStackOptions;
- private int numberOfFrames = 10;
+public class PrintDebugInfoStackOptions extends PrintStackOptions {
- private boolean printFullPaths = false;
-
- private boolean printParams = false;
- private boolean printLocals = false;
- private boolean printLibraries = false;
- private boolean printInlineFunctions = false;
- private boolean printDebugNames = false;
-
- public PrintStackOptions() {
+ public PrintDebugInfoStackOptions() {
+ // Note, the super calls clear.
}
+ private boolean printParameters;
+ private boolean printLocals;
+ private boolean printInlineFunctions;
+ private boolean printDebugNames;
+ private boolean printValues;
+
/**
- * Set things up for a light-weight, or low-cost, back-trace by
- * limiting things to just the elf information.
+ * Clear all options.
*/
- public PrintStackOptions setLite() {
- printParams = false;
+ public void clear() {
+ super.clear();
+ printParameters = false;
printLocals = false;
- printLibraries = true;
printInlineFunctions = false;
- printDebugNames = true;
- return this;
+ printDebugNames = false;
+ printValues = false;
+ }
+
+ /**
+ * Set things up for a light-weight, or low-cost, back-trace by
+ * limiting things to just the elf information.
+ */
+ public void setLite() {
+ setAbi();
+ setPrintDebugNames(true);
}
/**
* Set things up for a rich, or detailed, back-trace by including
* inline frames and parameter information.
*/
- public PrintStackOptions setRich() {
- printParams = true;
- printLocals = true;
- printLibraries = true;
- printInlineFunctions = true;
- printDebugNames = true;
- return this;
+ public void setRich() {
+ setAbi();
+ setPrintParameters(true);
+ setPrintInlineFunctions(true);
+ setPrintDebugNames(true);
}
/**
- * Specify the number of frames to include in the back-trace, 0 to
- * include all frames.
+ * Print the parameter list (see also printValues).
*/
- public void setNumberOfFrames(int numberOfFrames) {
- this.numberOfFrames = numberOfFrames;
+ public boolean printParameters() {
+ return printParameters;
}
- public int numberOfFrames() {
- return numberOfFrames;
+ public void setPrintParameters(boolean printParameters) {
+ this.printParameters = printParameters;
}
- public void setPrintParams(boolean printParams) {
- this.printParams = printParams;
+ /**
+ * Print paramter and variable values (rather than just their
+ * names).
+ */
+ public boolean printValues() {
+ return printValues;
}
- public boolean printParams() {
- return printParams;
+ public void setPrintValues(boolean printValues) {
+ this.printValues = printValues;
}
- public void setPrintLocals(boolean printLocals) {
- this.printLocals = printLocals;
- }
+ /**
+ * Print the function's local variables.
+ */
public boolean printLocals() {
return printLocals;
}
-
- public void setPrintFullPaths(boolean printFullPaths) {
- this.printFullPaths = printFullPaths;
- }
- public boolean printFullPaths() {
- return printFullPaths;
+ public void setPrintLocals(boolean printLocals) {
+ this.printLocals = printLocals;
}
- public void setPrintLibraries(boolean printLibraries) {
- this.printLibraries = printLibraries;
- }
- public boolean printLibraries() {
- return printLibraries;
+ /**
+ * Print inline function instances.
+ */
+ public boolean printInlineFunctions() {
+ return printInlineFunctions;
}
-
public void setPrintInlineFunctions(boolean printInlineFunctions) {
this.printInlineFunctions = printInlineFunctions;
}
- public boolean printInlineFunctions() {
- return printInlineFunctions;
- }
- public void setPrintDebugNames(boolean printDebugNames) {
- this.printDebugNames = printDebugNames;
- }
+ /**
+ * Print function and variable names using debug, rather than ABI,
+ * information.
+ */
public boolean printDebugNames() {
return printDebugNames;
}
+ public void setPrintDebugNames(boolean printDebugNames) {
+ this.printDebugNames = printDebugNames;
+ }
- public boolean elfOnly() {
- return ! (printLocals || printInlineFunctions || printParams
+ public boolean abiOnly() {
+ return ! (printLocals
+ || printInlineFunctions
+ || printParameters
+ || printValues
|| printDebugNames);
}
-
}
import java.util.LinkedList;
import javax.naming.NameNotFoundException;
-
import lib.dwfl.DwTag;
import lib.dwfl.DwarfDie;
import lib.dwfl.Dwfl;
StringWriter stringWriter = new StringWriter();
DebugInfoFrame frame = DebugInfoStackFactory.createDebugInfoStackTrace(task);
- PrintStackOptions options = new PrintStackOptions();
+ PrintDebugInfoStackOptions options = new PrintDebugInfoStackOptions();
options.setNumberOfFrames(20);
- options.setPrintParams(true);
+ options.setPrintParameters(true);
options.setPrintLocals(true);
options.setPrintFullPaths(true);
DebugInfoStackFactory.printStackTrace(new PrintWriter(stringWriter),frame, options);
Task task = (new DaemonBlockedAtSignal("funit-stack-inlined" + ext)).getMainTask();
StringWriter stringWriter = new StringWriter();
- PrintStackOptions options = new PrintStackOptions();
+ PrintDebugInfoStackOptions options = new PrintDebugInfoStackOptions();
options.setNumberOfFrames(0);
- options.setPrintParams(true);
+ options.setPrintParameters(true);
options.setPrintLocals(true);
options.setPrintFullPaths(true);
DebugInfoStackFactory.printVirtualTaskStackTrace(new PrintWriter(stringWriter), task, options);
Task task = (new DaemonBlockedAtSignal("funit-stack-inlined")).getMainTask();
- PrintStackOptions options = new PrintStackOptions();
+ PrintDebugInfoStackOptions options = new PrintDebugInfoStackOptions();
options.setNumberOfFrames(0);
- options.setPrintParams(true);
+ options.setPrintParameters(true);
options.setPrintLocals(true);
options.setPrintFullPaths(true);
super(inner, decorated);
}
- public void toPrint(PrintWriter writer, boolean printParameters,
- boolean fullpath) {
- super.toPrint(writer, printParameters, fullpath);
+ public void toPrint(PrintWriter writer,
+ PrintDebugInfoStackOptions options) {
+ super.toPrint(writer, options);
writer.print(" [inline]");
}
+2008-06-10 Andrew Cagney <cagney@redhat.com>
+
+ * Ftrace.java: Use PrintDebugInfoStackOptions.
+ * Reporter.java: Ditto.
+
2008-06-05 Petr Machata <pmachata@redhat.com>
* Ftrace.java: Fix race in attaching various task observers.
import inua.util.PrintWriter;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.dwfl.ObjectFile;
import frysk.event.Event;
import frysk.isa.signals.Signal;
static private final Log finest = LogFactory.finest(Ftrace.class);
static private final Log warning = LogFactory.warning(Ftrace.class);
- private final PrintStackOptions stackPrintOptions;
+ private final PrintDebugInfoStackOptions stackPrintOptions;
- public Ftrace(PrintStackOptions stackPrintOptions) {
+ public Ftrace(PrintDebugInfoStackOptions stackPrintOptions) {
this.stackPrintOptions = stackPrintOptions;
}
import inua.util.PrintWriter;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.proc.Task;
import frysk.util.ArchFormatter;
import frysk.util.StackPrintUtil;
private Object lastItem = null;
private Task lastTask = null;
private HashMap levelMap = new HashMap();
- private final PrintStackOptions stackPrintOptions;
+ private final PrintDebugInfoStackOptions stackPrintOptions;
private final boolean showPC;
- public Reporter(PrintWriter writer, PrintStackOptions stackPrintOptions, boolean show) {
+ public Reporter(PrintWriter writer,
+ PrintDebugInfoStackOptions stackPrintOptions,
+ boolean show) {
this.writer = writer;
this.stackPrintOptions = stackPrintOptions;
this.showPC = show;
// This file is part of the program FRYSK.
//
-// Copyright 2005, 2006, 2007 Red Hat Inc.
+// Copyright 2005, 2006, 2007, 2008 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
import java.util.Iterator;
import java.util.List;
-
import frysk.debuginfo.DebugInfoFrame;
import frysk.debuginfo.DebugInfoStackFactory;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.proc.Task;
abstract class StackCommands extends ParameterizedCommand {
static private void printStack(CLI cli, DebugInfoFrame frame,
int stopLevel, Options options) {
- PrintStackOptions printStackOptions = new PrintStackOptions();
+ PrintDebugInfoStackOptions printStackOptions
+ = new PrintDebugInfoStackOptions();
printStackOptions.setNumberOfFrames(stopLevel);
- printStackOptions.setPrintParams(true);
+ printStackOptions.setPrintParameters(true);
printStackOptions.setPrintLocals(options.printLocals);
printStackOptions.setPrintFullPaths(true);
+2008-06-10 Andrew Cagney <cagney@redhat.com>
+
+ * TestLinuxCore.java: Use PrintDebugInfoStackOptions.
+
2008-06-04 Andrew Cagney <cagney@redhat.com>
* LinuxCoreInfo.java (constructAuxv): Eliminate use of
import lib.dwfl.DwflModule;
import lib.dwfl.SymbolBuilder;
import frysk.config.Prefix;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.dwfl.DwflCache;
import frysk.event.Event;
import frysk.event.RequestStopEvent;
// relative -> absolute converstion is occuring.
StacktraceAction coreStacktrace;
StringWriter coreStackOutput = new StringWriter();
- PrintStackOptions options = new PrintStackOptions();
+ PrintDebugInfoStackOptions options = new PrintDebugInfoStackOptions();
options.setNumberOfFrames(20);
// Create a stackktrace of a the corefile process
StacktraceAction coreStacktrace;
StringWriter liveStackOutput = new StringWriter();
StringWriter coreStackOutput = new StringWriter();
- PrintStackOptions options = new PrintStackOptions();
+ PrintDebugInfoStackOptions options = new PrintDebugInfoStackOptions();
options.setNumberOfFrames(20);
// Create a Stacktrace of the blocked live process
assertEquals("Compare stack traces",
liveStackOutput.getBuffer().toString(),
coreStackOutput.getBuffer().toString());
-
}
private static class PrintEvent implements Event
+2008-06-10 Andrew Cagney <cagney@redhat.com>
+
+ * Function.java (printParameters): Add boolean printValues
+ parameter.
+
2008-06-06 Andrew Cagney <cagney@redhat.com>
* TestScopeFactory.java: Let DwflDie adjust for bias.
}
- public void printParameters (PrintWriter writer, DebugInfoFrame frame)
- {
-
- Iterator iterator = this.parameters.iterator();
- while(iterator.hasNext()) {
- Variable parameter = (Variable) iterator.next();
- parameter.toPrint(writer, frame);
- writer.flush();
- if(parameters.indexOf(parameter) < (this.parameters.size()-1)){
- writer.print(",");
- }
- }
-
+ public void printParameters(PrintWriter writer, DebugInfoFrame frame,
+ boolean printValues) {
+ Iterator iterator = this.parameters.iterator();
+ while(iterator.hasNext()) {
+ Variable parameter = (Variable) iterator.next();
+ parameter.toPrint(writer, frame);
+ writer.flush();
+ if(parameters.indexOf(parameter) < (this.parameters.size()-1)){
+ writer.print(",");
+ }
+ }
}
}
+2008-06-10 Andrew Cagney <cagney@redhat.com>
+
+ * Frame.java (toPrint(PrintWriter,PrintStackOptions)): Replace
+ toPrint(PrintWriter,boolean,boolean).
+ (toPrint(PrintWriter)): Delete.
+ * PrintStackOptions.java: New.
+ * StackFactory.java: Use.
+
2008-06-03 Andrew Cagney <cagney@redhat.com>
* TestFrame.java: Use DwflModule.getModules() and not
import lib.dwfl.Dwfl;
import lib.dwfl.DwflModule;
import frysk.dwfl.DwflCache;
-import frysk.dwfl.DwflFactory;
import frysk.isa.registers.Register;
import frysk.proc.Task;
import frysk.rsl.Log;
* Write a simple string representation of this stack frame.
* @param printWriter
*/
- public void toPrint (PrintWriter writer) {
- toPrint(writer, true, true);
- }
-
- /**
- * Write a simple string representation of this stack frame.
- * @param printWriter
- */
- public void toPrint (PrintWriter writer, boolean printSource, boolean fullpath) {
+ public void toPrint(PrintWriter writer, PrintStackOptions options) {
writer.write(ArchFormatter.toHexString(getTask(), getAddress()));
// the symbol, if known append (), ..
Symbol symbol = getSymbol();
writer.write(symbol.getDemangledName());
if (symbol != SymbolFactory.UNKNOWN)
writer.write(" ()");
-
- if(printSource){
+ if (options.printLibraryNames()){
// the library if known ...
- File library = new File(getLibraryName());
+ String library = getLibraryName();
+ System.err.println("library: " + library);
if (library != null) {
writer.print(" from ");
-
- if(DwflFactory.isVDSO(this.getTask().getProc(), this.getTask().getProc().getMap(getAdjustedAddress()))
- || library.getName().contains("[stack]")){
- writer.print(library.getName());
- }else{
-
- if(fullpath){
- writer.print(library.getPath());
- }else{
- writer.print(".../"+library.getName());
+ if (library.startsWith("[")) {
+ // Things like [vdso], [stack], ...
+ writer.print(library);
+ } else {
+ // Should there be separate libraryFullPath?
+ if (options.printFullPaths()) {
+ writer.print(library);
+ } else {
+ // Discard the path
+ writer.print(new File(library).getName());
}
}
if (dwflModule != null) {
return dwflModule.getName();
} else {
- return "Unknown";
+ return null;
}
}
PrintWriter pw = new PrintWriter(sw);
pw.print(this.getClass().getName());
pw.print('[');
- toPrint(pw, false, false);
+ toPrint(pw, PrintStackOptions.DEFAULT);
pw.print(']');
pw.flush();
return sw.toString();
--- /dev/null
+// This file is part of the program FRYSK.
+//
+// Copyright 2007, 2008, 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.stack;
+
+public class PrintStackOptions {
+
+ static final PrintStackOptions DEFAULT = new PrintStackOptions();
+
+ private int numberOfFrames = 10;
+
+ private boolean printFullPaths;
+ private boolean printLibraryNames;
+
+ public PrintStackOptions() {
+ clear();
+ }
+
+ /**
+ * Clear all stack options, a very raw ABI stack trace will be
+ * produced.
+ */
+ public void clear() {
+ printFullPaths = false;
+ printLibraryNames = false;
+ }
+
+ /**
+ * Generate an ABI backtrace using ELF symbols and shared library
+ * names.
+ */
+ public void setAbi() {
+ clear();
+ printFullPaths = false;
+ printLibraryNames = true;
+ }
+
+ /**
+ * Specify the number of frames to include in the back-trace, 0 to
+ * include all frames.
+ */
+ public void setNumberOfFrames(int numberOfFrames) {
+ this.numberOfFrames = numberOfFrames;
+ }
+ public int numberOfFrames() {
+ return numberOfFrames;
+ }
+
+ public void setPrintFullPaths(boolean printFullPaths) {
+ this.printFullPaths = printFullPaths;
+ }
+ public boolean printFullPaths() {
+ return printFullPaths;
+ }
+
+ public void setPrintLibraryNames(boolean printLibraryNames) {
+ this.printLibraryNames = printLibraryNames;
+ }
+ public boolean printLibraryNames() {
+ return printLibraryNames;
+ }
+
+ public boolean abiOnly() {
+ return true;
+ }
+
+}
import java.util.WeakHashMap;
import lib.unwind.Cursor;
-import frysk.debuginfo.PrintStackOptions;
import frysk.proc.Task;
public class StackFactory
}
public static final void printTaskStackTrace(PrintWriter writer,
- Task task, PrintStackOptions options) {
+ Task task,
+ PrintStackOptions options) {
if (task != null) {
writer.print("Task #");
writer.print(task.getTid());
writer.println();
Frame frame = StackFactory.createFrame(task);
for (int i = 0; frame != null; frame = frame.getOuter(),i++) {
-
- if (options.numberOfFrames() > 0 && i >= options.numberOfFrames()) {
+ if (options.numberOfFrames() > 0
+ && i >= options.numberOfFrames()) {
writer.println("...");
break;
+ } else if (options.numberOfFrames() < 0
+ && i >= -options.numberOfFrames()) {
+ break;
}
-
frame.printLevel(writer);
writer.print(" ");
- frame.toPrint(writer, options.printLibraries(),
- options.printFullPaths());
+ frame.toPrint(writer, options);
writer.println();
}
}
for (; frame != null; frame = frame.getOuter()) {
frame.printLevel(writer);
writer.print(" ");
- frame.toPrint(writer);
+ frame.toPrint(writer, PrintStackOptions.DEFAULT);
writer.println();
}
}
+2008-06-10 Andrew Cagney <cagney@redhat.com>
+
+ * TestStackTraceAction.java: Use PrintDebugInfoStackOptions.
+ * StackPrintUtil.java: Ditto.
+ * StacktraceAction.java: Ditto.
+ * FCatch.java: Ditto.
+ * StressTestStackTraceAction.java: Ditto.
+
2008-05-20 Andrew Cagney <cagney@redhat.com>
* CommandlineParser.java (isCoreFile(String))
import java.io.StringWriter;
import java.util.HashMap;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.isa.signals.Signal;
import frysk.proc.Action;
import frysk.proc.Task;
public class FCatch {
private static final Log fine = Log.fine(FCatch.class);
- private final PrintStackOptions stackPrintOptions = new PrintStackOptions();
+ private final PrintDebugInfoStackOptions stackPrintOptions
+ = new PrintDebugInfoStackOptions();
private PrintWriter printWriter = new PrintWriter(System.out);
HashMap signaledTasks = new HashMap();
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
/**
* Framework for printing stack backtraces; both providing a standard
* Create, in a separate group, the standard set of stack-print
* options provided by utilities.
*/
- public static OptionGroup options(final PrintStackOptions options) {
+ public static OptionGroup options(final PrintDebugInfoStackOptions options) {
+ // Set the default, which matches the documentation; and is
+ // consistent across all utilities.
+ options.setAbi();
OptionGroup group = new OptionGroup("Stack print options");
group.add(new Option("number-of-frames",
("number of frames to print. Specify '0' or"
group.add(new Option
("print", "select the back-trace information to display\n"
+ "OPTION is:\n"
- + "debug-names: use debug-info names (e.g., DWARF)\n"
+ + "debug-names: print debug-info names (e.g., DWARF)\n"
+ "full-path: include the full (untruncated) path to files\n"
+ "inline: include inlined frames\n"
- + "locals: include each functions local variables\n"
- + "params: include function parameters\n"
+ + "locals: include each function's local variables\n"
+ //+ "params: include function parameters\n"
+ + "values: include values of parameters and variables\n"
+ "OPTIONs can be negated by prefixing a '-'",
"OPTION,...") {
public void parsed(String arg) throws OptionException {
} else if (name.equals("locals")) {
options.setPrintLocals(val);
} else if (name.equals("params")) {
- options.setPrintParams(val);
+ options.setPrintParameters(val);
+ } else if (name.equals("values")) {
+ options.setPrintValues(val);
} else {
throw new OptionException
("unknown -print OPTION: " + name);
* Given a task, a writer, and the selected stack-print-options,
* produce a stack back-trace.
*/
- public static void print(Task task, PrintStackOptions options,
+ public static void print(Task task, PrintDebugInfoStackOptions options,
PrintWriter printWriter) {
- if (options.elfOnly()) {
+ if (options.abiOnly()) {
StackFactory.printTaskStackTrace(printWriter, task, options);
} else if (options.printInlineFunctions()) {
DebugInfoStackFactory.printVirtualTaskStackTrace(printWriter,
import java.util.TreeMap;
import frysk.rsl.Log;
import frysk.debuginfo.DebugInfoStackFactory;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.event.Event;
import frysk.event.RequestStopEvent;
import frysk.event.SignalEvent;
private Event event;
- PrintStackOptions options;
+ PrintDebugInfoStackOptions options;
/**
* Runs a stacktrace on the given process.
* file path is printed other wise only the name of the file is printed.
* @throws ProcException
*/
- public StacktraceAction (PrintWriter printWriter, Proc theProc, Event theEvent, PrintStackOptions options)
- {
- event = theEvent;
-
- this.options = options;
- this.printWriter = printWriter;
- Manager.eventLoop.add(new InterruptEvent(theProc));
- }
+ public StacktraceAction (PrintWriter printWriter, Proc theProc,
+ Event theEvent,
+ PrintDebugInfoStackOptions options) {
+ event = theEvent;
+ this.options = options;
+ this.printWriter = printWriter;
+ Manager.eventLoop.add(new InterruptEvent(theProc));
+ }
public final void existingTask (Task task)
{
"because", w);
}
- private final void printTasks ()
- {
- fine.log(this, "printTasks");
- Iterator iter = sortedTasks.values().iterator();
- while (iter.hasNext())
- {
- Task task = (Task) iter.next();
-
- if(options.elfOnly()){
- StackFactory.printTaskStackTrace(printWriter,task,options);
- }else{
- if(options.printInlineFunctions()){
- DebugInfoStackFactory.printVirtualTaskStackTrace(printWriter,task,options);
- }else{
- DebugInfoStackFactory.printTaskStackTrace(printWriter,task,options);
- }
+ private final void printTasks() {
+ fine.log(this, "printTasks");
+ Iterator iter = sortedTasks.values().iterator();
+ while (iter.hasNext()) {
+ Task task = (Task) iter.next();
+
+ if (options.abiOnly()) {
+ StackFactory.printTaskStackTrace(printWriter,task,options);
+ } else {
+ if (options.printInlineFunctions()) {
+ DebugInfoStackFactory
+ .printVirtualTaskStackTrace(printWriter,task,options);
+ } else {
+ DebugInfoStackFactory
+ .printTaskStackTrace(printWriter, task, options);
+ }
}
- printWriter.println();
- }
- fine.log(this, "exiting printTasks");
- }
+ printWriter.println();
+ }
+ fine.log(this, "exiting printTasks");
+ }
public void flush(){
this.printWriter.flush();
import java.io.PrintWriter;
import java.io.StringWriter;
import frysk.rsl.Log;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.event.Event;
import frysk.event.RequestStopEvent;
import frysk.proc.Manager;
FunitThreadsOffspring ackProc = new FunitThreadsOffspring(threads);
final Proc proc = ackProc.assertRunToFindProc();
- PrintStackOptions options = new PrintStackOptions();
+ PrintDebugInfoStackOptions options = new PrintDebugInfoStackOptions();
options.setNumberOfFrames(20);
- options.setPrintParams(true);
+ options.setPrintParameters(true);
StacktraceAction stacker = new StacktraceAction(new PrintWriter(stringWriter),proc, new Event()
{
import java.io.PrintWriter;
import java.io.StringWriter;
import frysk.rsl.Log;
-import frysk.debuginfo.PrintStackOptions;
+import frysk.debuginfo.PrintDebugInfoStackOptions;
import frysk.event.RequestStopEvent;
import frysk.proc.Manager;
import frysk.proc.Proc;
static void multiThreaded(SlaveOffspring ackProc,
int numSecondaryThreads) {
- PrintStackOptions options = new PrintStackOptions();
+ PrintDebugInfoStackOptions options = new PrintDebugInfoStackOptions();
options.setNumberOfFrames(20);
options.setPrintFullPaths(true);
- options.setPrintLibraries(true);
+ options.setPrintLibraryNames(true);
StringWriter stringWriter = new StringWriter();