Exception-Handling in D (gdc, phobos)
Posted: Fri Mar 26, 2010 11:19 am
Hi,
I'm trying to port phobos to my OS (for userspace). The basics work but now I'm stuck at the exception-handling-stuff.
I'm using this as basis: http://switch.dl.sourceforge.net/projec ... rc.tar.bz2
As it seems internal/deh2.d is used for exception-handling-support on linux. I think I can port it without many changes; the only problem is (as far as I know now) that I don't know the origin of the symbols _deh_beg and _deh_end.
They are used here:
FuncTable is declared as:
So, as far as I understand it, its simply a table of "catch-handlers" and whenever an exception should be thrown we look through these handlers until we find the one for our function.
I've searched quite a bit now and tried very much but I haven't found out where this table is. I guess the linker puts it in a separate section or something like that? But I couldn't find usefull information about it :/
Has anybody a hint where to look or knows how this works?
Thanks!
hrniels
PS: I'm not sure if the forum "General programming" fits better. Feel free to move it
I'm trying to port phobos to my OS (for userspace). The basics work but now I'm stuck at the exception-handling-stuff.
I'm using this as basis: http://switch.dl.sourceforge.net/projec ... rc.tar.bz2
As it seems internal/deh2.d is used for exception-handling-support on linux. I think I can port it without many changes; the only problem is (as far as I know now) that I don't know the origin of the symbols _deh_beg and _deh_end.
They are used here:
Code: Select all
/*******************************************
* Given address that is inside a function,
* figure out which function it is in.
* Return DHandlerTable if there is one, NULL if not.
*/
DHandlerTable *__eh_finddata(void *address)
{
FuncTable *ft;
for (ft = cast(FuncTable *)&_deh_beg;
ft < cast(FuncTable *)&_deh_end;
ft++)
{
if (ft.fptr <= address &&
address < cast(void *)(cast(char *)ft.fptr + ft.fsize))
{
return ft.handlertable;
}
}
return null;
}
Code: Select all
// One of these is generated for each function with try-catch or try-finally
struct FuncTable
{
void *fptr; // pointer to start of function
DHandlerTable *handlertable; // eh data for this function
uint fsize; // size of function in bytes
}
I've searched quite a bit now and tried very much but I haven't found out where this table is. I guess the linker puts it in a separate section or something like that? But I couldn't find usefull information about it :/
Has anybody a hint where to look or knows how this works?
Thanks!
hrniels
PS: I'm not sure if the forum "General programming" fits better. Feel free to move it