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
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
31 //#include "i_string.h"
37 #include "cmd_infocl.h"
40 set_info_help(class cl_cmd
*cmd
)
42 cmd
->set_help("info subcommand",
43 "Information about simulator objects",
48 * INFO BREAKPOINTS command
51 COMMAND_DO_WORK_UC(cl_info_bp_cmd
)
56 class cl_memory_cell
*c
;
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();
65 sa
.format("0x%06x", fb
->addr
);
69 v
= uc
->vars
->by_cell(c
);
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);
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();
93 sa
.format("0x%06x", eb
->addr
);
97 v
= uc
->vars
->by_cell(c
);
104 con
->dd_printf("%-3d %-10s %s %-5d %-5d %8s %s\n", eb
->nr
,
105 "event", (eb
->perm
==brkFIX
)?"keep":"del ",
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");
118 CMDHELP(cl_info_bp_cmd
,
120 "Status of user-settable breakpoints",
124 * INFO REGISTERS command
127 COMMAND_DO_WORK_UC(cl_info_reg_cmd
)
133 CMDHELP(cl_info_reg_cmd
,
135 "List of integer registers and their contents",
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
)
148 class cl_cmd_arg
*params
[4]= { cmdline
->param(0),
153 if (cmdline
->syntax_match(uc
, HW
)) {
154 hw
= params
[0]->value
.hw
;
155 con
->dd_color("answer");
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))
165 uc->cpu->print_info(con);
174 CMDHELP(cl_info_hw_cmd
,
175 "info hardware category",
176 "Status of hardware elements of the CPU",
183 COMMAND_DO_WORK_UC(cl_info_stack_cmd)
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));
197 /*CMDHELP(cl_info_stack_cmd,
199 "Status of stack of the CPU",
203 * INFO MEMORY command
204 *----------------------------------------------------------------------------
207 COMMAND_DO_WORK_UC(cl_info_memory_cmd
)
210 class cl_memory
*mem
= NULL
;
211 class cl_cmd_arg
*params
[4]= { cmdline
->param(0),
216 if (cmdline
->syntax_match(uc
, MEMORY
))
218 mem
= params
[0]->value
.memory
.memory
;
221 mem
->print_info("", con
);
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
));
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
);
254 CMDHELP(cl_info_memory_cmd
,
256 "Information about memory system",
260 * INFO VARIABLES command
261 *----------------------------------------------------------------------------
264 COMMAND_DO_WORK_UC(cl_info_var_cmd
)
268 //class cl_cmd_arg *params[2]= { cmdline->param(0), cmdline->param(1) };
273 class cl_cmd_arg
*a
= cmdline
->param(i
);
276 char *ps
= a
->get_svalue();
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
)
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 */