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 "cmd_infocl.h"
36
37 void
set_info_help(class cl_cmd * cmd)38 set_info_help(class cl_cmd *cmd)
39 {
40 cmd->set_help("info subcommand",
41 "Information about simulator objects",
42 "Long of info");
43 }
44
45 /*
46 * INFO BREAKPOINTS command
47 */
48
COMMAND_DO_WORK_UC(cl_info_bp_cmd)49 COMMAND_DO_WORK_UC(cl_info_bp_cmd)
50 {
51 int i;
52 bool extra;
53
54 con->dd_printf("Num Type Disp Hit Cnt Address Cond What\n");
55 for (i= 0; i < uc->fbrk->count; i++)
56 {
57 class cl_brk *fb= (class cl_brk *)(uc->fbrk->at(i));
58 const char *s= uc->disass(fb->addr, NULL);
59 con->dd_printf("%-3d %-10s %s %-5d %-5d 0x%06x %-5s %s\n", fb->nr,
60 "fetch", (fb->perm==brkFIX)?"keep":"del ",
61 fb->hit, fb->cnt, AU(fb->addr),
62 fb->condition()?"true":"false",
63 s);
64 extra= false;
65 if (!(fb->cond.empty()))
66 con->dd_printf(" cond=\"%s\"", (char*)(fb->cond)), extra= true;
67 if (!(fb->commands.empty()))
68 con->dd_printf(" cmd=\"%s\"", (char*)(fb->commands)), extra= true;
69 free((char *)s);
70 if (extra) con->dd_printf("\n");
71 }
72 for (i= 0; i < uc->ebrk->count; i++)
73 {
74 class cl_ev_brk *eb= (class cl_ev_brk *)(uc->ebrk->at(i));
75 con->dd_printf("%-3d %-10s %s %-5d %-5d 0x%06x %s\n", eb->nr,
76 "event", (eb->perm==brkFIX)?"keep":"del ",
77 eb->hit, eb->cnt,
78 AU(eb->addr), eb->id);
79 extra= false;
80 if (!(eb->cond.empty()))
81 con->dd_printf(" cond=\"%s\"", (char*)(eb->cond)), extra= true;
82 if (!(eb->commands.empty()))
83 con->dd_printf(" cmd=\"%s\"", (char*)(eb->commands)), extra= true;
84 if (extra) con->dd_printf("\n");
85 }
86 return(0);
87 }
88
89 CMDHELP(cl_info_bp_cmd,
90 "info breakpoints",
91 "Status of user-settable breakpoints",
92 "long help of info breakpoints")
93
94 /*
95 * INFO REGISTERS command
96 */
97
COMMAND_DO_WORK_UC(cl_info_reg_cmd)98 COMMAND_DO_WORK_UC(cl_info_reg_cmd)
99 {
100 uc->print_regs(con);
101 return(0);
102 }
103
104 CMDHELP(cl_info_reg_cmd,
105 "info registers",
106 "List of integer registers and their contents",
107 "long help of info registers")
108
109 /*
110 * INFO HW command
111 */
112
113 //int
114 //cl_info_hw_cmd::do_work(class cl_sim *sim,
115 // class cl_cmdline *cmdline, class cl_console *con)
COMMAND_DO_WORK_UC(cl_info_hw_cmd)116 COMMAND_DO_WORK_UC(cl_info_hw_cmd)
117 {
118 class cl_hw *hw;
119 class cl_cmd_arg *params[4]= { cmdline->param(0),
120 cmdline->param(1),
121 cmdline->param(2),
122 cmdline->param(3) };
123
124 if (cmdline->syntax_match(uc, HW)) {
125 hw= params[0]->value.hw;
126 hw->print_info(con);
127 }
128 else if (cmdline->syntax_match(uc, STRING))
129 {
130 char *s= params[0]->get_svalue();
131 if (s && *s && (strcmp("cpu", s)==0))
132 {
133 if (uc->cpu)
134 uc->cpu->print_info(con);
135 }
136 }
137 else
138 syntax_error(con);
139
140 return(false);
141 }
142
143 CMDHELP(cl_info_hw_cmd,
144 "info hardware cathegory",
145 "Status of hardware elements of the CPU",
146 "long help of info hardware")
147
148 /*
149 * INFO STACK command
150 */
151 /*
152 COMMAND_DO_WORK_UC(cl_info_stack_cmd)
153 {
154 int i;
155
156 cl_stack_op::info_head(con);
157 for (i= uc->stack_ops->count-1; i >= 0; i--)
158 {
159 class cl_stack_op *so= (class cl_stack_op *)(uc->stack_ops->at(i));
160 so->info(con, uc);
161 }
162 return(false);
163 }
164 */
165
166 /*CMDHELP(cl_info_stack_cmd,
167 "info stack",
168 "Status of stack of the CPU",
169 "long help of info stack")*/
170
171 /*
172 * INFO MEMORY command
173 *----------------------------------------------------------------------------
174 */
175
COMMAND_DO_WORK_UC(cl_info_memory_cmd)176 COMMAND_DO_WORK_UC(cl_info_memory_cmd)
177 {
178 int i;
179 class cl_memory *mem= NULL;
180 class cl_cmd_arg *params[4]= { cmdline->param(0),
181 cmdline->param(1),
182 cmdline->param(2),
183 cmdline->param(3) };
184
185 if (cmdline->syntax_match(uc, MEMORY))
186 {
187 mem= params[0]->value.memory.memory;
188 if (mem)
189 {
190 mem->print_info("", con);
191 }
192 return false;
193 }
194 con->dd_printf("Memory chips:\n");
195 for (i= 0; i < uc->memchips->count; i++)
196 {
197 class cl_memory_chip *m= (class cl_memory_chip *)(uc->memchips->at(i));
198 m->print_info(" ", con);
199 }
200 con->dd_printf("Address spaces:\n");
201 for (i= 0; i < uc->address_spaces->count; i++)
202 {
203 class cl_address_space *m=
204 (class cl_address_space *)(uc->address_spaces->at(i));
205 m->print_info(" ", con);
206 }
207 con->dd_printf("Address decoders:\n");
208 for (i= 0; i < uc->address_spaces->count; i++)
209 {
210 class cl_address_space *m=
211 (class cl_address_space *)(uc->address_spaces->at(i));
212 int j;
213 for (j= 0; j < m->decoders->count; j++)
214 {
215 class cl_address_decoder *d=
216 (class cl_address_decoder *)(m->decoders->at(j));
217 d->print_info(chars(" "), con);
218 }
219 }
220 return(0);
221 }
222
223 CMDHELP(cl_info_memory_cmd,
224 "info memory",
225 "Information about memory system",
226 "long help of info memory")
227
228 /*
229 * INFO VARIABLES command
230 *----------------------------------------------------------------------------
231 */
232
COMMAND_DO_WORK_UC(cl_info_var_cmd)233 COMMAND_DO_WORK_UC(cl_info_var_cmd)
234 {
235 class cl_var *v;
236 int i;
237 class cl_cmd_arg *params[1]= { cmdline->param(0) };
238 char *s= NULL;
239
240 if (cmdline->syntax_match(uc, STRING))
241 {
242 s= params[0]->get_svalue();
243 if (!s ||
244 !*s)
245 s= NULL;
246 }
247 for (i= 0; i < uc->vars->count; i++)
248 {
249 v= (class cl_var *)(uc->vars->at(i));
250 if ((s == NULL) ||
251 (
252 (strstr(v->as->get_name(), s) != NULL) ||
253 (strstr(v->get_name(), s) != NULL)
254 )
255 )
256 v->print_info(con);
257 }
258 return 0;
259 }
260
261 CMDHELP(cl_info_var_cmd,
262 "info variables [filter]",
263 "Information about variables",
264 "long help of info variables")
265
266 /* End of cmd.src/cmd_info.cc */
267