[patch] Cleanup free_agent_expr cleanup

Andrew Cagney ac131313@cygnus.com
Sun May 14 23:16:00 GMT 2000


FYI,

Yet another one.

	Andrew
Mon May 15 16:05:46 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* ax.h (make_cleanup_free_agent_expr): Add declaration.
	* ax-general.c (do_free_agent_expr_cleanup): 
	(make_cleanup_free_agent_expr): New functions.

	* tracepoint.c (validate_actionline, encode_actions), ax-gdb.c
 	(expr_to_agent, gen_trace_for_expr, agent_command): Replace calls
 	to make_cleanup.

Index: ax-gdb.c
===================================================================
RCS file: /cvs/src/src/gdb/ax-gdb.c,v
retrieving revision 1.3
diff -p -r1.3 ax-gdb.c
*** ax-gdb.c	2000/04/26 12:41:47	1.3
--- ax-gdb.c	2000/05/15 06:12:26
*************** expr_to_agent (expr, value)
*** 1798,1804 ****
    struct agent_expr *ax = new_agent_expr (0);
    union exp_element *pc;
  
!   old_chain = make_cleanup ((make_cleanup_func) free_agent_expr, ax);
  
    pc = expr->elts;
    trace_kludge = 0;
--- 1798,1804 ----
    struct agent_expr *ax = new_agent_expr (0);
    union exp_element *pc;
  
!   old_chain = make_cleanup_free_agent_expr (ax);
  
    pc = expr->elts;
    trace_kludge = 0;
*************** gen_trace_for_expr (scope, expr)
*** 1854,1860 ****
    union exp_element *pc;
    struct axs_value value;
  
!   old_chain = make_cleanup ((make_cleanup_func) free_agent_expr, ax);
  
    pc = expr->elts;
    trace_kludge = 1;
--- 1854,1860 ----
    union exp_element *pc;
    struct axs_value value;
  
!   old_chain = make_cleanup_free_agent_expr (ax);
  
    pc = expr->elts;
    trace_kludge = 1;
*************** agent_command (exp, from_tty)
*** 1925,1931 ****
    expr = parse_expression (exp);
    old_chain = make_cleanup (free_current_contents, &expr);
    agent = gen_trace_for_expr (fi->pc, expr);
!   make_cleanup ((make_cleanup_func) free_agent_expr, agent);
    ax_print (gdb_stdout, agent);
  
    /* It would be nice to call ax_reqs here to gather some general info
--- 1925,1931 ----
    expr = parse_expression (exp);
    old_chain = make_cleanup (free_current_contents, &expr);
    agent = gen_trace_for_expr (fi->pc, expr);
!   make_cleanup_free_agent_expr (agent);
    ax_print (gdb_stdout, agent);
  
    /* It would be nice to call ax_reqs here to gather some general info
Index: ax-general.c
===================================================================
RCS file: /cvs/src/src/gdb/ax-general.c,v
retrieving revision 1.1.1.5
diff -p -r1.1.1.5 ax-general.c
*** ax-general.c	2000/02/02 00:21:04	1.1.1.5
--- ax-general.c	2000/05/15 06:12:26
*************** free_agent_expr (x)
*** 62,67 ****
--- 62,79 ----
    free (x);
  }
  
+ static void
+ do_free_agent_expr_cleanup (void *x)
+ {
+   free_agent_expr (x);
+ }
+ 
+ struct cleanup *
+ make_cleanup_free_agent_expr (struct agent_expr *x)
+ {
+   return make_cleanup (do_free_agent_expr_cleanup, x);
+ }
+ 
  
  /* Make sure that X has room for at least N more bytes.  This doesn't
     affect the length, just the allocated size.  */
Index: ax.h
===================================================================
RCS file: /cvs/src/src/gdb/ax.h,v
retrieving revision 1.1.1.4
diff -p -r1.1.1.4 ax.h
*** ax.h	2000/02/02 00:21:04	1.1.1.4
--- ax.h	2000/05/15 06:12:28
*************** extern struct agent_expr *new_agent_expr
*** 143,148 ****
--- 143,149 ----
  
  /* Free a agent expression.  */
  extern void free_agent_expr PARAMS ((struct agent_expr *));
+ extern struct cleanup *make_cleanup_free_agent_expr (struct agent_expr *);
  
  /* Append a simple operator OP to EXPR.  */
  extern void ax_simple PARAMS ((struct agent_expr * EXPR, enum agent_op OP));
Index: tracepoint.c
===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.3
diff -p -r1.3 tracepoint.c
*** tracepoint.c	2000/04/26 12:41:48	1.3
--- tracepoint.c	2000/05/15 06:12:33
*************** validate_actionline (line, t)
*** 999,1005 ****
  	  /* we have something to collect, make sure that the expr to
  	     bytecode translator can handle it and that it's not too long */
  	  aexpr = gen_trace_for_expr (t->address, exp);
! 	  (void) make_cleanup ((make_cleanup_func) free_agent_expr, aexpr);
  
  	  if (aexpr->len > MAX_AGENT_EXPR_LEN)
  	    error ("expression too complicated, try simplifying");
--- 999,1005 ----
  	  /* we have something to collect, make sure that the expr to
  	     bytecode translator can handle it and that it's not too long */
  	  aexpr = gen_trace_for_expr (t->address, exp);
! 	  make_cleanup_free_agent_expr (aexpr);
  
  	  if (aexpr->len > MAX_AGENT_EXPR_LEN)
  	    error ("expression too complicated, try simplifying");
*************** encode_actions (t, tdp_actions, stepping
*** 1617,1624 ****
  		    default:	/* full-fledged expression */
  		      aexpr = gen_trace_for_expr (t->address, exp);
  
! 		      old_chain1 = make_cleanup ((make_cleanup_func)
! 						 free_agent_expr, aexpr);
  
  		      ax_reqs (aexpr, &areqs);
  		      if (areqs.flaw != agent_flaw_none)
--- 1617,1623 ----
  		    default:	/* full-fledged expression */
  		      aexpr = gen_trace_for_expr (t->address, exp);
  
! 		      old_chain1 = make_cleanup_free_agent_expr (aexpr);
  
  		      ax_reqs (aexpr, &areqs);
  		      if (areqs.flaw != agent_flaw_none)


More information about the Gdb-patches mailing list