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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [or1k-tdep.c] - Blame information for rev 1333

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

powered by: WebSVN 2.1.0

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