93d948245339b1bd0001dc440b9f6b78abd4cf1e
[deliverable/binutils-gdb.git] / gdb / values.c
1 /* Low level packing and unpacking of values for GDB.
2 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
3
4 GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5 WARRANTY. No author or distributor accepts responsibility to anyone
6 for the consequences of using it or for whether it serves any
7 particular purpose or works at all, unless he says so in writing.
8 Refer to the GDB General Public License for full details.
9
10 Everyone is granted permission to copy, modify and redistribute GDB,
11 but only under the conditions described in the GDB General Public
12 License. A copy of this license is supposed to have been given to you
13 along with GDB so you can know your rights and responsibilities. It
14 should be in a file named COPYING. Among other things, the copyright
15 notice and this notice must be preserved on all copies.
16
17 In other words, go ahead and share GDB, but don't try to stop
18 anyone else from sharing it farther. Help stamp out software hoarding!
19 */
20
21 #include <stdio.h>
22 #include "defs.h"
23 #include "initialize.h"
24 #include "param.h"
25 #include "symtab.h"
26 #include "value.h"
27
28 /* The value-history records all the values printed
29 by print commands during this session. Each chunk
30 records 60 consecutive values. The first chunk on
31 the chain records the most recent values.
32 The total number of values is in value_history_count. */
33
34 #define VALUE_HISTORY_CHUNK 60
35
36 struct value_history_chunk
37 {
38 struct value_history_chunk *next;
39 value values[VALUE_HISTORY_CHUNK];
40 };
41
42 /* Chain of chunks now in use. */
43
44 static struct value_history_chunk *value_history_chain;
45
46 static int value_history_count; /* Abs number of last entry stored */
47
48 START_FILE
49 \f
50 /* List of all value objects currently allocated
51 (except for those released by calls to release_value)
52 This is so they can be freed after each command. */
53
54 static value all_values;
55
56 /* Allocate a value that has the correct length for type TYPE. */
57
58 value
59 allocate_value (type)
60 struct type *type;
61 {
62 register value val;
63
64 val = (value) xmalloc (sizeof (struct value) + TYPE_LENGTH (type));
65 VALUE_NEXT (val) = all_values;
66 all_values = val;
67 VALUE_TYPE (val) = type;
68 VALUE_LVAL (val) = not_lval;
69 VALUE_ADDRESS (val) = 0;
70 VALUE_OFFSET (val) = 0;
71 VALUE_BITPOS (val) = 0;
72 VALUE_BITSIZE (val) = 0;
73 VALUE_REPEATED (val) = 0;
74 VALUE_REPETITIONS (val) = 0;
75 VALUE_REGNO (val) = -1;
76 return val;
77 }
78
79 /* Allocate a value that has the correct length
80 for COUNT repetitions type TYPE. */
81
82 value
83 allocate_repeat_value (type, count)
84 struct type *type;
85 int count;
86 {
87 register value val;
88
89 val = (value) xmalloc (sizeof (struct value) + TYPE_LENGTH (type) * count);
90 VALUE_NEXT (val) = all_values;
91 all_values = val;
92 VALUE_TYPE (val) = type;
93 VALUE_LVAL (val) = not_lval;
94 VALUE_ADDRESS (val) = 0;
95 VALUE_OFFSET (val) = 0;
96 VALUE_BITPOS (val) = 0;
97 VALUE_BITSIZE (val) = 0;
98 VALUE_REPEATED (val) = 1;
99 VALUE_REPETITIONS (val) = count;
100 VALUE_REGNO (val) = -1;
101 return val;
102 }
103
104 /* Free all the values that have been allocated (except for those released).
105 Called after each command, successful or not. */
106
107 void
108 free_all_values ()
109 {
110 register value val, next;
111
112 for (val = all_values; val; val = next)
113 {
114 next = VALUE_NEXT (val);
115 free (val);
116 }
117
118 all_values = 0;
119 }
120
121 /* Remove VAL from the chain all_values
122 so it will not be freed automatically. */
123
124 void
125 release_value (val)
126 register value val;
127 {
128 register value v;
129
130 if (all_values == val)
131 {
132 all_values = val->next;
133 return;
134 }
135
136 for (v = all_values; v; v = v->next)
137 {
138 if (v->next == val)
139 {
140 v->next = val->next;
141 break;
142 }
143 }
144 }
145
146 /* Return a copy of the value ARG.
147 It contains the same contents, for same memory address,
148 but it's a different block of storage. */
149
150 static value
151 value_copy (arg)
152 value arg;
153 {
154 register value val;
155 register struct type *type = VALUE_TYPE (arg);
156 if (VALUE_REPEATED (arg))
157 val = allocate_repeat_value (type, VALUE_REPETITIONS (arg));
158 else
159 val = allocate_value (type);
160 VALUE_LVAL (val) = VALUE_LVAL (arg);
161 VALUE_ADDRESS (val) = VALUE_ADDRESS (arg);
162 VALUE_OFFSET (val) = VALUE_OFFSET (arg);
163 VALUE_BITPOS (val) = VALUE_BITPOS (arg);
164 VALUE_BITSIZE (val) = VALUE_BITSIZE (arg);
165 VALUE_REGNO (val) = VALUE_REGNO (arg);
166 bcopy (VALUE_CONTENTS (arg), VALUE_CONTENTS (val),
167 TYPE_LENGTH (VALUE_TYPE (arg))
168 * (VALUE_REPEATED (arg) ? VALUE_REPETITIONS (arg) : 1));
169 return val;
170 }
171 \f
172 /* Access to the value history. */
173
174 /* Record a new value in the value history.
175 Returns the absolute history index of the entry. */
176
177 int
178 record_latest_value (val)
179 value val;
180 {
181 register int i;
182
183 /* Get error now if about to store an invalid float. */
184 if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FLT)
185 value_as_double (val);
186
187 /* Here we treat value_history_count as origin-zero
188 and applying to the value being stored now. */
189
190 i = value_history_count % VALUE_HISTORY_CHUNK;
191 if (i == 0)
192 {
193 register struct value_history_chunk *new
194 = (struct value_history_chunk *) xmalloc (sizeof (struct value_history_chunk));
195 bzero (new->values, sizeof new->values);
196 new->next = value_history_chain;
197 value_history_chain = new;
198 }
199
200 value_history_chain->values[i] = val;
201 release_value (val);
202
203 /* Now we regard value_history_count as origin-one
204 and applying to the value just stored. */
205
206 return ++value_history_count;
207 }
208
209 /* Return a copy of the value in the history with sequence number NUM. */
210
211 value
212 access_value_history (num)
213 int num;
214 {
215 register struct value_history_chunk *chunk;
216 register int i;
217 register int absnum = num;
218
219 if (absnum <= 0)
220 absnum += value_history_count;
221
222 if (absnum <= 0)
223 {
224 if (num == 0)
225 error ("The history is empty.");
226 else if (num == 1)
227 error ("There is only one value in the history.");
228 else
229 error ("History does not go back to $$%d.", -num);
230 }
231 if (absnum > value_history_count)
232 error ("History has not yet reached $%d.", absnum);
233
234 absnum--;
235
236 /* Now absnum is always absolute and origin zero. */
237
238 chunk = value_history_chain;
239 for (i = (value_history_count - 1) / VALUE_HISTORY_CHUNK - absnum / VALUE_HISTORY_CHUNK;
240 i > 0; i--)
241 chunk = chunk->next;
242
243 return value_copy (chunk->values[absnum % VALUE_HISTORY_CHUNK]);
244 }
245
246 /* Clear the value history entirely.
247 Must be done when new symbol tables are loaded,
248 because the type pointers become invalid. */
249
250 void
251 clear_value_history ()
252 {
253 register struct value_history_chunk *next;
254 register int i;
255 register value val;
256
257 while (value_history_chain)
258 {
259 for (i = 0; i < VALUE_HISTORY_CHUNK; i++)
260 if (val = value_history_chain->values[i])
261 free (val);
262 next = value_history_chain->next;
263 free (value_history_chain);
264 value_history_chain = next;
265 }
266 value_history_count = 0;
267 }
268
269 static void
270 history_info (num_exp)
271 char *num_exp;
272 {
273 register int i;
274 register value val;
275 register int num;
276
277 if (num_exp)
278 num = parse_and_eval_address (num_exp) - 5;
279 else
280 num = value_history_count - 9;
281
282 if (num <= 0)
283 num = 1;
284
285 for (i = num; i < num + 10 && i <= value_history_count; i++)
286 {
287 val = access_value_history (i);
288 printf ("$%d = ", i);
289 value_print (val, stdout);
290 printf ("\n");
291 }
292 }
293 \f
294 /* Internal variables. These are variables within the debugger
295 that hold values assigned by debugger commands.
296 The user refers to them with a '$' prefix
297 that does not appear in the variable names stored internally. */
298
299 static struct internalvar *internalvars;
300
301 /* Look up an internal variable with name NAME. NAME should not
302 normally include a dollar sign.
303
304 If the specified internal variable does not exist,
305 one is created, with a void value. */
306
307 struct internalvar *
308 lookup_internalvar (name)
309 char *name;
310 {
311 register struct internalvar *var;
312
313 for (var = internalvars; var; var = var->next)
314 if (!strcmp (var->name, name))
315 return var;
316
317 var = (struct internalvar *) xmalloc (sizeof (struct internalvar));
318 var->name = concat (name, "", "");
319 var->value = allocate_value (builtin_type_void);
320 release_value (var->value);
321 var->next = internalvars;
322 internalvars = var;
323 return var;
324 }
325
326 value
327 value_of_internalvar (var)
328 struct internalvar *var;
329 {
330 register value val = value_copy (var->value);
331 VALUE_LVAL (val) = lval_internalvar;
332 VALUE_INTERNALVAR (val) = var;
333 }
334
335 void
336 set_internalvar_component (var, offset, bitpos, bitsize, newval)
337 struct internalvar *var;
338 int offset, bitpos, bitsize;
339 value newval;
340 {
341 register char *addr = VALUE_CONTENTS (var->value) + offset;
342 if (bitsize)
343 modify_field (addr, value_as_long (newval),
344 bitpos, bitsize);
345 else
346 bcopy (VALUE_CONTENTS (newval), addr,
347 TYPE_LENGTH (VALUE_TYPE (newval)));
348 }
349
350 void
351 set_internalvar (var, val)
352 struct internalvar *var;
353 value val;
354 {
355 free (var->value);
356 var->value = value_copy (val);
357 release_value (var->value);
358 }
359
360 char *
361 internalvar_name (var)
362 struct internalvar *var;
363 {
364 return var->name;
365 }
366
367 /* Free all internalvars. Done when new symtabs are loaded,
368 because that makes the values invalid. */
369
370 void
371 clear_internalvars ()
372 {
373 register struct internalvar *var;
374
375 while (internalvars)
376 {
377 var = internalvars;
378 internalvars = var->next;
379 free (var->name);
380 free (var->value);
381 free (var);
382 }
383 }
384
385 static void
386 convenience_info ()
387 {
388 register struct internalvar *var;
389
390 if (internalvars)
391 printf ("Debugger convenience variables:\n\n");
392 else
393 printf ("No debugger convenience variables now defined.\n\
394 Convenience variables have names starting with \"$\";\n\
395 use \"set\" as in \"set $foo = 5\" to define them.\n");
396
397 for (var = internalvars; var; var = var->next)
398 {
399 printf ("$%s: ", var->name);
400 value_print (var->value, stdout);
401 printf ("\n");
402 }
403 }
404 \f
405 /* Extract a value as a C number (either long or double).
406 Knows how to convert fixed values to double, or
407 floating values to long.
408 Does not deallocate the value. */
409
410 long
411 value_as_long (val)
412 register value val;
413 {
414 return unpack_long (VALUE_TYPE (val), VALUE_CONTENTS (val));
415 }
416
417 double
418 value_as_double (val)
419 register value val;
420 {
421 return unpack_double (VALUE_TYPE (val), VALUE_CONTENTS (val));
422 }
423 \f
424 /* Unpack raw data (copied from debugee) at VALADDR
425 as a long, or as a double, assuming the raw data is described
426 by type TYPE. Knows how to convert different sizes of values
427 and can convert between fixed and floating point.
428
429 C++: It is assumed that the front-end has taken care of
430 all matters concerning pointers to members. A pointer
431 to member which reaches here is considered to be equivalent
432 to an INT (or some size). After all, it is only an offset. */
433
434 long
435 unpack_long (type, valaddr)
436 struct type *type;
437 char *valaddr;
438 {
439 register enum type_code code = TYPE_CODE (type);
440 register int len = TYPE_LENGTH (type);
441 register int nosign = TYPE_UNSIGNED (type);
442
443 if (code == TYPE_CODE_ENUM)
444 code = TYPE_CODE_INT;
445 if (code == TYPE_CODE_FLT)
446 {
447 if (len == sizeof (float))
448 return * (float *) valaddr;
449
450 if (len == sizeof (double))
451 return * (double *) valaddr;
452 }
453 else if (code == TYPE_CODE_INT && nosign)
454 {
455 if (len == sizeof (char))
456 return * (unsigned char *) valaddr;
457
458 if (len == sizeof (short))
459 return * (unsigned short *) valaddr;
460
461 if (len == sizeof (int))
462 return * (unsigned int *) valaddr;
463
464 if (len == sizeof (long))
465 return * (unsigned long *) valaddr;
466 }
467 else if (code == TYPE_CODE_INT
468 || code == TYPE_CODE_MPTR)
469 {
470 if (len == sizeof (char))
471 return * (char *) valaddr;
472
473 if (len == sizeof (short))
474 return * (short *) valaddr;
475
476 if (len == sizeof (int))
477 return * (int *) valaddr;
478
479 if (len == sizeof (long))
480 return * (long *) valaddr;
481 }
482 else if (code == TYPE_CODE_PTR
483 || code == TYPE_CODE_REF)
484 {
485 if (len == sizeof (char *))
486 return (CORE_ADDR) * (char **) valaddr;
487 }
488 error ("Value not integer or pointer.");
489 }
490
491 double
492 unpack_double (type, valaddr)
493 struct type *type;
494 char *valaddr;
495 {
496 register enum type_code code = TYPE_CODE (type);
497 register int len = TYPE_LENGTH (type);
498 register int nosign = TYPE_UNSIGNED (type);
499
500 if (code == TYPE_CODE_FLT)
501 {
502 if (INVALID_FLOAT (valaddr, len))
503 error ("Invalid floating value found in program.");
504
505 if (len == sizeof (float))
506 return * (float *) valaddr;
507
508 if (len == sizeof (double))
509 return * (double *) valaddr;
510 }
511 else if (code == TYPE_CODE_INT && nosign)
512 {
513 if (len == sizeof (char))
514 return * (unsigned char *) valaddr;
515
516 if (len == sizeof (short))
517 return * (unsigned short *) valaddr;
518
519 if (len == sizeof (int))
520 return * (unsigned int *) valaddr;
521
522 if (len == sizeof (long))
523 return * (unsigned long *) valaddr;
524 }
525 else if (code == TYPE_CODE_INT)
526 {
527 if (len == sizeof (char))
528 return * (char *) valaddr;
529
530 if (len == sizeof (short))
531 return * (short *) valaddr;
532
533 if (len == sizeof (int))
534 return * (int *) valaddr;
535
536 if (len == sizeof (long))
537 return * (long *) valaddr;
538 }
539
540 error ("Value not floating number.");
541 }
542 \f
543 /* Given a value ARG1 of a struct or union type,
544 extract and return the value of one of its fields.
545 FIELDNO says which field.
546
547 For C++, must also be able to return values from static fields */
548
549 value
550 value_field (arg1, fieldno)
551 register value arg1;
552 register int fieldno;
553 {
554 register value v;
555 register struct type *type = TYPE_FIELD_TYPE (VALUE_TYPE (arg1), fieldno);
556 register int offset;
557
558 /* Handle packed fields */
559
560 offset = TYPE_FIELD_BITPOS (VALUE_TYPE (arg1), fieldno) / 8;
561 if (TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno))
562 {
563 v = value_from_long (type,
564 unpack_field_as_long (VALUE_TYPE (arg1),
565 VALUE_CONTENTS (arg1),
566 fieldno));
567 VALUE_BITPOS (v) = TYPE_FIELD_BITPOS (VALUE_TYPE (arg1), fieldno) % 8;
568 VALUE_BITSIZE (v) = TYPE_FIELD_BITSIZE (VALUE_TYPE (arg1), fieldno);
569 }
570 else
571 {
572 v = allocate_value (type);
573 bcopy (VALUE_CONTENTS (arg1) + offset,
574 VALUE_CONTENTS (v),
575 TYPE_LENGTH (type));
576 }
577 VALUE_LVAL (v) = VALUE_LVAL (arg1);
578 if (VALUE_LVAL (arg1) == lval_internalvar)
579 VALUE_LVAL (v) = lval_internalvar_component;
580 VALUE_ADDRESS (v) = VALUE_ADDRESS (arg1);
581 VALUE_OFFSET (v) = offset + VALUE_OFFSET (arg1);
582 return v;
583 }
584
585 value
586 value_fn_field (arg1, fieldno, subfieldno)
587 register value arg1;
588 register int fieldno;
589 {
590 register value v;
591 struct fn_field *f = TYPE_FN_FIELDLIST1 (VALUE_TYPE (arg1), fieldno);
592 register struct type *type = TYPE_FN_FIELD_TYPE (f, subfieldno);
593 struct symbol *sym;
594
595 sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, subfieldno),
596 0, VAR_NAMESPACE);
597 if (! sym) error ("Internal error: could not find physical method named %s",
598 TYPE_FN_FIELD_PHYSNAME (f, subfieldno));
599
600 v = allocate_value (type);
601 VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
602 VALUE_TYPE (v) = type;
603 return v;
604 }
605
606 /* The value of a static class member does not depend
607 on its instance, only on its type. If FIELDNO >= 0,
608 then fieldno is a valid field number and is used directly.
609 Otherwise, FIELDNAME is the name of the field we are
610 searching for. If it is not a static field name, an
611 error is signaled. TYPE is the type in which we look for the
612 static field member. */
613 value
614 value_static_field (type, fieldname, fieldno)
615 register struct type *type;
616 char *fieldname;
617 register int fieldno;
618 {
619 register value v;
620 struct symbol *sym;
621
622 if (fieldno < 0)
623 {
624 register struct type *t = type;
625 /* Look for static field. */
626 while (t)
627 {
628 int i;
629 for (i = TYPE_NFIELDS (t) - 1; i >= 0; i--)
630 if (! strcmp (TYPE_FIELD_NAME (t, i), fieldname))
631 {
632 if (TYPE_FIELD_STATIC (t, i))
633 {
634 fieldno = i;
635 goto found;
636 }
637 else
638 error ("field `%s' is not static");
639 }
640 t = TYPE_BASECLASS (t);
641 }
642
643 t = type;
644
645 if (destructor_name_p (fieldname, t))
646 error ("use `info method' command to print out value of destructor");
647
648 while (t)
649 {
650 int i, j;
651
652 for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; i--)
653 {
654 if (! strcmp (TYPE_FN_FIELDLIST_NAME (t, i), fieldname))
655 {
656 error ("use `info method' command to print value of method \"%s\"", fieldname);
657 }
658 }
659 t = TYPE_BASECLASS (t);
660 }
661 error("there is no field named %s", fieldname);
662 }
663
664 found:
665
666 sym = lookup_symbol (TYPE_FIELD_STATIC_PHYSNAME (type, fieldno),
667 0, VAR_NAMESPACE);
668 if (! sym) error ("Internal error: could not find physical static variable named %s", TYPE_FIELD_BITSIZE (type, fieldno));
669
670 type = TYPE_FIELD_TYPE (type, fieldno);
671 v = value_at (type, (CORE_ADDR)SYMBOL_BLOCK_VALUE (sym));
672 return v;
673 }
674
675 long
676 unpack_field_as_long (type, valaddr, fieldno)
677 struct type *type;
678 char *valaddr;
679 int fieldno;
680 {
681 long val;
682 int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
683 int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
684 union { int i; char c; } test;
685
686 bcopy (valaddr + bitpos / 8, &val, sizeof val);
687
688 /* Extracting bits depends on endianness of the machine. */
689 test.i = 1;
690 if (test.c == 1)
691 /* Little-endian. */
692 val = val >> (bitpos % 8);
693 else
694 val = val >> (sizeof val * 8 - bitpos % 8 - bitsize);
695
696 val &= (1 << bitsize) - 1;
697 return val;
698 }
699
700 modify_field (addr, fieldval, bitpos, bitsize)
701 char *addr;
702 int fieldval;
703 int bitpos, bitsize;
704 {
705 long oword;
706 union { int i; char c; } test;
707
708 bcopy (addr, &oword, sizeof oword);
709
710 /* Shifting for bit field depends on endianness of the machine. */
711 test.c = 1;
712 if (test.i != 1)
713 /* not little-endian: assume big-endian. */
714 bitpos = sizeof oword * 8 - bitpos - bitsize;
715
716 oword &= ~(((1 << bitsize) - 1) << bitpos);
717 oword |= fieldval << bitpos;
718 bcopy (&oword, addr, sizeof oword);
719 }
720 \f
721 /* Convert C numbers into newly allocated values */
722
723 value
724 value_from_long (type, num)
725 struct type *type;
726 register long num;
727 {
728 register value val = allocate_value (type);
729 register enum type_code code = TYPE_CODE (type);
730 register int len = TYPE_LENGTH (type);
731
732 if (code == TYPE_CODE_INT || code == TYPE_CODE_ENUM)
733 {
734 if (len == sizeof (char))
735 * (char *) VALUE_CONTENTS (val) = num;
736 else if (len == sizeof (short))
737 * (short *) VALUE_CONTENTS (val) = num;
738 else if (len == sizeof (int))
739 * (int *) VALUE_CONTENTS (val) = num;
740 else if (len == sizeof (long))
741 * (long *) VALUE_CONTENTS (val) = num;
742 else
743 error ("Integer type encountered with unexpected data length.");
744 }
745 else
746 error ("Unexpected type encountered for integer constant.");
747
748 return val;
749 }
750
751 value
752 value_from_double (type, num)
753 struct type *type;
754 double num;
755 {
756 register value val = allocate_value (type);
757 register enum type_code code = TYPE_CODE (type);
758 register int len = TYPE_LENGTH (type);
759
760 if (code == TYPE_CODE_FLT)
761 {
762 if (len == sizeof (float))
763 * (float *) VALUE_CONTENTS (val) = num;
764 else if (len == sizeof (double))
765 * (double *) VALUE_CONTENTS (val) = num;
766 else
767 error ("Floating type encountered with unexpected data length.");
768 }
769 else
770 error ("Unexpected type encountered for floating constant.");
771
772 return val;
773 }
774 \f
775 /* Deal with the value that is "about to be returned". */
776
777 /* Return the value that a function returning now
778 would be returning to its caller, assuming its type is VALTYPE.
779 RETBUF is where we look for what ought to be the contents
780 of the registers (in raw form). This is because it is often
781 desirable to restore old values to those registers
782 after saving the contents of interest, and then call
783 this function using the saved values. */
784
785 value
786 value_being_returned (valtype, retbuf)
787 register struct type *valtype;
788 char retbuf[REGISTER_BYTES];
789 {
790 register value val;
791
792 if (TYPE_CODE (valtype) == TYPE_CODE_STRUCT
793 || TYPE_CODE (valtype) == TYPE_CODE_UNION)
794 return value_at (valtype, EXTRACT_STRUCT_VALUE_ADDRESS (retbuf));
795
796 val = allocate_value (valtype);
797 EXTRACT_RETURN_VALUE (valtype, retbuf, VALUE_CONTENTS (val));
798
799 return val;
800 }
801
802 /* Store VAL so it will be returned if a function returns now.
803 Does not verify that VAL's type matches what the current
804 function wants to return. */
805
806 void
807 set_return_value (val)
808 value val;
809 {
810 register enum type_code code = TYPE_CODE (VALUE_TYPE (val));
811 char regbuf[REGISTER_BYTES];
812 double dbuf;
813 long lbuf;
814
815 if (code == TYPE_CODE_STRUCT
816 || code == TYPE_CODE_UNION)
817 error ("Specifying a struct or union return value is not supported.");
818
819 if (code == TYPE_CODE_FLT)
820 {
821 dbuf = value_as_double (val);
822
823 STORE_RETURN_VALUE (VALUE_TYPE (val), &dbuf);
824 }
825 else
826 {
827 lbuf = value_as_long (val);
828 STORE_RETURN_VALUE (VALUE_TYPE (val), &lbuf);
829 }
830 }
831 \f
832 static
833 initialize ()
834 {
835 add_info ("convenience", convenience_info,
836 "Debugger convenience (\"$foo\") variables.\n\
837 These variables are created when you assign them values;\n\
838 thus, \"print $foo=1\" gives \"$foo\" the value 1. Values may be any type.\n\n\
839 A few convenience variables are given values automatically GDB:\n\
840 \"$_\"holds the last address examined with \"x\" or \"info lines\",\n\
841 \"$__\" holds the contents of the last address examined with \"x\".");
842
843 add_info ("history", history_info,
844 "Elements of value history (around item number IDX, or last ten).");
845 }
846
847 END_FILE
This page took 0.046898 seconds and 4 git commands to generate.