2 * Simulator of microcontrollers (cmd.src/bp.cc)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
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
47 //cl_break_cmd::do_work(class cl_sim *sim,
48 // class cl_cmdline *cmdline, class cl_console_base *con)
49 COMMAND_DO_WORK_UC(cl_break_cmd)
54 class cl_address_space *mem;
55 class cl_cmd_arg *params[4]= { cmdline->param(0),
60 if (cmdline->syntax_match(uc, ADDRESS)) {
61 addr= params[0]->value.address;
63 do_fetch(uc, addr, hit, con);
65 else if (cmdline->syntax_match(uc, ADDRESS NUMBER)) {
66 addr= params[0]->value.address;
67 hit= params[1]->value.number;
68 do_fetch(uc, addr, hit, con);
70 else if (cmdline->syntax_match(uc, MEMORY STRING ADDRESS)) {
71 mem= params[0]->value.memory.address_space;
72 op= *(params[1]->get_svalue());
73 addr= params[2]->value.address;
75 do_event(uc, mem, op, addr, hit, con);
77 else if (cmdline->syntax_match(uc, MEMORY STRING ADDRESS NUMBER)) {
78 mem= params[0]->value.memory.address_space;
79 op= *(params[1]->get_svalue());
80 addr= params[2]->value.address;
81 hit= params[3]->value.number;
82 do_event(uc, mem, op, addr, hit, con);
86 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
93 cl_break_cmd::do_fetch(class cl_uc *uc,
94 t_addr addr, int hit, class cl_console_base *con)
98 con->dd_printf("Hit value %d is too big.\n", hit);
101 if (uc->fbrk->bp_at(addr))
102 con->dd_printf("Breakpoint at 0x%06x is already set.\n", addr);
105 class cl_brk *b= new cl_fetch_brk(uc->address_space(MEM_ROM_ID),
106 uc->make_new_brknr(),
110 char *s= uc->disass(addr, NULL);
111 con->dd_printf("Breakpoint %d at 0x%06x: %s\n", b->nr, addr, s);
117 cl_break_cmd::do_event(class cl_uc *uc,
118 class cl_address_space *mem,
119 char op, t_addr addr, int hit,
120 class cl_console_base *con)
122 class cl_ev_brk *b= NULL;
124 b= uc->mk_ebrk(perm, mem, op, addr, hit);
128 con->dd_printf("Couldn't make event breakpoint\n");
137 //cl_clear_cmd::do_work(class cl_sim *sim,
138 // class cl_cmdline *cmdline, class cl_console_base *con)
139 COMMAND_DO_WORK_UC(cl_clear_cmd)
142 class cl_brk *brk= uc->fbrk->get_bp(uc->PC, &idx);
144 if (cmdline->param(0) == 0)
148 con->dd_printf("No breakpoint at this address.\n");
151 uc->fbrk->del_bp(uc->PC);
156 class cl_cmd_arg *param;
157 while ((param= cmdline->param(i++)))
160 if (!param->as_address(uc))
162 addr= param->value.address;
163 if (uc->fbrk->bp_at(addr) == 0)
164 con->dd_printf("No breakpoint at 0x%06x\n", addr);
166 uc->fbrk->del_bp(addr);
178 //cl_delete_cmd::do_work(class cl_sim *sim,
179 // class cl_cmdline *cmdline, class cl_console_base *con)
180 COMMAND_DO_WORK_UC(cl_delete_cmd)
182 if (cmdline->param(0) == 0)
185 uc->remove_all_breaks();
190 class cl_cmd_arg *param;
191 while ((param= cmdline->param(i++)))
194 if (param->get_ivalue(&num))
196 if (!uc->rm_brk(num))
197 con->dd_printf("Error\n");
205 /* End of cmd.src/bp.cc */