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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [or1k-tdep.c] - Blame information for rev 362

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 120 markom
/* Target-dependent code for the or1k architecture, for GDB, the GNU Debugger.
2
 
3
   Copyright 1988-1999, Free Software Foundation, Inc.
4
   Contributed by Alessandro Forin(af@cs.cmu.edu at CMU
5
   and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
6
 
7
   This file is part of GDB.
8
 
9
   This program is free software; you can redistribute it and/or modify
10
   it under the terms of the GNU General Public License as published by
11
   the Free Software Foundation; either version 2 of the License, or
12
   (at your option) any later version.
13
 
14
   This program is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
   GNU General Public License for more details.
18
 
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 59 Temple Place - Suite 330,
22
   Boston, MA 02111-1307, USA.  */
23
 
24
#include "demangle.h"
25
#include "defs.h"
26
#include "gdb_string.h"
27
#include "frame.h"
28
#include "inferior.h"
29
#include "symtab.h"
30
#include "value.h"
31
#include "gdbcmd.h"
32
#include "language.h"
33
#include "gdbcore.h"
34
#include "symfile.h"
35
#include "objfiles.h"
36
#include "gdbtypes.h"
37
#include "target.h"
38
 
39
#include "opcode/or32.h"
40
 
41
/* *INDENT-OFF* */
42
 
43
/* Group reg name size.  See or1k_reg_names.  */
44
int or1k_group_name_sizes[OR1K_NUM_SPR_GROUPS] = {
45 362 markom
  72,   0,   0, 6, 4, 2,
46
  22, 16, 1, 3, 2, 8};
47 120 markom
 
48
int or1k_group_name_start[OR1K_NUM_SPR_GROUPS] = {
49
  0,   0,   0, 253, 254, 256,
50 362 markom
  16, 248, 16, 16, 255, 0};
51 120 markom
 
52
/* Generated reg names (max valid alias index).
53
   See or1k_spr_reg_name.  */
54
int or1k_spr_valid_aliases[OR1K_NUM_SPR_GROUPS] = {
55
  2047+1, 2047+1, 2047+1, 258+1, 257+1, 257+1,
56 362 markom
  78+1, 263+1, 16+1, 18+1, 256+1, 7+1};
57 120 markom
 
58
/* Register names.  */
59
char *or1k_reg_names[] = {
60
 
61
  /* group 0 - general*/
62
  "VR", "UPR", "CPUCFGR", "DMMUCFGR", "IMMUCFGR", "DCCFGR", "ICCFGR", "DCFGR",
63
  "PCCFGR", "SPR0_9", "SPR0_10", "SPR0_11", "SPR0_12", "SPR0_13", "SPR0_14", "SPR0_15",
64
  "PC", "SR", "SPR0_18", "SPR0_19", "SPR0_20", "SPR0_21", "SPR0_22", "SPR0_23",
65
  "EPCR0", "EPCR1", "EPCR2", "EPCR3", "EPCR4", "EPCR5", "EPCR6", "EPCR7",
66
  "EPCR8", "EPCR9", "EPCR10", "EPCR11", "EPCR12", "EPCR13", "EPCR14", "EPCR15",
67
  "EEAR0","EEAR1", "EEAR2", "EEAR3", "EEAR4", "EEAR5", "EEAR6", "EEAR7",
68
  "EEAR8", "EEAR9", "EEAR10", "EEAR11", "EEAR12", "EEAR13", "EEAR14", "EEAR15",
69
  "ESR0", "ESR1", "ESR2", "ESR3", "ESR4", "ESR5", "ESR6", "ESR7",
70
  "ESR8", "ESR9", "ESR10", "ESR11", "ESR12", "ESR13", "ESR14", "ESR15",
71
 
72
  /* gpr+vf registers generated */
73
  /* group 1 - Data MMU - not listed, generated */
74
  /* group 2 - Instruction MMU - not listed, generated */
75
 
76
  /* group 3 - Data cache */
77
  "DCCR", "DCBIR", "DCBPR", "DCBFR", "DCBWR", "DCBLR",
78
 
79
  /* group 4 - Instruction cache */
80
  "ICCR", "ICBLR", "ICBIR", "ICBPR",
81
 
82
  /* group 5 - MAC */
83
  "MACLO", "MACHI",
84
 
85
  /* group 6 - debug */
86
  "DVR0", "DVR1", "DVR2", "DVR3", "DVR4", "DVR5", "DVR6", "DVR7",
87
  "DCR0", "DCR1", "DCR2", "DCR3", "DCR4", "DCR5", "DCR6", "DCR7",
88 362 markom
  "DMR1", "DMR2", "DCWR0","DCWR1","DSR",  "DRR",
89 120 markom
 
90
  /* group 7 - performance counters unit */
91
  "PCCM0", "PCMR1", "PCMR2", "PCMR3", "PCMR4", "PCMR5", "PCMR6", "PCMR7",
92
  "PCCR0", "PCCR1", "PCCR2", "PCCR3", "PCCR4", "PCCR5", "PCCR6", "PCCR7",
93
 
94
  /* group 8 - power management */
95
  "PMR",
96
 
97
  /* group 9 - PIC */
98
  "PICMR", "PICPR",
99
 
100
  /* group 10 - tick timer */
101
  "TTMR", "TTCR",
102
 
103
  /* group 11 - configuration */
104
  "CPUCFGR", "DMMUCFGR", "IMMUCFGR", "DCCFGR", "ICCFGR", "SPR11_5", "DCFGR", "PCCFGR"
105
};
106
 
107
static char *or1k_gdb_reg_names[] = {
108
 
109
  /* general purpose registers */
110 362 markom
  "R0", "R1(SP)", "R2(FP)", "R3(A0)", "R4(A1)", "R5(A2)", "R6(A3)", "R7(A4)",
111
  "R8(A5)", "R9(LR)", "R10", "R11(RV)", "R12", "R13", "R14", "R15",
112 120 markom
  "R16", "R17", "R18", "R19", "R20", "R21", "R22", "R23",
113
  "R24", "R25", "R26", "R27", "R28", "R29", "R30", "R31",
114
 
115 207 chris
  /* Modified by CZ 12/09/01 */
116 120 markom
  /* vector/floating point registers */
117
  "VFA0",  "VFA1",  "VFA2",  "VFA3",  "VFA4",  "VFA5",  "VFRV ", "VFR7",
118
  "VFR8",  "VFR9",  "VFR10", "VFR11", "VFR12", "VFR13", "VFR14", "VFR15",
119
  "VFR16", "VFR17", "VFR18", "VFR19", "VFR20", "VFR21", "VFR22", "VFR23",
120
  "VFR24", "VFR25", "VFR26", "VFR27", "VFR28", "VFR29", "VFR30", "VFR31",
121 207 chris
  "PC",    "SR",    "EPCR", "ExPC", "ExEAR", "ExSR"
122 120 markom
};
123
 
124
static char *or1k_group_names[] = {
125
  "SYS", "DMMU", "IMMU", "DCACHE", "ICACHE", "MAC", "DEBUG", "PERF", "POWER",
126
  "PIC", "TIMER"
127
};
128
 
129
/* Table of or1k signals.  */
130
static struct
131
  {
132
  char *name;
133
  char *string;
134
  } or1k_signals [NUM_OR1K_SIGNALS + 1] =
135
  {
136
    {"RSTE", "Reset Exception"},
137 207 chris
    {"BUSE", "Bus Error" },
138 120 markom
    {"DFPE", "Data Page Fault Exception"},
139
    {"IFPE", "Instruction Page Fault Exception"},
140
    {"LPINTE", "Low Priority Interrupt Exception"},
141
    {"AE", "Alignment Exception"},
142 207 chris
    {"ILINSE" "Illegal Instruction" },
143 120 markom
    {"HPINTE", "High Priority Interrupt Exception"},
144
    {"DME", "DTLB Miss Exception"},
145
    {"IME", "ITLB Miss Exception"},
146
    {"RE", "Range Exception"},
147
    {"SCE", "SCE Exception"},
148 207 chris
    {"BRKPTE", "Breakpoint Exception"},
149
    {"TRAPE", "Trap Exception"},
150 120 markom
    {NULL, NULL}
151
  };
152
 
153
const char *compare_to_names[NUM_CT_NAMES] =
154
  {
155
    "DISABLED", "FETCH", "LEA", "SEA", "LDATA", "SDATA", "AEA", "ADATA"
156
  };
157
 
158
const char *or1k_record_names[MAX_RECORD_NAMES] =
159
  {
160
    "PC", "LSEA", "LDATA", "SDATA", "READSPR", "WRITESPR", "INSTR"
161
  };
162
 
163
const char *or1k_is_names[MAX_IS_NAMES] =
164
  {
165
    "IF_NONE", "IF_NORMAL", "IF_BRANCH", "IF_DELAY"
166
  };
167
 
168
const char *or1k_ls_names[MAX_LS_NAMES] =
169
  {
170
    "LS_NONE", " ", "LBZ", "LBS", "LHZ", "LHS", "LWZ", "LWS",
171
    " ", " ", "SB", " ", "SH", " ", "SW", " "
172
  };
173
 
174
/* *INDENT-ON* */
175
 
176
/* The list of available "set or1k " and "show or1k " commands */
177
static struct cmd_list_element *htrace_cmdlist = NULL;
178
static struct cmd_list_element *htrace_mode_cmdlist = NULL;
179
 
180
/* List of all saved register addresses, produced by skip_prologue.
181
   Relative address to sp, not used if 0.  */
182
static int or1k_saved_reg_addr[NUM_REGS];
183
 
184
struct htrace_struct or1k_htrace;
185
struct hwatch_struct or1k_hwatch[MAX_HW_WATCHES];
186
int num_hw_watches = 0;
187
 
188
/* Trace data.  */
189
char trace_filename[TRACE_FILENAME_SIZE] = "trace.dat";
190
 
191
/* Size of trace file in records.  */
192
int trace_size = 0;
193
 
194
/* Previous values for buffer display.  */
195
static int prev_length = 10;
196
static int prev_from = 0;
197
 
198 207 chris
/* Define NEW_PC_HANDLING if you want to use the new style routines
199
   where control is given to the debug interface AFTER the exception
200
   has already been taken. */
201
 
202
#ifdef NEW_PC_HANDLING
203
 
204
/* Specialized read_pc routine. Looks at returned value. If value
205
   is detected inside the breakpoint exception vector, the actual
206
   value stored in EPC is returned instead. The breakpoint exception
207
   vector should consist of nothing more than an RTE and a NOP. Note
208
   that this mechanism prohibits the use of GDB in an environment
209
   where this restriction is not met, however this is not expected
210
   to cause a significant problem. Anyone wishing to use GDB can
211
   easily store the appropriate instructions at the vector, and if
212
   they're not using GDB, why the hell are they inserting breakpoint
213
   exceptions?...
214
*/
215
 
216
CORE_ADDR or1k_target_read_pc(int pid)
217
{
218
#if defined(PC_REGNUM) && defined(EPC_REGNUM)
219
  if(PC_REGNUM >= 0)
220
    {
221
      unsigned long pc_val = or1k_read_spr_reg(PC_SPRNUM);
222
 
223
      /* If we're currently at the breakpoint exception, get the logical PC
224
         from the exception register instead. */
225
      if(pc_val == 0xD00)
226
        {
227
          unsigned long sr_val = or1k_read_spr_reg(ESR_SPRNUM(CURRENT_CID));
228
 
229
          pc_val = or1k_read_spr_reg(EPC_SPRNUM(CURRENT_CID));
230
#if 0
231
          if(!(sr_val & 0x2000)) /* If ESR[DSX] is not set */
232
            pc_val += 4;
233
#endif
234
        }
235
      return pc_val;
236
    }
237
#endif
238
  internal_error ("or1k_target_read_pc");
239
  return 0;
240
}
241
 
242
void or1k_target_write_pc(CORE_ADDR pc,int pid)
243
{
244
#if defined(PC_REGNUM) && defined(EPC_REGNUM)
245
  if(PC_REGNUM >= 0)
246
    {
247
      unsigned long pc_val = or1k_read_spr_reg(PC_SPRNUM);
248
      if(pc_val == 0xD00)
249
        {
250
          unsigned long sr_val = or1k_read_spr_reg(ESR_SPRNUM(CURRENT_CID));
251
 
252
          if(or1k_read_spr_reg(EPC_SPRNUM(CURRENT_CID)) != pc)
253
            or1k_write_spr_reg(EPC_SPRNUM(CURRENT_CID), pc);
254
        }
255
      else
256
        {
257
          unsigned char break_bytes[4] = BRK_INSTR_STRUCT;
258
          unsigned long b_insn = ntohl(*((unsigned long*)break_bytes));
259
          unsigned long saved_insn = or1k_read_spr_reg((pc_val >> 2) + MEM_SPACE);
260
          unsigned long saved_sr = or1k_read_spr_reg(SR_SPRNUM);
261
          unsigned long saved_dmr1 = or1k_read_spr_reg(DMR1_SPRNUM);
262
          unsigned long working_sr = saved_sr;
263
          unsigned long working_dmr1 = saved_dmr1;
264
          unsigned long new_pc_val = pc_val;
265
 
266
          or1k_save_stall_state();
267
          /* Install a breakpoint */
268
          or1k_write_spr_reg((pc_val >> 2) + MEM_SPACE,b_insn);
269
 
270
          /* Make sure exceptions are enabled and interrupts
271
             are disabled */
272
          working_sr |= 0x02;  /* Exceptions enabled */
273
          working_sr &= ~0x04; /* Interrupts disabled */
274
          or1k_write_spr_reg(SR_SPRNUM,working_sr);
275
 
276
          /* Make sure we are in hardware single step... */
277
          dmr1 |= DMR1_ST;
278
          or1k_write_spr_reg(DMR1_SPRNUM, dmr1);
279
 
280
          or1k_do_1_processor_step();
281
          while((new_pc_val = or1k_read_spr_reg(PC_SPRNUM)) != 0xD00)
282
            {
283
              /* We still haven't managed to get into the exception.
284
                 Perhaps there was an exception pending already and
285
                 it jumped somewhere else? Let's try it again. */
286
 
287
              /* Restore the old instruction */
288
              or1k_write_spr_reg((pc_val >> 2) + MEM_SPACE, saved_insn);
289
              pc_val = new_pc_val;
290
 
291
              /* Install a new breakpoint */
292
              saved_insn = or1k_read_spr_reg(( pc_val >> 2) + MEM_SPACE);
293
              or1k_write_spr_reg((pc_val >> 2) + MEM_SPACE,b_insn);
294
 
295
              /* Again, make sure exceptions are enabled */
296
              working_sr = or1k_read_spr_reg(SR_SPRNUM);
297
              working_sr |= 0x02;  /* Exceptions enabled */
298
              working_sr &= ~0x04; /* Interrupts disabled */
299
              or1k_write_spr_reg(SR_SPRNUM,working_sr);
300
 
301
              or1k_do_1_processor_step();
302
            }
303
 
304
          /* Restore the state of everything */
305
#if 0
306
          if(saved_sr & 0x2000)
307
            or1k_write_spr_reg(EPC_SPRNUM(CURRENT_CID), pc);
308
          else
309
            or1k_write_spr_reg(EPC_SPRNUM(CURRENT_CID), pc-4);
310
#endif
311
          or1k_write_spr_reg(EPC_SPRNUM(CURRENT_CID), pc);
312
          or1k_write_spr_reg(ESR_SPRNUM(CURRENT_CID), saved_sr);
313
          or1k_write_spr_reg((pc_val >> 2) + MEM_SPACE, saved_insn);
314
 
315
          /* Step the processor twice to finish through the
316
             breakpoint instruction */
317
          or1k_do_1_processor_step();
318
          or1k_do_1_processor_step();
319
 
320
          or1k_restore_stall_state();
321
 
322
          /* Reset the single step mode */
323
          or1k_write_spr_reg(DMR1_SPRNUM,saved_dmr1);
324
        }
325
      return;
326
    }
327
#endif
328
  internal_error ("or1k_target_write_pc");
329
  return;
330
}
331
 
332
#endif /* NEW_PC_HANDLING */
333
 
334 120 markom
/* Converts regno to sprno.  or1k debug unit has GPRs mapped to SPRs,
335
   which are not compact, so we are mapping them for GDB.  */
336 207 chris
/* Rewritten by CZ 12/09/01 */
337 120 markom
int
338
or1k_regnum_to_sprnum (int regno)
339
{
340 207 chris
  if(regno < MAX_GPR_REGS)
341 120 markom
    return SPR_REG(SPR_SYSTEM_GROUP, regno + CURRENT_CID * MAX_GPR_REGS + SPR_GPR_START);
342 207 chris
 
343 120 markom
  if (regno < MAX_GPR_REGS + MAX_VF_REGS)
344
    return SPR_REG(SPR_SYSTEM_GROUP, regno - MAX_GPR_REGS
345
                   + CURRENT_CID * MAX_GPR_REGS + SPR_VFPR_START);
346 207 chris
 
347
  switch(regno)
348
    {
349
    case PS_REGNUM:         return SR_SPRNUM;
350
    case PC_REGNUM:         return PC_SPRNUM;
351 362 markom
    /*case CCR_REGNUM:        return CCR_SPRNUM(CURRENT_CID);*/
352
    case EPCR_REGNUM:        return EPCR_SPRNUM(CURRENT_CID);
353
    /*case EAR_REGNUM:        return EAR_SPRNUM(CURRENT_CID);
354
    case ESR_REGNUM:        return ESR_SPRNUM(CURRENT_CID);*/
355 207 chris
    default:
356
      error("Invalid register number!");
357
      break;
358
    }
359
 
360
  return 0;
361 120 markom
}
362
 
363
/* Builds and returns register name.  */
364
 
365
static char tmp_name[16];
366
static char *
367
or1k_spr_register_name (i)
368
     int i;
369
{
370
  int group = i >> SPR_GROUP_SIZE_BITS;
371
  int index = i & (SPR_GROUP_SIZE - 1);
372
  switch (group)
373
    {
374
      /* Names covered in or1k_reg_names.  */
375
    case 0:
376
 
377
      /* Generate upper names.  */
378
      if (index >= SPR_GPR_START)
379
        {
380
          if (index < SPR_VFPR_START)
381
            sprintf (tmp_name, "GPR%i", index - SPR_GPR_START);
382
          else
383
            sprintf (tmp_name, "VFR%i", index - SPR_VFPR_START);
384
          return (char *)&tmp_name;
385
        }
386
    case 3:
387
    case 4:
388
    case 5:
389
    case 6:
390
    case 7:
391
    case 8:
392
    case 9:
393
    case 10:
394
      {
395
        int group_start = 0;
396
        for (i = 0; i < group; i++)
397
          group_start += or1k_group_name_sizes[i];
398
 
399 362 markom
        index -= or1k_group_name_start[group];
400 120 markom
        if (index >= or1k_group_name_sizes[group])
401
          {
402
            sprintf (tmp_name, "SPR%i_%i", group, index);
403
            return (char *)&tmp_name;
404
          }
405
        else
406 362 markom
          return or1k_reg_names[group_start + index];
407 120 markom
      }
408
 
409
      /* Build names for DMMU group.  */
410
    case 1:
411
    case 2:
412
      strcpy (tmp_name, (group == 1)?"D":"I");
413
      switch (index)
414
        {
415
        case 16:
416
          return strcat (tmp_name, "MMUCR");
417
        case 17:
418
          return strcat (tmp_name, "MMUPR");
419
        case 18:
420
          return strcat (tmp_name, "TLBEIR");
421
        case 24:
422
          return strcat (tmp_name, "ATBMR0");
423
        case 25:
424
          return strcat (tmp_name, "ATBMR1");
425
        case 26:
426
          return strcat (tmp_name, "ATBMR2");
427
        case 27:
428
          return strcat (tmp_name, "ATBMR3");
429
        case 28:
430
          return strcat (tmp_name, "ATBTR0");
431
        case 29:
432
          return strcat (tmp_name, "ATBTR0");
433
        case 30:
434
          return strcat (tmp_name, "ATBTR0");
435
        case 31:
436
          return strcat (tmp_name, "ATBTR0");
437
        default:
438
          if (index >= 1024) {
439
            index -= 1024;
440
            sprintf (tmp_name, "%sTLBW%iMR%i", (group == 1)?"D":"I", index / 128, index % 128);
441
            return (char *)&tmp_name;
442
          }
443
          sprintf (tmp_name, "SPR%i_%i", group, index);
444
          return (char *)&tmp_name;
445
      }
446
    default:
447
      sprintf (tmp_name, "SPR%i_%i", group, index);
448
      return (char *)&tmp_name;
449
    }
450
}
451
 
452
/* Get register index in group from name.  Negative if no match.  */
453
 
454
static int
455
or1k_regno_from_name (group, name)
456
     int group;
457
     char *name;
458
{
459
  int i;
460
  if (toupper(name[0]) == 'S' && toupper(name[1]) == 'P' && toupper(name[2]) == 'R')
461
    {
462
      char *ptr_c;
463
      name += 3;
464
      i = (int) strtoul (name, &ptr_c, 10);
465
      if (*ptr_c != '_' || i != group)
466
        return -1;
467
      ptr_c++;
468
      i = (int) strtoul (name, &ptr_c, 10);
469
      if (*ptr_c)
470
        return -1;
471
      else return i;
472
    }
473 362 markom
  for (i = or1k_group_name_start[group]; i < or1k_spr_valid_aliases[group]; i++)
474 120 markom
    {
475
      char *s;
476
      s = or1k_spr_register_name (SPR_REG(group, i));
477
      if (strcasecmp (name, s) == 0)
478
        return i;
479
    }
480
  return -1;
481
}
482
 
483
/* Returns gdb register name.  */
484
 
485
char *
486
or1k_register_name (regno)
487
     int regno;
488
{
489
  return or1k_gdb_reg_names[regno];
490
}
491
 
492
/* Utility function to display vf regs.  */
493
 
494
static int
495
do_vf_register (regnum)
496
     int regnum;
497
{
498
  /* do values for FP (float) regs */
499
  char *raw_buffer;
500
 
501
   /* doubles extracted from raw hex data */
502
  double doub, flt;
503
  int inv1, inv3, byte;
504
 
505
  raw_buffer = (char *) alloca (OR1K_VF_REGSIZE);
506
 
507
  /* Get the data in raw format.  */
508
  if (read_relative_register_raw_bytes (regnum, raw_buffer))
509
    error ("can't read register %d (%s)", regnum, REGISTER_NAME (regnum));
510
 
511
  flt = unpack_double (builtin_type_float, raw_buffer, &inv1);
512
  doub = unpack_double (builtin_type_double, raw_buffer, &inv3);
513
 
514
  if (inv1)
515
    printf_filtered (" %-5s flt: <invalid float>", REGISTER_NAME (regnum));
516
  else
517
    printf_filtered (" %-5s flt:%-17.9g", REGISTER_NAME (regnum), flt);
518
  printf_filtered (inv3 ? " dbl: <invalid double> " :
519
                   " dbl: %-24.17g ", doub);
520
 
521
  /* pad small registers */
522
  for (byte = 0; byte < (OR1K_GPR_REGSIZE - REGISTER_VIRTUAL_SIZE (regnum)); byte++)
523
    printf_filtered ("  ");
524
 
525
  /* Now print the register value in hex, endian order. */
526
  if (TARGET_BYTE_ORDER == BIG_ENDIAN)
527
    for (byte = REGISTER_RAW_SIZE (regnum) - REGISTER_VIRTUAL_SIZE (regnum);
528
         byte < REGISTER_RAW_SIZE (regnum);
529
         byte++)
530
      printf_filtered ("%02x", (unsigned char) raw_buffer[byte]);
531
  else
532
    for (byte = REGISTER_VIRTUAL_SIZE (regnum) - 1;
533
         byte >= 0;
534
         byte--)
535
      printf_filtered ("%02x", (unsigned char) raw_buffer[byte]);
536
  printf_filtered ("\n");
537
 
538
  regnum++;
539
  return regnum;
540
}
541
 
542
/* Print a row's worth of GP (int) registers, with name labels above */
543
 
544
static int
545
do_gp_register_row (regnum)
546
     int regnum;
547
{
548
  /* do values for GP (int) regs */
549
  char raw_buffer[MAX_REGISTER_RAW_SIZE];
550
 
551
  /* display cols per row */
552
  int ncols = (OR1K_64BIT_IMPLEMENTATION ? 4 : 8);
553
  int col, byte;
554
  int start_regnum = regnum;
555
  int numregs = NUM_REGS;
556
 
557
  /* For GP registers, we print a separate row of names above the vals */
558
  printf_filtered ("     ");
559
  for (col = 0; col < ncols && regnum < numregs; regnum++)
560
    {
561
      if (*REGISTER_NAME (regnum) == '\0')
562
        continue;               /* unused register */
563
      if (OR1K_IS_VF(regnum))
564
        break;                  /* end the row: reached VF register */
565
      printf_filtered (OR1K_64BIT_IMPLEMENTATION ? "%17s" : "%9s",
566
                       REGISTER_NAME (regnum));
567
      col++;
568
    }
569
  printf_filtered ("\n      ");
570
 
571
  regnum = start_regnum;        /* go back to start of row */
572
 
573
  /* now print the values in hex, 4 or 8 to the row */
574
  for (col = 0; col < ncols && regnum < numregs; regnum++)
575
    {
576
      /* unused register? */
577
      if (*REGISTER_NAME (regnum) == '\0')
578
        continue;
579
 
580
      /* end row: reached VF register? */
581
      if (OR1K_IS_VF(regnum))
582
        break;
583
 
584
      /* OK: get the data in raw format.  */
585
      if (read_relative_register_raw_bytes (regnum, raw_buffer))
586
        error ("can't read register %d (%s)", regnum, REGISTER_NAME (regnum));
587
 
588
      /* pad small registers */
589
      for (byte = 0; byte < (OR1K_GPR_REGSIZE - REGISTER_VIRTUAL_SIZE (regnum)); byte++)
590
        printf_filtered ("  ");
591
 
592
      /* Now print the register value in hex, endian order. */
593
      if (TARGET_BYTE_ORDER == BIG_ENDIAN)
594
        for (byte = REGISTER_RAW_SIZE (regnum) - REGISTER_VIRTUAL_SIZE (regnum);
595
             byte < REGISTER_RAW_SIZE (regnum);
596
             byte++)
597
          printf_filtered ("%02x", (unsigned char) raw_buffer[byte]);
598
      else
599
        for (byte = REGISTER_VIRTUAL_SIZE (regnum) - 1;
600
             byte >= 0;
601
             byte--)
602
          printf_filtered ("%02x", (unsigned char) raw_buffer[byte]);
603
      printf_filtered (" ");
604
      col++;
605
    }
606
 
607
  /* ie. if we actually printed anything... */
608
  if (col > 0)
609
    printf_filtered ("\n");
610
 
611
  return regnum;
612
}
613
 
614
/* Replacement for generic do_registers_info.
615
   Print regs in pretty columns.  */
616
 
617
static void
618
print_register (regnum, all)
619
     int regnum, all;
620
{
621
  int offset;
622
  char raw_buffer[MAX_REGISTER_RAW_SIZE];
623
 
624
  /* Get the data in raw format.  */
625
  if (read_relative_register_raw_bytes (regnum, raw_buffer))
626
    {
627
      printf_filtered ("%s: [Invalid]", REGISTER_NAME (regnum));
628
      return;
629
    }
630
 
631
  /* If virtual format is floating, print it that way.  */
632
  if (OR1K_IS_VF (regnum))
633
    do_vf_register (regnum);
634
  else
635
    {
636
      int byte;
637
      printf_filtered ("%-16s\t", REGISTER_NAME (regnum));
638
 
639
      /* pad small registers */
640
      for (byte = 0; byte < (OR1K_GPR_REGSIZE - REGISTER_VIRTUAL_SIZE (regnum)); byte++)
641
        printf_filtered ("  ");
642
 
643
      /* Now print the register value in hex, endian order. */
644
      if (TARGET_BYTE_ORDER == BIG_ENDIAN)
645
        for (byte = REGISTER_RAW_SIZE (regnum) - REGISTER_VIRTUAL_SIZE (regnum);
646
             byte < REGISTER_RAW_SIZE (regnum);
647
             byte++)
648
          printf_filtered ("%02x", (unsigned char) raw_buffer[byte]);
649
      else
650
        for (byte = REGISTER_VIRTUAL_SIZE (regnum) - 1;
651
             byte >= 0;
652
             byte--)
653
          printf_filtered ("%02x", (unsigned char) raw_buffer[byte]);
654
      printf_filtered (" ");
655
    }
656
}
657
 
658
/* DO_REGISTERS_INFO: called by "info register" command */
659
 
660
void
661
or1k_do_registers_info (regnum, fpregs)
662
     int regnum;
663
     int fpregs;
664
{
665
  if (fpregs && !or1k_implementation.vf_present)
666
    {
667
      warning ("VF register set not present in this implementation.");
668
      fpregs = 0;
669
    }
670
  if (regnum != -1)
671
    {
672
      /* do one specified register */
673
      if (*(REGISTER_NAME (regnum)) == '\0')
674
        error ("Not a valid register for the current processor type");
675
 
676
      print_register (regnum, 0);
677
      printf_filtered ("\n");
678
    }
679
  else
680
    /* do all (or most) registers */
681
    {
682
      regnum = 0;
683
      while (regnum < NUM_REGS)
684
        {
685
          if (OR1K_IS_VF (regnum))
686
            /* true for "INFO ALL-REGISTERS" command */
687
            if (fpregs)
688
              /* FP regs */
689
              regnum = do_vf_register (regnum);
690
            else
691
              /* skip floating point regs */
692
              regnum++;
693
          else
694
            /* GP (int) regs */
695
            regnum = do_gp_register_row (regnum);
696
        }
697
    }
698
}
699
 
700
/* Given the address at which to insert a breakpoint (BP_ADDR),
701
   what will that breakpoint be?
702
 
703
   For or1k, we have a breakpoint instruction. Since all or1k
704
   instructions are 32 bits, this is all we need, regardless of
705
   address. K is not used.  */
706
 
707
unsigned char *
708
or1k_breakpoint_from_pc (bp_addr, bp_size)
709
     CORE_ADDR * bp_addr;
710
     int *bp_size;
711
{
712
  static char breakpoint[] = BRK_INSTR_STRUCT;
713
  *bp_size = OR1K_INSTLEN;
714
  return breakpoint;
715
}
716
 
717
/* Return the string for a signal.
718
   Replacement for target_signal_to_string (sig).  NOT USED.  */
719
 
720
char
721
*or1k_signal_to_string (sig)
722
     enum target_signal sig;
723
{
724
  if ((sig >= TARGET_SIGNAL_FIRST) && (sig <= TARGET_SIGNAL_LAST))
725
    return or1k_signals[sig].string;
726
  else
727
    if (sig <= TARGET_SIGNAL_LAST + NUM_OR1K_SIGNALS)
728
      return or1k_signals[sig - TARGET_SIGNAL_LAST].string;
729
    else
730
      return 0;
731
}
732
 
733
/* Return the name for a signal.  */
734
 
735
char *
736
or1k_signal_to_name (sig)
737
     enum target_signal sig;
738
{
739
  if (sig >= TARGET_SIGNAL_LAST)
740
    if (sig <= TARGET_SIGNAL_LAST + NUM_OR1K_SIGNALS)
741
      return or1k_signals[sig - TARGET_SIGNAL_LAST].name;
742
    else
743
 
744
    /* I think the code which prints this will always print it along with
745
       the string, so no need to be verbose.  */
746
      return "?";
747
  if (sig == TARGET_SIGNAL_UNKNOWN)
748
    return "?";
749
  return 0;
750
}
751
 
752
/* Given a name, return its signal.  NOT USED.  */
753
enum target_signal
754
or1k_signal_from_name (name)
755
     char *name;
756
{
757
  enum target_signal sig;
758
 
759
  /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
760
     for TARGET_SIGNAL_SIGCHLD.  SIGIOT, on the other hand, is more
761
     questionable; seems like by now people should call it SIGABRT
762
     instead.  */
763
 
764
  /* This ugly cast brought to you by the native VAX compiler.  */
765
  for (sig = TARGET_SIGNAL_FIRST;
766
       or1k_signal_to_name (sig) != NULL;
767
       sig = (enum target_signal) ((int) sig + 1))
768
    if (STREQ (name, or1k_signal_to_name (sig)))
769
      return sig;
770
  return TARGET_SIGNAL_UNKNOWN;
771
}
772
 
773
/* Given a return value in `regbuf' with a type `valtype', extract and
774
   copy its value into `valbuf'. */
775
 
776
void
777
or1k_extract_return_value (valtype, regbuf, valbuf)
778
     struct type *valtype;
779
     char regbuf[REGISTER_BYTES];
780
     char *valbuf;
781
{
782
  if (TYPE_CODE_FLT == TYPE_CODE (valtype))
783
    memcpy (valbuf, &regbuf[REGISTER_BYTE (VFRV_REGNUM)], TYPE_LENGTH (valtype));
784
  else
785
    memcpy (valbuf, &regbuf[REGISTER_BYTE (RV_REGNUM)], TYPE_LENGTH (valtype));
786
}
787
 
788 207 chris
/* CZ -- 25/09/01 -- The prologue handling code has been rewritten
789
   to bring it inline with the new C compiler and various changes
790
   that have been made. The code below expects to see various
791
   instructions that are identified by states. States are ordered
792
   and should flow from one to the next. If a state is encountered
793
   out of order, it is assumed to be function code and not
794
   prologue, so the prologue parsing is terminated. I've tried
795
   several real world tests from the C compiler, and this seems
796
   to recognize the transition from prologue to code even under
797
   a worst case (21 instructions) scenario. */
798 120 markom
 
799 207 chris
typedef enum {
800
  PrologueStateMachineStart,
801
  PrologueStateMachineFrameInitialized,
802
  PrologueStateMachineFrameSaved,
803
  PrologueStateMachineFrameAdjusted,
804
  PrologueStateMachineRegisterSaved,
805
  PrologueStateMachineParameterSaved,
806
  PrologueStateMachineInvalid,
807
} FunctionPrologueStates;
808 120 markom
 
809 207 chris
/* Parse the insn and save the arguments */
810
static FunctionPrologueStates getPrologueInsnType(unsigned long insn,
811
                                                  int* arg1,int* arg2)
812 120 markom
{
813 207 chris
  int code = insn >> 26;
814
  int state = PrologueStateMachineInvalid;
815
  int op1,op2;
816
  short offset;
817 120 markom
 
818 207 chris
  switch(code)
819
    {
820
    case 0x27:  /* l.addi */
821
      op1 = (insn & 0x03E00000) >> 21;
822
      op2 = (insn & 0x001F0000) >> 16;
823
      if(op1 == 1 && op2 == 1)
824
        {
825
          offset = insn & 0xFFFF;
826
          state = PrologueStateMachineFrameInitialized;
827
        }
828
      else if(op1 == 2 && op2 == 1)
829
        {
830
          offset = insn & 0xFFFF;
831
          state = PrologueStateMachineFrameAdjusted;
832
        }
833
      *arg1 = op1;
834
      *arg2 = offset;
835
      break;
836
    case 0x35:  /* l.sw */
837
      op1 = (insn & 0x001F0000) >> 16;
838
      op2 = (insn & 0x0000F800) >> 11;
839
      offset = (insn & 0x000007FF) |
840
        ((insn & 0x03E00000) >> 10);
841
 
842
      if(op1 == 1)
843
        state = (op2 == 2) ? PrologueStateMachineFrameSaved :
844
          PrologueStateMachineRegisterSaved;
845
      else if(op1 == 2)
846
        state = PrologueStateMachineParameterSaved;
847
      *arg1 = op2;
848
      *arg2 = offset;
849
      break;
850
    default:    /* unknown */
851
      break;
852
    }
853
 
854
  return state;
855
}
856
 
857
CORE_ADDR or1k_skip_prologue (CORE_ADDR pc)
858
{
859
  int frame_size = 0,i;
860
  FunctionPrologueStates state = PrologueStateMachineStart;
861
  CORE_ADDR t_pc;
862
 
863
  /*
864
     Maximum prologue: save even reg's 10-30 (11 insns)
865
     save params passed in regs (6 insns)
866
     adjust stack (1 insn), adjust frame (1 insn),
867
     save old frame pointer (1 insn),
868
     save old link register (1 insn)
869
  */
870
  static const int MAX_PROLOGUE_LENGTH = 21;
871
 
872 120 markom
  for (i = 0; i < MAX_GPR_REGS; i++)
873
    or1k_saved_reg_addr[i] = -1;
874
 
875 362 markom
  /* Is there a prologue?  */
876
  inst = or1k_fetch_instruction (pc);
877
  if ((inst & 0xfc1ff800) != 0xd4011000) return pc; /* l.sw I(r1),r2 */
878
  or1k_saved_reg_addr[2] = offset++;
879
  inst = or1k_fetch_instruction (pc + OR1K_INSTLEN);
880
  if ((inst & 0xFFFF0000) != 0x9c410000) return pc; /* l.addi r2,r1,I */
881
  pc += 2 * OR1K_INSTLEN;
882
  inst = or1k_fetch_instruction (pc);
883
  if ((inst & 0xFFFF0000) != 0x9c210000) return pc; /* l.addi r1,r1,I */
884
  pc += OR1K_INSTLEN;
885
 
886
  /* Skip stored registers.  */
887
  inst = or1k_fetch_instruction (pc);
888
  while ((inst & 0xfc1ff800) != 0xd4020000)  /* l.sw 0x0(r2),rx */
889 207 chris
    {
890 362 markom
      /* get saved reg. */
891
      or1k_saved_reg_addr[(inst >> 11) & 0x1f] = offset++;
892
      pc += OR1K_INSTLEN;
893
      inst = or1k_fetch_instruction (pc);
894 120 markom
    }
895 207 chris
 
896
  return t_pc;
897 120 markom
}
898
 
899
/* Determines whether this function has frame.  */
900
 
901
int
902
or1k_frameless_function_invocation (struct frame_info *fi)
903
{
904
  CORE_ADDR func_start, after_prologue;
905
  int frameless;
906
  func_start = (get_pc_function_start ((fi)->pc) + FUNCTION_START_OFFSET);
907
  after_prologue = SKIP_PROLOGUE (func_start);
908
 
909
  /* If we don't skip pc, we don't have even shortest possible  prologue.  */
910
  frameless = (after_prologue <= func_start);
911
  return frameless;
912
}
913
 
914
/* Given a GDB frame, determine the address of the calling function's frame.
915
   This will be used to create a new GDB frame struct, and then
916
   INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame. */
917
 
918
CORE_ADDR
919
or1k_frame_chain (frame)
920
     struct frame_info *frame;
921
{
922
  CORE_ADDR fp;
923
  if (USE_GENERIC_DUMMY_FRAMES)
924
    {
925
      if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
926
        /* dummy frame same as caller's frame */
927
        return frame->frame;
928
    }
929
 
930
  if (inside_entry_file (frame->pc) ||
931
      frame->pc == entry_point_address ())
932
    return 0;
933
 
934
  if (frame->signal_handler_caller)
935
    fp = read_memory_integer (frame->frame, 4);
936
  else if (frame->next != NULL
937
           && frame->next->signal_handler_caller
938
           && FRAMELESS_FUNCTION_INVOCATION (frame))
939
    /* A frameless function interrupted by a signal did not change the
940
       frame pointer.  */
941
    fp = FRAME_FP (frame);
942
  else
943 207 chris
    {
944
      unsigned long func_pc = get_pc_function_start(frame->pc);
945
      unsigned long insn = read_memory_integer(func_pc,4);
946
      int i;
947
      int offset = 0;
948 120 markom
 
949 207 chris
      /* The first instruction should be the number of bytes
950
         in our frame. If it isn't we're in trouble because
951
         the function is without a prologue... */
952
      if(((insn & 0xFC000000) == 0x9C000000) &&
953
         ((insn & 0x03E00000) == 0x00200000) &&
954
         ((insn & 0x001F0000) == 0x00010000))
955
        {
956
          short off = insn & 0xFFFF;
957
 
958
          /* Look for the storage of the frame pointer in the
959
             function prologue.. */
960
          for(i=1;i<20;i++)
961
            {
962
              unsigned long insn = read_memory_integer(func_pc+4*i,4);
963
 
964
              /* If bits are 31 - 26 are %110101,
965
                 and bits 20 - 16 are %00001,
966
                 and bits 15 - 11 are %00010,
967
                 then our frame pointer lies at the offset specified
968
                 by bits [25-21][10-0]. */
969
 
970
              int code = insn >> 26;
971
              int r1    = (insn & 0x001F0000) >> 16;
972
              int r2    = (insn & 0x0000F800) >> 11;
973
              int idx_h = (insn & 0x03E00000) >> 10;
974
              int idx   = (insn & 0x000007FF) | idx_h;
975
 
976
              if(code == 0x35 && r1 == 1 && r2 == 2)
977
                {
978
                  offset = off + idx;
979
                  break;
980
                }
981
            }
982
        }
983
 
984
      fp = read_memory_integer (frame->frame + offset, 4);
985
    }
986
 
987 120 markom
  if (USE_GENERIC_DUMMY_FRAMES)
988
    {
989
      CORE_ADDR fpp, lr;
990
 
991
      lr = read_register (LR_REGNUM);
992
      if (lr == entry_point_address ())
993
        if (fp != 0 && (fpp = read_memory_integer (fp, 4)) != 0)
994
          if (PC_IN_CALL_DUMMY (lr, fpp, fpp))
995
            return fpp;
996
    }
997
 
998
  return fp;
999
}
1000
 
1001
/* The code to store, into a struct frame_saved_regs,
1002
   the addresses of the saved registers of frame described by FRAME_INFO.
1003
   This includes special registers such as pc and fp saved in special
1004
   ways in the stack frame.  sp is even more special:
1005
   the address we return for it IS the sp for the next frame.  */
1006
void
1007
or1k_init_saved_regs (struct frame_info *fi)
1008
{
1009
  int i;
1010
  CORE_ADDR frame_addr;
1011 207 chris
  CORE_ADDR func_pc = get_pc_function_start ((fi)->pc) + FUNCTION_START_OFFSET;
1012
  int frame_size;
1013
  int pc_found = 0;
1014
 
1015 120 markom
  frame_saved_regs_zalloc (fi);
1016
 
1017
  /* Skip prologue sets or1k_saved_reg_addr[], we will use it later.  */
1018 207 chris
  or1k_skip_prologue (func_pc);
1019 120 markom
 
1020 207 chris
  frame_size = or1k_saved_reg_addr[1];
1021
  or1k_saved_reg_addr[1] = -1;
1022
 
1023
  /* If the frame_size is less than 0, we have hit an assembly
1024
     routine which we can't traverse beyond. Let's give up here,
1025
     because attempting to continue will only lead to trouble. */
1026
  if(frame_size < 0)
1027
    {
1028
      printf("Found a function without a prologue at 0x%08x\n",func_pc);
1029
      printf("Frame pc was at 0x%08x\n",fi->pc);
1030
      return;
1031
    }
1032
 
1033 120 markom
  for (i = 0; i < NUM_GPR_REGS + NUM_VF_REGS; i++)
1034
    if (or1k_saved_reg_addr[i] >= 0)
1035 207 chris
      fi->saved_regs[i] = fi->frame - or1k_saved_reg_addr[i];
1036
 
1037
  /* We want to make sure we fill in the PC with the value of the
1038
     r9 register from the NEXT frame, and that the value of r1 is
1039
     the correct value of r1 for the next frame, which can be
1040
     calculated by adding the frame_size to the frame pointer. */
1041
  fi->saved_regs[1] = fi->frame - frame_size;
1042
 
1043
  if(fi->saved_regs[LR_REGNUM])
1044
    fi->saved_regs[PC_REGNUM] = read_memory_integer(fi->saved_regs[LR_REGNUM],4);
1045
  else
1046
    fi->saved_regs[PC_REGNUM] = read_register(LR_REGNUM);
1047 120 markom
}
1048
 
1049
static CORE_ADDR
1050
read_next_frame_reg (fi, regno)
1051
     struct frame_info *fi;
1052
     int regno;
1053
{
1054
  for (; fi; fi = fi->next)
1055
    {
1056
      /* We have to get the saved sp from the sigcontext
1057
         if it is a signal handler frame.  */
1058
      if (regno == SP_REGNUM && !fi->signal_handler_caller)
1059
        return fi->frame;
1060
      else
1061
        {
1062
          if (fi->saved_regs == NULL)
1063
            or1k_init_saved_regs (fi);
1064
          if (fi->saved_regs[regno])
1065 207 chris
            {
1066
              if(regno == SP_REGNUM || regno == PC_REGNUM)
1067
                return fi->saved_regs[regno];
1068
              else
1069
                return read_memory_integer (ADDR_BITS_REMOVE (fi->saved_regs[regno]), OR1K_GPR_REGSIZE);
1070
            }
1071 120 markom
        }
1072
    }
1073
  return read_register (regno);
1074
}
1075
 
1076
/* Find the caller of this frame.  We do this by seeing if LR_REGNUM
1077
   is saved in the stack anywhere, otherwise we get it from the
1078
   registers.  */
1079
 
1080
CORE_ADDR
1081
or1k_frame_saved_pc (fi)
1082
     struct frame_info *fi;
1083
{
1084
  CORE_ADDR saved_pc;
1085
 
1086
  /* We have to get the saved pc from the sigcontext
1087
     if it is a signal handler frame.  */
1088
  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
1089
    saved_pc = read_memory_integer (fi->frame, OR1K_GPR_REGSIZE);
1090
  else
1091
    saved_pc = read_next_frame_reg (fi, PC_REGNUM);
1092
 
1093
  return ADDR_BITS_REMOVE (saved_pc);
1094
}
1095
 
1096
/* Discard from the stack the innermost frame, restoring all registers.  */
1097
 
1098
void
1099
or1k_pop_frame ()
1100
{
1101
  register int regnum;
1102
  struct frame_info *frame = get_current_frame ();
1103
  CORE_ADDR new_sp = FRAME_FP (frame);
1104
 
1105
  write_register (PC_REGNUM, FRAME_SAVED_PC (frame));
1106
  if (frame->saved_regs == NULL)
1107
    or1k_init_saved_regs (frame);
1108
  for (regnum = 0; regnum < NUM_REGS; regnum++)    {
1109
      if (regnum != SP_REGNUM && regnum != PC_REGNUM
1110
          && frame->saved_regs[regnum] >= 0)
1111
        write_register (regnum,
1112
                        read_memory_integer (frame->saved_regs[regnum],
1113
                                             OR1K_GPR_REGSIZE));
1114
    }
1115
  write_register (SP_REGNUM, new_sp);
1116
  flush_cached_frames ();
1117
}
1118
 
1119
CORE_ADDR
1120
or1k_push_arguments (nargs, args, sp, struct_return, struct_addr)
1121
     int nargs;
1122
     value_ptr *args;
1123
     CORE_ADDR sp;
1124
     int struct_return;
1125
     CORE_ADDR struct_addr;
1126
{
1127
  int argreg;
1128
  int float_argreg;
1129
  int argnum;
1130
  int len = 0;
1131
  int stack_offset = 0;
1132
 
1133
  /* Initialize the integer and float register pointers.  */
1134
  argreg = A0_REGNUM;
1135
  float_argreg = VFA0_REGNUM;
1136
 
1137
  /* The struct_return pointer occupies the RV value register.  */
1138
  if (struct_return)
1139
    write_register (RV_REGNUM, struct_addr);
1140
 
1141
  /* Now load as many as possible of the first arguments into
1142
     registers, and push the rest onto the stack.  Loop thru args
1143
     from first to last.  */
1144
  for (argnum = 0; argnum < nargs; argnum++)
1145
    {
1146
      char *val;
1147
      char valbuf[MAX_REGISTER_RAW_SIZE];
1148
      value_ptr arg = args[argnum];
1149
      struct type *arg_type = check_typedef (VALUE_TYPE (arg));
1150
      int len = TYPE_LENGTH (arg_type);
1151
      enum type_code typecode = TYPE_CODE (arg_type);
1152
 
1153
      /* The EABI passes structures that do not fit in a register by
1154
         reference. In all other cases, pass the structure by value.  */
1155
      if (len > OR1K_GPR_REGSIZE &&
1156
          (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION))
1157
        {
1158
          store_address (valbuf, OR1K_GPR_REGSIZE, VALUE_ADDRESS (arg));
1159
          typecode = TYPE_CODE_PTR;
1160
          len = OR1K_GPR_REGSIZE;
1161
          val = valbuf;
1162
        }
1163
      else
1164
        {
1165
          val = (char *) VALUE_CONTENTS (arg);
1166
 
1167
          if (typecode == TYPE_CODE_FLT
1168
              /* Doubles are not stored in regs on 32b target.  */
1169
              && len <= OR1K_VF_REGSIZE
1170
              && OR1K_VF_PRESENT)
1171
            {
1172
              if (float_argreg <= OR1K_LAST_FP_ARG_REGNUM)
1173
                {
1174
                  CORE_ADDR regval = extract_address (val, len);
1175
                  write_register (float_argreg++, regval);
1176
                }
1177
              else
1178
                {
1179
                  write_memory ((CORE_ADDR) sp, val, OR1K_VF_REGSIZE);
1180
                  sp -= OR1K_STACK_ALIGN;
1181
                }
1182
            }
1183
          else
1184
            {
1185
              if (argreg <= OR1K_LAST_ARG_REGNUM)
1186
                {
1187
                  CORE_ADDR regval = extract_address (val, len);
1188
                  write_register (argreg++, regval);
1189
                }
1190
              else
1191
                {
1192
                  write_memory ((CORE_ADDR) sp, val, OR1K_GPR_REGSIZE);
1193
                  sp -= OR1K_STACK_ALIGN;
1194
                }
1195
            }
1196
        }
1197
    }
1198
 
1199
  /* Return adjusted stack pointer.  */
1200
  return sp;
1201
}
1202
 
1203
/* Return nonzero when instruction has delay slot.  */
1204
static int
1205
is_delayed (insn)
1206
     unsigned long insn;
1207
{
1208
  int i;
1209
  for (i = 0; i < num_opcodes; ++i)
1210
    if ((or32_opcodes[i].flags & OR32_IF_DELAY)
1211
        && (or32_opcode_match (insn, or32_opcodes[i].encoding)))
1212
      break;
1213
  return (i < num_opcodes);
1214
}
1215
 
1216
int
1217
or1k_step_skips_delay (pc)
1218
     CORE_ADDR pc;
1219
{
1220
  char buf[OR1K_INSTLEN];
1221
 
1222
  if (target_read_memory (pc, buf, OR1K_INSTLEN) != 0)
1223
    /* If error reading memory, guess that it is not a delayed branch.  */
1224
    return 0;
1225
  return is_delayed ((unsigned long) extract_unsigned_integer (buf, OR1K_INSTLEN));
1226
}
1227
 
1228
CORE_ADDR
1229
or1k_push_return_address (pc, sp)
1230
     CORE_ADDR pc;
1231
     CORE_ADDR sp;
1232
{
1233
  /* Set the return address register to point to the entry
1234
     point of the program, where a breakpoint lies in wait.  */
1235
  write_register (LR_REGNUM, CALL_DUMMY_ADDRESS ());
1236
  return sp;
1237
}
1238
 
1239
/* Parses args for spr name and puts result into group and index.  */
1240
 
1241
static char *
1242
parse_spr_params (args, group, index)
1243
                  char *args;
1244
                  int *group, *index;
1245
{
1246
  *index = -1;
1247
  if (args)
1248
    {
1249
      int i;
1250
      char *ptr_c;
1251
 
1252
      /* Check if group number was supplied.  */
1253
      ptr_c = args;
1254
      while (*ptr_c != ' ' && *ptr_c != 0)
1255
        ptr_c++;
1256
      *ptr_c = 0;
1257
 
1258
      *group = (int) strtoul (args, &ptr_c, 0);
1259
      if (*ptr_c != 0)
1260
        {
1261
          *group = OR1K_NUM_SPR_GROUPS;
1262
 
1263
          /* check for group name */
1264
          for (i = 0; i < OR1K_NUM_SPR_GROUPS; i++)
1265
            if (strcasecmp (or1k_group_names[i], args) == 0)
1266
              {
1267
                *group = i;
1268
                break;
1269
              }
1270
 
1271
          /* Invalid group => check all register names in all groups.  */
1272
          if (*group >= OR1K_NUM_SPR_GROUPS)
1273
            {
1274
              for (i = 0; i < OR1K_NUM_SPR_GROUPS; i++)
1275
                {
1276
                  int regno;
1277
                  regno = or1k_regno_from_name (i, args);
1278
                  if (regno >= 0)
1279
                    {
1280
                      *group = i;
1281
                      *index = regno;
1282 362 markom
                      break;
1283 120 markom
                    }
1284
                }
1285
            }
1286
        }
1287
      if (*group < 0 || *group >= OR1K_NUM_SPR_GROUPS)
1288
        error ("Invalid group or register.\n");
1289
 
1290
      if (*index < 0)
1291
        {
1292
          args += strlen(args) + 1;
1293
          ptr_c = args;
1294
          while (*ptr_c != ' ' && *ptr_c != 0)
1295
            ptr_c++;
1296
          *ptr_c = 0;
1297
          *index = (int) strtoul (args, &ptr_c, 0);
1298
          if (*ptr_c != 0)
1299
            *index = or1k_regno_from_name (*group, args);
1300
          else *index = -1;
1301
 
1302
          if (*index < 0)
1303
            {
1304
              printf_filtered ("No register supplied. Valid registers are:\n");
1305
              for (i = 0; i < or1k_spr_valid_aliases[*group]; i++)
1306
                {
1307
                  char reg_name[16];
1308 362 markom
                  char *gen_name = or1k_spr_register_name (SPR_REG(*group, i + or1k_group_name_start[*group]));
1309 120 markom
                  sprintf (reg_name, "SPR%i_%i", *group, i);
1310
                  if (strcmp (reg_name, gen_name) != 0)
1311
                    printf_filtered ("%s\t", gen_name);
1312
                }
1313
              printf_filtered ("\n");
1314
              return args + strlen(args) + 1;
1315
            }
1316
        }
1317
    }
1318
  else
1319
    {
1320
      /* No parameters - print groups */
1321
      int i;
1322
      printf_filtered ("No parameter supplied. Valid groups are:\n");
1323
      for (i = 0; i < OR1K_NUM_SPR_GROUPS; i++)
1324
        printf_filtered ("%s\t", or1k_group_names[i]);
1325
      printf_filtered ("\nSingle register name or register name or number after the group can be also supplied.\n");
1326
      return args;
1327
    }
1328
  return args + strlen(args) + 1;
1329
}
1330
 
1331
/* SPR register info.  */
1332
 
1333
void
1334
info_spr_command (args, from_tty)
1335
     char *args;
1336
     int from_tty;
1337
{
1338
  int group, index;
1339
  parse_spr_params (args, &group, &index);
1340
  if (index >= 0)
1341
    {
1342 362 markom
        unsigned long value = or1k_read_spr_reg (SPR_REG(group, index));
1343
      printf_unfiltered ("%s.%s = SPR%i_%i = %i(%x)\n", or1k_group_names[group],
1344
                         or1k_spr_register_name (SPR_REG(group, index)), group, index, value, value);
1345 120 markom
    }
1346
}
1347
 
1348
/* Set SPR register.  */
1349
 
1350
void
1351
spr_command (args, from_tty)
1352
     char *args;
1353
     int from_tty;
1354
{
1355
  int group, index;
1356
  char *nargs = parse_spr_params (args, &group, &index);
1357
  if (index >= 0)
1358
    {
1359
      unsigned long prev;
1360
      unsigned long value;
1361
      char *ptr_c;
1362
 
1363
      /* Any arguments left?  */
1364
      if (args + strlen(args) >= nargs)
1365
        error ("Invalid register value.");
1366
 
1367
      prev = or1k_read_spr_reg (SPR_REG(group, index));
1368
 
1369
      ptr_c = nargs;
1370
      while (*ptr_c != ' ' && *ptr_c != 0)
1371
        ptr_c++;
1372
      *ptr_c = 0;
1373
      value = strtoul (nargs, &ptr_c, 0);
1374
      if (*ptr_c != 0)
1375 362 markom
                                error ("Invalid register value.");
1376
                        or1k_write_spr_reg (SPR_REG(group, index), value);
1377
      printf_unfiltered ("%s.%s (SPR%i_%i) set to %i(%x), was:%i(%x)\n", or1k_group_names[group],
1378 120 markom
                         or1k_spr_register_name (SPR_REG(group, index)), group, index,
1379
                         value, value, prev, prev);
1380
    }
1381
}
1382
 
1383
/* Calls extended command on target.  */
1384
 
1385
void
1386
sim_command (args, from_tty)
1387
     char *args;
1388
     int from_tty;
1389
{
1390
  or1k_sim_cmd (args, from_tty);
1391
}
1392
 
1393
 
1394
static union exp_element exp_error;
1395
 
1396
/* Parses compare variable and returns it into ct.  */
1397
 
1398
union exp_element * or1k_parse_ct (exp, ct)
1399
     union exp_element *exp;
1400
     int *ct;
1401
{
1402
  int i;
1403
  if (exp->opcode != OP_INTERNALVAR)
1404
    error ("Valid lvalue expected.");
1405
  exp++;
1406
 
1407
  for (i = 1; i < NUM_CT_NAMES; i++)
1408
    if (strcasecmp (compare_to_names[i], exp->internalvar->name) == 0) break;
1409
 
1410
  if (i >= NUM_CT_NAMES)
1411
    error ("Invalid compare to operand.");
1412
  *ct = i;
1413
  exp++;
1414
 
1415
  if (exp->opcode != OP_INTERNALVAR)
1416
    return &exp_error;
1417
  exp++;
1418
  return exp;
1419
}
1420
 
1421
/* Parses compare value and returns it into cv.  */
1422
 
1423
union exp_element * or1k_parse_cv (exp, cv)
1424
     union exp_element *exp;
1425
     unsigned int *cv;
1426
{
1427
  switch (exp->opcode)
1428
    {
1429
    case UNOP_IND:
1430
      exp++;
1431
      exp = or1k_parse_cv (exp, cv);
1432
      *cv = or1k_fetch_word (*cv);
1433
      break;
1434
    case OP_LONG:
1435
      exp += 2;
1436
      *cv = exp->longconst;
1437
      exp += 2;
1438
      break;
1439
    case OP_REGISTER:
1440
      exp++;
1441
      *cv = read_register (exp->longconst);
1442
      exp += 2;
1443
      break;
1444
    default:
1445
      error ("Value expected.");
1446
    }
1447
  return exp;
1448
}
1449
 
1450
/* Parse conditional.
1451
   Puts freshly allocated array of matchpoints into match.  */
1452
 
1453
union exp_element *
1454
or1k_parse_cond (exp, match, nmatch)
1455
     union exp_element *exp;
1456
     struct matchpoint **match;
1457
     int *nmatch;
1458
{
1459
  unsigned int ct;
1460
  *match = (struct matchpoint *) malloc (sizeof (struct matchpoint));
1461
  *nmatch = 1;
1462
  switch (exp->opcode)
1463
    {
1464
    case BINOP_EQUAL:
1465
      (*match)->dcr.cc = CC_EQUAL;
1466
      break;
1467
    case BINOP_NOTEQUAL:
1468
      (*match)->dcr.cc = CC_NEQUAL;
1469
      break;
1470
    case BINOP_LESS:
1471
      (*match)->dcr.cc = CC_LESS;
1472
      break;
1473
    case BINOP_GTR:
1474
      (*match)->dcr.cc = CC_GREAT;
1475
      break;
1476
    case BINOP_LEQ:
1477
      (*match)->dcr.cc = CC_LESSE;
1478
      break;
1479
    case BINOP_GEQ:
1480
      (*match)->dcr.cc = CC_GREATE;
1481
      break;
1482
    case BINOP_BITWISE_AND:
1483
      (*match)->dcr.cc = CC_MASKED;
1484
      break;
1485
    default:
1486
      return &exp_error;
1487
    }
1488
 
1489
  exp++;
1490
  (*match)->dcr.dp = 1;
1491
  (*match)->dcr.sc = 0;
1492
  if (exp->opcode == OP_INTERNALVAR)
1493
    {
1494
      exp = or1k_parse_ct (exp, &ct);
1495
      exp = or1k_parse_cv (exp, &(*match)->dvr);
1496
    }
1497
  else
1498
    {
1499
      exp = or1k_parse_cv (exp, &(*match)->dvr);
1500
      exp = or1k_parse_ct (exp, &ct);
1501
    }
1502
 
1503
  (*match)->dcr.ct = ct;
1504
  (*match)->chain_type = CHAINING_NONE;
1505
  (*match)->cause_breakpoint = 0;
1506
  return exp;
1507
}
1508
 
1509
/* Parses expression with && or || operators.
1510
   Puts freshly allocated array of matchpoints into match.
1511
   valid & 1: && is allowed,
1512
   valid & 2: || is allowed.  */
1513
 
1514
union exp_element *
1515
or1k_parse_any (exp, match, nmatch, valid)
1516
     union exp_element *exp;
1517
     struct matchpoint **match;
1518
     int *nmatch;
1519
     int valid;
1520
{
1521
  union exp_element *tmp;
1522
  int first_and_only = 0, first_or_only = 0;
1523
  struct matchpoint *tmp_match1, *tmp_match2, *tmpm;
1524
  int tmp_nmatch1, tmp_nmatch2, tmpn;
1525
 
1526
  switch (exp->opcode)
1527
    {
1528
    case BINOP_LOGICAL_AND:
1529
      if (!(valid & 1))
1530
        return &exp_error;
1531
      exp++;
1532
 
1533
      /* Parse first argument.  */
1534
      tmp = or1k_parse_any (exp, &tmp_match1, &tmp_nmatch1, 1);
1535
      if (tmp == &exp_error)
1536
        exp = or1k_parse_any (exp, &tmp_match1, &tmp_nmatch1, valid);
1537
      else
1538
        {
1539
          /* and_only successful */
1540
          exp = tmp;
1541
          first_and_only = 1;
1542
        }
1543
      if (exp == &exp_error)
1544
        return &exp_error;
1545
 
1546
      /* Parse second argument.  */
1547
      if (first_and_only)
1548
        exp = or1k_parse_any (exp, &tmp_match2, &tmp_nmatch2, valid);
1549
      else
1550
        exp = or1k_parse_any (exp, &tmp_match2, &tmp_nmatch2, 1);
1551
 
1552
      if (exp == &exp_error)
1553
        return &exp_error;
1554
 
1555
      if (first_and_only)
1556
        {
1557
          /* Exchange structures, so that and_only is listed last.  */
1558
          struct matchpoint *tmpm = tmp_match1;
1559
          int tmpn = tmp_nmatch1;
1560
          tmp_match1 = tmp_match2;
1561
          tmp_nmatch1 = tmp_nmatch2;
1562
          tmp_match2 = tmpm;
1563
          tmp_nmatch2 = tmpn;
1564
        }
1565
 
1566
      *nmatch = tmp_nmatch1 + tmp_nmatch2;
1567
      *match = (struct matchpoint *)malloc (*nmatch * sizeof (struct matchpoint));
1568
      memcpy (*match, tmp_match1, tmp_nmatch1 * sizeof (struct matchpoint));
1569
      free (tmp_match1);
1570
      tmp_match2[0].chain_type = CHAINING_AND;
1571
      memcpy (*match + tmp_nmatch1, tmp_match2, tmp_nmatch2 * sizeof (struct matchpoint));
1572
      free (tmp_match2);
1573
      return exp;
1574
 
1575
    case BINOP_LOGICAL_OR:
1576
      if (!(valid & 2))
1577
        return &exp_error;
1578
      exp++;
1579
 
1580
      /* Parse first argument.  */
1581
      tmp = or1k_parse_any (exp, &tmp_match1, &tmp_nmatch1, 2);
1582
      if (tmp == &exp_error)
1583
        exp = or1k_parse_any (exp, &tmp_match1, &tmp_nmatch1, valid);
1584
      else
1585
        {
1586
          /* and_only successful */
1587
          exp = tmp;
1588
          first_or_only = 1;
1589
        }
1590
      if (exp == &exp_error)
1591
        return &exp_error;
1592
 
1593
      /* Parse second argument.  */
1594
      if (first_or_only)
1595
        exp = or1k_parse_any (exp, &tmp_match2, &tmp_nmatch2, valid);
1596
      else
1597
        exp = or1k_parse_any (exp, &tmp_match2, &tmp_nmatch2, 2);
1598
 
1599
      if (exp == &exp_error)
1600
        return &exp_error;
1601
 
1602
      if (first_or_only)
1603
        {
1604
          /* Exchange structures, so that and_only is listed first.  */
1605
          struct matchpoint *tmpm = tmp_match1;
1606
          int tmpn = tmp_nmatch1;
1607
          tmp_match1 = tmp_match2;
1608
          tmp_nmatch1 = tmp_nmatch2;
1609
          tmp_match2 = tmpm;
1610
          tmp_nmatch2 = tmpn;
1611
        }
1612
 
1613
      *nmatch = tmp_nmatch1 + tmp_nmatch2;
1614
      *match = (struct matchpoint *)malloc (*nmatch * sizeof (struct matchpoint));
1615
      memcpy (*match, tmp_match1, tmp_nmatch1 * sizeof (struct matchpoint));
1616
      free (tmp_match1);
1617
      tmp_match2[0].chain_type = CHAINING_OR;
1618
      memcpy (*match + tmp_nmatch1, tmp_match2, tmp_nmatch2 * sizeof (struct matchpoint));
1619
      free (tmp_match2);
1620
      return exp;
1621
 
1622
    default:
1623
      return or1k_parse_cond (exp, match, nmatch);
1624
    }
1625
}
1626
 
1627
/* Parses sequence of ||s.
1628
   Puts freshly allocated array of matchpoints into match.  */
1629
 
1630
union exp_element *
1631
or1k_parse_or (exp, match, nmatch, set_break)
1632
     union exp_element *exp;
1633
     struct matchpoint **match;
1634
     int *nmatch;
1635
     int set_break;
1636
{
1637
  struct matchpoint *tmp_match1, *tmp_match2;
1638
  int tmp_nmatch1, tmp_nmatch2;
1639
 
1640
  switch (exp->opcode)
1641
    {
1642
    case BINOP_LOGICAL_OR:
1643
      exp++;
1644
      exp = or1k_parse_or (exp, &tmp_match1, &tmp_nmatch1);
1645
      if (exp == &exp_error)
1646
        return &exp_error;
1647
 
1648
      exp = or1k_parse_any (exp, &tmp_match2, &tmp_nmatch2, 3);
1649
      if (set_break)
1650
        {
1651
          tmp_match1[tmp_nmatch1 - 1].cause_breakpoint = 1;
1652
          tmp_match2[tmp_nmatch2 - 1].cause_breakpoint = 1;
1653
        }
1654
      *nmatch = tmp_nmatch1 + tmp_nmatch2;
1655
      *match = (struct matchpoint *)malloc (*nmatch * sizeof (struct matchpoint));
1656
      memcpy (*match, tmp_match1, tmp_nmatch1 * sizeof (struct matchpoint));
1657
      free (tmp_match1);
1658
      memcpy (*match + tmp_nmatch1, tmp_match2, tmp_nmatch2 * sizeof (struct matchpoint));
1659
      free (tmp_match2);
1660
      return exp;
1661
 
1662
    default:
1663
      return or1k_parse_any (exp, match, nmatch, 3);
1664
      if (set_break)
1665
        (*match)[*nmatch - 1].cause_breakpoint = 1;
1666
    }
1667
}
1668
 
1669
/* Prints single matchpoint from specified struct.  */
1670
 
1671
static void
1672
print_matchpoint_struct (mp)
1673
     struct matchpoint *mp;
1674
{
1675
  printf_filtered ("%-6s (%i) %u, ON=%i, chain_type=%i, cause break=%i\n", compare_to_names[mp->dcr.ct],
1676
                   mp->dcr.cc, mp->dvr, mp->dcr.dp, mp->chain_type, mp->cause_breakpoint);
1677
}
1678
 
1679
/* Build watchpoint(s) based on given structure.  */
1680
 
1681
static void
1682
set_matchpoints (match, nmatch)
1683
     struct matchpoint *match;
1684
     int nmatch;
1685
{
1686
  int i;
1687
  debug_regs_changed = 1;
1688
  sift_matchpoints ();
1689
  for (i = 0; i < nmatch; i++)
1690
    {
1691
      int num = or1k_implementation.num_used_matchpoints;
1692
      dcr[num] = match[i].dcr;
1693
      dvr[num] = match[i].dvr;
1694
 
1695
      /* Set chaining bits.  */
1696
      dmr1 &= ~(3 << (2 * num));
1697
      dmr1 |= match[i].chain_type << (2 * num);
1698
 
1699
      /* Set watchpoint bits */
1700
      dmr2 &= 1 << num;
1701
      dmr2 |= match[i].cause_breakpoint << num;
1702
      matchpoint_user_count[i]++;
1703
      or1k_implementation.num_used_matchpoints++;
1704
    }
1705
}
1706
 
1707
/* Returns nonzero, if matchpoints [start .. start+nmatch-1] are
1708
   equal to match record. */
1709
 
1710
static int
1711
matchpoint_matches (start, match, nmatch)
1712
     int start;
1713
     struct matchpoint *match;
1714
     int nmatch;
1715
{
1716
  int i;
1717
  if (nmatch + start >= or1k_implementation.num_matchpoints)
1718
    return 0;
1719
 
1720
  for (i = 0; i < nmatch; i++)
1721
    {
1722
      int j = i + start;
1723
 
1724
      /* Everything exept cause breakpoint must match.  */
1725
      if (dcr[j].dp != match[i].dcr.dp
1726
          || dcr[j].ct != match[i].dcr.ct
1727
          || dcr[j].cc != match[i].dcr.cc
1728
          || dcr[j].sc != match[i].dcr.sc
1729
          || dvr[j] != match[i].dvr
1730
          || match[i].chain_type != (dmr1 >> (2 * j)) & 3)
1731
        return 0;
1732
    }
1733
  return 1;
1734
}
1735
 
1736
static void
1737
hwatch_command (arg, from_tty)
1738
     char *arg;
1739
     int from_tty;
1740
{
1741
  struct expression *exp;
1742
  int i, nfree, nmatch, remove = 0;
1743
  struct matchpoint *match;
1744
 
1745
  if (arg == NULL)
1746
    arg = "";
1747
  if (strncasecmp ("remove ", arg, 7) == 0)
1748
    {
1749
      arg += 7;
1750
      remove = 1;
1751
    }
1752
 
1753
  /* Parse arguments.  */
1754
  exp = parse_exp_1 (&arg, 0, 0);
1755
 
1756
#ifdef DEBUG
1757
  dump_prefix_expression (exp, gdb_stdout, "expr1");
1758
#endif  
1759
 
1760
  if (or1k_parse_or (&exp->elts[0], &match, &nmatch, 1) == &exp_error)
1761
    error ("Watchpoint too complex.");
1762
 
1763
  for (i = 0; i < nmatch; i++)
1764
    print_matchpoint_struct (&match[i]);
1765
 
1766
  if (remove)
1767
    {
1768
      int start = -1;
1769
      int cleared = 0;
1770
 
1771
      if (num_hw_watches <= 0)
1772
        error ("No extended hardware supported watchpoints present.");
1773
 
1774
      for (i = 0; i < num_hw_watches; i++)
1775
        if (matchpoint_matches (or1k_hwatch[i].matchpoint_start, match, nmatch))
1776
          {
1777
            start = or1k_hwatch[i].matchpoint_start;
1778
            break;
1779
          }
1780
 
1781
      if (start < 0)
1782
        error ("Watchpoint not found.");
1783
 
1784
      for (i = 0; i < nmatch; i++)
1785
        {
1786
          int j = start + i;
1787
          if (--matchpoint_user_count[j] <= 0)
1788
            {
1789
              debug_regs_changed = 1;
1790
              memset (&dcr[j], 0, sizeof (dcr[j]));
1791
              or1k_implementation.num_used_matchpoints--;
1792
              cleared = 1;
1793
            }
1794
        }
1795
      if (!cleared)
1796
        warning ("No matchpoint(s) freed. Resources are busy.");
1797
    }
1798
  else
1799
    {
1800
      if (num_hw_watches >= MAX_HW_WATCHES)
1801
        error ("Number of watchpoints too large.");
1802
 
1803
      /* Now we have to find out if given prefix expression matches
1804
         our HW based support. It may take up to
1805
         or1k_implementation.num_matchpoints - or1k_implementation.num_used_matchpoints. */
1806
      nfree = or1k_implementation.num_matchpoints - or1k_implementation.num_used_matchpoints;
1807
 
1808
      if (nmatch > nfree)
1809
        error ("Not enough free matchpoint resources.");
1810
 
1811
      /* Build watchpoint(s) based on just built structure.  */
1812
      or1k_hwatch[num_hw_watches].matchpoint_start = or1k_implementation.num_used_matchpoints;
1813
      set_matchpoints (match, nmatch);
1814
      num_hw_watches++;
1815
      printf_unfiltered ("Watchpoint successfully allocated.\n");
1816
    }
1817
  free (match);
1818
  free (exp);
1819
}
1820
 
1821
static void
1822
htrace_command (args, from_tty)
1823
     char *args;
1824
     int from_tty;
1825
{
1826
  help_list (htrace_cmdlist, "htrace ", all_commands, gdb_stdout);
1827
}
1828
 
1829
static void
1830
htrace_mode_command (args, from_tty)
1831
     char *args;
1832
     int from_tty;
1833
{
1834
  help_list (htrace_mode_cmdlist, "htrace mode ", all_commands, gdb_stdout);
1835
}
1836
 
1837
static void
1838
htrace_mode_contin_command (args, from_tty)
1839
     char *args;
1840
     int from_tty;
1841
{
1842
  or1k_htrace.moder.contin = 1;
1843
  printf_unfiltered ("Continuous trace mode set.\n");
1844
}
1845
 
1846
static void
1847
htrace_mode_suspend_command (args, from_tty)
1848
     char *args;
1849
     int from_tty;
1850
{
1851
  or1k_htrace.moder.contin = 0;
1852
  printf_unfiltered ("Suspend trace mode set.\n");
1853
}
1854
 
1855
static void print_event_struct (event, stop)
1856
     struct htrace_event_struct *event;
1857
     int stop;
1858
{
1859
  int i;
1860
  if (event->operation == TRIGOP_ANY)
1861
    if (stop)
1862
      printf_filtered ("not active");
1863
    else
1864
      printf_filtered ("always active");
1865
  else
1866
    {
1867
      char *comma;
1868
      if (event->operation == TRIGOP_AND)
1869
        comma = "&(";
1870
      else
1871
        comma = "|(";
1872
 
1873
      if (event->is_valid)
1874
        {
1875
          printf_filtered ("%s%s", comma, or1k_is_names[event->is_trig]);
1876
          comma = ", ";
1877
        }
1878
      if (event->ls_valid)
1879
        {
1880
          printf_filtered ("%s%s", comma, or1k_ls_names[event->ls_trig]);
1881
          comma = ", ";
1882
        }
1883
      if (event->bp_valid)
1884
        {
1885
          printf_filtered ("%sbreak", comma);
1886
          comma = ", ";
1887
        }
1888
      if (event->wp_valid)
1889
        for (i = 0; i < 11; i++)
1890
          if ((event->wp_trig >> i) & 1)
1891
            {
1892
              printf_filtered ("%sWP%i", comma, i);
1893
              comma = ", ";
1894
            }
1895
      if (comma[0] == ',')
1896
        printf_filtered (")");
1897
      else
1898
        printf_filtered ("not active");
1899
    }
1900
}
1901
 
1902
static void
1903
print_record_struct (record)
1904
     struct htrace_record_struct *record;
1905
{
1906
  int i;
1907
  char *comma = "";
1908
  for (i = 0; i < MAX_RECORD_NAMES; i++)
1909
    {
1910
      if ((record->rec >> i)&1)
1911
        {
1912
          printf_filtered ("%s%s", comma, or1k_record_names[i]);
1913
          comma = ", ";
1914
        }
1915
    }
1916
  if (!*comma)
1917
    printf_unfiltered ("none");
1918
}
1919
 
1920
static void
1921
htrace_info_command (args, from_tty)
1922
     char *args;
1923
     int from_tty;
1924
{
1925
  int i;
1926
  printf_filtered ("Trace trigger: ");
1927
  print_event_struct (&or1k_htrace.trig, 0);
1928
  printf_filtered ("\nTrace qualifier: ");
1929
  print_event_struct (&or1k_htrace.qual, 0);
1930
  for (i = 0; i < MAX_MATCHPOINTS; i++)
1931
    {
1932
      printf_filtered ("\n WP%i records: ", i);
1933
      print_record_struct (&or1k_htrace.recwp[i]);
1934
    }
1935
  printf_filtered ("\n BP records: ");
1936
  print_record_struct (&or1k_htrace.recbp);
1937
  printf_filtered ("\nTrace stop: ");
1938
  print_event_struct (&or1k_htrace.stop, 1);
1939
  printf_filtered ("\n");
1940
}
1941
 
1942
/* Parses event from given string.
1943
   Result is placed into event structure, and previously allocated
1944
   resources are freed.  Parameter stop is nonzero, when we are parsing
1945
   for stop criteria.  */
1946
 
1947
static void
1948
parse_event (args, event, stop)
1949
     char *args;
1950
     struct htrace_event_struct *event;
1951
     int stop;
1952
{
1953
  int i, op_type = 0, was_last_op = 1, any = 0;
1954
 
1955
  /* Release previous resources.  */
1956
  for (i = 0; i < MAX_MATCHPOINTS; i++)
1957
    {
1958
      if ((event->wp_trig << i) & 1)
1959
        if (--matchpoint_user_count[i] <= 0)
1960
          {
1961
            memset (&dcr[i], 0, sizeof (dcr[i]));
1962
            debug_regs_changed = 1;
1963
            or1k_implementation.num_used_matchpoints--;
1964
          }
1965
    }
1966
 
1967
  event->is_valid = event->is_trig = 0;
1968
  event->ls_valid = event->ls_trig = 0;
1969
  event->bp_valid = event->bp_trig = 0;
1970
  event->wp_valid = event->wp_trig = 0;
1971
 
1972
  if (args == NULL)
1973
    args = "";
1974
  while (*args == ' ')
1975
    args++;
1976
 
1977
  while (*args != '\0')
1978
    {
1979
      if (strncasecmp ("breakpoint", args, 10) == 0)
1980
        {
1981
          if (!was_last_op)
1982
            error ("Syntax error.");
1983
          was_last_op = 0;
1984
          event->bp_valid = event->bp_trig = 1;
1985
        }
1986
      else if (!stop && strncasecmp ("any", args, 3) == 0
1987
               || stop && strncasecmp ("none", args, 4) == 0)
1988
        {
1989
          if (!was_last_op)
1990
            error ("Syntax error.");
1991
          was_last_op = 0;
1992
          any = 1;
1993
        }
1994
      else if (strncasecmp ("||", args, 2) == 0)
1995
        {
1996
          if (op_type == TRIGOP_AND)
1997
            error ("Only one type of logical operator allowed at a time.");
1998
          op_type = TRIGOP_OR;
1999
          if (was_last_op)
2000
            error ("Syntax error.");
2001
          was_last_op = 1;
2002
          args += 2;
2003
        }
2004
      else if (strncasecmp ("&&", args, 2) == 0)
2005
        {
2006
          if (op_type == TRIGOP_OR)
2007
            error ("Only one type of logical operator allowed at a time.");
2008
          op_type = TRIGOP_AND;
2009
          if (was_last_op)
2010
            error ("Syntax error.");
2011
          was_last_op = 1;
2012
          args += 2;
2013
        }
2014
      else
2015
        {
2016
          int found = 0;
2017
          if (!was_last_op)
2018
            error ("Syntax error.");
2019
          was_last_op = 0;
2020
 
2021
          /* Search through is and ls tables for a match.  */
2022
          for (i = 0; i < MAX_IS_NAMES; i++)
2023
            if (strncasecmp (args, or1k_is_names[i], strlen (or1k_is_names[i])) == 0)
2024
              {
2025
                event->is_valid = 1;
2026
                event->is_trig = i;
2027
                args +=  strlen (or1k_is_names[i]);
2028
                found = 1;
2029
                break;
2030
              }
2031
          if (!found)
2032
            {
2033
              for (i = 0; i < MAX_LS_NAMES; i++)
2034
                if (strncasecmp (args, or1k_ls_names[i], strlen (or1k_ls_names[i])) == 0)
2035
                  {
2036
                    event->ls_valid = 1;
2037
                    event->ls_trig = i;
2038
                    args +=  strlen (or1k_ls_names[i]);
2039
                    found = 1;
2040
                    break;
2041
                  }
2042
            }
2043
          if (!found)
2044
            {
2045
              /* No special name was found => parse expression.  */
2046
              struct expression *exp;
2047
              struct matchpoint *match;
2048
              int nmatch, nfree;
2049
 
2050
              exp = parse_exp_1 (&args, 0, 0);
2051
 
2052
              if (or1k_parse_any (&exp->elts[0], &match, &nmatch, 3) == &exp_error)
2053
                error ("Expression too complex.");
2054
              for (i = 0; i < nmatch; i++)
2055
                print_matchpoint_struct (&match[i]);
2056
 
2057
              /* Now we have to find out if given prefix expression matches
2058
                 our HW based support. It may take up to
2059
                 or1k_implementation.num_matchpoints - or1k_implementation.num_used_matchpoints. */
2060
              nfree = or1k_implementation.num_matchpoints - or1k_implementation.num_used_matchpoints;
2061
 
2062
              if (nmatch > nfree)
2063
                error ("Not enough free matchpoint resources.");
2064
 
2065
              /* Build matchpoint(s) based on just built structure.  */
2066
              set_matchpoints (match, nmatch);
2067
              event->wp_valid = 1;
2068
              event->wp_trig |= 1 << (or1k_implementation.num_used_matchpoints - 1);
2069
              printf_unfiltered ("Watchpoint successfully allocated.\n");
2070
              free (match);
2071
              free (exp);
2072
              found = 1;
2073
            }
2074
          if (!found)
2075
            warning ("Invalid event at '%s'", args);
2076
        }
2077
      while (*args == ' ') args++;
2078
    }
2079
  if (any)
2080
    event->operation = TRIGOP_ANY;
2081
  else
2082
    {
2083
      if (op_type == 0)
2084
        op_type = TRIGOP_AND;
2085
      event->operation = op_type;
2086
    }
2087
}
2088
 
2089
static void
2090
htrace_trigger_command (args, from_tty)
2091
     char *args;
2092
     int from_tty;
2093
{
2094
  parse_event (args, &or1k_htrace.trig, 0);
2095
  printf_filtered ("Trace starts, when:\n");
2096
  print_event_struct (&or1k_htrace.trig, 0);
2097
  printf_filtered ("\n");
2098
}
2099
 
2100
static void
2101
htrace_qualifier_command (args, from_tty)
2102
     char *args;
2103
     int from_tty;
2104
{
2105
  parse_event (args, &or1k_htrace.qual, 0);
2106
  printf_filtered ("Trace records, when:\n");
2107
  print_event_struct (&or1k_htrace.qual, 0);
2108
  printf_filtered ("\n");
2109
}
2110
 
2111
static void
2112
htrace_stop_command (args, from_tty)
2113
     char *args;
2114
     int from_tty;
2115
{
2116
  parse_event (args, &or1k_htrace.stop, 1);
2117
  printf_filtered ("Trace stops, when:\n");
2118
  print_event_struct (&or1k_htrace.stop, 1);
2119
  printf_filtered ("\n");
2120
}
2121
 
2122
static void
2123
htrace_clear_records_command (args, from_tty)
2124
     char *args;
2125
     int from_tty;
2126
{
2127
  int i, j, cleared = 0;
2128
 
2129
  /* Clear all. */
2130
  for (i = 0; i < MAX_MATCHPOINTS; i++)
2131
    {
2132
      for (j = 0; j < MAX_MATCHPOINTS; j++)
2133
        {
2134
          if ((or1k_htrace.wp_record_uses[i] << j) & 1)
2135
            if (--matchpoint_user_count[j] <= 0)
2136
            {
2137
              memset (&dcr[j], 0, sizeof (dcr[j]));
2138
              debug_regs_changed = 1;
2139
              cleared = 1;
2140
              or1k_implementation.num_used_matchpoints--;
2141
            }
2142
        }
2143
      or1k_htrace.wp_record_uses[i] = 0;
2144
    }
2145
  if (!cleared)
2146
    warning ("No matchpoints freed. Resources are busy.");
2147
}
2148
 
2149
/* Syntax: htrace record {data}* when {expr} */
2150
 
2151
static void
2152
htrace_record_command (args, from_tty)
2153
     char *args;
2154
     int from_tty;
2155
{
2156
  struct expression *exp;
2157
  int i, nfree, nmatch, wp;
2158
  struct matchpoint *match;
2159
  unsigned int recdata = 0;
2160
  char *c;
2161
 
2162
  if (args == '\0')
2163
    error ( "Please specify data to record, e.g.:\n"
2164
            "htrace record PC SDATA when $SEA == 100\n"
2165
            "htrace record when $SEA == 100 to remove record");
2166
 
2167
  for (i = 0; *args != '\0' && strncasecmp ("when ", args, 5); i++)
2168
    {
2169
      int j, found = 0;
2170
      for (j = 0; j < MAX_RECORD_NAMES; j++)
2171
        if (strncasecmp (args, or1k_record_names[j], strlen (or1k_record_names[j])) == 0)
2172
          {
2173
            recdata |= 1 << j;
2174
            found = 1;
2175
            break;
2176
          }
2177
      if (!found)
2178
        warning ("Invalid record data name at '%s'.", args);
2179
      while (*args != ' ' && *args != '\0') args++;
2180
      while (*args == ' ') args++;
2181
    }
2182
 
2183
  if (strncasecmp ("when ", args, 5) != 0)
2184
    if (*args == '\0')
2185
      {
2186
        warning ("Condition not set. Assuming breakpoint.");
2187
        wp = -1;
2188
      }
2189
    else
2190
      error ("Syntax error.");
2191
  else
2192
    {
2193
      args += 5;
2194
      if (strcasecmp ("breakpoint", args) == 0)
2195
        wp = -1;
2196
      else
2197
        {
2198
          /* Parse arguments.  */
2199
          exp = parse_exp_1 (&args, 0, 0);
2200
 
2201
#ifdef DEBUG
2202
          dump_prefix_expression (exp, gdb_stdout, "expr1");
2203
#endif
2204
          if (or1k_parse_any (&exp->elts[0], &match, &nmatch, 3) == &exp_error)
2205
            error ("Expression too complex.");
2206
 
2207
          for (i = 0; i < nmatch; i++)
2208
            print_matchpoint_struct (&match[i]);
2209
 
2210
          if (recdata)
2211
            {
2212
              /* Now we have to find out if given prefix expression matches
2213
                 our HW based support. It may take up to
2214
                 or1k_implementation.num_matchpoints - or1k_implementation.num_used_matchpoints. */
2215
              nfree = or1k_implementation.num_matchpoints - or1k_implementation.num_used_matchpoints;
2216
 
2217
              if (nmatch > nfree)
2218
                error ("Not enough free matchpoint resources.");
2219
 
2220
              wp = or1k_implementation.num_used_matchpoints - 1;
2221
              or1k_htrace.wp_record_uses[wp] = 0;
2222
              for (i = or1k_implementation.num_used_matchpoints; i <= wp; i++)
2223
                or1k_htrace.wp_record_uses[wp] |= 1 << i;
2224
              set_matchpoints (match, nmatch);
2225
            }
2226
          else
2227
            {
2228
              /* Remove record. */
2229
              int start = -1, cleared = 0;
2230
 
2231
              for (i = 0; i < MAX_MATCHPOINTS; i++)
2232
                {
2233
                  int mp_start = 0, j;
2234
                  j = or1k_htrace.wp_record_uses[i];
2235
                  while (j > 0 && j & 1 == 0)
2236
                    mp_start++;
2237
 
2238
                  if (matchpoint_matches (mp_start, match, nmatch))
2239
                    {
2240
                      start = mp_start;
2241
                      or1k_htrace.wp_record_uses[i] = 0;
2242
                      break;
2243
                    }
2244
                }
2245
              if (start < 0)
2246
                error ("Record with such expression not found.");
2247
 
2248
              for (i = 0; i < nmatch; i++)
2249
                {
2250
                  int j = i + start;
2251
                  if (--matchpoint_user_count[j] <= 0)
2252
                    {
2253
                      memset (&dcr[j], 0, sizeof (dcr[j]));
2254
                      debug_regs_changed = 1;
2255
                      cleared = 1;
2256
                    }
2257
                }
2258
              if (!cleared)
2259
                warning ("No matchpoint(s) freed.");
2260
            }
2261
        }
2262
    }
2263
 
2264
  /* If we reached this point we have matchpoints set, and wp
2265
     holds the value of that watchpoint.  wp == -1, if breakpoint
2266
     was specified.  */
2267
  if (wp < 0)
2268
    or1k_htrace.recbp.rec = recdata;
2269
  else
2270
    or1k_htrace.recwp[wp].rec = recdata;
2271
 
2272
  if (recdata)
2273
    {
2274
      printf_unfiltered ("Data");
2275
      for (i = 0; i < MAX_RECORD_NAMES; i++)
2276
        if ((recdata >> i) & 1)
2277
          printf_unfiltered (" %s,", or1k_record_names[i]);
2278
    }
2279
  else
2280
    printf_unfiltered ("No data");
2281
  if (wp < 0)
2282
    printf_unfiltered (" will be recorded when breakpoint occurs\n");
2283
  else
2284
    printf_unfiltered (" will be recorded when watchpoint #%i occurs\n", wp);
2285
}
2286
 
2287
static void
2288
htrace_enable_command (args, from_tty)
2289
     char *args;
2290
     int from_tty;
2291
{
2292
  or1k_htrace.moder.trace_enable = 1;
2293
  printf_unfiltered ("HW Trace enabled.\n");
2294
}
2295
 
2296
static void
2297
htrace_disable_command (args, from_tty)
2298
     char *args;
2299
     int from_tty;
2300
{
2301
  or1k_htrace.moder.trace_enable = 0;
2302
  printf_unfiltered ("HW Trace disabled.\n");
2303
}
2304
 
2305
static void
2306
htrace_rewind_command (args, from_tty)
2307
     char *args;
2308
     int from_tty;
2309
{
2310
  FILE *f;
2311
  if (args != NULL && *args != '\0')
2312
    strncpy (TRACE_FILENAME, args, TRACE_FILENAME_SIZE);
2313
 
2314
  /* Just empty it.  */
2315
  if ((f = fopen (TRACE_FILENAME, "wb+")) == NULL)
2316
    error ("Cannot open trace file.");
2317
  fclose (f);
2318
  printf_unfiltered ("Trace data cleared.\n");
2319
}
2320
 
2321
static void
2322
print_data_struct (pos, data)
2323
     unsigned int pos;
2324
     struct htrace_data_struct *data;
2325
{
2326
  struct symbol *func;
2327
  char *funname = NULL;
2328
 
2329
  if (data->type < 4)
2330
    {
2331
      /* Determine function name - copied from stack.c  */
2332
      func = find_pc_function (data->data);
2333
      if (func)
2334
        {
2335
          struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (data->data);
2336
          if (msymbol != NULL
2337
              && (SYMBOL_VALUE_ADDRESS (msymbol)
2338
                  > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
2339
            funname = SYMBOL_NAME (msymbol);
2340
          else
2341
            {
2342
              char *demangled;
2343
              funname = SYMBOL_NAME (func);
2344
              if (SYMBOL_LANGUAGE (func) == language_cplus)
2345
                {
2346
                  demangled = cplus_demangle (funname, DMGL_ANSI);
2347
                  if (demangled == NULL)
2348
                    funname = SYMBOL_SOURCE_NAME (func);
2349
                }
2350
            }
2351
        }
2352
      else
2353
        {
2354
          struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (data->data);
2355
          if (msymbol != NULL)
2356
            funname = SYMBOL_NAME (msymbol);
2357
        }
2358
    }
2359
 
2360
  printf_filtered ("%06X%c %-8s %08X", pos, data->valid ? '>' : ':',
2361
                   or1k_record_names[data->type], data->data);
2362
  if (funname)
2363
    printf_filtered (" (%s)\n", funname);
2364
  else
2365
    printf_filtered ("\n");
2366
}
2367
 
2368
/* Prints out trace buffer.  */
2369
 
2370
static void
2371
htrace_print_command (args, from_tty)
2372
     char *args;
2373
     int from_tty;
2374
{
2375
  int i, from = 0, length = prev_length;
2376
  FILE *f;
2377
  struct htrace_data_struct *td;
2378
 
2379
  if (args == NULL) args = "";
2380
  while (*args == ' ') args++;
2381
  if (*args == '\0')
2382
    {
2383
      /* We will display buffer further. */
2384
      from = prev_from + prev_length;
2385
    }
2386
  else
2387
    {
2388
      /* Display buffer range.  */
2389
      int numbers = 0;
2390
      char *cnum = args;
2391
      while (*args != ' ' && *args != '\0')
2392
        args++;
2393
 
2394
      /* Any arguments?  */
2395
      if (*args == '\0')
2396
        numbers = 1;
2397
      else
2398
        {
2399
          *args = 0;
2400
          args++;
2401
          numbers = 2;
2402
        }
2403
      from = strtoul (cnum, &cnum, 0);
2404
      if (*cnum != 0)
2405
        error ("Invalid from value.");
2406
      if (from < 0) from += trace_size;
2407
      if (numbers == 2)
2408
        {
2409
          while (*args == ' ') args++;
2410
          length = strtoul (cnum, &cnum, 0);
2411
          if (*args != 0)
2412
            error ("Invalid length value.");
2413
          if (length < 0)
2414
            {
2415
              from += length;
2416
              length = -length;
2417
            }
2418
        }
2419
    }
2420
 
2421
  if (from >= trace_size)
2422
    from = trace_size - 1;
2423
  if (from < 0)
2424
    from = 0;
2425
  if (from + length >= trace_size)
2426
    length = trace_size - from;
2427
 
2428
  prev_length = length;
2429
  prev_from = from;
2430
  if (length == 0)
2431
    error ("Nothing to print.");
2432
 
2433
  printf_filtered ("Trace buffer %06x:%06x (size = %i)\n", from, from + length - 1, length);
2434
  if ((f = fopen (TRACE_FILENAME, "rb")) == NULL)
2435
    error ("Cannot open trace file.");
2436
  if (fseek (f, TRACE_DATA_SIZE * from, SEEK_SET))
2437
    error ("Error reading trace file.");
2438
  td = (struct htrace_data_struct *) malloc (TRACE_DATA_SIZE * length);
2439
  length = fread (td, TRACE_DATA_SIZE, length, f);
2440
  for (i = 0; i < length; i++)
2441
    print_data_struct (from + i, td[i]);
2442
  fclose (f);
2443
}
2444
 
2445 149 chris
int print_insn_big_or32 (bfd_vma,struct disassemble_info*);
2446
int print_insn_little_or32 (bfd_vma,struct disassemble_info*);
2447
 
2448 120 markom
void
2449
_initialize_or1k_tdep ()
2450
{
2451 149 chris
 
2452
  /* Added by CZ 26/06/01 */
2453
  if(TARGET_BYTE_ORDER == BIG_ENDIAN)
2454
    tm_print_insn = print_insn_big_or32;
2455
  else
2456
    tm_print_insn = print_insn_little_or32;
2457
 
2458 120 markom
  /* Commands to show and set sprs.  */
2459
  add_info ("spr", info_spr_command, "Show information about the spr registers.");
2460
  add_com ("spr", class_support, spr_command, "Set specified SPR register.");
2461
 
2462
  /* hwatch command.  */
2463 207 chris
  add_com ("hwatch", class_breakpoint, hwatch_command, "Set hardware watch"
2464
           "point.\nExample: ($LEA == my_var)&&($LDATA < 50)||($SEA == my_"
2465
           "var)&&($SDATA >= 50).\nSee OR1k Architecture document for more"
2466
           " info.");
2467 120 markom
 
2468
  /* htrace commands.  */
2469
  add_prefix_cmd ("htrace", class_breakpoint, htrace_command,
2470
                  "Group of commands for handling hardware assisted trace\n\n"
2471
                  "See OR1k Architecture and gdb for or1k documents for more info.",
2472
                  &htrace_cmdlist, "htrace ", 0, &cmdlist);
2473
  add_cmd ("info", class_breakpoint, htrace_info_command, "Display information about HW trace.",
2474
           &htrace_cmdlist);
2475
  add_alias_cmd ("i", "info", class_breakpoint, 1, &htrace_cmdlist);
2476
  add_cmd ("trigger", class_breakpoint, htrace_trigger_command, "Set starting criteria for trace.",
2477
           &htrace_cmdlist);
2478
  add_alias_cmd ("t", "trigger", class_breakpoint, 1, &htrace_cmdlist);
2479
  add_cmd ("qualifier", class_breakpoint, htrace_qualifier_command, "Set acquisition qualifier for HW trace.",
2480
           &htrace_cmdlist);
2481
  add_alias_cmd ("q", "qualifier", class_breakpoint, 1, &htrace_cmdlist);
2482
  add_cmd ("stop", class_breakpoint, htrace_stop_command, "Set HW trace stopping criteria.",
2483
           &htrace_cmdlist);
2484
  add_alias_cmd ("s", "stop", class_breakpoint, 1, &htrace_cmdlist);
2485
  add_cmd ("record", class_breakpoint, htrace_record_command, "Sets data to be recorded when expression occurs.",
2486
           &htrace_cmdlist);
2487
  add_alias_cmd ("r", "record", class_breakpoint, 1, &htrace_cmdlist);
2488
  add_cmd ("clear records", class_breakpoint, htrace_clear_records_command,
2489
           "Disposes all matchpoints used by records.", &htrace_cmdlist);
2490
  add_cmd ("enable", class_breakpoint, htrace_enable_command, "Enables the HW trace.", &htrace_cmdlist);
2491
  add_alias_cmd ("e", "enable", class_breakpoint, 1, &htrace_cmdlist);
2492
  add_cmd ("disable", class_breakpoint, htrace_disable_command, "Disables the HW trace.", &htrace_cmdlist);
2493
  add_alias_cmd ("d", "disable", class_breakpoint, 1, &htrace_cmdlist);
2494
  add_cmd ("rewind", class_breakpoint, htrace_rewind_command, "Clears currently recorded trace data.\n"
2495
           "If filename is specified, new trace file is made and any newly collected data\n"
2496
           "will be written there.", &htrace_cmdlist);
2497
  add_cmd ("print", class_breakpoint, htrace_print_command,
2498
           "Prints trace buffer, using current record configuration.\n"
2499
           "htrace print [<start> [<len>]]\n"
2500
           "htrace print"
2501
           , &htrace_cmdlist);
2502
  add_alias_cmd ("p", "print", class_breakpoint, 1, &htrace_cmdlist);
2503
  add_prefix_cmd ("mode", class_breakpoint, htrace_mode_command,
2504
           "Configures the HW trace.\n"
2505
           "htrace mode [continuous|suspend]"
2506
           , &htrace_mode_cmdlist, "htrace mode ", 0, &htrace_cmdlist);
2507
  add_alias_cmd ("m", "mode", class_breakpoint, 1, &htrace_cmdlist);
2508
  add_cmd ("continuous", class_breakpoint, htrace_mode_contin_command,
2509
           "Set continuous trace mode.\n", &htrace_mode_cmdlist);
2510
  add_cmd ("suspend", class_breakpoint, htrace_mode_suspend_command,
2511
           "Set suspend trace mode.\n", &htrace_mode_cmdlist);
2512
 
2513
  /* Extra functions supported by simulator.  */
2514
  add_com ("sim", class_obscure, sim_command,
2515
           "Send a extended command to the simulator.");
2516
}

powered by: WebSVN 2.1.0

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