public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Correctly check error returned by dwarf_get_scopevar.
@ 2008-06-16 12:08 cagney
  0 siblings, 0 replies; only message in thread
From: cagney @ 2008-06-16 12:08 UTC (permalink / raw)
  To: frysk-cvs

The branch, master has been updated
       via  8168d6edcf7a58fc490b9a4d37647b3576345334 (commit)
      from  a9c05fad829ce6b638eadeb1c93a44e71c4dd457 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 8168d6edcf7a58fc490b9a4d37647b3576345334
Author: Andrew Cagney <cagney@redhat.com>
Date:   Mon Jun 16 08:07:47 2008 -0400

    Correctly check error returned by dwarf_get_scopevar.
    
    frysk-core/frysk/debuginfo/ChangeLog
    2008-06-15  Andrew Cagney  <cagney@redhat.com>
    
    	* gen-type-expect-tests.py (open_file): Use assert, not if/println
    	to detect and report bad values.
    
    frysk-sys/lib/dwfl/ChangeLog
    2008-06-15  Andrew Cagney  <cagney@redhat.com>
    
    	* DwarfDie.java (get_scopevar): Return an int.
    	* jni/DwarfDie.cxx (DwarfDie::get_scopevar): Only examine the die
    	when its valid.
    	* cni/DwarfDie.cxx (DwarfDie::get_scopevar): Ditto.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/debuginfo/ChangeLog               |    5 +++
 .../frysk/debuginfo/gen-type-expect-tests.py       |   15 +-------
 frysk-sys/lib/dwfl/ChangeLog                       |    7 ++++
 frysk-sys/lib/dwfl/DwarfDie.java                   |    3 +-
 frysk-sys/lib/dwfl/cni/DwarfDie.cxx                |   37 +++++++++-----------
 frysk-sys/lib/dwfl/jni/DwarfDie.cxx                |    6 ++--
 6 files changed, 36 insertions(+), 37 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/debuginfo/ChangeLog b/frysk-core/frysk/debuginfo/ChangeLog
index d7fe563..37736fc 100644
--- a/frysk-core/frysk/debuginfo/ChangeLog
+++ b/frysk-core/frysk/debuginfo/ChangeLog
@@ -1,3 +1,8 @@
+2008-06-15  Andrew Cagney  <cagney@redhat.com>
+
+	* gen-type-expect-tests.py (open_file): Use assert, not if/println
+	to detect and report bad values.
+
 2008-06-12  Andrew Cagney  <cagney@redhat.com>
 
 	* ObjectDeclarationNotFoundException.java: Extend
diff --git a/frysk-core/frysk/debuginfo/gen-type-expect-tests.py b/frysk-core/frysk/debuginfo/gen-type-expect-tests.py
index c8513c4..0daf18a 100644
--- a/frysk-core/frysk/debuginfo/gen-type-expect-tests.py
+++ b/frysk-core/frysk/debuginfo/gen-type-expect-tests.py
@@ -94,15 +94,10 @@ public class %s extends TestLib {
         print('''
 	void checkType(String symbol, String expected) {
 	    Type varType;
-
 	    DwarfDie varDie = biasDie.getScopeVar(allDies, symbol);
-	    if (varDie == null)
-		System.out.println("Error: Cannot find " + symbol);
-	    assertNotNull(varDie);
+            assertNotNull("die for variable " + symbol, varDie);
 	    varType = typeFactory.getType(varDie.getType());
 	    assertNotNull(varType);
-	    // System.out.println("Expect: " + symbol + "\\n'" +
-	    //    expected + "'\\nGot:\\n'" + varType.toPrint());
 	    assertEquals(testName + symbol, expected, varType.toPrint());
 	}
 
@@ -115,19 +110,13 @@ public class %s extends TestLib {
 		|| expected.length() == 0)
 		return;
 	    DwarfDie varDie = biasDie.getScopeVar(allDies, symbol);
-	    if (varDie == null)
-		System.out.println("Error: Cannot find " + symbol);
-	    assertNotNull(varDie);
+            assertNotNull("die for variable " + symbol, varDie);
 	    DebugInfo debugInfo = new DebugInfo(frame);
 	    Value value =  debugInfo.print(symbol, frame);
 	    value.toPrint(pw, task.getMemory(), Format.NATURAL, 0);
 	    pw.flush();
 	    String valueString = baos.toString();
-	    // System.out.println("Expect: " + symbol +
-	    //     "\\n'" + expected + "'\\nGot:\\n'" +
-	    //     valueString + "'" + " " + value.getType());
 	    assertEquals(testName + symbol, expected, valueString);
-	    baos.reset();
 	}
     }
 ''')
diff --git a/frysk-sys/lib/dwfl/ChangeLog b/frysk-sys/lib/dwfl/ChangeLog
index aa96035..c44bebe 100644
--- a/frysk-sys/lib/dwfl/ChangeLog
+++ b/frysk-sys/lib/dwfl/ChangeLog
@@ -1,3 +1,10 @@
+2008-06-15  Andrew Cagney  <cagney@redhat.com>
+
+	* DwarfDie.java (get_scopevar): Return an int.
+	* jni/DwarfDie.cxx (DwarfDie::get_scopevar): Only examine the die
+	when its valid.
+	* cni/DwarfDie.cxx (DwarfDie::get_scopevar): Ditto.
+
 2008-06-12  Andrew Cagney  <cagney@redhat.com>
 
 	* ElfException.java: Extend UserException.
diff --git a/frysk-sys/lib/dwfl/DwarfDie.java b/frysk-sys/lib/dwfl/DwarfDie.java
index dda1671..bc2d24b 100644
--- a/frysk-sys/lib/dwfl/DwarfDie.java
+++ b/frysk-sys/lib/dwfl/DwarfDie.java
@@ -476,7 +476,8 @@ public class DwarfDie {
 
     private native long[] get_scopes_die ();
 
-    private native long get_scopevar (long[] die_scope, long[] scopes, String variable);
+    private native int get_scopevar(long[] die_scope, long[] scopes,
+				    String variable);
 
     private native long get_scopevar_names (long[] scopes, String variable);
   
diff --git a/frysk-sys/lib/dwfl/cni/DwarfDie.cxx b/frysk-sys/lib/dwfl/cni/DwarfDie.cxx
index c562d2e..b10689d 100644
--- a/frysk-sys/lib/dwfl/cni/DwarfDie.cxx
+++ b/frysk-sys/lib/dwfl/cni/DwarfDie.cxx
@@ -1,6 +1,6 @@
 // This file is part of the program FRYSK.
 //
-// Copyright 2005, 2007, Red Hat Inc.
+// Copyright 2005, 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
@@ -165,10 +165,9 @@ lib::dwfl::DwarfDie::get_scopes_die()
 
 Dwarf_Die *var_die;
 
-jlong
-lib::dwfl::DwarfDie::get_scopevar (jlongArray die_scope, jlongArray scopes,
-				 jstring variable)
-{
+jint
+lib::dwfl::DwarfDie::get_scopevar(jlongArray die_scope, jlongArray scopes,
+				 jstring variable) {
   
   var_die = (Dwarf_Die*)JvMalloc(sizeof(Dwarf_Die));
   int nscopes = JvGetArrayLength (scopes);
@@ -176,11 +175,10 @@ lib::dwfl::DwarfDie::get_scopevar (jlongArray die_scope, jlongArray scopes,
   Dwarf_Die *dies[nscopes];
   jlong* scopesp = elements(scopes);
 
-  for(int i = 0; i < nscopes; i++)
-    {
-      jlong dieptr = scopesp[i];
-      dies[i] = (Dwarf_Die*)dieptr;
-    }
+  for(int i = 0; i < nscopes; i++) {
+    jlong dieptr = scopesp[i];
+    dies[i] = (Dwarf_Die*)dieptr;
+  }
   
   int utf_variable_len = variable->length ();
   char utf_variable[utf_variable_len + 1];
@@ -190,16 +188,15 @@ lib::dwfl::DwarfDie::get_scopevar (jlongArray die_scope, jlongArray scopes,
   int code = dwarf_getscopevar (*dies, nscopes,
 				utf_variable,
 				0, NULL, 0, 0, var_die);
-  if (code >= 0)
-    {
-      if (dwarf_tag (var_die) != DW_TAG_variable)
-	return -1;
-      jlong* longp = elements(die_scope);
-      longp[0] = (jlong)var_die;    // Die for variable
-      longp[1] = code; // Die for scope
-    }
-  else if (dwarf_tag (var_die) != DW_TAG_variable)
-    return -1;
+  if (code >= 0) {
+    if (dwarf_tag(var_die) != DW_TAG_variable)
+      return -1;
+    jlong* longp = elements(die_scope);
+    longp[0] = (jlong)var_die;    // Die for variable
+    longp[1] = code; // Die for scope
+  } else {
+    ::free(var_die);
+  }
   return code;
 }
 
diff --git a/frysk-sys/lib/dwfl/jni/DwarfDie.cxx b/frysk-sys/lib/dwfl/jni/DwarfDie.cxx
index 0935d19..0da40c1 100644
--- a/frysk-sys/lib/dwfl/jni/DwarfDie.cxx
+++ b/frysk-sys/lib/dwfl/jni/DwarfDie.cxx
@@ -148,7 +148,7 @@ lib::dwfl::DwarfDie::get_scopes_die(jnixx::env env) {
   return longs;
 }
 
-jlong
+jint
 lib::dwfl::DwarfDie::get_scopevar(jnixx::env env, jnixx::jlongArray jdie_scope,
 				  jnixx::jlongArray jscopes, String jvariable) {
   // FIXME: This appears to be leaked?
@@ -169,8 +169,8 @@ lib::dwfl::DwarfDie::get_scopevar(jnixx::env env, jnixx::jlongArray jdie_scope,
     jlongArrayElements die_scope = jlongArrayElements(env, jdie_scope);
     die_scope.elements()[0] = (jlong)var_die;    // Die for variable
     die_scope.elements()[1] = code; // Die for scope
-  } else if (dwarf_tag (var_die) != DW_TAG_variable) {
-    return -1;
+  } else {
+    ::free(var_die);
   }
   return code;
 }


hooks/post-receive
--
frysk system monitor/debugger


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-16 12:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-16 12:08 [SCM] master: Correctly check error returned by dwarf_get_scopevar cagney

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).