Hi all.
I implemented a simple test case to test my theory that my platform does not support the regparms(0) function attribute and my theory is bunk. bleah.
I modified this autotools tutorial's source files at
http://www.gnu.org/software/automake/manual/html_node/Creating-amhello.html
to mimic the __attribute__((regparms(0))) behavior in cog.
I could not recreate the error under any compination of PRODUCTION and #if #else conditions. I am at a loss at the moment (and sick with a cold) so I will have to revisit this later. CMakeVMMakerSqueak dev is blocked by this issue.
I added a test.h file to the src directory that looks like this:
bash-4.2$ cat test.h #undef NoDbgRegParms #define PRODUCTION 1 #if !PRODUCTION && defined(__GNUC__) && !defined(NoDbgRegParms) # define NoDbgRegParms __attribute__ ((regparm(0))) #else # define NoDbgRegParms __attribute__ ((deprecated)) #endif
int plus (int a, int b) NoDbgRegParms;
and modified the main.c . bash-4.2$ cat src/main.c #include <config.h> #include <stdio.h> #include "test.h"
int main(void){ int p;
puts("Hello World!"); puts ("This is " PACKAGE_STRING ".");
p=plus(3,3);
printf("%d\n",p); return 0; }
int plus (int a, int b) { return a + b; }
Hi Tim,
the attributes are only ever meaningful for static functions. gcc (and other compilers) use faster register-based calling conventions where possible when the optimize. Non-static functions can't be so optimized because they have to accord with the Application Binary Interface (ABI) and on x86 that's a purely stack-based calling convention. But static functions are not visible outside the file and so the optimizer is free to so optimize. But that breaks the use of static functions within gdb; gdb only knows how to call functions that accord with the ABI. Given that we don't care too much about performance in the Debug and Assert VMs but we /do/ care about debuggability (and hence being able to call useful functions, be they static or not) I try and apply the "don't use register parameters" attribute to these functions.
Des this make sense to you? Cuz if it isn't you need to understand it before you can fix it, otherwise you'll waste a lot of effort chasing down rat holes.
On Tue, Mar 31, 2015 at 3:33 PM, gettimothy gettimothy@zoho.com wrote:
Hi all.
I implemented a simple test case to test my theory that my platform does not support the regparms(0) function attribute and my theory is bunk. bleah.
I modified this autotools tutorial's source files at
http://www.gnu.org/software/automake/manual/html_node/Creating-amhello.html
to mimic the __attribute__((regparms(0))) behavior in cog.
I could not recreate the error under any compination of PRODUCTION and #if #else conditions. I am at a loss at the moment (and sick with a cold) so I will have to revisit this later. CMakeVMMakerSqueak dev is blocked by this issue.
I added a test.h file to the src directory that looks like this:
bash-4.2$ cat test.h #undef NoDbgRegParms #define PRODUCTION 1 #if !PRODUCTION && defined(__GNUC__) && !defined(NoDbgRegParms) # define NoDbgRegParms __attribute__ ((regparm(0))) #else # define NoDbgRegParms __attribute__ ((deprecated)) #endif
int plus (int a, int b) NoDbgRegParms;
and modified the main.c .
bash-4.2$ cat src/main.c #include <config.h> #include <stdio.h> #include "test.h"
int main(void){ int p;
puts("Hello World!"); puts ("This is " PACKAGE_STRING ".");
p=plus(3,3);
printf("%d\n",p); return 0; }
int plus (int a, int b) { return a + b; }
Hi Eliot,
Thanks for your reply.
the attributes are only ever meaningful for static functions. gcc (and other compilers) use faster register-based calling conventions where possible when the optimize. Non-static functions can't be so optimized because they have to accord with the Application Binary Interface (ABI) and on x86 that's a purely stack-based calling convention. But static functions are not visible outside the file and so the optimizer is free to so optimize. But that breaks the use of static functions within gdb; gdb only knows how to call functions that accord with the ABI. Given that we don't care too much about performance in the Debug and Assert VMs but we /do/ care about debuggability (and hence being able to call useful functions, be they static or not) I try and apply the "don't use register parameters" attribute to these functions.
Des this make sense to you? Cuz if it isn't you need to understand it before you can fix it, otherwise you'll waste a lot of effort chasing down rat holes.
Yes, it makes perfect sense in the abstract. The use of GDB in the concrete to see if the function attributes are actually in place is the specific task I do not know how to approach (I could learn, my gdb skills are rudimentary) so I asked.
My last email about gcc -E confirms the problem is at the cpp stage (fingers crossed). The "fix" of putting #define NoDbgRegParms in config.h.in probably only masked the error; it is that 'false positive' I wanted to confirm.
cheers.
tty
vm-dev@lists.squeakfoundation.org