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