public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
From: scox@sourceware.org
To: frysk-cvs@sourceware.org
Subject: [SCM]  master: Improve list -length support.
Date: Mon, 24 Mar 2008 20:10:00 -0000	[thread overview]
Message-ID: <20080324201011.23135.qmail@sourceware.org> (raw)

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 <scox@redhat.com>
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  <scox@redhat.com>
+
+	* 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  <cagney@redhat.com>
 
 	* 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  <scox@redhat.com>
+
+	* 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  <timoore@redhat.com>
 
 	* 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


                 reply	other threads:[~2008-03-24 20:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20080324201011.23135.qmail@sourceware.org \
    --to=scox@sourceware.org \
    --cc=frysk-cvs@sourceware.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).