#1731 More sdcdb bugs

open
nobody
Debugger (15)
5
2013-11-29
2010-12-24
No

Unfortunatly now that sdcdb runs on the current snapshots (thank you!) I have another couple of bugs to report.

Bug #1 structure members don't display properly (it appears the address of the pointer is printed at all times):

Bug #2 the pt command doesn't work on structures it loops ...

A script (under cygwin) of a program that demonstrates both problems:

Script started on Thu Dec 23 16:17:27 201

$ cat test3.c
#include <stdio.h>

typedef unsigned char uint8;
typedef unsigned int uint16;
#define REGS_IN_TCB 7

typedef uint8 tid;

typedef __pdata struct tcb_st { // [offset:size]
__idata uint8 *sp; // stack pointer [0:1]
uint8 b; // B register [1:1]
uint8 dpl, dph; // DPTR register [2:2]
uint8 dps; // DPS register [4:1]
__idata uint8 *bp; // frame register [5:1]
uint8 r[REGS_IN_TCB]; // registers [6:7]
tid id; // task ID [13:1]
uint8 state; // task state [14:1]
uint8 priority; // task priority [15:1]
uint8 event; // event number to wait for [16:1]
uint16 timer; // timer variable [17:2]
__pdata struct tcb_st *next; // next tcb in queue [19:1]
__xdata uint8 *stack; // stack in xdata [20:2]
uint8 stack_size; // stack size [22:1]

} tcb_type;

typedef __xdata struct msg_struct {
uint8 id; // message id [0:1]
__xdata void *ptr; // pointer to message [1:2]
__xdata struct msg_struct *next; // next message in the queue [3:
2]
} msg_type;

#define MAX_TASKS 5
#define TASK_STOPPED 0x00
#define TASK_READY 0x81
#define TASK_RUNNING 0x82
#define IDLE_TASK 0
#define MAIN_TASK 1

#define PRIORITY_IDLE 0x00
#define PRIORITY_NORMAL 0x80
#define PRIORITY_HIGHEST 0xff

#define NO_EVENT 0

msg_type *msg_queue[MAX_TASKS];
msg_type *msg_queue_end[MAX_TASKS];

tcb_type tasks[MAX_TASKS];
tcb_type * __data ktcb;
volatile tcb_type * __data running_task;

main()
{
uint8 i;
char __xdata buf[80];

// inialize TCB & message structures
for (i = 0; i < MAX_TASKS; ++i) {
// initialize task ids
tasks[i].id = i;
// stop all task and define task number
tasks[i].state = TASK_STOPPED;

// initialize message queues
msg_queue[i] = NULL;
msg_queue_end[i] = NULL;
}

ktcb = &tasks[IDLE_TASK];
ktcb->state = TASK_READY;
ktcb->priority = PRIORITY_NORMAL;
ktcb->event = NO_EVENT;
ktcb->timer = 0;
ktcb->next = NULL;

running_task = ktcb;

ktcb = &tasks[MAIN_TASK];
ktcb->state = TASK_RUNNING;
ktcb->priority = PRIORITY_HIGHEST;
ktcb->event = NO_EVENT;
ktcb->timer = 0;
ktcb->next = NULL;

if (ktcb->priority > running_task->priority) {
sprintf(buf,"switch");
}else {
sprintf(buf,"don't switch");
}

return 0;
}

$ "/cygdrive/c/program files/SDCC"/bin/sdcc -v
SDCC : mcs51/gbz80/z80/ds390/pic16/pic14/TININative/ds400/hc08 3.0.1 #6091 (Dec
22 2010) (MINGW32)
$ "/cygdrive/c/program files/SDCC"/bin/sdcc --debug test3.c
$ "/cygdrive/c/program files/SDCC"/bin/sdcdb test3
uCsim 0.5.4, Copyright (C) 1997 Daniel Drotos, Talker Bt.
uCsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
file "test3.ihx"
SDCDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for SDCDB; type "show warranty" for details.
SDCDB 0.9. Copyright (C) 1999 Sandeep Dutta (sandeep.dutta@usa.net)
Type ? for help
WARNING: SDCDB is EXPERIMENTAL.
(sdcdb) l main
52 main()
53 {
54 uint8 i;
55 char __xdata buf[80];
56 ... (deleted for space)
82 ktcb->timer = 0;
83 ktcb->next = NULL;
84
85
86 if (ktcb->priority > running_task->priority) {
87 sprintf(buf,"switch");
88 }else {
89 sprintf(buf,"don't switch");
90 }
91
92 return 0;
93 }
(sdcdb) b 86
(sdcdb) r
Starting program
Breakpoint 1, main() at test3.c:87
87 if (ktcb->priority > running_task->priority) {

Bug #1 structure members don't display properly (it appears the address
of the pointer is printed at all times):

(sdcdb) print running_task
$1 = 0x 0
(sdcdb) print running_task->priority
$2 = 0x 0
(sdcdb) print ktcb
$3 = 0x17
(sdcdb) print ktcb->priority
$4 = 0x17

Bug #2 the pt command doesn't work on structures it loops ...

(sdcdb) pt ktcb
struct tcb_st {
char (_near *) sp ;
char b ;
char dpl ;
char dph ;
char dps ;
char (_near *) bp ;
char [7] r ;
char id ;
char state ;
char priority ;
char event ;
int timer ;
struct tcb_st {
char (_near *) sp ;
char b ;
char dpl ;
char dph ;
char dps ;
char (_near *) bp ;
char [7] r ;
char id ;
char state ;
char priority ;
char event ;
int timer ;

... loops til exited via cntrl-c

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks