This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/F28M35H52C: Generating and Using Profile Information

Part Number: F28M35H52C
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: TI C/C++ Compiler

Hello,

The ARM Compilers Users Guide (spnu151t.pdf) talks about generating and using profile information. 

Since our target device does not have access to a file system I am trying to figure out a way to extract the profile information after doing a run.

The document says the follows: "You can install a device handler for the PPHNDL device to
re-direct the profile data to a custom device driver routine. For example, this could
be used to send the profile data to a device that does not use a file system.
Feedback directed optimization requires you to turn on at least some debug
information when using the --gen_profile_info option. "

My problem is that I cannot find any detailed information regarding creating and installing a custom device driver routine and how to install this as the PPHNDL device.

Can somebody please point me to documentation and possibly examples on how to do this?

Thanks you much,

Bob Lewis

  • Unfortunately, we don't have an example of doing exactly that.  I suggest you learn how to create a device driver by reading the article RAMDISK: A Sample User-Defined C I/O Driver.  You need to create a device driver similar to that one.  Instead of naming it "ramdisk", name it "PPHNDL" instead.

    Thanks and regards,

    -George

  • Hello. Well it seems that I was able to install a custom driver based on your example.
    But now I am at the point where I am trying to analyze the data and I get an error.
    I am using the following command:
    armpdd -e Program.out -o pprofout.prf pprofout.pdat
    and I get the following error:
    fatal error: Invalid file magic TIPPRD
    When I look in the pprofout.pdat file it does start with the first six bytes equal to TIPPRD, so

    I do not understand what this error message means.
    I attempted to attached the pprofout.pdat file for your review but for some reason it would not attach.

    Any help is appreciated.
    Thanks
    Bob Lewis
  • Bob Lewis said:
    I attempted to attached the pprofout.pdat file for your review but for some reason it would not attach.

    To avoid problems, the forum only accepts a few different file types as attachments.  Please put it inside a zip file, then attach the zip file.

    Thanks and regards,

    -George

  • Hello.  Well it seems that I was able to install a custom driver based on your example.
    But now I am at the point where I am trying to analyze the data and I get an error.
    I am using the following command:
       armpdd -e Program.out -o pprofout.prf pprofout.pdat
    and I get the following error:
       fatal error: Invalid file magic TIPPRD
    When I look in the pprofout.pdat file it does start with the first six bytes equal to TIPPRD, so

    I do not understand what this error message means.

    Attached is the .prf file that was generated by the compiler.pprofout.zip

  • I apologize.  I should have asked you to include the Program.out file in the zip file.  Please send it as well.

    Thanks and regards,

    -George

  • Hi George,

    I don't believe I am at liberty to share our .out file.

    Instead, would it be possible for you to work up a very simple example of capturing profile/code coverage information?

    We are using compiler arm_15.12.3.LTS, Manifest ID - SRAS00001960.

    I have been attempting to follow the instructions given in document spnu151lt.pdf, under

    chapter 3.8 Using Profile Information to Analyze Code Coverage

    Would that be possible?

    Thanks,

    Bob Lewis

  • Bob Lewis said:
    I don't believe I am at liberty to share our .out file.

    I understand.  Are you able to send it just to me?  If so, use the private messaging feature of the forum.  Hover your mouse over my screen name or avatar. A box will pop up. Click on Send a private message. In the message compose interface which comes up, use the paper clip icon to attach the zip file.

    Bob Lewis said:
    Instead, would it be possible for you to work up a very simple example of capturing profile/code coverage information?

    That is a reasonable request.  But I am confused as to why you want it.  Is this for me to attempt to reproduce your problem?  Or, it is an example you would follow?

    Thanks and regards,

    -George

  • Hi George,
    No, I am unable to share the .out file outside of our group.
    But yes, if you can work up a short example, even a simple hello world program, and run it through the steps to produce the final coverage information that would be great. I suspect if you use the same tool set I am using, which I mentioned the compiler version in my earlier message, you will most likely come across the same problem I did. If you don't that's great, because then I will have at least one example that works.
    Thanks,
    Bob
  • Regarding ...

    Bob Lewis said:
    fatal error: Invalid file magic TIPPRD

    I filed CODEGEN-5872 in the SDOWP system to have this investigated.  You are welcome to follow it with the SDOWP link below in my signature.  

    Regarding the example you have requested ... That is going to take longer than I first thought.  I'll get back to you on that.

    Thanks and regards,

    -George

  • Some analysis regarding the invalid file magic error ...

    The file should begin with these bytes (rendered as ASCII characters here) ...

    TI_PDDTIPPRD

    Your file is missing the initial 6 bytes.  It starts ...

    TIPPRD

    The code which writes out the collected profile data is part of the compiler RTS library.  The source to the RTS library is part of the compiler installation.  If you have it installed as part of CCS, then it can found in a location similar to ...

    C:\ti\ccsv8\tools\compiler\arm_15.12.3.LTS\lib\src

    The code which writes out the collected profile data is in the file outprof.c.  After inspecting the code in that file, I suspect the problem is the open call in your custom device driver (the one named PPHNDL) fails to return the value -1 on error.  Inspect the code in the function _output_path_profile_info (or even better, step through it), and I think it will become clear.

    Thanks and regards,

    -George

  • Hi George,

    Great work!! Thank you.  Yes that did the trick.  I now get the proper magic value.

    Now on to the next problem which is feeding the .prf file back into the compiler.  I use the following command line and the compiler completes with no complaints, but I am not able to find any output results.

    c:\ti\ccsv6\tools\compiler\arm_15.12.3.LTS\bin\armcl --include_path=c:\ti\ccsv6\tools\compiler\arm_15.12.3.LTS\include --include_path=C:\ti\controlSUITE\device_support\f28m35x\v220\MWare --use_profile_info=pprofout.prf --onlycodecov helloworld.c

    I thought there should be some output files such as .csv .

    If you were able to get a small hello world example to work that will be great.

    Thanks for your hard work,

    Bob Lewis

  • The CSV file, by default, is written to whatever is the current directory when the compiler is invoked.  In a complicated build driven by make (which includes CCS), this can be difficult to determine.  So, set the environment variable TI_COVDIR to specify exactly what directory to use for generating the CSV file.

    Thanks and regards,

    -George

  • Hello George,

    Yes, I tried defining TI_COVDIR and still no .csv files are being generated, and no error messages of any kind are emitted by the compiler.

    Will you be able to work up a simple hello world example?

    Thanks,

    Bob Lewis

  • Bob Lewis said:
    Will you be able to work up a simple hello world example?

    Unfortunately, not yet.  In the mean time, would it be possible for you to write a simple hello world program, then profile that?  I'm guessing you still won't get a CSV file.  But you would be able to send me that project, and we could investigate the problem.

    Thanks and regards,

    -George

  • Hi George,

    Ok attached is a zip file with a simple program that can be profiled. You will notice that there is a pprofout.pdat file and a pprofout.prf file that I was able to generate.  But yes, have not been able to produce the report .csv files.

    Let me know if you have any questions.

    CoverageTesting.zip

  • I apologize for the delay.

    Thank you for sending the example project.  I am able to use it to generate the CSV files.  I had to change the compiler build options.  I removed the option --gen_profile_info.  Then I added an entry under --use_profile_info to point to the pprofout.prf file you generated.  See the screenshot below for the details.  (I used the PROJECT_LOC variable to have a path that works in more contexts.  Feel free to just hard code that path.)  After building, the CSV files appear in the Source directory, which is the directory where the C source files are located.

    Thanks and regards,

    -George

  • **** Build of configuration Debug for project CoverageTest ****
    
    "c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all 
    'Building file: C:/CoverageTesting/Source/AddDriver.c'
    'Invoking: ARM Compiler'
    "c:/ti/ccsv6/tools/compiler/arm_15.12.3.LTS/bin/armcl" -mv7M3 --code_state=16 -me --include_path="c:/ti/ccsv6/tools/compiler/arm_15.12.3.LTS/include" --include_path="C:/ti/controlSUITE/device_support/f28m35x/v220/MWare" -g --gcc --define=ccs --diag_wrap=off --diag_warning=225 --display_error_number --gen_func_subsections=on --abi=eabi --use_profile_info="C:/CoverageTesting/ResultData/pprofout.prf" --analyze=codecov --ual --preproc_with_compile --preproc_dependency="AddDriver.pp"  "C:/CoverageTesting/Source/AddDriver.c"
    'Finished building: C:/CoverageTesting/Source/AddDriver.c'
    ' '
    'Building file: C:/CoverageTesting/Source/HelloWorld.c'
    'Invoking: ARM Compiler'
    "c:/ti/ccsv6/tools/compiler/arm_15.12.3.LTS/bin/armcl" -mv7M3 --code_state=16 -me --include_path="c:/ti/ccsv6/tools/compiler/arm_15.12.3.LTS/include" --include_path="C:/ti/controlSUITE/device_support/f28m35x/v220/MWare" -g --gcc --define=ccs --diag_wrap=off --diag_warning=225 --display_error_number --gen_func_subsections=on --abi=eabi --use_profile_info="C:/CoverageTesting/ResultData/pprofout.prf" --analyze=codecov --ual --preproc_with_compile --preproc_dependency="HelloWorld.pp"  "C:/CoverageTesting/Source/HelloWorld.c"
    'Finished building: C:/CoverageTesting/Source/HelloWorld.c'
    ' '
    'Building file: C:/CoverageTesting/Source/startup_ccs.c'
    'Invoking: ARM Compiler'
    "c:/ti/ccsv6/tools/compiler/arm_15.12.3.LTS/bin/armcl" -mv7M3 --code_state=16 -me --include_path="c:/ti/ccsv6/tools/compiler/arm_15.12.3.LTS/include" --include_path="C:/ti/controlSUITE/device_support/f28m35x/v220/MWare" -g --gcc --define=ccs --diag_wrap=off --diag_warning=225 --display_error_number --gen_func_subsections=on --abi=eabi --use_profile_info="C:/CoverageTesting/ResultData/pprofout.prf" --analyze=codecov --ual --preproc_with_compile --preproc_dependency="startup_ccs.pp"  "C:/CoverageTesting/Source/startup_ccs.c"
    'Finished building: C:/CoverageTesting/Source/startup_ccs.c'
    ' '
    'Building target: CoverageTest.out'
    'Invoking: ARM Linker'
    "c:/ti/ccsv6/tools/compiler/arm_15.12.3.LTS/bin/armcl" -mv7M3 --code_state=16 -me -g --gcc --define=ccs --diag_wrap=off --diag_warning=225 --display_error_number --gen_func_subsections=on --abi=eabi --use_profile_info="C:/CoverageTesting/ResultData/pprofout.prf" --analyze=codecov --ual -z -m"CoverageTest.map" --stack_size=256 --heap_size=0 -i"c:/ti/ccsv6/tools/compiler/arm_15.12.3.LTS/lib" -i"C:/ti/controlSUITE/device_support/f28m35x/v220/MWare/lib" -i"C:/ti/controlSUITE/device_support/f28m35x/v220/MWare/driverlib/ccs/Debug" -i"c:/ti/ccsv6/tools/compiler/arm_15.12.3.LTS/include" --reread_libs --diag_wrap=off --warn_sections --display_error_number --xml_link_info="CoverageTest_linkInfo.xml" --rom_model -o "CoverageTest.out"  "./startup_ccs.obj" "./HelloWorld.obj" "./AddDriver.obj" "C:/CoverageTesting/Source/F28M35x_generic_M3_FLASH.cmd" -l"rtsv7M3_T_le_eabi.lib" -l"F021_API_CortexM3_LE.lib" -l"driverlib.lib" 
    <Linking>
    'Finished building target: CoverageTest.out'
    ' '
    
    **** Build Finished ****
    
     Hello George,

    I tried what you show here and still no .csv files anywhere.

    Attached is a screenshot showing the config I used along with a file that contains the build commands that are emitted.

    Maybe you can send me the build commands that your build is emitting so that we can compare.

    Maybe we are using two different versions of compilers.  It does appear that we are using different version of CCS.

    Thanks,

    Bob

  • Hi George,

    To let you know, after generating the pprofout.prf I modified it to remove all occurrences of the following text:
    C:\CoverageTesting\Workspace\CoverageTest\Debug/
    After doing this I am able to generate the .csv files which show up under folder:
    C:\CoverageTesting\Workspace\CoverageTest\Debug
    So for some reason when I run the following armcl command it puts the extra text that I removed in the .prf file, which I guess the compiler does not like when generating the .csv files.
    c:\ti\ccsv6\tools\compiler\arm_15.12.3.LTS\bin\armpdd -e CoverageTest.out -o pprofout.prf pprofout.pdat

    Thanks for the help,
    Bob
  • I apologize for the delay.

    I have tried to reproduce this behavior where you get this extra text in the .prf file ...

    Bob Lewis said:
    C:\CoverageTesting\Workspace\CoverageTest\Debug/

    Unfortunately, I cannot reproduce it.  Thus, I don't know what causes that problem.  At this point, I'm stuck.  I'll talk it over with some colleagues and get back to you.

    Thanks and regards,

    -George

  • I discovered that I can reproduce this extra text in the .prf file ...

    Bob Lewis said:
    C:\CoverageTesting\Workspace\CoverageTest\Debug/

    ... if I use version 15.12.3.LTS to build the project, and then run armpdd with your pprofout.pdat file as input.  When I change the version to 18.12.0.LTS, and do the same thing, I do not get the extra text.  So, is it practical for you to upgrade to compiler version 18.12.x.LTS?

    Thanks and regards,

    -George

  • Hi George,

    Excellent.  I verified your statement by testing with version ti-cgt-arm_18.12.1.LTS

    Thank you for your hard work.

    I consider this case closed.

    Thanks again,

    Bob Lewis