[ucsim] Update email and file info, fix stm8 flash controller
[sdcc.git] / sdcc / sim / ucsim / src / core / cmd.src / cmd_info.cc
blob0d1dc61bd94f319967b1aa8ff0640e2433e07e63
1 /*
2 * Simulator of microcontrollers (cmd.src/info.cc)
4 * Copyright (C) 1999 Drotos Daniel
6 * To contact author send email to dr.dkdb@gmail.com
8 */
10 /* This file is part of microcontroller simulator: ucsim.
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.
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.
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@*/
28 #include <stdlib.h>
29 #include <string.h>
31 //#include "i_string.h"
33 // sim.src
34 #include "simcl.h"
36 // local
37 #include "cmd_infocl.h"
39 void
40 set_info_help(class cl_cmd *cmd)
42 cmd->set_help("info subcommand",
43 "Information about simulator objects",
44 "Long of info");
48 * INFO BREAKPOINTS command
51 COMMAND_DO_WORK_UC(cl_info_bp_cmd)
53 int i;
54 bool extra;
55 chars sa;
56 class cl_memory_cell *c;
57 class cl_var *v;
59 con->dd_printf("Num Type Disp Hit Cnt Address Cond\n");
60 for (i= 0; i < uc->fbrk->count; i++)
62 class cl_brk *fb= (class cl_brk *)(uc->fbrk->at(i));
63 class cl_memory *mem= fb->get_mem();
64 if (mem)
65 sa.format("0x%06x", fb->addr);
66 else
68 c= fb->get_cell();
69 v= uc->vars->by_cell(c);
70 if (v)
71 sa= v->get_name();
72 else
73 sa= "cell";
74 sa.substr(0,8);
76 con->dd_printf("%-3d %-10s %s %-5d %-5d %8s %-5s ", fb->nr,
77 "fetch", (fb->perm==brkFIX)?"keep":"del ",
78 fb->hit, fb->cnt, sa.c_str(),
79 fb->condition()?"true":"false");
80 //uc->print_disass(fb->addr, con);
81 extra= false;
82 if (!(fb->cond.empty()))
83 con->dd_printf(" cond=\"%s\"", fb->cond.c_str()), extra= true;
84 if (!(fb->commands.empty()))
85 con->dd_printf(" cmd=\"%s\"", fb->commands.c_str()), extra= true;
86 /*if (extra)*/ con->dd_printf("\n");
88 for (i= 0; i < uc->ebrk->count; i++)
90 class cl_ev_brk *eb= (class cl_ev_brk *)(uc->ebrk->at(i));
91 class cl_memory *mem= eb->get_mem();
92 if (mem)
93 sa.format("0x%06x", eb->addr);
94 else
96 c= eb->get_cell();
97 v= uc->vars->by_cell(c);
98 if (v)
99 sa= v->get_name();
100 else
101 sa= "cell";
102 sa.substr(0,8);
104 con->dd_printf("%-3d %-10s %s %-5d %-5d %8s %s\n", eb->nr,
105 "event", (eb->perm==brkFIX)?"keep":"del ",
106 eb->hit, eb->cnt,
107 sa.c_str(), eb->id);
108 extra= false;
109 if (!(eb->cond.empty()))
110 con->dd_printf(" cond=\"%s\"", eb->cond.c_str()), extra= true;
111 if (!(eb->commands.empty()))
112 con->dd_printf(" cmd=\"%s\"", eb->commands.c_str()), extra= true;
113 if (extra) con->dd_printf("\n");
115 return(0);
118 CMDHELP(cl_info_bp_cmd,
119 "info breakpoints",
120 "Status of user-settable breakpoints",
124 * INFO REGISTERS command
127 COMMAND_DO_WORK_UC(cl_info_reg_cmd)
129 uc->print_regs(con);
130 return(0);
133 CMDHELP(cl_info_reg_cmd,
134 "info registers",
135 "List of integer registers and their contents",
139 * INFO HW command
142 //int
143 //cl_info_hw_cmd::do_work(class cl_sim *sim,
144 // class cl_cmdline *cmdline, class cl_console *con)
145 COMMAND_DO_WORK_UC(cl_info_hw_cmd)
147 class cl_hw *hw;
148 class cl_cmd_arg *params[4]= { cmdline->param(0),
149 cmdline->param(1),
150 cmdline->param(2),
151 cmdline->param(3) };
153 if (cmdline->syntax_match(uc, HW)) {
154 hw= params[0]->value.hw;
155 con->dd_color("answer");
156 hw->print_info(con);
157 hw->print_cfg_info(con);
159 /*else if (cmdline->syntax_match(uc, STRING))
161 char *s= params[0]->get_svalue();
162 if (s && *s && (strcmp("cpu", s)==0))
164 if (uc->cpu)
165 uc->cpu->print_info(con);
168 else
169 syntax_error(con);
171 return(false);
174 CMDHELP(cl_info_hw_cmd,
175 "info hardware category",
176 "Status of hardware elements of the CPU",
180 * INFO STACK command
183 COMMAND_DO_WORK_UC(cl_info_stack_cmd)
185 int i;
187 cl_stack_op::info_head(con);
188 for (i= uc->stack_ops->count-1; i >= 0; i--)
190 class cl_stack_op *so= (class cl_stack_op *)(uc->stack_ops->at(i));
191 so->info(con, uc);
193 return(false);
197 /*CMDHELP(cl_info_stack_cmd,
198 "info stack",
199 "Status of stack of the CPU",
200 "")*/
203 * INFO MEMORY command
204 *----------------------------------------------------------------------------
207 COMMAND_DO_WORK_UC(cl_info_memory_cmd)
209 int i;
210 class cl_memory *mem= NULL;
211 class cl_cmd_arg *params[4]= { cmdline->param(0),
212 cmdline->param(1),
213 cmdline->param(2),
214 cmdline->param(3) };
216 if (cmdline->syntax_match(uc, MEMORY))
218 mem= params[0]->value.memory.memory;
219 if (mem)
221 mem->print_info("", con);
223 return false;
225 con->dd_printf("Memory chips:\n");
226 for (i= 0; i < uc->memchips->count; i++)
228 class cl_memory_chip *m= (class cl_memory_chip *)(uc->memchips->at(i));
229 m->print_info(" ", con);
231 con->dd_printf("Address spaces:\n");
232 for (i= 0; i < uc->address_spaces->count; i++)
234 class cl_address_space *m=
235 (class cl_address_space *)(uc->address_spaces->at(i));
236 m->print_info(" ", con);
238 con->dd_printf("Address decoders:\n");
239 for (i= 0; i < uc->address_spaces->count; i++)
241 class cl_address_space *m=
242 (class cl_address_space *)(uc->address_spaces->at(i));
243 int j;
244 for (j= 0; j < m->decoders->count; j++)
246 class cl_address_decoder *d=
247 (class cl_address_decoder *)(m->decoders->at(j));
248 d->print_info(chars(" "), con);
251 return(0);
254 CMDHELP(cl_info_memory_cmd,
255 "info memory",
256 "Information about memory system",
260 * INFO VARIABLES command
261 *----------------------------------------------------------------------------
264 COMMAND_DO_WORK_UC(cl_info_var_cmd)
266 class cl_cvar *v;
267 int i;
268 //class cl_cmd_arg *params[2]= { cmdline->param(0), cmdline->param(1) };
269 chars src;
270 chars filter_by;
272 i= 0;
273 class cl_cmd_arg *a= cmdline->param(i);
274 while (a != NULL)
276 char *ps= a->get_svalue();
277 if (ps && *ps)
279 if (ps[0] == '/')
280 filter_by= &ps[1];
281 else
282 src= ps;
284 i++;
285 a= cmdline->param(i);
288 for (i= 0; i < uc->vars->by_name.count; i++)
290 v= uc->vars->by_name.at(i);
291 if ((src.empty() && *(v->get_name()) != '.') ||
292 (src.nempty() && strstr(v->get_name(), src.c_str()) != NULL))
294 if (filter_by.nempty())
296 if (strchr(filter_by.c_str(), (char)(v->defined_by)) == NULL)
297 continue;
299 v->print_info(con);
302 return 0;
305 CMDHELP(cl_info_var_cmd,
306 "info variables [[/filter] search]",
307 "Information about variables",
308 "This command prints info about all or selected variables.\n"
309 "To select some variables, \"search\" string can be used,\n"
310 "in this case those variables will be printed which name\n"
311 "contains the specified search string.\n"
312 "Filter option can be used to select variables according to\n"
313 "place where the variable is defined.\n"
314 " /p list predefined variables,\n"
315 " /u list user defined variables (by var command),\n"
316 " /d list variables read from debug info (cdb) file.\n"
320 /* End of cmd.src/cmd_info.cc */