Debugging with CDT and Cygwin GDB [message #159615] |
Thu, 01 December 2005 02:37  |
Eclipse User |
|
|
|
Dear All
I have two questions regarding the debugging of a C program with
Eclipse/CDT in conjunction with the Cygwin GDB Debugger.
1. What could the reason be for the debugger process to write the
following to its console?
mi_cmd_stack_list_frames: No stack.
No symbol "auto" in current context.
2. What could the reason be for that the results of my C program's
"printf" statements are written to the program process console first after
the program ends when I step through the program (the complete output is
buffered and then flushed)? Maybe it is related to point 1. above!?
- SW versions remark:
I make use of the following Software releases:
Eclipse: eclipse-SDK-3.1.1-win32
CDT plugin: org.eclipse.cdt.sdk-3.0.1-win32.x86
Cygwin: "downloaded and installed on the 5/11-2005"
- My small test program:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
char *name;
int reg_num;
} Student;
typedef struct {
char *name;
char *room;
char *institute;
} Professor;
typedef struct {
char *name;
char PhD_student; /* 'y', 'n' */
} Assistant;
typedef struct {
enum {STU,PROF,ASSI} kind;
union {
Student *s;
Professor *p;
Assistant *a;
} u;
} Person;
typedef Person **List;
void printStudent(Student *s) {
printf("%s\n", s->name);
}
void printProf(Professor *p) {
printf("%s\n", p->name);
printf("%s\n", p->room);
printf("%s\n", p->institute);
}
void printAssi(Assistant *a) {
printf("%s\n", a->name);
}
void printAll(List I) {
int i;
for (i=0;I[i]!=NULL;i++)
switch(I[i]->kind) {
case STU:
/* printf("STU\n"); */
printf("address I[i]->u.s: %x\n", I[i]->u.s);
printStudent(I[i]->u.s);
break;
case PROF:
/* printf("PROF\n"); */
printf("address I[i]->u.p: %x\n", I[i]->u.p);
printProf(I[i]->u.p);
break;
case ASSI:
/* printf("ASSI\n"); */
printf("address I[i]->u.a: %x\n", I[i]->u.a);
printAssi(I[i]->u.a);
break;
}
}
int main() {
Student s;
Professor p;
Assistant a;
Person person1, person2, person3;
Person **test;
person1.kind = STU;
person1.u.s = &s;
printf("address &s: %x\n", &s);
printf("address person1.u.s: %x\n", person1.u.s);
person2.kind = PROF;
person2.u.p = &p;
printf("address &p: %x\n", &p);
printf("address person2.u.s: %x\n", person2.u.p);
person3.kind = ASSI;
person3.u.a = &a;
printf("address &a: %x\n", &a);
printf("address person3.u.s: %x\n", person3.u.a);
s.name = "Student";
p.name = "Professor";
p.room = "ProfessorSitsInRoom1";
p.institute = "ProfessorWorksAtInstitute1";
a.name = "Assistant";
printf("%s\n", s.name);
printf("%s\n", p.name);
printf("%s\n", a.name);
test = (Person **) calloc( 4, sizeof(Person*) );
test[0] = &person1;
test[1] = &person2;
test[2] = &person3;
test[3] = NULL;
printAll(test);
return 0;
}
|
|
|
Re: Debugging with CDT and Cygwin GDB [message #159777 is a reply to message #159615] |
Thu, 01 December 2005 12:03  |
Eclipse User |
|
|
|
Dear All
I think I found the answers myself..
1.
From what I could read, it seems to be normal ("no bug") that the debugger
process writes these kind of messages at times..
mi_cmd_stack_list_frames: No stack.
No symbol "auto" in current context.
2.
Adding..
fflush(stdout);
..gives me want I want.
Regards,
U.Wilhelm
|
|
|
Powered by
FUDForum. Page generated in 0.03446 seconds