Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Side by Side Diff: gdb/cris-tdep.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/cp-valprint.c ('k') | gdb/d-lang.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Target dependent code for CRIS, for GDB, the GNU debugger. 1 /* Target dependent code for CRIS, for GDB, the GNU debugger.
2 2
3 Copyright (C) 2001-2012 Free Software Foundation, Inc. 3 Copyright (C) 2001-2012 Free Software Foundation, Inc.
4 4
5 Contributed by Axis Communications AB. 5 Contributed by Axis Communications AB.
6 Written by Hendrik Ruijter, Stefan Andersson, and Orjan Friberg. 6 Written by Hendrik Ruijter, Stefan Andersson, and Orjan Friberg.
7 7
8 This file is part of GDB. 8 This file is part of GDB.
9 9
10 This program is free software; you can redistribute it and/or modify 10 This program is free software; you can redistribute it and/or modify
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 /* CRIS version, set via the user command 'set cris-version'. Affects 145 /* CRIS version, set via the user command 'set cris-version'. Affects
146 register names and sizes. */ 146 register names and sizes. */
147 static int usr_cmd_cris_version; 147 static int usr_cmd_cris_version;
148 148
149 /* Indicates whether to trust the above variable. */ 149 /* Indicates whether to trust the above variable. */
150 static int usr_cmd_cris_version_valid = 0; 150 static int usr_cmd_cris_version_valid = 0;
151 151
152 static const char cris_mode_normal[] = "normal"; 152 static const char cris_mode_normal[] = "normal";
153 static const char cris_mode_guru[] = "guru"; 153 static const char cris_mode_guru[] = "guru";
154 static const char *cris_modes[] = { 154 static const char *const cris_modes[] = {
155 cris_mode_normal, 155 cris_mode_normal,
156 cris_mode_guru, 156 cris_mode_guru,
157 0 157 0
158 }; 158 };
159 159
160 /* CRIS mode, set via the user command 'set cris-mode'. Affects 160 /* CRIS mode, set via the user command 'set cris-mode'. Affects
161 type of break instruction among other things. */ 161 type of break instruction among other things. */
162 static const char *usr_cmd_cris_mode = cris_mode_normal; 162 static const char *usr_cmd_cris_mode = cris_mode_normal;
163 163
164 /* Whether to make use of Dwarf-2 CFI (default on). */ 164 /* Whether to make use of Dwarf-2 CFI (default on). */
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 }; 315 };
316 316
317 static struct cris_unwind_cache * 317 static struct cris_unwind_cache *
318 cris_sigtramp_frame_unwind_cache (struct frame_info *this_frame, 318 cris_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
319 void **this_cache) 319 void **this_cache)
320 { 320 {
321 struct gdbarch *gdbarch = get_frame_arch (this_frame); 321 struct gdbarch *gdbarch = get_frame_arch (this_frame);
322 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); 322 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
323 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); 323 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
324 struct cris_unwind_cache *info; 324 struct cris_unwind_cache *info;
325 CORE_ADDR pc;
326 CORE_ADDR sp;
327 CORE_ADDR addr; 325 CORE_ADDR addr;
328 char buf[4]; 326 char buf[4];
329 int i; 327 int i;
330 328
331 if ((*this_cache)) 329 if ((*this_cache))
332 return (*this_cache); 330 return (*this_cache);
333 331
334 info = FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache); 332 info = FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache);
335 (*this_cache) = info; 333 (*this_cache) = info;
336 info->saved_regs = trad_frame_alloc_saved_regs (this_frame); 334 info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 if (erp & 0x1) 468 if (erp & 0x1)
471 { 469 {
472 /* In delay slot - check if there's a breakpoint at the preceding 470 /* In delay slot - check if there's a breakpoint at the preceding
473 instruction. */ 471 instruction. */
474 if (breakpoint_here_p (get_frame_address_space (this_frame), erp & ~0x1)) 472 if (breakpoint_here_p (get_frame_address_space (this_frame), erp & ~0x1))
475 ret = 1; 473 ret = 1;
476 } 474 }
477 return ret; 475 return ret;
478 } 476 }
479 477
480 /* Hardware watchpoint support. */
481
482 /* We support 6 hardware data watchpoints, but cannot trigger on execute
483 (any combination of read/write is fine). */
484
485 int
486 cris_can_use_hardware_watchpoint (int type, int count, int other)
487 {
488 struct gdbarch_tdep *tdep = gdbarch_tdep (target_gdbarch);
489
490 /* No bookkeeping is done here; it is handled by the remote debug agent. */
491
492 if (tdep->cris_version != 32)
493 return 0;
494 else
495 /* CRISv32: Six data watchpoints, one for instructions. */
496 return (((type == bp_read_watchpoint || type == bp_access_watchpoint
497 || type == bp_hardware_watchpoint) && count <= 6)
498 || (type == bp_hardware_breakpoint && count <= 1));
499 }
500
501 /* The CRISv32 hardware data watchpoints work by specifying ranges,
502 which have no alignment or length restrictions. */
503
504 int
505 cris_region_ok_for_watchpoint (CORE_ADDR addr, int len)
506 {
507 return 1;
508 }
509
510 /* If the inferior has some watchpoint that triggered, return the
511 address associated with that watchpoint. Otherwise, return
512 zero. */
513
514 CORE_ADDR
515 cris_stopped_data_address (void)
516 {
517 CORE_ADDR eda;
518 eda = get_frame_register_unsigned (get_current_frame (), EDA_REGNUM);
519 return eda;
520 }
521
522 /* The instruction environment needed to find single-step breakpoints. */ 478 /* The instruction environment needed to find single-step breakpoints. */
523 479
524 typedef 480 typedef
525 struct instruction_environment 481 struct instruction_environment
526 { 482 {
527 unsigned long reg[NUM_GENREGS]; 483 unsigned long reg[NUM_GENREGS];
528 unsigned long preg[NUM_SPECREGS]; 484 unsigned long preg[NUM_SPECREGS];
529 unsigned long branch_break_address; 485 unsigned long branch_break_address;
530 unsigned long delay_slot_pc; 486 unsigned long delay_slot_pc;
531 unsigned long prefix_value; 487 unsigned long prefix_value;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 includes special registers such as pc and fp saved in special ways 702 includes special registers such as pc and fp saved in special ways
747 in the stack frame. sp is even more special: the address we return 703 in the stack frame. sp is even more special: the address we return
748 for it IS the sp for the next frame. */ 704 for it IS the sp for the next frame. */
749 705
750 static struct cris_unwind_cache * 706 static struct cris_unwind_cache *
751 cris_frame_unwind_cache (struct frame_info *this_frame, 707 cris_frame_unwind_cache (struct frame_info *this_frame,
752 void **this_prologue_cache) 708 void **this_prologue_cache)
753 { 709 {
754 struct gdbarch *gdbarch = get_frame_arch (this_frame); 710 struct gdbarch *gdbarch = get_frame_arch (this_frame);
755 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); 711 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
756 CORE_ADDR pc;
757 struct cris_unwind_cache *info; 712 struct cris_unwind_cache *info;
758 int i;
759 713
760 if ((*this_prologue_cache)) 714 if ((*this_prologue_cache))
761 return (*this_prologue_cache); 715 return (*this_prologue_cache);
762 716
763 info = FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache); 717 info = FRAME_OBSTACK_ZALLOC (struct cris_unwind_cache);
764 (*this_prologue_cache) = info; 718 (*this_prologue_cache) = info;
765 info->saved_regs = trad_frame_alloc_saved_regs (this_frame); 719 info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
766 720
767 /* Zero all fields. */ 721 /* Zero all fields. */
768 info->prev_sp = 0; 722 info->prev_sp = 0;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 return sp; 812 return sp;
859 } 813 }
860 814
861 static CORE_ADDR 815 static CORE_ADDR
862 cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function, 816 cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
863 struct regcache *regcache, CORE_ADDR bp_addr, 817 struct regcache *regcache, CORE_ADDR bp_addr,
864 int nargs, struct value **args, CORE_ADDR sp, 818 int nargs, struct value **args, CORE_ADDR sp,
865 int struct_return, CORE_ADDR struct_addr) 819 int struct_return, CORE_ADDR struct_addr)
866 { 820 {
867 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); 821 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
868 int stack_alloc;
869 int stack_offset; 822 int stack_offset;
870 int argreg; 823 int argreg;
871 int argnum; 824 int argnum;
872 825
873 CORE_ADDR regval;
874
875 /* The function's arguments and memory allocated by gdb for the arguments to 826 /* The function's arguments and memory allocated by gdb for the arguments to
876 point at reside in separate areas on the stack. 827 point at reside in separate areas on the stack.
877 Both frame pointers grow toward higher addresses. */ 828 Both frame pointers grow toward higher addresses. */
878 CORE_ADDR fp_arg; 829 CORE_ADDR fp_arg;
879 CORE_ADDR fp_mem; 830 CORE_ADDR fp_mem;
880 831
881 struct stack_item *si = NULL; 832 struct stack_item *si = NULL;
882 833
883 /* Push the return address. */ 834 /* Push the return address. */
884 regcache_cooked_write_unsigned (regcache, SRP_REGNUM, bp_addr); 835 regcache_cooked_write_unsigned (regcache, SRP_REGNUM, bp_addr);
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 regcache_cooked_read_unsigned (regcache, ARG2_REGNUM, &val); 1849 regcache_cooked_read_unsigned (regcache, ARG2_REGNUM, &val);
1899 store_unsigned_integer ((char *)valbuf + 4, len - 4, byte_order, val); 1850 store_unsigned_integer ((char *)valbuf + 4, len - 4, byte_order, val);
1900 } 1851 }
1901 else 1852 else
1902 error (_("cris_extract_return_value: type length too large")); 1853 error (_("cris_extract_return_value: type length too large"));
1903 } 1854 }
1904 1855
1905 /* Handle the CRIS return value convention. */ 1856 /* Handle the CRIS return value convention. */
1906 1857
1907 static enum return_value_convention 1858 static enum return_value_convention
1908 cris_return_value (struct gdbarch *gdbarch, struct type *func_type, 1859 cris_return_value (struct gdbarch *gdbarch, struct value *function,
1909 struct type *type, struct regcache *regcache, 1860 struct type *type, struct regcache *regcache,
1910 gdb_byte *readbuf, const gdb_byte *writebuf) 1861 gdb_byte *readbuf, const gdb_byte *writebuf)
1911 { 1862 {
1912 if (TYPE_CODE (type) == TYPE_CODE_STRUCT 1863 if (TYPE_CODE (type) == TYPE_CODE_STRUCT
1913 || TYPE_CODE (type) == TYPE_CODE_UNION 1864 || TYPE_CODE (type) == TYPE_CODE_UNION
1914 || TYPE_LENGTH (type) > 8) 1865 || TYPE_LENGTH (type) > 8)
1915 /* Structs, unions, and anything larger than 8 bytes (2 registers) 1866 /* Structs, unions, and anything larger than 8 bytes (2 registers)
1916 goes on the stack. */ 1867 goes on the stack. */
1917 return RETURN_VALUE_STRUCT_CONVENTION; 1868 return RETURN_VALUE_STRUCT_CONVENTION;
1918 1869
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 static unsigned long get_data_from_address (unsigned short *inst, 2175 static unsigned long get_data_from_address (unsigned short *inst,
2225 CORE_ADDR address, 2176 CORE_ADDR address,
2226 enum bfd_endian byte_order); 2177 enum bfd_endian byte_order);
2227 2178
2228 /* Calculates the prefix value for the general case of offset addressing 2179 /* Calculates the prefix value for the general case of offset addressing
2229 mode. */ 2180 mode. */
2230 2181
2231 static void 2182 static void
2232 bdap_prefix (unsigned short inst, inst_env_type *inst_env) 2183 bdap_prefix (unsigned short inst, inst_env_type *inst_env)
2233 { 2184 {
2234
2235 long offset;
2236
2237 /* It's invalid to be in a delay slot. */ 2185 /* It's invalid to be in a delay slot. */
2238 if (inst_env->slot_needed || inst_env->prefix_found) 2186 if (inst_env->slot_needed || inst_env->prefix_found)
2239 { 2187 {
2240 inst_env->invalid = 1; 2188 inst_env->invalid = 1;
2241 return; 2189 return;
2242 } 2190 }
2243 2191
2244 /* The calculation of prefix_value used to be after process_autoincrement, 2192 /* The calculation of prefix_value used to be after process_autoincrement,
2245 but that fails for an instruction such as jsr [$r0+12] which is encoded 2193 but that fails for an instruction such as jsr [$r0+12] which is encoded
2246 as 5f0d 0c00 30b9 when compiled with -fpic. Since PC is operand1 it 2194 as 5f0d 0c00 30b9 when compiled with -fpic. Since PC is operand1 it
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after
4231 set_solib_svr4_fetch_link_map_offsets 4179 set_solib_svr4_fetch_link_map_offsets
4232 (gdbarch, svr4_ilp32_fetch_link_map_offsets); 4180 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
4233 4181
4234 /* FIXME: cagney/2003-08-27: It should be possible to select a CRIS 4182 /* FIXME: cagney/2003-08-27: It should be possible to select a CRIS
4235 disassembler, even when there is no BFD. Does something like 4183 disassembler, even when there is no BFD. Does something like
4236 "gdb; target remote; disassmeble *0x123" work? */ 4184 "gdb; target remote; disassmeble *0x123" work? */
4237 set_gdbarch_print_insn (gdbarch, cris_delayed_get_disassembler); 4185 set_gdbarch_print_insn (gdbarch, cris_delayed_get_disassembler);
4238 4186
4239 return gdbarch; 4187 return gdbarch;
4240 } 4188 }
OLDNEW
« no previous file with comments | « gdb/cp-valprint.c ('k') | gdb/d-lang.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698