1834532 Members
3167 Online
110069 Solutions
New Discussion

errors by debugger

 
Malte Neumann
Advisor

errors by debugger

Hello,

I have problems debugging a c-program on hpux 11.0 The debugger (gdb or wdb or dde or ddd) prints wrong contents of variables or structures. I.e. the program works allright, but the information shown by the debugger is not correct.

The same program, same compiler, same flags, same debugger on HPUX 10.20 works well.

Any suggestions are appreciated.

Thanks a lot for your help.

Malte
5 REPLIES 5
Ramkumar Devanathan
Honored Contributor

Re: errors by debugger

Hi Malte,

Write a smaller program containing the exact statements that cause problems, compile with the same options on both 10.20 and 11.0 and debug these two a.out's. if they go fine, there may probably be some #ifdef's in the source code in your original program which is causing the difference.

r u sure the values you view are wrong???

FWIW.
- ramd.
HPE Software Rocks!
Malte Neumann
Advisor

Re: errors by debugger

Hi Ramd,

here are just a few lines out of the source code to demonstarte what I mean with wrong values:

Definition of a structure in .h file:
typedef struct _INTRA
{
enum _FIELDTYP intra_fieldtyp; /*!< type of field */
int intra_rank; /*!< proc's intra-rank */
int intra_nprocs; /*!< number of procs in this intracomm. */
} INTRA;

Somewhere in th code, including the above:
INTRA *actintra;

actintra = (INTRA*)CCACALLOC(1,sizeof(INTRA));
/* debugger: print *actintra */
/* *actintra: 1 */
if (!actintra) dserror("Allocation of INTRA failed");
actintra->intra_fieldtyp = fluid;
/* debugger: print actintra->intra_fieldtyp */
/* Attempt to take member of something that is not a structure. */
actintra->intra_rank = 0;
actintra->intra_nprocs = 1;

The parts in the comments are the request to and the responses from the debugger.Maybe this helps you to understand the problem a little better.

How can #ifdef's cause such difference?

Thanks for your response.

Malte
Steve Steel
Honored Contributor

Re: errors by debugger

Hi


I have been informed that there will be a new debugger version in the third week of April


Wait and try it


Steve steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Adam J Markiewicz
Trusted Contributor

Re: errors by debugger

Hi

If your program works well than everything is correct.

I suspect compiling options, esspecially optimizations.

After your structure is allocated, when you initiate the fields - for the program to work well it is not essential to refresh the contents of the pointer variable. I guess compiler decided to keep the value in the CPU register and use it.

If you want to be absolutelly sure, you can try to check it in assembly under debugger (if you're not aware of it, as its more complicated to analyse). Values are returned in 'rp' register.

You have do disable optimalisation. Mayby you have to ensure somehow that every variable must be up to date at the moment of line change of your source file. Check the documentation of your compiler about it.

Good luck
Adam
I do everything perfectly, except from my mistakes
Malte Neumann
Advisor

Re: errors by debugger

SOLVED !!

Thanks a lot for your help!

The solution is:
We are using fortran subroutines in our program which make use of the PARAMETER statement. These PARAMETER statements compiled with f90 cause the debugger to print the wrong contents of variables/structures.
So we will simply resign from using the PARAMETER statement.
BTW, on HPUX 10.20 we are using f77 which causes no problems.

Malte