Pelles C forum

Pelles C => Add-ins => Topic started by: Pelle on November 27, 2004, 11:24:31 AM

Title: Switch between Release, Debug or Profile build
Post by: Pelle on November 27, 2004, 11:24:31 AM
Extended version of the add-in that switches between debug and release build: third button for profile build (writes information to executable.prf when the program is run).

Author: Alexander Stoica
Title: Re: Switch between Release, Debug or Profile build
Post by: JohnF on November 27, 2004, 12:07:36 PM
Quote from: "Pelle"
Extended version of the add-in that switches between debug and release build: third button for profile build (writes information to executable.prf when the program is run).

Author: Alexander Stoica


Very nice!

John
Title: Switch between Release, Debug or Profile build
Post by: Mike Henning on November 28, 2004, 01:57:27 AM
I agree, very nice! Is there a separate viewer available that will parse the log file and compute the totals, percentages and that sort of thing?

Thanks,
Mike H.
Title: Switch between Release, Debug or Profile build
Post by: Pelle on November 28, 2004, 09:44:58 PM
Quote from: "Mike Henning"
I agree, very nice! Is there a separate viewer available that will parse the log file and compute the totals, percentages and that sort of thing?

Not that I'm aware of. A more 'visual' presentation has been on my wishlist for years, but no time so far. Maybe someone else...?

Pelle
Title: Switch between Release, Debug or Profile build
Post by: nitex on December 23, 2004, 07:05:48 PM
i have started developing a *.prf viewer for pelles c. it is still in a very early state. i will publish a first version here when finished.

greets alex
Title: Switch between Release, Debug or Profile build
Post by: Pelle on December 23, 2004, 08:58:34 PM
Quote from: "nitex"
i have started developing a *.prf viewer for pelles c. it is still in a very early state. i will publish a first version here when finished.

Great! Looking forward to seeing it...

Pelle
Title: Switch between Release, Debug or Profile build
Post by: nitex on January 14, 2005, 06:03:21 PM
here is a first screenshot of the prf view program i'm currently writing.

the program is based on internet explorer, this allows writing report generation templates with some knowledge in html, css and javascript and the program can be integrated with a addin into the pelles c ide for easy access.

i will realease it as freeware until i have finished implementing all the stuff i want and after that with full sourcecode so that it can be enhanced by other people.

greets, alex
Title: Switch between Release, Debug or Profile build
Post by: Pelle on January 14, 2005, 06:44:03 PM
Cool !!!  :D  :D

Pelle
Title: Switch between Release, Debug or Profile build
Post by: Anonymous on January 21, 2005, 06:53:20 PM
PRF View Alpha Build 1 Readme (21.01.05)

here is a first alpha build of PRF View. please note that this is no final version and may contain bugs which i haven't found yet. i would like to hear some comments about the parsing performance on big projects. may be someone can post a big profiler log as zip file in the forum.

requirements:

the program was successfully tested on Win98 SE / IE 6 and WinXP Pro SP2 / IE 6. if you're getting script errors or some menu commands do not work it is probably because of an old browser version.

Quote
options:

- "use owner drawn menus"
self-instructional

- "print background colors and pictures"
this is the same option like in internet explorer. if not activated you won't see the colored charts if you print a report.

- "register *.prf files with PRF View"
allows you to doubleclick a prf file if activated. if you deactivate this option, PRF View will restore the extension to internet explorer (PICS Rules File).

missing:

 - new window command
 - template library and support
 - statusbar has no useful implementation
 - mru list
 - addin for pelles c ide
 - help
 - better error checking
 - better path handling

known problems:

 - can't handle paths longer than MAX_PATH (260)



if you find bugs or have ideas for additional features you may post them
in the forum:

  http://smorgasbordet.com/phpBB2/viewtopic.php?t=257

or you can write a mail to:

  nitex@freenet.de

and now, happy profiling.

  Alexander Stoica
Title: Switch between Release, Debug or Profile build
Post by: nitex on January 21, 2005, 06:59:24 PM
i forgot to login, sorry.
Title: bug?
Post by: TBD on January 22, 2005, 07:38:09 AM
Error: Unable to parse file contents!

.prf file:
Code: [Select]

2005-01-22, 08.11.55:
 7150 ms,       1 time(s): address 00401000
  321 ms,     297 time(s): address 004010b2
  230 ms,    2325 time(s): address 0040129e
  180 ms,       4 time(s): address 0040116c
    0 ms,     297 time(s): address 00401148
Title: Switch between Release, Debug or Profile build
Post by: TBD on January 22, 2005, 07:42:26 AM
after playing a bit with the settings, I get this .prf file but with the same error - Unable to parse file contents!

Code: [Select]


2005-01-22, 08.40.37:
 4908 ms,       1 time(s): _WinMain@16
  260 ms,     273 time(s): _LV_InsertItem
  160 ms,       3 time(s): _sql_search@4
   60 ms,    2201 time(s): _MainDlgProc@16
    0 ms,     273 time(s): _sql_callback
Title: Switch between Release, Debug or Profile build
Post by: Pelle on January 27, 2005, 12:27:19 AM
Browsing to a different directory than where prfview.exe lives, will give the "Unable to parse file contents!" error. Seems like a problem with the "current directory".

I copied the attached file (pocc.prf) to the same directory as prfview.exe, then I can get a bit further - but soon I get a script error:

Line: 55
Char: 19
Error: 'prf[...].ftime.length' is null or not an object
Code: 0
URL: file://C:\prfview\templates\standard.html

Any ideas?

Pelle
Title: Switch between Release, Debug or Profile build
Post by: nitex on January 28, 2005, 05:47:22 PM
Sorry, for the directory problem, here is the second alpha. I used relative pathnames in the code, so the current directory was wrong.

Quote
Edit: I removed the alpha2, i have zipped the wrong executable. I will post correct version in some days.


To Pelle: The problem with your file is that i'm checking for a @ char in the function name. I will fix this in next version.
Greets Alex
Title: Switch between Release, Debug or Profile build
Post by: TBD on January 28, 2005, 05:55:53 PM
still "Unable to parse file contents!" :(
I moved in the prfview directory - same error.

what should I try else ?
Title: Switch between Release, Debug or Profile build
Post by: Anonymous on January 28, 2005, 06:06:27 PM
i had completely rewritten the parser, i have saved all posted prf files and will test them at home. sorry for the problems.  :oops:
Title: Switch between Release, Debug or Profile build
Post by: Pelle on January 28, 2005, 06:54:08 PM
No problem - you said it was alpha. Looking forward to the next version...  =P~  8-[

Pelle
Title: Switch between Release, Debug or Profile build
Post by: nitex on January 29, 2005, 05:37:52 PM
Here is the fixed version, hopefully no parsing problems anymore. At least all posted profiler logs were correct opened.

Quote
PRF View History

Version 1.0.0.0 Alpha Build 3 (29.01.2005)
  - Fixed: The checks while parsing the *.prf file were changed. The parser now
    looks if it finds the chars -,.: in a line for profiling session date and
    time, or ,:() for function time, number of calls and function name.
  - Fixed: The parser sometimes stripped some chars from the function name.
  - New: Integrated dummy help file.

Version 1.0.0.0 Alpha Build 2 (28.01.2005)
  - Fixed: *.prf files were opened only if they layed in the program directory
    (blame on me)
  - Fixed: The banners in the option and about dialog disappeared sometimes if
    other windows layed over them.
  - Fixed: Layout of banners in dialogs should be correct now with bigger
    windows fonts
  - New: Owner Drawn Buttons with pictures, and option to disable them.
  - New: Parser is completely rewritten.

Version 1.0.0.0 Alpha Build 1 (21.01.2005)
  - First public release
Title: Switch between Release, Debug or Profile build
Post by: Pelle on January 29, 2005, 06:19:36 PM
Rock 'n' Roll! Well done!  =D>  \:D/

Pelle
Title: Switch between Release, Debug or Profile build
Post by: TBD on January 29, 2005, 06:24:15 PM
nitex: yupeee. now it works perfectly  =D>

maybe you can share with us how to render html pages using IExplore  :lol:
Title: Switch between Release, Debug or Profile build
Post by: nitex on January 29, 2005, 06:27:22 PM
Have a look in the credits, there is a link to an article i used for embedding the Internet Explorer.

Alex
Title: profiling console based programs
Post by: khyron on May 23, 2005, 07:59:10 PM
hi there,

just a little question about the debug, release and profile addin, if I create a new console project and press the prf button i get the following  errors:

POLINK: error: Unresolved external symbol '__imp__MessageBoxA'.
POLINK: error: Unresolved external symbol '__imp__wsprintfA'.
POLINK: fatal error: 2 unresolved external(s).

I usually solve it adding user32.lib in the linker section, is this the correct way of solving it? if it is maybe it could be useful if the addin added that library automatically for console based projects....
Title: Switch between Release, Debug or Profile build
Post by: nitex on May 23, 2005, 09:12:18 PM
This can be easily fixed by modifying the SetLinkerFlags() function.

Change:
Code: [Select]
case ID_PROFILE:
{
lstrcpy(szNew, _T("-debug -debugtype:both profiler.lib"));
break;
}


To:
Code: [Select]
case ID_PROFILE:
{
lstrcpy(szNew, _T("-debug -debugtype:both profiler.lib user32.lib"));
break;
}


And:
Code: [Select]
/* Forget old options */
if (lstrcmp(psz, _T("-release")) == 0 ||
lstrcmp(psz, _T("-debug")) == 0 ||
lstrcmp(psz, _T("-debugtype:both")) == 0 ||
lstrcmp(psz, _T("-debugtype:coff")) == 0 ||
lstrcmp(psz, _T("-debugtype:cv")) == 0 ||
lstrcmp(psz, _T("profiler.lib")) == 0)
continue;


To:
Code: [Select]
/* Forget old options */
if (lstrcmp(psz, _T("-release")) == 0 ||
lstrcmp(psz, _T("-debug")) == 0 ||
lstrcmp(psz, _T("-debugtype:both")) == 0 ||
lstrcmp(psz, _T("-debugtype:coff")) == 0 ||
lstrcmp(psz, _T("-debugtype:cv")) == 0 ||
lstrcmp(psz, _T("profiler.lib")) == 0 ||
lstrcmp(psz, _T("user32.lib")) == 0)
continue;


Alex
Title: Switch between Release, Debug or Profile build
Post by: khyron on May 23, 2005, 10:25:08 PM
hello, thanks for your help and your fast reply!

I patched the code as suggested but I run into a problem, the addin does not work anymore for normal windows apps because it removes user32.lib when your press debug or release...

in the end I just did:

      case ID_PROFILE:
      {
         lstrcpy(szNew, _T("-debug -debugtype:both profiler.lib user32.lib"));
         break;
      }

it works now for both scenarios for me (it leaves user32.lib in the linker for debug and release in console apps but it doesn´t bother me).
Title: Switch between Release, Debug or Profile build
Post by: nitex on May 23, 2005, 11:40:38 PM
Seems i forgot a check, try this one.

Code: [Select]
static BOOL SetLinkerFlags(int idCmd)
{
TCHAR szOld[1024], szNew[1024], *psz;

/* Get the current linker options */
if (AddIn_GetProjectSymbol(g_hwndPrj, _T("LINKFLAGS"), szOld, NELEMS(szOld)) == 0)
return FALSE;

/* Set the new options */
switch (idCmd)
{
case ID_RELEASE:
{
lstrcpy(szNew, _T("-release"));
break;
}
case ID_DEBUG:
{
lstrcpy(szNew, _T("-debug -debugtype:both"));
break;
}
case ID_PROFILE:
{
            if (_tcsstr(szOld, _T("console")) == NULL)
{
lstrcpy(szNew, _T("-debug -debugtype:both profiler.lib"));
}
else
{
lstrcpy(szNew, _T("-debug -debugtype:both profiler.lib user32.lib"));
}

break;
}
}

    if (_tcsstr(szOld, _T("console")) == NULL)
    {
/* Walk through the current options and build the new options */
for (psz = _tcstok(szOld, _T(" ")); psz != NULL; psz = _tcstok(NULL, _T(" ")))
{
/* Forget old options */
if (lstrcmp(psz, _T("-release")) == 0 ||
lstrcmp(psz, _T("-debug")) == 0 ||
lstrcmp(psz, _T("-debugtype:both")) == 0 ||
lstrcmp(psz, _T("-debugtype:coff")) == 0 ||
lstrcmp(psz, _T("-debugtype:cv")) == 0 ||
lstrcmp(psz, _T("profiler.lib")) == 0)
continue;

/* Add this option to the new linker options */
if (szNew[0] != '\0')
lstrcat(szNew, _T(" "));
lstrcat(szNew, psz);
}
}
else
{
/* Walk through the current options and build the new options */
for (psz = _tcstok(szOld, _T(" ")); psz != NULL; psz = _tcstok(NULL, _T(" ")))
{
/* Forget old options */
if (lstrcmp(psz, _T("-release")) == 0 ||
lstrcmp(psz, _T("-debug")) == 0 ||
lstrcmp(psz, _T("-debugtype:both")) == 0 ||
lstrcmp(psz, _T("-debugtype:coff")) == 0 ||
lstrcmp(psz, _T("-debugtype:cv")) == 0 ||
lstrcmp(psz, _T("profiler.lib")) == 0 ||
            ((idCmd != ID_PROFILE) && (lstrcmp(psz, _T("user32.lib")) == 0)))
continue;

/* Add this option to the new linker options */
if (szNew[0] != '\0')
lstrcat(szNew, _T(" "));
lstrcat(szNew, psz);
}
}

/* Set the new linker options */
return AddIn_SetProjectSymbol(g_hwndPrj, _T("LINKFLAGS"), szNew);
}
Title: Switch between Release, Debug or Profile build
Post by: khyron on May 24, 2005, 12:53:05 AM
it works perfectly  :D
thanks!!!
Title: Switch between Release, Debug or Profile build
Post by: nitex on May 25, 2005, 12:57:36 PM
New version of the Addin which fixes the error pointed out by khyron and and a new error introduced by me. The check for the console project was changed from
Code: [Select]
if (_tcsstr(szOld, _T("console")) == NULL) to
Code: [Select]
if (_tcsstr(szOld, _T("-subsystem:console")) == NULL)

This could otherwise fail to build projects which include a console.lib for example.