LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-20-2005, 07:26 AM   #1
Stephan P.
LQ Newbie
 
Registered: Jul 2005
Posts: 2

Rep: Reputation: 0
Question g77/Linux: how to locate floating point errors in my own shared libs?


I'm trying to locate FPEs in my own g77 lib, which works fine when I'm compiling statically. But when I compile my code into shared libs, I have problems finding the offending line.

Here's what I do for the static case:

- compile my lib code with -g

- link my main program against my lib and the "trapfpe" code mentioned in the g77 manual under "Trouble", "Missing Features", "Floating-point Exception Handling"

- load my main program into gdb, run it, and I get the offending line on a silver platter.


When I compile my lib into a shared object file, and link my main program against it, using trapfpe.so and LD_PRELOAD, it still aborts with "floating exception" alright, but running it in gdb simply produces output like this:

Program received signal SIGFPE, Arithmetic exception
0x41bbfc4d in ?? ()


What can I do to get the source line info in the case of shared objects too?

Thanks in advance for any pointers, I'm really stumped!

Stephan
 
Old 07-20-2005, 09:22 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
The reason for the ()?? thing is that gdb has no symbol information.

In order to debug meaningfully you have to have linked -g.

You could simply keep a static library in your app until you've worked out all the issues.


It also sounds like you need to do some parameter checking before you execute the core math operations in your library. If something is out of range, find a way to report the problem.
 
Old 07-22-2005, 08:04 AM   #3
Stephan P.
LQ Newbie
 
Registered: Jul 2005
Posts: 2

Original Poster
Rep: Reputation: 0
Hi Jim,

thanks a lot for your reply, it's much appreciated!

Quote:
The reason for the ()?? thing is that gdb has no symbol information.

In order to debug meaningfully you have to have linked -g.
I actually did this, my lib code is compiled with -g.

Quote:
You could simply keep a static library in your app until you've worked out all the issues.
As long as I'm doing my own tests, yes. But the real problem is that this FPE occurs when my lib is linked to a commercial program, and that only takes shared libs (and is itself of course not compiled with -g, btw.).

Quote:
It also sounds like you need to do some parameter checking before you execute the core math operations in your library. If something is out of range, find a way to report the problem.
True. For now I'm just looking for a way to locate the offending line.

But from your response I take it that what I'm trying do to at least should be possible, so I'm currently looking into other potential reasons. For instance, I might have picked up a non-debug version of my lib because I didn't update LD_LIBRARY_PATH properly...

All the best,
Stephan
 
Old 08-05-2005, 02:23 PM   #4
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 217

Rep: Reputation: 21
If you variable really holds a float point value and you do something like fp := (fp*100.00)/100.00;
than the range of the float point value is changed and you get that signal. So trunc or round that floatpoint before the range will be changed. It's a CPU-fault like division by 0.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating Point in kernel 2.4.28 lucs Slackware 1 10-19-2005 08:33 AM
Floating point exception hemk76 Linux - Software 1 05-06-2005 11:49 PM
floating point multiplication irfanhab Programming 0 12-23-2004 10:13 PM
managing floating point vince_2x Linux - General 2 09-21-2004 09:05 PM
how to preserve the floating point calculation in linux suchi_s Programming 3 09-09-2004 10:30 AM


All times are GMT -5. The time now is 04:41 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration