From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23189 invoked by alias); 24 Mar 2008 20:10:15 -0000 Received: (qmail 23154 invoked by uid 440); 24 Mar 2008 20:10:11 -0000 Date: Mon, 24 Mar 2008 20:10:00 -0000 Message-ID: <20080324201011.23135.qmail@sourceware.org> From: scox@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Improve list -length support. X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 4fef9765b59a925c333c1c1c53091e789857b6a9 X-Git-Newrev: 85c95cef4f9c593478eae091cfd4230895da8687 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2008-q1/txt/msg00421.txt.bz2 The branch, master has been updated via 85c95cef4f9c593478eae091cfd4230895da8687 (commit) from 4fef9765b59a925c333c1c1c53091e789857b6a9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 85c95cef4f9c593478eae091cfd4230895da8687 Author: Stan Cox Date: Mon Mar 24 16:07:13 2008 -0400 Improve list -length support. * ListCommand.java (listOneTask): New. Refactored from interpret. (parseFunctionName): Likewise. (interpret): Use listOneTask and parseFunctionName. * TestListCommand.java (testListReverse): Test 'list -length' around PC. * TestSysRoot.java (testHaveSysRoot()): Reactivate. * dwfl_module_getdwarf.c (load_symtab): Keep looking for an external symbol table even if we have a .dynsym. Should be fixed post 0.133. ----------------------------------------------------------------------- Summary of changes: frysk-core/frysk/hpd/ChangeLog | 8 + frysk-core/frysk/hpd/ListCommand.java | 242 ++++++++++--------- frysk-core/frysk/hpd/TestListCommand.java | 12 +- frysk-core/frysk/hpd/TestSysRoot.java | 2 - frysk-imports/elfutils/libdwfl/ChangeLog | 5 + .../elfutils/libdwfl/dwfl_module_getdwarf.c | 8 +- 6 files changed, 153 insertions(+), 124 deletions(-) First 500 lines of diff: diff --git a/frysk-core/frysk/hpd/ChangeLog b/frysk-core/frysk/hpd/ChangeLog index 734d9cb..ef69eeb 100644 --- a/frysk-core/frysk/hpd/ChangeLog +++ b/frysk-core/frysk/hpd/ChangeLog @@ -1,3 +1,11 @@ +2008-03-24 Stan Cox + + * ListCommand.java (listOneTask): New. Refactored from interpret. + (parseFunctionName): Likewise. + (interpret): Use listOneTask and parseFunctionName. + * TestListCommand.java (testListReverse): Test 'list -length' around PC. + * TestSysRoot.java (testHaveSysRoot()): Reactivate. + 2008-03-20 Andrew Cagney * StartRun.java: Use ProcTasksAction and ProcTasksObserver. diff --git a/frysk-core/frysk/hpd/ListCommand.java b/frysk-core/frysk/hpd/ListCommand.java index d4e417e..8c7355a 100644 --- a/frysk-core/frysk/hpd/ListCommand.java +++ b/frysk-core/frysk/hpd/ListCommand.java @@ -94,133 +94,145 @@ class ListCommand extends ParameterizedCommand { Options options = (Options)o; PTSet ptset = cli.getCommandPTSet(cmd); int windowSize = 20; + boolean adjust_line = true; + Iterator taskIter = ptset.getTaskData(); while (taskIter.hasNext()) { TaskData taskData = (TaskData)taskIter.next(); - Task task = taskData.getTask(); - cli.outWriter.print("["); - cli.outWriter.print(taskData.getParentID()); - cli.outWriter.print("."); - cli.outWriter.print(taskData.getID()); - cli.outWriter.println("]"); - DebugInfoFrame frame = cli.getTaskFrame(task); - if (frame.getLine() == SourceLocation.UNKNOWN) { - cli.outWriter.println("No symbol table is available."); - continue; + exec_line = cli.getTaskFrame(taskData.getTask()).getLine().getLine(); + if (cmd.size() == 0) + // default to list around PC + line = exec_line; + else if (cmd.size() == 1) { + try { + line = Integer.parseInt(cmd.parameter(0)); + } + catch (NumberFormatException ignore) { + line = parseFunctionName(cmd.parameter(0), file, cli, taskData); + adjust_line = false; + } } - if (cmd.size() == 1) { - // list N - try { - line = Integer.parseInt(cmd.parameter(0)); - } - catch (NumberFormatException ignore) { - if ((cmd.parameter(0)).compareTo("$EXEC") == 0) - line = frame.getLine().getLine() - (windowSize / 2); - else { - DwarfDie funcDie = null; - DebugInfo debugInfo = cli.getTaskDebugInfo(task); - if (debugInfo != null) { - funcDie = debugInfo - .getSymbolDie(cmd.parameter(0)); - } - if (funcDie.getTag().hashCode() == DwTag.SUBPROGRAM_) { - DwflLine dwflLine = DwflCache.getDwfl(frame.getTask()) - .getSourceLine(frame.getAdjustedAddress()); - if (dwflLine != null) { - SysRoot sysRoot = new SysRoot(SysRootCache.getSysRoot(frame.getTask())); - file = sysRoot.getSourcePathViaSysRoot - (new File(dwflLine.getCompilationDir()), - funcDie.getDeclFile()).getSysRootedFile(); - } - else - file = funcDie.getDeclFile(); - line = (int)funcDie.getDeclLine(); - } - else { - cli.addMessage("function " + cmd.parameter(0) + " not found.", - Message.TYPE_ERROR); - return; - } - } - } + if (options.length != null) { + windowSize = options.length.magnitude; } - else if (options.length != null) { - windowSize = options.length.magnitude; - if (options.length.sign < 0) { - windowSize *= -1; - line += windowSize; + + if (adjust_line) + line = line - (windowSize / 2); + listOneTask(cli, cmd, taskData, windowSize); + } + } + + int completer(CLI cli, Input input, int cursor, List candidates) { + return -1; + } + + private void listOneTask (CLI cli, Input cmd, TaskData taskData, int windowSize) { + Task task = taskData.getTask(); + cli.outWriter.print("["); + cli.outWriter.print(taskData.getParentID()); + cli.outWriter.print("."); + cli.outWriter.print(taskData.getID()); + cli.outWriter.println("]"); + DebugInfoFrame frame = cli.getTaskFrame(task); + if (frame.getLine() == SourceLocation.UNKNOWN) { + cli.outWriter.println("No symbol table is available."); + return; + } + if (cmd.size() == 1) { + } + + if (file == null || frame != currentFrame) { + if (frame.getLine() != SourceLocation.UNKNOWN) { + file = (frame.getLine()).getFile(); + if (file == null) { + cli.addMessage("No symbol table is available.", + Message.TYPE_NORMAL); + return; } + line = (frame.getLine()).getLine() - (windowSize / 2); + currentFrame = frame; + if (exec_line == 0) + exec_line = line; } - else if (frame.getLine().getLine() != exec_line) { - // list around pc. - exec_line = frame.getLine().getLine(); - line = exec_line - (windowSize / 2); - } - - if (file == null || frame != currentFrame) { - if (frame.getLine() != SourceLocation.UNKNOWN) { - file = (frame.getLine()).getFile(); - if (file == null) { - cli.addMessage("No symbol table is available.", - Message.TYPE_NORMAL); - return; - } - line = (frame.getLine()).getLine() - (windowSize / 2); - currentFrame = frame; - if (exec_line == 0) - exec_line = line; - } - else { - cli.outWriter.println("No source for current frame"); - return; - } - } - - if (line < 0) - line = 1; - try { - FileReader fr = new FileReader(file); - LineNumberReader lr = new LineNumberReader(fr); - String str; - boolean display = false; - int endLine = line + StrictMath.abs(windowSize); - String flag = ""; - while ((str = lr.readLine()) != null) { - if (lr.getLineNumber() == line) - display = true; - else if (lr.getLineNumber() == endLine) - break; - if (display && lr.getLineNumber() == exec_line) - flag = "->"; + else { + cli.outWriter.println("No source for current frame"); + return; + } + } + + if (line < 0) + line = 1; + try { + FileReader fr = new FileReader(file); + LineNumberReader lr = new LineNumberReader(fr); + String str; + boolean display = false; + int endLine = line + StrictMath.abs(windowSize); + String flag = ""; + while ((str = lr.readLine()) != null) { + if (lr.getLineNumber() == line) + display = true; + else if (lr.getLineNumber() == endLine) + break; + if (display && lr.getLineNumber() == exec_line) + flag = "->"; else flag = " "; - if (display) { - int lineNumber = lr.getLineNumber(); - String rightAdjust; - if (lineNumber < 10) - rightAdjust = " "; - else if (lineNumber < 100) - rightAdjust = " "; - else if (lineNumber < 1000) - rightAdjust = " "; - else - rightAdjust = ""; - cli.outWriter.println(flag + rightAdjust + lineNumber + "\t "+ str); - flag = ""; - } - } - lr.close(); - } - catch (IOException e) { - cli.addMessage("file " + file + " not found.", - Message.TYPE_ERROR); - } + if (display) { + int lineNumber = lr.getLineNumber(); + String rightAdjust; + if (lineNumber < 10) + rightAdjust = " "; + else if (lineNumber < 100) + rightAdjust = " "; + else if (lineNumber < 1000) + rightAdjust = " "; + else + rightAdjust = ""; + cli.outWriter.println(flag + rightAdjust + lineNumber + "\t "+ str); + flag = ""; + } + } + lr.close(); + } + catch (IOException e) { + cli.addMessage("file " + file + " not found.", + Message.TYPE_ERROR); } - } + + private int parseFunctionName (String cmdParm, File file, CLI cli, TaskData taskData) { + Task task = taskData.getTask(); + DebugInfoFrame frame = cli.getTaskFrame(task); - int completer(CLI cli, Input input, int cursor, List candidates) { - return -1; + if ((cmdParm).compareTo("$EXEC") == 0) + return frame.getLine().getLine(); + else { + DwarfDie funcDie = null; + DebugInfo debugInfo = cli.getTaskDebugInfo(task); + if (debugInfo != null) { + funcDie = debugInfo + .getSymbolDie(cmdParm); + } + if (funcDie.getTag().hashCode() == DwTag.SUBPROGRAM_) { + DwflLine dwflLine = DwflCache.getDwfl(frame.getTask()) + .getSourceLine(frame.getAdjustedAddress()); + if (dwflLine != null) { + SysRoot sysRoot = new SysRoot(SysRootCache.getSysRoot(frame.getTask())); + file = sysRoot.getSourcePathViaSysRoot + (new File(dwflLine.getCompilationDir()), + funcDie.getDeclFile()).getSysRootedFile(); + } + else + file = funcDie.getDeclFile(); + return (int)funcDie.getDeclLine(); + } + else { + cli.addMessage("function " + cmdParm + " not found.", + Message.TYPE_ERROR); + return line; + } + } } } diff --git a/frysk-core/frysk/hpd/TestListCommand.java b/frysk-core/frysk/hpd/TestListCommand.java index e048c6d..8051e8f 100644 --- a/frysk-core/frysk/hpd/TestListCommand.java +++ b/frysk-core/frysk/hpd/TestListCommand.java @@ -112,7 +112,7 @@ public class TestListCommand extends TestLib { e.expect("68.*68"); e.expect("69.*69.*while"); e.expect("70.*70.*if"); - e.send("list 71 -length 10\n"); + e.send("list 76 -length 10\n"); e.expect("71.*71.*quicksort"); e.expect("72.*72.*if"); e.expect("73.*73 .*quicksort"); @@ -136,9 +136,11 @@ public class TestListCommand extends TestLib { e.sendCommandExpectPrompt("break main", "breakpoint.*"); e.send("go\n"); e.expect("go.*\n" + prompt + "Breakpoint"); - e.send("list\n"); - e.expect(prompt); - e.send("list 78 -length -10\n"); + e.send("list -length 3\n"); + e.expect("97.*97"); + e.expect("-> 98.*98.*init_array"); + e.expect("99.*99.*quicksort"); + e.send("list 83 -length -10\n"); e.expect("78.*78"); e.expect("79.*79"); e.expect("80.*80.*unsigned int seed"); @@ -149,7 +151,7 @@ public class TestListCommand extends TestLib { e.expect("85.*85.*if"); e.expect("86.*86.*biggest"); e.expect("87.*87.*else if"); - e.send("list 68 -length -10\n"); + e.send("list 73 -length -10\n"); e.expect("68.*68"); e.expect("69.*69.*while"); e.expect("70.*70"); diff --git a/frysk-core/frysk/hpd/TestSysRoot.java b/frysk-core/frysk/hpd/TestSysRoot.java index cd0e685..3d37aab 100644 --- a/frysk-core/frysk/hpd/TestSysRoot.java +++ b/frysk-core/frysk/hpd/TestSysRoot.java @@ -53,8 +53,6 @@ public class TestSysRoot extends TestLib { } public void testHaveSysRoot() { - if (unresolved(5953)) - return; File testSysRootDir = Config.getPkgLibFile("test-sysroot"); File testPath = Config.getPkgLibFile("funit-addresses"); e.sendCommandExpectPrompt("load " diff --git a/frysk-imports/elfutils/libdwfl/ChangeLog b/frysk-imports/elfutils/libdwfl/ChangeLog index bad1f9e..30272d1 100644 --- a/frysk-imports/elfutils/libdwfl/ChangeLog +++ b/frysk-imports/elfutils/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2008-03-24 Stan Cox + + * dwfl_module_getdwarf.c (load_symtab): Keep looking for an external + symbol table even if we have a .dynsym. Should be fixed post 0.133. + 2008-03-13 Tim Moore * dwfl_module_addrsym.c (dwfl_module_addrsym): Start min_label diff --git a/frysk-imports/elfutils/libdwfl/dwfl_module_getdwarf.c b/frysk-imports/elfutils/libdwfl/dwfl_module_getdwarf.c index 7dd9b53..4044514 100644 --- a/frysk-imports/elfutils/libdwfl/dwfl_module_getdwarf.c +++ b/frysk-imports/elfutils/libdwfl/dwfl_module_getdwarf.c @@ -218,6 +218,7 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile, Elf_Scn **symscn, Elf_Scn **xndxscn, size_t *syments, GElf_Word *strshndx) { + bool symtab = false; Elf_Scn *scn = NULL; while ((scn = elf_nextscn (file->elf, scn)) != NULL) { @@ -226,6 +227,7 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile, switch (shdr->sh_type) { case SHT_SYMTAB: + symtab = true; *symscn = scn; *symfile = file; *strshndx = shdr->sh_link; @@ -235,6 +237,8 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile, break; case SHT_DYNSYM: + if (symtab) + break; /* Use this if need be, but keep looking for SHT_SYMTAB. */ *symscn = scn; *symfile = file; @@ -244,7 +248,7 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile, case SHT_SYMTAB_SHNDX: *xndxscn = scn; - if (*symscn != NULL) + if (symtab) return DWFL_E_NOERROR; break; @@ -253,7 +257,7 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile, } } - if (*symscn != NULL) + if (symtab) /* We found one, though no SHT_SYMTAB_SHNDX to go with it. */ return DWFL_E_NOERROR; hooks/post-receive -- frysk system monitor/debugger