This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix debug printing of TYPE_INSTANCE


Hi,

dependency on:
	[patch] Fix debug printing of OP_* names
	http://sourceware.org/ml/gdb-patches/2011-01/msg00531.html

before patch:

echo 'void f(int i,long j){}main(){}'|gcc -x c - -g; ./gdb -nx -ex 'set debug expr 1' ./a.out -ex 'p f(int,long)' 

Dump of expression @ 0x25e48d0, before conversion to prefix form:
        Language c, 10 elements, 16 bytes each.
        Index                Opcode         Hex Value  String Value
            0          OP_VAR_VALUE  43  +...............
            1               OP_NULL  0  ................
            2    <unknown 39917504>  39917504  ..a.............
            3          OP_VAR_VALUE  43  +...............
            4         TYPE_INSTANCE  29  ................
            5             BINOP_SUB  2  ................
            6    <unknown 39917248>  39917248  ..a.............
            7    <unknown 39830000>  39830000  .._.............
            8             BINOP_SUB  2  ................
            9         TYPE_INSTANCE  29  ................
Dump of expression @ 0x2a4b570, after conversion to prefix form:
Expression: `Invalid expression
(gdb)

after patch:

[...]       
            9         TYPE_INSTANCE  29  ................
Dump of expression @ 0x25e48d0, after conversion to prefix form:
Expression: `TypesInstance(int,long,f)'
        Language c, 10 elements, 16 bytes each.
            0  TYPE_INSTANCE         2 TypeInstance: Type @0x26116c0 (int), Type @0x25fc1f0 (long)
            6    OP_VAR_VALUE          Block @0x0, symbol @0x26117c0 (f)
$1 = {void (int, long int)} 0x400474 <f>


I will check it in after the patch above, debug dumps are not a big issue.


Thanks,
Jan


gdb/
2011-01-29  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Support `set debug expression' also for TYPE_INSTANCE.
	* expprint.c (print_subexp_standard) <TYPE_INSTANCE>: New.
	(dump_subexp_body_standard) <TYPE_INSTANCE>: New.

--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -534,6 +534,27 @@ print_subexp_standard (struct expression *exp, int *pos,
       fprintf_unfiltered (stream, ")");
       return;
 
+    case TYPE_INSTANCE:
+      {
+	LONGEST count = exp->elts[pc + 1].longconst;
+
+	/* The COUNT.  */
+	(*pos)++;
+	fputs_unfiltered ("TypesInstance(", stream);
+	while (count-- > 0)
+	  {
+	    type_print (exp->elts[(*pos)++].type, "", stream, 0);
+	    if (count > 0)
+	      fputs_unfiltered (",", stream);
+	  }
+	fputs_unfiltered (",", stream);
+	/* Ending COUNT and ending TYPE_INSTANCE.  */
+	(*pos) += 2;
+	print_subexp (exp, pos, stream, PREC_PREFIX);
+	fputs_unfiltered (")", stream);
+	return;
+      }
+
       /* Default ops */
 
     default:
@@ -937,6 +958,29 @@ dump_subexp_body_standard (struct expression *exp,
 	elt += 4 + BYTES_TO_EXP_ELEM (len + 1);
       }
       break;
+    case TYPE_INSTANCE:
+      {
+	char *elem_name;
+	LONGEST len;
+
+	len = exp->elts[elt++].longconst;
+	fprintf_filtered (stream, "%s TypeInstance: ", plongest (len));
+	while (len-- > 0)
+	  {
+	    fprintf_filtered (stream, "Type @");
+	    gdb_print_host_address (exp->elts[elt].type, stream);
+	    fprintf_filtered (stream, " (");
+	    type_print (exp->elts[elt].type, NULL, stream, 0);
+	    fprintf_filtered (stream, ")");
+	    elt++;
+	    if (len > 0)
+	      fputs_filtered (", ", stream);
+	  }
+	/* Ending LEN and ending TYPE_INSTANCE.  */
+	elt += 2;
+	elt = dump_subexp (exp, stream, elt);
+      }
+      break;
     default:
     case OP_NULL:
     case MULTI_SUBSCRIPT:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]