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