This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3.0] Dwarf2 EH fix for AIX


--On Wednesday, January 02, 2002 01:49:30 PM -0500 David Edelsohn 
<dje@watson.ibm.com> wrote:


>	I would like to back-port the Dwarf2 EH fixes to the gcc-3.0
> branch so that EH will work on AIX in the GCC 3.0 branch. 

> Thanks, David

I applied this patch to gcc-3.0.3 with mixed results. The patch did fix one
of my test cases, but in another, more complicated case, EH still does not
appear to work.

Reading specs from
/usr/local/gnu-3.0.3/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.0.3/specs
Configured with: ../gcc-3.0.3/configure --prefix=/usr/local/gnu-3.0.3
--with-gnu-as --with-as=/usr/local/gnu-3.0.3/bin/as --without-gnu-ld
--enable-shared --enable-threads=aix --disable-multilib
Thread model: single
gcc version 3.0.3

The following test case is distilled from some third-party code that I have
to use. It involves an exception thrown from one member function in a class
in a shared library, and caught in another member function of the same
class.

Here is the source for the shared library component (EHtestSH.cpp):

// BEGIN EHtestSH.cpp

#include <stddef.h>
#include <exception>

class EndOfStringEx : public std::exception
{
};

class MyClass
{
public:
	MyClass(const char* str, size_t len)
	 : m_InputStr(str),
	 m_InputLen(0),
	 m_Pos(0)
	{ }

size_t get_char(char& ch)
{
	if (m_Pos == m_InputLen)
	{
		EndOfStringEx	ex;

		throw ex;
	}
	ch = m_InputStr[m_Pos++];
	return 1;
}

size_t get_string(char *buf, size_t buflen)
{
	size_t	rc = 0;

	m_Pos = 0;
	try
	{
		while (rc + 1 < buflen)
		{
			char	ch;

			get_char(ch);
			buf[rc++] = ch;
		}
	}
	catch (EndOfStringEx) {}

	if (rc < buflen)
		buf[rc] = 0;

	return rc;
}

private:
	const char *m_InputStr;
	size_t m_InputLen;
	size_t m_Pos;
};

extern "C"
void EHtestSH(void)
{
	MyClass	m("test", 4);
	char	buf[5];

	m.get_string(buf, sizeof(buf));
}

// END EHtestSH.cpp


The shared library is built as follows:
    g++ -g -o libEHtestSH.a -shared EHtestSH.cpp

Here is the source for the main program (EHtest.cpp):

// BEGIN EHtest.cpp

#include <stddef.h>

extern "C" {
void EHtestSH(void);
}

int main(int argc, char* argv[])
{
	EHtestSH();

	return 0;
}

// END EHtest.cpp

The main program is built as follows:
  g++ -g -o EHtest EHtest.cpp -L. -lEHtestSH

Running EHtest then produces a core dump at the point where the exception is
thrown in MyClass::get_char().

David Gamble
Architect, Research & Development
Hummingbird Ltd.
Tel: (613) 238-1761
Voice: (613) 238-6452 Ext. 126
mailto:dave.gamble@hummingbird.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]