1 /* longjmp-free interface between gdb and gdbtk.
2 Copyright (C) 1999 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #include "gdbtk-wrapper.h"
26 * Wrapper functions exported to the world
29 gdb_result GDB_value_fetch_lazy
PARAMS ((value_ptr
));
31 gdb_result GDB_evaluate_expression
PARAMS ((struct expression
*, value_ptr
*));
33 gdb_result GDB_type_print
PARAMS ((value_ptr
, char *, GDB_FILE
*, int));
35 gdb_result GDB_val_print
PARAMS ((struct type
*type
, char *valaddr
,
36 CORE_ADDR address
, GDB_FILE
*stream
,
37 int format
, int deref_ref
, int recurse
,
38 enum val_prettyprint pretty
));
40 gdb_result GDB_select_frame
PARAMS ((struct frame_info
*, int));
42 gdb_result GDB_value_equal
PARAMS ((value_ptr
, value_ptr
, int *));
44 gdb_result GDB_parse_exp_1
PARAMS ((char **stringptr
, struct block
*block
, int comma
,
45 struct expression
**result
));
47 gdb_result GDB_evaluate_type
PARAMS ((struct expression
*exp
, value_ptr
*result
));
49 gdb_result GDB_block_for_pc
PARAMS ((CORE_ADDR pc
, struct block
**result
));
51 gdb_result GDB_block_innermost_frame
PARAMS ((struct block
*block
,
52 struct frame_info
**result
));
54 gdb_result GDB_reinit_frame_cache
PARAMS ((void));
56 gdb_result GDB_find_frame_addr_in_frame_chain
PARAMS ((CORE_ADDR addr
,
57 struct frame_info
**result
));
60 * Private functions for this file
62 static gdb_result call_wrapped_function
PARAMS ((catch_errors_ftype
*,
63 struct gdb_wrapper_arguments
*));
65 static int wrap_type_print
PARAMS ((char *));
67 static int wrap_evaluate_expression
PARAMS ((char *));
69 static int wrap_value_fetch_lazy
PARAMS ((char *));
71 static int wrap_val_print
PARAMS ((char*));
73 static int wrap_select_frame
PARAMS ((char *));
75 static int wrap_value_equal
PARAMS ((char *));
77 static int wrap_parse_exp_1
PARAMS ((char *opaque_arg
));
79 static int wrap_evaluate_type
PARAMS ((char *opaque_arg
));
81 static int wrap_block_for_pc
PARAMS ((char *opaque_arg
));
83 static int wrap_block_innermost_frame
PARAMS ((char *opaque_arg
));
85 static int wrap_reinit_frame_cache
PARAMS ((char *opaque_arg
));
87 static int wrap_find_frame_addr_in_frame_chain
PARAMS ((char *opaque_arg
));
90 call_wrapped_function (fn
, arg
)
91 catch_errors_ftype
*fn
;
92 struct gdb_wrapper_arguments
*arg
;
94 if (!catch_errors (fn
, (char *) &arg
, "", RETURN_MASK_ERROR
))
96 /* An error occurred */
104 GDB_type_print (val
, varstring
, stream
, show
)
110 struct gdb_wrapper_arguments args
;
112 args
.args
[0] = (char *) val
;
113 args
.args
[1] = varstring
;
114 args
.args
[2] = (char *) stream
;
115 args
.args
[3] = (char *) show
;
116 return call_wrapped_function ((catch_errors_ftype
*) wrap_type_print
, &args
);
123 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) a
;
124 value_ptr val
= (value_ptr
) (*args
)->args
[0];
125 char *varstring
= (*args
)->args
[1];
126 GDB_FILE
*stream
= (GDB_FILE
*) (*args
)->args
[2];
127 int show
= (int) (*args
)->args
[3];
128 type_print (VALUE_TYPE (val
), varstring
, stream
, show
);
133 GDB_val_print (type
, valaddr
, address
, stream
, format
, deref_ref
,
142 enum val_prettyprint pretty
;
144 struct gdb_wrapper_arguments args
;
146 args
.args
[0] = (char *) type
;
147 args
.args
[1] = (char *) valaddr
;
148 args
.args
[2] = (char *) address
;
149 args
.args
[3] = (char *) stream
;
150 args
.args
[4] = (char *) format
;
151 args
.args
[5] = (char *) deref_ref
;
152 args
.args
[6] = (char *) recurse
;
153 args
.args
[7] = (char *) pretty
;
155 return call_wrapped_function ((catch_errors_ftype
*) wrap_val_print
, &args
);
162 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) a
;
170 enum val_prettyprint pretty
;
172 type
= (struct type
*) (*args
)->args
[0];
173 valaddr
= (char *) (*args
)->args
[1];
174 address
= (CORE_ADDR
) (*args
)->args
[2];
175 stream
= (GDB_FILE
*) (*args
)->args
[3];
176 format
= (int) (*args
)->args
[4];
177 deref_ref
= (int) (*args
)->args
[5];
178 recurse
= (int) (*args
)->args
[6];
179 pretty
= (enum val_prettyprint
) (*args
)->args
[7];
181 val_print (type
, valaddr
, 0, address
, stream
, format
, deref_ref
,
187 GDB_value_fetch_lazy (value
)
190 struct gdb_wrapper_arguments args
;
192 args
.args
[0] = (char *) value
;
193 return call_wrapped_function ((catch_errors_ftype
*) wrap_value_fetch_lazy
, &args
);
197 wrap_value_fetch_lazy (a
)
200 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) a
;
202 value_fetch_lazy ((value_ptr
) (*args
)->args
[0]);
207 GDB_evaluate_expression (exp
, value
)
208 struct expression
*exp
;
211 struct gdb_wrapper_arguments args
;
213 args
.args
[0] = (char *) exp
;
215 result
= call_wrapped_function ((catch_errors_ftype
*) wrap_evaluate_expression
, &args
);
216 if (result
!= GDB_OK
)
219 *value
= (value_ptr
) args
.result
;
224 wrap_evaluate_expression (a
)
227 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) a
;
230 (char *) evaluate_expression ((struct expression
*) (*args
)->args
[0]);
235 GDB_select_frame (fi
, level
)
236 struct frame_info
*fi
;
239 struct gdb_wrapper_arguments args
;
241 args
.args
[0] = (char *) fi
;
242 args
.args
[1] = (char *) &level
;
244 return call_wrapped_function ((catch_errors_ftype
*) wrap_select_frame
, &args
);
248 wrap_select_frame (a
)
251 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) a
;
252 int level
= * (int *) (*args
)->args
[1];
253 struct frame_info
*fi
= (struct frame_info
*) (*args
)->args
[0];
255 select_frame (fi
, level
);
260 GDB_value_equal (val1
, val2
, result
)
265 struct gdb_wrapper_arguments args
;
268 args
.args
[0] = (char *) val1
;
269 args
.args
[1] = (char *) val2
;
271 r
= call_wrapped_function ((catch_errors_ftype
*) wrap_value_equal
, &args
);
275 *result
= (int) args
.result
;
283 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) a
;
284 value_ptr val1
, val2
;
286 val1
= (value_ptr
) (*args
)->args
[0];
287 val2
= (value_ptr
) (*args
)->args
[1];
289 (*args
)->result
= (char *) value_equal (val1
, val2
);
294 GDB_parse_exp_1 (stringptr
, block
, comma
, result
)
298 struct expression
**result
;
300 struct gdb_wrapper_arguments args
;
303 args
.args
[0] = (char *) stringptr
;
304 args
.args
[1] = (char *) block
;
305 args
.args
[2] = (char *) comma
;
307 r
= call_wrapped_function ((catch_errors_ftype
*) wrap_parse_exp_1
, &args
);
311 *result
= (struct expression
*) args
.result
;
316 wrap_parse_exp_1 (opaque_arg
)
319 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) opaque_arg
;
324 stringptr
= (char **) (*args
)->args
[0];
325 block
= (struct block
*) (*args
)->args
[1];
326 comma
= (int) (*args
)->args
[2];
328 (*args
)->result
= (char *) parse_exp_1 (stringptr
, block
, comma
);
333 GDB_evaluate_type (exp
, result
)
334 struct expression
*exp
;
337 struct gdb_wrapper_arguments args
;
340 args
.args
[0] = (char *) exp
;
342 r
= call_wrapped_function ((catch_errors_ftype
*) wrap_evaluate_type
, &args
);
346 *result
= (value_ptr
) args
.result
;
351 wrap_evaluate_type (opaque_arg
)
354 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) opaque_arg
;
355 struct expression
*exp
;
357 exp
= (struct expression
*) (*args
)->args
[0];
358 (*args
)->result
= (char *) evaluate_type (exp
);
363 GDB_block_for_pc (pc
, result
)
365 struct block
**result
;
367 struct gdb_wrapper_arguments args
;
370 args
.args
[0] = (char *) pc
;
372 r
= call_wrapped_function ((catch_errors_ftype
*) wrap_block_for_pc
, &args
);
376 *result
= (struct block
*) args
.result
;
381 wrap_block_for_pc (opaque_arg
)
384 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) opaque_arg
;
387 pc
= (CORE_ADDR
) (*args
)->args
[0];
388 (*args
)->result
= (char *) block_for_pc (pc
);
393 GDB_block_innermost_frame (block
, result
)
395 struct frame_info
**result
;
397 struct gdb_wrapper_arguments args
;
400 args
.args
[0] = (char *) block
;
402 r
= call_wrapped_function ((catch_errors_ftype
*) wrap_block_innermost_frame
, &args
);
406 *result
= (struct frame_info
*) args
.result
;
411 wrap_block_innermost_frame (opaque_arg
)
414 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) opaque_arg
;
417 block
= (struct block
*) (*args
)->args
[0];
418 (*args
)->result
= (char *) block_innermost_frame (block
);
423 GDB_reinit_frame_cache ()
427 r
= call_wrapped_function ((catch_errors_ftype
*) wrap_reinit_frame_cache
, NULL
);
435 wrap_reinit_frame_cache (opaque_arg
)
438 reinit_frame_cache ();
443 GDB_find_frame_addr_in_frame_chain (addr
, result
)
445 struct frame_info
**result
;
447 struct gdb_wrapper_arguments args
;
450 args
.args
[0] = (char *) addr
;
452 r
= call_wrapped_function ((catch_errors_ftype
*) wrap_find_frame_addr_in_frame_chain
, &args
);
456 *result
= (struct frame_info
*) args
.result
;
461 wrap_find_frame_addr_in_frame_chain (opaque_arg
)
464 struct gdb_wrapper_arguments
**args
= (struct gdb_wrapper_arguments
**) opaque_arg
;
467 addr
= (CORE_ADDR
) (*args
)->args
[0];
468 (*args
)->result
= (char *) find_frame_addr_in_frame_chain (addr
);
473 /* Local variables: */
474 /* change-log-default-name: "ChangeLog-gdbtk" */