This is the mail archive of the
cygwin-apps@cygwin.com
mailing list for the Cygwin project.
Re[8]: vmstat
- From: Pavel Tsekov <ptsekov at syntrex dot com>
- To: "Chris January" <chris at atomice dot net>
- Cc: cygwin-apps at cygwin dot com
- Date: Thu, 4 Jul 2002 17:29:28 +0200
- Subject: Re[8]: vmstat
- Organization: Syntrex, Inc.
- References: <OF9302AC86.0EB950DE-ON85256BE4.005579C2@isn.instinet.com><00b901c21df9$1c9e3df0$0100a8c0@advent02> <20020627163750.GA27819@redhat.com><010901c21dfa$de6d74e0$0100a8c0@advent02> <3D1B5A59.7090609@ece.gatech.edu><3D1B92A6.4020707@ece.gatech < <003101c2236e$6cbdada0$0100a8c0@advent02>
- Reply-to: Pavel Tsekov <cygwin-apps at cygwin dot com>
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 ().