9e04cc79fd5b8fc8ed53c027ad46c4bc0f3caf4d
[fw/sdcc] / sim / ucsim / cmd.src / info.cc
1 /*
2  * Simulator of microcontrollers (cmd.src/info.cc)
3  *
4  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5  * 
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9
10 /* This file is part of microcontroller simulator: ucsim.
11
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING.  If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA. */
26 /*@1@*/
27
28 #include <stdlib.h>
29 #include "i_string.h"
30
31 // sim.src
32 #include "simcl.h"
33  
34 // local
35 #include "infocl.h"
36
37
38 /*
39  * INFO BREAKPOINTS command
40  */
41
42 //int
43 //cl_info_bp_cmd::do_work(class cl_sim *sim,
44 //                      class cl_cmdline *cmdline, class cl_console *con)
45 COMMAND_DO_WORK_UC(cl_info_bp_cmd)
46 {
47   int i;
48   char *s;
49
50   con->dd_printf("Num Type       Disp Hit   Cnt   Address  What\n");
51   for (i= 0; i < uc->fbrk->count; i++)
52     {
53       class cl_brk *fb= (class cl_brk *)(uc->fbrk->at(i));
54       s= uc->disass(fb->addr, NULL);
55       con->dd_printf("%-3d %-10s %s %-5d %-5d 0x%06x %s\n", fb->nr,
56                      "fetch", (fb->perm==brkFIX)?"keep":"del ",
57                      fb->hit, fb->cnt,
58                      fb->addr, s);
59       free(s);
60     }
61   for (i= 0; i < uc->ebrk->count; i++)
62     {
63       class cl_ev_brk *eb= (class cl_ev_brk *)(uc->ebrk->at(i));
64       con->dd_printf("%-3d %-10s %s %-5d %-5d 0x%06x %s\n", eb->nr,
65                      "event", (eb->perm==brkFIX)?"keep":"del ",
66                      eb->hit, eb->cnt,
67                      eb->addr, eb->id);
68     }
69   /*t_addr a;
70   class cl_rom *r= (class cl_rom *)(sim->uc->mem(MEM_ROM));
71   for (a= 0; a < sim->uc->get_mem_size(MEM_ROM); a++)
72     {
73       if (r->bp_map->get(a))
74         con->dd_printf("0x%06x\n", a);
75         }*/
76   return(0);
77 }
78
79
80 /*
81  * INFO REGISTERS command
82  */
83
84 //int
85 //cl_info_reg_cmd::do_work(class cl_sim *sim,
86 //                       class cl_cmdline *cmdline, class cl_console *con)
87 COMMAND_DO_WORK_UC(cl_info_reg_cmd)
88 {
89   uc->print_regs(con);
90   return(0);
91 }
92
93
94 /*
95  * INFO HW command
96  */
97
98 //int
99 //cl_info_hw_cmd::do_work(class cl_sim *sim,
100 //                      class cl_cmdline *cmdline, class cl_console *con)
101 COMMAND_DO_WORK_UC(cl_info_hw_cmd)
102 {
103   class cl_hw *hw;
104   class cl_cmd_arg *params[4]= { cmdline->param(0),
105                                  cmdline->param(1),
106                                  cmdline->param(2),
107                                  cmdline->param(3) };
108
109   if (cmdline->syntax_match(uc, HW)) {
110     hw= params[0]->value.hw;
111     hw->print_info(con);
112   }
113   else
114     con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
115
116   return(DD_FALSE);
117 }
118
119
120 /* End of cmd.src/info.cc */