* xcoffread.c (scan_xcoff_symtab): Ignore symbols beginning with
[deliverable/binutils-gdb.git] / gdb / arch-utils.c
CommitLineData
c0e8c252 1/* Dynamic architecture support for GDB, the GNU debugger.
b6ba6518 2 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
c0e8c252
AC
3
4 This file is part of GDB.
5
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.
10
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.
15
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,
19 Boston, MA 02111-1307, USA. */
20
21#include "defs.h"
22
23#if GDB_MULTI_ARCH
24#include "gdbcmd.h"
25#include "inferior.h" /* enum CALL_DUMMY_LOCATION et.al. */
26#else
27/* Just include everything in sight so that the every old definition
28 of macro is visible. */
29#include "gdb_string.h"
c0e8c252
AC
30#include "symtab.h"
31#include "frame.h"
32#include "inferior.h"
33#include "breakpoint.h"
34#include "gdb_wait.h"
35#include "gdbcore.h"
36#include "gdbcmd.h"
37#include "target.h"
c0e8c252 38#include "annotate.h"
c0e8c252
AC
39#endif
40
1ba607ad
AC
41#include "version.h"
42
f0d4cc9e
AC
43#include "floatformat.h"
44
c0e8c252
AC
45/* Use the program counter to determine the contents and size
46 of a breakpoint instruction. If no target-dependent macro
47 BREAKPOINT_FROM_PC has been defined to implement this function,
48 assume that the breakpoint doesn't depend on the PC, and
49 use the values of the BIG_BREAKPOINT and LITTLE_BREAKPOINT macros.
50 Return a pointer to a string of bytes that encode a breakpoint
51 instruction, stores the length of the string to *lenptr,
52 and optionally adjust the pc to point to the correct memory location
53 for inserting the breakpoint. */
54
55unsigned char *
56legacy_breakpoint_from_pc (CORE_ADDR * pcptr, int *lenptr)
57{
58 /* {BIG_,LITTLE_}BREAKPOINT is the sequence of bytes we insert for a
59 breakpoint. On some machines, breakpoints are handled by the
60 target environment and we don't have to worry about them here. */
61#ifdef BIG_BREAKPOINT
62 if (TARGET_BYTE_ORDER == BIG_ENDIAN)
63 {
64 static unsigned char big_break_insn[] = BIG_BREAKPOINT;
65 *lenptr = sizeof (big_break_insn);
66 return big_break_insn;
67 }
68#endif
69#ifdef LITTLE_BREAKPOINT
70 if (TARGET_BYTE_ORDER != BIG_ENDIAN)
71 {
72 static unsigned char little_break_insn[] = LITTLE_BREAKPOINT;
73 *lenptr = sizeof (little_break_insn);
74 return little_break_insn;
75 }
76#endif
77#ifdef BREAKPOINT
78 {
79 static unsigned char break_insn[] = BREAKPOINT;
80 *lenptr = sizeof (break_insn);
81 return break_insn;
82 }
83#endif
84 *lenptr = 0;
85 return NULL;
86}
87
88int
89generic_frameless_function_invocation_not (struct frame_info *fi)
90{
91 return 0;
92}
93
71a9f22e
JB
94int
95generic_return_value_on_stack_not (struct type *type)
96{
97 return 0;
98}
99
c0e8c252
AC
100char *
101legacy_register_name (int i)
102{
103#ifdef REGISTER_NAMES
104 static char *names[] = REGISTER_NAMES;
105 if (i < 0 || i >= (sizeof (names) / sizeof (*names)))
106 return NULL;
107 else
108 return names[i];
109#else
8e65ff28
AC
110 internal_error (__FILE__, __LINE__,
111 "legacy_register_name: called.");
c0e8c252
AC
112 return NULL;
113#endif
114}
115
116#if defined (CALL_DUMMY)
117LONGEST legacy_call_dummy_words[] = CALL_DUMMY;
118#else
119LONGEST legacy_call_dummy_words[1];
120#endif
121int legacy_sizeof_call_dummy_words = sizeof (legacy_call_dummy_words);
122
123void
124generic_remote_translate_xfer_address (CORE_ADDR gdb_addr, int gdb_len,
125 CORE_ADDR * rem_addr, int *rem_len)
126{
127 *rem_addr = gdb_addr;
128 *rem_len = gdb_len;
129}
130
dad41f9a
AC
131int
132generic_prologue_frameless_p (CORE_ADDR ip)
133{
134#ifdef SKIP_PROLOGUE_FRAMELESS_P
135 return ip == SKIP_PROLOGUE_FRAMELESS_P (ip);
136#else
137 return ip == SKIP_PROLOGUE (ip);
138#endif
139}
140
141
3339cf8b
AC
142/* Helper functions for INNER_THAN */
143
144int
fba45db2 145core_addr_lessthan (CORE_ADDR lhs, CORE_ADDR rhs)
3339cf8b
AC
146{
147 return (lhs < rhs);
148}
149
150int
fba45db2 151core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs)
3339cf8b
AC
152{
153 return (lhs > rhs);
154}
155
156
f0d4cc9e
AC
157/* Helper functions for TARGET_{FLOAT,DOUBLE}_FORMAT */
158
159const struct floatformat *
160default_float_format (struct gdbarch *gdbarch)
161{
162#if GDB_MULTI_ARCH
163 int byte_order = gdbarch_byte_order (gdbarch);
164#else
165 int byte_order = TARGET_BYTE_ORDER;
166#endif
167 switch (byte_order)
168 {
169 case BIG_ENDIAN:
170 return &floatformat_ieee_single_big;
171 case LITTLE_ENDIAN:
172 return &floatformat_ieee_single_little;
173 default:
8e65ff28
AC
174 internal_error (__FILE__, __LINE__,
175 "default_float_format: bad byte order");
f0d4cc9e
AC
176 }
177}
178
179
180const struct floatformat *
181default_double_format (struct gdbarch *gdbarch)
182{
183#if GDB_MULTI_ARCH
184 int byte_order = gdbarch_byte_order (gdbarch);
185#else
186 int byte_order = TARGET_BYTE_ORDER;
187#endif
188 switch (byte_order)
189 {
190 case BIG_ENDIAN:
191 return &floatformat_ieee_double_big;
192 case LITTLE_ENDIAN:
193 return &floatformat_ieee_double_little;
194 default:
8e65ff28
AC
195 internal_error (__FILE__, __LINE__,
196 "default_double_format: bad byte order");
f0d4cc9e
AC
197 }
198}
199
193e3b1a
AC
200/* Misc helper functions for targets. */
201
202int
fba45db2 203frame_num_args_unknown (struct frame_info *fi)
193e3b1a
AC
204{
205 return -1;
206}
207
208
209int
fba45db2 210generic_register_convertible_not (int num)
193e3b1a
AC
211{
212 return 0;
213}
214
b4a20239 215
7c7651b2
AC
216int
217default_register_sim_regno (int num)
218{
219 return num;
220}
221
f517ea4e
PS
222
223CORE_ADDR
224default_convert_from_func_ptr_addr (CORE_ADDR addr)
225{
226 return addr;
227}
228
88c72b7d
AC
229int
230no_op_reg_to_regnum (int reg)
231{
232 return reg;
233}
234
c347ee3e
MS
235/* For use by frame_args_address and frame_locals_address. */
236CORE_ADDR
237default_frame_address (struct frame_info *fi)
238{
239 return fi->frame;
240}
241
e02bc4cc
DS
242/* Default prepare_to_procced(). */
243int
244default_prepare_to_proceed (int select_it)
245{
246 return 0;
247}
248
249/* Generic prepare_to_proceed(). This one should be suitable for most
250 targets that support threads. */
251int
252generic_prepare_to_proceed (int select_it)
253{
254 int wait_pid;
255 struct target_waitstatus wait_status;
256
257 /* Get the last target status returned by target_wait(). */
258 get_last_target_status (&wait_pid, &wait_status);
259
260 /* Make sure we were stopped at a breakpoint. */
261 if (wait_status.kind != TARGET_WAITKIND_STOPPED
262 || wait_status.value.sig != TARGET_SIGNAL_TRAP)
263 {
264 return 0;
265 }
266
267 if (wait_pid != -1 && inferior_pid != wait_pid)
268 {
269 /* Switched over from WAIT_PID. */
270 CORE_ADDR wait_pc = read_pc_pid (wait_pid);
271
272 /* Avoid switching where it wouldn't do any good, i.e. if both
273 threads are at the same breakpoint. */
274 if (wait_pc != read_pc () && breakpoint_here_p (wait_pc))
275 {
276 if (select_it)
277 {
278 /* User hasn't deleted the breakpoint. Switch back to
279 WAIT_PID and return non-zero. */
280 inferior_pid = wait_pid;
281
282 /* FIXME: This stuff came from switch_to_thread() in
283 thread.c (which should probably be a public function). */
284 flush_cached_frames ();
285 registers_changed ();
286 stop_pc = wait_pc;
287 select_frame (get_current_frame (), 0);
288 }
289
290 return 1;
291 }
292 }
293 return 0;
294
295}
296
b4a20239
AC
297/* Functions to manipulate the endianness of the target. */
298
299#ifdef TARGET_BYTE_ORDER_SELECTABLE
300/* compat - Catch old targets that expect a selectable byte-order to
301 default to BIG_ENDIAN */
302#ifndef TARGET_BYTE_ORDER_DEFAULT
303#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN
304#endif
305#endif
306#if !TARGET_BYTE_ORDER_SELECTABLE_P
307#ifndef TARGET_BYTE_ORDER_DEFAULT
308/* compat - Catch old non byte-order selectable targets that do not
309 define TARGET_BYTE_ORDER_DEFAULT and instead expect
310 TARGET_BYTE_ORDER to be used as the default. For targets that
311 defined neither TARGET_BYTE_ORDER nor TARGET_BYTE_ORDER_DEFAULT the
312 below will get a strange compiler warning. */
313#define TARGET_BYTE_ORDER_DEFAULT TARGET_BYTE_ORDER
314#endif
315#endif
316#ifndef TARGET_BYTE_ORDER_DEFAULT
317#define TARGET_BYTE_ORDER_DEFAULT BIG_ENDIAN /* arbitrary */
318#endif
1ba607ad
AC
319/* ``target_byte_order'' is only used when non- multi-arch.
320 Multi-arch targets obtain the current byte order using
321 TARGET_BYTE_ORDER which is controlled by gdbarch.*. */
b4a20239
AC
322int target_byte_order = TARGET_BYTE_ORDER_DEFAULT;
323int target_byte_order_auto = 1;
324
53904c9e
AC
325static const char endian_big[] = "big";
326static const char endian_little[] = "little";
327static const char endian_auto[] = "auto";
328static const char *endian_enum[] =
b4a20239
AC
329{
330 endian_big,
331 endian_little,
332 endian_auto,
333 NULL,
334};
53904c9e 335static const char *set_endian_string;
b4a20239
AC
336
337/* Called by ``show endian''. */
338
339static void
340show_endian (char *args, int from_tty)
341{
342 if (TARGET_BYTE_ORDER_AUTO)
343 printf_unfiltered ("The target endianness is set automatically (currently %s endian)\n",
344 (TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"));
345 else
346 printf_unfiltered ("The target is assumed to be %s endian\n",
347 (TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little"));
348}
349
350static void
351set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
352{
353 if (!TARGET_BYTE_ORDER_SELECTABLE_P)
354 {
355 printf_unfiltered ("Byte order is not selectable.");
356 }
357 else if (set_endian_string == endian_auto)
358 {
359 target_byte_order_auto = 1;
360 }
361 else if (set_endian_string == endian_little)
362 {
b4a20239
AC
363 target_byte_order_auto = 0;
364 if (GDB_MULTI_ARCH)
365 {
366 struct gdbarch_info info;
367 memset (&info, 0, sizeof info);
368 info.byte_order = LITTLE_ENDIAN;
16f33e29
AC
369 if (! gdbarch_update_p (info))
370 {
371 printf_unfiltered ("Little endian target not supported by GDB\n");
372 }
b4a20239 373 }
1ba607ad
AC
374 else
375 {
376 target_byte_order = LITTLE_ENDIAN;
377 }
b4a20239
AC
378 }
379 else if (set_endian_string == endian_big)
380 {
b4a20239
AC
381 target_byte_order_auto = 0;
382 if (GDB_MULTI_ARCH)
383 {
384 struct gdbarch_info info;
385 memset (&info, 0, sizeof info);
386 info.byte_order = BIG_ENDIAN;
16f33e29
AC
387 if (! gdbarch_update_p (info))
388 {
389 printf_unfiltered ("Big endian target not supported by GDB\n");
390 }
b4a20239 391 }
1ba607ad
AC
392 else
393 {
394 target_byte_order = BIG_ENDIAN;
395 }
b4a20239
AC
396 }
397 else
8e65ff28
AC
398 internal_error (__FILE__, __LINE__,
399 "set_endian: bad value");
b4a20239
AC
400 show_endian (NULL, from_tty);
401}
402
403/* Set the endianness from a BFD. */
404
405static void
406set_endian_from_file (bfd *abfd)
407{
1ba607ad 408 if (GDB_MULTI_ARCH)
8e65ff28
AC
409 internal_error (__FILE__, __LINE__,
410 "set_endian_from_file: not for multi-arch");
b4a20239
AC
411 if (TARGET_BYTE_ORDER_SELECTABLE_P)
412 {
413 int want;
414
415 if (bfd_big_endian (abfd))
416 want = BIG_ENDIAN;
417 else
418 want = LITTLE_ENDIAN;
419 if (TARGET_BYTE_ORDER_AUTO)
420 target_byte_order = want;
421 else if (TARGET_BYTE_ORDER != want)
422 warning ("%s endian file does not match %s endian target.",
423 want == BIG_ENDIAN ? "big" : "little",
424 TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little");
425 }
426 else
427 {
428 if (bfd_big_endian (abfd)
429 ? TARGET_BYTE_ORDER != BIG_ENDIAN
430 : TARGET_BYTE_ORDER == BIG_ENDIAN)
431 warning ("%s endian file does not match %s endian target.",
432 bfd_big_endian (abfd) ? "big" : "little",
433 TARGET_BYTE_ORDER == BIG_ENDIAN ? "big" : "little");
434 }
435}
436
437
438/* Functions to manipulate the architecture of the target */
439
440enum set_arch { set_arch_auto, set_arch_manual };
441
442int target_architecture_auto = 1;
443
53904c9e 444const char *set_architecture_string;
b4a20239
AC
445
446/* Old way of changing the current architecture. */
447
448extern const struct bfd_arch_info bfd_default_arch_struct;
449const struct bfd_arch_info *target_architecture = &bfd_default_arch_struct;
450int (*target_architecture_hook) (const struct bfd_arch_info *ap);
451
452static int
453arch_ok (const struct bfd_arch_info *arch)
454{
455 if (GDB_MULTI_ARCH)
8e65ff28
AC
456 internal_error (__FILE__, __LINE__,
457 "arch_ok: not multi-arched");
b4a20239
AC
458 /* Should be performing the more basic check that the binary is
459 compatible with GDB. */
460 /* Check with the target that the architecture is valid. */
461 return (target_architecture_hook == NULL
462 || target_architecture_hook (arch));
463}
464
465static void
466set_arch (const struct bfd_arch_info *arch,
467 enum set_arch type)
468{
469 if (GDB_MULTI_ARCH)
8e65ff28
AC
470 internal_error (__FILE__, __LINE__,
471 "set_arch: not multi-arched");
b4a20239
AC
472 switch (type)
473 {
474 case set_arch_auto:
475 if (!arch_ok (arch))
476 warning ("Target may not support %s architecture",
477 arch->printable_name);
478 target_architecture = arch;
479 break;
480 case set_arch_manual:
481 if (!arch_ok (arch))
482 {
483 printf_unfiltered ("Target does not support `%s' architecture.\n",
484 arch->printable_name);
485 }
486 else
487 {
488 target_architecture_auto = 0;
489 target_architecture = arch;
490 }
491 break;
492 }
493 if (gdbarch_debug)
4b9b3959 494 gdbarch_dump (current_gdbarch, gdb_stdlog);
b4a20239
AC
495}
496
497/* Set the architecture from arch/machine (deprecated) */
498
499void
500set_architecture_from_arch_mach (enum bfd_architecture arch,
501 unsigned long mach)
502{
503 const struct bfd_arch_info *wanted = bfd_lookup_arch (arch, mach);
504 if (GDB_MULTI_ARCH)
8e65ff28
AC
505 internal_error (__FILE__, __LINE__,
506 "set_architecture_from_arch_mach: not multi-arched");
b4a20239
AC
507 if (wanted != NULL)
508 set_arch (wanted, set_arch_manual);
509 else
8e65ff28
AC
510 internal_error (__FILE__, __LINE__,
511 "gdbarch: hardwired architecture/machine not recognized");
b4a20239
AC
512}
513
514/* Set the architecture from a BFD (deprecated) */
515
516static void
517set_architecture_from_file (bfd *abfd)
518{
519 const struct bfd_arch_info *wanted = bfd_get_arch_info (abfd);
520 if (GDB_MULTI_ARCH)
8e65ff28
AC
521 internal_error (__FILE__, __LINE__,
522 "set_architecture_from_file: not multi-arched");
b4a20239
AC
523 if (target_architecture_auto)
524 {
525 set_arch (wanted, set_arch_auto);
526 }
527 else if (wanted != target_architecture)
528 {
529 warning ("%s architecture file may be incompatible with %s target.",
530 wanted->printable_name,
531 target_architecture->printable_name);
532 }
533}
534
535
536/* Called if the user enters ``show architecture'' without an
537 argument. */
538
539static void
540show_architecture (char *args, int from_tty)
541{
542 const char *arch;
543 arch = TARGET_ARCHITECTURE->printable_name;
544 if (target_architecture_auto)
545 printf_filtered ("The target architecture is set automatically (currently %s)\n", arch);
546 else
547 printf_filtered ("The target architecture is assumed to be %s\n", arch);
548}
549
550
551/* Called if the user enters ``set architecture'' with or without an
552 argument. */
553
554static void
555set_architecture (char *ignore_args, int from_tty, struct cmd_list_element *c)
556{
557 if (strcmp (set_architecture_string, "auto") == 0)
558 {
559 target_architecture_auto = 1;
560 }
561 else if (GDB_MULTI_ARCH)
562 {
563 struct gdbarch_info info;
564 memset (&info, 0, sizeof info);
565 info.bfd_arch_info = bfd_scan_arch (set_architecture_string);
566 if (info.bfd_arch_info == NULL)
8e65ff28
AC
567 internal_error (__FILE__, __LINE__,
568 "set_architecture: bfd_scan_arch failed");
16f33e29 569 if (gdbarch_update_p (info))
b4a20239
AC
570 target_architecture_auto = 0;
571 else
ec3d358c 572 printf_unfiltered ("Architecture `%s' not recognized.\n",
b4a20239
AC
573 set_architecture_string);
574 }
575 else
576 {
577 const struct bfd_arch_info *arch
578 = bfd_scan_arch (set_architecture_string);
579 if (arch == NULL)
8e65ff28
AC
580 internal_error (__FILE__, __LINE__,
581 "set_architecture: bfd_scan_arch failed");
b4a20239
AC
582 set_arch (arch, set_arch_manual);
583 }
584 show_architecture (NULL, from_tty);
585}
586
587/* Called if the user enters ``info architecture'' without an argument. */
588
589static void
590info_architecture (char *args, int from_tty)
591{
592 printf_filtered ("Available architectures are:\n");
593 if (GDB_MULTI_ARCH)
594 {
595 const char **arches = gdbarch_printable_names ();
596 const char **arch;
597 for (arch = arches; *arch != NULL; arch++)
598 {
599 printf_filtered (" %s", *arch);
600 }
b8c9b27d 601 xfree (arches);
b4a20239
AC
602 }
603 else
604 {
605 enum bfd_architecture a;
606 for (a = bfd_arch_obscure + 1; a < bfd_arch_last; a++)
607 {
608 const struct bfd_arch_info *ap;
609 for (ap = bfd_lookup_arch (a, 0);
610 ap != NULL;
611 ap = ap->next)
612 {
613 printf_filtered (" %s", ap->printable_name);
614 ap = ap->next;
615 }
616 }
617 }
618 printf_filtered ("\n");
619}
620
b7d6b182 621/* Set the dynamic target-system-dependent parameters (architecture,
b4a20239
AC
622 byte-order) using information found in the BFD */
623
624void
fba45db2 625set_gdbarch_from_file (bfd *abfd)
b4a20239
AC
626{
627 if (GDB_MULTI_ARCH)
628 {
629 struct gdbarch_info info;
630 memset (&info, 0, sizeof info);
631 info.abfd = abfd;
16f33e29 632 if (! gdbarch_update_p (info))
ec3d358c 633 error ("Architecture of file not recognized.\n");
b4a20239
AC
634 }
635 else
636 {
637 set_architecture_from_file (abfd);
638 set_endian_from_file (abfd);
639 }
640}
641
642/* Initialize the current architecture. Update the ``set
643 architecture'' command so that it specifies a list of valid
644 architectures. */
645
1ba607ad
AC
646#ifdef DEFAULT_BFD_ARCH
647extern const bfd_arch_info_type DEFAULT_BFD_ARCH;
648static const bfd_arch_info_type *default_bfd_arch = &DEFAULT_BFD_ARCH;
649#else
4b9b3959 650static const bfd_arch_info_type *default_bfd_arch;
1ba607ad
AC
651#endif
652
653#ifdef DEFAULT_BFD_VEC
654extern const bfd_target DEFAULT_BFD_VEC;
655static const bfd_target *default_bfd_vec = &DEFAULT_BFD_VEC;
656#else
657static const bfd_target *default_bfd_vec;
658#endif
659
b4a20239
AC
660void
661initialize_current_architecture (void)
662{
663 const char **arches = gdbarch_printable_names ();
b4a20239 664
1ba607ad
AC
665 /* determine a default architecture and byte order. */
666 struct gdbarch_info info;
667 memset (&info, 0, sizeof (info));
668
669 /* Find a default architecture. */
670 if (info.bfd_arch_info == NULL
671 && default_bfd_arch != NULL)
672 info.bfd_arch_info = default_bfd_arch;
673 if (info.bfd_arch_info == NULL)
b4a20239 674 {
1ba607ad
AC
675 /* Choose the architecture by taking the first one
676 alphabetically. */
677 const char *chosen = arches[0];
b4a20239 678 const char **arch;
b4a20239
AC
679 for (arch = arches; *arch != NULL; arch++)
680 {
b4a20239
AC
681 if (strcmp (*arch, chosen) < 0)
682 chosen = *arch;
683 }
684 if (chosen == NULL)
8e65ff28
AC
685 internal_error (__FILE__, __LINE__,
686 "initialize_current_architecture: No arch");
b4a20239
AC
687 info.bfd_arch_info = bfd_scan_arch (chosen);
688 if (info.bfd_arch_info == NULL)
8e65ff28
AC
689 internal_error (__FILE__, __LINE__,
690 "initialize_current_architecture: Arch not found");
1ba607ad
AC
691 }
692
693 /* take several guesses at a byte order. */
694 /* NB: can't use TARGET_BYTE_ORDER_DEFAULT as its definition is
695 forced above. */
696 if (info.byte_order == 0
697 && default_bfd_vec != NULL)
698 {
699 /* Extract BFD's default vector's byte order. */
700 switch (default_bfd_vec->byteorder)
701 {
702 case BFD_ENDIAN_BIG:
703 info.byte_order = BIG_ENDIAN;
704 break;
705 case BFD_ENDIAN_LITTLE:
706 info.byte_order = LITTLE_ENDIAN;
707 break;
708 default:
709 break;
710 }
711 }
712 if (info.byte_order == 0)
713 {
714 /* look for ``*el-*'' in the target name. */
715 const char *chp;
716 chp = strchr (target_name, '-');
717 if (chp != NULL
718 && chp - 2 >= target_name
719 && strncmp (chp - 2, "el", 2) == 0)
720 info.byte_order = LITTLE_ENDIAN;
721 }
722 if (info.byte_order == 0)
723 {
724 /* Wire it to big-endian!!! */
725 info.byte_order = BIG_ENDIAN;
726 }
727
728 if (GDB_MULTI_ARCH)
729 {
16f33e29
AC
730 if (! gdbarch_update_p (info))
731 {
8e65ff28
AC
732 internal_error (__FILE__, __LINE__,
733 "initialize_current_architecture: Selection of initial architecture failed");
16f33e29 734 }
b4a20239
AC
735 }
736
1ba607ad
AC
737 /* Create the ``set architecture'' command appending ``auto'' to the
738 list of architectures. */
b4a20239
AC
739 {
740 struct cmd_list_element *c;
741 /* Append ``auto''. */
742 int nr;
743 for (nr = 0; arches[nr] != NULL; nr++);
744 arches = xrealloc (arches, sizeof (char*) * (nr + 2));
745 arches[nr + 0] = "auto";
746 arches[nr + 1] = NULL;
747 /* FIXME: add_set_enum_cmd() uses an array of ``char *'' instead
748 of ``const char *''. We just happen to know that the casts are
749 safe. */
750 c = add_set_enum_cmd ("architecture", class_support,
53904c9e 751 arches, &set_architecture_string,
b4a20239
AC
752 "Set architecture of target.",
753 &setlist);
754 c->function.sfunc = set_architecture;
755 add_alias_cmd ("processor", "architecture", class_support, 1, &setlist);
756 /* Don't use set_from_show - need to print both auto/manual and
757 current setting. */
758 add_cmd ("architecture", class_support, show_architecture,
759 "Show the current target architecture", &showlist);
760 c = add_cmd ("architecture", class_support, info_architecture,
761 "List supported target architectures", &infolist);
762 deprecate_cmd (c, "set architecture");
763 }
764}
765
766
c0e8c252
AC
767/* */
768
b4a20239 769extern initialize_file_ftype _initialize_gdbarch_utils;
c0e8c252
AC
770
771void
b4a20239 772_initialize_gdbarch_utils (void)
c0e8c252 773{
b4a20239
AC
774 struct cmd_list_element *c;
775 c = add_set_enum_cmd ("endian", class_support,
776 endian_enum, &set_endian_string,
777 "Set endianness of target.",
778 &setlist);
779 c->function.sfunc = set_endian;
780 /* Don't use set_from_show - need to print both auto/manual and
781 current setting. */
782 add_cmd ("endian", class_support, show_endian,
783 "Show the current byte-order", &showlist);
c0e8c252 784}
This page took 0.15818 seconds and 4 git commands to generate.