OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [v850-tdep.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
/* Target-dependent code for the NEC V850 for GDB, the GNU debugger.
2
   Copyright 1996, 1998, 1999, 2000, 2001, 2002 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
#include "frame.h"
23
#include "inferior.h"
24
#include "target.h"
25
#include "value.h"
26
#include "bfd.h"
27
#include "gdb_string.h"
28
#include "gdbcore.h"
29
#include "symfile.h"
30
#include "arch-utils.h"
31
#include "regcache.h"
32
#include "symtab.h"
33
 
34
struct gdbarch_tdep
35
{
36
  /* gdbarch target dependent data here. Currently unused for v850. */
37
};
38
 
39
/* Extra info which is saved in each frame_info. */
40
struct frame_extra_info
41
{
42
};
43
 
44
enum {
45
 E_R0_REGNUM,
46
 E_R1_REGNUM,
47
 E_R2_REGNUM, E_SAVE1_START_REGNUM = E_R2_REGNUM, E_SAVE1_END_REGNUM = E_R2_REGNUM,
48
 E_R3_REGNUM, E_SP_REGNUM = E_R3_REGNUM,
49
 E_R4_REGNUM,
50
 E_R5_REGNUM,
51
 E_R6_REGNUM, E_ARG0_REGNUM = E_R6_REGNUM,
52
 E_R7_REGNUM,
53
 E_R8_REGNUM,
54
 E_R9_REGNUM, E_ARGLAST_REGNUM = E_R9_REGNUM,
55
 E_R10_REGNUM, E_V0_REGNUM = E_R10_REGNUM,
56
 E_R11_REGNUM, E_V1_REGNUM = E_R11_REGNUM,
57
 E_R12_REGNUM,
58
 E_R13_REGNUM,
59
 E_R14_REGNUM,
60
 E_R15_REGNUM,
61
 E_R16_REGNUM,
62
 E_R17_REGNUM,
63
 E_R18_REGNUM,
64
 E_R19_REGNUM,
65
 E_R20_REGNUM, E_SAVE2_START_REGNUM = E_R20_REGNUM,
66
 E_R21_REGNUM,
67
 E_R22_REGNUM,
68
 E_R23_REGNUM,
69
 E_R24_REGNUM,
70
 E_R25_REGNUM,
71
 E_R26_REGNUM,
72
 E_R27_REGNUM,
73
 E_R28_REGNUM,
74
 E_R29_REGNUM, E_SAVE2_END_REGNUM = E_R29_REGNUM, E_FP_RAW_REGNUM = E_R29_REGNUM,
75
 E_R30_REGNUM, E_EP_REGNUM = E_R30_REGNUM,
76
 E_R31_REGNUM, E_SAVE3_START_REGNUM = E_R31_REGNUM, E_SAVE3_END_REGNUM = E_R31_REGNUM, E_RP_REGNUM = E_R31_REGNUM,
77
 E_R32_REGNUM, E_SR0_REGNUM = E_R32_REGNUM,
78
 E_R33_REGNUM,
79
 E_R34_REGNUM,
80
 E_R35_REGNUM,
81
 E_R36_REGNUM,
82
 E_R37_REGNUM, E_PS_REGNUM = E_R37_REGNUM,
83
 E_R38_REGNUM,
84
 E_R39_REGNUM,
85
 E_R40_REGNUM,
86
 E_R41_REGNUM,
87
 E_R42_REGNUM,
88
 E_R43_REGNUM,
89
 E_R44_REGNUM,
90
 E_R45_REGNUM,
91
 E_R46_REGNUM,
92
 E_R47_REGNUM,
93
 E_R48_REGNUM,
94
 E_R49_REGNUM,
95
 E_R50_REGNUM,
96
 E_R51_REGNUM,
97
 E_R52_REGNUM, E_CTBP_REGNUM = E_R52_REGNUM,
98
 E_R53_REGNUM,
99
 E_R54_REGNUM,
100
 E_R55_REGNUM,
101
 E_R56_REGNUM,
102
 E_R57_REGNUM,
103
 E_R58_REGNUM,
104
 E_R59_REGNUM,
105
 E_R60_REGNUM,
106
 E_R61_REGNUM,
107
 E_R62_REGNUM,
108
 E_R63_REGNUM,
109
 E_R64_REGNUM, E_PC_REGNUM = E_R64_REGNUM,
110
 E_R65_REGNUM, E_FP_REGNUM = E_R65_REGNUM,
111
 E_NUM_REGS
112
};
113
 
114
enum
115
{
116
  v850_reg_size = 4
117
};
118
 
119
/* Size of all registers as a whole. */
120
enum
121
{
122
  E_ALL_REGS_SIZE = (E_NUM_REGS) * v850_reg_size
123
};
124
 
125
/* Size of return datatype which fits into all return registers. */
126
enum
127
{
128
  E_MAX_RETTYPE_SIZE_IN_REGS = 2 * v850_reg_size
129
};
130
 
131
static LONGEST call_dummy_nil[] = {0};
132
 
133
static char *v850_generic_reg_names[] =
134
{ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
135
  "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
136
  "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
137
  "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
138
  "eipc", "eipsw", "fepc", "fepsw", "ecr", "psw", "sr6", "sr7",
139
  "sr8", "sr9", "sr10", "sr11", "sr12", "sr13", "sr14", "sr15",
140
  "sr16", "sr17", "sr18", "sr19", "sr20", "sr21", "sr22", "sr23",
141
  "sr24", "sr25", "sr26", "sr27", "sr28", "sr29", "sr30", "sr31",
142
  "pc", "fp"
143
};
144
 
145
static char *v850e_reg_names[] =
146
{
147
  "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
148
  "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
149
  "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
150
  "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
151
  "eipc", "eipsw", "fepc", "fepsw", "ecr", "psw", "sr6", "sr7",
152
  "sr8", "sr9", "sr10", "sr11", "sr12", "sr13", "sr14", "sr15",
153
  "ctpc", "ctpsw", "dbpc", "dbpsw", "ctbp", "sr21", "sr22", "sr23",
154
  "sr24", "sr25", "sr26", "sr27", "sr28", "sr29", "sr30", "sr31",
155
  "pc", "fp"
156
};
157
 
158
char **v850_register_names = v850_generic_reg_names;
159
 
160
struct
161
  {
162
    char **regnames;
163
    int mach;
164
  }
165
v850_processor_type_table[] =
166
{
167
  {
168
    v850_generic_reg_names, bfd_mach_v850
169
  }
170
  ,
171
  {
172
    v850e_reg_names, bfd_mach_v850e
173
  }
174
  ,
175
  {
176
    v850e_reg_names, bfd_mach_v850ea
177
  }
178
  ,
179
  {
180
    NULL, 0
181
  }
182
};
183
 
184
/* Info gleaned from scanning a function's prologue.  */
185
 
186
struct pifsr                    /* Info about one saved reg */
187
  {
188
    int framereg;               /* Frame reg (SP or FP) */
189
    int offset;                 /* Offset from framereg */
190
    int cur_frameoffset;        /* Current frameoffset */
191
    int reg;                    /* Saved register number */
192
  };
193
 
194
struct prologue_info
195
  {
196
    int framereg;
197
    int frameoffset;
198
    int start_function;
199
    struct pifsr *pifsrs;
200
  };
201
 
202
static CORE_ADDR v850_scan_prologue (CORE_ADDR pc, struct prologue_info *fs);
203
 
204
/* Function: v850_register_name
205
   Returns the name of the v850/v850e register N. */
206
 
207
static const char *
208
v850_register_name (int regnum)
209
{
210
  if (regnum < 0 || regnum >= E_NUM_REGS)
211
    internal_error (__FILE__, __LINE__,
212
                    "v850_register_name: illegal register number %d",
213
                    regnum);
214
  else
215
    return v850_register_names[regnum];
216
 
217
}
218
 
219
/* Function: v850_register_byte
220
   Returns the byte position in the register cache for register N. */
221
 
222
static int
223
v850_register_byte (int regnum)
224
{
225
  if (regnum < 0 || regnum >= E_NUM_REGS)
226
    internal_error (__FILE__, __LINE__,
227
                    "v850_register_byte: illegal register number %d",
228
                    regnum);
229
  else
230
    return regnum * v850_reg_size;
231
}
232
 
233
/* Function: v850_register_raw_size
234
   Returns the number of bytes occupied by the register on the target. */
235
 
236
static int
237
v850_register_raw_size (int regnum)
238
{
239
  if (regnum < 0 || regnum >= E_NUM_REGS)
240
    internal_error (__FILE__, __LINE__,
241
                    "v850_register_raw_size: illegal register number %d",
242
                    regnum);
243
  /* Only the PC has 4 Byte, all other registers 2 Byte. */
244
  else
245
    return v850_reg_size;
246
}
247
 
248
/* Function: v850_register_virtual_size
249
   Returns the number of bytes occupied by the register as represented
250
   internally by gdb. */
251
 
252
static int
253
v850_register_virtual_size (int regnum)
254
{
255
  return v850_register_raw_size (regnum);
256
}
257
 
258
/* Function: v850_reg_virtual_type
259
   Returns the default type for register N. */
260
 
261
static struct type *
262
v850_reg_virtual_type (int regnum)
263
{
264
  if (regnum < 0 || regnum >= E_NUM_REGS)
265
    internal_error (__FILE__, __LINE__,
266
                    "v850_register_virtual_type: illegal register number %d",
267
                    regnum);
268
  else if (regnum == E_PC_REGNUM)
269
    return builtin_type_uint32;
270
  else
271
    return builtin_type_int32;
272
}
273
 
274
static int
275
v850_type_is_scalar (struct type *t)
276
{
277
  return (TYPE_CODE (t) != TYPE_CODE_STRUCT
278
          && TYPE_CODE (t) != TYPE_CODE_UNION
279
          && TYPE_CODE (t) != TYPE_CODE_ARRAY);
280
}
281
 
282
/* Should call_function allocate stack space for a struct return?  */
283
static int
284
v850_use_struct_convention (int gcc_p, struct type *type)
285
{
286
  /* According to ABI:
287
   * return TYPE_LENGTH (type) > 8);
288
   */
289
 
290
  /* Current implementation in gcc: */
291
 
292
  int i;
293
  struct type *fld_type, *tgt_type;
294
 
295
  /* 1. The value is greater than 8 bytes -> returned by copying */
296
  if (TYPE_LENGTH (type) > 8)
297
    return 1;
298
 
299
  /* 2. The value is a single basic type -> returned in register */
300
  if (v850_type_is_scalar (type))
301
    return 0;
302
 
303
  /* The value is a structure or union with a single element
304
   * and that element is either a single basic type or an array of
305
   * a single basic type whoes size is greater than or equal to 4
306
   * -> returned in register */
307
  if ((TYPE_CODE (type) == TYPE_CODE_STRUCT
308
       || TYPE_CODE (type) == TYPE_CODE_UNION)
309
       && TYPE_NFIELDS (type) == 1)
310
    {
311
      fld_type = TYPE_FIELD_TYPE (type, 0);
312
      if (v850_type_is_scalar (fld_type) && TYPE_LENGTH (fld_type) >= 4)
313
        return 0;
314
 
315
      if (TYPE_CODE (fld_type) == TYPE_CODE_ARRAY)
316
        {
317
          tgt_type = TYPE_TARGET_TYPE (fld_type);
318
          if (v850_type_is_scalar (tgt_type) && TYPE_LENGTH (tgt_type) >= 4)
319
            return 0;
320
        }
321
    }
322
 
323
  /* The value is a structure whose first element is an integer or
324
   * a float, and which contains no arrays of more than two elements
325
   * -> returned in register */
326
  if (TYPE_CODE (type) == TYPE_CODE_STRUCT
327
      && v850_type_is_scalar (TYPE_FIELD_TYPE (type, 0))
328
      && TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) == 4)
329
    {
330
      for (i = 1; i < TYPE_NFIELDS (type); ++i)
331
        {
332
          fld_type = TYPE_FIELD_TYPE (type, 0);
333
          if (TYPE_CODE (fld_type) == TYPE_CODE_ARRAY)
334
            {
335
              tgt_type = TYPE_TARGET_TYPE (fld_type);
336
              if (TYPE_LENGTH (fld_type) >= 0 && TYPE_LENGTH (tgt_type) >= 0
337
                  && TYPE_LENGTH (fld_type) / TYPE_LENGTH (tgt_type) > 2)
338
                return 1;
339
            }
340
        }
341
      return 0;
342
    }
343
 
344
  /* The value is a union which contains at least one field which
345
   * would be returned in registers according to these rules
346
   * -> returned in register */
347
  if (TYPE_CODE (type) == TYPE_CODE_UNION)
348
    {
349
      for (i = 0; i < TYPE_NFIELDS (type); ++i)
350
        {
351
          fld_type = TYPE_FIELD_TYPE (type, 0);
352
          if (!v850_use_struct_convention (0, fld_type))
353
            return 0;
354
        }
355
    }
356
 
357
  return 1;
358
}
359
 
360
 
361
 
362
/* Structure for mapping bits in register lists to register numbers. */
363
struct reg_list
364
{
365
  long mask;
366
  int regno;
367
};
368
 
369
/* Helper function for v850_scan_prologue to handle prepare instruction. */
370
 
371
static void
372
handle_prepare (int insn, int insn2, CORE_ADDR * current_pc_ptr,
373
                struct prologue_info *pi, struct pifsr **pifsr_ptr)
374
{
375
  CORE_ADDR current_pc = *current_pc_ptr;
376
  struct pifsr *pifsr = *pifsr_ptr;
377
  long next = insn2 & 0xffff;
378
  long list12 = ((insn & 1) << 16) + (next & 0xffe0);
379
  long offset = (insn & 0x3e) << 1;
380
  static struct reg_list reg_table[] =
381
  {
382
    {0x00800, 20},              /* r20 */
383
    {0x00400, 21},              /* r21 */
384
    {0x00200, 22},              /* r22 */
385
    {0x00100, 23},              /* r23 */
386
    {0x08000, 24},              /* r24 */
387
    {0x04000, 25},              /* r25 */
388
    {0x02000, 26},              /* r26 */
389
    {0x01000, 27},              /* r27 */
390
    {0x00080, 28},              /* r28 */
391
    {0x00040, 29},              /* r29 */
392
    {0x10000, 30},              /* ep */
393
    {0x00020, 31},              /* lp */
394
    {0, 0}                        /* end of table */
395
  };
396
  int i;
397
 
398
  if ((next & 0x1f) == 0x0b)    /* skip imm16 argument */
399
    current_pc += 2;
400
  else if ((next & 0x1f) == 0x13)       /* skip imm16 argument */
401
    current_pc += 2;
402
  else if ((next & 0x1f) == 0x1b)       /* skip imm32 argument */
403
    current_pc += 4;
404
 
405
  /* Calculate the total size of the saved registers, and add it
406
     it to the immediate value used to adjust SP. */
407
  for (i = 0; reg_table[i].mask != 0; i++)
408
    if (list12 & reg_table[i].mask)
409
      offset += v850_register_raw_size (reg_table[i].regno);
410
  pi->frameoffset -= offset;
411
 
412
  /* Calculate the offsets of the registers relative to the value
413
     the SP will have after the registers have been pushed and the
414
     imm5 value has been subtracted from it. */
415
  if (pifsr)
416
    {
417
      for (i = 0; reg_table[i].mask != 0; i++)
418
        {
419
          if (list12 & reg_table[i].mask)
420
            {
421
              int reg = reg_table[i].regno;
422
              offset -= v850_register_raw_size (reg);
423
              pifsr->reg = reg;
424
              pifsr->offset = offset;
425
              pifsr->cur_frameoffset = pi->frameoffset;
426
#ifdef DEBUG
427
              printf_filtered ("\tSaved register r%d, offset %d", reg, pifsr->offset);
428
#endif
429
              pifsr++;
430
            }
431
        }
432
    }
433
#ifdef DEBUG
434
  printf_filtered ("\tfound ctret after regsave func");
435
#endif
436
 
437
  /* Set result parameters. */
438
  *current_pc_ptr = current_pc;
439
  *pifsr_ptr = pifsr;
440
}
441
 
442
 
443
/* Helper function for v850_scan_prologue to handle pushm/pushl instructions.
444
   FIXME: the SR bit of the register list is not supported; must check
445
   that the compiler does not ever generate this bit. */
446
 
447
static void
448
handle_pushm (int insn, int insn2, struct prologue_info *pi,
449
              struct pifsr **pifsr_ptr)
450
{
451
  struct pifsr *pifsr = *pifsr_ptr;
452
  long list12 = ((insn & 0x0f) << 16) + (insn2 & 0xfff0);
453
  long offset = 0;
454
  static struct reg_list pushml_reg_table[] =
455
  {
456
    {0x80000, E_PS_REGNUM},     /* PSW */
457
    {0x40000, 1},               /* r1 */
458
    {0x20000, 2},               /* r2 */
459
    {0x10000, 3},               /* r3 */
460
    {0x00800, 4},               /* r4 */
461
    {0x00400, 5},               /* r5 */
462
    {0x00200, 6},               /* r6 */
463
    {0x00100, 7},               /* r7 */
464
    {0x08000, 8},               /* r8 */
465
    {0x04000, 9},               /* r9 */
466
    {0x02000, 10},              /* r10 */
467
    {0x01000, 11},              /* r11 */
468
    {0x00080, 12},              /* r12 */
469
    {0x00040, 13},              /* r13 */
470
    {0x00020, 14},              /* r14 */
471
    {0x00010, 15},              /* r15 */
472
    {0, 0}                        /* end of table */
473
  };
474
  static struct reg_list pushmh_reg_table[] =
475
  {
476
    {0x80000, 16},              /* r16 */
477
    {0x40000, 17},              /* r17 */
478
    {0x20000, 18},              /* r18 */
479
    {0x10000, 19},              /* r19 */
480
    {0x00800, 20},              /* r20 */
481
    {0x00400, 21},              /* r21 */
482
    {0x00200, 22},              /* r22 */
483
    {0x00100, 23},              /* r23 */
484
    {0x08000, 24},              /* r24 */
485
    {0x04000, 25},              /* r25 */
486
    {0x02000, 26},              /* r26 */
487
    {0x01000, 27},              /* r27 */
488
    {0x00080, 28},              /* r28 */
489
    {0x00040, 29},              /* r29 */
490
    {0x00010, 30},              /* r30 */
491
    {0x00020, 31},              /* r31 */
492
    {0, 0}                        /* end of table */
493
  };
494
  struct reg_list *reg_table;
495
  int i;
496
 
497
  /* Is this a pushml or a pushmh? */
498
  if ((insn2 & 7) == 1)
499
    reg_table = pushml_reg_table;
500
  else
501
    reg_table = pushmh_reg_table;
502
 
503
  /* Calculate the total size of the saved registers, and add it
504
     it to the immediate value used to adjust SP. */
505
  for (i = 0; reg_table[i].mask != 0; i++)
506
    if (list12 & reg_table[i].mask)
507
      offset += v850_register_raw_size (reg_table[i].regno);
508
  pi->frameoffset -= offset;
509
 
510
  /* Calculate the offsets of the registers relative to the value
511
     the SP will have after the registers have been pushed and the
512
     imm5 value is subtracted from it. */
513
  if (pifsr)
514
    {
515
      for (i = 0; reg_table[i].mask != 0; i++)
516
        {
517
          if (list12 & reg_table[i].mask)
518
            {
519
              int reg = reg_table[i].regno;
520
              offset -= v850_register_raw_size (reg);
521
              pifsr->reg = reg;
522
              pifsr->offset = offset;
523
              pifsr->cur_frameoffset = pi->frameoffset;
524
#ifdef DEBUG
525
              printf_filtered ("\tSaved register r%d, offset %d", reg, pifsr->offset);
526
#endif
527
              pifsr++;
528
            }
529
        }
530
    }
531
#ifdef DEBUG
532
  printf_filtered ("\tfound ctret after regsave func");
533
#endif
534
 
535
  /* Set result parameters. */
536
  *pifsr_ptr = pifsr;
537
}
538
 
539
 
540
 
541
 
542
/* Function: scan_prologue
543
   Scan the prologue of the function that contains PC, and record what
544
   we find in PI.  Returns the pc after the prologue.  Note that the
545
   addresses saved in frame->saved_regs are just frame relative (negative
546
   offsets from the frame pointer).  This is because we don't know the
547
   actual value of the frame pointer yet.  In some circumstances, the
548
   frame pointer can't be determined till after we have scanned the
549
   prologue.  */
550
 
551
static CORE_ADDR
552
v850_scan_prologue (CORE_ADDR pc, struct prologue_info *pi)
553
{
554
  CORE_ADDR func_addr, prologue_end, current_pc;
555
  struct pifsr *pifsr, *pifsr_tmp;
556
  int fp_used;
557
  int ep_used;
558
  int reg;
559
  CORE_ADDR save_pc, save_end;
560
  int regsave_func_p;
561
  int r12_tmp;
562
 
563
  /* First, figure out the bounds of the prologue so that we can limit the
564
     search to something reasonable.  */
565
 
566
  if (find_pc_partial_function (pc, NULL, &func_addr, NULL))
567
    {
568
      struct symtab_and_line sal;
569
 
570
      sal = find_pc_line (func_addr, 0);
571
 
572
      if (func_addr == entry_point_address ())
573
        pi->start_function = 1;
574
      else
575
        pi->start_function = 0;
576
 
577
#if 0
578
      if (sal.line == 0)
579
        prologue_end = pc;
580
      else
581
        prologue_end = sal.end;
582
#else
583
      prologue_end = pc;
584
#endif
585
    }
586
  else
587
    {                           /* We're in the boondocks */
588
      func_addr = pc - 100;
589
      prologue_end = pc;
590
    }
591
 
592
  prologue_end = min (prologue_end, pc);
593
 
594
  /* Now, search the prologue looking for instructions that setup fp, save
595
     rp, adjust sp and such.  We also record the frame offset of any saved
596
     registers. */
597
 
598
  pi->frameoffset = 0;
599
  pi->framereg = E_SP_REGNUM;
600
  fp_used = 0;
601
  ep_used = 0;
602
  pifsr = pi->pifsrs;
603
  regsave_func_p = 0;
604
  save_pc = 0;
605
  save_end = 0;
606
  r12_tmp = 0;
607
 
608
#ifdef DEBUG
609
  printf_filtered ("Current_pc = 0x%.8lx, prologue_end = 0x%.8lx\n",
610
                   (long) func_addr, (long) prologue_end);
611
#endif
612
 
613
  for (current_pc = func_addr; current_pc < prologue_end;)
614
    {
615
      int insn;
616
      int insn2 = -1; /* dummy value */
617
 
618
#ifdef DEBUG
619
      printf_filtered ("0x%.8lx ", (long) current_pc);
620
      TARGET_PRINT_INSN (current_pc, &tm_print_insn_info);
621
#endif
622
 
623
      insn = read_memory_unsigned_integer (current_pc, 2);
624
      current_pc += 2;
625
      if ((insn & 0x0780) >= 0x0600)    /* Four byte instruction? */
626
        {
627
          insn2 = read_memory_unsigned_integer (current_pc, 2);
628
          current_pc += 2;
629
        }
630
 
631
      if ((insn & 0xffc0) == ((10 << 11) | 0x0780) && !regsave_func_p)
632
        {                       /* jarl <func>,10 */
633
          long low_disp = insn2 & ~(long) 1;
634
          long disp = (((((insn & 0x3f) << 16) + low_disp)
635
                        & ~(long) 1) ^ 0x00200000) - 0x00200000;
636
 
637
          save_pc = current_pc;
638
          save_end = prologue_end;
639
          regsave_func_p = 1;
640
          current_pc += disp - 4;
641
          prologue_end = (current_pc
642
                          + (2 * 3)     /* moves to/from ep */
643
                          + 4   /* addi <const>,sp,sp */
644
                          + 2   /* jmp [r10] */
645
                          + (2 * 12)    /* sst.w to save r2, r20-r29, r31 */
646
                          + 20);        /* slop area */
647
 
648
#ifdef DEBUG
649
          printf_filtered ("\tfound jarl <func>,r10, disp = %ld, low_disp = %ld, new pc = 0x%.8lx\n",
650
                           disp, low_disp, (long) current_pc + 2);
651
#endif
652
          continue;
653
        }
654
      else if ((insn & 0xffc0) == 0x0200 && !regsave_func_p)
655
        {                       /* callt <imm6> */
656
          long ctbp = read_register (E_CTBP_REGNUM);
657
          long adr = ctbp + ((insn & 0x3f) << 1);
658
 
659
          save_pc = current_pc;
660
          save_end = prologue_end;
661
          regsave_func_p = 1;
662
          current_pc = ctbp + (read_memory_unsigned_integer (adr, 2) & 0xffff);
663
          prologue_end = (current_pc
664
                          + (2 * 3)     /* prepare list2,imm5,sp/imm */
665
                          + 4   /* ctret */
666
                          + 20);        /* slop area */
667
 
668
#ifdef DEBUG
669
          printf_filtered ("\tfound callt,  ctbp = 0x%.8lx, adr = %.8lx, new pc = 0x%.8lx\n",
670
                           ctbp, adr, (long) current_pc);
671
#endif
672
          continue;
673
        }
674
      else if ((insn & 0xffc0) == 0x0780)       /* prepare list2,imm5 */
675
        {
676
          handle_prepare (insn, insn2, &current_pc, pi, &pifsr);
677
          continue;
678
        }
679
      else if (insn == 0x07e0 && regsave_func_p && insn2 == 0x0144)
680
        {                       /* ctret after processing register save function */
681
          current_pc = save_pc;
682
          prologue_end = save_end;
683
          regsave_func_p = 0;
684
#ifdef DEBUG
685
          printf_filtered ("\tfound ctret after regsave func");
686
#endif
687
          continue;
688
        }
689
      else if ((insn & 0xfff0) == 0x07e0 && (insn2 & 5) == 1)
690
        {                       /* pushml, pushmh */
691
          handle_pushm (insn, insn2, pi, &pifsr);
692
          continue;
693
        }
694
      else if ((insn & 0xffe0) == 0x0060 && regsave_func_p)
695
        {                       /* jmp after processing register save function */
696
          current_pc = save_pc;
697
          prologue_end = save_end;
698
          regsave_func_p = 0;
699
#ifdef DEBUG
700
          printf_filtered ("\tfound jmp after regsave func");
701
#endif
702
          continue;
703
        }
704
      else if ((insn & 0x07c0) == 0x0780        /* jarl or jr */
705
               || (insn & 0xffe0) == 0x0060     /* jmp */
706
               || (insn & 0x0780) == 0x0580)    /* branch */
707
        {
708
#ifdef DEBUG
709
          printf_filtered ("\n");
710
#endif
711
          break;                /* Ran into end of prologue */
712
        }
713
 
714
      else if ((insn & 0xffe0) == ((E_SP_REGNUM << 11) | 0x0240))               /* add <imm>,sp */
715
        pi->frameoffset += ((insn & 0x1f) ^ 0x10) - 0x10;
716
      else if (insn == ((E_SP_REGNUM << 11) | 0x0600 | E_SP_REGNUM))    /* addi <imm>,sp,sp */
717
        pi->frameoffset += insn2;
718
      else if (insn == ((E_FP_RAW_REGNUM << 11) | 0x0000 | E_SP_REGNUM))        /* mov sp,fp */
719
        {
720
          fp_used = 1;
721
          pi->framereg = E_FP_RAW_REGNUM;
722
        }
723
 
724
      else if (insn == ((E_R12_REGNUM << 11) | 0x0640 | E_R0_REGNUM))   /* movhi hi(const),r0,r12 */
725
        r12_tmp = insn2 << 16;
726
      else if (insn == ((E_R12_REGNUM << 11) | 0x0620 | E_R12_REGNUM))  /* movea lo(const),r12,r12 */
727
        r12_tmp += insn2;
728
      else if (insn == ((E_SP_REGNUM << 11) | 0x01c0 | E_R12_REGNUM) && r12_tmp)        /* add r12,sp */
729
        pi->frameoffset = r12_tmp;
730
      else if (insn == ((E_EP_REGNUM << 11) | 0x0000 | E_SP_REGNUM))    /* mov sp,ep */
731
        ep_used = 1;
732
      else if (insn == ((E_EP_REGNUM << 11) | 0x0000 | E_R1_REGNUM))    /* mov r1,ep */
733
        ep_used = 0;
734
      else if (((insn & 0x07ff) == (0x0760 | E_SP_REGNUM)               /* st.w <reg>,<offset>[sp] */
735
                || (fp_used
736
                    && (insn & 0x07ff) == (0x0760 | E_FP_RAW_REGNUM)))  /* st.w <reg>,<offset>[fp] */
737
               && pifsr
738
               && (((reg = (insn >> 11) & 0x1f) >= E_SAVE1_START_REGNUM && reg <= E_SAVE1_END_REGNUM)
739
                   || (reg >= E_SAVE2_START_REGNUM && reg <= E_SAVE2_END_REGNUM)
740
                 || (reg >= E_SAVE3_START_REGNUM && reg <= E_SAVE3_END_REGNUM)))
741
        {
742
          pifsr->reg = reg;
743
          pifsr->offset = insn2 & ~1;
744
          pifsr->cur_frameoffset = pi->frameoffset;
745
#ifdef DEBUG
746
          printf_filtered ("\tSaved register r%d, offset %d", reg, pifsr->offset);
747
#endif
748
          pifsr++;
749
        }
750
 
751
      else if (ep_used          /* sst.w <reg>,<offset>[ep] */
752
               && ((insn & 0x0781) == 0x0501)
753
               && pifsr
754
               && (((reg = (insn >> 11) & 0x1f) >= E_SAVE1_START_REGNUM && reg <= E_SAVE1_END_REGNUM)
755
                   || (reg >= E_SAVE2_START_REGNUM && reg <= E_SAVE2_END_REGNUM)
756
                 || (reg >= E_SAVE3_START_REGNUM && reg <= E_SAVE3_END_REGNUM)))
757
        {
758
          pifsr->reg = reg;
759
          pifsr->offset = (insn & 0x007e) << 1;
760
          pifsr->cur_frameoffset = pi->frameoffset;
761
#ifdef DEBUG
762
          printf_filtered ("\tSaved register r%d, offset %d", reg, pifsr->offset);
763
#endif
764
          pifsr++;
765
        }
766
 
767
#ifdef DEBUG
768
      printf_filtered ("\n");
769
#endif
770
    }
771
 
772
  if (pifsr)
773
    pifsr->framereg = 0; /* Tie off last entry */
774
 
775
  /* Fix up any offsets to the final offset.  If a frame pointer was created, use it
776
     instead of the stack pointer.  */
777
  for (pifsr_tmp = pi->pifsrs; pifsr_tmp && pifsr_tmp != pifsr; pifsr_tmp++)
778
    {
779
      pifsr_tmp->offset -= pi->frameoffset - pifsr_tmp->cur_frameoffset;
780
      pifsr_tmp->framereg = pi->framereg;
781
 
782
#ifdef DEBUG
783
      printf_filtered ("Saved register r%d, offset = %d, framereg = r%d\n",
784
                    pifsr_tmp->reg, pifsr_tmp->offset, pifsr_tmp->framereg);
785
#endif
786
    }
787
 
788
#ifdef DEBUG
789
  printf_filtered ("Framereg = r%d, frameoffset = %d\n", pi->framereg, pi->frameoffset);
790
#endif
791
 
792
  return current_pc;
793
}
794
 
795
/* Function: find_callers_reg
796
   Find REGNUM on the stack.  Otherwise, it's in an active register.
797
   One thing we might want to do here is to check REGNUM against the
798
   clobber mask, and somehow flag it as invalid if it isn't saved on
799
   the stack somewhere.  This would provide a graceful failure mode
800
   when trying to get the value of caller-saves registers for an inner
801
   frame.  */
802
 
803
CORE_ADDR
804
v850_find_callers_reg (struct frame_info *fi, int regnum)
805
{
806
  for (; fi; fi = fi->next)
807
    if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
808
      return generic_read_register_dummy (fi->pc, fi->frame, regnum);
809
    else if (fi->saved_regs[regnum] != 0)
810
      return read_memory_unsigned_integer (fi->saved_regs[regnum],
811
                                           v850_register_raw_size (regnum));
812
 
813
  return read_register (regnum);
814
}
815
 
816
/* Function: frame_chain
817
   Figure out the frame prior to FI.  Unfortunately, this involves
818
   scanning the prologue of the caller, which will also be done
819
   shortly by v850_init_extra_frame_info.  For the dummy frame, we
820
   just return the stack pointer that was in use at the time the
821
   function call was made.  */
822
 
823
CORE_ADDR
824
v850_frame_chain (struct frame_info *fi)
825
{
826
  struct prologue_info pi;
827
  CORE_ADDR callers_pc, fp;
828
 
829
  /* First, find out who called us */
830
  callers_pc = FRAME_SAVED_PC (fi);
831
  /* If caller is a call-dummy, then our FP bears no relation to his FP! */
832
  fp = v850_find_callers_reg (fi, E_FP_RAW_REGNUM);
833
  if (PC_IN_CALL_DUMMY (callers_pc, fp, fp))
834
    return fp;                  /* caller is call-dummy: return oldest value of FP */
835
 
836
  /* Caller is NOT a call-dummy, so everything else should just work.
837
     Even if THIS frame is a call-dummy! */
838
  pi.pifsrs = NULL;
839
 
840
  v850_scan_prologue (callers_pc, &pi);
841
 
842
  if (pi.start_function)
843
    return 0;                    /* Don't chain beyond the start function */
844
 
845
  if (pi.framereg == E_FP_RAW_REGNUM)
846
    return v850_find_callers_reg (fi, pi.framereg);
847
 
848
  return fi->frame - pi.frameoffset;
849
}
850
 
851
/* Function: skip_prologue
852
   Return the address of the first code past the prologue of the function.  */
853
 
854
CORE_ADDR
855
v850_skip_prologue (CORE_ADDR pc)
856
{
857
  CORE_ADDR func_addr, func_end;
858
 
859
  /* See what the symbol table says */
860
 
861
  if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
862
    {
863
      struct symtab_and_line sal;
864
 
865
      sal = find_pc_line (func_addr, 0);
866
 
867
      if (sal.line != 0 && sal.end < func_end)
868
        return sal.end;
869
      else
870
        /* Either there's no line info, or the line after the prologue is after
871
           the end of the function.  In this case, there probably isn't a
872
           prologue.  */
873
        return pc;
874
    }
875
 
876
/* We can't find the start of this function, so there's nothing we can do. */
877
  return pc;
878
}
879
 
880
/* Function: pop_frame
881
   This routine gets called when either the user uses the `return'
882
   command, or the call dummy breakpoint gets hit.  */
883
 
884
void
885
v850_pop_frame (void)
886
{
887
  struct frame_info *frame = get_current_frame ();
888
  int regnum;
889
 
890
  if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
891
    generic_pop_dummy_frame ();
892
  else
893
    {
894
      write_register (E_PC_REGNUM, FRAME_SAVED_PC (frame));
895
 
896
      for (regnum = 0; regnum < E_NUM_REGS; regnum++)
897
        if (frame->saved_regs[regnum] != 0)
898
          write_register (regnum,
899
                      read_memory_unsigned_integer (frame->saved_regs[regnum],
900
                                             v850_register_raw_size (regnum)));
901
 
902
      write_register (E_SP_REGNUM, FRAME_FP (frame));
903
    }
904
 
905
  flush_cached_frames ();
906
}
907
 
908
/* Function: push_arguments
909
   Setup arguments and RP for a call to the target.  First four args
910
   go in R6->R9, subsequent args go into sp + 16 -> sp + ...  Structs
911
   are passed by reference.  64 bit quantities (doubles and long
912
   longs) may be split between the regs and the stack.  When calling a
913
   function that returns a struct, a pointer to the struct is passed
914
   in as a secret first argument (always in R6).
915
 
916
   Stack space for the args has NOT been allocated: that job is up to us.
917
 */
918
 
919
CORE_ADDR
920
v850_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
921
                     int struct_return, CORE_ADDR struct_addr)
922
{
923
  int argreg;
924
  int argnum;
925
  int len = 0;
926
  int stack_offset;
927
 
928
  /* First, just for safety, make sure stack is aligned */
929
  sp &= ~3;
930
 
931
  /* The offset onto the stack at which we will start copying parameters
932
     (after the registers are used up) begins at 16 rather than at zero.
933
     I don't really know why, that's just the way it seems to work.  */
934
  stack_offset = 16;
935
 
936
  /* Now make space on the stack for the args. */
937
  for (argnum = 0; argnum < nargs; argnum++)
938
    len += ((TYPE_LENGTH (VALUE_TYPE (args[argnum])) + 3) & ~3);
939
  sp -= len + stack_offset;     /* possibly over-allocating, but it works... */
940
  /* (you might think we could allocate 16 bytes */
941
  /* less, but the ABI seems to use it all! )  */
942
 
943
  argreg = E_ARG0_REGNUM;
944
  /* the struct_return pointer occupies the first parameter-passing reg */
945
  if (struct_return)
946
    argreg++;
947
 
948
  /* Now load as many as possible of the first arguments into
949
     registers, and push the rest onto the stack.  There are 16 bytes
950
     in four registers available.  Loop thru args from first to last.  */
951
  for (argnum = 0; argnum < nargs; argnum++)
952
    {
953
      int len;
954
      char *val;
955
      char valbuf[v850_register_raw_size (E_ARG0_REGNUM)];
956
 
957
      if (!v850_type_is_scalar (VALUE_TYPE (*args))
958
          && TYPE_LENGTH (VALUE_TYPE (*args)) > E_MAX_RETTYPE_SIZE_IN_REGS)
959
        {
960
          store_address (valbuf, 4, VALUE_ADDRESS (*args));
961
          len = 4;
962
          val = valbuf;
963
        }
964
      else
965
        {
966
          len = TYPE_LENGTH (VALUE_TYPE (*args));
967
          val = (char *) VALUE_CONTENTS (*args);
968
        }
969
 
970
      while (len > 0)
971
        if (argreg <= E_ARGLAST_REGNUM)
972
          {
973
            CORE_ADDR regval;
974
 
975
            regval = extract_address (val, v850_register_raw_size (argreg));
976
            write_register (argreg, regval);
977
 
978
            len -= v850_register_raw_size (argreg);
979
            val += v850_register_raw_size (argreg);
980
            argreg++;
981
          }
982
        else
983
          {
984
            write_memory (sp + stack_offset, val, 4);
985
 
986
            len -= 4;
987
            val += 4;
988
            stack_offset += 4;
989
          }
990
      args++;
991
    }
992
  return sp;
993
}
994
 
995
/* Function: push_return_address (pc)
996
   Set up the return address for the inferior function call.
997
   Needed for targets where we don't actually execute a JSR/BSR instruction */
998
 
999
CORE_ADDR
1000
v850_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
1001
{
1002
  write_register (E_RP_REGNUM, CALL_DUMMY_ADDRESS ());
1003
  return sp;
1004
}
1005
 
1006
/* Function: frame_saved_pc
1007
   Find the caller of this frame.  We do this by seeing if E_RP_REGNUM
1008
   is saved in the stack anywhere, otherwise we get it from the
1009
   registers.  If the inner frame is a dummy frame, return its PC
1010
   instead of RP, because that's where "caller" of the dummy-frame
1011
   will be found.  */
1012
 
1013
CORE_ADDR
1014
v850_frame_saved_pc (struct frame_info *fi)
1015
{
1016
  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
1017
    return generic_read_register_dummy (fi->pc, fi->frame, E_PC_REGNUM);
1018
  else
1019
    return v850_find_callers_reg (fi, E_RP_REGNUM);
1020
}
1021
 
1022
 
1023
/* Function: fix_call_dummy
1024
   Pokes the callee function's address into the CALL_DUMMY assembly stub.
1025
   Assumes that the CALL_DUMMY looks like this:
1026
   jarl <offset24>, r31
1027
   trap
1028
 */
1029
 
1030
void
1031
v850_fix_call_dummy (char *dummy, CORE_ADDR sp, CORE_ADDR fun, int nargs,
1032
                     struct value **args, struct type *type, int gcc_p)
1033
{
1034
  long offset24;
1035
 
1036
  offset24 = (long) fun - (long) entry_point_address ();
1037
  offset24 &= 0x3fffff;
1038
  offset24 |= 0xff800000;       /* jarl <offset24>, r31 */
1039
 
1040
  store_unsigned_integer ((unsigned int *) &dummy[2], 2, offset24 & 0xffff);
1041
  store_unsigned_integer ((unsigned int *) &dummy[0], 2, offset24 >> 16);
1042
}
1043
 
1044
static CORE_ADDR
1045
v850_saved_pc_after_call (struct frame_info *ignore)
1046
{
1047
  return read_register (E_RP_REGNUM);
1048
}
1049
 
1050
static void
1051
v850_extract_return_value (struct type *type, char *regbuf, char *valbuf)
1052
{
1053
  CORE_ADDR return_buffer;
1054
 
1055
  if (!v850_use_struct_convention (0, type))
1056
    {
1057
      /* Scalar return values of <= 8 bytes are returned in
1058
         E_V0_REGNUM to E_V1_REGNUM. */
1059
      memcpy (valbuf,
1060
              &regbuf[REGISTER_BYTE (E_V0_REGNUM)],
1061
              TYPE_LENGTH (type));
1062
    }
1063
  else
1064
    {
1065
      /* Aggregates and return values > 8 bytes are returned in memory,
1066
         pointed to by R6. */
1067
      return_buffer =
1068
        extract_address (regbuf + REGISTER_BYTE (E_V0_REGNUM),
1069
                         REGISTER_RAW_SIZE (E_V0_REGNUM));
1070
 
1071
      read_memory (return_buffer, valbuf, TYPE_LENGTH (type));
1072
    }
1073
}
1074
 
1075
const static unsigned char *
1076
v850_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
1077
{
1078
  static unsigned char breakpoint[] = { 0x85, 0x05 };
1079
  *lenptr = sizeof (breakpoint);
1080
  return breakpoint;
1081
}
1082
 
1083
static CORE_ADDR
1084
v850_extract_struct_value_address (char *regbuf)
1085
{
1086
  return extract_address (regbuf + v850_register_byte (E_V0_REGNUM),
1087
                          v850_register_raw_size (E_V0_REGNUM));
1088
}
1089
 
1090
static void
1091
v850_store_return_value (struct type *type, char *valbuf)
1092
{
1093
  CORE_ADDR return_buffer;
1094
 
1095
  if (!v850_use_struct_convention (0, type))
1096
    write_register_bytes (REGISTER_BYTE (E_V0_REGNUM), valbuf,
1097
                          TYPE_LENGTH (type));
1098
  else
1099
    {
1100
      return_buffer = read_register (E_V0_REGNUM);
1101
      write_memory (return_buffer, valbuf, TYPE_LENGTH (type));
1102
    }
1103
}
1104
 
1105
static void
1106
v850_frame_init_saved_regs (struct frame_info *fi)
1107
{
1108
  struct prologue_info pi;
1109
  struct pifsr pifsrs[E_NUM_REGS + 1], *pifsr;
1110
  CORE_ADDR func_addr, func_end;
1111
 
1112
  if (!fi->saved_regs)
1113
    {
1114
      frame_saved_regs_zalloc (fi);
1115
 
1116
      /* The call dummy doesn't save any registers on the stack, so we
1117
         can return now.  */
1118
      if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
1119
        return;
1120
 
1121
      /* Find the beginning of this function, so we can analyze its
1122
         prologue. */
1123
      if (find_pc_partial_function (fi->pc, NULL, &func_addr, &func_end))
1124
        {
1125
          pi.pifsrs = pifsrs;
1126
 
1127
          v850_scan_prologue (fi->pc, &pi);
1128
 
1129
          if (!fi->next && pi.framereg == E_SP_REGNUM)
1130
            fi->frame = read_register (pi.framereg) - pi.frameoffset;
1131
 
1132
          for (pifsr = pifsrs; pifsr->framereg; pifsr++)
1133
            {
1134
              fi->saved_regs[pifsr->reg] = pifsr->offset + fi->frame;
1135
 
1136
              if (pifsr->framereg == E_SP_REGNUM)
1137
                fi->saved_regs[pifsr->reg] += pi.frameoffset;
1138
            }
1139
        }
1140
      /* Else we're out of luck (can't debug completely stripped code).
1141
         FIXME. */
1142
    }
1143
}
1144
 
1145
/* Function: init_extra_frame_info
1146
   Setup the frame's frame pointer, pc, and frame addresses for saved
1147
   registers.  Most of the work is done in scan_prologue().
1148
 
1149
   Note that when we are called for the last frame (currently active frame),
1150
   that fi->pc and fi->frame will already be setup.  However, fi->frame will
1151
   be valid only if this routine uses FP.  For previous frames, fi-frame will
1152
   always be correct (since that is derived from v850_frame_chain ()).
1153
 
1154
   We can be called with the PC in the call dummy under two circumstances.
1155
   First, during normal backtracing, second, while figuring out the frame
1156
   pointer just prior to calling the target function (see run_stack_dummy).  */
1157
 
1158
static void
1159
v850_init_extra_frame_info (int fromleaf, struct frame_info *fi)
1160
{
1161
  struct prologue_info pi;
1162
 
1163
  if (fi->next)
1164
    fi->pc = FRAME_SAVED_PC (fi->next);
1165
 
1166
  v850_frame_init_saved_regs (fi);
1167
}
1168
 
1169
static void
1170
v850_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
1171
{
1172
  write_register (E_ARG0_REGNUM, addr);
1173
}
1174
 
1175
static CORE_ADDR
1176
v850_target_read_fp (void)
1177
{
1178
  return read_register (E_FP_RAW_REGNUM);
1179
}
1180
 
1181
static struct gdbarch *
1182
v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1183
{
1184
  static LONGEST call_dummy_words[1] = { 0 };
1185
  struct gdbarch_tdep *tdep = NULL;
1186
  struct gdbarch *gdbarch;
1187
  int i;
1188
 
1189
  /* find a candidate among the list of pre-declared architectures. */
1190
  arches = gdbarch_list_lookup_by_info (arches, &info);
1191
  if (arches != NULL)
1192
    return (arches->gdbarch);
1193
 
1194
#if 0
1195
  tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
1196
#endif
1197
 
1198
  /* Change the register names based on the current machine type. */
1199
  if (info.bfd_arch_info->arch != bfd_arch_v850)
1200
    return 0;
1201
 
1202
  gdbarch = gdbarch_alloc (&info, 0);
1203
 
1204
  for (i = 0; v850_processor_type_table[i].regnames != NULL; i++)
1205
    {
1206
      if (v850_processor_type_table[i].mach == info.bfd_arch_info->mach)
1207
        {
1208
          v850_register_names = v850_processor_type_table[i].regnames;
1209
          tm_print_insn_info.mach = info.bfd_arch_info->mach;
1210
          break;
1211
        }
1212
    }
1213
 
1214
  /*
1215
   * Basic register fields and methods.
1216
   */
1217
  set_gdbarch_num_regs (gdbarch, E_NUM_REGS);
1218
  set_gdbarch_num_pseudo_regs (gdbarch, 0);
1219
  set_gdbarch_sp_regnum (gdbarch, E_SP_REGNUM);
1220
  set_gdbarch_fp_regnum (gdbarch, E_FP_REGNUM);
1221
  set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM);
1222
  set_gdbarch_register_name (gdbarch, v850_register_name);
1223
  set_gdbarch_register_size (gdbarch, v850_reg_size);
1224
  set_gdbarch_register_bytes (gdbarch, E_ALL_REGS_SIZE);
1225
  set_gdbarch_register_byte (gdbarch, v850_register_byte);
1226
  set_gdbarch_register_raw_size (gdbarch, v850_register_raw_size);
1227
  set_gdbarch_max_register_raw_size (gdbarch, v850_reg_size);
1228
  set_gdbarch_register_virtual_size (gdbarch, v850_register_raw_size);
1229
  set_gdbarch_max_register_virtual_size (gdbarch, v850_reg_size);
1230
  set_gdbarch_register_virtual_type (gdbarch, v850_reg_virtual_type);
1231
 
1232
  set_gdbarch_read_fp (gdbarch, v850_target_read_fp);
1233
 
1234
  /*
1235
   * Frame Info
1236
   */
1237
  set_gdbarch_init_extra_frame_info (gdbarch, v850_init_extra_frame_info);
1238
  set_gdbarch_frame_init_saved_regs (gdbarch, v850_frame_init_saved_regs);
1239
  set_gdbarch_frame_chain (gdbarch, v850_frame_chain);
1240
  set_gdbarch_get_saved_register (gdbarch, generic_unwind_get_saved_register);
1241
  set_gdbarch_saved_pc_after_call (gdbarch, v850_saved_pc_after_call);
1242
  set_gdbarch_frame_saved_pc (gdbarch, v850_frame_saved_pc);
1243
  set_gdbarch_skip_prologue (gdbarch, v850_skip_prologue);
1244
  set_gdbarch_frame_chain_valid (gdbarch, generic_file_frame_chain_valid);
1245
  set_gdbarch_frame_args_address (gdbarch, default_frame_address);
1246
  set_gdbarch_frame_locals_address (gdbarch, default_frame_address);
1247
 
1248
  /*
1249
   * Miscelany
1250
   */
1251
  /* Stack grows up. */
1252
  set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
1253
  /* PC stops zero byte after a trap instruction
1254
     (which means: exactly on trap instruction). */
1255
  set_gdbarch_decr_pc_after_break (gdbarch, 0);
1256
  /* This value is almost never non-zero... */
1257
  set_gdbarch_function_start_offset (gdbarch, 0);
1258
  /* This value is almost never non-zero... */
1259
  set_gdbarch_frame_args_skip (gdbarch, 0);
1260
  /* OK to default this value to 'unknown'. */
1261
  set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
1262
  /* W/o prototype, coerce float args to double. */
1263
  set_gdbarch_coerce_float_to_double (gdbarch, standard_coerce_float_to_double);
1264
 
1265
  /*
1266
   * Call Dummies
1267
   *
1268
   * These values and methods are used when gdb calls a target function.  */
1269
  set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
1270
  set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
1271
  set_gdbarch_push_return_address (gdbarch, v850_push_return_address);
1272
  set_gdbarch_deprecated_extract_return_value (gdbarch, v850_extract_return_value);
1273
  set_gdbarch_push_arguments (gdbarch, v850_push_arguments);
1274
  set_gdbarch_pop_frame (gdbarch, v850_pop_frame);
1275
  set_gdbarch_store_struct_return (gdbarch, v850_store_struct_return);
1276
  set_gdbarch_deprecated_store_return_value (gdbarch, v850_store_return_value);
1277
  set_gdbarch_deprecated_extract_struct_value_address (gdbarch, v850_extract_struct_value_address);
1278
  set_gdbarch_use_struct_convention (gdbarch, v850_use_struct_convention);
1279
  set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
1280
  set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
1281
  set_gdbarch_call_dummy_start_offset (gdbarch, 0);
1282
  set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
1283
  set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
1284
  set_gdbarch_call_dummy_length (gdbarch, 0);
1285
  set_gdbarch_pc_in_call_dummy (gdbarch, generic_pc_in_call_dummy);
1286
  set_gdbarch_call_dummy_p (gdbarch, 1);
1287
  set_gdbarch_call_dummy_words (gdbarch, call_dummy_nil);
1288
  set_gdbarch_sizeof_call_dummy_words (gdbarch, 0);
1289
  set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
1290
  /* set_gdbarch_call_dummy_stack_adjust */
1291
  set_gdbarch_fix_call_dummy (gdbarch, v850_fix_call_dummy);
1292
  set_gdbarch_breakpoint_from_pc (gdbarch, v850_breakpoint_from_pc);
1293
 
1294
  set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
1295
  set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
1296
  set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
1297
  set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
1298
 
1299
  set_gdbarch_extra_stack_alignment_needed (gdbarch, 0);
1300
 
1301
  return gdbarch;
1302
}
1303
 
1304
void
1305
_initialize_v850_tdep (void)
1306
{
1307
  tm_print_insn = print_insn_v850;
1308
  register_gdbarch_init (bfd_arch_v850, v850_gdbarch_init);
1309
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.