| OLD | NEW |
| 1 /* Target-dependent code for Lattice Mico32 processor, for GDB. | 1 /* Target-dependent code for Lattice Mico32 processor, for GDB. |
| 2 Contributed by Jon Beniston <jon@beniston.com> | 2 Contributed by Jon Beniston <jon@beniston.com> |
| 3 | 3 |
| 4 Copyright (C) 2009-2012 Free Software Foundation, Inc. | 4 Copyright (C) 2009-2012 Free Software Foundation, Inc. |
| 5 | 5 |
| 6 This file is part of GDB. | 6 This file is part of GDB. |
| 7 | 7 |
| 8 This program is free software; you can redistribute it and/or modify | 8 This program is free software; you can redistribute it and/or modify |
| 9 it under the terms of the GNU General Public License as published by | 9 it under the terms of the GNU General Public License as published by |
| 10 the Free Software Foundation; either version 3 of the License, or | 10 the Free Software Foundation; either version 3 of the License, or |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 return pc; | 181 return pc; |
| 182 } | 182 } |
| 183 | 183 |
| 184 /* Return PC of first non prologue instruction, for the function at the | 184 /* Return PC of first non prologue instruction, for the function at the |
| 185 specified address. */ | 185 specified address. */ |
| 186 | 186 |
| 187 static CORE_ADDR | 187 static CORE_ADDR |
| 188 lm32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) | 188 lm32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) |
| 189 { | 189 { |
| 190 CORE_ADDR func_addr, limit_pc; | 190 CORE_ADDR func_addr, limit_pc; |
| 191 struct symtab_and_line sal; | |
| 192 struct lm32_frame_cache frame_info; | 191 struct lm32_frame_cache frame_info; |
| 193 struct trad_frame_saved_reg saved_regs[SIM_LM32_NUM_REGS]; | 192 struct trad_frame_saved_reg saved_regs[SIM_LM32_NUM_REGS]; |
| 194 | 193 |
| 195 /* See if we can determine the end of the prologue via the symbol table. | 194 /* See if we can determine the end of the prologue via the symbol table. |
| 196 If so, then return either PC, or the PC after the prologue, whichever | 195 If so, then return either PC, or the PC after the prologue, whichever |
| 197 is greater. */ | 196 is greater. */ |
| 198 if (find_pc_partial_function (pc, NULL, &func_addr, NULL)) | 197 if (find_pc_partial_function (pc, NULL, &func_addr, NULL)) |
| 199 { | 198 { |
| 200 CORE_ADDR post_prologue_pc | 199 CORE_ADDR post_prologue_pc |
| 201 = skip_prologue_using_sal (gdbarch, func_addr); | 200 = skip_prologue_using_sal (gdbarch, func_addr); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 sp -= 4; | 255 sp -= 4; |
| 257 } | 256 } |
| 258 | 257 |
| 259 /* Setup parameters. */ | 258 /* Setup parameters. */ |
| 260 for (i = 0; i < nargs; i++) | 259 for (i = 0; i < nargs; i++) |
| 261 { | 260 { |
| 262 struct value *arg = args[i]; | 261 struct value *arg = args[i]; |
| 263 struct type *arg_type = check_typedef (value_type (arg)); | 262 struct type *arg_type = check_typedef (value_type (arg)); |
| 264 gdb_byte *contents; | 263 gdb_byte *contents; |
| 265 int len; | 264 int len; |
| 266 int j; | |
| 267 int reg; | |
| 268 ULONGEST val; | 265 ULONGEST val; |
| 269 | 266 |
| 270 /* Promote small integer types to int. */ | 267 /* Promote small integer types to int. */ |
| 271 switch (TYPE_CODE (arg_type)) | 268 switch (TYPE_CODE (arg_type)) |
| 272 { | 269 { |
| 273 case TYPE_CODE_INT: | 270 case TYPE_CODE_INT: |
| 274 case TYPE_CODE_BOOL: | 271 case TYPE_CODE_BOOL: |
| 275 case TYPE_CODE_CHAR: | 272 case TYPE_CODE_CHAR: |
| 276 case TYPE_CODE_RANGE: | 273 case TYPE_CODE_RANGE: |
| 277 case TYPE_CODE_ENUM: | 274 case TYPE_CODE_ENUM: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 308 } | 305 } |
| 309 | 306 |
| 310 /* Extract return value after calling a function in the inferior. */ | 307 /* Extract return value after calling a function in the inferior. */ |
| 311 | 308 |
| 312 static void | 309 static void |
| 313 lm32_extract_return_value (struct type *type, struct regcache *regcache, | 310 lm32_extract_return_value (struct type *type, struct regcache *regcache, |
| 314 gdb_byte *valbuf) | 311 gdb_byte *valbuf) |
| 315 { | 312 { |
| 316 struct gdbarch *gdbarch = get_regcache_arch (regcache); | 313 struct gdbarch *gdbarch = get_regcache_arch (regcache); |
| 317 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); | 314 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); |
| 318 int offset; | |
| 319 ULONGEST l; | 315 ULONGEST l; |
| 320 CORE_ADDR return_buffer; | 316 CORE_ADDR return_buffer; |
| 321 | 317 |
| 322 if (TYPE_CODE (type) != TYPE_CODE_STRUCT | 318 if (TYPE_CODE (type) != TYPE_CODE_STRUCT |
| 323 && TYPE_CODE (type) != TYPE_CODE_UNION | 319 && TYPE_CODE (type) != TYPE_CODE_UNION |
| 324 && TYPE_CODE (type) != TYPE_CODE_ARRAY && TYPE_LENGTH (type) <= 4) | 320 && TYPE_CODE (type) != TYPE_CODE_ARRAY && TYPE_LENGTH (type) <= 4) |
| 325 { | 321 { |
| 326 /* Return value is returned in a single register. */ | 322 /* Return value is returned in a single register. */ |
| 327 regcache_cooked_read_unsigned (regcache, SIM_LM32_R1_REGNUM, &l); | 323 regcache_cooked_read_unsigned (regcache, SIM_LM32_R1_REGNUM, &l); |
| 328 store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, l); | 324 store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, l); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 regcache_cooked_write_unsigned (regcache, SIM_LM32_R1_REGNUM, val); | 363 regcache_cooked_write_unsigned (regcache, SIM_LM32_R1_REGNUM, val); |
| 368 val = extract_unsigned_integer (valbuf + 4, len - 4, byte_order); | 364 val = extract_unsigned_integer (valbuf + 4, len - 4, byte_order); |
| 369 regcache_cooked_write_unsigned (regcache, SIM_LM32_R2_REGNUM, val); | 365 regcache_cooked_write_unsigned (regcache, SIM_LM32_R2_REGNUM, val); |
| 370 } | 366 } |
| 371 else | 367 else |
| 372 error (_("lm32_store_return_value: type length too large.")); | 368 error (_("lm32_store_return_value: type length too large.")); |
| 373 } | 369 } |
| 374 | 370 |
| 375 /* Determine whether a functions return value is in a register or memory. */ | 371 /* Determine whether a functions return value is in a register or memory. */ |
| 376 static enum return_value_convention | 372 static enum return_value_convention |
| 377 lm32_return_value (struct gdbarch *gdbarch, struct type *func_type, | 373 lm32_return_value (struct gdbarch *gdbarch, struct value *function, |
| 378 struct type *valtype, struct regcache *regcache, | 374 struct type *valtype, struct regcache *regcache, |
| 379 gdb_byte *readbuf, const gdb_byte *writebuf) | 375 gdb_byte *readbuf, const gdb_byte *writebuf) |
| 380 { | 376 { |
| 381 enum type_code code = TYPE_CODE (valtype); | 377 enum type_code code = TYPE_CODE (valtype); |
| 382 | 378 |
| 383 if (code == TYPE_CODE_STRUCT | 379 if (code == TYPE_CODE_STRUCT |
| 384 || code == TYPE_CODE_UNION | 380 || code == TYPE_CODE_UNION |
| 385 || code == TYPE_CODE_ARRAY || TYPE_LENGTH (valtype) > 8) | 381 || code == TYPE_CODE_ARRAY || TYPE_LENGTH (valtype) > 8) |
| 386 return RETURN_VALUE_STRUCT_CONVENTION; | 382 return RETURN_VALUE_STRUCT_CONVENTION; |
| 387 | 383 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 415 | 411 |
| 416 /* Put here the code to store, into fi->saved_regs, the addresses of | 412 /* Put here the code to store, into fi->saved_regs, the addresses of |
| 417 the saved registers of frame described by FRAME_INFO. This | 413 the saved registers of frame described by FRAME_INFO. This |
| 418 includes special registers such as pc and fp saved in special ways | 414 includes special registers such as pc and fp saved in special ways |
| 419 in the stack frame. sp is even more special: the address we return | 415 in the stack frame. sp is even more special: the address we return |
| 420 for it IS the sp for the next frame. */ | 416 for it IS the sp for the next frame. */ |
| 421 | 417 |
| 422 static struct lm32_frame_cache * | 418 static struct lm32_frame_cache * |
| 423 lm32_frame_cache (struct frame_info *this_frame, void **this_prologue_cache) | 419 lm32_frame_cache (struct frame_info *this_frame, void **this_prologue_cache) |
| 424 { | 420 { |
| 425 CORE_ADDR prologue_pc; | |
| 426 CORE_ADDR current_pc; | 421 CORE_ADDR current_pc; |
| 427 ULONGEST prev_sp; | 422 ULONGEST prev_sp; |
| 428 ULONGEST this_base; | 423 ULONGEST this_base; |
| 429 struct lm32_frame_cache *info; | 424 struct lm32_frame_cache *info; |
| 430 int prefixed; | |
| 431 unsigned long instruction; | |
| 432 int op; | |
| 433 int offsets[32]; | |
| 434 int i; | 425 int i; |
| 435 long immediate; | |
| 436 | 426 |
| 437 if ((*this_prologue_cache)) | 427 if ((*this_prologue_cache)) |
| 438 return (*this_prologue_cache); | 428 return (*this_prologue_cache); |
| 439 | 429 |
| 440 info = FRAME_OBSTACK_ZALLOC (struct lm32_frame_cache); | 430 info = FRAME_OBSTACK_ZALLOC (struct lm32_frame_cache); |
| 441 (*this_prologue_cache) = info; | 431 (*this_prologue_cache) = info; |
| 442 info->saved_regs = trad_frame_alloc_saved_regs (this_frame); | 432 info->saved_regs = trad_frame_alloc_saved_regs (this_frame); |
| 443 | 433 |
| 444 info->pc = get_frame_func (this_frame); | 434 info->pc = get_frame_func (this_frame); |
| 445 current_pc = get_frame_pc (this_frame); | 435 current_pc = get_frame_pc (this_frame); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 573 |
| 584 /* Instruction disassembler. */ | 574 /* Instruction disassembler. */ |
| 585 set_gdbarch_print_insn (gdbarch, print_insn_lm32); | 575 set_gdbarch_print_insn (gdbarch, print_insn_lm32); |
| 586 | 576 |
| 587 lm32_add_reggroups (gdbarch); | 577 lm32_add_reggroups (gdbarch); |
| 588 set_gdbarch_register_reggroup_p (gdbarch, lm32_register_reggroup_p); | 578 set_gdbarch_register_reggroup_p (gdbarch, lm32_register_reggroup_p); |
| 589 | 579 |
| 590 return gdbarch; | 580 return gdbarch; |
| 591 } | 581 } |
| 592 | 582 |
| 583 /* -Wmissing-prototypes */ |
| 584 extern initialize_file_ftype _initialize_lm32_tdep; |
| 585 |
| 593 void | 586 void |
| 594 _initialize_lm32_tdep (void) | 587 _initialize_lm32_tdep (void) |
| 595 { | 588 { |
| 596 register_gdbarch_init (bfd_arch_lm32, lm32_gdbarch_init); | 589 register_gdbarch_init (bfd_arch_lm32, lm32_gdbarch_init); |
| 597 } | 590 } |
| OLD | NEW |