www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/02/24/07:00:54

From: brenig AT thp DOT Uni-Koeln DOT DE (Wolfram Brenig)
Date: Fri, 24 Feb 95 12:25:29 MET
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: GDB problem

Anybody out there (Hi !) who would like to comment on this question:

---------------------------------------------------------------------

I am trying to use GDB to debug C++ source code compiled with DJ's
32-bit DOS-extender GCC-compiler (which I am a complete novice to !).

My problem is that I can't get debug info attached such that GDB will
STEP INTO class member function which are declared/defined in various
header files as well as into template declarations.

A miniature program displaying this problem would be:

1) a header file: head.h
===================

#include <stdlib.h>
#include <stdio.h>

class V {
 public:
	V(int i, int j) : l(i),m(j) {
		if(l>m) {
			printf("Fatal: Wrong index ordering!\n");
			exit(1);
		}
		if((dp=new double[m-l+1])==0) {
			printf("Fatal: Allocation failure!\n");
			exit(1);
		}
		dp-=l;
	}
	~V() { delete (dp+l);}
	double& operator()(int i) {
		if(l<=i && i<=m)
			return dp[i];
		else {
			printf("Warning: Index out of range!\n");
			return dp[l];
		}
	}
 private:
	int l,m;
	double *dp;
};

2) the main source code file: myprog.cc
=====================================

#include "head.h"

int main() {
	V v(1,10);

	v(1)=1.0;
	v(2)=v(1);

	return 0;
}

3) compile (with DJ's GCC):
======================================
gcc -g myprog.cc

4) debug with GDB:
================================
go32 -d gdb a.out

Now, trying to step into say the indexing operator "double&
operator()(int)" in the statement "v(2)=v(1);" simply doesn't
work. GDB 'claims' that the line numbers where the executable
code for this member function resides are not within the
valid range of line numbers for the program compiled ?!

Similar problems arise for header files containing template
declarations/definitions.

----------------------------------------------------------------

Any help on this one ?? I am NOT subscribing to the djgpp mailing
list so please mail your comments to:

brenig AT thp DOT uni-koeln DOT de

Thanks :-) !



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019