While debugging a problem related to C++ exceptions I noticed
something strange. When generating code for a handler label, a
function entry is output rather than just a label. For example, given
the following test program:
1 #include <stdio.h>
2 #include <string.h>
3
4 int main()
5 {
6 char *str;
7
8 try {
9 str = new char[6];
10 }
11 catch (...) {
12 printf("alloc failed\n");
13 }
14 strcpy(str, "Hello");
15 printf("%s\n", str);
16 return 0;
17 }
The code generated for main() for x86-64 includes main, plus two
additional functions Handler.0.770, and Handler.0.2050. Worse, some
parts of the non-handler code of main() are associated with these
functions, making debugging confusing:
(gdb) b 14
Breakpoint 1 at 0x400920: file e.cxx, line 14.
(gdb) r
Starting program: ...
Breakpoint 1, Handler.0.2050 () at e.cxx:14
14 strcpy(str, "Hello");
The code in Open64 that generates the function is in osprey/be/cg/whirl2ops.cxx:
...
6408 if (WN_Label_Is_Handler_Begin(entry)) {
6409 // handlers are LABELS, but want function ST in entryinfo.
6410 // So create a dummy func ST for this pseudo-altentry.
...
6416 #ifdef KEY
6417 char *name = (char *) alloca (strlen("Handler")+1+8+1);
6418 sprintf (name, "Handler.%d", Current_PU_Count());
6419 ST_Init (entry_st, Save_Str2i (name, ".", Get_WN_Label(entry)),
6420 CLASS_FUNC, SCLASS_TEXT, EXPORT_LOCAL, (TY_IDX) pu_idx);
...
I do not understand the comment about wanting function ST in entryinfo
and could not find any more info in the svn log.
Is there anyone who can shed some light on why we need function
entries for handler labels?
-David Coakley / AMD Open Source Compiler Engineering
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Open64-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open64-devel