This is the mail archive of the gdb-patches@sources.redhat.com 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 for gdb/mi 796


This patch is an extension of 680 whereby more ui_out_tuple_begin and
ui_out_list_begin statements are switched over to use the new make_cleanup....
equivalents.

Since I do not have a test case, I will leave it up to the originator to
verify if the patch does in fact fix the problem.

gdb/ChangeLog:

2002-10-11  Jeff Johnston  <jjohnstn@redhat.com>

	* disasm.c (dump_insns, do_mixed_source_and_assembly): Change uiout tuples
	and lists to use make_cleanup_ui_out_tuple_begin_end,
	make_cleanup_ui_out_list_begin_end respectively, and do_cleanups.
	This is a fix for PR gdb/796.
	(do_assembly_only): Ditto.
	* thread.c (do_captured_list_thread_ids): Ditto.

Is this ok to commit?

-- Jeff J.
Index: disasm.c
===================================================================
RCS file: /cvs/src/src/gdb/disasm.c,v
retrieving revision 1.1
diff -u -r1.1 disasm.c
--- disasm.c	30 Sep 2002 15:57:25 -0000	1.1
+++ disasm.c	11 Oct 2002 22:04:29 -0000
@@ -89,6 +89,7 @@
 {
   int num_displayed = 0;
   CORE_ADDR pc;
+  struct cleanup *cleanup_tuple;
 
   /* parts of the symbolic representation of the address */
   int unmapped;
@@ -107,7 +108,7 @@
 	  else
 	    num_displayed++;
 	}
-      ui_out_tuple_begin (uiout, NULL);
+      cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
       ui_out_field_core_addr (uiout, "address", pc);
 
       if (!build_address_symbolic (pc, 0, &name, &offset, &filename,
@@ -130,7 +131,7 @@
       pc += TARGET_PRINT_INSN (pc, di);
       ui_out_field_stream (uiout, "inst", stb);
       ui_file_rewind (stb->stream);
-      ui_out_tuple_end (uiout);
+      do_cleanups (cleanup_tuple);
       ui_out_text (uiout, "\n");
     }
   return num_displayed;
@@ -152,6 +153,9 @@
   struct dis_line_entry *mle;
   struct symtab_and_line sal;
   int i;
+  struct cleanup *cleanup_list_1;
+  struct cleanup *cleanup_list_2 = NULL;
+  struct cleanup *cleanup_tuple = NULL;
   int out_of_order = 0;
   int next_line = 0;
   CORE_ADDR pc;
@@ -209,7 +213,7 @@
      they have been emitted before), followed by the assembly code
      for that line.  */
 
-  ui_out_list_begin (uiout, "asm_insns");
+  cleanup_list_1 = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns");
 
   for (i = 0; i < newlines; i++)
     {
@@ -222,7 +226,8 @@
 	      /* Just one line to print. */
 	      if (next_line == mle[i].line)
 		{
-		  ui_out_tuple_begin (uiout, "src_and_asm_line");
+		  cleanup_tuple = 
+		    make_cleanup_ui_out_tuple_begin_end (uiout, "src_and_asm_line");
 		  print_source_lines (symtab, next_line, mle[i].line + 1, 0);
 		}
 	      else
@@ -230,27 +235,32 @@
 		  /* Several source lines w/o asm instructions associated. */
 		  for (; next_line < mle[i].line; next_line++)
 		    {
-		      ui_out_tuple_begin (uiout, "src_and_asm_line");
+		      cleanup_tuple =
+		        make_cleanup_ui_out_tuple_begin_end (uiout, "src_and_asm_line");
 		      print_source_lines (symtab, next_line, next_line + 1,
 					  0);
-		      ui_out_list_begin (uiout, "line_asm_insn");
-		      ui_out_list_end (uiout);
-		      ui_out_tuple_end (uiout);
+		      cleanup_list_2 =
+		        make_cleanup_ui_out_list_begin_end (uiout, "line_asm_insn");
+		      do_cleanups (cleanup_list_2);
+		      do_cleanups (cleanup_tuple);
 		    }
 		  /* Print the last line and leave list open for
 		     asm instructions to be added. */
-		  ui_out_tuple_begin (uiout, "src_and_asm_line");
+		  cleanup_tuple =
+		    make_cleanup_ui_out_tuple_begin_end (uiout, "src_and_asm_line");
 		  print_source_lines (symtab, next_line, mle[i].line + 1, 0);
 		}
 	    }
 	  else
 	    {
-	      ui_out_tuple_begin (uiout, "src_and_asm_line");
+	      cleanup_tuple =
+	        make_cleanup_ui_out_tuple_begin_end (uiout, "src_and_asm_line");
 	      print_source_lines (symtab, mle[i].line, mle[i].line + 1, 0);
 	    }
 
 	  next_line = mle[i].line + 1;
-	  ui_out_list_begin (uiout, "line_asm_insn");
+	  cleanup_list_2 = 
+            make_cleanup_ui_out_list_begin_end (uiout, "line_asm_insn");
 	  /* Don't close the list if the lines are not in order. */
 	  if (i < (newlines - 1) && mle[i + 1].line <= mle[i].line)
 	    close_list = 0;
@@ -260,8 +270,8 @@
 				   how_many, stb);
       if (close_list)
 	{
-	  ui_out_list_end (uiout);
-	  ui_out_tuple_end (uiout);
+	  do_cleanups (cleanup_list_2);
+	  do_cleanups (cleanup_tuple);
 	  ui_out_text (uiout, "\n");
 	  close_list = 0;
 	}
@@ -269,7 +279,7 @@
 	if (num_displayed >= how_many)
 	  break;
     }
-  ui_out_list_end (uiout);
+  do_cleanups (cleanup_list_1);
 }
 
 
@@ -278,13 +288,14 @@
 		  CORE_ADDR low, CORE_ADDR high,
 		  int how_many, struct ui_stream *stb)
 {
+  struct cleanup *cleanup_list;
   int num_displayed = 0;
 
-  ui_out_list_begin (uiout, "asm_insns");
+  cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns");
 
   num_displayed = dump_insns (uiout, di, low, high, how_many, stb);
 
-  ui_out_list_end (uiout);
+  do_cleanups (cleanup_list);
 }
 
 void
Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.23
diff -u -r1.23 thread.c
--- thread.c	2 Aug 2002 20:51:21 -0000	1.23
+++ thread.c	11 Oct 2002 22:04:30 -0000
@@ -260,9 +260,10 @@
 			     void *arg)
 {
   struct thread_info *tp;
+  struct cleanup *cleanup_tuple;
   int num = 0;
 
-  ui_out_tuple_begin (uiout, "thread-ids");
+  cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, "thread-ids");
 
   for (tp = thread_list; tp; tp = tp->next)
     {
@@ -270,7 +271,7 @@
       ui_out_field_int (uiout, "thread-id", tp->num);
     }
 
-  ui_out_tuple_end (uiout);
+  do_cleanups (cleanup_tuple);
   ui_out_field_int (uiout, "number-of-threads", num);
   return GDB_RC_OK;
 }

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