+ ret:
+ return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdSetTmpUserBp - settempory break point at the user specified location */
+/*-----------------------------------------------------------------*/
+int cmdSetTmpUserBp (char *s, context *cctxt)
+{
+ return commonSetUserBp(s, cctxt, TMPUSER );
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdSetUserBp - set break point at the user specified location */
+/*-----------------------------------------------------------------*/
+int cmdSetUserBp (char *s, context *cctxt)
+{
+ return commonSetUserBp(s, cctxt, USER );
+}
+
+/*-----------------------------------------------------------------*/
+/* cmdJump - set program counter */
+/*-----------------------------------------------------------------*/
+int cmdJump (char *s, context *cctxt)
+{
+ char *bp;
+ function *func = NULL;
+ if (STACK_EMPTY(callStack))
+ {
+ fprintf(stdout,"The program is not running.\n");
+ return 0;
+ }
+
+ /* trim left and right */
+ s = trim(s);
+
+ if (! *s )
+ {
+ fprintf(stdout,"No argument: need line or *addr.\n");
+ return 0;
+ }
+ if ( *s == '*' && isdigit(*(s+1)))
+ {
+ unsigned int addr = atoi(s);
+ if (cctxt && cctxt->func &&
+ cctxt->func->sym->addr <= addr &&
+ cctxt->func->sym->eaddr >= addr)
+ {
+ simSetPC(addr);
+ return 0;
+ }
+ fprintf(stdout,"Warning addr 0x%x outside actual function.\n",addr);
+ simSetPC(addr);
+ return 0;
+ }
+ if (isdigit(*s))
+ {
+ /* get the lineno */
+ int line = atoi(s) -1;
+ if (!cctxt || !cctxt->func || !cctxt->func->mod)
+ {
+ fprintf(stderr,"Function not defined.\n");
+ return 0;
+ }
+ if (line >= cctxt->func->entryline &&
+ line <= cctxt->func->exitline )
+ {
+ simSetPC(cctxt->func->mod->cLines[line]->addr);
+ return 0;
+ }
+ if (line >= cctxt->func->mod->ncLines )
+ {
+ fprintf(stderr,"line not in module.\n");
+ return 0;
+ }
+ fprintf(stdout,"Warning line %d outside actual function.\n",line+1);
+ simSetPC(cctxt->func->mod->cLines[line]->addr);
+ return 0;
+ }
+ if ((bp = strchr(s,':')))
+ {
+ int line;
+ module *mod = NULL;
+ *bp++ = '\0';
+ if (!applyToSet(modules,moduleWithCName,s,&mod))
+ {
+ fprintf (stderr,"No source file named %s.\n",s);
+ return 0;
+ }
+ if (!isdigit(*bp))
+ {
+ fprintf (stderr,"No line number.\n");
+ return 0;
+ }
+ line = atoi(bp) -1;
+ if (line >= mod->ncLines )
+ {
+ fprintf(stderr,"line not in module.\n");
+ return 0;
+ }
+ if ( mod != cctxt->func->mod ||
+ line < cctxt->func->entryline ||
+ line > cctxt->func->exitline )
+ {
+ fprintf(stdout,"Warning line %d outside actual function.\n",
+ line+1);
+ }
+ simSetPC(mod->cLines[line]->addr);
+ }