This is the mail archive of the mailing list for the Cygwin 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[8]: vmstat

Hello Chris,

Thursday, July 04, 2002, 5:21:07 PM, you wrote:

>> CJ> uptime reads the /proc files regardless of what options you pass.
>> int main(int argc, char *argv[]) {
>>   if(argc == 1) print_uptime();
>>   if((argc == 2) && (!strcmp(argv[1], "-V"))) display_version();
>>   return 0;
>> }
>> How ?
CJ> Try re-compiling with print_uptime commented out. Notice how it works. Now
CJ> put print_uptime back in. Notice how it doesn't work, regardless of what
CJ> arguments you pass. Magic!
CJ> Run it in gdb - notice how it doesn't reach the first line after main().
CJ> Notice how stepping assembly instructions the program wanders off into
CJ> invalid memory.

I did all this :) Noticed that it is not invalid memory, but cygwin
initializing global constructors. In fact at the end when you are
stepping the instructions you have to issue 'stepi' command and you
will enter init_Hertz_value() - or you can just put a breakpoint on
init_Hertz_value (). It causes the loop with stock 1.3.12.

There are three functions in procps.a with "__attribute__
((constructor))__" these are called by cygwin __main () before
the actual code of main ().

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