diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..bd0f04d --- /dev/null +++ b/ChangeLog @@ -0,0 +1,589 @@ +2005-07-18 John Levon + + * libutil++/tests/Makefile.am: canonicalize + SRCDIR to fix make check + +2005-07-18 John Levon + + * configure.in: bump to 0.9.1 + +2005-07-11 John Levon + + * module/oprofile.c: fix for GCC 3.4, spotted by + Jason Lunz + +2005-01-06 Ralf Baechle + + * events/Makefile.am: + * events/mips/24K/events: + * events/mips/24K/unit_masks: + * libop/op_events.c: + * libop/op_cpu_type.h: + * libop/op_cpu_type.c: + * utils/ophelp.c: Add MIPS 24K support + +2005-06-16 Richard Purdie + + * utils/opcontrol: fix ARM kernels again after 2005-05-04 + change to op_bfd.cpp broke it again. Only look for .text + section for our kernel range. + +2005-06-13 Richard Purdie + + * libpp/callgraph_container.cpp: + * libpp/profile.cpp: ignore any symbols before .text + for start_offset profiles + +2005-06-02 Jason Lunz + + * libpp/diff_container.cpp: + * libpp/format_output.cpp: + * libutil++/bfd_support.cpp: + * libutil++/op_bfd.cpp: fix compilation on GCC 2.95.x, + older glibc + +2005-06-01 Philippe Elie + + * pp/opannotate_options.cpp: error out if --assembly and --output-dir + are used together + * doc/opannotate.1.in: + * doc/oprofile.xml: update docucmentation according. + +2005-05-31 John Levon + + * configure.in: bump to 0.9.1cvs + +2005-05-27 John Levon + + * libpp/diff_container.cpp: convert the diffs into + an actual percentage! + + * configure.in: bump to 0.9 + +2005-05-26 John Levon + + * daemon/opd_cookie.c: + * daemon/opd_sfile.c: + * daemon/opd_trans.c: fixes for image filtering + +2005-05-09 Will Cohen + + * daemon/opd_sfile.c: Fix variable declaration to compile on gcc 3.4. + +2005-05-04 Philippe Elie + + * pp/common_option.cpp: split argument "{}" in two separate argument + +2005-05-04 John Levon + + * doc/oprofile.xml: fix typos + +2005-05-04 Philippe Elie + + * libutil++/cverb.cpp: + * libutil++/cverb.h: fix comment, remove unecessary friend declaration. + +2005-05-04 John Levon + + * daemon/liblegacy/opd_kernel.c: fix previous workaround + so it only triggers on x86 + +2005-05-04 John Levon + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: don't assume .text is the first SEC_CODE + section. Keep a map of section file offsets to fix up dbfd + symbols. Remove broken sanity checks. + +2005-05-02 John Levon + + * doc/oprofile.xml: small change + +2005-05-02 John Levon + + * daemon/Makefile.am: + * daemon/opd_anon.h: + * daemon/opd_anon.c: + * daemon/init.c: + * daemon/opd_cookie.c: + * daemon/opd_events.h: + * daemon/opd_events.c: + * daemon/opd_mangling.c: + * daemon/opd_sfile.h: + * daemon/opd_sfile.c: + * daemon/opd_trans.h: + * daemon/opd_trans.c: + * daemon/liblegacy/opd_sample_files.c: + * doc/oprofile.xml: + * libabi/abi.cpp: + * libabi/opimport.cpp: + * libabi/tests/abi_test.cpp: + * libop/op_mangle.h: + * libop/op_mangle.c: + * libop/op_sample_file.h: + * libpp/callgraph_container.cpp: + * libpp/image_errors.cpp: + * libpp/op_header.cpp: + * libpp/parse_filename.cpp: + * libpp/populate.cpp: + * libpp/profile.h: + * libpp/profile.cpp: + * libpp/profile_spec.cpp: + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: + * pp/opannotate.cpp: + * pp/opgprof.cpp: add basic anon mapping support + +2005-04-28 John Levon + + * utils/opcontrol: + * doc/opcontrol.1.in: + * doc/oprofile.xml: add opcontrol --status + +2005-04-28 Philippe Elie + + * daemon/opd_sfile.c: clear only 256 entry in the sfile lru list + +2005-04-28 John Levon + + * libabi/abi.cpp: + * libabi/op_import.cpp: add cg_to_is_kernel to abi + + * configure.in: + * libabi/tests/Makefile.am: + * libabi/tests/abi_test.cpp: move test to subdir + +2005-04-28 Philippe Elie + + * module/ia64/op_pmu.c: compile fix, pfm_syst_info has been added + between 2.4.20 and 2.4.21 + +2005-04-27 Philippe Elie + + * libutil/op_file.h: op_file_readable() accept only regular file + * libutil/op_file.c: + * libutil++/tests/file_manip_tests.cpp: + +2005-04-27 John Levon + + * daemon/opd_sfile.h: + * daemon/opd_sfile.c: rewrite. Fix --no-vmlinux taking up + CPU when using call graph profiling + +2005-04-27 John Levon + + * daemon/oprofiled.h: remove dead prototype + +2005-04-25 Philippe Elie + + * daemon/opd_mangling.c: protect last against sfile lru deletion + * daemon/opd_sfile.c: allow null sfile to sfile_get(), sfile_put() + +2005-04-24 John Levon + + * daemon/opd_cookie.h: + * daemon/opd_cookie.c: + * daemon/opd_trans.c: + * daemon/opd_sfile.c: + * daemon/opd_stats.h: + * daemon/opd_stats.c: handle NO_COOKIE (drop on the floor) + + * m4/qt.m4: allow gcc 4.0 compile with Qt headers + by using -isystem + +2005-04-23 John Levon + + * configure.in: add --with-gcc, --with-binutils (for + development use only, undocumented) + +2005-04-22 Philippe Elie + + * libpp/locate_images.h: add a virtual dtor to extra_images::matcher + +2005-04-22 John Levon + + * doc/internals.xml: some paragraphs on call graphs + + * libop/op_events.h: + * libop/op_events.c: + * libutil/op_deviceio.h: + * libutil/op_deviceio.c: + * libutil/op_fileio.h: + * libutil/op_fileio.c: remove dead code + + * libutil/op_lock_file.h: + * libutil/op_lock_file.c: make a function static + + * libutil++/Makefile.am: + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: + * libutil++/bfd_support.h: + * libutil++/bfd_support.cpp: move lots of BFD gunk into + a separate file. Fix synth symbols support, with lots of + testing by Maynard. + + * libutil++/comma_list.h: remove unused set_p + + * pp/opannotate.cpp: complain less verbosely if the input file + couldn't be found + +2005-04-14 John Levon + + * libutil++/growable_vector.h: + * libpp/diff_container.cpp: fix fill() + + * pp/opreport.cpp: fix multiple apps for diff output + +2005-04-14 John Levon + + * daemon/opd_interface.h: + * daemon/opd_trans.c: remove legacy TRACE_END + + * daemon/liblegacy/opd_kernel.c: + * daemon/liblegacy/opd_proc.c: avoid attributing "no mapping" + samples to vmlinux when using --no-vmlinux via a sick hack + +2005-04-13 John Levon + + * libutil++/growable_vector.h: add fill() + + * libutil++/diff_container.cpp: use it + + * libpp/symbol_sort.cpp: code clean up + +2005-04-13 John Levon + + * libpp/diff_container.h: + * libpp/diff_container.cpp: syms doesn't need to be a member + +2005-04-13 Nathan Tallent + + * utils/opcontrol: fix unquoted variable references in 'test' + expressions + +2005-04-13 Maynard Johnson + + * libutil++/op_bfd.cpp: skip null-name section symbols + +2005-04-12 Philippe Elie + + * libutil++/string_manip.cpp: fix double formating when value are + negative + +2005-04-12 John Levon + + * libpp/arrange_profiles.h: + * libpp/arrange_profiles.cpp: + * pp/opreport_options.cpp: + * pp/common_option.cpp: verify diff profile classes match + +2005-04-12 John Levon + + * doc/oprofile.xml: + * doc/oprofile.1.in: document diff profiles + +2005-04-12 John Levon + + * libpp/diff_container.cpp: fix duplicate syms in output + + * pp/opreport.cpp: + * libpp/diff_container.h: + * libpp/diff_container.cpp: implement thresholding etc. + +2005-04-12 John Levon + + * libpp/Makefile.am: + * libpp/count_array.cpp: + * libpp/count_array.h: + * libpp/diff_container.cpp: + * libpp/diff_container.h: + * libpp/format_flags.h: + * libpp/format_output.cpp: + * libpp/format_output.h: + * libpp/profile_spec.cpp: + * libpp/profile_spec.h: + * libpp/symbol.h: + * libpp/symbol_functors.cpp: + * libpp/symbol_sort.cpp: + * libpp/symbol_sort.h: + * libutil++/Makefile.am: + * libutil++/growable_vector.h: + * libutil++/string_manip.cpp: + * libutil++/string_manip.h: + * pp/common_option.cpp: + * pp/common_option.h: + * pp/opannotate.cpp: + * pp/opannotate_options.cpp: + * pp/opannotate_options.h: + * pp/oparchive.cpp: + * pp/oparchive_options.cpp: + * pp/oparchive_options.h: + * pp/opdiff.cpp: + * pp/opdiff_options.cpp: + * pp/opdiff_options.h: + * pp/opgprof.cpp: + * pp/opgprof_options.cpp: + * pp/opgprof_options.h: + * pp/opreport.cpp: + * pp/opreport_options.cpp: + * pp/opreport_options.h: implement an initial version of diff + profiling + +2005-04-11 John Levon + + * doc/oprofile.xml: + * doc/opreport.1.in: + * doc/opannotate.1.in: + * pp/opreport_options.cpp: + * pp/opannotate_options.cpp: add -D and -% + +2005-04-11 John Levon + + * pp/opannotate.cpp: fix opannotate matching several binaries + +2005-04-09 Philippe Elie + + * libutil++/op_bfd.cpp: fix a segfault if a binary file can't be + accessed (opreport -gl; opannotate) problem and solution pointed + by Maynard P. Johnson . + * libutil++/op_bfd.h: op_bfd member function must check for a NULL + ibfd before using it. + +2005-04-07 John Levon + + * libutil/tests/Makefile.am: + * libutil++/tests/Makefile.am: + * libdb/tests/Makefile.am: + * libop/tests/Makefile.am: fix tests build + +2005-04-07 John Levon + + * m4/Makefile.am: + * m4/binutils.m4: + * configure.in: move binutils stuff into a macro + + * doc/oprofile.xml: fixes and improvements + +2005-04-07 John Levon + + * libpp/callgraph_container.cpp: hoist image/app name lookup + outside of the loop + +2005-04-07 John Levon + + * libutil++/op_bfd.cpp: performance improvements with handling + symbols + +2005-04-06 John Levon + + * libpp/populate.h: + * libpp/populate.cpp: + * libpp/callgraph_container.cpp: + * libutil++/cached_value.h: + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: + * pp/opannotate.cpp: + * pp/opreport.cpp: + * libutil++/tests/Makefile.am: + * libutil++/tests/cached_value_tests.cpp: tweak CRC buffer. + Do delayed debug info searching (makes no actual difference). + +2005-04-05 John Levon + + * libpp/format_output.cpp: add separator at first function + for opreport -c + +2005-04-05 John Levon + + * libpp/callgraph_container.h: + * libpp/callgraph_container.cpp: + * pp/opreport.cpp: + * pp/opreport_options.cpp: implement -i / -e for + opreport -c + +2005-04-05 John Levon + + * libpp/format_output.h: + * libpp/format_output.cpp: + * pp/opreport.cpp: + * pp/opreport_options.cpp: implement --global-percent + for opreport -c + +2005-04-04 John Levon + + * configure.in: + * doc/Makefile.am: + * doc/oprofile.xml: + * doc/opstack.1.in: + * doc/opreport.1.in: + * doc/oprofile.1.in: + * pp/.cvsignore: + * pp/Makefile.am: + * pp/opreport.cpp: + * pp/opreport_options.cpp: + * pp/opreport_options.h: + * pp/opstack.cpp: + * pp/opstack_options.cpp: + * pp/opstack_options.h: remove opstack in favour of opreport -c + + * libpp/callgraph_container.cpp: fix for new call-graph code + + * doc/oprofile.xml: + * doc/oparchive.1.in: document -x, re-organise manual + +2005-04-04 Maynard Johnson + + * configure.in: further check for bfd synthesised + symbols support + +2005-04-04 John Levon + + * libpp/callgraph_container.cpp: + * libpp/callgraph_container.h: + * libpp/format_flags.h: + * libpp/format_output.cpp: + * libpp/format_output.h: + * libpp/symbol.cpp: + * libpp/symbol.h: + * libpp/symbol_sort.cpp: + * libpp/symbol_sort.h: + * libutil++/op_bfd.cpp: + * pp/common_option.cpp: + * pp/common_option.h: + * pp/opstack.cpp: + * pp/opstack_options.cpp: + * pp/opstack_options.h: re-whack call-graph collection + and output format + +2005-04-03 Maynard Johnson + + * configure.in: + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: synthesis dotted symbols + if necessary + +2005-03-31 John Levon + + * HACKING: + * TODO: + * configure.in: + * doc/Makefile.am: + * doc/op_help.1.in: + * doc/ophelp.1.in: + * doc/oprofile.xml: + * libabi/.cvsignore: + * libabi/Makefile.am: + * libabi/opimport.cpp: + * utils/.cvsignore: + * utils/Makefile.am: + * utils/opcontrol: + * utils/ophelp.c: rename op_import->opimport, + op_help->ophelp. Allow normal user to use + opcontrol --list-events + +2005-03-31 John Levon + + * doc/internals.xml: more internals docs + +2005-03-29 John Levon + + * libpp/callgraph_container.h: + * libpp/callgraph_container.cpp: + * libpp/format_output.h: + * libpp/format_output.cpp: + * libpp/profile_container.h: + * libpp/symbol.h: + * libpp/symbol_sort.h: + * libpp/symbol_sort.cpp: + * libpp/symbol_container.h: + * libpp/symbol_container.cpp: + * pp/opreport_options.h: header file cleanup + +2005-03-26 John Levon + + * Makefile.am: + * doc/oprofile.xml: + * m4/configmodule.m4: + * module/x86/Makefile.in: + * module/x86/hammer_entry.S: + * module/x86/hammer_ia32entry.S: + * module/x86/hammer_op_syscalls.c: + * module/x86/hammer_oprofile_nmi.S: + * module/x86/op_apic.h: + * module/x86/op_arch.h: + * module/x86/op_nmi.c: remove x86-64 support for 2.4 + kernels, as it's non-functional + +2005-03-26 John Levon + + * daemon/oprofiled.c: honour oprofiled -v first, complain + if --events option is missing instead of core dumping + + * doc/oprofiled.xml: explain opreport -d behaviour for + no-symbol binaries + +2005-03-14 Maynard Johnson + + * utils/op_help.c: + * doc/oprofile.xml: + Update PPC64-related documentation to include URL links to + IBM publications. + +2005-03-22 John Levon + + * configure.in: bump to 0.9cvs + +2005-03-19 Philippe Elie + + * configure.in: bump to 0.8.2 + +2005-03-18 Philippe Elie + + * events/i386/p4/events: + * events/i386/p4/unit_masks: + * events/i386/p4-ht/events: + * events/i386/p4-ht/unit_masks: remove FRONT_END_EVENT, EXECUTION_EVENT + and REPLAY_EVENT. + + * libop/tests/alloc_counter_tests.c: update test according events + removal + +2005-03-18 Philippe Elie + + * utils/opcontrol: revert last patch, bash can't do integer + arithmetic on hexadecimal. + +2005-02-21 John Levon + + * utils/opcontrol: further validation of the kernel range to + prevent an unrelocated vmlinux being used + +2005-02-07 John Levon + + * events/arm/xscale1/unit_masks: fix 'zero' unit mask + +2005-01-25 Maynard Johnson + + * doc/oprofile.xml: Add PowerPC 64-bit processor support information + +2005-01-24 Philippe Elie + + * libutil++/op_bfd.cpp: always initialize op_bfd_symbol:symb_hidden + and symb_weak, not a bug fix but a cleanup. + +2005-01-04 Andy Fleming + + * events/Makefile.am: + * events/ppc/e500/events: + * events/ppc/e500/unit_masks: + * libop/op_events.c: + * libop/op_cpu_type.h: + * libop/op_cpu_type.c: + * utils/op_help.c: Add PPC e500 support + +2005-01-02 Philippe Elie + + * pp/opannotate.cpp: fix #1093162 by simplifying the code, this was + likely to be a compiler problem but the new code is simpler. + +See ChangeLog-2004 for earlier changelogs. diff --git a/ChangeLog-2001 b/ChangeLog-2001 new file mode 100644 index 0000000..acc5be4 --- /dev/null +++ b/ChangeLog-2001 @@ -0,0 +1,2327 @@ +2001-12-31 Philippe Elie + + * module/op_init.c: + * module/oprofile.c: export cpu type preparing for user space + cpu detection change + * module/oprofile.h: preparatory work to add support for + preempt patch + + * pp/oprofpp.cpp: cleanup #if 0 ... #else ... #endif + * pp/orofpp_util.cpp: allow to deduce image name from + shared lib samples files name produced with + --separate-samples + + * gui/oprof_start.cpp: minor fix + +2001-12-31 John Levon + + * various files: use op_cpu enum for cpu type + + * all .cvsignore: + * Rules.make.in: + * all Makefile.in: hide .d files in .deps directories + +2001-12-31 John Levon + + * Makefile.in: move config.h.in to maintainerclean - it is included + in a tarball so a distclean shouldn't remove it + +2001-12-31 John Levon + + * TODO: update + + * gui/ui/oprof_start.base.ui: + * doc/oprofile.sgml: + * doc/oprofile.1.in: small updates + + * oprofile.c: more detail on locking requirements for wake_up + +2001-12-31 Michel Dagenais + + * gui/oprof_start.cpp: + * gui/oprof_start.h: show total samples so far + +2001-12-29 Philippe Elie + + * dae/oprofiled.c: + * dae/op_start: --separate-samples is working + + * gui/oprof_start.cpp: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: + * gui/ui/oprof_start.base.ui: handle separating for + shared libs, off by default. + + * doc/oprofile.sgml: + * doc/oprofile.1.in: document --show-shared-libs + + * pp/opf_filter.h: + * pp/opf_container.cpp: new class samples_files_t + to easier access to subset of symbols/samples or + source filename from multiple image + + * pp/Makefile.in: + * pp/op_time.cpp: + * pp/opf_filter.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: implement --show-shared-libs except + for opf_filter + + * util/file_manip.h: + * util/file_manip.cpp: new function to manipulate sample + file name and list of sample file name. + +2001-12-27 Philippe Elie + + * dae/op_stop: always do an op_dump before stopping + * gui/oprof_start.cpp: op_dump before op_stop + no longer required + +2001-12-26 Philippe Elie + + * pp/opf_filter.cpp: + * pp/opf_filter.h: + * pp/oprofpp.h: + * pp/opf_filter.cpp: + * pp/oprofpp_util.cpp: + * pp/oprofpp.cpp: + * pp/op_time.c: remove some use of global var + samplefile and imagefile + + * pp/oprofpp.cpp: do_dump_gprof() free memory + too soon. (was bugged from 2001-12-05) + + * doc/oprofile.sgml: remove mention about oprof-thread + +2001-12-23 Philippe Elie + + * util/string_manip.h: + * util/string_manip.cpp: separate_token() new function + + * pp/opf_filter.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: + * doc/oprofil.1.in: + * doc/oprofile.sgml: add support for --exclude-symbol + + * TODO: update + +2001-12-22 Philippe Elie + + * dae/op_start: add --separate-samples + * dae/oprofiled.c: ditto + * dae/opd_proc.c: + * dae/opd_util.h: + * dae/opd_util.c: + * dae/oprofiled.h: implementation of above + * pp/op_time.cpp: + * doc/oprofile.1.in: + * doc/oprfile.sgml: handle and document above + * pp/oprofpp_util.cpp: minor change related + + * dae/oprofiled.c: bug fix while blocking signal + + * doc/Makefile.in: avoid unecessary build of html doc + +2001-12-22 Dave Jones + + * config.h.in: Readd to CVS. + +2001-12-18 Dave Jones + + * Makefile.in: Make documentation build again. + +2001-12-14 Philippe Elie + + * dae/opd_proc.c: memory leak fix in opd_init_images() + +2001-12-12 Philippe Elie + + * module/oprofile.h: change slightly op_hash() + + * util/file_manip.h: + * util/file_manip.cpp: + * util/string_manip.h: + * util/string_manip.cpp: + * util/child_reader.h: + * util/child_reader.cpp: cleanup John's FIXME + + * dae/opd_util.h: + * dae/opd_util.c: move libiberty things to ... + * util/misc.h: + * util/misc.c: here + * util/Makefile.in: update + * dae/Makefile.in: + * pp/Makefile.in: + + * doc/Makefile.in: install the html doc + +2001-12-10 John Levon + + * dae/oprofiled.c: fix sigprocmask() blooper + +2001-12-09 John Levon + + * TODO: update again + + * util/child_reader.h: + * util/child_reader.cpp: + * util/file_manip.cpp: + * util/string_manip.cpp: pedantic cleanup + FIXMEs + +2001-12-09 John Levon + + * configure.in: add FIXME comment + + * util/file_manip.h: add FIXME comment, + avoid warning with // + +2001-12-09 John Levon + + * TODO: update + +2001-12-09 Philippe Elie + + * dae/opd_proc.c: verbprintf() what cause the + deletion of a sample file + minor cleanup + * doc/oprofile.sgml: document samples files backup + +2001-12-07 Philippe Elie + + * dae/oprofiled.h: + * dae/opd_proc.c: handle an accessed field of + deleted of deleted procs to defer deleting + the procs. This greatly reduce the Nr of lost + samples due to no proc information. + +2001-12-06 Philippe Elie + + * dae/oprofiled.h: + * dae/opd_proc.c: separate stats for kernel + and modules address space and minor cleanup + +2001-12-05 Philippe Elie + + * Rules.make.in: + * dae/Makefile.in: + * events/Makefile.in: + * pp/Makefile.in: + * util/Makefile.in: tidy + * module/Makefile.in: + * gui/Makefile.in: use auto-deps + + * util/child_reader.h: allow to compile with -ansi + * util/child_reader.cpp: fix memory leak fix + * pp/oprofpp.cpp: fix memory leak + + * TODO: update + +2001-12-05 Philippe Elie + + * autogen.sh: use autoheader to create config.h + * configure.in: handle missing libiberty.h and + missing xcalloc in libiberty.a + * dae/opd_util.cpp: + * dae/opd_proc.c: + * dae/opd_util.h: + * dae/oprofiled.c: + * evets/Makefile.in + * pp/oprof_convert.c: + * pp/oprofpp.cpp: + * pp/oprofpp_util.cpp: replace opd_malloc() and related + by xmalloc. + * util/op_popt.c: add call to xmalloc_set_program_name() + * ./cvsignore: add config.h, config.h.in + +2001-12-04 Dave Jones + + * events/op_events_desc.c: + Add recognition for alternative PIII string. + Reported by Lev Iserovich + +2001-12-04 Philippe Elie + + * dae/opd_util.c: + * dae/opd_util.c: move common fuctionnality to ... + * util/file_manip.h + * util/file_manip.c: here + * pp/oprof_convert.c: reflect above change + * pp/oprof_convert.c: + * pp/opf_filter.cpp: ditto + minor cleanup + * gui/Makefile.in: + * pp/Makefile.in: reflect above change + +2001-12-02 Philippe Elie + + * pp/oprofpp.h: + * pp/oprofpp.cpp: + * pp/oprofpp_util.cpp: + * pp/opf_filter.cpp: small tidies + +2001-12-01 Philippe Elie + + * Makefile.in: build util sub-dir first + + * dae/opd_util.h: + * dae/opd_util.c: move opd_GetContext() ... + * util/opd_popt.h: + * util/opd_popt.c: in these new files + + * pp/oprofpp.cpp: + * pp/opf_filter.cpp: + * pp/op_time.cpp: + * dae/oprofiled.c: free the poptContext + cleanup popt + + * events/op_help.c: + * events/Makefile.in: use the popt library + + * pp/oprofpp.cpp: allow to use --output-linenr-info with + --list-symbols. + * doc/oprofile.1.in: + * doc/oprofile.sgml: reflect it + +2001-12-01 Philippe Elie + + * dae/opd_proc.c: + * dae/opd_util.c: + * dae/opd_util.h: + * dae/oprofiled.c: backup if needed old samples files + in a separate directory + + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: cleanup + minor buglet fix + + * util/file_manip.h: + * util/file_manip.cpp: create_file_list() new to create + a list of all the file in a directory + + * pp/op_time.cpp: new utility + * pp/Makefile.in: handle op_time + + * doc/oprofile.sgml: + * doc/oprofile.1.in: Document op_time + +2001-11-30 Philippe Elie + + * configure.in: cvs add Rules.make.in. + +2001-11-30 Dave Jones + + * configure.in: suppress reference to an inexistant + Rules.make.in + +2001-11-29 Philippe Elie + + * pp/oprofpp_util.cpp: do not remove leading underscore to + avoid C++ demangling failure + +2001-11-27 Philippe Elie + + * configure.in: + * pp/Makefile.in: work-around for gcc 3.0 and bfd pre-1998 + + * doc/oprofile.sgml: typo + +2001-11-26 Philippe Elie + + * Rules.make.in: new to add autodeps and share commons + definitions + * all Makefile.in except module, gui: use autodeps + + * doc/oprofile.1.in: typo + + * util/filemanip.h: missing std:: + +2001-11-25 Philippe Elie + + * oprofile-tests/understanding/persistent.cpp: new + * util/persistent.h: new. An attempt to provide a better + configuration saving/restoring library. Not yet linked to + oprof_start. + +2001-11-22 Philippe Elie + + * pp/oprofpp_util.cpp: take care than get_linenr() get + line nr and filename info from bfd for the right symbol + and not for the nearest symbol with debug info (#484660) + +2001-11-15 Philippe Elie + + * module/oprofile.h: work around against a gcc + 2.91.66 code generation bug in oprof_exit() + +2001-11-14 Philippe Elie + + * dae/op_start: do not pass bufsize, note_bufsize and + kernel_only as option to the daemon but ... + * dae/oprofiled.c: read them from sysctl + + * dae/opd_proc.c: in opd_handle_old_sample_file() do not + delete sample file if mtime differ but backup it. + + * doc/oprofile.sgml: + * pp/oprof_convert.c: + * pp/oprofpp_util.cpp: replace session number by + backup number + + * util/string_manip.cpp: fix stupid bug in rtrim() + +2001-11-13 Philippe Elie + + * gui/oprof_start.h: + * gui/oprof_start.cpp: + * dae/opd_util.h: + * dae/opd_util.cpp: small cleanup + + * module/oprofile.c: simplify a little what the + nmi handler + + * doc/oprofile.sgml: clarify op_to_source options + + * pp/child_reader.cpp: + * pp/child_reader.h: move these ... + * util/child_reader.cpp: + * util/child_reader.h: here + * util/file_manip.h: + * util/file_manip.cpp: new + * gui/Makefile.in: + * gui/oprof_start_util.h: + * gui/oprof_start_util.cpp: + * pp/Makefile.in: + * pp/opf_filter.cpp: use child_reader and file_manip + + * pp/oprofpp_util.cpp: change ordering of opening in + opp_bfd ctr to avoid cryptic error message + + * TODO: update + +2001-11-12 Philippe Elie + + * events: new directory + + * events/Makefile.in: + * events/op_events.c: + * events/op_events_desc.c: + * events/op_help.c: new, splitted from op_events.c + + * pp/oprofpp_util.cpp: new, splitted from oprofpp.cpp + + * pp/oprofpp.h: + * pp/oprofpp.c: + * op_user.h: + * all Makefile.in: update + * op_events.c: remove + +2001-11-12 Philippe Elie + + * op_events.c: last commit was bad + + * pp/oprofpp.c: use sstream + +2001-11-12 Philippe Elie + + * util: new directory + * util/string_manip.cpp: + * util/string_manip.h: new + * Makefile.in: handle util directory + * pp/Makefile.in: + * pp/opf_filter.h: + * pp/opf_filter.cpp: + * gui/Makefile.in: + * gui/oprof_start_util.cpp: + * gui/oprof_start_util.h: update to use string_manip.cpp + + * op_events.c: + * op_user.h: + * pp/opf_filter.h: + * pp/opf_filter.cpp: + * pp/opf_container.cpp: remove dead code + +2001-11-11 Dave Jones + + * module/oprofile.[c|h]: Change MSR defines from + MSR_IA32_xxx from MSR_P6_xxx, based on info on + Linux kernel from Mikael Pettersson that these MSRs + don't exist on Pentium 4. + +2001-11-11 Philippe Elie + + * gui/oprof_start.cpp: fix record_config() + + * op_user.h: fix one comment + +2001-11-10 Bob Montgomery + + * module/oprofile.c: fix pid/pgrp filter to reset counter + +2001-11-08 John Levon + + * TODO: update + + * configure.in: bump to 0.0.8cvs + +2001-11-07 John Levon + + * acinclude.m4: + * configure.in: fixes for configuration when Qt2 not found + + * child_reader.h: + * child_reader.cpp: compile with gcc 3.0 + +2001-11-07 John Levon + + * configure.in: bump to 0.0.7 + +2001-11-07 John Levon + + * configure.in: + * module/oprofile.h: + * module/oprofile.c: fail if hard_get_current() exists + - this won't work + +2001-11-06 Philippe Elie + + * doc/oprofile.1.in: reformat options + * doc/oprofile.sgml: clarify options that require argument. + Document short option + + * gui/oprof_start_util.cpp: fix basename() + + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/opf_filter.cpp: better options handling + + * module/oprofile.c: update one comment + + * TODO: update + +2001-11-06 John Levon + + * configure.in: + * module/oprofile.h: + * module/oprofile.c: support for hard_get_current() + +2001-11-06 John Levon + + * module/oprofile.h: + * module/oprofile.c: make allow_unload exist for UP + too (default to 1) + +2001-11-05 John Levon + + * TODO: update + + * module/oprofile.c: fix nr_interrupts sysctl + +2001-11-04 Philippe Elie + + * dae/op_start: + * gui/oprof_start.cpp: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: + * gui/ui/oprof_start.base.ui: handle note table size sysctl + + * module/op_syscalls.c: handle dname hash coding collision with + a linear search. + + * module/oprofile.c: + * module/oprofile.h: + * module/op_syscalls.c: Use a struct to hold the whole + sysctl settable things rather global var. + +2001-11-03 Philippe Elie + + * modules/oprofile.h: add a sysctl struct to hold + all sysctl set-able variable + + * modules/oprofile.c: two bugs fixes. + +2001-11-02 Philippe Elie + + * modules/oprofile.h: minor cleanup + * modules/oprofile.c: better handling of irq statistics + +2001-10-31 John Levon + + * module/oprofile.c: add comment about unfixable + races. + +2001-10-30 John Levon + + * Move module code into module/ subdir. Bye + bye CVS history :/ + +2001-10-30 John Levon + + * op_x86.c: complain properly about lAPIC-less + machines + +2001-10-26 John Levon + + * TODO: update + +2001-10-26 H. J. Lu + + * Makefile.in: use $(LD) not ld + +2001-10-25 Philippe Elie + + * configure.in: fix version.h checking for gcc 2.91.66 + +2001-10-25 John Levon + + * Makefile.in: + * doc/Makefile.in: + * dae/Makefile.in: + * pp/Makefile.in: + * gui/Makefile.in: add $DESTDIR to prefix (part from + H.J. Lu) + +2001-10-25 H. J. Lu + + * configure.in: better version.h workaround + + * doc/*.1: + * doc/Makefile.in: better .so manpage install + +2001-10-25 Philippe Elie + + * doc/oprofile.sgml: minor change. + * pp/opf_filter.cpp: repair short option -a and -s + +2001-10-24 Philippe Elie + + * pp/op_to_source: remove from cvs + * pp/Makefile.in: opf_filter application renamed to op_to_source + * pp/child_reader.h: new + * pp/child_reader.cpp: new, allow to fork a child and read + its stdout/stderr + * pp/opf_filter.h: + * pp/opf_filter.cpp: use child_reader to launch objdump. + op_to_source -a and -s must be specified with long + form --assembly and --source-with-assembly. This also + speed-up assembly output. Doc not updated. + +2001-10-18 John Levon + + * configure.in: workaround #2, hopefully fixing + Mandrake (bug #471448) + +2001-10-17 John Levon + + * oprofile.c: don't mask when restoring MSR values + + * doc/Makefile.in: don't use man symlinks + +2001-10-17 John Levon + + * oprofile.c: save original counter setup + and restore on unload (bug #464094) + +2001-10-16 John Levon + + * configure.in: + * oprofile.h: workaround for Mandrake randomly + back-porting things. + +2001-10-16 John Levon + + * dae/opd_proc.c: + * gui/oprof_start.cpp: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: + * gui/oprof_start_util.cpp: + * pp/opf_container.cpp: + * pp/opf_filter.h: + * pp/opf_filter.cpp: + * pp/oprof_convert.cpp: add note device to gui, + general cleanup + +2001-10-16 John Levon + + * oprofile.h: fix likely() macro + +2001-10-14 John Levon + + * TODO: update + + * op_syscalls.c: + * op_user.h: + * oprofile.h: + * oprofile.c: + * dae/op_start: + * dae/opd_proc.c: + * dae/oprofiled.h: + * dae/oprofiled.c: use a separate map buffer. + +2001-10-14 John Levon + + * acinclude.m4: don't give up if we can't find moc + +2001-10-14 John Levon + + * oprofile.c: merge no-thread code + +2001-10-14 John Levon + + * dae/opd_proc.c: + * dae/oprofiled.c: + * op_user.h: + * oprofile.h: + * op_syscalls.c: use string pool. Prime hash table + with common entries. Consider parent in name_hash. + +2001-10-13 Philippe Elie + + * doc/oprofile.sgml: minor change + * pp/opf_filter.cpp: better warning + +2001-10-13 John Levon + + * configure.in: 0.0.6 has been released -> 0.0.7cvs + +2001-10-12 John Levon + + * TODO: update + + * doc/oprofile.sgml: new docs for annotation filter + +2001-10-12 John Levon + + * pp/opf_filter.cpp: make output filters more like diff (needs doc), + briefer info message + +2001-10-12 John Levon + + * doc/Makefile.in: add FIXME + + * gui/oprof_start.cpp: fix std:: + + * acinclude.m4: more fixes + +2001-10-12 Philippe Elie + + * gui/oprof_start_util.cpp: use select() rather non-blocking + mode to read output from the child process + +2001-10-11 Philippe Elie + + * doc/oprofile.sgml: + * doc/oprofile.1.in: + * pp/opf_filter: make --output and --no-output more intuitive + +2001-10-09 Philippe Elie + + * doc/oprofile.sgml: + * doc/oprofile.1.in: clarify doc + * pp/opf_filter.cpp: corner case fix in --output-dir and + --source-dir handling. + +2001-10-08 John Levon + + * acinclude.m4: + * configure.in: + * gui/Makefile.in: fix idiot config bug of mine + +2001-10-06 Philippe Elie + + * pp/opf_filter.cpp: + * pp/op_to_source: small cleanup + +2001-10-05 Philippe Elie + + * doc/oprofile.1.in: + * doc/oprofile.sgml: + * pp/op_to_source: + * pp/opf_filter.cpp: implement --output and --no-output to + allow output file generation filtering + +2001-10-04 John Levon + + * TODO: update + +2001-10-03 Philippe Elie + + * doc/oprofile.1.in: + * doc/oprofile.sgml: + * pp/op_to_source: + * pp/opf_filter.cpp: implement --source-dir and --output-dir + to generated separated annoted source file. + +2001-10-03 Philippe Elie + + * pp/oprofpp.cpp + * pp/oprofpp.h + * pp/opf_filter.cpp: minor cleanup + +2001-10-03 John Levon + + * TODO: update + + * Makefile.in: remove generated files on make distclean + + * acinclude.m4: update from source + +2001-10-02 Philippe Elie + + * pp/oprofpp.cpp: fix a silly bug in do_list_symbols (oprofpp -l) + +2001-10-02 John Levon + + * doc/oprofile.sgml: fix + + * Makefile.in: dist fix + +2001-10-02 John Levon + + * TODO: update + + * configure.in: -> 0.0.5 for release + +2001-10-01 Philippe Elie + + * pp/opf_container.cpp: + * pp/opf_filter.h: comment + * pp/opf_filter.cpp: speed-up + +2001-09-30 Philippe Elie + + * pp/opf_container.cpp: + * pp/opf_filter.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp.h: cleanup + +2001-09-30 Philippe Elie + + * gui/oprof_start.cpp: + * gui/oprof_start.h: + * gui/ui/oprof_start.base.ui: cleanup + +2001-09-29 Philippe Elie + + * pp/opf_filter.cpp: check if we need debug info to work. + + * gui/oprof_start.cpp: use one config file by counter. Store + selected counter in oprof_start_config + + * gui/oprof_start.cpp: + * gui/persistent_config.h: remove dirty flag in + persistent_config_t template class + +2001-09-29 John Levon + + * TODO: update + + * gui/oprof_start.cpp: + * gui/ui/oprof_start_base.ui: + * gui/oprof_start_config.h: + * gui/oprof_start_config.cpp: add verbose option + + * pp/opf_container.cpp: + * pp/opf_filter.cpp: some FIXMEs and little cleanups + +2001-09-29 Philippe Elie + + * pp/oprofpp.cpp: bug fix when calling the bfd lib. + +2001-09-29 Philippe Elie + + * gui/oprof_start.cpp: two minor fixes. + +2001-09-28 John Levon + + * various files: the footer is now a header ! + + * dae/opd_start.c: fix msync !! + + * gui/oprof_start.cpp: + * gui/oprof_start_util.h: + * gui/oprof_start_util.cpp: better default event count + value. Save CPU type to oprofile file. + +2001-09-28 Philippe Elie + + * pp/opf_filter.c: fix op_to_source [-a] [-s] + +2001-09-28 Philippe Elie + + * doc/oprofile.sgml: oops, correct bad merging with + John's last update. + +2001-09-27 Philippe Elie + + * doc/oprofile.1.in: minor change + * op_events.c: remove --gui-description stuff + * pp/opf_filter.cpp: remove use of temporary array to + pass argument to the popt library + +2001-09-27 John Levon + + * doc/oprofile.sgml: updates + + * gui/oprof_start_util.cpp: fix compile, revert + g++ extension (different on g++ 3.0) + +2001-09-27 John Levon + + * gui/oprof_start_util.cpp: use g++ extension to + avoid using temporary files + +2001-09-27 John Levon + + * gui/oprof_start_util.cpp: fix crasher bug + +2001-09-27 John Levon + + * gui/oprof_start.h: + * gui/oprof_start.cpp: get per-counter config working + +2001-09-27 John Levon + + * pp/Makefile.in: + * pp/oprofpp.c: + * pp/oprofpp.cpp: rename file + +2001-09-27 John Levon + + * pp/opf_container.cpp: + * pp/oprofpp.h: + * pp/oprofpp.c: speed improvements + +2001-09-26 Philippe Elie + + * configure.in: typo + + * pp/oprofpp.c: fix oprofpp -s. + Use std::string (work not yet finish) + * pp/oprofpp.h: ditto + * pp/opf_filter.cpp: ditto + +2001-09-26 John Levon + + * oprofile.c: add nr_interrupts + + * gui/oprof_start.h: + * gui/oprof_start.cpp: + * gui/oprof_start_util.h: + * gui/oprof_start_util.cpp: + * gui/oprof_start_config.h: + * gui/oprof_start_config.cpp: + * gui/ui/oprof_start_base.ui: add daemon status + display, fix basename() + +2001-09-26 John Levon + + * configure.in: remove broken bit + + * pp/Makefile.in: fix options + + * doc/oprofile.sgml: minor changes + +2001-09-26 Philippe Elie + + * pp/Makefile.in: increase level of warning + * pp/oprof_convert.c: minor fix to avoid warning + * dae/opd_util.c: ditto + * pp/oprofpp.c: get_linenr() never return null in + filename (fix bug #464482). symcomp() ensure + correct vma comparison (fix #464093) + * dae/opd_util.c: minor fixe in op_poptGetContext() + * gui/oprof_start.cpp: minor cleanup + +2001-09-25 John Levon + + * dae/op_stop: + * gui/oprof_start_config.cpp: use pidof instead + +2001-09-25 John Levon + + * gui/oprof_start_config.cpp: fix is_profiler_started() too + +2001-09-25 John Levon + + * dae/op_stop: fix terribly stupid error + +2001-09-25 John Levon + + * op_event.c: whooops + +2001-09-25 John Levon + + * gui/oprof_start.cpp: std:: fix + + * dae/op_start: + * op_events.c: robustness fix + +2001-09-25 John Levon + + * gui/oprof_start.cpp: fix silly bug + +2001-09-24 John Levon + + * pp/opf_filter.cpp: "fix" compile error + +2001-09-24 John Levon + + * gui/oprofile: + * gui/Makefile.in: remove old gui + +2001-09-24 John Levon + + * dae/op_start: make a little more robust + +2001-09-24 John Levon + + * include/sstream: + * Makefile.in: + * configure.in: + * pp/Makefile.in: + * gui/Makefile.in: configure/make fixes + + * op_events.c: re-order for Athlon + +2001-09-23 John Levon + + * pp/oprofpp.c: small cleanup + +2001-09-23 John Levon + + * oprofile.h: + * op_x86.c: support for 2.4.10 + +2001-09-23 John Levon + + * gui/oprof_start.h: + * gui/oprof_start.cpp: rework validator stuff a bit + +2001-09-23 John Levon + + * gui/oprof_start.cpp: use std::find_if + + * gui/oprof_start_config.cpp: + * gui/oprof_start_util.cpp: minor tidies + +2001-09-23 John Levon + + * dae/op_dump: + * dae/op_start: echo errors to stderr + + * gui/oprof_start_util.h: + * gui/oprof_start_util.cpp: + * gui/oprof_start.cpp: use fork/exec to spawn children + +2001-09-23 John Levon + + * TODO: update + + * gui/Makefile.in: + * gui/oprof_start_config.h: + * gui/oprof_start_config.cpp: + * gui/oprof_start_util.h: + * gui/oprof_start_util.cpp: + * gui/oprof_start.h: + * gui/oprof_start.cpp: new file for util functions + +2001-09-23 John Levon + + * dae/opd_util.c: + * dae/opd_util.h: + * dae/oprofiled.c: + * pp/oprofpp.c: + * pp/opf_filter.cpp: + * configure.in: enable __builtin_expect, fix popt problem + + * pp/oprof_convert.c: small fixes + + * op_events.c: shorten event descriptions for GUI + + * gui/*: many more updates + + * pp/Makefile.in: fix + +2001-09-21 John Levon + + * dae/opd_proc.c: removed over-verbose line + + * configure.in: + * oprofile.h: + * oprofile.c: add likely/unlikely, take note lock on dump + +2001-09-21 Philippe Elie + + * pp/opf_filter.h: move declaration of counter_array_t to + * pp/oprofpp.h: here + * pp/oprofpp.c: define and use counter_array_t + minor cleanup + * pp/opf_filter.cpp: remove definition of counter_array_t + +2001-09-21 Philippe Elie + + * Makefile.in: remove aclocal.m4 in distclean + * pp/Makefile.in: use $(CXX) and $(CXXFLAGS) + + * pp/opf_container.cpp: + * pp/opf_filter.cpp: + * pp/opf_filter.h: + * pp/oprofpp.c: + * pp/oprofpp.h: cleanup + +2001-09-20 Philippe Elie + + * Makefile.in: minor change in module building + * pp/Makefile.in: link oprofpp with opf_filter + * pp/op_to_source: avoid pipe from oprofpp to opf_filter + * pp/opf_filter.h: remove a few member function + * pp/opf_container.cpp: ditto + minor cleanup + * pp/opf_filter.cpp: oprofpp is no longer piped to opf_filter + but linked with it. Many change, needs additional cleanup + * pp/oprofpp.c: group all stuff in two class. Rather a + a C with class than a full C++ file for now. Fix a bug + in filename handling. + * pp/oprofpp.h: add opp_bfd and opp_samples_files class. + + * dae/opd_util.c: add a few explicit cast for C++ compile + * dae/opd_util.h: wrap function declaratio with extern "C" + +2001-09-19 John Levon + + * oprofile.c: fix silly read valid bug + +2001-09-19 John Levon + + * Makefile.in: whoops, missed op_util.o from build + +2001-09-19 John Levon + + * dae/oprofiled.c: fix little bug, tidy a bit + + * TODO: update + +2001-09-18 John Levon + + * Makefile.in: + * op_syscalls.c: + * op_util.c: + * oprofile.h: move some code around + + * oprofile.c: fix a tiny bug + +2001-09-18 John Levon + + * dae/opd_proc.c: + * dae/oprofiled.h: implement hashing of images + + * doc/oprofile.sgml: fix -- issue and use + +2001-09-18 John Levon + + * .cvsignore: + * README: update + + * configure.in: small cleanup + + * op_init.c: add comment + + * oprofile.h: + * op_syscalls.c: + * op_x86.c: move fixmap stuff, remove disable APIC + + * oprofile.c: init failure fix + + * doc/oprofile.sgml: + * dae/opd_proc.c: fix handle_old_sample_files() bug, + check mtime hasn't changed on a new map + +2001-09-16 John Levon + + * acinclude.m4: + * autogen.sh: + * configure.in: + * gui/Makefile.in: + * gui/ui/Makefile.in: + * gui/ui/oprof_start.base.ui: + * gui/oprof_start.h: autoconfiscation for Qt2 + + * gui/oprof_start_config.cpp: add comments + +2001-09-16 Philippe Elie + + * pp/opf_filter.cpp: fix unrecognized input + * pp/opf_container.cpp: better error messages. put + op_nr_counters in the global namespace (gcc 2.91 + work around) + +2001-09-16 John Levon + + * pp/oprofpp.cpp: small tidy + +2001-09-16 Philippe Elie + + * pp/opf_filter.cpp: minor tidy + + * gui/oprof_start.base.ui: new oprof_start gui + * gui/oprof_start.cpp: new, derived class of oprof_start_base + * gui/oprof_start.h: ditto + * gui/oprof_start_impl.cpp: implementation of oprof_start class + * gui/oprof_start_config.cpp: utilities function for oprof_start + * gui/oprof_start_config.h: ditto + * gui/persistent_config.h: utility template + * gui/oprof_start_main.cpp: main() for oprof_start + * gui/Makefile.in: handle this stuff + +2001-09-15 John Levon + + * pp/oprofpp.c: some cleanup + +2001-09-15 John Levon + + * pp/oprofpp.c: allow non-matching mtimes in order + to allow pp on different machines. Make conflicting + counter specifications a fatal error + +2001-09-15 John Levon + + * all Makefile.in: install should depend on all + + * pp/oprofpp.c: fixes for Athlon 4 counters. Enable debug info + for list-symbol. Some stricter checking + +2001-09-15 Philippe Elie + + * op_events.c: some static variable to global + * op_user.h: export these + + * oprofile.c: typo in comment + + * dae/opd_proc.c: fix size of samples files + +2001-09-13 Dave Jones + + * doc/oprofile.1.in: + Update so it doesn't say 'Intel only' + * dae/op_start: + Fix output so that it prints [0-3] instead of [0-4[ + +2001-09-12 Philippe Elie + + * pp/oprofpp.c: fix cpu type output for opf_filter + + * dae/op_stop: return error code properly + +2001-09-12 John Levon + + * pp/oprofpp.c: print name of cpu type + + * dae/op_stop: + * dae/op_start: re-organise, tidy + +2001-09-12 John Levon + + * oprofile.c: fix small but triggerable + SMP dump race + +2001-09-12 John Levon + + * oprofile.h: + * oprofile.c: + * op_x86.c: move some code about + + * op_syscalls.c: add comment + +2001-09-12 John Levon + + * configure.in: remove warning + + * op_user.h: + * op_events.c: fix and clean up cpu type detection + + * op_init.c: fix email + + * oprofile.c: add IRQ stats. Not sure whether to keep... + +2001-09-12 John Levon + + * oprofile.h: + * oprofile.c: use cpu_number_map (pedantry thing) + +2001-09-07 Philippe Elie + + * oprofile.c: remove /proc/.../cpu_type. Check if user + mode cpu type detection is identical to module cpu type + * op_events.h: + * op_events.c: add op_get_cpu_type(). script can get cpu_type + by op_help --get-cpu-type + * gui/oprofile: use it + * dae/oprofiled.c: ditto + * dae/op_start: ditto, pass expected_cpu_type to module + * doc/oprofile.sgml: update + * doc/oprofile.1.in: update + * pp/oprofpp.c: get cpu_type from samples file + * pp/opf_filter.cpp: get cpu type from stdin + +2001-09-06 John Levon + + * dae/opd_proc.c: use j not i in msync ! + +2001-09-06 John Levon + + * dae/op_start: more sanity checking of options + +2001-09-06 John Levon + + * doc/oprofile.sgml: update a bit + +2001-09-06 John Levon + + * : make op_nr_counters a var (no pp support for > 2 yet) + + * dae/oprofiled.c: don't print help when counter event etc. are wrong + +2001-09-06 John Levon + + * oprofile.h: + * oprofile.c: use MODULE_LICENSE + +2001-09-06 John Levon + + * op_user.h: add missing prototype + + * dae/op_start: fix counter extraction + +2001-09-05 Philippe Elie + + * pp/oprofpp.c: fix a few corner case, cleanup. + * dae/opd_proc: ditto. + + * dae/op_start: better handling of counter number + + * dae/opd_proc: minor change. + + * op_user.h: enable support for four counters + * oprofile.c: ditto. Split functions + + * op_events.c: expose op_get_cpu_type_str(int) to world. + +2001-09-04 John Levon + + * oprofile.h: + * oprofile.c: don't restore delivery mode to LVTPC (causes + APIC error on SMP). Fix for silly sem hang with do_dump + +2001-09-04 John Levon + + * dae/op_start: fix typo bug + +2001-09-04 John Levon + + * doc/oprofile.sgml: some small tidies + +2001-09-04 John Levon + + * oprofile.c: change lvtpc_apic_restore to be more careful ! + +2001-09-02 John Levon + + * oprofile.c: don't allow unload on SMP unless allow_unload + is set. Still needs docs (no point till SMP works). + +2001-09-02 John Levon + + * dae/op_dump: complain if not root more clearly. + +2001-09-02 John Levon + + * oprofile.c: remove bogus setting for NMI oopser. + smp_apic_restore() -> lvtpc_apic_restore() + +2001-09-01 Philippe Elie + + * oprofile.c: fix pmc_setup() + + * pp/Makefile.in: + * dae/Makefile.in: fix uninstall problem + +2001-08-31 Philippe Elie + + * oprofile.h: + * dae/oprofiled.h: + * op_user.h: + * oprofpp.h: + * dae/opd_util.h: share commmon declarations, put it in + op_user.h, include op_user.h in other .h when necessary. + * op_events.c: + * all Makefile.in: update dependancies. + +2001-08-30 Philippe Elie + + * oprofile.c: use loop instead of fixed counter number + +2001-08-26 Philippe Elie + + * op_events.c: add option to op_help for the gui + * gui/oprofile: use op_help to build description + of events, accept Athlon (only 2 counters) + +2001-08-25 Philippe Elie + + * pp/oprofpp.c: + * dae/op_start: use loop instead of fixed number of counter. + +2001-08-24 Philippe Elie + + * pp/oprof_convert.c: add v4 --> v5 conversion + +2001-08-23 Philippe Elie + + * oprofile.c: correct some comment. + +2001-08-22 Philippe Elie + + * op_user.h: + * dae/opd_proc.c: + * dae/opd_util.c: + * dae/opd_util.h: + * dae/oprofiled.h: + * dae/oprofiled.c: + * dae/oprofiled.c: row to column file format, lot of changes. + +2001-08-21 Philippe Elie + + * op_events.c: Add Athlon string/unit maks description + +2001-08-20 Philippe Elie + + * op_events.c: change in handling of search/check events + * dae/oprofiled.c: + * dae/oprofiled.h: + * oprofile.c: + * oprofile.h: + * pp/oprofpp.c: + * pp/oprofpp.h: reflects caller/prototype, lot of changes. + +2001-08-31 John Levon + + * Makefile.in: + * op_x86.c: + * oprofile.h: + * oprofile.c: a prototype detector for SMP hardware, + some small cleanup + +2001-08-20 Dave Jones + + * doc/oprofile.sgml: + Updated to reflect new Athlon/Duron capabilities. + * pp/oprof_convert.c: + * pp/oprofpp.c: use EXIT_FAILURE | EXIT_SUCCESS + in exit() calls. + * oprofile.c: Make non-exported functions static + and remove duplicate definitions. + +2001-08-19 John Levon + + * dae/op_start: handle celeries in cpu type + +2001-08-19 John Levon + + * op_init.c: + * oprofile.h: + * oprofile.c: small tidies of the Athlon support + +2001-08-19 Dave Jones + + * op_events.c: + * op_init.c: + * oprofile.h: + * oprofile.c: + * dae/op_start: + * dae/oprofiled.h: + * dae/oprofiled.c: initial Athlon support + +2001-08-19 Philippe Elie + + * oprofile.c: use symbolic constant for all apic setup, no generated + code change + +2001-08-18 Philippe Elie + + * Makefile.in: + * dae/Makefile.in: + * pp/Makefile.in: + * doc/Makefile.in: + * gui/Makefile.in: add uninstall target + +2001-08-18 John Levon + + * dae/opd_proc.c: tiny cleanup + +2001-08-17 Philippe Elie + + * dae/opd_proc.c: + * TODO: minor cleanup. + +2001-08-16 Philippe Elie + + * gui/oprofile: + * dae/op_start: + * doc/oprofile.1.in: document and use op_dump + +2001-08-16 John Levon + + * configure.in: bump version to 0.0.5cvs + +2001-08-16 John Levon + + * all Makefile.in: mkdir install files + +2001-08-15 Philippe Elie + + * dae/opd_proc.c: fix a FILE* leak in opd_get_ascii_maps() + +2001-08-14 John Levon + + * op_syscalls.c: don't return negative hashes ! + revert dname len "fix" + use a much better hash function + + * dae/opd_proc.c: protect against negative hashes + +2001-08-14 John Levon + + * op_syscalls.c: some small fixes + + * oprofile.c: add back unmasking code during set_gate, but only + LVTPC + +2001-08-11 John Levon + + * oprofile.h: 2.4.8 doesn't either. *sigh*. looks like we need + some autoconfery :( + +2001-08-11 John Levon + + * oprofile.h: 2.4.7-linus doesn't include the Andrew Morton + complete_and_exit(). Hopefully this will make it into 2.4.8, + I'm banking on this. + +2001-08-11 John Levon + + * dae/op_dump: + * doc/oprofile.sgml: + * dae/Makefile.in: a little utility for dumping + +2001-08-11 Dave Jones + + * oprofile.h: + * oprofile.c: back-compat code and use of new struct completion + for the thread + +2001-08-11 John Levon + + * oprofile.c: corner case where an a miss against a full count, + we were attributing wrong (reported by Bob Montgomery) + +2001-08-11 John Levon + + * oprofile.c: use a simple cli/sti when installing the NMI + handler. It should work and avoids the unmasking problem. + +2001-08-10 John Levon + + * dae/oprofiled.h: fix header include (from Dave Jones) + + * op_syscalls.c: + * oprofile.c: fix undefined symbol (from Dave Jones) + +2001-08-10 John Levon + + * oprofile.c: small tidy in apic setup + +2001-08-02 John Levon + + * oprofile.c: fix mod unload race, small fixes + + * dae/op_start: make sysctl error actually appear + + * doc/oprofile.sgml: document need for modutils 2.4.6 + + * op_syscalls.c: fix stupid mod use count problem + +2001-07-28 John Levon + + * dae/opd_proc.c: d'oh, fat-fingered a slow memleak in the + a-ksymoops modules fix + +2001-07-27 Philippe Elie + + * pp/oprof_convert.c: fix bug when conversion skip more than one + version. + +2001-07-27 John Levon + + * doc/Makefile.in: ln -s -> ln -sf + + * dae/opd_util.c: actually include the right header + + * dae/opd_util.h: compile freestanding from oprofiled.h + +2001-07-26 John Levon + + * oprofile.c: fix comment + + * doc/oprofile.sgml: document symbolless modules not working + + * dae/Makefile.in: + * dae/opd_proc.c: + * dae/oprofiled.h: catch modules with no symbols via query_module() + and ignore samples for them quickly + +2001-07-25 Philippe Elie + + * dae/op_start: beautify the output of op_start --help + * pp/op_to_source: ditto. better argument checking. + + * pp/oprof_convert.c: + * pp/oprofpp.h: + * dae/oprofiled.h: fix problem with opd_footer, don't bump + opd_footer version number ! + +2001-07-25 John Levon + + * pp/Makefile.in: + * pp/oprof_convert.c: convert to v4 + + * pp/oprofpp.c: use opd_strdup + +2001-07-25 John Levon + + * dae/opd_util.c: small tidy + +2001-07-24 Philippe Elie + + * dae/opd_util.c: + * dae/opd_util.h: add relative path name to absolute path name stuff + * pp/oprofpp.c: use it. + * pp/op_to_source: simplify code to reflect above change. + +2001-07-25 John Levon + + * dae/opd_proc.c: fix uninitialised pointer access (reported by + ) that could segfault oprofile in case of + module load/unload activity + + * Makefile.in: + * dae/opd_proc.c: + * dae/opd_util.c: + * dae/opd_util.h: + * dae/oprofiled.c: + * dae/oprofiled.h: + * pp/Makefile.in: + * pp/oprofpp.c: + * pp/oprofpp.h: use mtime() instead of md5sum(). Still doesn't handle + "./a; gcc -o a a.c; ./a" + +2001-07-22 Philippe Elie + + * doc/oprofile.1.in: + * doc/oprofile.sgml: + * pp/opf_filter.h: + * pp/opf_filter.cpp: + * pp/opf_container.cpp: implement and document filtering for assembly + output. + +2001-07-21 Philippe Elie + + * doc/oprofile.sgml: + * gui/oprofile: + * oprofile.c: remove edge_detect support. + + * pp/oprofpp.c: check counter range for each event type. + * oprofile.c: ditto. + * gui/oprofile: ditto and save setup for each event type. + * oprofile.h: op_check_range() : display the allowed range. + +2001-07-18 Philippe Elie + + * dae/op_start: disable all counters before starting the setup. + +2001-07-18 John Levon + + * doc/oprofile.sgml: add in bit I forgot about not profiling ring 0 + +2001-07-18 John Levon + + * doc/oprofile.sgml: added a warning about very low counter values + (from Philippe, modified) + +2001-07-15 John Levon + + * oprofile.c: + * oprofile.h: + * dae/op_start: + * dae/oprofiled.c: + * doc/oprofile.sgml: remove ability to set different values on + different CPUs + +2001-07-15 John Levon + + * TODO: remove done thing + +2001-07-15 John Levon + + * dae/opd_proc.c: backup old sample files if the profiling + details (count, unit mask etc.) disagree. Fixes #435245 + +2001-07-15 Philippe Elie + + * dae/oprofiled.c: fix oprofiled --version to work even if the + profiler is not already started. + + * gui/oprofile: many cleanup. Fix bug track #435248. Make the gui more + independant on the number of counter. + + * pp/op_to_source: fix bug in command line arguments handling. + + * pp/opf_filter.h: + * pp/opf_filter.cpp: + * pp/opf_container.cpp: Apply some cleanup suggested by John, principally + change few inheritance to composition. + + * pp/oprof_convert.c: fix --version. + +2001-07-14 Philippe Elie + + * doc/oprofile.sgml: + * doc/oprofile.1.in: minor doc fix. + +2001-07-14 John Levon + + * doc/oprofile.sgml: small tidies + +2001-07-01 Philippe Elie + + * doc/oprofile.1.in: + * doc/oprofile.sgml: document op_to_source, oprof_convert and the + oprofile gui + + * gui/oprofile: onStartProfiling() check that count is in the allowed + range. onStopProfiling() flush the samples + +2001-07-14 John Levon + + * Makefile.in: dist fix + +2001-07-14 John Levon + + * doc/oprofile.sgml: make it clear we want vmlinux not vmlinuz + + * doc/html/: remove generated files from CVS + + * Makefile.in: changes to create HTML files on dist + +2001-06-30 John Levon + + * pp/Makefile.in: fix the fix + + * pp/opf_filter.h: very minor changes + +2001-06-29 John Levon + + * pp/Makefile.in: fix up for opf_filter + + * configure.in: add AC_PROG_CXX + +2001-06-29 Philippe Elie + + * pp/opf_filter.cpp: + * pp/opf_container.cpp: + * pp/opf_filter.h: + * pp/op_to_source: new file which provide a source annotation utility. + * pp/Makefile.in: build and install opf_filter / op_to_source + +2001-06-29 John Levon + + * configure.in: + * dae/opd_util.h: hide __attribute__((malloc)) warnings + when necessary. Document --with-cc bug. + +2001-06-29 Philippe Elie + + * gui/oprofile: more saving of the user setup. + +2001-06-27 John Levon + + * dae/opd_util.c: document get_line() restriction + +2001-06-27 Philippe Elie + + * dae/oprofiled.c: fix cpu_speed_str/cpu_speed variable setup logic. + + * gui/oprofile: save advanced setup form to persistent storage. + Add many validation. + +2001-06-25 John Levon + + * op_events.c: + * pp/oprof_convert.c: add missing headers, remove CVS blip + + * dae/opd_util.h: specify malloc attribute. gives warnings on + older compilers, who cares. I doubt this will help but it can't + harm + +2001-06-25 John Levon + + * pp/oprof_convert.c: continue if an error with one file occurs + + * dae/op_stop: remove rmmod again - it is user's choice on when/whether + to unload + +2001-06-23 Philippe Elie + + * pp/op_start: add missing support for specifying the log filename. + Get correct cpu speed information for smp as suggested by John. + + * dae/oprofiled.c: Correct a warning with some older version of the + popt library. + * pp/oprofpp: as above. + + * gui/oprofile: advanced setup form added. + + * pp/oprof_convert.c: version and help option support. + +2001-06-23 John Levon + + * pp/.cvsignore: add oprof_convert + +2001-06-23 Philippe Elie + + * pp/oprof_convert.c: new utility to convert samples files when the opd_footer + struct is changed. + * pp/Makefile.in: reflect the above change. Tidy some unnecessary blank. + * Makefile.in: Tidy some unnecessary blank/tabulation. + +2001-06-23 John Levon + + * README: update + +2001-06-22 John Levon + + * oprofile.c: always have smp_apic_restore() + +2001-06-22 John Levon + + * various: made spacing more consistent in C source, + removed unused utility functions. + +2001-06-22 John Levon + + * oprofile.c: actually call smp_apic_restore() on UP + + * dae/op_start: don't remove the module immediately after + inserting it ! + +2001-06-22 Philippe Elie + + * dae/oprofiled.h, pp/oprofpp.h: change the opd_footer struct. + Bump OPD_VERSION to reflect the file format change. + * pp/oprofpp.c: reflect the above change + * dae/oprofiled.c: reflect the above change, many options supressed + because setup is read from the /proc/sys/dev/oprofile files. + * dae/opd_proc: suppress some "extern variable" which no longer exist. + * dae/op_start: reflect the above change + +2001-06-22 Philippe Elie + + * dae/op_start: add --ctr[0|1]-edge-detect + * gui/oprofile: add edge detect stuff + * oprofile.c: add edge-detect stuff, the edge-detect is an + experimental feature which do not work actually (no effect for now). + Because this is experimental no documentation are provided on this + option. + +2001-06-22 John Levon + + * configure.in: + * dae/op_stop: + * doc/oprofile.sgml: + * op_init.c: + * op_syscalls.c: + * oprofile.h: + * oprofile.c: add and document the ability + to make the module unloadable. Not well tested + (but seems to work). + + * doc/oprofile.sgml: document compile-time options + better, thank Philippe + +2001-06-21 John Levon + + * oprofile.c: remove stale comments. fix theoretical + memory leaks when setting up the sysctls fails, small tidy + +2001-06-19 John Levon + + * README: + * doc/oprofile.sgml: + * doc/html/: s/sourceforge/sf/ + +2001-06-16 Philippe Elie + + * op_events.c: op_check_events() fix two bad use of + op_check_unit_mask(). op_get_um_desc() fix a typo. + +2001-06-14 Philippe Elie + + * op_events.c: struct op_unit_mask, struct op_unit_desc allow up to + seven unit masks. Reflect this change in data, op_check_unit_mask() + and callers of op_check_unit_mask(). + +2001-06-12 John Levon + + * results/intro: tidy up + + * results/kernel-compile/time-aves.pl: fix regexps + + * results/latex/: results from the LaTeX runs + +2001-06-09 Philippe Elie + + * dae/op_start: avoid chmod to a non existing directory and setup access + mode from 700 to 755. Replace use of the sysctl utility by a + do_sysctl() function. + + * gui/oprofile: some cleanup and bugfix. + + * pp/oprofpp.c: add new output options --list-all-symbols-details, + --output-linenr-info + + * doc/oprofile.1.in: + * doc/oprofile.sgml: update documentation about the new oprofpp + option + +2001-06-09 John Levon + + * configure.in: fix build with CONFIG_MODVERSIONS + enabled. + +2001-06-04 John Levon + + * dae/oprofiled.c: move logfile message to + before close(1) to not need to use stderr + +2001-06-03 John Levon + + * gui/: new directory + + * Makefile.in: + * configure.in: + * gui/.cvsignore: + * gui/Makefile.in: + * gui/oprofile: Philippe's prototype tcl/tk startup + script. Requires more work. + +2001-06-03 John Levon + + * pp/oprofpp.h: remove libiberty header that was + apparently breaking install on slackware + +2001-06-03 John Levon + + * README: update + +2001-06-03 Philippe Elie + + * op_events.c: allow unit mask option to be bit mask + +2001-06-01 John Levon + + * dae/opd_proc.c: actually use opd_get_count - + fix bug with counter 1 reported results + + * dae/op_start: fix broken shell scripting + + * dae/oprofpp.c: fix list-symbols output + +2001-04-30 John Levon + + * dae/op_start: better error reporting + + * dae/opd_proc.c: fix indentation + +2001-04-08 John Levon + + * configure.in: 0.0.3 has been released. Bump cvs version + to 0.0.4 + +2001-04-05 John Levon + + * dae/opd_proc.c: remove forced dumping. It was + causing overhead spikes + + * doc/html/results.html: + * doc/oprofile.sgml: + * dae/op_start: Hopefully document dump clearly enough + +2001-04-05 John Levon + + * oprofile.h: + * op_syscalls.c: 2.4.3 and above have a rw mmap_sem + +2001-04-05 John Levon + + * doc/html/: added missing files + +2001-04-05 John Levon + + * doc/oprofile.sgml: + * doc/html/resources.html: add URLs + +2001-04-05 John Levon + + * pp/oprofpp.c: fix gprof output bug. It works OK now, + but MULTIPLIER == 1 will break for some reason + +2001-04-05 John Levon + + * doc/oprofile.sgml: + * doc/html/: finish SGML documentation (for now) + +2001-04-04 John Levon + + * doc/Makefile.in: + * doc/oprofile.sgml: + * doc/oprofile: start SGML documentation + +2001-04-04 John Levon + + * configure.in: + * Makefile.in: + * doc/Makefile.in: + * doc/oprofile.1.in: add a manpage + +2001-04-04 John Levon + + * pp/oprofpp.c: get some sort of half-working output + in gprof format. Currently the numbers are screwed up, + need a major trawl through gprof source to see what's + going on. + +2001-04-04 John Levon + + * dae/Makefile.in: + * dae/md5.c: + * dae/md5.h: + * dae/opd_proc.c: + * dae/oprofiled.h: + * pp/Makefile.in: + * pp/oprofpp.c: + * pp/oprofpp.h: use md5sums to verify sample file + integrity. Stored in each sample file footer are + md5sums of the binary. These are checked by the daemon + when re-using an old file, and by the post-processor. + Bump OPD_VERSION to reflect the file format change. + + * dae/oprofiled.c: make start up more friendly + + * dae/op_start: make script more friendly + +2001-03-10 John Levon + + * dae/opd_proc.c: fixed some error messages + + * results/kernel-compile/raw/ccu.gnuplot: add + +2001-02-05 John Levon + + * TODO: update + + * results/intro: update + + * results/kernel-compile/: update, add FIG files + + * results/lmbench: lmbench results + + * results/output/kernel-ac12-output: add readprofile output + +2001-02-04 John Levon + + * TODO: update + + * op_syscalls.c: small re-org, some micro-optimisations + to do_hash() + + * pp/oprofpp.c: clean up --list-symbol output a little + + * results/kernel-compile/overhead: update with results + + * results/kernel-compile/time-aves.pl: add gnuplot output + + * results/kernel-compile/raw/ : raw output files + + * results/output/ : new dir for example output + + * results/output/libc-2.1.92.so: output from libc profile + + * results/output/kernel-ac12-output: output from kernel profile + + * results/output/do_anonymous_page: detailed symbol profile + + * results/output/oprofile.module: output for oprofile module + +2001-02-03 John Levon + + * TODO: update + + * oprofile.h: + * op_syscalls.c: make do_hash() non-recursive + + * oprofile.c: make thread wake up half as often + + * dae/opd_proc.c: quiesce dump sysctl + make resilient against broken sample (don't exceed mmap) + + * pp/oprofpp.c: --gcc-demangle -> --demangle, just too + annoying to live + +2001-02-01 John Levon + + * oprofile.h: add op_save_syscalls() + + * oprofile.c: let interrupt_sleep_on() die + add kernel_only option + sysctl dumps everything it can now + + * op_syscalls.c: add op_save_syscalls() + + * dae/opd_proc.c: + * dae/oprofiled.c: + * dae/op_start: add --kernel-only + + * doc/guide.lyx: mention --kernel-only + + * TODO: update + +2001-02-01 John Levon + + * Makefile.in: split out op_init.c + + * autogen.sh: new file + + * configure.in: fix --with-cc. Split out op_init.c + + * op_init.c: new file, to allow rest -march=i686 + + * oprofile.c: cut out init stuff to op_init.c + + * opd_proc.c: more verbose + + * results/kernel-compile/time-aves.pl: work with other + time format too + +2001-01-25 John Levon + + * configure.in: add --with-cc option + + * pp/oprofpp.c: fix const discard warnings + +2001-01-25 John Levon + + * configure.in: must check for liberty *after* + libdl + +2001-01-24 John Levon + + * oprofile.c: we're not using op_check_ctr() + return value, so don't have one + +2001-01-23 John Levon + + * configure.in: + * op_syscalls.c: + * oprofile.c: + * oprofile.h: stripped the NMI error handling stuff + + * op_events.c: fixed silly bug in the other place too :P + + * dae/oprofiled.c: improved error messages + +2001-01-22 John Levon + + * op_events.c: fix silly bug so you can set both + counters at once + + * oprofile.c: don't disable/enable counters in + the interrupt handler. It's expensive and + doesn't really buy anything. + Fix a silly EBUSY bug when open fails once. + + * dae/op_start: don't remove old sample files + pass correct event to daemon for ctr1 + +2001-01-22 John Levon + + * op_syscalls.c:do_hash(): use strcpy not strncpy. + It's probably faster, and if d_name.len is corrupted + the kernel has bigger things to worry about. + +2001-01-22 John Levon + + * dae/guide.lyx: + * dae/guide.html: update docs a little + +2001-01-22 John Levon + + * dae/op_start: + * op_user.h: bump up hash table size + + * results/kernel-compile/overhead: intro to kernel + compile tests + + * results/kernel-compile/time-aves.pl: script + to generate averages + overheads + + * op_syscalls.c: three fixes to do_hash(). It's + going to be a pain to make iterative :( + +2001-01-21 John Levon + + * results/: Started a collection of results + +2001-01-20 John Levon + + * TODO: update + + * configure.in: add comment + + * Makefile.in: moved oprofile_k.c to op_syscalls.c, op_user.h added + + * op_syscalls.c: rename of oprofile_k.c + map buffer is dead now + use vmalloc() and friends for hash map + Reworking of hash_map stuff into abb's linked + hash map structure + + * op_user.h: new file representing shared structs etc. + between daemon and kernel module + Reworked OP_ flags in count. + Reworked hash map structure + + * oprofile.c: get along with the new UP APIC stuff in 2.4.0ac9 + remove extraneous lock_kernel() + default buffer size added + map buffer died + Use up_and_exit() in kernel thread to fix zombies :P + Set diethreaddie = 0 in start_thread() + oprof_put_mapping() added + we weren't turning OFF kernel/user counting when asked to + + * oprofile.h: move shared stuff to op_user.h + increase the watermark to a much safer 768 + + * dae/Makefile.in: dependencies on op_user.h and version.h + + * dae/op_start: hide confusing output of op_stop + --verbose option + map buffer died + + * dae/opd_proc.c: --verbose option + don't insist on new sample files + Rework mapping code + Be a little more forgiving with unstattable images + + * dae/opd_util.h: + * dae/opd_util.c: add fatal flag to opd_get_fsize(). + + * dae/oprofiled.h: --verbose option + move common code to op_user.h + + * dae/oprofiled.c: add --verbose option (very verbose !) + map buffer died + Add code for unpacking mapping notifications, rework + mapping recognition + + * doc/guide.html: + * doc/guide.lyx: some small updates + + * pp/oprofpp.c: fix segfault on failure to open binary. + add --verbose option + + * pp/oprofpp.h: add --verbose option + +2000-01-12 John Levon + + * oprofile.c: use standard kernel names for MSRs. + Don't re-do fixmap if UP oopser patch is installed. + Allow UP oopser to work if patches enabled, disable + otherwise + + * oprofile.h: use standard kernel names for MSRs. + + * oprofile_k.c: only include fixmap code if necessary + + * configure.in: bump minor version + +2000-12-15 John Levon + + * configure.in: default to /lib/modules/`uname -r`/build + as kernel source directory + + * doc/guide.lyx: + * doc/guide.html: update documentation + +2000-12-13 John Levon + + * configure.in: bump minor version + + * oprofile.c: added KERN_ where needed, + exclude the Pentium IV + + * pp/oprofpp.c: allow "oprofpp -l /bin/mv" and friends, + some minor fixes + +2000-12-12 John Levon + + * Makefile.in: + * configure.in: approximate working modversions + a little more + + * op_events.c: op_help INST_RETIRED will print out + the value now + + * op_ioctl.h: + * oprofile.c: + * oprofile.h: + * oprofile_k.c: + * dae/Makefile.in: + * dae/op_start: + * dae/op_stop: + * dae/opd_proc.c: + * dae/oprofctl.c: + * dae/oprofctl.h: + * dae/oprofiled.h: ioctl() didn't last long. Replaced with + sysctls. This has had a knock-on effect of moving the + start/stop mechanism into the driver open/close routines + + * dae/oprofiled.c: must open devices in "reverse" order now + + * oprofile_k.c: fix X86_FEATURE_PGE testing + + * oprofile.c: use daemonize() + + * pp/oprofpp.c: fix working on constant argv + +2000-11-04 John Levon + + * oprofile.c: what if signal happens later ? + * dae/opd_util.c: clarify opd_read_device() API + +2000-11-04 John Levon + + * ChangeLog: started ChangeLog (cue gc koan) + * op_ioctl.h: added FIXME comment + * oprofile.c: slight cleanup + * oprofile.h: cleanups, use u16 for data->ctrs, + data->next + + * pp/oprofpp.c: added comments + * pp/oprofpp.h: fixed #defines diff --git a/ChangeLog-2002 b/ChangeLog-2002 new file mode 100644 index 0000000..edb20ea --- /dev/null +++ b/ChangeLog-2002 @@ -0,0 +1,4416 @@ +2002-12-21 John Levon + + * Makefile.am: list module files explicitly, needed + for make dist from separate objdir + + * configure.in: make both x86/ and ia64/ changelogs + +2002-12-21 John Levon + + * module/Makefile.am: + * configure.in: remove the ln -s arch in favour of + using -I and AC_SUBST + + * module/ia64/arch.h: + * module/x86/arch.h: rename to op_arch.h + + * utils/Makefile.am: fix make uninstall + +2002-12-21 John Levon + + * utils/Makefile.am: fix back-compat scripts install + for 2.5 kernel + +2002-12-19 Will Cohen + + * utils/opcontrol: Revise kernel range computation. + +2002-12-19 Philippe Elie + + * pp/op_time.cpp: minor formating fix + * pp/oprofpp.cpp: fix #656123 corner case with --separate-sample + +2002-12-17 John Levon + + * configure.in: remove oprof_report - breaks make dist + +2002-12-17 Philippe Elie + + * libdb/*.c *.h: + * libutil/op_fileio.c: + * dae/opd_proc.c: doxygen comment fix + +2002-12-16 Philippe Elie + + * module/ia64/op_syscalls.c: + * module/x86/hammer_op_syscalls.c: + * module/x86/op_syscalls.c: u16 pid to u32, tested/compiled only with + 32 bits x86 + +2002-12-15 Philippe Elie + + * libutil++/string_manip.cpp: minor fix + * pp/derive_files.cpp: comment + +2002-12-14 Philippe Elie + + * pp/format_output.cpp: + * pp/format_output.h: + * pp/outsymbflag.h: + * pp/opp_symbol.h: add an app_name field in file_location and + formater options for this field. + + * pp/profile_container.cpp: + * pp/profile_container.h: add_samples() add app_name parameter + + * pp/oprofpp.cpp: + * pp/op_to_source.cpp: + * pp/op_time.cpp: + * pp/op_time_options.cpp: + * pp/op_time_options.h: honor app_name parameter. No user visible + change except for op_time -l when profiling with --separate-samples + + * doc/oprofile.1.in: + * doc/oprofile.xml: update doc + +2002-12-13 John Levon + + * doc/oprofile.xml: lots of fixes. Remove sysctl documentation + as its really an internal feature and was cluttering up + the user manual. + +2002-12-13 John Levon + + * doc/oprofile.xml: some clarifications on timer interrupt + +2002-12-12 John Levon + + * opcontrol: set one_enabled if timer interrupt. No + behaviour change, but "safer" + +2002-12-11 John Levon + + * pp/derive_files.h: + * pp/op_time.cpp: + * pp/op_time_options.cpp: + * pp/op_to_source.cpp: + * pp/opp_symbol.h: + * pp/profile.h: + * pp/profile_container.h: + * utils/Makefile.am: small pedantries + +2002-12-10 Will Cohen + + * utils/op_dump_25: + * utils/opcontrol (do_dump): Correct TMPFILE. + +2002-12-10 Will Cohen + + * daemon/opd_image.c (complete_dump): New. + * libop/op_config.h (OP_DUMP_STATUS): New. + * utils/op_dump_25: New file. + * utils/Makefile.am: Add op_dump_25. + * utils/opcontrol (do_dump): Revise how dump performed. + +2002-12-10 Philippe Elie + + * pp/profile.cpp : oprofpp reported incorrectly counter setting when + using multiple counter. Fix #651183 + +2002-12-10 Philippe Elie + + * pp/op_time.cpp: honor --excude-symbols. Fix #651165 + +2002-12-09 Philippe Elie + + * libutil++/op_bfd.cpp: stupid segfault when filtering included symbols + +2002-12-09 Philippe Elie + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: replace a 0(N²) by a 0(N) behavior + + * pp/output_format.cpp: actualize comment + +2002-12-08 Philippe Elie + + * pp/profile.cpp: use scoped_ptr + + * libopt++/popt_options.h: + * pp/counter_profile.cpp: minor cleanup + +2002-12-08 Philippe Elie + + * pp/counter_profile.cpp: + * pp/counter_profile.h: use scoped_ptr + +2002-12-08 Philippe Elie + + * pp/counter_profile.h: + * pp/counter_profile.cpp: relax samples_db_t sooner + +2002-12-08 Philippe Elie + + * pp/opp_samples_files.cpp: + * pp/opp_samples_files.h: + * pp/samples_container.cpp: + * pp/samples_container.h: + * pp/samples_file.cpp: + * pp/samples_file.h: rename class samples_file_t to counter_profile_t + rename class opp_samples_files to profile_t + rename class samples_container_t to profile_container_t + rename file using the new class name as filename w/o _t suffix + + * pp/format_output.cpp: + * pp/format_output.h: + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/op_to_source.cpp: + * pp/oprofpp.cpp: + * pp/symbol_container_imp.cpp: + * pp/symbol_container_imp.h: + * pp/Makefile.am: reflect above class/file name change + +2002-12-06 Philippe Elie + + * libdb/db_manage.c: + * libdb/db_hash.h: db_init() new to properly initialize a samples_db_t + + * dae/opd_image.c: + * daemon/opd_imge.c: earlier init a samples_db_t object using + db_init() rather a memset. This fix a potential bogosity cause we + closed a lot of time file descriptor 0 + +2002-12-06 Philippe Elie + + * dae/opd_image.c: + * dae/opd_image.h: + * dae/opd_kernel.c: use hash table entry 0 for kernel and module image + +2002-12-04 John Levon + + * pp/opp_symbol.h: + * pp/opp_symbol.cpp: + * pp/format_output.h: + * pp/format_output.cpp: + * others from above: create format_output namespace, some + clean up + +2002-12-04 Philippe Elie + + * daemon/opd_image.c: revert last change, it break daemon... + +2002-12-04 Philippe Elie + + * daemon/opd_image.c: re-enable opd_check_image_mtime() it's not + perfect but better than nothing + + * libutil++/cverb.cpp: comment fix + +2002-12-04 Will Cohen + + * utils/opcontrol: Revised checking to determine kernel + interface. + + +2002-12-04 Philippe Elie + + * libdb/db_test.c: measure system + user time + + * dae/oprofiled.c: better error message + * daemon/oprofiled.c: write_abi() is static + +2002-12-03 Philippe Elie + + * libdb/db_stat.c: + * libdb/db_debug.c: Alex whisp me than a few code was not 64 bits + size_t safe. + +2002-12-03 John Levon + + * doc/oprofile.xml: + * doc/oprofile.1.in: + * doc/Makefile.am: remove references to deprecated stuff + +2002-12-03 John Levon + + * utils/opcontrol: add --version + +2002-12-03 John Levon + + * utils/op_start: + * utils/op_start_25: + * utils/op_stop_25: + * utils/op_stop: print deprecation notice + +2002-12-03 John Levon + + * utils/op_session.c: + * utils/op_dump: print deprecation notice + +2002-12-03 John Levon + + * utils/opcontrol: do not shutdown on --reset. Send + signal on --reset/--save like op_session. Try to dump + like op_session to hack race "fix" + +2002-12-03 John Levon + + * utils/opcontrol: complain on opcontrol --save + +2002-12-03 Philippe Elie + + * daemon/opd_kernel.c: + * daemon/opd_kernel.h: minor cleanup + + * libabi/abi.cpp: + * libabi/abi_test.cpp: + * libabi/op_import.cpp: fix bad include filename. + +2002-12-03 Philippe Elie + + * libdb/.cvsignore: + * libdb/Makefile.am: + * libdb/*.c --> db-hash-name.c to db_name.c + + * dae/opd_image.h: + * daemon/opd_image.h: + * pp/samples_file.h: include db_hash.h + +2002-12-03 Philippe Elie + + * gui/oprof_start_config.cpp: allow default value change w/o + breaking actual user. + +2002-12-03 Philippe Elie + + * TODO: update + + * dae/opd_image.h: + * dae/opd_kernel.c: + * dae/opd_kernel.h: + * dae/opd_parse_proc.c: + * dae/opd_proc.c: + * dae/opd_proc.h: + * dae/opd_sample_files.c: + * dae/oprofiled.c: + * daemon/opd_image.h: + * pp/op_merge.cpp: + * pp/samples_file.h: + * pp/samples_file.cpp: + * pp/Makefile.am: + * libabi/Makefile.am: + * libabi/abi.cpp: + * libabi/abi_test.cpp: + * libabi/op_import.cpp: use hash table implementation of libdb + + * gui/oprof_start.cpp: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: + * gui/ui/oprof_start.base.ui: + * utils/op_start: + * doc/oprofile.1.in: + * doc/oprofile.xml: remove module hash table size + + * libdb/.cvsignore: update + * libdb/Makefile.am: build libdb-hash.a + * libdb/db-hash.h: + * libdb/db-hash-debug.c: + * libdb/db-hash-manage.c: + * libdb/db-hash-test.c: + * libdb/db-hash-insert.c: + * libdb/db-hash-stat.c: + * libdb/db-hash-travel.c: new files implementing a growable hash table + * libdb/Makefile.am: update + + * libop/op_config_24.h: remove module hash table. Increase + OP_PRE_WATERMARK, OP_DEFAULT_BUF_SIZE. + * libop/op_interface.h: struct op_sample update. + + * module/oprofile.h: + * module/oprofile.c: remove hash table + +2002-12-02 John Levon + + * configure.in: remove annoying AC_REVISION() + +2002-12-02 John Levon + + * utils/opcontrol: couple of minor cleanups + +2002-12-02 John Levon + + * utils/opcontrol: fix --deinit, complain on missing + argument + +2002-12-02 Will Cohen + + * doc/Makefile.am: Generate opcontrol. + * doc/oprofile.1.in: Add opcontrol information. + * doc/oprofile.xml: Add opcontrol information. + +2002-12-01 Will Cohen + + * utils/Makefile.am: Add opcontrol. + * utils/opcontrol: New. + +2002-12-01 John Levon + + * various files: don't use db_tree name outside of libdb, + it's implementation detail for most case + +2002-11-29 Graydon Hoare + + * module/x86/op_model_p4.c: fix dropped overflows. + +2002-11-26 Graydon Hoare + + * module/x86/op_model_p4.c: fix CCCR-clearing logic. + * module/x86/cpu_type.c: re-enable Pentium IV. + +2002-11-25 John Levon + + * module/x86/cpu_type.c: disable Pentium IV till it works + +2002-11-23 Philippe Elie + + * doc/oprofile.xml: start a FAQ. Clarify debug information vs + symbol information. Explain why we don't use dynamic symbol + +2002-11-20 John Levon + + * daemon/oprofiled.c: + * utils/op_start_25: kernel_only is a no-op on 2.5, no point + in it existing + +2002-11-19 Philippe Elie + + * daemon/oprofiled.c: /dev/oprofile/kernel_only doesn't exists + in timer int mode (second pass to fix #637804 ...) + +2002-11-17 Graydon Hoare + + * module/x86/op_apic.h: + * module/x86/op_apic.c: revert, use copy of kernel code. + +2002-11-16 Philippe Elie + + * dae/opd_kernel.c: + * dae/opd_mapping.c: + * dae/opd_proc.c: + * daemon/opd_image.c: + * daemon/opd_kernel.c: + * libop++/op_mangling.h: + * libutil++/cverb.h: + * pp/opp_samples_files.cpp: + * pp/samples_file.cpp: doxygen fix + * doc/srcdoc/Doxyfile: bump to 0.5 cvs + +2002-11-14 Will Cohen + + * gui/Makefile.am: Use $(bindir). + * oprof_report/Makefile.am: Use $(bindir). + +2002-11-15 Dave Jones + + * module/x86/cputype.c: Make the AMD case a bit simpler. + +2002-11-14 John Levon + + * dae/Makefile.am: + * daemon/Makefile.am: proper fix for c++ link + as suggested by Alexandre Duret-Lutz + +2002-11-14 Philippe Elie + + * Makefile.am: we installed module in the wrong directory. + +2002-11-14 Philippe Elie + + * libutil/op_file.c: op_simplify_path_name(): strip leading '/' + * daemon/oprofiled.c: + * dae/oprofiled.c: fix incorrect specification of vmlinux file + through --vmlinux=/foo//bar fixing #637805 + +2002-11-14 Philippe Elie + + * utils/op_start_25: /dev/oprofile/kernel_only doesn't exists + in timer int mode. fix #637804 + +2002-11-14 John Levon + + * dae/*: + * daemon/*: + * libutil++/op_bfd.h: + * pp/samples_container.cpp: + * pp/samples_container.h: doxygen anality + +2002-11-14 John Levon + + * libopt++/popt_options.h: + * libopt++/popt_options.cpp: place in popt + namespace to avoid clash with getopt.h + + * libabi/abi_test.cpp: + * libabi/op_import.cpp: + * pp/op_merge.cpp: + * pp/op_time_options.cpp: + * pp/op_to_source_options.cpp: + * pp/oprofpp_options.cpp: + * pp/session.cpp: fix for above + + * libabi/abi.cpp: + * libabi/abi.h: g++ 3.2 fixes + + * libabi/op_import.cpp: uninline extract + + * dae/Makefile.am: + * daemon/Makefile.am: fix c++ link hack for -Werror + +2002-11-13 Graydon Hoare + + ( this changeset is mostly Dave Jones' work ) + + * README: + * TODO: + * configure.in: + * doc/oprofile.xml: + * libop/op_cpu_type.c: + * libop/op_cpu_type.h: + * libop/op_events.c: + * utils/op_help.c: + * module/compat.h: + * module/compat24.h: + * module/op_util.c: + * module/x86/Makefile.in: + * module/x86/apic_compat.h: + * module/x86/arch.h: + * module/x86/cpu_type.c: + * module/x86/op_fixmap.c: + * module/x86/op_nmi.c: minor additions for hammer support. + + * module/x86/op_apic.c: + * module/x86/op_apic.h: major cleanup; add hammer support. + + * module/x86/hammer_entry.S: + * module/x86/hammer_ia32entry.S: + * module/x86/hammer_op_syscalls.c: + * module/x86/hammer_oprofile_nmi.S: new hammer support files. + +2002-11-14 John Levon + + * configure.in: hack around case where clean checkout + then ./configure --with-kernel-support + +2002-11-12 Graydon Hoare + + * autogen.sh: support overriding autotool binary names. + +2002-11-11 Philippe Elie + + * configure.in: honor --with-extra-libs + +2002-11-11 Philippe Elie + + * configure.in: add -W -Wall and optionnaly -Werror to user space + compilation + +2002-11-11 John Levon + + * dae/Makefile.am: + * daemon/Makefile.am: don't dist dummy.cpp + +2002-11-11 John Levon + + * dae/Makefile.am: + * daemon/Makefile.am: hack to fix --enable-abi + +2002-11-10 John Levon + + * configure.in: + * gui/Makefile.am: + * oprof_report/Makefile.am: only use X libs where + they're actually wanted + +2002-11-10 John Levon + + * configure.in: make included sstream work again + +2002-11-08 Will Cohen + + * doc/oprofile.xml: Update with IA64 information. + +2002-11-10 John Levon + + * Makefile.am: remove oprof_report from SUBDIRS to + avoid separate objdir problem + +2002-11-10 John Levon + + * most Makefile.am: do the dist_sources trick + properly + +2002-11-10 John Levon + + * Makefile.am: + * configure.in: + * dae/Makefile.am: + * daemon/Makefile.am: + * utils/Makefile.am: s/WITH_KERNEL_SUPPORT/kernel_support + + * configure.in: + * dae/Makefile.am: + * dae/oprofiled.c: + * daemon/Makefile.am: + * daemon/oprofiled.c: + * libabi/Makefile.am: approximate working --enable-abi more + +2002-11-10 John Levon + + * dae/oprofiled.c: + * daemon/oprofiled.c: abi tidy + +2002-11-10 John Levon + + * autogen.sh: be verbose + + * gui/Makefile.am: + * gui/ui/Makefile.am: + * oprof_report/Makefile.am: + * oprof_report/ui/Makefile.am: remove duplicate + set MOC/UIC + +2002-11-10 John Levon + + * Makefile.am: add comment + + * configure.in: no need to subst OPROFILE_25 + +2002-11-09 John Levon + + * TODO: update + + * configure.in: + * most Makefile.am: make separate objdir work, + except for module (impossible I suppose) + +2002-11-09 John Levon + + * autogen.sh: use --foreign + +2002-11-09 John Levon + + * configure.in: fix --with-kernel-support + + * doc/.cvsignore: add *.1 + + * libabi/Makefile.am: don't install abi_test + +2002-11-09 John Levon + + * all cvsignore: add Makefile.in + + * gui/Makefile.am: move EXTRA_DIST out of qt check + + * gui/ui/Makefile.am: + * oprof_report/ui/Makefile.am: fix AM_CPPFLAGS typo + +2002-11-09 John Levon + + * all build files: use automake, written by Phil + +2002-11-09 Philippe Elie + + * pp/samples_file.cpp: check than samples files version + match expected version fixing #635759 + +2002-11-07 John Levon + + * configure.in: + * module/compat.h: + * module/compat24.h: + * module/op_dname.c: + * module/oprofile.c: + * module/x86/op_fixmap.c: + * module/x86/op_nmi.c: remove 2.5 support from old + module code + +2002-11-06 Will Cohen + + * configure.in: Tests for ia64 architecture. + * dae/opd_mapping.c: Added includes. + * oprofile/dae/oprofiled.c (opd_do_samples): Typecast. + * libop/op_cpu_type.c (cpu_names, cpu_nr_counters): Add IA64 info. + * libop/op_cpu_type.h (op_cpu): Add IA64 enums. + * libop/op_events.c: Add defines for IA64 and IA64 events. + * libop++/op_print_event.cpp: Change include order to work on IA64. + * module/oprofile.c: Include "arch.h" file. + (evict_op_entry): Use IRQ_ENABLED macro. + (op_do_profile): Use INST_PTR and STATUS macros. + (oprof_init_data): Factor out computation. + * module/op_util.c (rvmalloc, rvfree): Typecasts. + * module/x86/arch.h: New. + * README: Update. + * utils/op_help.c (main): Add IA64 information. + + * module/ia64/arch.h: + * module/ia64/cpu_type.c: + * module/ia64/IA64entry.h: + * module/ia64/IA64minstate.h: + * module/ia64/IA64syscallstub.h: + * module/ia64/Makefile.in: + * module/ia64/op_ia64_model.h: + * module/ia64/op_pmu.c: + * module/ia64/oprofile_stubs.S: + * module/ia64/op_syscalls.c: New. + +2002-11-06 John Levon + + * configure.in: 0.5cvs + + * Makefile.in: mention doxyfile in release steps + +2002-11-06 Philippe Elie + + * pp/op_to_source.cpp: op_to_source --source-with-assembly: avoid + to be confused by source line which look like an asm line and + stop incorrectly the output. This change go in 0.4 release + +2002-11-06 John Levon + + * configure.in: bump to 0.4 in prep for release + +2002-11-06 John Levon + + * module/x86/cpu_type.c: detect if we actually are + using HT (from Alex T) + +2002-11-05 John Levon + + * doc/oprofile.xml: manual fixes from Will Cohen + +2002-11-01 John Levon + + * daemon/opd_image.c: fix lookup_dcookie usage + + * libabi/.cvsignore: add + +2002-11-01 Philippe Elie + + * module/x86/op_apic.c: restore correctly the lvtpc register + +2002-11-01 Philippe Elie + + * libop/op_hw_config.h: define DCOOKIE_SHIFT + * daemon/opd_image.c: use it + +2002-11-01 Philippe Elie + + * pp/Makefile.in: cleanup, build and use libpp.a + +2002-10-31 John Levon + + * pp/counter_array.cpp: using namespace std + +2002-10-31 Philippe Elie + + * dae/.cvsignore: + * dae/opd_image.c: + * dae/opd_kernel.c: + * dae/opd_sample_files.c: + * dae/opd_stats.c: + * dae/oprofiled.c: + * daemon/opd_image.c: + * daemon/opd_sample_files.c: + * libop/op_config_24.h: cleanup, including some little merging + from daemon to dae + + * daemon/opd_image.c: change dcookie hashing function + + * doc/oprofile.xml: typo + +2002-10-26 Philippe Elie + + * libutil++/file_manip.cpp: + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: cleanup + + * pp/counter_array.h: + * pp/counter_array.cpp: add a bool empty() member to counter_array_t + * pp/sample_container_imp.cpp: use it + +2002-10-26 Philippe Elie + + * configure.in: minor cleanup. Use config.h rather than gcc -D option + + * libutil/op_libiberty.h: + * libutil++/op_bfd.h: + * pp/opp_symbol.h: #include + + * libutil/Makefile.in: + * pp/Makefile.in: remove BFD_CXXFLAGS + +2002-10-24 Philippe Elie + + * libutil++/op_bfd.cpp: + * libutil++/op_bfd.h: allow to specify explicetly on which symbol we + want to work. + + * pp/op_to_source_options.h: + * pp/op_to_source_options.cpp: + * pp/op_to_source.cpp: handle --include-symbol, for asm output only + output for symbols with samplels or selected symbols. + + * pp/oprofp.cpp: + * pp/samplesc_ontainer.cpp: minor change to reflect op_bfd api change + +2002-10-24 Philippe Elie + + * daemon/opd_image.c: revert 64 bit dcookie patch commited + accidentally with 2002-10-18 abi patch. + +2002-10-21 Graydon Hoare + + * doc/oprofile.xml: Describe op_import and --enable-abi. + +2002-10-20 Philippe Elie + + * pp/Makefile.in: + * pp/session.cpp: + * pp/session.h: + * pp/op_time_options.cpp: + * pp/op_to_source.cpp: + * pp/oprofpp.cpp: + * doc/oprofile.1.in: + * doc/oprofile.xml: handle --session options + +2002-10-19 John Levon + + * configure.in: AC_HELP_STRING is too new for my autoconf + +2002-10-18 Graydon Hoare + + * libabi/*: Add support for abi descriptions, for portability. + * daemon/oprofiled.c: + * dae/oprofiled.c: Emit abi description on startup. + * configure.in: Add --enable-abi option. + * make.common.in: + * Makefile.in: Support building libabi/ + +2002-10-19 John Levon + + * utils/op_start_25: grep -o does not exist on any of + my systems - fix + +2002-10-19 Philippe Elie + + * libutil++/op_bfd.cpp: calculate symbol size after removing duplicate + symbol. Fix #625678 + +2002-10-19 Philippe Elie + + * pp/op_to_source.cpp: + * pp/op_to_source_options.cpp: + * pp/op_to_source_options.h: + * doc/oprofile.1.in: + * doc/oprofile.xml: allow to pass multiple options to objdump + + * pp/opp_symbol.h: + * pp/samples_container.cpp: store symbol size in symbol_entry object. + +2002-10-19 Philippe Elie + + * libutil++/child_reader.cpp: In some pathological case getline() + finished too early when child process write on stderr. + +2002-10-18 Philippe Elie + + * libutill++/child_reader.cpp: read_block() : cumulate stderr + output rather to overwrite always the same buffer space ... + +2002-10-16 John Levon + + * utils/op_start_25: check if mounted, from Will Cohen + Also mkdir the mountpoint + +2002-10-16 Philippe Elie + + * configure.in: get linux include path earlier + +2002-10-15 Philippe Elie + + * dae/oprofiled.c: + * daemon/oprofiled: strerrno --> strerror + +2002-10-14 Philippe Elie + + * libop/op_events.c: typo in L2_DBUS_BUSY_RD PPro event name + +2002-10-13 Philippe Elie + + * README: update contrib + * TODO: update + + * gui/oprof_start.cpp: better error message, fixme removal + + * libdb/db-insert.c: fix samples count overflow. + + * libdb/db.h: + * libdb/db-manage.c: + * libdb/db-debug.c: don't use page zero, use this value as nil page + number, avoid to touch mmaped memory when growing the samples file. + * libop/op_config.h: bump OPD_VERSION + +2002-10-12 Philippe Elie + + * pp/samples_file.h: + * pp/samples_file.cpp: move class opp_samples_files ... + * pp/opp_samples_files.h: + * pp/opp_samples_files.cpp: to these new files + + * pp/Makefile.in: + * pp/op_to_source.cpp: + * pp/oprofpp.cpp: reflect above change + +2002-10-12 Philippe Elie + + * dae/opd_sample_files.c: fixme remove + * dae/oprofiled.c: + * daemon/oprofiled.c: minor error message improvement + + * pp/op_time.cpp: + * pp/symbol_container.cpp: fixme remove + + * pp/samples_file.cpp: + * pp/sample_file.h: privatize more data members + +2002-10-12 Philippe Elie + + * libutil++/utility.h: op_ratio() new + * pp/op_time.cpp: + * pp/op_to_source.cpp: + * pp/opp_symbol.cpp: + * pp/samples_container.cpp: use op_ratio() + +2002-10-11 Philippe Elie + + * libutil++/file_manip.cpp: + * libutil++/filename_match.cpp: + * libutil++/string_manip.cpp: + * libutil++/string_manip.h: fix dirname(), basename(), remove rtrim() + +2002-10-07 John Levon + + * daemon/opd_image.h: + * daemon/opd_image.c: + * daemon/oprofiled.c: + * libop/op_interface_25.h: update to latest interface + +2002-10-06 Philippe Elie + + * dae/opd_image.c: allow to free(image->app_name) + +2002-10-05 Philippe Elie + + * daemon/opd_image.c: + * dae/opd_image.c: spacing + + * dae/opd_mapping.c: + * dae/opd_mapping.h: kill op_grow_maps() simplify adding map path + * dae/opd_parse_proc.c: use opd_add_mapping() + +2002-10-05 Philippe Elie + + * TODO: update + + * doc/oprofile.xml: more doc in interpreting results + +2002-10-04 Philippe Elie + + * pp/opp_symbols.cpp: + * pp/opp_symbols.h: + * pp/outsymbflag.h: implement 'q' 'Q' format flags. Fix #618165 + * pp/op_time_options.cpp: reject these formats for op_time + * doc/oprofile.1.in: + * doc/oprofile.xml: document them + +2002-10-02 John Levon + + * Makefile.in: use -P to strip dead dirs on dist + + * dae/opd_parse_proc.c: spacing + +2002-10-02 Philippe Elie + + * libdb/db-*.c/*.h: typedef tweaking for 64 bits arch (signaled + by Dave Jones) + + * remove libdb/ChangeLog, old entries are: + + 2002-04-20 Philippe Elie + * db-insert.c: check for count overflow + + 2002-04-20 Philippe Elie + * db-manage.c: properly handle already existing db file + * db.h: extern "C" wrapper + + 2002-04-19 Philippe Elie + * *.c;*.h: make plugin db in oprofile more easy. + + 2002-04-18 Philippe Elie + * *.c;*.h: prefix all public identifier with db_. + Use typedef as much I can rather than plain unsigned int. + + 2002-04-17 Philippe Elie + * db-debug.c: + * db-insert.c: + * db-manage.c: + * dbtest.c: + * db-travel.c: + * db.h: add file locking and necessary stuff to allow + plugging db in an imbedded file format like oprofile + samples files. + + 2002-04-16 Philippe Elie + * db-manage.c: silly bug fix, db works now with + malloc/realloc or mmap/mremap memory allocation + selected at compile time. + + 2002-04-14 Philippe Elie + * first import standalone code to test btree samples files + +2002-10-02 Philippe Elie + + * module/x86/op_msr.h: Hyper threading #define + * module/x86/cpu_type.c: include op_msr.h + +2002-10-02 Philippe Elie + + * */*.cpp: using std::xxx; --> using namespace std; + +2002-10-01 Will Cohen + + * module/x86/cpu_type.c (p4_threads): New. + (get_cpu_type): Use p4_threads(). + * doc/oprofile.xml: Add comment about P4 HT support. + +2002-10-01 John Levon + + * daemon/opd_image.c: fix non --separate-samples. Still broke. + +2002-10-01 John Levon + + * libop/op_cpu_type.h: + * libop/op_cpu_type.c: make this work on 2.5/normal both. + Does not respect different mounted oprofilefs (yet) + +2002-10-01 John Levon + + * daemon/.cvsignore: add + + * libop/op_interface_25.h: + * daemon/opd_image.h: + * daemon/opd_image.c: + * daemon/oprofiled.c: fixups for new encoded interface. Fix + --separate-samples + + * utils/op_start_25: startup fixes + +2002-09-26 Will Cohen + + * module/x86/op_model_p4.c: Correct TC_DELIVER_MODE cccr select. + +2002-09-23 Graydon Hoare + + * dae/oprofiled.c: + * daemon/op_sample_files.c: + * daemon/oprofiled.c: + * pp/op_to_source.c: + * utils/op_help.c: u8 unit mask -> u16 unit-mask. I'm not sure this + catches *all* the instances, but it does appear to be an improvement + +2002-09-30 William Cohen + + * libutil++/string_manip.cpp (sample_filename): Correct declaration. + * pp/samples_container.h: Correct add_samples() declaration. + +2002-09-29 Philippe Elie + + * libutil++/string_manip.cpp: + * libutil++/string_manip.h: sample_filename() new + + * pp/samples_container.cpp: + * pp/samples_container.h: add_samples() new + + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/oprofpp.cpp: + * pp/samples_file.cpp: use them + minor cleanup + +2002-09-28 Philippe Elie + + * libopt++/popt_options.cpp: fix #615760, in rare case + oprofpp called with lot of invalid arguments segfault + during the help printing. All post-profile tools are + concerned by this fix. + + * doc/oprofile.xml: small improvements + + * libutil++/op_bfd.cpp: improve error message when bfd_openr() fails. + + * TODO: update + +2002-09-28 Philippe Elie + + * dae/opd_image.c: + * dae/opd_kernel.c: + * dae/opd_parse_proc.c: + * dae/opd_parse_parse.h: + * dae/opd_proc.c: + * dae/opd_sample_files.c: + * daemon/opd_image.c: + * daemon/opd_kernel.c: + * daemon/opd_sample_files.c: + * libop/op_cpu_type.c: + * libop/op_events.c: + * libop/op_events_desc.c: + * libopt++/popt_options.cpp: + * libutil/op_deviceio.c: + * libutil/op_file.c: + * libutil++/file_manip.cpp: + * libutil++/file_manip.h: + * libutil++/string_manip.h: + * pp/op_to_source.cpp: doxygen fix + +2002-09-27 John Levon + + * configure.in: add --with-kernel-support for 2.5 + + * daemon/oprofiled.c: fix comment, give exit message on sig + + * utils/Makefile.in: + * utils/op_stop_25: add 2.5 op_stop, no 2.5 op_dump + + * utils/op_start_25: use enable + +2002-09-25 Bob Montgomery + + * module/oprofile.c: avoid to dump zero samples count, fix #615087 + +2002-09-25 Philippe Elie + + * dae/opd_image.c: fix #615166, ensure we recognize an + existing image struct so we don't try to create db_tree_t + object for the same samples files. + * db/db-debug.c: display page index when something goes wrong + * db/db-insert.c: be more strict on assertion + +2002-09-25 Philippe Elie + + * doc/Makefile.in: remove dependencies for doc/html.xsl + +2002-09-25 Philippe Elie + + * doc/xsl/.cvsignore: new + * doc/oprofile.xml: document watchdog problem + +2002-09-25 John Levon + + * module/x86/op_nmi.c: OP_MAX_CPUS is not necessarily + static so use NR_CPUS for array instead. Fix a prototype. + +2002-09-23 Graydon Hoare + + * doc/oprofile.xml: Add some P4 documentation. + * configure.in: Add detection of different stylesheet paths. + * doc/xsl/xhtml.xsl.in: Parameterize by configure's result. + * doc/xsl/xhtml.xsl: Remove. + * dae/opd_sample_files.c: Change unit mask from 8 to 16 bits. + * gui/oprof_start.cpp: Change number of unit masks from 7 to 16. + * gui/ui/oprof_start.base.ui: Likewise. + * libop/op_cpu_type.c: Add P4 CPU type. + * libop/op_events.h: Change unit mask bit width, number. + * libop/op_events.c: Add P4 events, unit masks. + * libop_op_hw_config.h: Set OP_MAX_COUNTERS to 8. + * libop++/op_print_event.cpp: Change unit mask bit width. + * libop++/op_print_event.h: Likewise. + * module/oprofile.c: Add extra sysctls for counters 5-8. + * module/x86/Makefile.in: Add op_model_p4.o to obj list. + * module/x86/cpu_type.c: Change CPU identification to handle P4. + * module/x86/op_apic.c: (enable_apic): APIC_MAXLVT < 4, not != 4. + (check_cpu_ok): Accept CPU_P4. + * module/x86/op_model_p4.c: New file. + * module/x86/op_nmi.c: (get_model): Handle CPU_P4. + Add sysctl names for counters 5-8. + * module/x86/op_x86_model.h: Declare extern op_p4_spec. + +2002-09-24 Philippe Elie + + * dae/opd_image.c: + * dae/opd_image.h: + * dae/opd_kernel.c: + * dae/oprofiled.c: + * dae/p_module.h: + * dae/opd_image.c: + * dae/opd_kernel.c: + * dae/oprofiled.c: + * dae/p_module.h: small blank/comment change to minimize + diff between daemon and dae dir. + +2002-09-23 John Levon + + * configure.in: fix for 2.5 patch to build + +2002-09-23 John Levon + + * utils/Makefile.in: + * utils/op_start_25: 2.5 patch start script + +2002-09-23 John Levon + + * dae/opd_image.c: + + * libop/op_cpu_type.c: fix arrays + +2002-09-23 John Levon + + * utils/op_start: use right value for RTC CPU + +2002-09-23 John Levon + + * libop/op_config.h: + * libop/op_config_24.h: + * libop/op_config_25.h: split config file up + + * daemon/opd_kernel.c: + * daemon/oprofiled.c: include op_config_25.h + + * dae/oprofiled.c: + * dae/opd_image.c: + * dae/opd_kernel.c: + * dae/opd_mapping.c: include op_config_24.h + + * module/oprofile.h: include op_config_24.h + + * gui/oprof_start.cpp: + * gui/oprof_start_config.cpp: fix from above + (old support only right now) + + * libop/op_cpu_type.h: introduce 2.5-patch CPU_TIMER_INT + +2002-09-23 John Levon + + * libop/op_interface_25.h: 2.5 interface + + * daemon/opd_image.c: + * daemon/opd_sample_files.c: + * daemon/oprofiled.c: + + * libop++/op_print_event.h: fix header + + * pp/op_to_source.cpp: change from above + +2002-09-23 John Levon + + * daemon/: new 2.5 patch daemon code. WIP + + * configure.in: + * Makefile.in: detect 2.5 patch and build appropriately + +2002-09-23 John Levon + + * module/x86/op_msr.h: match kernel naming + + * module/x86/op_model_athlon.c: from above + +2002-09-22 Philippe Elie + + * libdb/db-insert.c: bad cut&paste. Shame on me, I broke the build... + +2002-09-22 Philippe Elie + + * libdb/db-insert.c: handle samples count overflow. + + * libdb/Makefile.in: db-test new target not built by default. + * libdb/db-debug.c: more strict checking + * libdb/db-test.c: allow db-test to be used as "db-test samples_dir/*" + +2002-09-22 John Levon + + * dae/opd_stats.c: nicify + + * module/x86/op_model_pproc.c: + * module/x86/op_model_athlon.c: drop macro prefixes, ws fixes + + * module/x86/op_nmi.c: fix save/restore possible crash, init + possible leak + +2002-09-22 Philippe Elie + + * module/x86/op_model_pproc.c: fix p6_start() + * module/x86/op_model_athlon.c: fix athlon_start() + * module/x86/op_nmi.c: pmc_save_registers() typo when checking + null for kmalloc return value + +2002-09-20 Graydon Hoare + + * module/x86/op_x86_model.h: New interface for MSRs. + * module/x86/op_nmi.c: Use interface. + * module/x86/op_model_ppro.c: New, code from op_nmi.c. + * module/x86/op_model_athlon.c: New, code from op_nmi.c. + * module/x86/Makefile.in: Reflect new files. + +2002-09-20 John Levon + + * libutil++/op_bfd.cpp: fix a bug where we broke + with multiple executable sections due to sorting + the symbols wrongly. Fix #617288 and the duplicated + #617264 + + * libutil++/op_bfd.h: fix an outdated comment + + * dae/opd_image.c: fix comment + +2002-09-19 Graydon Hoare + + * libop/op_events.h: + * libop/op_events_desc.c: Move descriptions from here. + * libop/op_events_desc.h: + * libop/op_events.c: To here. + (um_*): Add new static unit masks. + (op_events): Use pointers to static unit masks. + * libop++/op_print_event.h: + * libop++/op_print_event.cpp: + * gui/oprof_start.h: + * gui/oprof_start.cpp: + * utils/op_help.c: Make compatible with struct changes. + +2002-09-18 John Levon + + * utils/op_start: give an example for unit mask. + +2002-09-18 Will Cohen + + * libop/op_mangle.c: (op_mangle_filename): Correct logic for + generating mangled name. Fix #611107 + +2002-09-15 John Levon + + * libop/op_event.c: fix comment + +2002-09-15 Philippe Elie + + * module/x86/cpu_type.c: allow to force RTC mode. + * dae/oprofiled.c: checking when we need to backup samples + dir in RTC mode was broken. + +2002-09-14 Philippe Elie + + * libop/op_config.h: remove OP_MIN/MAX_PID, OP_MIN/MAX_PGRP + * gui/oprof_start.cpp: pid_filter/pgrp_filter accept all integer + +2002-09-13 John Levon + + * acinclude.m4: another tweak + +2002-09-13 Philippe Elie + + * Makefile.in: never remove doc/oprofile.html. + * acinclude.m4: small work-around for sed-related problem + +2002-09-12 Will Cohen + + * Makefile.in: Separate kernel and user code build rules. + +2002-09-12 Will Cohen + + * libutil++/child_reader.h (child_reader): Add missing "std::". + * libutil++/child_reader.cpp (error_str): Ditto. + +2002-09-12 John Levon + + * acinclude.m4: update from upstream + +2002-09-12 John Levon + + * acinclude.m4: fix moc2/moc conflict, cache val + +2002-09-12 Philippe Elie + + * libutil++/child_reader.cpp: + * libutil++/child_reader.h: fix for child terminated by a signal + * gui/oprof_start_util.cpp: + * pp/op_to_source.cpp: use the the new child_reader interface + +2002-09-11 John Levon + + * acinclude.m4: + * configure.in: + * gui/Makefile.in: replace with new Qt configure script + +2002-09-11 Philippe Elie + + * acinclude.m4: fix qt3 detection in some corner case. + +2002-09-11 Philippe Elie + + * pp/samples_container.cpp: + * pp/samples_container.h: Check at run time we don't try to use an + unitialized samples_container_t. + +2002-09-11 Philippe Elie + + * pp/op_time.cpp: exit sooner when no samples files are available. + +2002-09-09 Will Cohen + + * dae/opd_kernel.c (struct opd_module): + (kernel_start, kernel_end): + (opd_parse_kernel_range): + (opd_drop_module_sample): + (opd_find_module_by_eip): + (opd_handle_module_sample): + (opd_handle_kernel_sample): + (opd_eip_is_kernel): + * dae/opd_kernel.h (opd_handle_kernel_sample): + (opd_eip_is_kernel): + * dae/opd_mapping.c (opd_put_mapping): + * dae/opd_mapping.h (struct opd_map): + (opd_is_in_map): + (opd_map_offset): + * dae/opd_parse_proc.c (opd_add_ascii_map): + * dae/opd_proc.c(verb_show_sample): + (opd_put_image_sample): + * dae/opd_proc.h (opd_put_image_sample): Change things referring + to addresses to unsigned long for operation on 64-bit machines. + +2002-09-07 Philippe Elie + + * all source file : remove email address from @author + +2002-09-05 Philippe Elie + + * libop/op_interface.h: (op_sample, op_note): Make compatible with + 64-bit targets. + * dae/opd_proc.c: (opd_put_sample): Adjust verbprintf arguments. + (opd_handle_fork): Ditto. + * dae/oprofiled.c: (opd_do_samples): Ditto. + +2002-09-04 Will Cohen + + * module/op_rtc.c: move to ... + * module/x86/op_rtc.c: here + * module/Makefile.in: + * module/x86/Makefile.in: reflect file move + +2002-09-03 Will Cohen + + * module/oprofile.h: (regparm3): remove, use FASTCALL instead. + * module/oprofile.c: (op_do_profile): Eliminate regparm3. + +2002-09-03 Will Cohen + + * module/oprofile.c: (oprof_read, oprof_note_read): Return ssize_t. + +2002-08-30 Will Cohen + + * Makefile.in: + * make.common.in: more DESTDIR change + +2002-09-02 Dave Jones + + * module/x86/cpu_type.c: support hammer in ia32 mode + +2002-09-02 John Levon + + * doc/oprofile.xml: mention Qt 3 + +2002-08-30 Will Cohen + + * doc/Makefile.in: Set MANDIR and CATDIR based on DESTDIR. + +2002-08-16 Philippe Elie + + * dae/opd_kernel.c: + * dae/opd_kernel.h: + * dae/opd_proc.c: + * dae/opd_proc.h: + * dae/oprofiled.c: + * libop/op_hw_config.h: + * libop/op_interface.h: + * module/oprofile.c: + * module/oprofile.h: change the layout of data used between + daemon/module (32 bits pid fix for 2.5.31) + + * gui/oprof_start_config.h: use pid_t + + * libutil/op_fileio.c: op_read_file(), op_write_file(), use %lu + and cast, uglier solution but more portable than last fix + + * utils/op_start: typo + +2002-08-14 William Cohen + + * libutil/op_fileio.c (op_read_file): Change fprintf specifier. + (op_write_file): Ditto. + +2002-08-08 Will Cohen + + * utils/op_start: Do not compute quantity of counters from + CPUTYPE. Get counter names directly from /proc/sys/dev/oprofile. + +2002-08-06 Philippe Elie + + * Makefile.in: + * doc/Makefile.in: delete generated doc only on a make maintainerclean + + * pp/opp_symbol.cpp: small cleanup + +2002-08-06 Philippe Elie + + * dae/opd_parse.c: + * dae/opd_proc.c: + * dae/opd_proc.h: fix #591275 which is a re-hash of #584723 we can + now safely assume than proc->maps[0] is the primary image. + Problem reported by William cohen + +2002-08-03 Philippe Elie + + * libutil++/string_manip.h: + * libutil++/string_manip.cpp: separate_token() treat escape sequence + +2002-07-30 Philippe Elie + + * gui/oprof_start.cpp: apply misssing part from this patch + 2002-07-27 Will Cohen + + * dae/oprofiled.c: + * doc/oprofile.1.in: + * util/oprof_start: + * doc/oprofile.xml: clarify than pgrp filter is the tty program + group id + +2002-07-28 Philippe Elie + + * libop/op_cpu_type.c: + * libop/op_cpu_type.h: + * libop/op_events.h: + * pp/samples_file.cpp: op_get_cpu_nr_counters() / op_get_nr_counters() + merge + + * module/compat22.h: + * module/x68/op_apic.c: __cli()/__sti() removal, this fix build up + to 2.5.29 + + * module/op_fixmap.c: fix test_bit() warning + +2002-07-27 Will Cohen + + * gui/oprof_start_config.cpp: config_setting::config_setting() + uses uname to guess path to vmlinux. + +2002-07-27 John Levon + + * dae/opd_stats.h: + * dae/opd_stats.c: + * dae/opd_proc.c: log unique samples vs. sample entries + +2002-07-27 Will Cohen + + * dae/oprofiled.c: + * gui/oprof_start.cpp: + * libop/op_cpu_type.h: + * libop/op_cpu_type.c: op_get_nr_counter() new, localize + op_nr_counter computations. + +2002-07-26 Philippe Elie + + * TODO: update + + * utils/op_start: fix #587093, some option of op_start + was incorrectly checked + +2002-07-26 Philippe Elie + + * pp/op_time_options.cpp: + * pp/oprofpp_options.cpp: output format header or details are illegal + if not combined with other output format flag + + * pp/opp_symbol.cpp: + * pp/opp_symbol.h: + * pp/oprofpp.cpp: + * pp/outsymbflag.h: minor cleanup + +2002-07-25 John Levon + + * configure.in: bump to 0.4cvs + +2002-07-24 Kevin Puetz + + * gui/ui/oprof_start.base.ui: fix resize + +2002-07-22 Philippe Elie + + * libutil/op_fileio.c: + * libutil/op_fileio.h: opd_get_link() new, read a symlink filename + * libutil++/file_manip.cpp: + * libutil++/file_manip.h: opd_read_link() use the above function + + * dae/opd_image.c: + * dae/opd_parse_proc.c: fix #584723 we can not assume than the first + map in /proc/pid/maps is the the map for the binary image + +2002-07-21 John Levon + + * configure.in: bump to 0.3 + +2002-07-17 William Cohen + + * gui/oprof_start_util.cpp: get HZ from sysconf + +2002-07-17 Philippe Elie + + * gui/oprof_start.base.ui: revert patch 2002-07-13, reapply + the same modification with QT2 designer rather QT3 designer + +2002-07-14 John Levon + + * Makefile.in: set KVERS properly + + * dae/oprofiled.c: remove eip == 0 checking + + * module/oprofile.c: do check in evict_op_entry() instead, + as suggested by Philippe + +2002-07-13 Philippe Elie + + * TODO: update + + * make.deps: + * gui/Makefile.in: fix include search path for dependencies generation + +2002-07-13 John Levon + + * dae/oprofiled.c: don't throw away last samples on shutdown + notification + +2002-07-13 Philippe Elie + + * TODO: update + + * doc/oprofile.1.in: + * doc/oprofile.xml: + * gui/oprof_start.cpp: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: + * gui/oprof_start.base.ui: remove kernel-range specification UI + +2002-07-12 John Levon + + * TODO: update + + * dae/oprofiled.c: + * libop/op_interface.h: + * module/oprofile.c: + * module/oprofile.h: + * module/x86/op_nmi.c: + * module/x86/op_syscalls.c: replace partial_stop,quitting,prof_on + with single state variable, and clean up how shutdown is triggered. + + * module/oprofile.c: always init data->entries etc. for every CPU + +2002-07-12 Philippe Elie + + * Makefile.in: typo in clean target + + * module/compat.h: + * module/compat24.h: + * module/oprofile.c: + * module/x86/op_nmi.c: support for online/offline cpu for 2.5.23+ + +2002-07-11 Philippe Elie + + * Makefile.in: + * module/Makefile.in: + * module/x86/Makefile.in: move all goal to the topdir Makefile + +2002-07-10 Philippe Elie + + * TODO: update + + * pp/op_time.cpp: errno for file permission problem is + EACCES not EPERM ... + + * module/x86/op_apic.c: + * module/x86/op_fixmap.c: + * module/x86/op_nmi.c: revert partially the 2002-06-26 patch, preempt + need rather to be fixed before/after calling the + op_int_operation functions pointer. + +2002-07-09 Philippe Elie + + * gui/oprof_start.cpp: use not + * libutil/op_libiberty.c: don't assume than string.h is included + by libiberty.h as in old gcc release + +2002-07-08 Philippe Elie + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: pass vector by const reference rather + than by value + + * pp/op_to_source.cpp: always output file even if the corresponding + source file does not exist + +2002-07-06 Philippe Elie + + * libopt++/popt_options.cpp: provide a dtor in derived class + + * doc/oprofile.1.in: + * pp/op_to_source.cpp: --output --no-output are meaningfull + in all case. + +2002-07-06 Philippe Elie + + * gui/oprof_start.cpp: + * pp/sample_container_imp.cpp: + * pp/symbol_container_imp.cpp: + * pp/op_to_source.cpp: fix an ISO corner case (3.4.2 #2) + +2002-07-05 Philippe Elie + + * libutil++/filename_match.h: + * libutil++/filename_match.cpp: constify + + * module/Makefile.in: small typo + * Makefile.in: do not make uninstall in module/arch + + * pp/op_to_source_options.h: + * pp/op_to_source_options.cpp: + * pp/op_to_source.cpp: general cleanup, remove the output class and + use free function instead, doxygen'ize them. + +2002-07-04 Philippe Elie + + * libop/op_events.cpp: + * libop/op_events.h: + * module/x86/op_nmi.c: + * dae/oprofiled.c: op_check_events() no longer accept 0 as valid events + + * pp/opp_symbol.cpp: small dead code removal + * pp/opp_symbol.h: doxygen comment fix + + * configure.in: do not use AC_CHECK_FILE: this macro generate + spurious warning with autoconf 2.2.13 + + * pp/op_to_source_options.h: + * pp/op_to_source_options.cpp: + * pp/op_to_source.cpp: + * doc/oprofile.1.in: + * doc/oprofile.xml: implement --objdump-params='params_strings' + allowing to pass additional parameters to objdump. + +2002-07-03 Philippe Elie + + * libutil/op_fileio.c: remove a FIXME, it's not worthwhile to try to + use GNU getline() instead of op_get_line() + + * pp/op_time.cpp: + * pp/op_time_options.cpp: + * pp/op_time_options.h: + * pp/oprofpp.cpp: remove minor FIXME + + * pp/opp_symbol.h: class outut_symbol: clarify why, with the current + design, some function are public member rather private. + +2002-07-01 Philippe Elie + + * configure.in: + * module/compat.h: fix compile error with kernel <= 2.2.17 + +2002-07-01 Philippe Elie + + * TODO: minor upadte + + * configure.in: support 2.5.20 + + * dae/opd_image.c: + * dae/opd_proc.c: + * libop++/op_print_event.h: + * libutil/op_popt.c: + * pp/op_merge.cpp: + * pp/samples_container.cpp: + * pp/symbol_container_imp.cpp: + * pp/symbol_functors.h: minor #include tweak + +2002-06-30 Philippe Elie + + * libdb/db.h: + * libdb/db-manage.c: constify db_sync() parameter. + + * dae/opd_image.c: fix #574459 "vmlinux samples file not backed up + by op_session". Small cleanup by adding opd_for_each_image() + +2002-06-29 Philippe Elie + + * TODO: update + + * libutil++/filename_match.cpp: + * libutil++/filename_match.h: add a convenience ctor. + + * doc/oprofile.1.in: + * doc/oprofile.xml: + * op_time.cpp: better error message for EPERM problem + * op_time_options.h: + * op_time_options.cpp: allow the user to specify explicitely on which + filename he want to work + +2002-06-29 Philippe Elie + + * TODO: update + + * acinclude.m4: + * configure.in: + * make.common.in: + * gui/Makefile.in: + * gui/ui/Makefile.in: better qt3 handling + + * doc/oprofile.1.in: + * doc/oprofile.xml: fix oprof_start --option=blah + +2002-06-28 Philippe Elie + + * .cvsignore: minor fix + + * configure.in: + * acinclude.m4: ugly temporary hack to compile with kde3/qt3 + * oprof_start.cpp: + * oprof_start_config.cpp: gcc-3.1 and qt3 fix (qt3 have an + hex() somewhere ...) + + * module/x86/op_fixmap.c: minor comment fix + +2002-06-26 Philippe Elie + + * TODO: update + + * module/compat.h: + * module/x86/op_apic.c: + * module/x86/op_fixmap.c: + * module/x86/op_nmi.c: preemptible kernel support. This fix point + #2 of kernel_src/Documentation/preempt-locking.txt + +2002-06-25 Philippe Elie + + * TODO: update + + * doc/oprofile.1.in: + * doc/oprofile.xml: document op_start --kernel-range option + * gui/oprf_start.cpp: + * gui/oprof_start.h: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: + * gui/ui/oprof_start_base.ui: + * utils/op_start: implement --kernel-range + + * gui/Makefile.in: force ui sub-dir build + +2002-06-25 Philippe Elie + + * TODO: update + + * configure.in: new AX_KERNEL_VERSION() to allow kernel version check, + use it to check minimal kernel version and fix 2.5.19 breakage + * module/.cvsignore: + * module/x86/.cvsignore: add .*.cmd + * module/Makefile.in: + * module/x86/Makefile.in: fix 2.5.19 make through EXTRA_CFLAGS_MODULE + * module/compat22.h: fix missing BUG() definition in 2.2 kernel + * module/x86/oprofile_nmi.S: fix minor 2.2 compile problem + + * pp/op_to_source.cpp: minor comment fix + +2002-06-18 John Levon + + * utils/op_start: + * pp/samples_file.h: + * libop/op_config.h: + * doc/oprofile.1.in: + * doc/oprofile.xml: + * dae/oprofiled.c: + * dae/opd_kernel.h: + * dae/opd_kernel.c: don't parse System.map any more, + now we work based off vmlinux alone + + * dae/opd_proc.c: move eip_is_kernel() into opd_kernel.c + +2002-06-18 John Levon + + * README: + * doc/oprofile.xml: update credits + +2002-06-16 John Levon + + * pp/op_time_options.h: + * pp/op_time_options.cpp: move private stuff out of + options namespace + +2002-06-16 John Levon + + * pp/counter_util.cpp: stop when we reach the first + available counter for sorting + + * pp/op_to_source.cpp: use absolute sample file name + + * pp/samples_file.cpp: better error message + +2002-06-16 John Levon + + * various: remove spurious == false, == true + +2002-06-15 John Levon + + * dae/oprofiled.c: + * libop/op_interface.h: + * libop++/op_print_event.h: + * module/oprofile.c: define a buffer head for the module + buffer interface, and use it + + * module/Makefile.in: oops, install the module properly + +2002-06-15 John Levon + + * libop/Makefile.in: + * libop/op_cpu_type.h: + * libop/op_cpu_type.c: new files split out, defines + changed + + * dae/opd_proc.c: + * dae/opd_sample_files.c: + * dae/oprofiled.c: + * gui/oprof_start.cpp: + * libop/op_events.h: + * libop/op_events.c: + * libop/op_events_desc.h: + * libop/op_events_desc.c: + * libop/op_interface.h: + * libop++/op_print_event.h: + * module/oprofile.h: + * module/x86/op_nmi.c: changes from above + +2002-06-15 John Levon + + * Makefile.in: compile module early as it's most + likely to fail + + * TODO: update + + * doc/oprofile.xml: + * configure.in: remove unneeded --with-cc + + * module/x86/Makefile.in: use USE_STANDARD_AS_RULE + + * module/x86/op_nmi.c: add preemption exclusion + +2002-06-15 John Levon + + * dae/opd_parse_proc.c: remove FIXME. We are fine to + assume first entry in maps is the executable, because + this is exactly what the kernel does (see /proc/pid/exe) + +2002-06-15 John Levon + + * pp/oprofpp.cpp: call check_mtime() correctly + for shared libraries + +2002-06-14 John Levon + + * libop/op_events.c: add warning + + * module/Makefile.in: link against libop.a like I meant to + + * module/oprofile.h: + * module/oprofile.c: readability cleanup + +2002-06-11 John Levon + + * module/compat.h: + * module/x86/arch_compat.h: remove arch_compat.h, + add BUG_ON() + + * module/op_util.c: return -EINVAL not 1 from check_range() + + * module/oprofile.c: use BUG_ON() in release functions, + fix use of check_range, remove spurious check for malloc + failure (already checked) + + * module/oprofile.h: clarify API + + * module/x86/op_msr.h: new file, MSR back-compat + + * module/x86/op_nmi.c: + * module/x86/op_apic.c: use it + +2002-06-10 John Levon + + * TODO: update + + * configure.in: remove old checks we don't need. + Add to EXTRA_CFLAGS not KCFLAGS + + * module/Makefile.in: update to use Rules.make and + kernel rules. + + * module/op_init.c: make this one include kernel modversion + stuff for 2.2 + + * module/oprofile.h: remove __cacheline_aligned in wrong place + + * module/x86/Makefile.in: use Rules.make (hacky) + + * module/x86/arch.mak: remove + + * module/x86/op_fixmap.c: add missing header + + * module/x86/op_syscalls.c: my_sys_exit is not static + +2002-06-09 Philippe Elie + + * libutil++/cverb.h: + * libutil++/cverb.cpp: cverb ostream initializations + * pp/op_merge.cpp: + * pp/op_time_options.cpp: + * pp/op_to_source_options.cpp: + * pp/oprofpp_options.cpp: use it + + * utils/Makefile.in: fix a typo in lib dependencies + +2002-06-07 Philippe Elie + + * TODO: update + + * pp/samples_container.cpp: + * pp/samples_container.h: add an hint parameter to add() + used to avoid recording all samples. + * pp/oprofpp.cpp: use it for the -s option. This change + slightly behavior of oprofpp -s, now percent are relative + to the selected symbol, not to the whole samples file. + Performance of oprofpp -s are improved a lot (40 times on vmlinux) + + * utils/Makefile.in: missing libs dependencies + +2002-06-07 Philippe Elie + + * pp/Makefile.in: + * dae/Makefile.in: + * gui/Makefile.in: update dependencies for library + +2002-06-07 Philippe Elie + + * libopt++/popt_options.cpp: + * libopt++/popt_options.h: memory leak fix + +2002-06-07 Philippe Elie + + * libutil++/Makefile.in: fix bfd compilation problem + with gcc >= 3.0 and old bfd.h + * module/Makefile.in: + * module/x86/Makefile.in: fix -Werror typo + * pp/op_merge.cpp: + * pp/op_time_options.cpp: + * pp/op_to_source_options.cpp: + * pp/oprofpp_options.cpp: work around for cverb + initialisations and gcc 2.91. + * pp/op_to_source.cpp: use the right comand line argument. + +2002-06-07 John Levon + + * TODO: update + + * libutil++/utility.h: fix stupid bug, add scoped_array + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: use it + +2002-06-07 John Levon + + * libutil++/utility.h: add a scoped_ptr + + * pp/op_to_source.cpp: + * pp/samples_container.h: + * pp/samples_container.cpp: use it + +2002-06-07 John Levon + + * dae/opd_kernel.c: remove some duplicate code + +2002-06-07 John Levon + + * pp/opp_symbol.cpp: kill last of the accursed char + arrays + +2002-06-07 John Levon + + * libutil++/op_bfd.cpp: + * libutil++/op_bfd.h: + * libutil++/verbose_ostream.h: + * pp/op_merge.cpp: + * pp/op_time_options.cpp: + * pp/oprofpp_options.cpp: + * pp/op_to_source_options.cpp: remove verbose_ostream + in favour of a much simpler solution + + * module/oprofile.h: remove dead prototype + +2002-06-06 John Levon + + * module/x86/Makefile.in: + * module/Makefile.in: remove 2.91 check, add 2.5 check + + * module/compat22.h: + * module/compat24.h: + * module/apic_up_compat.h: move to ... + + * module/x86/op_apic.h: + * module/x86/apic_compat.h: ... here + + * module/compat.h: move arch stuff to ... + + * module/x86/arch_compat.h: ... here + +2002-06-06 Philippe Elie + + * configure.in: remove gcc 2.91 check + * make.common.in: use -Werror even for gcc 2.91 + * gui/oprof_start.cpp: + * libutil++/op_bfd.cpp: + * pp/derive_files.cpp: + * pp/op_to_source.cpp: small tweak for gcc 2.91 and -Werror + +2002-06-06 John Levon + + * module/op_rtc.c: use check_range + +2002-06-06 John Levon + + * configure.in: fix typo so non-2.91 is detected + + * module/Makefile.in: + * module/x86/Makefile.in: enable -Werror + + * module/op_dname.c: + * module/oprofile.h: + * module/oprofile.c: + * module/op_util.h: + * module/op_util.c: + * module/x86/op_nmi.c: add op_util.h, make + op_check_range a function check_range + +2002-06-06 John Levon + + * module/Makefile.in: use @CC@, add clean for x86 + + * module/compat24.h: add path_hash prototype + + * module/x86/Makefile.in: use @CC@, make sure + options get picked up + +2002-06-06 John Levon + + * libutil/op_get_time.c: return "" not NULL + on failure, so we don't try to printf NULL + + * module/op_dname.c: do_path_hash_2_4 should not be static now + + * module/oprofile.c: add const + +2002-06-06 Philippe Elie + + * module/x86: new directory, for now some small portion + of x86 dependant code remains in module/* mainly in + oprofile.[ch]. This patch also don't take care about + libop/* which are architecture dependant + + * module/op_apic.c: + * module/op_nmi.c: + * module/op_syscalls.c: + * module/oprofile_nmi.S: + * module/op_fixmap.c: move this file to ... + * module/x86/op_apic.c: + * module/x86/op_nmi.c: + * module/x86/op_syscalls.c: + * module/x86/oprofile_nmi.S: + * module/x86/op_fixmap.c: these new files + * module/x86/op_apic.c: x86 stuff + * module/x86/arch.mak: specific arch makefile fragment + * module/op_init.c: move cpu detection code ... + * module/x86/cpu_type.c: here + * module/Makefile: handle arch sub-dir + * module/x86/.cvsignore: new + * module/oprofile.h: declare the interface to the + architecture dependant code + + * Makefile.in: + * configure.in: handle module/arch + * make.common.in: avoid -Werror with gcc 2.91 + * make.deps: small tweak allowing to use it in module + +2002-06-06 John Levon + + * configure.in: use CXXINCLUDES not CXXFLAGS + for including sstream + + * make.common.in: remove duplicate -g -O2 + + * include/sstream: fix compiler warning to + allow -Werror + + * libutil/op_file.c: + * libutil/op_fileio.h: + * libutil/op_fileio.c: more API fixage + + * libutil++/file_manip.cpp: add missing header + +2002-06-06 John Levon + + * make.common.in: enable -Werror for CVS builds + (not in module/) + + * dae/opd_image.c: + * dae/oprofiled.c: + * libutil/op_deviceio.h: + * libutil/op_deviceio.c: API fixes + + * libutil++/file_manip.h: + * libutil++/file_manip.cpp: + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: + * pp/op_time.cpp: + * pp/oprofpp.cpp: + * libutil/op_lockfile.c: + * libutil/op_file.h: + * libutil/op_file.c: add op_file_readable(), + API fixes + +2002-06-06 John Levon + + * utils/op_stop: fail early if ! root + +2002-06-05 John Levon + + * pp/*: s/OutputSymbol/output_symbol/, + s/OutSymbFlag/outsymbflag/ + +2002-06-05 John Levon + + * pp/op_time_options.cpp: + * pp/op_time_options.h: + * pp/op_to_source_options.h: + * pp/oprofpp_options.h: document + +2002-06-05 John Levon + + * pp/Makefile.in: + * pp/counter_util.h: + * pp/counter_util.cpp: move from ... + + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: ... here (removed) + + * pp/op_time.cpp: + * pp/op_time_options.cpp: + * pp/op_to_source.cpp: + * pp/opp_symbol.h: + * pp/oprofpp.cpp: + * pp/oprofpp_options.h: + * pp/oprofpp_options.cpp: + * pp/samples_container.h: + * pp/samples_container.cpp: + * pp/samples_file.h: + * pp/samples_file.cpp: changes from above + +2002-06-05 John Levon + + * libutil++/file_manip.h: + * libutil++/file_manip.cpp: move oprofile specific stuff + to ... + + * libop++/op_mangling.h: + * libop++/op_mangling.cpp: ... here + + * pp/Makefile.in: + * pp/op_bfd.h: + * pp/op_bfd.cpp: move to ... + + * libutil++/Makefile.in: + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: ... here + + * libutil++/verbose_ostream.h: add + + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/op_time_options.h: + * pp/op_time_options.cpp: + * pp/op_to_source.cpp: + * pp/op_to_source_options.h: + * pp/op_to_source_options.cpp: + * pp/oprofpp.h: + * pp/oprofpp.cpp: + * pp/oprofpp_options.h: + * pp/oprofpp_options.cpp: + * pp/oprofpp_util.cpp: + * pp/samples_file.h: various changes and + cleanups from above + + * pp/derive_files.cpp: remove now duplicate code + +2002-06-05 John Levon + + * libutil++/file_manip.h: + * libutil++/file_manip.cpp: simplify but don't + break already absolute paths, remove dead code + + * pp/op_time_options.h: + * pp/op_time_options.cpp: + * pp/op_time.cpp: remove dead code + + * pp/op_to_source_options.h: + * pp/op_to_source_options.cpp: + * pp/oprofpp_options.h: + * pp/oprofpp_options.cpp: variable name tweaks + + * pp/Makefile.in: + * pp/op_to_source.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: + * pp/derive_files.h: + * pp/derive_files.cpp: factor command-line file + derivation guessing out + +2002-06-04 John Levon + + * libop++/op_print_event.cpp: + * pp/op_bfd.h: + * pp/op_time_options.cpp: + * pp/op_to_source_options.cpp: + * pp/oprofpp_options.cpp: fixes for std + + * pp/Makefile.in: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: + * pp/samples_file.cpp: + * pp/opp_symbol.h: + * pp/counter_array.h: + * pp/counter_array.cpp: factor out counter_array + +2002-06-04 John Levon + + * pp/oprofpp.h: + * pp/samples_file.cpp: + * pp/oprofpp_util.cpp: remove a sanity check + that wasn't particularly useful + +2002-06-04 John Levon + + * libop++/Makefile.in: + * libop++/op_mangling.h: + * libop++/op_mangling.cpp: + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: move mangle/unmangle to libop++ + +2002-06-04 John Levon + + * pp/Makefile.in: + * pp/op_to_source.cpp: + * pp/opp_symbol.cpp: + * pp/demangle_symbol.h: + * pp/demangle_symbol.cpp: move this ... + + * libutil++/Makefile.in: + * libutil++/demangle_symbol.h: + * libutil++/demangle_symbol.cpp: ... to here + +2002-06-04 John Levon + + * make.common.in: + * make.deps: split out CXXINCLUDES + + * Makefile.in: + * configure.in: + * libop++/Makefile.in: + * libop++/op_print_event.h: + * libop++/op_print_event.cpp: + * pp/Makefile.in: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: + * pp/samples_file.cpp: start libop++ library, + move op_print_event there + + * pp/op_bfd.h: + * pp/op_bfd.cpp: + * pp/op_time.cpp: + * pp/op_to_source.cpp: + * pp/oprofpp.cpp: + * pp/samples_file.h: + * pp/samples_file.cpp: remove all knowledge of + is_kernel from op_bfd, some minor cleanups + +2002-06-04 John Levon + + * pp/op_bfd.h: + * pp/op_bfd.cpp: + * pp/samples_container.cpp: kill another char* + + * pp/outsymbflag.h: reduce fake dependencies with + new file, little cleanup + + * pp/Makefile.in: + * pp/demangle_symbol.cpp: + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/op_time_options.h: + * pp/op_time_options.cpp: + * pp/op_to_source.cpp: + * pp/op_to_source_options.h: + * pp/op_to_source_options.cpp: + * pp/opp_symbol.h: + * pp/oprofpp.h: + * pp/oprofpp.cpp: + * pp/oprofpp_options.h: + * pp/oprofpp_options.cpp: + * pp/oprofpp_util.cpp: Some more refactoring. More work + needed... + +2002-06-01 John Levon + + * doc/Makefile.in: fix DOCDIR (from Al Stone) + +2002-06-01 John Levon + + * libutil++/file_manip.h: + * libutil++/file_manip.cpp: clarify API + + * pp/oprofpp.cpp: fix bug 563324 resulting from above + +2002-06-01 John Levon + + * make.common.in: make --with-extra-lib work again + + * dae/opd_image.h: + * dae/opd_image.c: comment typos + + * doc/srcdoc/Doxyfile: generate PNG not GIF + +2002-05-23 Philippe Elie + + * doc/srcdoc/Doxyfile: + * libopt++/popt_options.cpp: + * libopt++/popt_options.h: + * pp/symbol_container_impl.h: small doxygen tweak. + +2002-05-23 Philippe Elie + + * dae/oprofiled.c: minor bug when backing up samples dir + + * libopt++/popt_options.h: + * libopt++/popt_options.cpp: avoid to force client code to + explicitly select the option template specializations. + + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/op_to_source.pp: + * pp/oprofpp.cpp: we no longer need explicit template + instantiations for options + +2002-05-22 Philippe Elie + + * pp/oprofpp.cpp: fix a missing SAMPLES_DIR prepend + +2002-05-22 John Levon + + * lib/util/op_file.c: + * utils/op_session.c: restore accidentally lost + commits : + + 2002-05-05 Philippe Elie + + * dae/op_session.c: tweak error message when session already + exist. Avoid to op_dump when profiler is not started. + + 2002-05-05 Philippe Elie + + * dae/op_session.c: do not create empty session directory + and backup oprofileg.log too + * dae/opd_util.c: + * op_user.h: minor related change + +2002-05-22 John Levon + + * dae/*: complete re-organisation of files + + * libop/op_config.h: add VMA_OFFSET and MAX_MODULES + tunables + +2002-05-22 Philippe Elie + + * gui: + * libdb: + * libopt++: + * libutil: + * libutil++: + * oprof_report: + * pp: all C/c++ source/header file, fix a few doxygen warning, + many const type to type const + other minor comestic change. + +2002-05-22 John Levon + + * libopt++/popt_options.cpp: my usual boring shit + + * libopt++/popt_options.h: document + + * libutil/op_popt.h: POPT_TABLEEND missing in some popt.h + + * TODO: update + + * doc/oprofile.xml: add some to ack.html + + * libop/op_events_desc.c: fix long-standing typo + +2002-05-22 Philippe Elie + + * configure.in: + * Makefile.in: + * libopt++/*: new directory, command line options handling + + * make.common.in: + * pp/Makefile.in: + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/op_to_source.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: use libpopt++ + +2002-05-19 Philippe Elie + + * TODO: update + +2002-05-19 John Levon + + * pp/op_bfd.cpp: fix bug coming from mis-placed + strlen() brackets + + * pp/op_bfd.h: + * pp/op_bfd.cpp: kill some more char[]s to avoid silly + bugs like the above + + * README: some minor change + +2002-05-18 Philippe Elie + + * module/compat.h: + * module/op_fixmap.c: + * module/op_syscalls.c: + * module/oprofile.c: + * module/oprofile.h: + * module/oprofile_nmi.S: fix module up to kernel 2.5.15 + + * module/compat22.h: small fix for 2.2 + +2002-05-17 Philippe Elie + + * module/op_fixmap.c: revert my last change :/. Something is + wrong with oprofiel and 2.5.15 but elsewhere + +2002-05-17 Philippe Elie + + * module/op_fixmap.c: fix a long time outstanding bug, + we tested bit in the address of x86_capability + rather the capability itself. + +2002-05-17 Philippe Elie + + * dae/opd_proc.c: from a typo in opd_put_image_samples first + incoming samples for each image was always ignored. As + a side effect if opd_open_sample_file() fail the daemon + will die with a seg fault. This behavior is in 0.2 release. + fix #556918 + +2002-05-17 John Levon + + * utils/op_start: typo in detect stale lock file + +2002-05-17 Philippe Elie + + * pp/*: gcc 3.1 compilation. + +2002-05-16 Philippe Elie + + * dae/opd_proc.c: close samples files at cleanup + + * libdb/db-insert.cpp: if we don't lock the file when creating + the root we must ensure than initialization is atomic + + * pp/op_bfd.cpp: + * pp/op_bfd.h: + * pp/op_time.cpp: + * pp/op_to_source.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: + * pp/samples_file.cpp: + * pp/samples_file.h: move all coherency check between a op_bfd and + it's related opp_samples_files outside these class + + * pp/samples_container.cpp: small modification allowing to privatize + op_bfd::ibfd pointer. + +2002-05-16 John Levon + + * libutil/op_lockfile.c: detect and remove stale + lock files + + * utils/op_start: detect stale lock file + +2002-05-15 John Levon + + * pp/Makefile.in: + * pp/op_time.cpp: + * pp/op_to_source.cpp: + * pp/oprofpp.cpp: + * pp/samples_container.h: + * pp/samples_container.cpp: + * pp/sample_container_imp.h: + * pp/sample_container_imp.cpp: + * pp/symbol_container_imp.h: + * pp/symbol_container_imp.cpp: + * pp/symbol_functors.h: some more file-refactoring, and some + minor changes + +2002-05-15 John Levon + + * pp/oprofpp.cpp: only allow -r with -l + * doc/oprofile.1.in: document -r for oprofpp + +2002-05-15 William Cohen + + * pp/oprofpp.cpp: Added "-r" reverse sort option. + +2002-05-15 Philippe Elie + + * libutil++/utility.h: fix a copyright problem, work-around + a (probable) gcc 2.91 bug. + + * pp/op_bfd.cpp: valgrind exposed a delete problem. + + * pp/op_time.cpp: + * pp/op_to_source.cpp: + * pp/oprofpp.cpp: + * pp/samples_container.cpp: + * pp/samples_container.h: + * pp/samples_container.cpp: + * pp/samples_container.h: change the handling of shared lib, + we no longer allow samples_container_t to auto load related + samples files belonging to a shared lib but we create at a higher + level an explicit list of samples files : fix #555276 + + * pp/op_to_source.cpp: + * pp/sample_container.cpp: + * pp/opp_symbol.cpp: demangle symbol only when we output + symbol name, not when we store symbol name in internal + representation of symbol. + +2002-05-14 Cliff Woolley + + * gui/oprof_start.cpp: allow Qt3 compilation + +2002-05-13 Philippe Elie + + * doc/oprofile.xml: clarify RTC use, fix #555302 + + * gui/oprof_start_util.cpp: missing closedir(). Fix #555268 + Thanks to William Cohen for his precise report. + + * module/Makefile.in: fix #555304, a non-native compiler can + fail to compile oprofile + + * libutil++/utility.h: class noncopyable + * pp/samples_file.h: use it + +2002-05-12 Philippe Elie + + * libop/op_events_desc.c: + * libop/op_events_desc.h: + + * pp/op_bfd.h: + * pp/op_bfd.cpp: + * pp/op_to_source.cpp: + * pp/oprofpp.h: + * pp/oprofpp.cpp: + * pp/oprofpp_util.cpp: + * pp/samples_file.cpp: + * pp/samples_file.h: + * pp/samplesfile.h: fix some FIXME + +2002-05-12 John Levon + + * dae/oprofiled.c: delete lockfile on SIGTERM + + * pp/samples_file.h: + * pp/samples_file.cpp: minor changes + +2002-05-11 Philippe Elie + + * pp/op_bfd.cpp: + * pp/op_bfd.h: ehance op_bfd_symbol ... + * pp/oprofpp.cpp: + * pp/samples_container.cpp: move handling of image w/o symbol + in op_bfd + + * pp/samples_file.h: ehance comment (John's work) + +2002-05-11 Philippe Elie + + * pp/op_bfd.cpp: + * pp/op_bfd.h: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/samples_files.cpp: minor cleanup + +2002-05-10 Philippe Elie + + * pp/op_bfd.h: + * pp/op_bfd.cpp: + * pp/opp_symbol.h: + * pp/opp_symbol.cpp: + * pp/oprofpp.cpp: + * pp/samples_container.h: + * pp/samples_container.cpp: more typedef for indexed things + +2002-05-10 Philippe Elie + + * pp/*: split oprofpp_util.cpp, oprofpp.h to these .. + * pp/samples_file.cpp: new file + * pp/samples_file.h: new file + * pp/op_bfd.cpp: new file + * pp/opbfd.h: new file + + * pp/*: add a symbol_index_t typedef + +2002-05-10 Philippe Elie + + * doc/srcdoc/Makefile: always clean before building + * doc/srcdoc/Doxyfile: ehance file filtering + + * pp/oprofpp.h: small typo fix + +2002-05-10 Philippe Elie + + * pp/oprofpp.h: + * pp/oprofpp.cpp: + * pp/oprofpp_util.cpp: + * pp/samples_container.cpp: generalize infrastucture for symbol + vma/size + + * pp/op_time.cpp: allow to exclude symbol with op_time -l + +2002-05-09 John Levon + + * doc/xhtml-chunk.xsl: + * doc/xhtml-common.xsl: + * doc/xhtml.xsl: + * doc/Makefile.in: some small improvements + + * doc/src/doc/Doyxfile: add FIXME + + * gui/oprof_start.cpp: + * libop/op_events_desc.h: + * libop/op_events_desc.c: + * libutil/filename_match.h: + * oprof_report/oprofpp_view.h: + * pp/op_time.cpp: + * pp/opp_symbol.h: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: + * pp/samples_container.cpp: + * pp/samples_container.h: more doxygen etc. fixes + +2002-05-08 Philippe Elie + + * TODO: update + + * pp/op_symbol.cpp: better column handling with oprofpp -L + +2002-05-08 Philippe Elie + + * dae/Makefile.in: + * gui/Makefile.in: + * pp/Makefile.in: + * utils/Makefile.in: fix make uninstall + +2002-05-08 Philippe Elie + + * pp/opf_filter.cpp: move to ... + * pp/op_to_source.cpp: + * pp/opf_container.cpp: move to .. + * pp/samples_container.cpp: + * pp/opf_filter.h: move to ... + * pp/samples_container.h: + * pp/Makefile.in: + * pp/.cvsignore: update + + * oprof_report/hotspotview.cpp: + * oprof_report/hotspotview.h: + * oprof_report/op_view.h: + * oprof_report/oprof_report.cpp: + * oprof_report/oprof_report.h: + * oprof_report/oprof_view.cpp: + * oprof_report/oprof_view.h: + * pp/op_time.cpp: + * pp/opf_container.cpp: + * pp/opf_filter.cpp: + * pp/opf_filter.h: + * pp/opp_symbol.cpp: + * pp/opp_symbol.h: + * pp/oprofpp.cpp: + * pp/oprofpp.h: samples_files_t -> samples_container_t + + * ui/.cvsignore: update + + * pp/opf_filter.cpp: move filename_match ... + * libutil++/filename_match.cpp: here + * libutil++/filename_match.cpp: + * libutil++/Makefile.in: + + * pp/Makefile.in: fix typo that prevent op_to_source + to be recompiled + +2002-05-08 John Levon + + * TODO: update + + * doc/Makefile.in: make clean delete *.html + + * libdb/db-debug.c: pedantry + + * libutil/op_fileio.h: + * libutil/op_fileio.c: + * pp/oprofpp.cpp: remove unused code and change + function names + +2002-05-08 Philippe Elie + + * libutil/op_libiberty.h: fix compile error (missing + size_t definition) + +2002-05-08 John Levon + + * Makefile.in: missing backslash + +2002-05-07 John Levon + + * : OK I lied. Fix some doxygen warnings, + and some char const *a -> const char * a + + * doc/srcdoc/Makefile: add + +2002-05-07 John Levon + + * : ok, fix the headers properly. Last tedious + patch, I promise. + + * dae/opd_util.h: finally remove ! + +2002-05-06 John Levon + + * : move to new header style, doxygen + should use @param blah not @blah: or \param blah + + * doc/srcdoc/Doxyfile: new file for api docs + + * scripts/Doxyfile: + * scripts/dodoc: remove + +2002-05-06 John Levon + + * configure.in: don't add KINC to BKCFLAGS directly + + * module/Makefile.in: re-write + + * TODO: update + +2002-05-06 John Levon + + Massive re-organisation of code + build. Most + files have been changed. Some small cosmetic + changes. + + * libutil/: + * libutil++/: general-purpose utility libs + + * libop/: oprofile-specific utility lib + + * utils/: moved op_start et al to this dir + + * events/: + * util/: removed + + * libutil++/child_reader.cpp: make sure to set + member "pid", not local variable + +2002-05-05 Philippe Elie + + * dae/op_session.c: tweak error message when session already + exist. Avoid to op_dump when profiler is not started. + +2002-05-05 Philippe Elie + + * TODO: update: + + * dae/op_session.c: do not create empty session directory + and backup oprofileg.log too + * dae/opd_util.c: + * op_user.h: minor related change + +2002-05-05 John Levon + + * doc/oprofile.xml: update copyright for 2002 + + * doc/xsl/xhtml-chunk.xsl: indent=yes + +2002-05-05 John Levon + + * TODO: update + + * Makefile.in: update my release steps + +2002-05-05 John Levon + + * configure.in: ->0.3cvs + + * results/: hmm, remove /all/ the files + +2002-05-04 John Levon + + * configure.in: bump to 0.2 + +2002-05-04 William Cohen + + * doc/oprofile.xml: add note on power management + +2002-05-03 John Levon + + * doc/Makefile.in: + * doc/xsl/xhtml-common.xsl: + * doc/xsl/xhtml.xsl: + * doc/xsl/xhtml-chunk.xsl: use some xsl to fix + some of the problems (not all :() + +2002-05-02 John Levon + + * TODO: update + +2002-05-02 John Levon + + * dae/op_session.c: couple of improvements + + * dae/opd_util.c: fix warning + + * doc/oprofile.xml: some docs on op_session + + * pp/op_time.cpp: introduce -s parameter (should be + in all utils) + +2002-05-02 John Levon + + * oprof_report/Makefile.in: disable for release + +2002-05-02 John Levon + + * results/: nuke this in favour of oprofile-tests + module + +2002-05-02 John Levon + + * TODO: update + + * op_user.h: + * dae/op_start: + * dae/op_stop: + * dae/opd_util.h: + * dae/opd_util.c: + * dae/oprofiled.c: + * dae/oprofiled.h: + * doc/oprofile.1.in: + * doc/oprofile.xml: + * gui/oprof_start.h: + * gui/oprof_start.cpp: + * gui/oprof_start_config.h: + * gui/oprof_start_config.cpp: + * gui/ui/oprof_start_base.ui: + * oprof_report/oprof_report.cpp: + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/opf_filter.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: remove useless command line + options in anticipation of the new spec + + * libdb/db-manage.c: reset base_memory and fd + on close + + * dae/.cvsignore: + * dae/Makefile.in: + * dae/op_session.c: + * dae/opd_proc.c: + * dae/opd_proc.h: + * dae/oprofiled.h: + * dae/oprofiled.c: use lock file for daemon. + Implement named sessions + +2002-05-02 Philippe Elie + + * pp/oprofpp.cpp: + * pp/op_time.cpp: + * pp/opf_container.cpp: + * pp/opf_filter.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: fix sect_offset problem. now all + class work on vma except samples_file_t which offset vma + to samples files offset + +2002-05-01 John Levon + + * dae/opd_proc.c: + * libdb/db-manage.c: + * libdb/db-test.c: + * libdb/db.h: + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/oprofpp_util.cpp: allow read-only sample + file reading + + * oprof_report/hotspot_view.cpp: fix warning + +2002-05-01 John Levon + + * dae/op_start: + * dae/oprofiled.c: + * doc/oprofile.1.in: + * doc/oprofile.xml: + * gui/oprof_start.cpp: + * module/op_nmi.c: + * module/op_rtc.c: + * module/op_syscalls.c: + * module/oprofile.h: + * module/oprofile.c: move pid/pgrp filter into + userspace only. Remove --ignore-myself + +2002-04-30 John Levon + + * op_user.h: + * dae/opd_proc.c: + * pp/oprofpp_util.cpp: first part of removing + OPD_KERNEL_OFFSET + +2002-04-30 John Levon + + * module/op_nmi.c: also allow user to see 0/ 1/ contents + +2002-04-30 William Cohen + + * module/oprofile.c: Allow non-root examination of + /proc/sys/dev/oprofile and initiation of dump. + + * dae/op_dump: modify message for above + +2002-04-30 John Levon + + * TODO: update + + * libdb/Makefile: remove from CVS + + * dae/oprofiled.c: + * module/oprofile.c: + * module/oprofile.h: use better hash function. + Fold unused/full entry case into eviction case + for faster common path + +2002-04-27 John Levon + + * configure.in: fix little blooper that shows up + when CONFIG_M386 is chosen + +2002-04-23 Philippe Elie + + * pp/oprofpp.cpp: + * pp/oprofpp_util.cpp: yet another bug fix for --sort= + and counter nr command line specification ... + +2002-04-22 Philippe Elie + + * dae/opd_proc.c: opd_alarm() flush properly samples files + + * oprof_report/oprof_report.cpp: use the right filename + when selecting a shared lib profiled with --separate-samples + +2002-04-22 Philippe Elie + + * pp/op_merge.c: implement merging of the new file format files. + +2002-04-21 Philippe Elie + + * oprof_report/Makefile.in: + * oprof_report/oprof_report.cpp: use db + +2002-04-20 Philippe Elie + + * dae/opd_proc.c: OPD_KERNEL_OFFSET thing + * pp/oprofpp_util.cpp: + +2002-04-20 Philippe Elie + + * dae/opd_proc.c: minor warning suppression + + * pp/Makefile.in: + * pp/oprofpp.cpp: + * pp/op_time.cpp: + * pp/opf_container.cpp: + * pp/opf_filter.cpp: + * pp/oprofpp.h: handle the new db file format, this stuff is + not yet extensively tested + + * pp/op_merge.c: not already updated, exit at run time + with an error message + +2002-04-19 Philippe Elie + + * dae/opd_proc.h: + * dae/oprofiled.h: enable db samples file format + +2002-04-19 Philippe Elie + + * libdb/*: initial import from oprofile-tests module + note than this direcroty have it's own ChangeLog file + * dae/Makefile.in: use libdb.a + * dae/opd_util.h: use db.h. These change do not yet enable + the db samples files format. + +2002-04-16 John Levon + + * TODO: + * doc/oprofile.xml: + * pp/oprof_convert.c: + * util/misc.h: + * util/misc.c: + * util/file_manip.h: + * pp/Makefile.in: kill oprof_convert + +2002-04-16 John Levon + + * pp/opf_container.cpp: + * pp/oprofpp.h: + * pp/demangle_symbol.h: + * pp/demangle_symbol.cpp: + * pp/Makefile.in: move demangle_symbol into own + file + + * TODO: update some... + +2002-04-11 Philippe Elie + + * pp/opf_filter.cpp: fix a memory leak uncovered + by valgrind + +2002-04-09 Philippe Elie + + * dae/oprofiled.h: move definition of linked list to ... + * dae/opd_list.h: this new file + + * dae/opd_proc.c: iterate on opened sample file + rather on image list to sync mmap'ed file + +2002-04-07 Philippe Elie + + * pp/oprofpp.h: + * oprof_report/oprof_report.cpp: + * pp/op_time.cpp: + * pp/opf_container.cpp: + * pp/opf_filter.cpp: + * pp/oprofpp_util.cpp: + * pp/oprofpp.cpp: use samples_file_t as internal implementation + of opp_samples_files. Now all samples files read are made + through samples_file_t object. + +2002-04-04 Philippe Elie + + * dae/op_start: fix bash1 detection + + * doc/Makefile.in: fix install target + +2002-03-25 John Levon + + * configure.in: some preliminary stuff for NGPT + + * TODO: update + + * doc/Makefile.in: + * doc/oprofile.sgml: + * doc/oprofile.xml: move to DocBook/XML + + * doc/oprofile.xml: document Bash 2 dependency + + * dae/op_start: fix for /bin/bash being bash v1 - untested + +2002-04-02 Philippe Elie + + * pp/oprofpp.cpp: + * pp/oprofp_util.cpp: debug and use opp_bfd::symbol_size() + +2002-03-30 Philippe Elie + + * ChangeLog: change my email address + +2002-03-22 Philippe Elie + + * dae/op_start: default buffer size to zero and let module + override the default. + + * module/op_rtc.c: + * module/oprofile.h: + * op_user.h: + * gui/oprof_start.cpp: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: an another coherency fix, unhopefully + this bug fix does not fix the configuration file (see # ) + + * pp/oprofpp.cpp: for gprof dump do not print events settings + + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: prepare using symbol size + +2002-03-21 Philippe Elie + + * pp/opf_filter.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp_util.cpp: factorize event settings output + * pp/oprofpp.h: ditto + do_list_xxx/do_dump_gprof : static + free function rather than member function. + +2002-03-21 Philippe Elie + + * op_user.h: + * pp/oprofpp.h: more doxygen comments + + * dae/opd_kernel.c: + * dae/opd_proc.c: + * dae/opd_util.c: + * dae/oprofiled.c: + * gui/oprof_start.cpp: + * gui/oprof_start_util.cpp: exit(): use {EXIT_FAILURE|EXIT_SUCCESS} + +2002-03-20 Philippe Elie + + * pp/opf_filter.h: simplify slightly interface of samples_files_t + * oprof_report/oprof_report.cpp: + * pp/op_time.cpp: + * pp/opf_container.cpp: + * pp/opf_filter.cpp: + * pp/oprofp.cpp: reflect the new interface. + + * pp/opp_symbol.cpp: ParseOutputOption --> static member of + OutputSymbol ... + + * pp/opp_symbol.h: + * util/file_manip.h: + * util/string_manip.h: doxygen comments + +2002-03-19 Philippe Elie + + * scripts/Doxyfile: small tweak + * op_user.h: + * pp/opp_symbol.h: + * pp/oprofpp.h: + * util/child_reader.h: doxygen comments. + +2002-03-19 Philippe Elie + + * pp/opf_filter.h: + * pp/opf_container.cpp: remove delegation + {symbol|samples}_container_t -> xxx_impl, no functionnal change + + * pp/*: start a more serious doxygenization. first step + include fixing prototype and a client documentation for + opp_bfd + * script/Doxyfile: doxygen script for pp/*.h, util/*.h + +2002-03-19 John Levon + + * module/op_fixmap.c: include pagemap.h, so + we pick up highmem.h, which is needed with + some kernels (missing kmap_pagetable define + via pte_offset) + +2002-03-18 Philippe Elie + + * pp/op_time.cpp: + * doc/oprofile1.1.in: + * doc/oprofile.sgml: allow reverse sort in all case + + * pp/opp_symbol.h: + * pp/opp_symbol.cpp: remove unnecessary cast + + * oprof_report/oprof_report.cpp: + * oprof_report/oprof_report.h: + * oprof_report/*_view.*: revert partially 2002-03-17 patch, + making again data change notification in two step. + +2002-03-17 John Levon + + * pp/oprofpp_util.cpp: clarify binutils bug workaround + +2002-03-17 Philippe Elie + + * oprof_report/op_view.h: + * oprof_report/hostpost_view.cpp: + * oprof_report/hostpost_view.h: + * oprof_report/oprof_report.cpp: + * oprof_report/oprof_report.h: + * oprof_report/oprof_view.cpp: + * oprof_report/oprof_view.h: simplify virtual interface + + minor graphic bug fix + +2002-03-16 Philippe Elie + + * TODO: update + + * oprof_report/hotspot_view.cpp: new + * oprof_report/hotspot_view.h: new HotspotView class + * oprof_report/oprof_report.cpp: + * oprof_report/oprof_report.h: use HotspotView + * oprof_report/Makefile.in: reflect above + + * pp/op_time.cpp: small tidy + +2002-03-15 Philippe Elie + + * TODO: update + + * dae/oprofiled.c: fix --version when module is not loaded + + * pp/opp_symbol.cpp: + * pp/opp_symbol.h: avoid to padd the last field, use a positive + form for osf_header + + * pp/oprofpp.h: + * pp/oprofpp.cpp: + * pp/opf_filter.cpp: + * pp/opprofpp_util.cpp: + * pp/op_time.cpp: fix --sort option + +2002-03-14 Philippe Elie + + * TODO: update + + * pp/op_time.cpp: + * pp/opf_filter.cpp: + * pp/opp_symbol.cpp: + * pp/oprofpp_.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: handle -c0,1 and --sort #nr_ctr + for all post-profile tools allowing a more precise way + to specify on which counters tools must work + +2002-03-13 Philippe Elie + + * pp/oprofpp_util.cpp: get_linenr() better handling + of bfd_find_nearest_line. Fix #529622 + + * pp/opf_container.cpp: simplify symbol_container_impl + + * pp/opp_symbol.cpp: use ostringstream only when necessary + +2002-03-09 John Levon + + * doc/oprofile.sgml: some laptops have a usable local APIC + +2002-03-09 Philippe Elie + + * oprof_report: new directory, oprofpp/op_time like GUI + * oprof_report/op_view.h: base class for view + * oprof_report/oprof_report_main.cpp: + * oprof_report/oprof_report.h: + * oprof_report/oprof_report.cpp: main class + * oprof_report/oprofpp_view.h: + * oprof_report/oprofpp_view.cpp: oproffp like view + * oprof_report/Makefile.in: + * oprof_report/ui/oprof_report.base.ui: oprof_report UI + * oprof_report/ui/Makefile.in: + + * Makefile.in: + * configure.in: handle oprof_report + + * ui/Makefile.in: clarify how dependencies work + +2002-03-08 John Levon + + * configure.in: bump to 0.2cvs + + * TODO: update + +2002-03-07 Philippe Elie + + * pp/opf_container.cpp: handle osf_short_linr_info + * pp/opp_symbol.cpp: tweak output output when + linenr/filename is not available + +2002-03-07 John Levon + + * util/Makefile.in: remove -pedantic (Phil don't you + read comments ? ;) + +2002-03-07 John Levon + + * TODO: update + + * pp/: use "invalid" not "illegal" + +2002-03-06 John Levon + + * TODO: update + +2002-03-06 Philippe Elie + + * pp/opfropp_util.cpp: more specific error messages + + * doc/oprofile.sgml: clarify problem about sparse + samples files and filesystem. + + * util/file_manip.h: + * util/file_manip.cpp: create_file_list() allow recursive + file list creation. + * pp/op_time.cpp: add option -p/-P to allow specifying + alternate path name where to search for image name + * doc/oprofile.1.in: + * doc/oprofile.sgml: update option for op_time + +2002-03-05 Philippe Elie + + * pp/oprofpp_util.cpp: remove multiple symbols belonging + to the same vma (Fix #526098) + Accept also all symbol types, we filter them by name. + +2002-03-04 Philippe Elie + + * util/misc.h: minor comment fix + + * pp/oprofpp_util.cpp: tweak the last commit + +2002-03-04 John Levon + + * pp/oprofpp_util.cpp: welcome in the local symbols ... + +2002-03-03 Philippe Elie + + * pp/opf_filter.h: + * pp/opf_container.cpp: samples_files_t::add() add an hint + parameter on what information will needed. + * pp/op_time.cpp: + * pp/oprofpp.cpp: + * pp/opf_filter.cpp: use it + + * pp/op_time.cpp: when a samples files for one counter + does not exist avoid to load it (op_time -l) fix #525237 + +2002-03-02 Philippe Elie + + * pp/Makefile.in: add -pedantic to CXXFLAGS + * pp/oprofpp.h: replace macro verpbrintf with a function + * pp/oprofpp_util.cpp: implement it + * pp/opp_symbol.h: + * pp/op_time.cpp: fix pedantic warning + + * pp/opevents.cpp: + * op_user.h: op_get_cpu_nr_counters() new + + * pp/op_time.cpp: + * pp/opf_container.cpp: + * pp/opf_filter.cpp: + * pp/opf_filter.h: + * pp/opp_symbol.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp_util.cpp: remove global var op_nr_counters + +2002-03-02 Philippe Elie + + * module/op_syscalls.c: do not pre-allocate some dname + hash map entry for common pathname but pre alloc entry + zero to reserve it + + * pp/op_time.cpp: add image name to the default output format + + * module/compat22.h: move cacheline_aligned macro to ... + * module/op_cache.h: this new file + * module/compat.h: use it + * module/compat22.h: + * module/oprofile.c: replace some __cacheline_aligned by + __cacheline_aligned_in_smp + +2002-03-01 Philippe Elie + + * dae/opd_kernel.c: + * dae/opd_proc.c: simplify handling of kernel samples + + * pp/opt_time.cpp: + * pp/opp_symbol.cpp: + * pp/opp_symbol.h: + * pp/oprofpp.cpp: + * pp/oprofpp.h: tidy, gives a negative form to header output + format + + * version.h.in: new macro show_version() to output version + * doc/oprofile.sgml: document it + * dae/oprofiled.c: + * events/op_help.c: + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/opf_filter.cpp: + * pp/oprofpp.cpp: use it + +2002-03-01 John Levon + + * TODO: update + + * module/oprofile.c: + * module/op_syscalls.c: merge note/map lock + +2002-02-27 Philippe Elie + + * TODO: upadte + + * doc/oprofile.1.in: + * doc/oprofile.sgml: + * pp/opp_symbol.h: + * pp/opp_symbol.cpp: + * pp/oprofpp.cpp: use columned output for oprofpp -L, -s + + * pp/oprofpp.cpp: command-line counter specification + was broken by my last patch + * pp/opf_filter.cpp: ditto but bug comes from the far past + +2002-02-26 Philippe Elie + + * pp/op_merge.cpp: small tidy + + * pp/op_time.cpp: + * pp/opf_container.cpp: + * pp/opf_filter.h: + * pp/opf_filter.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: remove the nasty global var int ctr; + pass it as parameter to each relevant function using it. + + * module/compat.h: support for 2.5.5. 2.4.18 also tested + + * pp/opp_symbol.h: + * pp/opp_symbol.cpp: new, mainly for implementing --output-format + * pp/op_time.cpp: + * pp/oprofpp.cpp: use output format stuff + * pp/Makefile.in: reflect above change + * doc/oprofile.1.in: + * doc/oprofile.sgml: document --output-format + +2002-02-13 Philippe Elie + + * TODO: update + + * module/compat22.h: + * module/compat24.h: + * module/oprofile_nmi.S: small tidy + + * module/op_apic.c: + * module/op_fixmap.c: + * module/op_nmi.c: + * module/oprofile.h: avoid memory leak of apic mapping + +2002-02-12 Philippe Elie + + * TODO: update + + * pp/oprofpp_util.cpp: use stable sort and correct the comparison + function on symbol vma + * pp/opf_filter.cpp: remove a boring new line in output + + * module/makefile.in: optimize for 686 but do not use any specific + 686 insn. + + * configure.in: check against CONFIG_PREEMPT + +2002-02-10 John Levon + + * events/op_events_desc.c: remove dead code + + * module/compat.h: RedHat backported MODULE_LICENSE() + + * module/op_syscalls.c: + * module/op_util.c: remove FIXMEs + +2002-02-09 Bob Montgomery + + * module/op_rtc.c: right actual RTC value back + + * doc/oprofile.sgml: document that + +2002-02-09 John Levon + + * module/op_init.c: set rtc cpu type directly + +2002-02-08 Philippe Elie + + * TODO: update + + * module/oprofile_nmi.S: cut and copy from oprofile_nmi24.s + * module/oprofile_nmi22.S: remove + * module/oprofile_nmi22.S: remove + * module/Makefile.in: reflect them + + * pp/opf_filter.cpp: do not print unit mask for RTC cpu type + + * doc/oprofile.sgml: document post-profile tools commons options + +2002-02-05 Philippe Elie + + * TODO: update mainly by moving things to 0.1 + + * pp/opf_filter.h: + * pp/opf_container.cpp: small cleanup + minor tweak to get + more reliable sort order on filename. + +2002-02-05 Philippe Elie + + * pp/opf_filter.h: declare create_artificial_symbol() + * pp/oprofpp_util.cpp: show how elf symbols size could + be handled. + + * pp/oprofpp_util.cpp: add BSF_GLOBAL symbols to + symbols of interest. + +2002-02-04 John Levon + + * module/oprofile.c: add [un]lock_sysctl + +2002-02-04 John Levon + + * dae/oprofiled.h: + * dae/oprofiled.c: + * dae/opd_proc.c: free stuff on shutdown (to + clean dmalloc reports) + +2002-02-03 John Levon + + * configure.in: bump to 0.1 + + * TODO: update + +2002-02-02 John Levon + + * configure.in: bump to 0.0.9 + +2002-02-02 John Levon + + * module/op_nmi.c: fix stupid bug spotted by Bob + Montgomery + +2002-02-01 Philippe Elie + + * module/compat.h: define REMAP_PAGE_RANGE + * module/op_syscalls.c: use it (2.5.3 support) + +2002-01-30 Philippe Elie + + * module/compat.h: + * module/op_nmi.c: re-add explicit constant for all MSR_ + constants. + +2002-01-30 Philippe Elie + + * configure.in: + * doc/oprofile.sgml: + * module/compat22.h: remove support for kernel version + prior to 2.2.11 + + * module/op_fixmap.c: + * module/compat.h: small cleanup + + * module/oprofile.c: avoid multi-line literal string + + * pp/oprofpp_util.cpp: better to get_symbols() ;) + +2002-01-29 John Levon + + * module/op_fixmap.c: remap fake mapping on 2.2 as well + when necessary + +2002-01-27 Philippe Elie + + * module/Makefile.in: sorry, -Werror is only usefull + for test. + + * doc/oprofile.1.in: a few words about op_stop + + * module/compat.h: + * module/compat22.h: + * module/compat24.h: change pte_page_address definition + for 2.2.20 + + * pp/opf_container.cpp: no warning when creating artificial symbols + * pp/oprofpp_tuil.cpp: no warning for image without symbols + +2002-01-27 John Levon + + * gui/oprof_start.cpp: + * pp/op_merge.cpp: + * pp/op_time.cpp: + * pp/opf_container.cpp: std namespace fixes. + +2002-01-27 John Levon + + * pp/op_time.cpp: small hacky output cleanup + +2002-01-27 Philippe Elie + + * TODO: update + + * dae/opd_proc.c: small cleanup + + * doc/opf_container.cpp: handle image without symbols + + * doc/oprofile.1.in: + * doc/oprofile.sgml: + * doc/op_time.cpp: implement and document --demangle + and --show-image-name + + * pp/oprofpp_util.cpp: add using elf symbols size but + disable it + +2002-01-26 John Levon + + * TODO: update + + * dae/opd_proc.c: tiny clean + + * doc/oprofile.sgml: spell fix + +2002-01-26 Philippe Elie + + * TODO: update + + * pp/op_merge.c: remove FIXME + * pp/op_time.cpp: minor fix + + * pp/opf_filter.h: + * pp/opf_filter.cpp: + * pp/oprofpp.cpp: + * pp/opf_container.cpp: Show more clearly than + samples_files_t support adding any number of samples + files to the underlined container. + +2002-01-26 Philippe Elie + + * pp/oprofpp_util.cpp: allow to load image without symbols + + * pp/Makefile.in: + * pp/op_time: implement -l option that show symbols details. + Currently with separate-samples files symbols are showed + more than one time. This is a bug rather a feature. + * doc/oprofile.1.in: + * doc/oprofile.sgml: document op_time -l + + * dae/opd_proc.c: bug fix from last change + +2002-01-25 John Levon + + * TODO: + * dae/opd_proc.c: search maps in reverse order so we prefer + newer mappings. + +2002-01-25 Philippe Elie + + * pp/op_merge.cpp: minor fix + comment + * pp/op_time.cpp: comment, use samples_file_t + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: minor change + +2002-01-24 John Levon + + * dae/opd_proc.c: remove stale comment + + * TODO: update + + * module/compat.h: + * module/compat22.h: + * module/compat24.h: fix for pte_page on 2.2.20+ + +2002-01-24 Philippe Elie + + * op_merge.cpp: + * oprofpp.h: + * oprofpp_util.cpp: code move + cleanup + +2002-01-23 Philippe Elie + + * util/shared_ptr.h: a templatized shared pointer. + + * pp/op_merge.c: new to merge samples files + * pp/Makefile.in: + * pp/opf_filter.cpp: + * pp/opf_filter.h: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: minor change to add op_merge support + + * doc/Makefile.in: + * doc/oprofile.1.in: + * doc/oprofle.smgl: document op_merge + +2002-01-22 John Levon + + * module/Makefile.in: can only depmod if we run that kernel + + * module/op_fixmap.c: deal with no APIC config for + 2.4.10+ + +2002-01-22 John Levon + + * module/Makefile.in: + * module/oprofile.h: + * module/oprofile.c: + * module/op_x86.c: + * module/op_apic.c: + * module/op_fixmap.c: split op_x86.c. Various changes to + only enable the APIC if it's not, and to remap / map the APIC + as is necessary. + + * module/apic_up_compat.h: + * module/compat.h: + * module/compat22.h: clean up V_*() macros + + * module/op_init.c: remove FORCE_RTC + +2002-01-22 Philippe Elie + + * TODO: update + + * dae/opd_proc.c: use remove not unlink + * gui/oprof_start.cpp: use remove not system("rm xxx") + + * doc/Makefile.in: slightly improvment + * doc/oprofile.1.in: move --help --version to a common section + +2002-01-21 John Levon + + * module/compat22.h: fix missing cli() + +2002-01-21 John Levon + + * module/oprofile.c: + * module/compat22.h: + * module/compat24.h: fix NMI wake-up for 2.2 SMP + + * module/op_dcache.h: add KERN_ERR + + * module/op_x86.c: cleanup a little + +2002-01-21 Philippe Elie + + * TODO: update + + * doc/oprofile.1.in: + * doc/oprofile.sgml: minor change + + * module/Makefile.in: auto-dependencies for compat.c + + * module/compat.c: + * module/compat22.h: FIXME remove for vmalloc_32 + +2002-01-20 Philippe Elie + + * gui/oprof_start.cpp: fix configuration saving when + switching of cpu_type. + + * module/Makefile.in: + * module/compat.c: minor change + + * compat.h: add minor macro + * oprofile.c: use minor instead MINOR (2.5.2 support) + + * op_x86.c: check SPIV (missing from a previous patch) + +2002-01-20 John Levon + + * TODO: punt some things to next release + + * dae/opd_proc.c: fix printf of null + +2002-01-20 John Levon + + * TODO: update + + * module/oprofile.c: add comment + + * module/compat22.h: + * module/compat24.h: + * module/op_syscalls.c: fix locking for out_mmap + +2002-01-20 Philippe Elie + + * module/op_x86.c: check MSR + SPIV for enabling APIC + + * module/compat.c: don't attempt to get root + + * module/compat.h: NEED_FIXMAP fixes + +2002-01-18 Philippe Elie + + * TODO: update + + * module/compat.h: + * module/compat24.h: move things needed for 2.2/2.4 in compat.h + +2002-01-18 John Levon + + * module/compat22.h: never wake up from NMI + on 2.2 SMP for now :( + +2002-01-18 John Levon + + * module/compat.h: + * module/compat22.h: + * module/compat24.h: s/VATLEAST/V_AT_LEAST/ + + * module/oprofile.c: remove dead code + +2002-01-17 John Levon + + * module/compat.c: don't need to re-take BKL for + d_path on 2.2 + +2002-01-17 John Levon + + * module/compat22.h: + * module/compat24.h: + * module/op_syscalls.c: we mustn't take the mmap sem + under 2.2 + +2002-01-17 John Levon + + * module/compat22.h: + * module/compat24.h: + * module/op_syscalls.c: whoops, handy to lock the + BKL when it is necessary. + + * dae/oprofiled.c: fix warning + +2002-01-17 John Levon + + * op_user.h: + * dae/op_start: + * gui/oprof_start_config.h: + * module/oprofile.h: bump note size and watermark, + I was getting problems on my dual SMP box in kernel compiles + +2002-01-17 John Levon + + * module/Makefile.in: + * module/oprofile_nmi.S: + * module/oprofile_nmi22.S: + * module/oprofile_nmi24.S: split assembly for 2.2/4 + + * module/compat.h: + * module/compat22.h: + * module/compat24.h: s/AFTER/ATLEAST/ + +2002-01-17 John Levon + + * module/compat24.h: define to have ->owner + +2002-01-17 Philippe Elie + + * gui/oprof_start.h: + * gui/oprof_start_config.h: + * gui/oprof_start.cpp: validate the RTC max count + +2002-01-17 John Levon + + * TODO: update + + * oprofile.c: + * module/compat24.h: + * module/compat22.h: fix compile, nmi wake up check + + * module/op_rtc.c: user/kernel profiling feature + +2002-01-17 John Levon + + * doc/oprofile.sgml: clarification + + * module/compat22.h: + * module/compat24.h: + * module/oprofile.c: ->owner fixes + +2002-01-17 John Levon + + * module/oprofile.h: clean up + + * module/compat.h: + * module/compat22.h: + * module/compat24.h: split header files up + for readability + +2002-01-17 Philippe Elie + + * TODO: update + + * doc/oprofile.sgml: speach about assembler + + * module/compat.h: small tweak for 2.2, no impact on 2.4 + +2002-01-16 John Levon + + * configure.in: look for rtc_lock + + * module/compat.h: use rtc_lock if there + +2002-01-16 Philippe Elie + + * module/compat.h: + * module/apic_up_compat.h: cleanup + allow compile + !CONFIG_X86_LOCAL_APIC on 2.4/2.5. (only compile + tested) + +2002-01-15 Philippe Elie + + * events/op_events.c: avoid gui crash: event name must + contain only one word. If you test RTC patch destroy + ~/.oprofile/oprof_start_event#0 + +2002-01-15 John Levon + + * module/compat.h: + * module/compat.c: + * module/op_rtc.c: 2.2 modversions fix + +2002-01-15 John Levon + + * TODO: update + + * module/compat.h: + * module/compat.c: + * module/op_rtc.c: fix 2.2 compile + +2002-01-15 John Levon + + * module/Makefile.in: whoops, forgot to commit this + +2002-01-15 John Levon + + * gui/oprof_start.cpp: some improvements for RTC + +2002-01-15 John Levon + + * dae/op_stop: fix "op_start && op_stop" bug using multiple + dump_stop writes. + +2002-01-14 Dave Jones + + * pp/op_time.cpp: fix for printing (NaN%) in the zero sample case. + +2002-01-14 John Levon + + * module/op_rtc.c: remove unneeded check + +2002-01-14 John Levon + + * dae/op_start: fix for PMC case + +2002-01-14 John Levon + + * TODO: update + + * dae/op_start: take --rtc-value + + * dae/oprofiled.c: set headers sensibly for RTC + + * doc/oprofile.1.in: update + + * doc/oprofile.sgml: RTC update + + * events/op_events_descr.c: + * events/op_events.c: good name for RTC event + + * gui/oprof_start.cpp: basic support for RTC + + * module/op_rtc.c: implement and use rtc_value + +2002-01-14 John Levon + + * TODO: update + + * dae/op_start: load module at start. Handle CPU_RTC. + Avoid sysctl for now on RTC case. + + * dae/oprofiled.c: only read sysctls if PMC. Needs clean. + + * events/op_events.c: add RTC event. + + * events/op_events_desc.c: get CPU type from module. + + * module/op_init.c: detect CPU_RTC. + + * module/op_nmi.c: setup code moved from op_init.c + + * module/op_rtc.c: enable interrupt, fixed at 128 for now. + + * module/op_x86.c: add Athlon to needs_apic_setup checks + + * module/oprofile.c: use correct interrupt handler based on + CPU type + +2002-01-14 John Levon + + * TODO: update + + * op_user.h: add CPU_RTC + + * op_init.c: add FIXMEs + + * op_nmi.c: + * op_rtc.c: + * oprofile.h: + * oprofile.c: implement abstract interrupt handler code + +2002-01-14 John Levon + + * gui/oprof_start_config.cpp: fix vmlinux/system.map defaults + +2002-01-13 Philippe Elie + + * configure.in: reject unsupported kernel version + * module/apic_up_compat.h: + * module/compat.h: small cleanup + * module/op_x86.c: ditto, always put apic memory page as + non cachable + +2002-01-12 John Levon + + * gui/oprof_start_util.h: + * gui/oprof_start_util.cpp: implement whitelist for arguments + to op_start + + * TODO: update + +2002-01-13 Philippe Elie + + * module/compat.h: + * module/apic_up_compat.h: + * module/op_x86.c: allow to run oprofile when + !CONFIG_X86_LOCAL_APIC on 2.2.x kernel + +2002-01-12 Philippe Elie + + * module/compat.h: fix some FIXME + * module/op_x86.c: do not hang SMP kernel UP box with 2.2.x + +2002-01-11 Philippe Elie + + * module/compat.h: support for UP from 2.2.0, for SMP + from 2.2.8. It is worthwhile to try more support. + !CONFIG_X86_LOCAL_APIC not yet supported. + +2002-01-11 John Levon + + * TODO: update + + * dae/opd_proc.c: + * doc/oprofile.sgml: + * pp/op_time.cpp: add FIXMEs + +2002-01-11 John Levon + + * module/oprofile.c: never return 0 unless we're + really closing down + +2002-01-11 John Levon + + * TODO: update + + * gui/Makefile.in: + * gui/oprof_start.cpp: use absolute paths + +2002-01-11 John Levon + + * doc/oprofile.sgml: add note about --with-linux + +2002-01-11 John Levon + + * Rules.make.in: + * gui/Makefile.in: + * gui/oprof_start_config.h: + * gui/oprof_start_config.cpp: remove kernel headers + from userland ! + +2002-01-11 John Levon + + * configure.in: remove dead checks. comment out APIC check, + hide grep output + + * module/Makefile.in: add compat.c + + * apic_up_compat.h: UP 2.2 missing defines. Need to investigate + fixmap situation. + + * compat.c: move 2.2 dcache code here + + * compat.h: dcache compat support. check for whether we + should check for mptable. Don't do fixmap hack on 2.2 + + * op_dcache.h: shared dcache inline functions + + * op_syscalls.c: clean up dcache code for 2.2/2.4 + + * op_x86.c: update apic_need_setup for 2.2 and the possibility + of not enabling APIC support on 2.4 too. Needs checking ! Also + don't do mptable check on 2.2 + + * oprofile.h: add missing include guard ;) + +2002-01-11 John Levon + + * module/compat.h: minor fixes + +2002-01-11 Philippe Elie + + * module/compat.h: many change, can be used down to 2.2.8 + * module/oprofile.h: move #ifdef on kernel version to compat.h + * module/op_util.c: + * module/op_syscalls.c: minor change + * configure.in: comment unnecessary stuf. + + * module/Makefile.in: missing include path for oprofile.s + +2002-01-10 John Levon + + * Makefile.in: update checklist for dist + + * module/oprofile.h: add apparently needed version.h + +2002-01-10 John Levon + + * configure.in: fix accidental trashing of BKCFLAGS + + * module/op_util.c: include right header + + * module/compat.h: use correct smp_call_function + +2002-01-10 Philippe Elie + + * module/compat.h: new file include backward compatibility + stuff + +2002-01-09 John Levon + + * doc/oprofile.sgml: update infodragon's email + address + + * configure.in: bump to 0.0.9cvs + +2002-01-08 John Levon + + * TODO: update + + * configure.in: fix case when X isn't installed. Bump to 0.0.8 + +2002-01-07 John Levon + + * util/Makefile.in: "fix" last g++ 3.0 problem + with libiberty.h and string.h clashing prototypes + by disabling -pedantic for this directory + +2002-01-07 John Levon + + * pp/opf_container.cpp: + * pp/opf_filter.h: + * pp/oprofpp.cpp: + * pp/oprofpp.h: + * pp/oprofpp_util.cpp: + * util/file_manip.h: + * util/file_manip.cpp: + * util/string_manip.h: fix most g++ 3.0 problems + +2002-01-07 John Levon + + * TODO: update + +2002-01-05 Philippe Elie + + * doc/oprofile.sgml: Avoid to use -- inside + sgml comment + +2002-01-05 John Levon + + * dae/op_start: + * dae/op_stop: (very) hacky loop to wait for + daemon start and stop + +2002-01-05 John Levon + + * module/oprofile.c: revert my broken stop fix, + and fix the old (new) one + +2002-01-05 John Levon + + * dae/opd_kernel.c: + * dae/opd_proc.c: + * dae/opd_proc.h: + * dae/opd_util.c: + * dae/oprofiled.c: + * dae/oprofiled.h: further minor cleanups + +2002-01-04 John Levon + + * module/oprofile.c: change last change to have an + explicit check in the sysctl dump, rather than generalised + code. + +2002-01-04 Philippe Elie + + * module/oprofile.c: do not re-enable counter during + shutdown + + * dae/Makefile.in: fix opd_kernel.c dependancy + +2002-01-04 John Levon + + * dae/Makefile.in: + * dae/opd_proc.c: + * dae/opd_kernel.c: move kernel/module stuff into + new file. Some minor changes. + +2002-01-04 John Levon + + * dae/oprofiled.c: remove extra dump + +2002-01-04 John Levon + + * dae/opd_proc.c: minor crap + +2002-01-04 John Levon + + * TODO: update + + * dae/oprofiled.c: + * dae/oprofiled.h: + * dae/opd_proc.c: print stats on shutdown too + + * module/oprofile.c: additional check against daemon hanging on shutdown :( + +2002-01-04 John Levon + + * dae/op_stop: + * dae/oprofiled.c: + * doc/oprofile.sgml: + * module/oprofile.h: + * module/oprofile.c: implement new clean shutdown via + sysctl dump_stop + +2002-01-04 Philippe Elie + + * module/oprofile.c: add a warning when note buff overflow. + +2002-01-04 John Levon + + * module/oprofile.c: pin note at the end on overflow + +2002-01-03 Philippe Elie + + * dae/opd_proc.c: Apologies: stupid bug. Never forget + than LRU list of samples files must not contain already + unmaped files + + * module/oprofile.c: another silly bug, detected cpu was + overwritten... + +2002-01-03 John Levon + + * doc/oprofile.sgml: some fixes, comments + +2002-01-03 Philippe Elie + + * doc/oprofile.sgml: improve documentation, corrected + by John Levon + +2002-01-03 John Levon + + * gui/oprof_start.h: + * gui/oprof_start.cpp: + * gui/ui/oprof_start.base.ui: remove the config buttons + and save on a hide from the WM + +2002-01-03 John Levon + + * module/oprofile.c: make sure note_pos never goes + past the buffer :P + +2002-01-03 John Levon + + * dae/opd_util.c: allow EAGAINs through as well + +2002-01-02 Philippe Elie + + * pp/opf_container.cpp: + * pp/opf_filter.cpp: minor change + +2002-01-02 John Levon + + * doc/oprofile.sgml: various docs improvements + +2002-01-02 John Levon + + * dae/oprofiled.c: better enable the actual + profiling again :P + +2002-01-02 John Levon + + * config.h.in: remove this again from CVS. + +2002-01-02 John Levon + + * dae/op_stop: send SIGUSR1 to stop profiler + + * dae/opd_proc.c: reformat a little + + * dae/opd_util.h: + * dae/opd_util.c: change opd_read_device semantics + + * dae/oprofiled.c: clean shutdown from SIGUSR1 + + * module/oprofile.c: handle non-blocking reads + + * pp/opf_filter.h: + * pp/opf_filter.cpp: slight cleanups + + * TODO: update + +2002-01-01 John Levon + + * oprofile.sgml: clarify that -g is not necessary for + basic profiling (reported by Jeff Epler ) + +See ChangeLog-2001 for earlier changelogs. diff --git a/ChangeLog-2003 b/ChangeLog-2003 new file mode 100644 index 0000000..6356abe --- /dev/null +++ b/ChangeLog-2003 @@ -0,0 +1,6251 @@ +2003-12-29 Philippe Elie + + * configure.in: my_op_prefix is not necessarily suffixed by a '/' + +2003-12-29 John Levon + + * configure.in: + * doc/*.1.in: add HTML docs to SEE ALSO + +2003-12-29 John Levon + + * doc/opcontrol.1.in: + * doc/oprofile.xml: minor language cleanups + + * utils/opcontrol: only allow --verbose when it makes sense + +2003-12-28 Philippe Elie + + * libutil++/tests/file_manip_tests.cpp: ensure filename passed to + op_realpath() exists + +2003-12-28 John Levon + + * doc/internals.xml: + * libutil++/file_manip.h: fix typos + +2003-12-16 Philippe Elie + + * utils/opcontrol: error message rewording + +2003-12-16 Carlo Wood + + * libregex/tests/Makefile.am: avoid to install mangled-name test file + +2003-11-20 John Levon + + * libregex/op_regex.cpp: move global ctor out of namespace + anon (bug #845616) + +2003-11-19 Philippe Elie + + * libpp/arrange_profiles.cpp: merge all unit mask before generating + event description string + +2003-11-17 Philippe Elie + + * libpp/arrange_profiles.cpp: put unitmask in the same axis as + event:count, meaning than unitmask is now a part of the event + specification. + +2003-12-19 Philippe Elie + + * daemon/opd_sfile.c: we reversed to/from pc in call graph sample + +2003-11-23 Philippe Elie + + * libpp/profile.h: + * pp/opgprof.cpp: oops a simplify a bit too cg handling in my last + patch, it was segfaulting each time no cg file was found... + +2003-11-15 Philippe Elie + + * pp/opgprof.cpp: simplify a bit cg handling, we don't need to know + if we retrieved some cg files since the profile_t will be empty + in this case + +2003-11-15 Philippe Elie + + * libpp/profile.h: iterator::vma() must return the full key not only + an unsigned int. + * pp/opgprof.cpp: implement merging of cg files. + +2003-11-15 Philippe Elie + + * libpp/profile_spec.cpp: + * libpp/profile_spec.h: + * pp/opannotate_options.cpp: + * pp/opgprof_options.cpp: + * pp/opreport_options.cpp: filter call graph samples files + +2003-11-14 Philippe Elie + + * daemon/opd_mangling.c: oops, it's better to really open the cg file + + * daemon/opd_sfile.c: + * daemon/opd_stats.c: + * daemon/opd_stats.h: + * daemon/liblegacy/opd_24_stats.c: + * daemon/liblegacy/opd_24_stats.h: + * daemon/liblegacy/opd_proc.c: log sample lost due to sample file open + failure + +2003-11-15 Philippe Elie + + * daemon/liblegacy/opd_parse_proc.c: always provide an image name + for parsed process in /proc + +2003-11-15 Philippe Elie + + * doc/oprofile.xml: + * libop/op_cpu_type.c: s/hammer/AMD64 processors/ for user visible + name. + +2003-11-13 John Levon + + * libutil/op_file.h: + * libutil/op_file.c: remove op_c_dirname(), + op_relative_to_absolute_path(), op_is_directory(), + op_follow_link(), in favour of using realpath(3) + + * libutil/tests/file_tests.c: fixes for above changes + + * libutil++/file_manip.h: + * libutil++/file_manip.cpp: changes from above. Add + op_realpath(). + + * libutil++/tests/file_manip_tests.cpp: changes from + above. + + * daemon/oprofiled.c: + * daemon/liblegacy/opd_parse_proc.c: + * gui/oprof_start_util.cpp: + * libpp/locate_images.cpp: + * libpp/profile_spec.cpp: + * pp/opannotate.cpp: changes from above + +2003-11-12 John Levon + + * configure.in: bump to 0.8cvs + +2003-11-11 John Levon + + * configure.in: bump to 0.7.1 + +2003-11-11 Joseph VanAndel + + * daemon/liblegacy/init.c: fix #840046 (segfault when starting profiler + with --no-vmlinux setup), this bug was present in 0.7.0. + +2003-11-11 Philippe Elie + + * libpp/profile_spec.cpp: more precise error message + * libutil++/tests/file_manip_tests.cpp: corner case test added + for dirname + +2003-11-11 Philippe Elie + + * libpp/arrange_profiles.cpp: report_error() shows only distinct + conflicting name. + +2003-11-10 Philippe Elie + + * doc/opcontrol.1.in: reverse kernel:user in event setting description. + Fix #838968 + +2003-11-09 Philippe Elie + + * daemon/init.c: + * daemon/liblegacy/init.c: move opd_read_fs_int ... + * daemon/oprofiled.h: + * daemon/oprofiled.c: here + * daemon/liblegacy/opd_24_stats.c: dump kernel note buffer overflow and + buffer overlow + +2003-11-09 Philippe Elie + + * utils/op_help.c: do not use OP_MAX_COUNTERS but get counter number + at runtime + +2003-11-09 Philippe Elie + + * libutil++/tests/string_manip_tests.cpp: rtrim/ltrim/trim tests + +2003-11-08 Philippe Elie + + * libop/tests/Makefile.am: + * libop/tests/mangle_tests.c: new tests: sample filename mangling + +2003-11-08 Philippe Elie + + * module/x86/op_syscalls.c: fix build with 2.2 kernel + +2003-11-06 Philippe Elie + + * Makefile.am: use .PHONY for module goal to not statisfy this goal + with the subdir named module + * m4/findkernel.m4: minor fix. + +2003-11-06 John Levon + + * Makefile.am: minor cleanup + +2003-11-06 John Levon + + * gui/Makefile.am: remove unused -DKVERSION + +2003-11-06 John Levon + + * configure.in: add --disable-werror and --disable-optimization + + * doc/oprofile.xml: document above. Remove docs for + * --enable-gcov (only useful to developers) + +2003-11-06 Philippe Elie + + * daemon/opd_kernel.c: + * daemon/liblegacy/opd_kernel.c: be less paranoid about kernel range, + this is slightly different than the patch Thomas Spatzier tested but + it can't hurt (famous last words ...). This fixes s390x where kernel + start can be zero and was rejected. + +2003-11-06 Thomas Spatzier + + * daemon/opd_cookie.c: changed an #if defined for selecting right + system call for IBM s390 or s390x, respectively + +2003-11-04 Philippe Elie + + * libutil++/path_filter.cpp: remove 2 identical FIXME + * libutil++/tests/file_manip_tests.cpp: + * libutil++/tests/path_filter_tests.cpp: reflect the behavior by + new tests + +2003-11-04 Philippe Elie + + * libdb/db_manage.c: + * libop/op_events.h: -pedantic fix + +2003-11-04 Philippe Elie + + * daemon/opd_sfile.c: + * daemon/liblegacy/opd_kernel.c: + * libutil/op_cpufreq.c: + * libutil/op_file.c: a few s/goto/break/ + * libpp/format_output.cpp: padding never used after initialization + +2003-11-04 Philippe Elie + + * libutil++/comma_list.h: don't accept cumulative behavior + * libutil++/string_manip.cpp: separate_token() return by value + * gui/oprof_start.cpp: + * libopt++/popt_options.cpp: + * libpp/parse_filename.cpp: + * libpp/profile_spec.cpp: + * libutil++/comma_list.h: + * libutil++/string_filter.cpp: + * libutil++/string_manip.cpp: + * libutil++/string_manip.h: + * libutil++/tests/comma_list_tests.cpp: + * libutil++/tests/string_manip_tests.cpp: update according + * libpp/profile_spec.cpp: remove all trace of defunct op_alias + +2003-11-04 Philippe Elie + + * daemon/liblegacy/opd_image.c: + * daemon/liblegacy/opd_image.h: + * daemon/liblegacy/opd_mapping.c: + * daemon/liblegacy/opd_mapping.h: + * daemon/liblegacy/opd_proc.c: + * gui/oprof_start.cpp: + * gui/oprof_start.h: + * gui/oprof_start_config.cpp: + * gui/oprof_start_util.cpp: + * libop/op_config_24.h: + * libpp/format_output.cpp: + * libpp/op_header.cpp: + * libpp/profile.h: + * libpp/profile_container.cpp: + * libpp/profile_spec.cpp: + * libpp/profile_spec.h: + * libpp/symbol.h: + * libpp/symbol_sort.cpp: + * libutil++/stream_util.cpp: + * libutil++/stream_util.h: + * libutil++/utility.h: + * pp/common_option.cpp: + * pp/common_option.h: + * pp/opannotate_options.h: + * pp/opgprof.cpp: + * pp/opgprof_options.cpp: + * pp/opgprof_options.h: + * pp/opreport_options.cpp: + * pp/opreport_options.h: + * pp/populate.cpp: remove some .h dependencies + +2003-11-03 Philippe Elie + + * libutil++/tests/Makefile.am: + * libutil++/tests/utility_tests.cpp: new test files convering most of + utility.h and op_exception.h + +2003-11-02 Philippe Elie + + * libpp/parse_filename.cpp: avoid repetitive vector::erase(v.begin()) + * libregex/stl.pat.in: + * libregex/tests/mangled-name.in: add (i|o)stream operator(>>|<<) + +2003-11-02 Philippe Elie + + * daemon/liblegacy/opd_image.h: + * daemon/liblegacy/opd_image.c: + * daemon/liblegacy/opd_proc.c: + * daemon/liblegacy/opd_sample_files.c: sparse sample file array + allocated by line. + +2003-11-02 Philippe Elie + + * libutil++/glob_filter.h: + * libutil++/path_filter.h: + * libutil++/string_filter.h: comment fix to match implementation + * libutil++/tests/path_filter_tests.cpp: new file test + * libutil++/tests/Makefile.am: upate build + * libutil++/tests/string_filter_tests.cpp: test white space at start + of pattern + +2003-11-02 Philippe Elie + + * libutil++/string_manip.cpp: format_double can only format percent + * libutil++/string_manip.h: + * libpp/format_output.cpp: + * libutil++/tests/string_manip_tests.cpp: + * pp/opannotate.cpp: + * pp/opreport.cpp: s/format_double/format_percent/ + +2003-11-02 Philippe Elie + + * libutil++/glob_filter.h: + * libutil++/string_filter.h: + * libutil++/tests/string_filter_tests.cpp: minor tidy + + * libutil++/tests/glob_filter_tests.cpp: new file + * libutil++/tests/Makefile.am: update build + +2003-11-01 Philippe Elie + + * libpp/arrange_profiles.cpp: typo + * libutil++/generic_spec.cpp: removed file + * libutil++/Makefile.am: update according + * libutil++/generic_spec.h: ensure generic_spec will not link + * libutil++/path_filter.cpp: minor tidy + +2003-11-01 Philippe Elie + + * libutil++/tests/string_manip_tests.cpp: ehance output on failure + * module/oprofile.h: + * module/oprofile.c: two new read-only sysctl: nr_buffer_overflow and + nr_note_buffer_overflow + +2003-11-01 Philippe Elie + + * libutil++/tests/Makefile.am: + * libutil++/tests/file_manip_tests.cpp: don't use getcwd nor __FILE__ + but ${topdir} and hard coded filename + +2003-11-01 John Levon + + * daemon/liblegacy/opd_parse_proc.c: use op_follow_link + + * libutil/op_file.c: + * libutil/op_file.h: make op_get_link() static, rename + op_basename to op_c_basename + + * libutil++/file_manip.cpp: + * libutil++/file_manip.h: rename to op_basename()/op_dirname(). + Use op_follow_link() for follow_link(). + + * libutil++/tests/file_manip_tests.cpp: + * gui/oprof_start_util.cpp: + * libpp/locate_images.cpp: + * libpp/name_storage.cpp: + * libutil++/path_filter.cpp: + * pp/opannotate.cpp: + * pp/opreport.cpp: fixup from above changes + +2003-11-01 Philippe Elie + + * libutil++/op_bfd.h: has_debug_info() new member + * pp/populate.h: + * pp/populate.cpp: + * pp/opannotate.cpp: use it to error out when --assembly is not + requested and no debug information exists + +2003-10-31 Philippe Elie + + * pp/common_option.cpp: don't exit() if merge_by.lib is set through + !allow_lib + +2003-10-31 Philippe Elie + + * pp/opreport_options.cpp: move handle_merge_option() ... + * pp/common_option.h: + * pp/common_option.cpp: here + * pp/opannotate_options.cpp: use it but disallow --merge=lib + +2003-10-31 Philippe Elie + + * libutil/op_file.c: + * libutil/op_file.h: implement dirname(), is_directory() and + op_follow_link() + * daemon/oprofiled.c: follow symlink for image filter + * libutil++/file_manip.cpp: + * libutil++/file_manip.h: + * gui/oprof_start_util.cpp: + * libpp/profile_spec.cpp: rename op_follow_link() to follow_link() + +2003-10-31 Philippe Elie + + * libutil/tests/file_tests.c: "//usr" --> "//usr" + * libutil++/tests/.cvsignore: + * libutil++/tests/Makefile.am: + * libutil++/tests/file_manip_tests.cpp: new tests file. + +2003-10-31 John Levon + + * daemon/opd_perfmon.c: fix compilation + +2003-10-30 John Levon + + * libpp/profile_spec.cpp: introduce a helper function + to make the comma_list matching clear + +2003-10-30 Philippe Elie + + * libutil++/comma_list.h: is_set() new member + * libpp/profile_spec.cpp: fix matching logic for cpu/tid/tgid + +2003-10-30 John Levon + + * libutil++/generic_spec.h: add value() and + is_set(), remove bool parameter from T value + match() (it was never set to true) + + * libutil++/comma_list.h: do not accept + generic_spec, the behaviour was to implicitly + not match an "all" generic_spec. Instead: + + * libpp/profile_spec.cpp: encode the matching + behaviour explicitly, and add a comment. + + * libutil++/tests/comma_list_tests.cpp: fix to + match the above + +2003-10-30 John Levon + + * Makefile.am: re-order build subdirs + + * libabi/Makefile.am: only build abitest on + make check + + * pp/Makefile.am: pp_common not pp_commons + +2003-10-30 John Levon + + * libutil++/tests/Makefile.am: + * libutil++/tests/comma_list_tests.cpp: Add. + +2003-10-30 John Levon + + * doc/Makefile.am: improve chunk rules + +2003-10-30 John Levon + + * libutil++/tests/Makefile.am: + * libutil++/tests/string_filter_tests.cpp: Add. + + * libutil++/tests/string_manip_tests.cpp: fix header include + +2003-10-30 John Levon + + * libutil++/tests/string_manip_tests.cpp: fix tobool test + ("33" is not castable to bool) + +2003-10-30 Philippe Elie + + * libutil++/string_manip.cpp: + * libutil++/string_manip.h: remove tostr()/tobool/touint(), rename + lexical_cast_no_ws<> to op_lexical_cast<> + + * gui/oprof_start.cpp: + * gui/oprof_start_config.cpp: + * libpp/arrange_profiles.cpp: + * libpp/filename_spec.cpp: + * libpp/op_header.cpp: + * libutil++/comma_list.h: + * libutil++/generic_spec.h: + * libutil++/tests/string_manip_tests.cpp: use op_lexical_cast<> + +2003-10-29 John Levon + + * pp/common_option.h: use std namespace + +2003-10-28 Jason Lunz + + * doc/oprofile.1.in: document cpu,tid,tgid in profile + spec + +2003-10-29 Philippe Elie + + * libpp/profile_spec.cpp: error out for all tag:value specified + more than once. + +2003-10-29 Philippe Elie + + * doc/opannotate.1.in: + * doc/opreport.1.in: + * doc/oprofile.xml: + * libregex/demangle_symbol.cpp: + * libregex/demangle_symbol.h: + * pp/common_option.cpp: + * pp/common_option.h: + * pp/opannotate_options.cpp: + * pp/opannotate_options.h: + * pp/opreport_options.cpp: + * pp/opreport_options.h: remove --no-demangle, --smart-demangle and + --demangle, replace them with --demangle=none|smart|normal + +2003-10-29 Philippe Elie + + * libutil++/tests: new directory + * libutil++/tests/string_manip_tests.cpp: new tests file + * configure.in: + * libutil++/Makefile.am: + * libutil++/tests/.cvsignore: + * libutil++/tests/Makefile.am: handle new test + + * libutil++/string_manip.h: + * libutil++/string_manip.cpp: correct implementation of separate_token + to match the documentation + * daemon/liblegacy/opd_image.c: fix comment + +2003-10-28 Philippe Elie + + * libpp/count_array.cpp: + * libpp/count_array.h: + * libpp/locate_images.h: + * libpp/parse_filename.cpp: + * libpp/profile.cpp: + * libpp/profile.h: + * libpp/profile_spec.cpp: + * libpp/symbol_sort.cpp: minor tidy + +2003-10-28 Jason Lunz + + * doc/opcontrol.1.in: better wording for --separate= + * doc/oprofile.1.in: typo + +2003-10-28 Philippe Elie + + * daemon/liblegacy/init.c: + * daemon/liblegacy/opd_24_stats.c: + * daemon/liblegacy/opd_24_stats.h: + * daemon/liblegacy/opd_image.c: + * daemon/liblegacy/opd_image.h: + * daemon/liblegacy/opd_kernel.c: + * daemon/liblegacy/opd_kernel.h: + * daemon/liblegacy/opd_mapping.c: + * daemon/liblegacy/opd_mapping.h: + * daemon/liblegacy/opd_parse_proc.c: + * daemon/liblegacy/opd_parse_proc.h: + * daemon/liblegacy/opd_proc.c: + * daemon/liblegacy/opd_proc.h: + * daemon/liblegacy/opd_sample_files.c: + * daemon/liblegacy/opd_sample_files.h: move doygen comment from *.c to + *.h. Add some doxygen comment. + +2003-10-27 Philippe Elie + + * daemon/liblegacy/opd_24_stats.c: + * daemon/liblegacy/opd_image.h: + * daemon/liblegacy/opd_image.h: nr_images static + +2003-10-27 John Levon + + * doc/opcontrol.1.in: document --image= + + * doc/oprofile.xml: + * utils/opcontrol: make user specify "--image=all" + to reset. Clean up help message. Ensure note table + size is given a value. Add '-t' for '--stop', and + '-i' for '--image'. + +2003-10-27 John Levon + + * doc/oprofile.xml: document opcontrol --image= + +2003-10-27 John Levon + + * daemon/opd_events.h: + * daemon/opd_events.c: move code for handling + event descriptions here, and share find_counter_event(), + plus fill_header() + + * daemon/opd_mangling.c: + * daemon/opd_perfmon.c: + * daemon/oprofiled.c: + * daemon/oprofiled.h: + * daemon/liblegacy/opd_proc.c: + * daemon/liblegacy/opd_sample_files.c: changes from + above + +2003-10-27 John Levon + + * daemon/oprofiled.c: fix help text + + * daemon/liblegacy/init.c: + * daemon/liblegacy/opd_proc.h: + * daemon/liblegacy/opd_proc.c: clean up headers + a bit + +2003-10-27 Philippe Elie + + * gui/oprof_start.cpp: check we can get kernel interface + +2003-10-27 John Levon + + * daemon/liblegacy/Makefile.am: remove unneeded + -I for abi + +2003-10-27 John Levon + + * daemon/init.c: + * daemon/opd_perfmon.c: move timer interrupt checks + into perfmon + +2003-10-27 John Levon + + * daemon/oprofiled.c: use op_get_interface() + + * libop/op_get_interface.c: simplify + +2003-10-26 Philippe Elie + + * gui/ui/oprof_start.base.ui: + * gui/oprof_start.cpp: + * gui/oprof_start.h: check separate_lib checkbox when + separate_kernel_cb is checked + +2003-10-26 Philippe Elie + + * utils/opcontrol: allow to reset --image through empty --image= + or --image + +2003-10-26 John Levon + + * daemon/opd_cookie.c: reduce the hash table size somewhat + + * various: fixes for doxygen + +2003-10-26 John Levon + + * HACKING: + * configure.in: + * Makefile.am: + * dae/: move all of 2.4 daemon code to ... + + * daemon/liblegacy/: here + + * daemon/Makefile.am: + * daemon/opd_util.h: + * daemon/opd_util.c: move to ... + + * daemon/oprofiled.h: + * daemon/oprofiled.c: here, and call the right operations + depending upon oprofile kernel version. + + * daemon/init.c: + * daemon/liblegacy/init.c: init and running for each version + +2003-10-26 John Levon + + * daemon/opd_cookie.c: make sure to create the + cookie for the ignore value if it's not found + + * daemon/opd_sfile.c: simplify ignored logic + +2003-10-26 John Levon + + * doc/internals.xml: + * doc/buffers.png: add a diagram + +2003-10-26 Philippe Elie + + implement image filtering: + + * dae/opd_image.h: add a field filtered + * dae/opd_image.c: set it at image creation + * dae/opd_proc.c: don't record sample when !image->filtered + + * daemon/opd_cookie.h: add a field filtered + * daemon/opd_cookie.c: set it a cookie_entry creation. + * daemon/opd_sfile.h: add a field filtered + * daemon/opd_file.c: set it a opd_sfile struct creation + * daemon/opd_trans.c: record sample if filtered + + * daemon/opd_util.h: export opd_hash_name(), is_image_filtered() + * daemon/opd_util.c: implement --image=xxx + + * oprofiled.c: #include "config.h" not <> + + * utils/opcontrol: handle --image + +2003-10-26 John Levon + + * doc/oprofile.xml: remove some outdated stuff + +2003-10-25 John Levon + + * doc/internals.xml: more docs + +2003-10-25 John Levon + + * daemon/opd_perfmon.c: cleanups + +2003-10-24 John Levon + + * doc/internals.xml: write some more + +2003-10-23 John Levon + + * configure.in: bump to 0.7.1cvs + +2003-10-22 John Levon + + * libop/tests/Makefile.am: + * libop/tests/load_events_files_tests.c: + * libop/tests/alloc_counter_tests.c: fix + make distcheck + + * configure.in: bump to 0.7 + +2003-10-22 John Levon + + * daemon/Makefile.am: + * daemon/opd_perfmon.h: + * daemon/opd_perfmon.c: re-enable. Wait for children. + More safety checking. + + * daemon/oprofiled.c: only use perfmon if !timer + +2003-10-20 Philippe Elie + + * doc/oprofile.xml: + * doc/oprofile.1.in: s/physical CPU/CPU/ + +2003-10-20 John Levon + + * daemon/Makefile.am: + * daemon/opd_perfmon.h: disable perfmon nicely + + * gui/oprof_start.cpp: + * gui/oprof_start_config.h: + * gui/oprof_start_config.cpp: + * gui/ui/oprof_start.base.ui: Fix reading of separate + parameters. Add CPU and thread separation + +2003-10-20 Philippe Elie + + * libpp/profile_spec.cpp: relative path are relative to current dir + not filename. + +2003-10-20 John Levon + + * doc/oprofile.xml: + * doc/opreport.1.in: fix --merge docs and profile specs + +2003-10-20 John Levon + + * dae/opd_sample_files.c: + * daemon/opd_mangling.c: + * libabi/abi.cpp: + * libabi/abi_test.cpp: + * libabi/op_import.cpp: + * libop/op_config.h: + * libop/op_sample_file.h: + * libpp/op_header.cpp: remove ctr and separate_* from + header. Re-arrange it a little, and make it 64 bytes + on ILP32. Bump the version. + +2003-10-20 John Levon + + * libpp/arrange_profiles.cpp: rework the clashing-axes + error message to be nicer to the user + +2003-10-20 John Levon + + * libpp/arrange_profiles.cpp: if tid == tgid for + every profile class, allow axes of both TID and TGID + - there is no actual difference, only theoretical + +2003-10-20 Philippe Elie + + * dae/oprofiled.c: correct an error message + * libop/op_alloc_counter.h: remove bogus FIXME + * libutil++/child_reader.cpp: avoid quadratic behaviour if child does a + lot of output in stderr + * libpp/opgprof.cpp: fix comment + +2003-10-19 Philippe Elie + + * gui/oprof_start.cpp: redundant return + +2003-10-19 John Levon + + * libop/op_events.c: move to a fixed value for the default + event count value + +2003-10-19 Philippe Elie + + remove some FIXME: + * libpp/format_output.h: remove first_output bool member + * libpp/format_output.cpp: call output_header from the right place + * libpp/op_header.h: remove bogus FIXME + + * libregex/tests/Makefile.am: fix dependencies on mangled-name file, + fix make dist + * libregex/tests/mangled-name.in: simplify a bit and remove a bogus + FIXME + * libregex/tests/regex_test.cpp: fix comment + + * module/ia64/op_syscalls.c: + * module/x86/hammer_op_syscalls.c: + * module/x86/op_syscalls.c: remove some FIXME + +2003-10-17 Philippe Elie + + * libpp/arrange_profiles.cpp: clarify suggestion. + * pp/opreport_options.cpp: update options help string for --merge. + + * libpp/profile_container.cpp: + * libpp/profile_spec.cpp: + * pp/common_option.cpp: + * pp/populate.cpp: ';' are not necessary to end namespace + +2003-10-17 Philippe Elie + + * libpp/arrange_profiles.cpp: use a set instead + of a vector<...> to replace a O(N*M) by a O(N*log(M)) behavior. + (N number of samples files, M number of class). + +2003-10-17 Philippe Elie + + * libutil++/op_bfd.cpp: show filename when warning about no debug + information available. get_linenr(): s/filename/source_filename/ + +2003-10-16 Philippe Elie + + * events/ia64/itanium/events: counter 0,1 not 2,3 for IA64_INST_RETIRED + + * daemon/opd_util.c: opd_parse_events() fix use after free. + +2003-10-16 John Levon + + * daemon/opd_perfmon.c: disable the code + +2003-10-15 John Levon + + * daemon/opd_perfmon.c: fflushes to improve + order of debug log + +2003-10-15 John Levon + + * daemon/opd_perfmon.c: fix dumb allocation typo; + handle signals correctly; wait for children to + come up before returning + +2003-10-15 Philippe Elie + + * dae/opd_sample_files.c: + * daemon/opd_mangling.c: + * daemon/opd_perfmon.c: + * daemon/opd_util.c: check we not overflow op_nr_counters + +2003-10-15 Philippe Elie + + * events/ia64/itanium/events: correct counter available according + to intel doc. + +2003-10-15 John Levon + + * dae/opd_image.c: + * dae/opd_kernel.c: + * dae/opd_proc.c: + * dae/opd_sample_files.c: + * dae/oprofiled.c: + * daemon/opd_kernel.c: + * daemon/opd_mangling.c: + * daemon/opd_sfile.c: + * daemon/opd_trans.c: + * daemon/opd_util.c: + * daemon/opd_util.h: + * daemon/oprofiled.c: merge the options handling + for dae and daemon + +2003-10-15 Philippe Elie + + * daemon/opd_perfmon.c: + * module/ia64/op_pmu.c: bit mask for event select field is 8 bits not 7 + +2003-10-14 John Levon + + * configure.in: + * m4/findkernel.m4: + * utils/opcontrol: 2.5 refs -> 2.6 + +2003-10-14 John Levon + + * utils/opcontrol: merge some 2.4/6 code + +2003-10-14 John Levon + + * dae/opd_image.c: + * dae/opd_sample_files.c: + * dae/oprofiled.c: + * utils/opcontrol: use --events for 2.4 daemon + too + + * daemon/opd_perfmon.c: + * daemon/opd_mangling.c: fix counter numbering + on !perfmon + +2003-10-14 John Levon + + * configure.in: xmemdup not xmemdump + +2003-10-14 John Levon + + * daemon/opd_perfmon.c: propagate a SIGTERM + up to the parent. + +2003-10-14 John Levon + + * m4/perfmon.m4: + * configure.in: remove pfmlib checks + + * daemon/opd_util.h: + * daemon/opd_util.c: + * daemon/opd_mangling.c: + * daemon/oprofiled.c: parse more detailed events + passed on command line + + * daemon/opd_perfmon.h: + * daemon/opd_perfmon.c: don't use libpfm at all, + do it ourselves. + + * utils/opcontrol: pass more of the events info to + the daemon + +2003-10-14 John Levon + + * m4/perfmon.m4: + * configure.in: look for pfmlib 3 + + * daemon/Makefile.am: + * daemon/opd_perfmon.h: + * daemon/opd_perfmon.c: interface to perfmon on 2.6 IA64 + + * daemon/opd_mangling.c: + * daemon/oprofiled.c: read event descriptions from command + line not oprofilefs + + * daemon/opd_util.h: + * daemon/opd_util.c: receive SIGUSR1/2 for perfmon + + * utils/opcontrol: handle multiple oprofileds. Send SIGUSR1/2 + on start/stop. Pass in events list to oprofiled on 2.6. Don't + attempt to fill in oprofilefs with event info if using perfmon. + +2003-10-14 Philippe Elie + + * daemon/opd_mangling.c: + * daemon/opd_sfile.c: + * daemon/opd_sfile.h: protect the sfile we are acting on to be freed + by sfile_lru_clear() + + * libdb/db_manage.c: + * libdb/odb_hash.h: Do not put hash->descr in an inconsistent state + when a failure occur. + +2003-10-13 Philippe Elie + + * module/oprofile.c: don't restore syscall and stop counter twice + +2003-10-13 Will Cohen + + * libop/op_parse_event.c(parse_events): Correct fprintf. + +2003-10-13 Philippe Elie + + * module/x86/hammer_op_syscalls.c: pass tgid to daemon. Not tested! + +2003-10-12 John Levon + + * utils/opcontrol: share --separate-cpu/thread code now + +2003-10-12 Philippe Elie + + * configure.in: add libregex/tests/mangled-name.in + * libregex/tests/mangled-name.txt: move ... + * libregex/tests/mangled-name.in: here, tune to support different arch + * libregex/tests/Makefile.am: s/mangled-name.txt/mangled-name.in + * libregex/stl.pat.in: fix iterator<... ptrdiff_t> + * libregex/tests/Makefile.am: update according to filename change + + * libregex/tests/regex_test.cpp: really fails on exception. + +2003-10-12 Philippe Elie + + * dae/oprofiled.c: don't set cpu_number when !--separate=cpu + + * libop/tests/alloc_counter_tests.c: printf format for 64 bits arch + * libop/tests/cpu_type_tests.c: #include + * libop/tests/parse_event_tests.c: #include + +2003-10-11 Philippe Elie + + * libop/op_interface.h: struct op_sample: remove packed attribute + +2003-10-11 Philippe Elie + + * dae/opd_image.c: + * dae/opd_image.h: reference count opd_image. Remove modification time + checking. Remove hash field. Tidy + * dae/opd_kernel.c: pass tid, tgid to op_get_kernel_image() + * dae/opd_mapping.c: + * dae/opd_mapping.h: use module hash code for image name to index + a cache of name, this hash code is no longer used elsewhere. When + killing map delete associated image, reference count of image + will check for a real delete. + * dae/opd_parse_proc.c: get tgid from /proc/pid/status + * dae/opd_proc.c: create an opd_proc by process when + separate_thread == true. Tidy by adding an opd_for_each_proc() + * dae/opd_proc.h: add tid/tgid to opd_proc struct + * dae/opd_sample_files.c: + * dae/opd_sample_files.h: lru all samples files, allowing to cleanup + a part of the lru if we go out of resource. Remove + opd_handle_old_sample_files() since we no longer check for image + modification time. + * dae/opd_stats.c: + * dae/opd_stats.h: statistics for opd_image struct depth search + * dae/oprofiled.c: add --separate-cpu and --separate-thread + * libop/op_interface.h: add tgid to samples struct passed from module + to daemon. + * module/compat22.h: + * module/compat24.h: op_get_tgid() return tgid, fall back to return + tid on 2.2 kernel. + * module/oprofile.c: + * module/ia64/op_syscalls.c: pass tgid to daemon. NOT TESTED but I + think it's ok. Note than even if it's broken ia64 should work w/o + --separate=thread + * module/x86/op_syscalls.c: pass tgid to daemon. + * utils/opcontrol: enable 2.4 thread/cpu separation + + * libdb/tests/db_test.c: verbose on when we provide filename of db file + to test on command line. + +2003-10-11 Philippe Elie + + * libop/op_cpu_type.h: + * libop/op_cpu_type.c: constification + * utils/op_help.c: check only if CPU_NO_GOOD not range + + * libutil/tests/Makefile.am: + * libregex/tests/Makefile.am: + * libdb/tests/Makefile.am: s/TEST = (.*)/TESTS = ${check_PROGRAMS}/ + + * libop/tests/alloc_counter_tests.c: comment fix + + * libop/tests/Makefile.am: + * libop/tests/cpu_type_tests.c: new file, test libop/op_cpu_type.c + +2003-10-10 Will Cohen + + * libop/op_cpu_type.h (op_get_cpu_number): Clarify comment. + * libop/op_cpu_type.c (op_get_cpu_number): Check number. + * utils/op_help.c (main): Make check with CPU_NO_GOOD. + +2003-10-10 Will Cohen + + * libop/op_cpu_type.h (op_get_cpu_number): Declare. + * libop/op_cpu_type.c (op_get_cpu_number): New. + (op_get_cpu_type): Use op_get_cpu_number. + * utils/op_help.c (main): Use op_get_cpu_number. + +2003-10-10 John Levon + + * libop/op_parse_event.c: fix compile for IA64 + +2003-10-09 John Levon + + * doc/oprofile.xml: document "no results" and + how to fix it + +2003-10-08 John Levon + + * utils/op_help.c: standardise name + + * gui/oprof_start.cpp: Qt 2.3.1 compile fix + (bug 819943) + +2003-10-07 Philippe Elie + + * dae/opd_kernel.c: memory leak + + * dae/opd_mapping.c: + * dae/opd_mapping.h: + * dae/opd_parse_proc.c: + * dae/opd_proc.c: + * dae/opd_proc.h: use a list of struct opd_map instead of an array, + remove last_map optimization. + + * dae/oprofiled.c: memory leak + + * libutil/op_cpufreq.c: memory leak, FILE* leak + * libutil/op_list.h: fix @author + +2003-10-06 Philippe Elie + + * dae/oprofiled.c: + * dae/opd_proc.h: + * dae/opd_proc.c: use struct list_head to chain opd_proc struct in hash + table + + * utils/op_help.c: comment fix + +2003-10-06 John Levon + + * utils/opcontrol: work around 2.6 daemon's signal + handling race that could cause it to hang during + a --shutdown + +2003-10-05 Philippe Elie + + * events/i386/p4/events: + * events/i386/p4-ht/events: put GLOBAL_POWER_EVENTS on top + + * events/i386/pii/unit_masks: + * events/i386/piii/unit_masks: typo in help string + + * utils/op_help.c: show "counter: all" instead an enumeration of all + counter + +2003-10-02 Philippe Elie + + * events/*.events *.unit_masks: move these files to subdir named + arch/processor_name/events and arch/processor_name/unit_masks + * events/Makefile.am: update according + + * libop/op_events.c: now it's safe to allow loading events file from a + directory provided through environment var OPROFILE_EVENTS_FILE_DIR + * libop/tests/alloc_counter_tests.c: use it + * libop/tests/load_events_files_tests.c: use it + +2003-10-02 Philippe Elie + + * libop/op_events.c: revert last commit (allowed to find events files + description directory in alternate directory) + + * libop/tests/Makefile.am: + * libop/tests/load_events_files_tests.c: new files. Validate events + description file by loading them. + + * libutil/op_cpufreq.c: comment why we don't have any code handling + s390 + +2003-10-01 Philippe Elie + + * configure.in: + * libop/Makefile.am: new subdir + * libop/op_events.c: allow to retrieve events file dir through + environment variable + * utils/op_help.c: move parse_events() and parsed_event struct to ... + * libop/op_parse_event.h: + * libop/op_parse_event.c: these new files + + * libop/tests/Makefile.am: new tests subdir + * libop/tests/alloc_counter_tests.c: events mapping to counter nr tests + * libop/tests/parse_event_tests.c: event parsing tests + +2003-10-01 Philippe Elie + + * libop/op_alloc_counter.c: add forward declaration + * libop/op_alloc_counter.c: alloc counter in increasing number order, + it's less surprising. + +2003-10-01 Philippe Elie + + * libdb/tests/db_test.c: if previous tests fails a corrupted samples + file can exist in test dir and will be re-used, remove() it. + +2003-10-01 John Levon + + * daemon/opd_sfile.c: + * libabi/op_import.cpp: + * libop/op_interface.h: + * libpp/locate_images.h: small cleanups + + * pp/opreport_options.cpp: don't complain about + "-x -m all" + +2003-09-28 Philippe Elie + + * libutil/op_file.c: + * libutil/tests/file_tests.c: honor posix "//" filename namespace + +2003-09-28 Philippe Elie + + * libop/op_alloc_counter.h: + * libop/op_alloc_counter.c: change allocator by a backtracking + algorithm walking only through possible solution. + +2003-09-26 Philippe Elie + + * libdb/tests/db_test.c: success must be silent + * dae/oprofiled.c: + * daemon/oprofiled.c: + * libutil/op_deviceio.c: + * libutil/op_deviceio.h: op_open_device(): remove unused parameter + fatal + +2003-09-26 Philippe Elie + + * libutil/tests/file_tests.c: Fix some test: in some case the pathname + component must be valid since we lstat() them. Fix a segfault due + to missing ',' + +2003-09-26 John Levon + + * libdb/tests/Makefile.am: + * libregex/tests/Makefile.am: + * libutil/tests/Makefile.am: don't build tests + unless "make check" + +2003-09-26 John Levon + + * libutil/op_file.c: don't test for NULL path + passed in, we want to crash here instead of + in xstrdup + + * configure.in: + * libutil/Makefile.am: + * libutil/tests/Makefile.am: + * libutil/tests/file_tests.c: + * libutil/tests/string_tests.c: add some unit tests + for libutil string and path handling + +2003-09-26 Philippe Elie + + * libdb/db_debug.c: remove useless display interface + * libdb/db_db_travel.c: remove callback interface + * libdb/odb_hash.h: remove display/callback interface + * libdb/db_test.cpp: move to tests subdir + * libdb/Makefile.am: update according + * libdb/tests: new dir + * libdb/tests/.cvsignore: + * libdb/tests/Makefile.am: new files + * libdb/tests/db_test.cpp: shorter tests + + * libregex/mangled-name.txt: + * libregex/regex_testc.cpp: move to ... + * libregex/tests: new directory + * libdb/Makefile.am: update according + * libregex/tests/.cvsignore: + * libregex/tests/Makefile.am: new files + +2003-09-26 John Levon + + * libabi/abi_test.cpp: + * libabi/op_import.cpp: small cleanups + +2003-09-25 John Levon + + * daemon/opd_cookie.c: + * daemon/opd_kernel.c: + * daemon/opd_sfile.c: + * daemon/opd_trans.c: + * daemon/oprofiled.c: trivial cleanups + +2003-09-25 Marc Herbert + + * configure.in: fix prefix stuff to allow stow + to work + +2003-09-25 Philippe Elie + + * pch-c++.h: remove + * Makefile.am: update according + * configure.in: no longer need for conditional enable_pch + * m4/precompiledheader.m4: don't use -Winvalid-pch + +2003-09-25 Philippe Elie + + * daemon/opd_sfile.c: sfile_lru_clear() return 0 if lru is empty + * daemon/opd_mangling.c: abort() if lru was empty (not tested) + * daemon/oprofiled.c: likewise; opd_alarm(): don't sfile_lru_clear() + + * utils/op_help.c: + * daemon/opd_sfile.h: + * daemon/opd_cookie.h: s/()/(void)/ in some function prototype and + definition + + * daemon/opd_cookie.c: s/"not looked up"/"not hashed"/ + +2003-09-25 John Levon + + * daemon/oprofiled.c: push rlimit down back to 2048. + This gives a running RSS of about 10Mb when thread + profiling on my box, which seems reasonable (at 8192 + it was hitting 40Mb) + +2003-09-25 Philippe Elie + + * doc/oprofile.xml: clarify what means a configured kernel. + +2003-09-25 John Levon + + * daemon/opd_sfile.c: bump LRU_AMOUNT to 1000 + +2003-09-24 John Levon + + * doc/opcontrol.1.in: + * doc/oprofile.xml: document thread and cpu + profiling a bit + + * daemon/opd_mangling.c: + * daemon/opd_sfile.c: + * daemon/oprofiled.c: + * utils/opcontrol: implement per-CPU profiling, + not tested yet + +2003-09-24 John Levon + + * dae/opd_proc.c: + * dae/opd_sample_files.c: + * daemon/opd_mangling.c: + * daemon/opd_sfile.c: + * libabi/abi_test.cpp: + * libabi/op_import.cpp: + * libdb/db_insert.c: + * libdb/db_manage.c: + * libdb/db_test.c: + * libdb/odb_hash.h: + * libpp/op_header.cpp: + * libpp/profile.cpp: remove samples_odb_t.err_msg + entirely - prefer UNIX-style errno returns. Modify + error messages to match + +2003-09-24 John Levon + + * dae/opd_sample_files.c: + * daemon/opd_sample_files.c: + * libpp/op_header.cpp: + * libpp/profile.cpp: + * libabi/abi_test.cpp: + * libabi/op_import.cpp: + * libdb/db_test.c: + * libdb/odb_hash.h: + * libdb/odb_manage.c: make odb_open return errno + instead of EXIT_FAILURE/SUCCESS to allow EMFILE + handling. Also do not leak fd's on failure. + + * libutil/op_types.h: cookie_t moved into daemon/ + + * daemon/: major rewrite: move to a hash on all + parameters of struct transient. Lots of readability + cleanups, plus resistance to cookie lookup failures, + and hitting open file limits. Additionally thread + profiling for kernel threads is enabled now. + +2003-09-24 John Levon + + * daemon/opd_image.c: remove support for missing + CTX_TGID + +2003-09-24 John Levon + + * daemon/oprofiled.c: remove /proc/kcore support + +2003-09-22 Philippe Elie + + * dae/opd_parse_proc.c: both op_file.h and op_fileio.h are needed + +2003-09-22 John Levon + + * doc/CodingStyle: document doxygen placing rule + + * libop/op_alloc_counter.h: + * libop/op_get_interface.c: + * libutil++/file_manip.cpp: + * libutil++/file_manip.h: + * libutil++/op_bfd.cpp: + * libutil++/op_bfd.h: + * libutil/op_deviceio.c: + * libutil/op_deviceio.h: + * libutil/op_get_time.c: + * libutil/op_get_time.h: + * libutil/op_libiberty.c: + * libutil/op_libiberty.h: + * libutil/op_lockfile.c: + * libutil/op_lockfile.h: + * libutil/op_popt.c: + * libutil/op_popt.h: follow the above + + * libutil/op_file.c: + * libutil/op_file.h: + * libutil/op_fileio.c: + * libutil/op_fileio.h: + * dae/opd_parse_proc.c: + * libutil++/string_manip.cpp: move op_get_link to + op_file + +2003-09-22 John Levon + + * libutil/op_fileio.h: + * libutil/op_fileio.c: warn about op_get_link() + restrictions + + * libutil++/file_manip.h: + * libutil++/file_manip.cpp: s/op_read_link/op_follow_link, + and behaviour change to match + + * libpp/profile_spec.cpp: + * gui/oprof_start_util.cpp: use op_follow_link + +2003-09-22 Philippe Elie + + * dae/makefile.am: missing AM_CFLAGS setting + + * dae/oprofiled.c: + * daemon/oprofiled.c: handle signal in read loop + * daemon/opd_util.h: + * daemon/opd_util.c: move opd_setup_signal() from dae/ daemon/ + +2003-09-22 John Levon + + * dae/oprofiled.c: + * daemon/oprofiled.c: mask SIGTERM too to prevent + the possibility of empty sample files + +2003-09-21 Philippe Elie + + * libpp/format_output.h: + * libpp/format_output.cpp: + * pp/opreport.cpp: format_output::show_header no hide_header + +2003-09-21 Philippe Elie + + * doc/opreport.1.in: + * doc/oprofile.xml: + * libpp/format_output.h: + * libpp/format_output.cpp: + * pp/opreport.cpp: --global_percent must be effective for detailed + output too + +2003-09-21 John Levon + + * pp/opreport_options.cpp: prevent --global-percent + when appropriate + +2003-09-21 John Levon + + * Makefile.am: back out broken make clean change + +2003-09-21 John Levon + + * Makefile.am: make clean now removes *.html + + * internals.xml: add some outline sections + +2003-09-21 John Levon + + * doc/internals.xml: provide a short overview + and start a glossary + + * libpp/count_array.h: + * libpp/format_output.cpp: + * libpp/format_output.h: + * libpp/profile.cpp: + * libpp/profile.h: + * libpp/profile_container.cpp: + * libpp/profile_container.h: + * pp/opreport.cpp: replace residual references to + count groups with profile class concept + +2003-09-21 John Levon + + * doc/Makefile.am: + * doc/internals.xml: start an internals manual ... + +2003-09-19 John Levon + + * pp/image_errors.cpp: missing include + +2003-09-19 John Levon + + * libopt++/popt_options.h: + * libopt++/popt_options.cpp: remove additional_help + stuff, unused for some time + +2003-09-18 John Levon + + * libutil++/Makefile.am: + * libutil++/image_flags.h: move to ... + + * libpp/Makefile.am: + * libpp/image_error.h: ... here, and rename + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: take an in-out bool + instead of image_flags + + * libpp/arrange_profiles.cpp: + * libpp/arrange_profiles.h: + * libpp/locate_images.cpp: + * libpp/locate_images.h: + * libpp/profile_spec.cpp: + * pp/image_errors.cpp: + * pp/opgprof.cpp: + * pp/populate.cpp: changes from above + +2003-09-18 John Levon + + * libutil++/Makefile.am: + * libutil++/image_flags.h: flags for image read failure + + * libpp/profile_spec.cpp: + * libpp/locate_images.h: + * libpp/locate_images.cpp: + * libpp/arrange_profiles.h: + * libpp/arrange_profiles.cpp: use image_flags + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: use image_flags, no longer error + out on format failure + + * pp/Makefile.am: + * pp/image_errors.cpp: + * pp/image_errors.h: errors previously reported in locate_images + are now reported here by the client + + * pp/opannotate.cpp: + * pp/opgprof.cpp: + * pp/opgprof_options.cpp: + * pp/opreport.cpp: + * pp/populate.h: + * pp/populate.cpp: use the above + +2003-09-18 Philippe Elie + + * libpp/format_output.cpp: use 9 not 12 for % field width + * libutil++/string_manip.cpp: shrink 100.0000 to 100.000 + * pp/opreport.cpp: s/" "/' ' + +2003-09-18 John Levon + + * pp/opannotate_options.cpp: + * pp/opreport_options.cpp: clean up error messages + + * pp/opgprof_options.h: + * pp/opgprof_options.cpp: + * pp/opgprof.cpp: use inverted_profile API + +2003-09-18 Philippe Elie + + * utils/opcontrol: overwrite all current settings with --separate, + this change behavior of --separate=kernel,library now we really setup + both in this case. + +2003-09-18 John Levon + + * libpp/locate_images.cpp: rewrite a little + + * libutil++/op_bfd.cpp: set fsize to default to -1, + for fake artificial symbol + +2003-09-18 Philippe Elie + + * libpp/locate_images.h: + * libpp/locate_images.cpp: find_module_path() extra bool parameter + to know if we fail to retrieve the image. + * libpp/arrange_profiles.h: + * libpp/arrange_profiles.cpp: use it and save this bool in + inverted_profile struct + * libpp/profile_spec.cpp: update caller according + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: use the above change to create fake op_bfd + + * pp/opgprof_options.cpp: + * pp/opgprof.cpp: update caller but never allow fake op_bfd + + * pp/populate.cpp: allow to create fake op_bfd + + +2003-09-18 John Levon + + * dae/opd_image.c: + * dae/opd_proc.c: + * dae/opd_sample_files.c: + * dae/oprofiled.c: + * daemon/opd_image.c: + * daemon/opd_image.h: + * daemon/opd_kernel.c: + * daemon/opd_sample_files.c: + * daemon/oprofiled.c: + * gui/oprof_start.cpp: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: + * gui/ui/oprof_start.base.ui: + * libabi/abi.cpp: + * libabi/abi_test.cpp: + * libabi/op_import.cpp: + * libop/op_sample_file.h: + * libpp/op_header.cpp: + * utils/opcontrol: renamings of separate stuff + +2003-09-17 Philippe Elie + + * dae/opd_kernel.c: thinko in opd_get_module_info(): we must take + care to re-use a previously created module not to create a new + +2003-09-17 John Levon + + * daemon/opd_kernel.c: logging improvements + +2003-09-17 Philippe Elie + + * dae/opd_kernel.c: + * daemon/opd_kernel.c: fix use after free of module + +2003-09-17 John Levon + + * daemon/opd_image.c: fix thread profiling when + --separate-library=0 + +2003-09-17 Philippe Elie + + * dae/opd_kernel.c: add module to list of module ... + * daemon/opd_kernel.c: s/print/verbprintf + +2003-09-17 Philippe Elie + + * libop/op_config.h: remove OPD_MAX_MODULEs + * dae/opd_kernel.c: + * daemon/opd_kernel.c: remove fixed array of modules replaced by + a list. Unify the way we create opd_module + * utils/opcontrol: don't use --thread-profiling for 2.4 + +2003-09-17 Ka Fai Lu + + I adapted slightly this patch Phil. + * daemon/opd_image.c: + * daemon/opd_image.h: + * daemon/opd_kernel.c: + * daemon/opd_sample_files.c: + * daemon/oprofiled.c: + * utils/opcontrol: implement per thread profiling + +2003-09-16 Philippe Elie + + * libopt++/popt_options.h: + * libpp/locate_images.cpp: minor tidy + +2003-09-16 John Levon + + * utils/opcontrol: don't pass pid/pgrp filter + to 2.6 daemon + + * dae/oprofiled.c: + * daemon/oprofiled.c: setrlimit to 8192 (lame + workaround for now), minor cleanups + +2003-09-15 John Levon + + * common_option.cpp: rename the array to + avoid a link error in GCC 3.4 + +2003-09-15 John Levon + + * libop/Makefile.am: + * libop/op_interface_25.h: move to ... + + * daemon/Makefile.am: + * daemon/opd_interface.h: ... here + + * daemon/opd_image.c: + * daemon/oprofiled.c: use above. Remove pointless + command line options. + + * libop/op_config_25.h: remove. + + * libop/op_hw_config.h: move DCOOKIE_SHIFT to + opd_interface.h + +2003-09-15 John Levon + + * configure.in: use -Wdeclaration-after-statement + if available + + * README: + * daemon/opd_util.c: + * daemon/opd_util.h: + * doc/opannotate.1.in: + * doc/opgprof.1.in: + * doc/opreport.1.in: + * doc/oprofile.1.in: + * doc/oprofile.xml: + * gui/oprof_start.cpp: + * gui/oprof_start_util.cpp: + * libop/op_cpu_type.c: + * libop/op_cpu_type.h: + * libop/op_get_interface.c: + * libpp/locate_images.cpp: remove references to + 2.5, replaced with 2.6 + +2003-09-15 John Levon + + * doc/opreport.1.in: document --show-address + +2003-09-15 John Levon + + * libpp/arrange_profiles.cpp: + * libpp/arrange_profiles.h: + * pp/populate.cpp: more commentary + +2003-09-14 Philippe Elie + + * pp/opreport.cpp: handle 2.95 right io manipulator and the lack + of a proper setw(w) << std::string + +2003-09-14 John Levon + + * pp/opreport.cpp: re-add header for image summary + +2003-09-14 John Levon + + * libpp/arrange_profiles.cpp: throw an exception + if there are two many unmerged profiles, with details + of how to fix it + + * pp/opgprof_options.cpp: + * pp/common_option.cpp: clean up error messages + +2003-09-14 John Levon + + * libpp/arrange_profiles.h: + * libpp/arrange_profiles.cpp: add location of + images when inverting profiles + + * libpp/locate_images.cpp: return empty string + if file isn't readable + + * pp/opannotate.cpp: use the above + + * pp/opreport.cpp: use the above; place warnings + before any other output + +2003-09-14 John Levon + + * pp/opgprof_options.cpp: use locate_image_path + +2003-09-14 John Levon + + * Makefile.am: + * populate.h: + * populate.cpp: shared code for populating from + inverted profiles + + * opreport.cpp: + * opannotate.cpp: use above + +2003-09-14 John Levon + + * libpp/arrange_profiles.h: + * libpp/arrange_profiles.cpp: add invert_profiles + + * pp/opreport.cpp: use it + +2003-09-14 John Levon + + * doc/oprofile.xml: + * pp/opreport.cpp: + * pp/opreport_options.cpp: + * pp/opreport_options.h: Turn off VMA report by + default, add --show-address + +2003-09-14 John Levon + + * pp/opreport.cpp: nice formatting of image report + column headers, respect --no-header + +2003-09-14 Philippe Elie + + * libpp/arrange_profiles.cpp: use string::erase() not string::clear() + for 2.95 + + * libutil++/generic_spec.h: allow to ignore "all" match + * libutil++/comma_list.h: use it + +2003-09-14 John Levon + + * pp/opreport.cpp: output column headers for + image report + +2003-09-14 John Levon + + * libpp/op_header.h: + * libpp/op_header.cpp: output header info to + a string not a stream + + * libpp/arrange_profiles.h: + * libpp/arrange_profiles.cpp: give classes a long + name, and fill in global event/cpu info + + * pp/opannotate.cpp: + * pp/opannotate_options.cpp: + * pp/opannotate_options.h: + * pp/opgprof_options.cpp: + * pp/opreport.cpp: + * pp/opreport_options.cpp: + * pp/opreport_options.h: use the class long names + and info + +2003-09-14 Philippe Elie + + * libpp/profile_spec.cpp: handle symlink + +2003-09-14 John Levon + + * arrange_profiles.h: + * arrange_profiles.cpp: Add code to give short names + to each class, unused yet + +2003-09-14 Philippe Elie + + * libpp/arrange_profiles.cpp: missing include<> with gcc 2.95 + +2003-09-14 John Levon + + * libpp/Makefile.am: + * libpp/split_sample_filename.cpp: + * libpp/split_sample_filename.h: rename as ... + + * libpp/parse_filename.cpp: + * libpp/parse_filename.h: ... this + + * libpp/filename_spec.cpp: + * libpp/arrange_profiles.cpp: + * libpp/arrange_profiles.h: sort classes for niceness, + changes from above + + * pp/opreport.cpp: remove needless double check of + exclude_dependent + + * libutil++/string_manip.cpp: touint should init to 0 + in case of parse failure + +2003-09-14 Philippe Elie + + * configure.in: fix maximum template depth to 50 + * libutil/op_fileio.c: op_get_link() don't truncate silently results + * m4/sstream.m4: use OP_CXXFLAGS not CXXFLAGS + +2003-09-14 John Levon + + * pp/partition_files.h: + * pp/partition_files.cpp: remove, now unused + +2003-09-14 John Levon + + * pp/opannotate.cpp: + * pp/opannotate_options.cpp: + * pp/opannotate_options.h: use arrange_profiles API + +2003-09-14 John Levon + + * pp/opgprof_options.h: + * pp/opgprof_options.cpp: + * pp/opgprof.cpp: use arrange_profiles API + +2003-09-14 John Levon + + * libpp/Makefile.am: + * libpp/arrange_profiles.cpp: + * libpp/arrange_profiles.h: introduce new + code for partitioning profiles and handling + merging + + * libpp/partition_files.h: + * pp/opreport_options.cpp: + * pp/opreport_options.h: + * pp/opreport.cpp: use the above code + + * libpp/format_flags.h: + * libpp/profile_container.cpp: remove unneeded + multiple apps hint + + * libpp/count_array.cpp: + * libpp/count_array.h: remove unnecessary code + +2003-09-14 John Levon + + * configure.in: back to 0.7cvs + +2003-09-14 John Levon + + * pp/opannotate.cpp: gcc 2.91 workaround + (in 0.6.1 release) + +2003-09-14 John Levon + + * configure.in: bump to 0.6.1 + +2003-09-13 John Levon + + * doc/oprofile.xml: document "incorrect source attribution" + a bit + +2003-09-12 Philippe Elie + + * libpp/op_header.cpp: typo in comment + +2003-09-11 John Levon + + * configure.in: check for -lintl, tweak -ldl check + +2003-09-11 John Levon + + * dae/oprofiled.c: + * daemon/oprofiled.c: + * libdb/db_manage.c: + * libdb/db_test.c: correct headers + +2003-09-11 John Levon + + * op_lockfile.c: use correct headers + +2003-09-07 Philippe Elie + + * utils/op_help.c: check than all events are distincts + +2003-09-06 Philippe Elie + + * pch-c++.h: + * m4/precompiledheader.m4: new file to handle precompiled header + * m4/Makefile.am: + * configure.in: + * Makefile.am: handle precompiled header + +2003-09-05 John Levon + + * opd_image.c: cleanup of ctx_switch_set_image() + +2003-09-05 Philippe Elie + + * daemon/opd_image.c: After a context switch ensure we update correctly + the current image. + +2003-09-04 Philippe Elie + + * pp/opreport.cpp: + * pp/opannotate.cpp: catch op_bfd exception and recover gracefully + +2003-09-04 Philippe Elie + + * utils/opcontrol: tweak "signaling daemon " message as suggested + by Carlo Wood + +2003-09-04 John Levon + + * doc/oprofile.xml: mention --reset in + "Getting Started" + +2003-09-03 John Levon + + * libop/op_events.c: + * libpp/op_header.cpp: + * dae/opd_sample_files.c: + * daemon/opd_sample_files.c: propagate event + error back up to caller + + * libdb/odb_hash.h: fix comment + +2003-09-02 John Levon + + * dae/opd_image.c: + * dae/opd_proc.c: + * dae/oprofiled.c: + * daemon/opd_image.c: use abort() not exit() + on "can't happen" errors + +2003-09-02 John Levon + + * dae/opd_proc.c: + * daemon/opd_image.c: fix error message + +2003-08-28 Philippe Elie + + * events/alpha.ev6.events: fix duplicate um tag + +2003-08-28 John Levon + + * events/i386.athlon.events: fix duplicate minimum tag + + * daemon/opd_image.c: + * libop/op_events.c: check for duplicate tags + +2003-08-28 John Levon + + +2003-08-27 Will Cohen + + * utils/op_help.c (resolve_events): Typecast printf argument. + +2003-08-25 Philippe Elie + + * pp/opannotate_options.cpp: + * pp/opannotate_options.h: + * pp/opannotate.cpp: enable multiple events + + * pp/opreport_options.cpp: remove #if 0 .... #endif + +2003-08-25 Philippe Elie + + * libpp/count_array.cpp: avoid to access invalid memory + +2003-08-25 Philippe Elie + + * configure.in: + * m4/builtinexpect.m4: + * m4/configmodule.m4: + * module/Makefile.in: + * module/ia64/Makefile.in: + * module/x86/makefile.in: always use EXTRA_CFLAGS_MODULE not + EXTRA_CFLAGS for module build flags + +2003-08-23 Philippe Elie + + * libregex/op_regex.h: + * libregex/op_regex.cpp: tidy + + * libutil++/op_bfd.cpp: remove obsolete comment + +2003-08-23 Philippe Elie + + * libutil++/file_manip.h: + * libutil++/file_manip.cpp: is_directory(dirname): return true if + dirname exists + * pp/common_option.cpp: validate --image-path parameters + +2003-08-22 Philippe Elie + + * events/i386.p4.events: clarify than 128BIT_MMX_UOP count only integer + SSE2 ops + * pp/opreport.cpp: minor spacing change in output + +2003-08-22 John Levon + + * daemon/oprofiled.c: report the kernel pointer size + +2003-08-22 John Levon + + * daemon/oprofiled.c: read new /dev/oprofile/pointer_size + in preference to kcore. kcore code will eventually go. + +2003-08-21 John Levon + + * libutil++/op_bfd.cpp: update gcc2_compiled. comment + to reflect reality + +2003-08-19 Philippe Elie + + * pp/opreport.cpp: really merge when --merge=lib and image name are + specified. + +2003-08-16 Philippe Elie + + * pp/opannotate.cpp: output threshold percent when necessary. + +2003-08-16 Philippe Elie + + * libutil++/op_bfd.cpp: remove ELF-based symbol size code + +2003-08-15 William Cohen + + * doc/opcontrol.1.in: + * doc/oprofile.1.in: + * doc/oprofile.xml: Correct path to /root/.oprofile/daemonrc. + +2003-08-15 Thomas Spatzier + + * daemon/opd_cookie.h: fix s390 syscall + +2003-08-14 Philippe Elie + + * libutil++/string_manip.cpp: erase_to_last_of() is not a ltrim() + +2003-08-14 Philippe Elie + + Dave Jones suggested this change. + + * module/x86/op_model_p4.c: remove superflous ';' at end of some macro + +2003-08-14 Philippe Elie + + * libutil++/string_manip.h: remove erase_from_last_of() + * libutil++/string_manip.cpp: and tidy erase_to_last_of(), rtrim() and + ltrim() + +2003-08-13 Philippe Elie + + * libutil++/op_bfd.h: + * libpp/profile_container.cpp: remove nil_symbol_index + +2003-08-13 John Levon + + * libpp/profile_container.cpp: + * libpp/profile_container.h: remove "base_vma" parameter + to add_samples(), we can just re-grab it straight from + the abfd + +2003-08-13 John Levon + + * libpp/profile_container.cpp: + * libpp/profile_container.h: remove unused "zero samples" + optimization hint: it's always false + + * pp/opannotate.cpp: + * pp/opgprof.cpp: + * pp/opreport.cpp: from above + +2003-08-12 John Levon + + * pp/opreport.cpp: small trivialities + +2003-08-12 Philippe Elie + + * libregex/stl.pat.in: minor fix/improvements + * libregex/mangled-name.txt: add tests + +2003-08-12 Philippe Elie + + * pp/opreport.cpp: fix thinko when --merge=lib + +2003-08-12 John Levon + + * pp/opreport.cpp: s/count_groups_summary/summary_container/g + +2003-08-12 John Levon + + * doc/oprofile.xml: document opreport's side-by-side a little + bit + +2003-08-12 John Levon + + * pp/opreport.cpp: s/group_summary/app_summary/, and + a lot of other renamings to clarify the count groups + usage. + +2003-08-12 John Levon + + * utils/op_help.c: add --unit-mask + + * utils/opcontrol: use --unit-mask + +2003-08-12 Philippe Elie + + * pp/opreport.cpp: re write using count_array_t + +2003-08-11 John Levon + + * libpp/count_array.cpp: + * libpp/count_array.h: auto-resize the number of groups + based on how we index. + + * libpp/profile_container.cpp: remove check + + * pp/opannotate.cpp: count_array.zero() not .empty() + +2003-08-11 John Levon + + * libpp/filename_spec.h: + * libpp/profile_spec.cpp: + * libpp/profile_spec.h: add comments, allow comma lists + for event, count, and unit mask + + * libutil++/comma_list.h: implement missing method + +2003-08-11 John Levon + + * libpp/format_output.cpp: + * libpp/format_output.h: add set_nr_groups(), remove + pp_nr_counters. + + * libpp/profile_container.cpp: + * libpp/profile_container.h: + * pp/opannotate.cpp: + * pp/opgprof.cpp: + * pp/opreport.cpp: count_group not counter + +2003-08-11 John Levon + + * libpp/Makefile.am: + * libpp/counter_array.cpp: + * libpp/counter_array.h: rename to ... + + * libpp/count_array.h: + * libpp/count_array.cpp: ... this ... + + * libpp/format_output.cpp: + * libpp/format_output.h: + * libpp/profile.cpp: + * libpp/profile.h: + * libpp/profile_container.cpp: + * libpp/profile_container.h: + * libpp/sample_container.cpp: + * libpp/sample_container.h: + * libpp/symbol.h: + * pp/opannotate.cpp: + * pp/opgprof.cpp: + * pp/opreport.cpp: ... and several renamings to starting + change the notion from "counters" to the more general notion + of "count groups" + +2003-08-10 Philippe Elie + + Multiple counter support for pp tools. + + * libpp/counter_array.h: + * libpp/counter_array.cpp: resurrected from pp-interface-branch, for + now memory use is inefficient. + * libpp/Makefile.am: add counter_array.cpp .h + * libpp/format_out.h: + * libpp/format_out.cpp: handle multiple counter + a general tidy + * libpp/format_flags.h: remove ff_immutable_mask and some nasty + requisite on flags value + * libpp/profile_container.h: + * libpp/profile_container.cpp: + * libpp/sample_container.h: + * libpp/sample_container.cpp: + * libpp/symbol.h: + * libpp/symbol_container.cpp: + * libpp/symbol_sort.cpp: + * pp/opreport.cpp: handle multiple counter + * pp/opannotate.cpp: partial handling of multiple counter + * pp/opgprof.cpp: + * pp/opreport.cpp: minor bits + +2003-08-08 Will Cohen + + * dae/Makefile.am: + * daemon/Makefile.am: Correct library linking order. + * daemon/opd_util.c: Add needed include files. + +2003-08-08 Philippe Elie + + * utils/opcontrol: move_and_remove() do nothing if source doesn't exist + +2003-08-08 Philippe Elie + + revert the previous patch + * dae/Makefile.am: + * dae/opd_sample_files.h: + * dae/opd_sample_files.c: + * daemon/Makefile.am: + * daemon/opd_sample_files.c: un-share opd_sample_files + code + +2003-08-08 John Levon + + * dae/Makefile.am: + * dae/opd_sample_files.h: + * dae/opd_sample_files.c: + * daemon/Makefile.am: + * daemon/opd_sample_files.c: share opd_sample_files + code + +2003-08-08 John Levon + + * dae/oprofiled.c: + * daemon/oprofiled.c: + * daemon/opd_util.h: + * daemon/opd_util.c: share opd_write_abi() + +2003-08-08 Philippe Elie + + * libop/op_alloc_counter.c: + * libop/op_events.h: minor doxygen fix + +2003-08-08 John Levon + + * dae/Makefile.am: + * dae/oprofiled.c: + * daemon/Makefile.am: + * daemon/oprofiled.c: + * daemon/opd_util.h: + * daemon/opd_util.c: share some small bits of code + between the daemons + +2003-08-08 John Levon + + * dae/oprofiled.c: + * daemon/oprofiled.c: remove mypid, unused + +2003-08-08 John Levon + + * dae/Makefile.am: + * dae/opd_printf.h: remove duplicate header + and use daemon/opd_printf.h + +2003-08-08 John Levon + + * dae/opd_image.c: + * dae/opd_sample_files.h: + * dae/opd_sample_files.c: + * daemon/opd_image.c: + * daemon/opd_sample_files.h: + * daemon/opd_sample_files.c: remove "create" bool + from opd_mangle_filename(): only one callsite needs + that functionality, open code the create instead + + * dae/opd_proc.c: + * dae/opd_sample_files.h: + * dae/opd_sample_files.c: + * daemon/opd_sample_files.h: + * daemon/opd_sample_files.c: return error from + opd_open_sample_filename(). Do not fail when odb_open + fails due to --reset races. + + * dae/oprofiled.c: + * daemon/oprofiled.c: a little more verbosity. + + * libutil/op_file.h: + * libutil/op_file.c: fix create_dir/path() comments, + don't use access() + + * utils/opcontrol: reduce chance of --reset races + +2003-08-06 Philippe Elie + + * libpp/symbol_sort.h: + * libpp/symbol_sort.cpp: add app_name sort order, force sort order + for criteria unspecified by user. + * pp/opreport_options.cpp: update --sort option help string. + +2003-08-04 John Levon + + * doc/oprofile.xml: + * doc/opannotate.1.in: + * pp/opannotate.cpp: + * pp/opannotate_options.h: + * pp/opannotate_options.cpp: add --base-dirs + +2003-08-04 John Levon + + * doc/oprofile.xml: + * doc/opannotate.1.in: + * pp/opannotate.cpp: + * pp/opannotate_options.h: + * pp/opannotate_options.cpp: add --search-dirs + +2003-08-04 John Levon + + * doc/oprofile.xml: + * doc/opannotate.1.in: + * pp/opannotate.cpp: + * pp/opannotate_options.h: + * pp/opannotate_options.cpp: remove --source-dir and --base-dir, + they're confusing and not useful in the current form + +2003-08-03 John Levon + + * utils/opcontrol: avoid using ps, it's very slow with kallsyms + +2003-08-03 Philippe Elie + + * libutil++/op_bfd.cpp: c++ static function doesn't get a mangled name + in debug info (see gcc #11774). Try to recover through a not + completely reliable mechanism but better than ignoring the problem + +2003-08-02 Philippe Elie + + * pp/opreport.cpp: minor: more consistency about function ordering + +2003-08-02 Philippe Elie + + * libpp/profile.h: + * libpp/profile.cpp: profile::sample_count() new to allow raw access + to samples count + * pp/opreport.cpp: use above function to implement opreport (w/o -l + or --details options). opreport is roughly twice faster. + +2003-08-02 Philippe Elie + + * pp/opreport.cpp: clarify multiple counter support + +2003-08-01 John Levon + + * libregex/stl.pat.in: fix _List_iterator regex + (from Phil) + +2003-07-31 Philippe Elie + + * pp/opannotate.cpp: output cpu type and cpu speed. + +2003-07-30 John Levon + + * libpp/partition_files.cpp: remove some apparently + dead code + +2003-07-30 John Levon + + * events/i386.p4.unit_masks: make flame_uops value + mandatory, Yuan.Lu@rrze.uni-erlangen.de does not + see any events without setting the unit mask + +2003-07-30 John Levon + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: bfd_openr() keeps a copy of + the passed in char * around, sickenly enough. Ensure lifetimes + will always be correct by adding a filename data member to + op_bfd + +2003-07-29 Philippe Elie + + * libpp/op_header.h: + * libpp/op_header.cpp: separate output of cpu_type, cpu_speed + and counter setup + + * libpp/partition_files.h: + * libpp/partition_files.cpp: unmergeable_profile() split profile + by the unmergeable. + + * pp/opreport_options.h: + * pp/opreport_options.cpp: + * pp/opreport.cpp: initial multiple counter output, multiple counter + with -l is not yet available. + +2003-07-29 John Levon + + * doc/opcontrol.1.in: update for --event + +2003-07-29 John Levon + + * configure.in: + * doc/srcdoc/Doxyfile.in: + * oprof_report/: remove badly out of date oprof_report + +2003-07-28 John Levon + + * configure.in: bump to 0.7cvs + +2003-07-26 John Levon + + * configure.in: bump to 0.6 + +2003-07-26 John Levon + + * utils/opcontrol: fix call of op_help + +2003-07-26 John Levon + + * gui/oprof_start.cpp: replace folder icons with clearer + red/green circles + +2003-07-26 John Levon + + * gui/oprof_start.cpp: actually select and show the default + event + +2003-07-26 John Levon + + * gui/oprof_start.cpp: small string tweak, show "conflicts" + message consistently + +2003-07-26 John Levon + + * gui/oprof_start.cpp: don't use invalidated iterator + +2003-07-26 Philippe Elie + + * gui/oprof_start.cpp: fix for 2.91.66 + + * libpp/profile.cpp: typo invoking an undefined behavior revealed + by gcc stl debug mode + * libpp/profile.h: ensure we provide the right typedef to std:: + for profile::const_iterator revealed by gcc stl debug mode at compile + time. The implementation is a bit tricky to work with old compiler + * libpp/symbol_sort.cpp: compare must define a weak ordered relation + order, revealed by gcc stl debug mode. + +2003-07-26 Philippe Elie + + * gui/ui/oprof_start.base.ui: + * gui/oprof_start.h: + * gui/oprof_start.cpp: change UI to use the new counter allocation + API + + * libop/op_alloc_counter.h: + * libop/op_alloc_counter.c: + * utils/op_help.c: minor const-ness api change + +2003-07-25 Will Cohen + + * utils/opcontrol: Restrict the search path. + +2003-07-25 Philippe Elie + + * libop/op_alloc_counter.c: use tabulation + + * libop/op_events.c: + * libop/op_events.h: find_event_by_name() new + * utils/op_help.c: use find_event_by_name() + +2003-07-24 Philippe Elie + + * utils/op_help.c: make valgrind happy + minor cleanup + +2003-07-24 Philippe Elie + + * libop/op_alloc_counter.h: + * libop/op_alloc_counter.c: new file providing mapping from an event + list to hardware counter number + * utils/op_help.c: use the above api + +2003-07-24 Philippe Elie + + * utils/op_help.c: fix hardware counter allocation order + +2003-07-23 John Levon + + * doc/oprofile.xml: comment out --base-dir mention + +2003-07-23 John Levon + + * doc/oprofile.xml: remove mention of oprof_start_event + +2003-07-23 John Levon + + * dae/oprofiled.c: + * daemon/oprofiled.c: don't uselessly try to unlink + non-existent lockfile + + * daemon/opd_image.c: + * daemon/oprofiled.c: clean up buffer read messages + +2003-07-23 John Levon + + * utils/opcontrol: error out at --setup time if vmlinux is not + valid. Cleanup the error message if so + + * daemon/opd_kernel.c: fix potential null deref + +2003-07-21 John Levon + + * gui/oprof_start.cpp: select "No event" when switching counter + if needed + +2003-07-21 John Levon + + * gui/oprof_start.cpp: fix default event choosing when + daemonrc exists + +2003-07-21 Philippe Elie + + * gui/oprof_start.cpp: thinko in has_unique_event(), don't warn for + no counter with CPU_TIMER_INT + +2003-07-21 Philippe Elie + + * gui/oprof_start.cpp: allow to de-select a counter + +2003-07-21 John Levon + + * gui/oprof_start.cpp: + * gui/oprof_start_util.h: + * gui/oprof_start_util.cpp: remove uptime pretty printing. + It's broken for 2.5 and ugly code + +2003-07-21 John Levon + + * gui/oprof_start.h: + * gui/oprof_start.cpp: use a default event if no + events are set yet + +2003-07-20 Philippe Elie + + * m4/compileroption.m4: fix for autoconf 2.13 + +2003-07-19 Philippe Elie + + * gui/oprof_start.cpp: + * libpp/format_output.cpp: + * libpp/format_output.h: + * pp/opannotate.cpp: + * pp/opreport_options.cpp: minor tidy + +2003-07-19 Philippe Elie + + * gui/oprof_start.cpp: RTC mode was not working + +2003-07-16 Philippe Elie + + * gui/oprof_start_config.h: + * gui/oprof_start_config.cpp: remove dead code, fix kernel_only read + +2003-07-16 John Levon + + * utils/opcontrol: fix typo that was partly breaking + CPU_TIMER_INT + +2003-07-16 John Levon + + * gui/oprof_start.h: + * gui/oprof_start.cpp: fixes for CPU_TIMER_INT + +2003-07-16 John Levon + + * gui/ui/oprof_start.base.ui: remove add/remove event buttons, + fix resize weirdness + + * gui/oprof_start.h: + * gui/oprof_start.cpp: remove add/remove event buttons, allow + short-form event descriptions + +2003-07-15 Philippe Elie + + * gui/persistent_config.h: remove + * gui/oprof_start.h: + * gui/oprof_start.cpp: debug, remove dead code, works better now, see + TODO + +2003-07-15 Philippe Elie + + * gui/oprof_start.h: + * gui/oprof_start.cpp: + * gui/oprof_start_util.cpp: re-enable partially the gui, sorta of + working if cautioulsy used + +2003-07-15 John Levon + + * gui/ui/oprof_start_base.ui: + * gui/oprof_start.h: + * gui/oprof_start.cpp: some steps towards fixing gui for + the new events stuff + +2003-07-15 John Levon + + * libop/op_events.h: + * libop/op_events.c: add op_default_event + + * utils/op_help.c: move default event stuff to libop, + fix -c option + +2003-07-15 John Levon + + * utils/op_help.c: fix default RTC event to be + "RTC_INTERRUPTS" + +2003-07-15 Philippe Elie + + * utils/opcontrol + * events/rtc..events: use RTC_INTERRUPTS as event name + +2003-07-15 Philippe Elie + + * daemon/opd_sample_files.c: C89 compile fix + +2003-07-15 John Levon + + * utils/opcontrol: + * utils/op_help.c: move the default event strings into + op_help.c instead of in opcontrol + +2003-07-15 John Levon + + * doc/oprofile.xml: document event name for timer interrupt + + * daemon/opd_sample_files.c: handle CPU_TIMER_INT + + * utils/op_help.c: fix a core dump + +2003-07-13 Philippe Elie + + * daemon/opd_image.c: verbprintf() when starting reading buffer not + printf + +2003-07-12 Philippe Elie + + * from BRANCH_CALLGRAPH: + * daemon/opd_image.c: printf -> verbprintf, fix comment + * daemon/opd_kernel.c: kernel/module samples statistics was wrong + + * daemon/opd_image.c: + * daemon/opd_image.h: + * daemon/opd_kernel.c: + * daemon/opd_kernel.h: import cleanup from branch, mainly don't handle + samples in opd_kernel.c but return (creating if necessary) an + opd_image struct where the sample must go and let opd_image caller + in opd_image.c do sample insertion + +2003-07-11 Philippe Elie + + * utils/opcontrol: shows basename $0 with --version + * libpp/op_header.cpp: formating + +2003-07-11 Philippe Elie + + * utils/opcontrol: don't try to save current if the directory doesn't + exist + +2003-07-11 Philippe Elie + + * libutil++/stream_util.h: + * libutil++/stream_util.cpp: new file, io_state() save object + * libutil++/Makefile.am: handle new file + * libutil++/op_bfd.cpp: + * pp/opreport.cpp: + * libpp/op_header.cpp: use io_state + +2003-07-09 Philippe Elie + + * module/x86/op_model_p4.c: reflect intel documentation fix. + +2003-07-08 Will Cohen + + * daemon/opd_kernel.c: Handle /proc/modules format. + +2003-07-08 Will Cohen + + * doc/oprofile.xml: + * configure.in: --enable-gcov option and documentation. + +2003-07-08 Will Cohen + + * utils/opcontrol: Correct P4 default event. + +2003-06-03 John Levon + + * from BRANCH_CALLGRAPH + * libdb/odb_hash.h: + * libdb/db_manage.c: + * libdb/db_insert.c: namespace safety + + * libpp/partition_files.cpp: + * libpp/profile.cpp: spacing, add a FIXME + +2003-07-07 Philippe Elie + + * pp/opannotate.cpp: + * pp/opgprof.cpp: + * pp/opreport.cpp: cleanup walking through multimap with a + pair + +2003-07-05 Philippe Elie + + * daemon/opd_image.c: + * libdb/db_insert.c: 64 bits arch compile fix, thanks to Falk Hueffner + + +2003-07-02 Philippe Elie + + * pp/opreport.cpp: honor options::show_header + +2003-06-30 Graydon Hoare + + * libpp/op_header.cpp: Handle printing multiple bitmask values. + +2003-06-19 John Levon + + * doc/Makefile.am: fix make distcheck + +2003-06-18 John Levon + + * pp/opannotate_options.c: hide the unhandled + --base-dir option + +2003-06-18 John Levon + + * pp/Makefile.am: don't build opdiff + +2003-06-17 Will Cohen + + * daemon/opd_cookie.h: Add s390 syscall value. + +2003-06-17 John Levon + + * utils/opcontrol: don't accept "-r" - it's too easy to typo + +2003-06-17 John Levon + + * doc/srcdoc/Doxyfile: removed + + * doc/srcdoc/Doxyfile.in: + * configure.in: generate doxygen version nr. automatically + +2003-06-17 Philippe Elie + + * libdb/db_insert.cpp: missing initialization of error message on + error path + +2003-06-17 John Levon + + * utils/opcontrol: accept some short forms for common + operations + +2003-06-17 John Levon + + * utils/opcontrol: accept --foo blah as well as + --foo=blah + +2003-06-16 John Levon + + * utils/opcontrol: "opcontrol" will show usage + instead of doing nothing + +2003-06-16 Will Cohen + + * libabi/abi.cpp: + * libabi/op_import.cpp: Add required include for cassert. + +2003-06-16 John Levon + + * events/x86-64.hammer.unit_masks: remove some + bogus FIXMEs + +2003-06-15 John Levon + + * README: fix autogen.sh line + +2003-06-15 John Levon + + * daemon/opd_image.c: 64 bit fixes + +2003-06-15 John Levon + + * utils/op_help.c: c89 fix + +2003-06-15 John Levon + + * daemon/opd_image.c: c89 fix + +2003-06-15 John Levon + + * doc/oprofile.xml: document --event + + * utils/opcontrol: + * utils/op_help.c: allow unit mask, kernel, user to be + optional. Verify not too many events are passed. + +2003-06-15 John Levon + + * libop/op_cpu_type.c: fix nr_counters cpu type check + + * utils/op_help: implement --check_events, event validation + and counter allocation + + * utils/opcontrol: use the above, implement --event=default + +2003-06-14 John Levon + + * daemon/opd_image.c: fix a stupid error in my previous TGID patch + +2003-06-12 Graydon Hoare + + * libop/op_events.c (op_check_events): Check bitmasks as well as + exclusive values, for unit masks. + +2003-06-12 John Levon + + * daemon/opd_image.c: we were not handling a truncated + TGID entry properly + +2003-06-12 John Levon + + * libutil++/unique_storage.h: missing typename + +2003-06-11 Philippe Elie + + * pp/opannotate_options.cpp: typo in option name + +2003-06-11 Philippe Elie + + * libutil++/op_bfd.cpp: boring_symbol() new to get a better choice + when eliminating symbol at identical vma + +2003-06-11 Philippe Elie + + * utils/opcontrol: fix rtc option checking, bug added after 0.5.3, + no big deal + +2003-06-11 Philippe Elie + + * libregex/op_regex.cpp: + * libpp/profile.cpp: compile fix, tree was broken by my previous patch + +2003-06-11 Jason Yeh + + * events/i386.athlon.events: add CPU_CLK_UNHALTED + + * utils/opcontrol: use the above by default + + * events/x86-64.hammer.events: + * events/x86-64.hammer.unit_masks: various fixes + +2003-06-11 Philippe Elie + + * libpp/op_header.cpp: + * libpp/profile.cpp: + * libpp/profile_spec.cpp: + * libpp/symbol_sort.cpp: + * libregex/op_regex.cpp: + * libutil++/op_bfd.cpp: use exception rather exit(EXIT_FAILURE) in + library code + +2003-06-11 John Levon + + * daemon/opd_image.c: future-proof the code handlers + +2003-06-11 Philippe Elie + + * pp/opannotate.cpp: output_asm() avoid output when the set of selected + symbols doesn't contain any samples + +2003-06-11 Philippe Elie + + * libutil++/unique_storage.h: we don't need to check if key is present + before trying to insert it + +2003-06-10 Philippe Elie + + * libpp/name_storage.h: minor tidy + * libutil++/unique_storage.h: small efficiency improvement + +2003-06-09 John Levon + + * pp/Makefile.am: + * libutil/Makefile.am: fix make distcheck + +2003-06-09 John Levon + + * libpp/opp_symbol.h: rename to ... + + * libpp/symbol.h: ... this + + * libpp/Makefile.am: + * libpp/format_output.h: + * libpp/format_output.cpp: + * libpp/profile_container.h: + * libpp/profile_container.cpp: + * libpp/sample_container.h: + * libpp/sample_container.cpp: + * libpp/symbol_functors.h: + * libpp/symbol_sort.cpp: fix up from above and some header + cleanups + +2003-06-09 John Levon + + * libpp/profile.h: std::pair not pair + +2003-06-08 Philippe Elie + + * libpp/profile.cpp: don't underflow start offset when the vma range + is unknown + * pp/opreport.cpp: use samples_range() not samples_range(0, ~0) + +2003-06-08 Philippe Elie + + * libpp/profile.h: + * libpp/profile.cpp: replace accumulate_samples() API by an iterator + interface + * libpp/profile_container.h: + * libpp/profilecontainer.cpp: + * pp/opreport.cpp: use new API + +2003-06-08 Philippe Elie + + * include/sstream: replace old version by the once shipped with + 2.95.3, seekg() in the old was not working + +2003-06-08 John Levon + + * libpp/name_storage.h: don't need to define the tag structs + + * libutil++/unique_storage.h: fix the comments, + make get() public + +2003-06-08 Philippe Elie + + * libpp/profile_container.cpp: + * libutil++/string_manip.cpp: gcc 2.91.66 fix + +2003-06-08 John Levon + + * libpp/name_storage.h: + * libpp/name_storage.cpp: + * libpp/opp_symbol.h: + * libpp/profile_container.cpp: + * libpp/symbol_functors.cpp: + * libutil++/unique_storage.h: don't derive from I() + at all for id_value, it's not needed. Hide .id and + provide operator<(), operator==(), operator!=(), and + set() + +2003-06-08 John Levon + + * libutil++/unique_storage.h: make some of + id_value only visible to unique_storage. + +2003-06-08 John Levon + + * libpp/name_storage.h: + * libutil++/unique_storage.h: move the ID class + into unique_storage, and make it derive from the + template parameter, to give simpler type safe support + +2003-06-08 John Levon + + * libutil++/Makefile.am: + * libutil++/unique_storage.h: add new template for + unique storage of values + + * libpp/name_storage.h: + * libpp/name_storage.cpp: use it + +2003-06-07 Philippe Elie + + * libpp/profile_container.cpp: fix order of file output with opannotate + --source to be consistent with other tools + +2003-06-07 John Levon + + * libpp/profile_container.cpp: fix operator< + +2003-06-07 Philippe Elie + + * libpp/profile.h: + * libpp/profile.cpp: change API to walk through vma with non zero + samples count rather looking for all vma. This is not very clean, an + iterator interface will be perhaps a better idea. Measures shows it's + to do it so for now I apply it. + * libpp/profile_container.cpp: update according to above change. + +2003-06-07 Philippe Elie + + * libpp/profile_container.h: + * libpp/profile_container.cpp: + * libpp/symbol_container.h: + * libpp/symbol_container.cpp: remove dead api + find_symbol(string symbol_name) + +2003-06-07 Philippe Elie + + * libpp/name_storage.h: + * libpp/name_storage.cpp: + * libpp/profile_container.cpp: + * libpp/profile_container.h: + * libpp/sample_container.h: + * libpp/sample_container.cpp: + * libpp/symbol_container.h: + * libpp/symbol_container.cpp: + * pp/opannotate.cpp: replace some use of string filename by + debug_name_id + +2003-06-05 John Levon + + * daemon/Makefile.am: + * daemon/opd_kernel.c: + * daemon/p_module.h: remove p_module.h, unused + + * daemon/opd_cookie.h: use __NR_lookup_dcookie and + use our definitions only if it's not defined + + * daemon/opd_image.c: + * daemon/opd_kernel.c: + * daemon/opd_sample_files.c: + * daemon/oprofiled.c: pedantry + + * libabi/op_import.cpp: + * libabi/abi_test.cpp: fix build from odb change + + * libop/op_config.h: move NR_CPUS to ... + + * libop/op_config_24.h: ... here + + * libop/op_hw_config.h: remove unused OP_COUNT_MAX + +2003-06-03 Philippe Elie + + * libpp/op_header.cpp: + * libpp/profile.cpp: + * dae/opd_proc.c: + * dae/opd_sample_files.c: + * daemon/opd_image.c: + * daemon/opd_sample_files.c: + * libdb/odb_hash.h: + * libdb/db_insert.c: + * libdb/db_manage.c: + * libdb/db_test.c: error message is now a field of a samples_odb_t + +2003-06-03 John Levon + + * libutil++/child_reader.cpp: + * libabi/abi.cpp: + * libabi/abi.h: + * libabi/abi_test.cpp: + * libabi/op_api.h: + * libabi/op_abi.cpp: + * libabi/op_import.cpp: pedantry, remove unused code + +2003-06-01 Philippe Elie + + * dae/oprofiled.c: + * libop/oprofiled.c: + * libop/op_cpu_type.c: + * module/oprofile.c: + * module/oprofile.h: + * pp/opdiff.cpp: more static data and function + +2003-05-31 Philippe Elie + + * gui/oprof_start_util.h: + * libdb/db_stat.c: + * libdb/odb_hash.h: + * libpp/format_output.h: + * libpp/locate_image.h: + * libpp/name_storage.h: + * libpp/partition_files.h: + * libpp/profile.h: + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: improve doxygen comment + +2003-05-31 Philippe Elie + + * configure.in: use AC_DEFINE_UNQUOTED() to define version string + in config.h not in version-1.h + * Makefile.am: distclean-local: is no longer used + * version-1.h.in: delete + * libutil/op_version.h: + * libutil/op_version.c: new file: package version output + * libutil/Makefile.am: + * dae/oprofiled.c: + * daemon/oprofiled.c: + * gui/oprof_start.h: + * libop/op_events.c: + * libopt++/popt_options.cpp: + * libregex/demangle_sybol.cpp: + * module/oprofile.c: + * utils/op_help.c: tweak # include according + +2003-05-30 Dan Zink + + * module/x86/op_apic.c: really disable the apic if it was disabled + +2003-05-29 John Levon + + * utils/opcontrol: don't allow --rtc-value if not RTC mode + +2003-05-27 John Levon + + * libutil++/string_manip.h: add + + * pp/opannotate.cpp: use '\n' not endl + + * pp/opreport.cpp: untie cout + +2003-05-29 Philippe Elie + + * merge with pp-interface-branch: following ChangeLog was unmerged + to branch + + 2003-05-27 John Levon + + * configure.in: oprofile 0.5.3 is released, back to + 0.6cvs + + 2003-05-26 John Levon + + * doc/oprofile.xml: update docs for --no-vmlinux + + 2003-05-26 John Levon + + * libop/op_interface_25.h: + * daemon/opd_image.c: handle tgid for future + compatibility, fix compile on older gccs + + 2003-05-26 John Levon + + * libop/op_interface_25.h: add LAST_CODE + + * daemon/opd_stats.h: + * daemon/opd_stats.c: count short reads of + buffer and unplaceable samples + + * daemon/opd_image.c: rewrite buffer parsing + code, handle window where we can't place a + sample + + 2003-05-26 John Levon + + * libutil++/utility.h: fix typo + + * utils/opcontrol: fix typo + + 2003-05-16 John Levon + + * pp/counter_profile.cpp: remove bogus cpu speed + consistency check + + 2003-05-09 John Levon + + * m4/Makefile.am: + * m4/compileroption.m4: add a generalised compiler option + tester + + * configure.in: use it, add -fno-common + + 2003-05-09 John Levon + + * daemon/oprofiled.c: + * dae/oprofiled.c: remove duplicate declaration found + via -fno-common + + 2003-05-04 John Levon + + * doc/oprofile.xml: fix validation errors from xmllint --valid + + +2003-05-28 Philippe Elie + + * libpp/profile_spec.cpp: make image:/path/to:image working + +2003-05-28 Philippe Elie + + * libutil++/string_manip.h: + * libutil++/string_manip.cpp: specialize + lexical_cast_no_ws to accept hexadecimal input + + * pp/common_option.cpp: missing << endl + +2003-05-27 Philippe Elie + + * doc/oprofile.xml: update example in "Interpreting profiling results" + section + +2003-05-26 John Levon + + * doc/oprofile.xml: add new pp tools options + +2003-05-26 John Levon + + * doc/opreport.1.in: + * doc/opgprof.1.in: + * doc/opannotate.1.in: + * doc/op_help.1.in: complete + +2003-05-26 John Levon + + * configure.in: + * doc/Makefile.am: + * doc/oprofile.1.in: + * doc/op_help.1.in: + * doc/opcontrol.1.in: + * doc/opreport.1.in: + * doc/opannotate.1.in: + * doc/opgprof.1.in: re-organise and add manpages + +2003-05-26 John Levon + + * doc/oprofile.xml: start to document the pp interface + +2003-05-26 Philippe Elie + + * pp/opreport.cpp: remove automatic switch to --symbols mode + +2003-05-26 Philippe Elie + + * libpp/symbol_sort.h: + * pp/opannotate_options.cpp: + * pp/opgprof_options.cpp: + * pp/opreport_options.cpp: handle meaningless options combinations + +2003-05-26 Philippe Elie + + * pp/opgprof_options.cpp: no need to use unmergeable_profile here + +2003-05-25 Philippe Elie + + * events/i386.piii.unit_masks: tweak comment, change default unit mask + for kni instruction to 0 and type to exclusive + +2003-05-25 Philippe Elie + + * libpp/profile_container.cpp: thinko + * pp/opreport.cpp: typo + +2003-05-25 John Levon + + * libopt++/popt_options.h: + * libopt++/popt_options.cpp: obvious cleanup, + remove some dead code + +2003-05-25 Philippe Elie + + * libpp/format_flags: cf_image_name new column_flags flag + * libpp/profile_container.cpp: use above flag. Don't compare app_name + by string but id + * pp/opreport.cpp: hide image_name when un-necessary + +2003-05-24 Philippe Elie + + * doc/srcdoc/Doxyfile: + * libpp/profile.h: + * libpp/profile_container.h: + * libutil++/utility.h: remove gcc 2.91 noncopyable as empty base class + work-around + +2003-05-23 Philippe Elie + + * configure.in: do early check of libiberty + + * libpp/symbol_sort.cpp: 2.91 compile fix + +2003-05-22 Philippe Elie + + * libutil++/child_reader.h: minor #include fix + +2003-05-22 Philippe Elie + + * libpp/name_storage.cpp: debug_name_storage::name() + return an empty string when for zero id to avoid exception + +2003-05-21 Philippe Elie + + * libpp/profile.cpp: + * libpp/op_header.h: + * libpp/op_header.cpp: when sample file differ output the sample + filename + + * pp/opannotate.cpp: remove spurious output + + * */Makefile.am: + * configure.in: handle our own OP_CFLAGS, OP_CXXFLAGS to let user + free to use make CFLAGS= + +2003-05-20 Philippe Elie + + * libpp/profile_spec.h: + * libpp/profile_spec.cpp: remove lib_image_exclude, use image_exclude + instead. match() Handle image exclusion. + + * libregex/stl.pat.in: FIXME + + * libutil++/string_manip.h: compile fix + +2003-05-19 John Levon + + * libutil++/comma_list.h: + * libpp/filename_spec.cpp: + * libutil++/string_manip.h: + * libutil++/generic_spec.h: rename strict_convert<> + to lexical_cast_no_ws<> + +2003-05-19 John Levon + + * libutil++/generic_spec.h: move strict_convert<> to... + + * libutil++/string_manip.h: ...here + +2003-05-19 John Levon + + * libutil++/generic_spec.h: comma_list isn't a friend + any more + + * libutil++/comma_list.h: use generic_spec<>::match() + directly + +2003-05-19 John Levon + + * libpp/name_storage.h: s/name_map/stored_names/, it's not + a map any more. + +2003-05-19 Philippe Elie + + * libregex/mangled-name.txt: + * libregex/stl.pat.in: partial handling of _Identity<> and + _Select1st<>, pattern fail if type are too complex + +2003-05-19 Philippe Elie + + * libpp/format_output.cpp: small cleanup + + * libpp/name_storage.h: + * libpp/name_storage.cpp: ensure type safety by providing distinct + type identifier for each name_storage based container + + * libpp/profile_container.cpp: + * libpp/sample_container.cpp: + * libpp/symbol_functors.cpp: + * libpp/symbol_sort.cpp: + * libpp/opp_symbol.h: use the name identifier api + + * libpp/op_header.cpp: + * libpp/partition_files.cpp: use a set not a name_storage + + * libpp/format_output.cpp: small cleanup + + +2003-05-18 Philippe Elie + + * libpp/partition_files.cpp: merge partition entry when necessary + fixing a corner case when a binary can be a dependent or a primary + image and was not merged + +2003-05-18 Philippe Elie + + * pp/opreport_options.cpp: + * pp/opannotate_options.cpp: remove conflicting options shortcut + +2003-05-18 Philippe Elie + + * libregex/stl.pat.in: add list::{const_}+iterator + +2003-05-17 Philippe Elie + + * libpp/name_storage.cpp: basename() return an empty string for nil id + +2003-05-17 Philippe Elie + + * libutil++/op_bfd.cpp: get_linenr() init linenr to zero + + * libpp/name_storage.cpp: don't use id zero + * libpp/opp_symbol.h: now we use id and not string we must provide + default ctor to initialize the id + * libpp/profile_container.cpp: init debug info entry only if + get_linenr() succeed + +2003-05-17 Philippe Elie + + * libdb/db_manage.c: better handling of zero sample file size when + opening in read only mode + + * module/x86/op_nmi.c: printk format fix + +2003-05-17 John Levon + + * pp/opannotate_option.cpp: + * pp/opreport_options.cpp: command line changes + +2003-05-17 John Levon + + * libpp/name_storage.h: + * libpp/name_storage.cpp: add present() + + * libpp/op_header.cpp: + * libpp/partition_files.cpp: use a name store + to track what we've warned about, and clean up + the warnings a bit + +2003-05-16 John Levon + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: expose anonymous symbols + to the world as "??sectionname". Useful for .plt + and .fini, which are quite common. + + * libpp/name_storage.cpp: demangle anonymous symbols + nicely. + +2003-05-16 John Levon + + * libpp/symbol_sort.cpp: fix image-sorting + +2003-05-16 John Levon + + * libpp/name_storage.h: + * libpp/name_storage.cpp: make ID be per-container + +2003-05-16 John Levon + + * libpp/name_storage.h: + * libpp/name_storage.cpp: merge processed names + into one string, remove the boolean + +2003-05-16 John Levon + + * libpp/name_storage.h: + * libpp/name_storage.cpp: whoops, use string + not stored_name for the ID map + +2003-05-16 John Levon + + * libpp/name_storage.h: + * libpp/name_storage.cpp: split into three + stores for debug filenames, symbols, and images + + * libpp/format_output.cpp: + * libpp/profile_container.cpp: + * libpp/sample_container.cpp: + * libpp/symbol_container.cpp: + * libpp/symbol_sort.cpp: + * pp/opannotate.cpp: changes from above + +2003-05-16 John Levon + + * libpp/Makefile.am: + * libpp/name_storage.h: + * libpp/name_storage.cpp: add shared storage + and caching of symbol and file names + + * libpp/opp_symbol.h: + * libpp/format_output.cpp: + * libpp/profile_container.cpp: + * libpp/sample_container.cpp: + * libpp/symbol_container.cpp: + * libpp/symbol_container.h: + * libpp/symbol_sort.cpp: + * libpp/symbol_sort.h: + * pp/opannotate.cpp: + * pp/opreport.cpp: use it + + * pp/opgprof_options.cpp: add unused demangle + options to hack-fix the build + +2003-05-16 John Levon + + * libpp/symbol_sort.cpp: fix --sort debug + +2003-05-16 John Levon + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: remove have_debug_info() + +2003-05-16 Philippe Elie + + * libpp/op_header.cpp: remove cpu_speed checking + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: bail out in get_linenr() if binary doesn't + contain any debug info. Speed up my test case opreport --debug-info + -l by 25 + +2003-05-16 John Levon + + * libutil++/op_bfd.cpp: clean up interesting_symbol + a bit + +2003-05-16 John Levon + + * libutil++/op_bfd.cpp: make sure linenr is + always set to something + + * libpp/opp_symbol.h: linenr should be unsigned + + * libpp/profile_container.cpp: remove some unneeded + copies + +2003-05-16 John Levon + + * pp/opannotate.cpp: small renaming + +2003-05-15 John Levon + + * libpp/symbol_container.h: + * libpp/symbol_container.cpp: add begin(), end(), + remove symbols_by_count() + + * libpp/profile_container.cpp: use symbol container + iterator directly in select_symbols() + +2003-05-15 John Levon + + * libpp/format_output.h: + * libpp/format_output.cpp: + * libpp/profile_container.h: + * libpp/profile_container.cpp: + * libpp/symbol_container.h: + * libpp/symbol_container.cpp: + * libpp/symbol_sort.h: + * libpp/symbol_sort.cpp: + * pp/opannotate.cpp: + * pp/opreport.cpp: + * pp/opgprof.cpp: move symbol_collection typedef + into global namespace, and use consistently + +2003-05-15 John Levon + + * libpp/format_output.h: + * libpp/format_output.cpp: add vma_format_64bit(), + remove bool parameter from output() + + * pp/opreport.cpp: change from above, refactor flags + code into get_format_flags() helper + +2003-05-12 Philippe Elie + + * libpp/format_output.h: + * libpp/format_output.cpp: + * libpp/symbol_sort.h: + * libpp/symbol_sort.cpp: handle reverse sort in sorting not in output + * pp/opannotate.cpp: + * pp/opreport.cpp: update according + +2003-05-12 Philippe Elie + + * libpp/symbol_sort.h: + * libpp/symbol_sort.cpp: handle sort order as specified on command line + + * pp/opgprof.cpp: sort symbol is not necessary for gprof + * pp/opreport.cpp: + * pp/opreport_options.cpp: + * pp/opannotate.cpp: use new sort API + +2003-05-12 John Levon + + * libpp/symbol_sort.h: + * libpp/symbol_sort.cpp: partial implementation + of other sort options + +2003-05-12 John Levon + + * libpp/Makefile.am: + * libpp/symbol_sort.h: + * libpp/symbol_sort.cpp: add sorting code + + * symbol_functors.h: move some less() into + symbol_sort.cpp + + * libpp/profile_container.h: + * libpp/profile_container.cpp: don't pass in + sort option to select_symbols(), do it in caller + + * pp/opannotate.cpp: + * pp/opgprof.cpp: + * pp/opreport.cpp: + * pp/opreport_options.h: + * pp/opreport_options.cpp: from the above + +2003-05-12 John Levon + + * format_flags.h: remove vma64_p. Add column_flags + + * libpp/profile_container.h: + * libpp/profile_container.cpp: pass in a struct + to select_symbols. Generate hints for 64-bit VMA + and multiple apps in the profile. + + * pp/opannotate.cpp: + * pp/opgprof.cpp: + * pp/opreport.cpp: use the above + +2003-05-12 John Levon + + * libpp/format_output.cpp: + * libpp/format_flags.h: + * pp/opreport.cpp: trivial renaming of flags + +2003-05-11 John Levon + + * libpp/format_output.cpp: + * libpp/format_flags.h: better output for + the default of short filenames + +2003-05-11 John Levon + + * pp/opreport.cpp: improve the app/image name column + showing a bit + +2003-05-11 John Levon + + * pp/opreport.cpp: default to -l if we were just + going to show one image summary. + +2003-05-11 John Levon + + * pp/opreport.cpp: move some code around that + outputs the image summaries + +2003-05-11 John Levon + + * libpp/format_output.h: + * libpp/format_output.cpp: + * pp/opreport.cpp: + * pp/opreport_options.h: + * pp/opreport_options.cpp: s/--short-filename/--long-filenames/ + +2003-05-11 John Levon + + * libpp/profile_spec.h: + * libpp/profile_spec.cpp: take exclude_dependent not + include_dependent + + * pp/opannotate_options.c: + * pp/opgprof_options.c: + * pp/opreport_options.h: + * pp/opreport_options.c: change to use exclude_dependent, + remove --hide-dependent + +2003-05-11 John Levon + + * locate_images.h: + * locate_images.cpp: extra_images can now use + relative paths for its search dirs. Move most of + the warnings out of find_image_path, and make it + also handle relative paths. Return the file + even if it wasn't readable. + + * libpp/partition_files.cpp: give warnings when + necessary. + + * libpp/profile_spec.h: + * libpp/profile_spec.cpp: handle relative paths + inside image specs, as stated in pp_interface; also + use the extra images search path for resolution. + + * pp/opannotate_options.cpp: + * pp/opreport_options.cpp: + * pp/opgprof_options.cpp: changes from above + +2003-05-11 John Levon + + * libpp/format_flags.h: source doc improvements + +2003-05-11 John Levon + + * libpp/opp_symbol.h: move vma64_p to ... + + * libpp/format_flags.h: ... here + +2003-05-11 John Levon + + * libpp/Makefile.am: + * libpp/outsymbflags.h: + * libpp/format_flags.h: + * libpp/profile_container.h: + * libpp/format_output.h: + * libpp/format_output.cpp: + * pp/opreport.cpp: rename outsymbflags to format_flags + +2003-05-11 John Levon + + * profile_container.h: + * profile_container.cpp: + * opannotate.cpp: clean up select_filename() in a + similar fashion + +2003-05-11 John Levon + + * libpp/profile_container.h: + * libpp/profile_container.cpp: + * pp/opreport.cpp: + * pp/opannotate.cpp: + * pp/opgprof.cpp: another select_symbols() API cleanup + +2003-05-11 John Levon + + * pp/opgprof.cpp: use select_symbols so we can + handle --threshold + +2003-05-11 Philippe Elie + + * pp/opannotate.cpp: use threshold for source output + +2003-05-11 John Levon + + * pp/common_option.h: + * pp/common_option.cpp: + * pp/opannotate_options.cpp: + * pp/opreport_options.cpp: make --threshold + be a common option. + +2003-05-11 John Levon + + * pp/profile_container.h: + * pp/profile_container.cpp: + * pp/opannotate.cpp: + * pp/opreport.cpp: clean up select_symbols + interface + +2003-05-11 John Levon + + * pp/opreport.cpp: make --threshold work for + image summaries too + +2003-05-11 John Levon + + * pp/opreport_options.cpp: fix --threshold + description to match reality + +2003-05-11 John Levon + + * libpp/partition_files.h: + * libpp/partition_files.cpp: + * pp/opannotate_options.cpp: + * pp/opgprof_options.cpp: + * pp/opreport.cpp: + * pp/opreport_options.cpp: rename merge_by members + +2003-05-11 John Levon + + * pp/opreport.cpp: add some logic to not output + duplicate lines for dep images when we've already + shown all the possible details in the main image summary + +2003-05-11 John Levon + + * pp/common_option.h: use std:: + +2003-05-11 Philippe Elie + + * pp/opreport_options.cpp: move handle_threshold() + * pp/common_option.h: + * pp/common_option.cpp: here + * pp/opannotate_options.h: + * pp/opannotate_options.cpp: + * pp/opannotate.cpp: handle --threshold + +2003-05-10 John Levon + + * libop/op_mangle.h: + * libop/op_mangle.c: use a temp struct for + passing the mangle parameters with a set of + flags. + + * dae/opd_sample_files.c: + * daemon/opd_sample_files.c: use it + +2003-05-10 John Levon + + * Makefile.am: + * HACKING: + * libop++/: + * pp/Makefile.am: + * libpp/Makefile.am: + * libpp/op_header.h: + * libpp/op_header.cpp: remove libop++ after + moving op_header into libpp + +2003-05-10 John Levon + + * libop++/op_header.cpp: make CPU info take up + one line not two + +2003-05-10 John Levon + + * libop++/Makefile.am: + * libop++/op_header.cpp: + * libop++/op_print_event.h: + * libop++/op_print_event.cpp: remove op_print_event + files, making it a function local to op_header.cpp + +2003-05-10 John Levon + + * libop++/op_header.h: + * libop++/op_header.cpp: make output_header() be + an operator<< + + * pp/opannotate.cpp: + * pp/opreport.cpp: changes from the above + + * libpp/profile.h: small cleanup + +2003-05-10 Philippe Elie + + * libutil++/string_manip.h: + * libutil++/string_manip.cpp: replace format_percent() by + format_double() + + * libpp/format_output.cpp: + * pp/opannotate.cpp: + * pp/opreport.cpp: use format_double() + +2003-05-09 John Levon + + * libpp/opp_symbol.h: app name, image name should + be in symbol not in file_location + + * libpp/format_output.cpp: + * libpp/profile_container.h: + * libpp/profile_container.cpp: + * libpp/symbol_container.cpp: + * libpp/symbol_functors.cpp: changes from above + +2003-05-09 John Levon + + * libpp/format_output.h: + * libpp/format_output.cpp: vma_64 doesn't need + to be in field_datum. make one output() private + +2003-05-09 John Levon + + * libpp/format_output.h: + * libpp/format_output.cpp: pass a symbol ref + not name down into the formatters + +2003-05-09 John Levon + + * libutil++/string_manip.h: + * libutil++/string_manip.cpp: sample_filename() is unused + +2003-05-09 Philippe Elie + + * libop++/op_header.h: + * libop++/op_header.cpp: read_header() new + * libop++/Makefile.in: we depend on libdb + + * pp/opannotate.cpp: + * pp/opreport.cpp: better way to get sample file header + +2003-05-09 Philippe Elie + + * libpp/format_output.cpp: remove redundant map formater + * pp/opannotate.cpp: spurious cout + +2003-05-08 John Levon + + * pp/opreport.cpp: + * pp/opreport_options.cpp: + * pp/opreport_options.h: clean up cout stuff as + suggested by Phil + +2003-05-08 John Levon + + * libpp/profile_spec.h: + * libpp/profile_spec.c: rename the set_p variables, + remove pointless is_empty() function + + * pp/opreport.cpp: split collation and output into + two separate functions. Rename the temporary structures + so it's hopefully a bit more obvious what's happening. + Add sourcedocs. + +2003-05-08 John Levon + + * pp/opreport_options.h: + * pp/opreport_options.cpp: add options::cout, + --output-file option + + * pp/opreport.cpp: use options::cout + +2003-05-08 John Levon + + * pp/format_output.cpp: fix cumulative column widths + +2003-05-08 John Levon + + * opreport_options.h: add accumulated + + * opreport.cpp: handle --accumulated + +2003-05-08 Philippe Elie + + * libpp/symbol_container.cpp: minor tidy + + * libpp/profile.h: + * libpp/profile.cpp: allow to cumulate sample file + * libpp/profile_container.h: + * libpp/profile_container.cpp: remove free function add_samples() + + * pp/annotate.cpp: + * pp/opgprof.cpp: + * pp/opreport.cpp: when possible cumulate samples into a profile_t + first before cumulating them in a profile_container + +2003-05-07 John Levon + + * pp/opannotate.cpp: small cleanup + +2003-05-07 John Levon + + * pp/opreport_options.cpp: remove unneeded include + +2003-05-07 John Levon + + * libpp/Makefile.am: + * libpp/parse_cmdline.h: + * libpp/parse_cmdline.cpp: rename to ... + + * libpp/profile_spec.h: + * libpp/profile_spec.cpp: this. Make handle_nonoptions() + be a static factory create() method instead. Make + select_sample_filenames() be a member generate_file_list() + instead. Concomitant cleanups. + + * libpp/filename_spec.h: + * pp/opannotate_options.cpp: + * pp/opgprof_options.cpp: + * pp/opreport_options.cpp: changes from above + +2003-05-07 John Levon + + * libpp/profile.cpp: fix stupid error in last commit + +2003-05-07 John Levon + + * libpp/profile.h: + * libpp/profile.cpp: remove sample_filename member, + bogus old spurious check, set_start_offset(). + + * libpp/profile_container.cpp: + * pp/opannotate.cpp: + * pp/opreport.cpp: changes from above + +2003-05-07 John Levon + + * libpp/derive_files.h: + * libpp/derive_files.cpp: rename files as ... + + * libpp/locate_images.h: + * libpp/locate_images.cpp: this. + + * libpp/Makefile.am: + * libpp/partition_files.h: + * pp/common_option.h: + * pp/opgprof.cpp: + * pp/opgprof_options.h: + * pp/opreport_options.h: changes from above + +2003-05-07 John Levon + + * libpp/derive_files.h: + * libpp/derive_files.cpp: rework into extra_images + class + + * libpp/partition_files.h: + * libpp/partition_files.cpp: + * pp/common_option.h: + * pp/common_option.cpp: + * pp/opannotate.cpp: + * pp/opgprof.cpp: + * pp/opreport.cpp: use the above + +2003-05-07 John Levon + + * libpp/Makefile.am: + * session.h: + * session.cpp: remove session.{h,cpp} + +2003-05-07 Philippe Elie + + * pp/oprofpp.cpp pp/oprofpp_options.cpp pp/oprofpp_options.h: + * pp/op_time.cpp pp/op_time_options.cpp pp/op_time_options.h: + * pp/op_to_source.cpp pp/op_to_source_options.cpp: + * pp/op_to_source_options.h pp/op_merge.cpp: removed files + + * pp/Makefile.am: update + +2003-05-06 Philippe Elie + + * pp/opgprof.cpp: infamous typo + + * pp/opannotate.cpp: output sample file header + + +2003-05-06 Philippe Elie + + * libpop++/op_mangling.h: + * libpop++/op_mangling.cpp: removed file + * libop++/op_header.h: + * libop++/op_header.cpp: new file, misc function acting on sample + file header stolen from libpp/profile.(cpp|h) + * libop++/op_print_event.h: typo + * libop++/op_print_event.cpp: save/restore ostream state + * libop++/Makefile.am: update + + * libop/op_sample_file.h: remove dead #define OPD_MANGLE_CHAR + + * libpp/profile.h: + * libpp/profile.cpp: move some member function to free function in + libop++/op_header.(cpp|h) + * libpp/profile_container.cpp: minor call change + + * libpp/Makefile.am: op_merge can't be compiled currently inhibit build + + * libpp/opreport.cpp: output sample file header + +2003-05-06 Philippe Elie + + * libutil++/path_filter.h: default param to empty string not "*" + + * libpp/symbol_functors.h: remove dead code + + * pp/opgprof.cpp: off by one in histsize calculation + +2003-05-04 Philippe Elie + + * libutil/op_file.h: + * libutil/op_file.c: sanitize create_path() + + * libutil++/path_filter.h: default ctor match all + + * libpp/profile_container.h: + * libpp/profile_container.cpp: + * libpp/sample_container.h: + * libpp/sample_container.cpp: + * libpp/symbol_container.h: + * libpp/symbol_container.cpp: extend api to allow selecting symbol + restricted to one application, ditto for retrieving samples + + * pp/opannotate_options.h: + * pp/opannotate_options.cpp: + * pp/opannotate.cpp: implement + + * pp/opgprof_options.h: + * pp/opgprof_options.cpp: + * pp/opreport_options.h: + * pp/opreport_options.cpp: comment fix + + * pp/opreport.cpp: update to match new profile_container api + +2003-05-03 Philippe Elie + + * pp/opreport.cpp: don't show dependent file if !--include-dependent + +2003-05-02 Philippe Elie + + * libpp/partition_files.h: + * libpp/partition_files.cpp: sort_by_image_name() new return a list + of sample filename sorted by bfd image name. + * libpp/profile_container.cpp: add_samples() don't build op_bfd object + used here but pass it as parameters + + * pp/opgprof.cpp: + * pp/opreport.cpp: use the above change to avoid opening multiple time + a bfd object. + + * pp/opannotate_options.cpp: add --(include|exclude)-symbols + + * libpp/parse_cmdline.cpp: + * pp/opgprof_options.cpp: + * pp/opreport.cpp: make a distinction in error message between no + sample available and sample file available but no one was selected + +2003-05-01 Philippe Elie + + * pp/opannotate_options.h: + * pp/opannotate_options.cpp: + * pp/opdiff.cpp: + * pp/opdiff_options.h: + * pp/opdiff_options.cpp: + * pp/opgprof.cpp: + * pp/opgprof_options.h: + * pp/opgprof_options.cpp: + * pp/opreport.cpp: + * pp/opreport_options.h: + * pp/opreport_options.cpp: move common options handling ... + * pp/common_option.h: + * pp/common_option.cpp: here + + * pp/opannotate.cpp: add options + + * libpp/parse_cmdline.cpp: #include ... + +2003-05-01 Philippe Elie + + * libpp/counter_util.h: + * libpp/counter_util.cpp: remove these files from cvs + + * libpp/derive_files.h: + * libpp/derive_files.cpp: remove dead code derive_files() + typo + + * libpp/parse_cmdline.cpp: select_sample_filename() throw if empty + session after filtering + + * pp/common_option.cpp: catch invalid_argument, return failure on + catched exception + +2003-05-01 Philippe Elie + + * libutil++/op_bfd.cpp: remove _init from excluded symbol + * libpp/profile_container.cpp: tidy + + * pp/opgprof.cpp: fix capping samples + +2003-04-30 John Levon + + * pp/opgprof.cpp: + * pp/opgprof_options.cpp: + * libpp/profile.cpp: tiny cleanups, fix compile + +2003-04-30 Philippe Elie + + * libdb/db_stat.c: minor improvement to stat, useful to track missed + sample by our tools. + + * pp/op_report.cpp: move matching_sample_filename() to ... + * libpp/parse_cmdline.h: + * libpp/parse_cmdline.cpp: here renamed select_sample_filename() + + * libpp/profile_container.h: + * libpp/profile_container.cpp: expose begin() / end() from + sample_container + + * pp/common_option.h: + * pp/common_option.cpp: move option which was not really common to .. + * pp/opreport_options.h: + * pp/opreport_options.cpp: here + * pp/opannotate_options.h: + * pp/opannotate_options.cpp: and here + + * pp/operport.cpp: + * pp/opannotate.cpp: better to return a value from main() ... + + * pp/opgprof_options.h: + * pp/opgprof_options.cpp: + * pp/opgprof.cpp: implement opgprof + +2003-04-29 Philippe Elie + + * libpp/parse_cmdline.h: + * libpp/parse_cmdline.cpp: handle opreport /lib/libc-2.2.5.so, now + non tag, non option argument match either an image name or lib name + +2003-04-29 John Levon + + * libutil++/op_bfd.cpp: remove "static " inside anon namespace + +2003-04-28 Philippe Elie + + * libpp/format_output.h: + * libpp/format_output.cpp: need header tweaking + + * pp/opannotate.cpp: + * pp/opgprof.cpp: minor tidy + + * pp/opreport_options.h: + * pp/opreport_options.cpp: + * pp/opreport.cpp: handle -no-header and --image-path + +2003-04-28 Philippe Elie + + * libutil++/glob_filter.cpp: + * libutil++/path_filter.cpp: + * libutil++/string_filter.cpp: #include + +2003-04-28 John Levon + + * libutil++/string_filter.cpp: + * libutil++/string_filter.h: + * libutil++/glob_filter.h: + * libutil++/glob_filter.cpp: + * libutil++/path_filter.h: + * libutil++/path_filter.cpp: use std::find[_if], + share some code + +2003-04-28 Philippe Elie + + * libutil++/op_bfd.cpp: replace a loop by a std::copy() + +2003-04-28 John Levon + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: cleanup of last fix + +2003-04-28 John Levon + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: make symbol filtering + happen *after* adding of artificial symbol + +2003-04-28 John Levon + + * libutil++/string_filter.cpp: + * libutil++/glob_filter.cpp: + * libutil++/path_filter.cpp: match as true if + include_list is empty and not excluded + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: use string_filter to + filter symbols + + * libpp/profile_container.h: + * libpp/profile_container.cpp: + * pp/opreport_options.h: + * pp/opreport_options.cpp: + * pp/opreport.cpp: changes from using string_filter + +2003-04-28 Philippe Elie + + * pp/opreport.cpp: finish to remove use of split_sample_filename + +2003-04-28 John Levon + + * libutil++/filename_match.h: + * libutil++/filename_match.cpp: replace with ... + + * libutil++/Makefile.am: + * libutil++/string_filter.h: + * libutil++/string_filter.cpp: + * libutil++/glob_filter.h: + * libutil++/glob_filter.cpp: + * libutil++/path_filter.h: + * libutil++/path_filter.cpp: .. split up variants + of the filters + + * libpp/parse_cmdline.cpp: use glob_filter + + * pp/op_to_source.cpp: use path_filter + +2003-04-28 Philippe Elie + + * libpp/partition_files.h: + * libpp/partition_files.cpp: + * libpp/split_sample_filename.h: + * libpp/split_sample_filename.cpp: + * pp/opreport.cpp: replace some use of std::string sample_filename + by a split_sample_filename struct + +2003-04-28 John Levon + + * libutil++/filename_match.h: + * libutil++/filename_match.cpp: use file-scope + not private static member function + +2003-04-27 Philippe Elie + + * libpp/format_output.h: + * libpp/format_output.cpp: remove all string based output format flag + + * libpp/format_output.cpp: move options::demangle handling ... + * libregx/demangle_symbol.cpp: here + + * libpp/profile_container.h: + * libpp/profile_container.cpp: + * pp/opreport_options.h: + * pp/opreport_options.cpp: + * pp/opreport.cpp: handle --include-symbols + +2003-04-27 Philippe Elie + + * pp/opreport_options.h: + * pp/opreport_options.cpp: + * pp/opreport.cpp: handle --threshold, remove --ignore-symbols + +2003-04-27 John Levon + + * libpp/: minor spacing etc. + +2003-04-27 Philippe Elie + + * libpp/outsymbflag.h: remove osf_short_xxx variant + * libpp/format_output.h: + * libpp/format_output.cpp: replace osf_short_xxx by a boolean + * libpp/profile_container.cpp: update according + + * pp/opreport_options.h: export short_filename option + * pp/opreport.cpp: use short_filename + +2003-04-27 Philippe Elie + + * libpp/symbol_functors.h: add less_symbol predicate + * libpp/symbol_functors.cpp: new file, less_symbol implementation + * libpp/Makefile.am: symbol_functors.cpp + + * libpp/symbol_container.h: + * libpp/symbol_container.cpp: use a node based container for symbols + ensuring validity of symbol pointer over a symbol_container life time + * libpp/sample_container.h: + * libpp/sample_container.cpp: ditto as above for samples + * libpp/profile_container.h: + * libpp/profile_container.cpp: use this new api to merge symbols + and sample. + + * libpp/format_output.h: + * libpp/format_output.cpp: use new api to iterate over sample by symbol + + * pp/opreport.cpp: detailed output + + +2003-04-27 John Levon + + * pp/opreport.cpp: make opreport -l put largest results + at the top like opreport does + +2003-04-26 Philippe Elie + + * libpp/profile_container.h: comment + + * pp/opreport_options.h: more options export + * pp/opreport.cpp: implement -l. Doesn't works correctly: --merge=lib + +2003-04-25 Philippe Elie + + * pp/opreport_options.h: export global_percent + * pp/opreport.cpp: finish to implement op_time like behavior. Remains + to implement op_time -l + +2003-04-25 Philippe Elie + + * libpp/partition_files.cpp: fix a crash when profile spec is empty + + * pp/opreport_options.cpp: bail out if no samples files are found + +2003-04-25 John Levon + + * pp/opreport_options.cpp: --hide-dependent should have 'h' as + short form. Add a FIXME for a crash + +2003-04-25 Philippe Elie + + * libpp/partition_files.cpp: thinko in sample filename partition + + * pp/opreport_options.h: export more options + * pp/opreport_options.cpp: add --hide-dependent, change --merge to not + default to all + * pp/opreport.cpp: handle --hide-dependent --include-dependent and + --merge=lib. Code is ugly, tidy incoming + +2003-04-25 John Levon + + * libpp/format_output.cpp: + * libpp/format_output.h: + * libpp/outsymbflag.h: "immutable" not "imutable" + + * libpp/partition_files.cpp: include to compile + +2003-04-24 Philippe Elie + + * libpp/partition_files.h: typo + * libpp/profile.cpp: difficult to get right result with a random value + in profile::start_offset + + * pp/opreport_options.h: export options::reverse_sort + * pp/opreport_options.cpp: bail out if we get multiple counter + + * pp/opreport.cpp: raw output result for application (not symbol) + output. + +2003-04-24 Philippe Elie + + * libpp/filename_spec.h: + * libpp/filename_spec.cpp: + * libpp/parse_cmdline.h: + * libpp/parse_cmdline.cpp: + * libpp/split_sample_filename.h: + * libpp/split_sample_filename.cpp: s/unit_mask/unitmask + + * libpp/merge_spec.cpp: + * libpp/merge_spec.h: rename to + * libpp/partition_files.h: + * libpp/partition_files.cpp: here. Add and merge_option. + partition_files is now a class. + * pp/opreport_options.h: + * pp/opreport_options.cpp: + * pp/opreport.cpp: update according to the above. Add a roughly support + to count samples for plain op_time opreport like + +2003-04-24 John Levon + + * libpp/profile_container.h: + * libpp/profile_container.cpp: chop off the _t of the class name + + * libpp/format_output.cpp: + * libpp/format_output.h: + * libpp/symbol_container.cpp: + * libpp/symbol_container.h: + * pp/op_time.cpp: + * pp/op_to_source.cpp: + * pp/oprofpp.cpp: changes from the above + +2003-04-24 John Levon + + * libpp/profile_container.h: + * libpp/profile_container.cpp: pedantry for sample_container + indices. + + * libpp/sample_container.h: + * libpp/sample_container.cpp: various cleanups and docs. Add + and use size_type. + + * libpp/symbol_container.h: + * libpp/symbol_container.cpp: renamings. Add and use size_type. + +2003-04-24 John Levon + + * libpp/symbol_container.h: + * libpp/symbol_container.cpp: remove unused operator[]. + Add some docs. Some small cleanups + +2003-04-24 John Levon + + * libpp/symbol_container_imp.h: + * libpp/symbol_container_imp.cpp: + * libpp/sample_container_imp.h: + * libpp/sample_container_imp.cpp: These classes weren't using + the pimpl idiom, so the _imp was spurious. Remove that as well + as removing the _t from the names, and rename to ... + + * libpp/symbol_container.h: + * libpp/symbol_container.cpp: + * libpp/sample_container.h: + * libpp/sample_container.cpp: ...files moved from the above with + new names. + +2003-04-23 Philippe Elie + + * libutil++/generic_spec.h: minor formating tweak + + * libpp/parse_cmdline.h: + * libpp/parse_cmdline.cpp: handle_non_options(): return parse_cmdline + by value + + * libpp/merge_spec.h: + * libpp/merge_spec.cpp: new files: partition list of samples filename + according to merge options. + * libpp/Makefile.am: update + + * pp/opreport_options.cpp: more options handling, use partition_files() + +2003-04-22 John Levon + + * pp/opreport_options.cpp: compile fix + +2003-04-21 Philippe Elie + + * libutil++/filename_match.h: + * libutil++/filename_match.cpp: add strict_match() + + * libutil++/generic_spec.cpp: generic_spec::set() was not + setting is_all member leading to bad matching + + * libpp/filename_spec.cpp: minor tidy + + * libpp/parse_cmdline.h: + * libpp/parse_cmdline.cpp: fix match() + + * libpp/split_sample_filename.h: + * libpp/split_sample_filename.cpp: handle sample file base directory + + * libop++/op_print_event.h: + * libop++/op_print_event.cpp: + * libpp/format_output.h: + * libpp/format_output.cpp: + * libpp/opp_symbol.h: + * libpp/profile.h: + * libpp/profile.cpp: + * libpp/profile_container.h: + * libpp/profile_container.cpp: + * libpp/sample_container_imp.h: + * libpp/sample_container_imp.cpp: + * libpp/symbol_container_imp.h: + * libpp/symbol_container_imp.cpp: + * libpp/symbol_functors.h: remove all use of counter number + + * libpp/counter_array.h: + * libpp/counter_array.cpp: + * libpp/counter_profile.h: + * libpp/counter_profile.cpp: no longer used, move some bits to + libpp/profile.(h|cpp) and remove these files. + * libpp/Makefile.am: update according + + * pp/op_merge.cpp: use profile_t not counter_profile_t + * pp/makefile.am: correct lib for op_merge + + * pp/opreport_options.cpp: more options handling + +2003-04-19 Philippe Elie + + * libopt++/popt_options.cpp: don't show help_str with --usage + * libpp/format_output.cpp: typo + * libutil/op_file.c: create dir with 755 not 700 + * pp/common_option.cpp: source formating + + * libpp/parse_cmdline.h: + * libpp/parse_cmdline.cpp: handle_non_options() new + * pp/opreport_options.cpp: handle more options + + * pp/opsummary.cpp: + * pp/opsummary_options.h: + * pp/opsummary_options.cpp: remove, opreport should do its job. + * pp/Makefile.am: update + +2003-04-18 Philippe Elie + + * libopt++/popt_options.cpp: allow "no-" prefix to long option name + implicitly specify the value must be negated + * libopt++/popt_options.cpp: update doxygen documentation + + * libpp/format_output.h: missing #include + * libpp/format_output.cpp: space + minor change + + * pp/opannotate_options.h: + * pp/opannotate_options.cpp: + * pp/opdiff_options.h: + * pp/opdiff_options.cpp: + * pp/opgprof_options.h: + * pp/opgprof_options.cpp: + * pp/opreport_options.h: + * pp/opreport_options.cpp: + * pp/opsummary_options.h: + * pp/opsummary_options.cpp: new skeleton file + + * pp/opannotate.cpp: + * pp/opdiff.cpp: + * pp/opgprof.cpp: + * pp/opreport.cpp: + * pp/opsummary.cpp: update to handle options + + * pp/common_option.cpp: follow more closely pp_interface + + * pp/opsummary_options.cpp: start to handle opsummary option + + * pp/Makefile.am: update + +2003-04-17 Philippe Elie + + * libpp/format_output.h: + * libpp/format_output.cpp: + * libpp/outsymbflag.h: + * libpp/profile_container.h: + * libpp/profile_container.cpp: osf_header/osf_details are no longer + flags but separate boolean. + +2003-04-17 Philippe Elie + + * dae/opd_kernel.c: + * daemon/opd_kernel.c: remove leading '/' on module name fixing 2.5 + module not under {kern} and similar case for "no-vmlinux" with 2.4/2.5 + + * libutil/op_file.c: tiny tidy + +2003-04-17 Philippe Elie + + * libop/op_mangle.c: app_name and image was reversed, {dep} was missing + +2003-04-17 John Levon + + * libpp/filename_spec.h: + * libutil++/comma_list.h: compile fixes + +2003-04-17 Philippe Elie + + * utils/opcontrol: better --reset handling + +2003-04-16 Philippe Elie + + * dae works, daemon compiles but not tested. + + * libop/op_config.h: + * libpp/op_session.h: + * libpp/session.cpp: + * pp/op_merge: handle new path to samples files. + + * libutil++/file_manip.h: + * libutil++/file_manip.cpp: move create_dir(), create_path() ... + * libutil/op_file.h: + * libutil/op_file.c: here. Remove op_move_regular_file() + + * daemon/opd_image.c: + * daemon/opd_sample_files.h: + * daemon/opd_sample_files.c: + * dae/opd_image.c: + * dae/opd_sample_files.h: + * dae/opd_sample_files.c: use new filename scheme + + * daemon/oprofiled.c: + * dae/oprofiled.c: remove samples files backup stuff + + * libop/op_mangle.h: + * libop/op_mangle.c: ugly modification to handle new samples filename + + * utils/opcontrol: handle new samples files path, --save and --reset + are working too. + + * gui/oprof_start_util.cpp: use new create_path() API + +2003-04-16 Philippe Elie + + * pp/common_option.cpp: + * pp/common_option.h: + * libregex/demangle_symbol.cpp: rename demangle_and_shrink to + smart_demangle + +2003-04-16 Philippe Elie + + * starting branch pp-interface-branch + + * Makefile.am: + * configure.in: handle new sub dir libpp + + * libutil++/comma_list.h: new file handling of comma separated list of + items. + * libutil++/generic_spec.cpp: + * libutil++/generic_spec.h: new file + * libutil++/Makefile.am: handle new file + + * pp/counter_array.*: + * pp/counter_profile.*: + * pp/counter_util.*: + * pp/derive_files.*: + * pp/format_output.*: + * pp/opp_symbol.h: + * pp/outsymbflag.h: + * pp/profile.*: + * pp/profile_container.*: + * pp/sample_container_imp.*: + * pp/session.*: + * pp/symbol_container_imp.*: + * pp/symbol_functors.*: move to + + * libpp/*: here + * libpp/filename_spec.cpp: + * libpp/filename_spec.h: new file handling of pp sample filename + * libpp/parse_cmdline.cpp: + * libpp/parse_cmdline.h: new file, handling of command line tag:value + * libpp/Makefile.am: new file build libpp.a + + * pp/common_option.h: + * pp/common_option.cpp: common option to pp tools. Implement common + entry point to pp tools. + * pp/opannotate.cpp: + * pp/opdiff.cpp: + * pp/opgprof.cpp: + * pp/opreport.cpp: + * pp/opsummary.cpp: skeleton file for all pp tools. + * pp/Makefile.am: remove old pp tools, add the news. + +2003-04-28 Alex Tsariounov + + * module/ia64/op_pmu.c: fix compile + +2003-04-24 Philippe Elie + + * module/compat22.h: add cpuid_edx when linux version < 2.2.21 + +2003-04-24 Dave Jones + + * events/x86-64.hammer.events: + * events/x86-64.hammer.unit_masks: typo fixes from AMD. + * module/x86/cpu_type.c: Check for APIC on Athlon before enabling it. + +2003-04-15 Philippe Elie + + * events/i386-ht.events: all events allow only one counter, remove + three events due to ESCR restriction. + * events/i386.events: add some comments. + + * module/x86/op_model_p4.c: synch with linux 2.5 mainline + - except events CTR_BPU_0 all virtual counter was not working. + - Prevents a segfault when using incorrect counter number. + - ESCR event select is 6 bits length not 5. + - Don't fail silently in p4_setup_ctrs(). + * module/x86/op_msr.h: match name used in linux. + +2003-04-15 John Levon + + * doc/oprofile.1.in: + * doc/oprofile.xml: small english fixes + +2003-04-14 Philippe Elie + + * dae/opd_kernel.c: + * dae/opd_proc.c: + * dae/oprofiled.c: + * utils/opcontrol: + * doc/oprofile.1.in: + * doc/oprofile.xml: handle --no-vmlinux + + * daemon/opd_kernel.c: use no-vmlinux not /no-vmlinux when user + specify --no-vmlinux + +2003-04-08 John Levon + + * HACKING: describe what happens with oprofile-www + +2003-04-08 Philippe Elie + + * libutil++/op_bfd.cpp: check for #717720 and direct user to + FAQ if detected. Note than we don't detect all symptom of this bug. + +2003-04-08 Philippe Elie + + * libutil++/op_exception.h: op_runtime_error is no longer abstract + + * libregex/op_regex.h: comment and tidy + * libregex/op_regex.cpp: tidy + +2003-04-07 Philippe Elie + + * pp/op_to_source.cpp: make each line be prefixed with the samples + counts. It was too hard to find samples inside previous format. + +2003-04-07 Philippe Elie + + * libutil++/string_manip.cpp: work around for gcc 2.95 + * p/op_to_source.cpp: minor cleanup + +2003-04-07 John Levon + + * pp/op_to_source.cpp: cheat a bit to get + better indentation on the default setup, by + widening counter width to 7. + +2003-04-07 John Levon + + * pp/op_to_source.cpp: append symbol summary + annotations separate from the prolog samples on + the same line. + +2003-04-07 John Levon + + * pp/op_to_source.cpp: only output line 0 annotation + if samples found there. + +2003-04-07 John Levon + + * utils/opcontrol: make sure --ctrX-event=none gets noticed + +2003-04-06 John Levon + + * libutil++/string_manip.h: + * libutil++/string_manip.cpp: remove ws_prefix(). Add + format_percent(). + + * pp/op_to_source.cpp: make each line be prefixed with + the sample counts, instead of on a line above, to preserve + line numbering. + +2003-04-06 John Levon + + * pp/op_to_source.cpp: some renamings for clarity + +2003-04-06 John Levon + + * pp/op_to_source.cpp: move extract_blank_at_begin() to ... + + * libutil++/string_manip.cpp: ... here, and rename as + ws_prefix(). + +2003-04-06 John Levon + + * pp/op_to_source.cpp: prefix comment lines. + Output the general footer on each separate file. + Output the info at the bottom when outputting + separate files (towards maintaining line numbering). + +2003-04-06 John Levon + + * pp/op_to_source.cpp: construct a file-scope + cmdline string, instead of passing it around. + +2003-04-06 John Levon + + * libregex/op_regexp.cpp: re-arrange a bit + +2003-04-06 John Levon + + * configure.in: + * all Makefile.am: don't blindly set $LIBS, use + explicit mention of which libs are needed. + + * dae/Makefile.am: + * daemon/Makefile.am: only link with C++ if needed. + +2003-04-05 Philippe Elie + + * libop/op_config_24.h: + * module/oprofile.c: + * module/oprofile.c: make watermark size proportional to buffer size. + +2003-04-05 Philippe Elie + + * libop/op_events.h: + * libop/op_events.c: re-add op_min_count(); + + * dae/oprofiled.c: + * daemon/oprofiled.c: use op_min_count() fixing #715923 + +2003-04-01 John Levon + + * libdb/Makefile.am: fix make dist + + * daemon/opd_cookie.h: add SPARC syscall number. + The system call function is OK for sparc/sparc64 + +2003-03-31 Will Cohen + + * libdb/odb_hash.h: Renamed db_hash.h. + + * dae/Makefile.am: + * dae/opd_image.c: + * dae/opd_image.h: + * dae/opd_proc.c: + * dae/opd_sample_files.c: + * daemon/Makefile.am: + * daemon/opd_image.c: + * daemon/opd_image.h: + * daemon/opd_sample_files.c: + * libabi/Makefile.am: + * libabi/abi.cpp: + * libabi/abi_test.cpp: + * libabi/op_import.cpp: + * libdb/Makefile.am: + * libdb/db_debug.c: + * libdb/db_hash.h: + * libdb/db_insert.c: + * libdb/db_manage.c: + * libdb/db_stat.c: + * libdb/db_test.c: + * libdb/db_travel.c: + * pp/Makefile.am: + * pp/counter_profile.cpp: + * pp/counter_profile.h: + * pp/op_merge.cpp: Change names to avoid libdb.a name conflicts. + +2003-03-30 John Levon + + * configure.in: bump to 0.6cvs + + * doc/oprofile.xml: fix id. Add java etc. mention + + * utils/Makefile.am: + * utils/op_start: + * utils/op_start_25: + * utils/op_stop: + * utils/op_stop_25: + * utils/op_dump: + * utils/op_dump_25: + * utils/op_session: finally remove the back compat crap + + * HACKING: add release-notes policy + +2003-03-30 John Levon + + * configure.in: bump to 0.5.2 + +2003-03-30 John Levon + + * Makefile.am: remove op_arch.h for ia64 + +2003-03-27 John Levon + + * doc/oprofile.xml: several more examples and fixes + +2003-03-26 John Levon + + From a patch by Bryan Rittmeyer. + + * module/oprofile.c: + * module/oprofile.h: push "irq_enabled" test + into arch code, don't pass struct pt_regs. + + * module/x86/op_arch.h: cleanups + + * module/x86/op_model_athlon.c: + * module/x86/op_model_ppro.c: + * module/x86/op_model_p4.c: + * module/x86/op_rtc.c: changes from above + + * module/ia64/op_arch.h: remove + * module/ia64/op_pmu.c: change from above + +2003-03-24 John Levon + + * doc/oprofile.xml: document prologues, and inline functions + +2003-03-24 Will Cohen + + * libutil/op_fileio.c (op_get_line): Use lower cost getc(). + +2003-03-24 John Levon + + * m4/configmodule.m4: fix quoting problem for awk + +2003-03-23 John Levon + + * configure.in: + * m4/: move lots of stuff into separate .m4 files + + * m4/typedef.m4: improve configure message + +2003-03-23 John Levon + + * configure.in: + * m4/Makefile.am: + * m4/copyifchange.m4: + * m4/docbook.m4: + * m4/kerneloption.m4: + * m4/kernelversion.m4: + * m4/resultyn.m4: move configure.in macros to m4/ + +2003-03-23 John Levon + + * m4/ChangeLog: add comment + + * m4/typedef.m4: can't use AC_LANG_PUSH/POP + +2003-03-23 Philippe Elie + + * TODO: update + + * m4/Makefile.am: + * m4/typedef.m4: new file to get underlined type for a typedef. + + * configure.in: get at configure time the real underlined type + for size_t and ptrdiff_t + + * libregex/stl.pat: move to ... + * libregex/stl.pat.in: here. Use @SIZE_T_TYPE@ and @PTRDIFF_T_TYPE@ + * libregex/Makefile.am: update according + * libregex/.cvsignore: ignore stl.pat + +2003-03-22 Philippe Elie + + * utils/opcontrol: use $OP_HELP not op_help + * utils/op_help.c: remove short option for --get-cpu-frequency + +2003-03-22 Philippe Elie + + * TODO: update + + * m4: new directory + * m4/.cvsignore: new + + * acinclude.m4: move to + * m4/qt.m4: here + * m4/Makefile.am: new for EXTRA_DIST = all our .m4 + * Makefile.am: + * configure.in: + * autogen.sh: handle m4 subdir, add -I m4 to aclocal flags + +2003-03-22 Philippe Elie + + Suggested by John + + * libutil/op_cpufreq.c: typo in comment + + * utils/op_help.c: add --get-cpu-frequency, intentionnaly not + documented. + * utils/opcontrol: use op_help --get-cpu-frequency and remove + ugly shell script doing the same thing. + +2003-03-22 Philippe Elie + + * libutil/op_cpufreq.h: + * libutil/op_cpufreq.c: new file exporting op_cpu_frequency() + * libutil/Makefile.am: update according + + * utils/opcontrol: handle other arch + + * gui/oprof_start_util.h: + * gui/oprof_start_util.cpp: remove get_cpu_speed() + * gui/oprof_start.h: + * gui/oprof_start.cpp: and use instead op_cpu_frequency() + + * daemon/oprofiled.c: + * dae/oprofiled.c: replace --cpu-speed option by a call to + op_cpu_frequencey() + +2003-03-20 John Levon + + * doc/oprofile.xml: doc some 2.5 module stuff + +2003-03-20 John Levon + + * utils/opcontrol: fix opcontrol --dump to do something + + * daemon/opd_image.c: give a printf when reading the buffer. + +2003-03-19 Philippe Elie + + * libutil++/op_bfd.cpp: correct get_vma_range() + + * pp/oprofpp.cpp: do_dump_gprof() this time it's right! + +2003-03-18 John Levon + + * pp/profile.cpp: improve mtime warning for 2.5 modules + +2003-03-18 John Levon + + * pp/derive_files.cpp: some more 2.5 modules derivation fixes + +2003-03-18 Philippe Elie + + * pp/derive_files.cpp: fix handling of 2.5 module name + +2003-03-18 John Levon + + * daemon/opd_image.c: + * libop/op_interface_25.h: rename to MODULE_LOADED_CODE + +2003-03-18 Philippe Elie + + * TODO: update + + * pp/derive_files.cpp: special to retrieve 2.5 module + +2003-03-18 Philippe Elie + + * TODO: update + + * pp/symbol_container_imp.h: + * pp/symbol_container_imp.cpp: + * pp/profile_container.h: + * pp/profile_container.cpp: find(string symbol_name) return a vector + of symbol rather a a single symbol + * pp/oprofpp.cpp: use above change so oprofpp -s will show all + symbol with the same name. + + * pp/symbol_functors.h: remove unused functors equal_symbol_by_name + +2003-03-17 Philippe Elie + + * TODO: update + + * libutil/op_fileio.h: + * libutil/op_fileio.c: op_write_u64() new + * libutil/op_types.h: continue our silly typedef: add u64 + + * libutil++/op_bfd.h: + * libutil++/op_bfd.cpp: op_bfd::arch_bits_per_address() new allowing + to get, on a per-binary basis, the vma size. + + * pp/oprofpp.cpp: fix 64 bits arch gprof output. Fix multiplier and + get the multiplier of gprof file at runtime. Fix a very old bug + where we credit the samples to previous gprof bin having the effect + than sample at start of function was credited to the previous + function + +2003-03-17 John Levon + + * daemon/opd_kernel.c: + * daemon/opd_kernel.h: + * daemon/opd_image.c: + * daemon/oprofiled.c: don't try to reread the module + list on a failed EIP match. We must have the module load + notification instead. + +2003-03-17 John Levon + + * daemon/opd_kernel.c: fix module accounting. Remove + quick-drop code that can't work. + + * doc/oprofile.1.in: + * doc/oprofile.xml: english tweaks + +2003-03-17 Philippe Elie + + * TODO: update + + * doc/oprofile.1.in: + * doc/oprofile.xml: remove documentation about -P, update doc about -p + + * pp/derive_files.h: + * pp/derive_files.cpp: check_image_name(), add_to_alternate_filename() + functions moved from op_time.cpp + + * pp/op_time_options.h: + * pp/op_time_options.cpp: + * pp/op_time.cpp: remove -P option, minor cleanup + + * pp/oprofpp_options.h: + * pp/oprofpp_options.cpp: + * pp/oprofpp.cpp: add -p option, minor cleanup + + * pp/op_to_source.cpp: minor cleanup + +2003-03-16 Philippe Elie + + * utils/opcontrol: check return code for --ctr??-event=none + +2003-03-16 Philippe Elie + + * gui/oprof_start.cpp: check for --separate=xxxx in the right order. + Old code do: if user set separate=library and separate=kernel only + separate=library was taken by opcontrol + +2003-03-16 Philippe Elie + + * configure.in: typo + +2003-03-16 John Levon + + * configure.in: more docbook macro fixes + +2003-03-15 Philippe Elie + + * libutil/op_libiberty.h: cut&paste typo breaking compilation on box + w/o libiberty.h + + * daemon/opd_image.c: remove bogus fprintf. compilation was broken + on alpha. + + * configure.in: xsltproc checking fix, was always accepted even + on box where xsltproc is not installed + +2003-03-15 Philippe Elie + + * TODO: update + + * Makefile.am: add ChangeLog-2002 in dist files + * all Makefile.am: put one item by line for most xxxx = blah + * doc/CodingStyle: rationale for the above change + +2003-03-15 Philippe Elie + + * libop/op_events.c: minor cleanup + +2003-03-15 Dave Jones + + * module/x86/op_nmi.c: Remove stale debug code from yesterdays commit. + +2003-03-15 Philippe Elie + + * configure.in: add checking for existence of xmemdup() + + * libutil/Makefile.am: + * libutil/op_string.h: + * libutil/op_string.c: new, a few C string handling function + + * libutil/op_libiberty.h: + * libutil/op_libiberty.c: xmemdup() new. + + * libop/op_events.h: + * libop/op_events.c: tidy parser. Add op_free_events(). Fix minor + buglet. + + * dae/oprofiled.c: + * daemon/oprofiled.c: fix memleak from parsing events files + + * gui/Makefile.am: + * pp/Makefile.am: fix lib ordering, now libop depend on libutil + + * utils/op_help.c: error message if invalid cpu type. Fix op_help + when using timer interrupt. + +2003-03-14 Andi Kleen + + * module/x86/op_nmi.c: Fix another possible race condition. + +2003-03-14 Philippe Elie + + * TODO: update + + * libregex/stl.pat: support for rb tree, set/map, anonymous namespace. + Fix incorrect pattern for gcc 3.2. Handle 2.95 vector/string + iterator and a few stl free function handling. add all C++ base type. + * libregex/mangled-name.txt: test for the above change + +2003-03-14 Philippe Elie + + * gui/oprof_start.cpp: gcc 2.91 warning work around + +2003-03-14 Philippe Elie + + * libop/op_events.c: fix a daemon segfault depending on the used + libc version, added 2003-03-04 (0.5.1 is ok) + +2003-03-13 Dave Jones + + * events/x86-64.hammer.events: Remove duplicate minimum tag + from RETIRED_INSNS counter. + +2003-03-11 John Levon + + * module/ia64/op_pmu.c: include op_arch.h not arch.h + +2003-03-10 Philippe Elie + + * configure.in: remove unsupported --warnnet, fix docbook root dir test + * doc/oprofile.xml: typo + +2003-03-10 John Levon + + * doc/Makefile.am: + * configure.in: + * doc/xsl/catalog-1.xml.in: more docbook changes + +2003-03-10 John Levon + + * configure.in: + * doc/Makefile.am: + * doc/xsl/xhtml.xsl: + * doc/xsl/xhtml-chunk.xsl: + * doc/xsl/catalog-1.xml.in: Use a catalog for finding + the XSL, so we only have one .in file now. + +2003-03-08 Will Cohen + + * doc/Makefile.am: Correct path for htmldir. + +2003-03-08 John Levon + + * libop/op_cpu_type.c: improve error message + + * utils/op_help.c: show CPU name in events list. Show CPU + pretty name in op_help --get-cpu-type. + +2003-03-08 John Levon + + * configure.in: specify distcheck ./configure flags. + Add version.h to distclean. + + * doc/Makefile.am: + * doc/xsl/xhtml-1.in: + * doc/xsl/xhtml-chunk-1.in: fix make distcheck + +2003-03-08 Philippe Elie + + * doc/xsl/.cvsignore: update + + * module/x86/cpu_type.c: is not necessary + +2003-03-07 John Levon + + * README: document autogen.sh + +2003-03-07 Philippe Elie + + * TODO: update + + * doc/xsl/xhtml.xsl.in: move to + * doc/xsl/xhtml-1.xsl.in: here + * doc/xsl/xhtml-chunk.xsl.in: move to + * doc/xsl/xhtml-chunk-1.xsl.in: here + * doc/Makefile.am; update according + * configure.in: avoid to touch doc/xsl generated files + +2003-03-07 Philippe Elie + + * TODO: update + + * daemon/opd_image.c: + * daemon/op_stats.c: + * daemon/opd_stats.h: add statistics for nil image whilst receiving + user space samples. + +2003-03-06 Philippe Elie + + * TODO: update + + * libdb/db_hash.h: + * libdb/db_insert.c: get error message from db_insert() + + * libdb/db_test.c: + * dae/opd_proc.c: + * daemon/opd_image.c: + * libabi/abi_test.cpp: + * libabi/op_import.cpp: + * pp/op_merge.cpp: update according to the new api + +2003-03-06 John Levon + + * doc/oprofile.xml: pedantry + +2003-03-06 Philippe Elie + + * TODO: update + + * doc/oprofile.1.in: + * doc/oprofile.xml: document --smart-demangle + +2003-03-06 Philippe Elie + + * module/ia64/op_pmu.c: + * module/x86/op_nmi.c: remove #include + +2003-03-06 John Levon + + * utils/opcontrol: sh != C. This is the last opcontrol + bug, honest ! OK, maybe not. + +2003-03-06 Philippe Elie + + * TODO: update + + * gui/oprof_start.cpp: save_config() gcc 2.95.3 warning work-around + +2003-03-05 John Levon + + * utils/opcontrol: Make --setup optional (e.g. + opcontrol --no-vmlinux). Fix a bug in the --setup + exclusive arg testing. + + * doc/oprofile.xml: reflect the above + +2003-03-05 John Levon + + * libutil++/string_manip.h: + * libutil++/string_manip.cpp: cleanup, use s.find + because older gcc's don't have the right s.compare + +2003-03-04 John Levon + + * utils/opcontrol: only sleep 2 after dump on 2.4 + +2003-03-04 John Levon + + * configure.in: tweak the xsltproc test + +2003-03-04 John Levon + + * configure.in: + * doc/Makefile.am: don't try to build the docs + if it will fail. + +2003-03-04 John Levon + + * utils/opcontrol: + * daemon/opd_kernel.h: + * daemon/opd_image.c: + * daemon/opd_kernel.c: + * daemon/oprofiled.c: implement --no-vmlinux. + Remove back compat for is_kernel. + + * gui/uioprof_start.base.ui: + * gui/oprof_start.cpp: + * gui/oprof_start_config.h: + * gui/oprof_start_config.cpp: support the above + + * doc/oprofile.1.in: + * doc/oprofile.xml: doc the above + +2003-03-04 John Levon + + * utils/opcontrol: allow --version, --help early on + +2003-03-04 John Levon + + * libop/op_events.c: alter the parser to give file/linenr on + error, and handle more whitespace. + +2003-03-04 John Levon + + * gui/oprof_start.cpp: + * gui/oprof_start.h: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: + + * libutil++/string_manip.h: + * libutil++/string_manip.cpp: add is_prefix(), + make the trimmers take an argument + +2003-03-04 John Levon + + * gui/oprof_start.cpp: + * gui/oprof_start.h: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: + * gui/persistent_config.h: + + * libutil++/string_manip.h: + * libutil++/string_manip.cpp: add split(), tobool(), touint() + + * utils/opcontrol: don't write BUF_SIZE twice. Write + RTC_VALUE properly. Write KERNEL_ONLY + +2003-03-03 John Levon + + * gui/oprof_start.cpp: use --ctrX-event=none, + --separate=none. --pid/pgrp-filter=0 was already + being done. + +2003-03-03 John Levon + + * doc/oprofile.1.in: + * doc/oprofile.xml: + * doc/opcontrol: add --ctrX-event=none + +2003-03-03 Will Cohen + + * gui/oprof_start.cpp (oprof_start::on_start_profiler): Limit + check to only utm_bitmask. + +2003-03-03 Will Cohen + + * events/ia64.itanium2.events: + * events/ia64.itanium2.unit_masks: Add Itanium 2 events. + +2003-03-03 Will Cohen + + * libop/op_events.h: + * libop/op_events.c: Correct checking for the number of unit + masks. + +2003-03-03 John Levon + + * doc/oprofile.1.in: + * doc/oprofile.xml: another round of cleanups + + * pp/op_merge.cpp: --counter not --use-counter, + for consistency + +2003-03-03 John Levon + + Patch from Chris Moller, modified. + + * dae/opd_proc.c: + * dae/opd_sample_files.c: + * daemon/opd_image.c: + * daemon/opd_sample_files.c: + * libabi/abi_test.cpp: + * libabi/op_import.cpp: + * libdb/db_hash.h: + * libdb/db_insert.c: + * libdb/db_manage.c: + * libdb/db_test.c: + * pp/counter_profile.cpp: + * pp/op_merge.cpp: push asserts in libdb down into + the clients. + +2003-03-03 John Levon + + * doc/oprofile.xml: + * doc/oprofile.1.in: + * utils/opcontrol: add --separate=none, --pid/pgrp-filter=non + +2003-03-03 John Levon + + * configure.in: + * doc/Makefile.am: + * doc/oprofile.xml: + * doc/xsl/xhtml-chunk.xsl.in: + * doc/xsl/xhtml.xsl.in: + * doc/xsl/xhtml-common.xsl: Add version to the + docs. Some doc cleanups + +2003-03-02 John Levon + + * utils/opcontrol: --separate=library should turn kernel off + +2003-03-02 John Levon + + * events/Makefile.am: fix uninstall + +2003-03-02 John Levon + + * doc/oprofile.xml: more re-workings prodded by aeb + +2003-03-02 John Levon + + * daemon/opd_kernel.c: remove /proc/ksyms reading + +2003-03-02 John Levon + + * libutil/op_fileio.c: change op_get_line to return + NULL on EOF. Also bump up the default allocation some. + + * dae/opd_kernel.c: + * dae/opd_parse_proc.c: + * daemon/opd_kernel.c: + * libop/op_events.c: changes from the above + +2003-03-02 John Levon + + * configure.in: + * Makefile.am: + * events/: add text files describing the CPU counters + and unit masks. Install them. + + * libop/op_events.h: + * libop/op_events.c: remove the bletcherous hard coded + descriptions. + + * module/ia64/op_pmu.c: + * module/x86/op_nmi.c: remove another big of validation + + * libutil/op_list.h: make C++ friendly + + * libop/op_cpu_type.h: + * libop/op_cpu_type.c: add op_get_cpu_name() + + * libop/Makefile: + * libop/op_events_desc.h: + * libop/op_events_desc.cpp: removed + + * libop++/op_print_event.cpp: + * utils/Makefile.am: + * utils/op_help.c: + * gui/oprof_start.h: + * gui/oprof_start.cpp: changes from above + +2003-03-01 John Levon + + * doc/oprofile.xml: tweaks + + * utils/opcontrol: scale the default event count. Please + test ... + +2003-03-01 John Levon + + * utils/opcontrol: setup default events. Allow part-setting + using --setup. Fix a help text. + + * doc/oprofile.xml: changes from the above + +2003-03-01 John Levon + + * libop/op_cpu_type.c: fix alpha/ev4 mis-detection + +2003-03-01 John Levon + + * doc/oprofile.xml: expand intro a little, small fixes + +2003-03-01 John Levon + + * pp/format_output.cpp: use "%" not "%-age" + +2003-02-28 John Levon + + * utils/opcontrol: fix IS_TIMER setting, noticed by + Duncan Sands + +2003-02-28 John Levon + + * configure.in: bump to 0.6cvs + +2003-02-28 John Levon + + * doc/Makefile.am: tweak + + * libregex/Makefile.am: fix make dist + +2003-02-27 John Levon + + * configure.in: bump to 0.5.1 + +2003-02-27 John Levon + + * doc/oprofile.xml: clarify --separate=kernel + +2003-02-25 John Levon + + * configure.in: clarify --with-kernel-support + + * libop/op_events.c: + * module/x86/op_nmi.c: + * module/ia64/op_nmi.c: remove sanity checking - it's + the wrong place to have such code, is a barrier to op_events + cleanup, and makes life harder for NDAers. + +2003-02-25 Will Cohen + + * utils/opcontrol (do_deinit): Correct search for /dev/oprofile. + +2003-02-24 Dave Jones + + * module/x86/op_apic.[c|h]: move NMI gate setup to architecture + specific SET_NMI_GATE macro. x86=no change. + Make x86-64 use the kernels _set_gate instead of its own open + coded variant. + +2003-02-23 John Levon + + * version-1.h.in: another rename + +2003-02-23 John Levon + + * configure.in: set up OP_DATADIR and OP_BINDIR + + * gui/oprof_start.cpp: + * libregex/demangle_symbol.cpp: use the above + + * version_tpl.h.in: move to ... + + * version.h.in.in: ... here + +2003-02-23 Philippe Elie + + * TODO: update + + * configure.in: add AX_COPY_IF_CHANGE() use it to generate version.h + * .cvsignore: update + + * gui/Makefile.am: + * gui/oprof_start.cpp: + * libregex/Makefile.am: + * libregex/demangle_symbol.cpp: don't use -DBINDIR, rather include + version.h to get install path + +2003-02-23 John Levon + + * README: quick start build insns + +2003-02-23 Philippe Elie + + * TODO: update + + * libregex/Makefile.am: install stl.pat in $prefix/share/oprofile + * libregex/demangle_symbol.cpp: use DATADIR not BINDIR + * libregex/magle-name.txt: add test for pointer + * libregex/stl.pat: partial support for pointer + +2003-02-23 John Levon + + * autogen.sh: error out if options passed + +2003-02-23 John Levon + + * libregex/op_regex.h: + * libregex/regex_test.cpp: fix std:: + +2003-02-23 Philippe Elie + + * libutil++/demangle_symbol.cpp: + * libutil++/demangle_symbol.h: move to + * libregex/demangle_symbol.cpp: + * libregex/demangle_symbol.h: here to avoid circular reference between + libutil++ and libregex + * libregex/Makefile.am: + * libutil++/Makefile.am: update according to file move + + * pp/Makefile.am: + * pp/op_time.cpp: + * pp/op_time_options.cpp: + * pp/op_to_source.cpp: + * pp/op_to_source_options.cpp: + * pp/oprofpp.cpp: + * pp/oprofpp_options.cpp: add -D --Demangle options enabling C++ + demangled name filtering. + +2003-02-23 Philippe Elie + + * libutil++/string_manip.h: + * libutil++/string_manip.cpp: trim(), ltrim(), rtrim() new functions + + * Makefile.am: handle libregex directory + * configure.in: handle libregex/Makefile + + * libregex/.cvsignore: + * libregex/Makefile.am : + * libregex/mangled-name.txt: + * libregex/op_regex.cpp: + * libregex/op_regex.h: + * libregex/regex_test.cpp: + * libregex/stl.pat: new file implementing a match and replace regular + expression around glibc regex. Not used for now, next commit will + use this for pp tools C++ name demangling. + +2003-02-22 John Levon + + * configure.in: fix X, non-Qt build case + +2003-02-22 John Levon + + * libutil++/Makefile.am: fix make dist + +2003-02-21 Dave Jones + + * configure.in: Enable building on hammer again. + +2003-02-21 John Levon + + * utils/opcontrol: "Params used" was lying + +2003-02-20 John Levon + + * daemon/opd_image.c: Fixed a bitch of a bug with separate-kernel, + now attribution of kernel samples should be more accurate + +2003-02-20 John Levon + + * utils/opcontrol: set LIB_SAMPLES if KERNEL_SAMPLES in .daemonrc + +2003-02-20 John Levon + + * dae/opd_stats.h: + * dae/opd_stats.c: + * daemon/opd_stats.h: + * daemon/opd_stats.c: + * dae/opd_proc.c: + * daemon/opd_image.c: remove unused OPD_SAMPLE_COUNTS. Actually + count samples for 2.5 + +2003-02-20 John Levon + + * libop/op_interface_25.h: + * daemon/opd_kernel.c: implement module dropping + + * daemon/opd_image.c: + * daemon/opd_kernel.c: attempt to make verbose logs + less confusing + +2003-02-22 Dave Jones + + * libop/op_events.c: segregload is utm_mask not utm_exclusive + +2003-02-20 Philippe Elie + + * TODO: update + + * pp/output_format.h: + * pp/output_format.cpp: + * pp/op_time.cpp: + * pp/oprofpp.cpp: + * pp/opp_symbol.h: better handling of 64/32 bits bfd_vma + in output + +2003-02-20 John Levon + + * libutil++/op_exception.h: + * libutil++/op_exception.cpp: throw() where needed + +2003-02-19 Philippe Elie + + * TODO: update + + * daemon/opd_image.h: + * daemon/opd_image.cpp: + * daemon/opd_kernel.cpp: fix thinko with --separate=kernel resulting + in duplicate opening of the same samples file. + +2003-02-19 Philippe Elie + + * libutil++/op_exception.h: + * libutil++/op_exception.cpp: new files, base class for exception. + Not used for now. + +2003-02-19 John Levon + + * acinclude.m4: update from upstream + + * gui/ui/oprof_start.base.ui: + * gui/oprof_start.cpp: separate --setup,--start. + Hide non-2.5 stuff in 2.5. + +2003-02-18 Philippe Elie + + * TODO: update + + * dae/opd_sample_files.c: + * daemon/opd_sample_files.c: opd_handle_old_sample_file() don't + try to delete old samples files if they don't exist. + +2003-02-18 Will Cohen + + * utils/opcontrol (do_options): Better option error checking. + +2003-02-17 Will Cohen + + * pp/format_output.h (show_help): namespace std. + +2003-02-17 Will Cohen + + * TODO: update. + +2003-02-17 Philippe Elie + + From Anton Blanchard : + + * daemon/opd_image.c: cookie_t fix for 64 bits + +2003-02-17 Philippe Elie + + * TODO: update + + * libopt++/popt_options.cpp: + * libopt++/popt_options.h: handle an user specific additional + help string + + * pp/output_format.h: + * pp/output_format.cpp: + * pp/op_time_options.cpp: + * pp/oprofpp_options.cpp: use it to show in --output_format + options details. + +2003-02-14 Philippe Elie + + * doc/oprofile.1.in: + * doc/oprofile.xml: + * pp/oprofpp_options.cpp: allow --show-shared-libs with -s + +2003-02-13 Philippe Elie + + * TODO: update + + * pp/output_format.h: + * pp/output_format.cpp: fix #686272, crash when using + oprofpp -s symb_name. + +2003-02-13 Philippe Elie + + * dae/opd_kernel.h: + * dae/opd_image.h: + * dae/opd_image.c: don't use hash entry zero for kernel image + fix #686175 + +2003-02-13 Will Cohen + + * daemon/opd_cookie.h(opd_nr_lookup_dcookie): Correct number. + +2003-02-13 Will Cohen + + * daemon/opd_cookie.h(opd_nr_lookup_dcookie): Add x86_64. + +2003-02-13 John Levon + + * dae/opd_image.c: little cleanup and fix error message + to not lie + +2003-02-12 Philippe Elie + + * doc/oprofile.1.in: + * doc/oprofile.xml: enhance doc about --separate=kernel + + * utils/opcontrol: handle gracefully opcontrol --deinit if profiler + was already shutdown. Avoid wrong warning when umount /dev/oprofile + +2003-02-12 Will Cohen + + * gui/oprof_start.cpp (oprof_start::oprof_start, + oprof_start::on_flush_profiler_data, + oprof_start::on_start_profiler, + oprof_start::on_stop_profiler): Use opcontrol. + * gui/oprof_start_util.cpp (daemon_status::daemon_status): + Allow reading interrupt info from new kernel interface. + * libop/op_get_interface.c: New. + * libop/Makefile.am: Add libop/op_get_interface.c. + * libop/op_cpu_type.h: Add enum op_interface. + + I Added some bits. Phil + * gui/oprof_start.cpp: correct --separate= handling + * gui/oprof_start_util.cpp: read only the real number of interrupts + +2003-02-12 Philippe Elie + + * utils/opcontrol: handle --note-table-size --kernel-only (2.4 kernel) + +2003-02-12 Philippe Elie + + * utils/op_start: map --separate-samples to daemon option + --separate-lib-samples. + +2003-02-11 Philippe Elie + + * dae/opd_image.c: + * dae/opd_kernel.c: + * dae/opd_kernel.h: + * dae/opd_parse_proc.c: + * dae/opd_proc.c: + * dae/opd_proc.h: + * dae/opd_sample_files.c: + * dae/oprofiled.c: + * daemon/opd_image.c: + * daemon/opd_image.h: + * daemon/opd_kernel.c: + * daemon/opd_kernel.h: + * daemon/opd_sample_files.c: + * daemon/oprofiled.c: per application kernel samples files + + * doc/oprofile.1.in: + * doc/oprofile.xml: document opcontrol --separate=kernel + + * gui/oprof_start.cpp: + * gui/oprof_start_config.cpp: + * gui/oprof_start_config.h: + * gui/ui/oprof_start.base.ui: remove ignore_daemon checkbox, handle + --separate=[library|kernel] + + * libop/op_sample_file.h: add separate_kernel_samples field, file + format is backward compatible + + * libabi/abi.cpp: + * libabi/abi_test.cpp: + * libabi/op_import.cpp: handle new samples file header field + + * pp/counter_profile.cpp: dump new sample files header field. + + * utils/opcontrol: handle --separate=kernel + +2003-02-09 Will Cohen + + * utils/opcontrol: Add rtc-value option. + +2003-02-09 John Levon + + * utils/opcontrol: stale lock file detection + +2003-02-06 Will Cohen + + * utils/opcontrol (do_dump): Do not exit if no daemon. + +2003-02-06 Will cohen + + * doc/oprofile.1.in: Update man page information. + +2003-02-03 John Levon + + * configure.in: 0.6cvs + +2003-02-02 John Levon + + * configure.in: bump to 0.5 + +2003-02-02 John Levon + + * configure.in: disable x86_64 + +2003-02-02 John Levon + + * pp/format_output.cpp: revert previous patch, Phil's + x86 binutils is built with 64-bit bfd_vma + +2003-02-01 John Levon + + * utils/opcontrol: rename --separate-samples to --separate=library + for future proofing. + + * pp/format_output.cpp: output vma at a suitable width + +2003-01-31 Will Cohen + + * utils/opcontrol(get_kernel_range): Match only .text segment. + +2003-01-31 Graydon Hoare + + * libabi/abi.cpp + * libabi/abi_test.cpp + * libabi/op_import.cpp: Treat endianness as a property of the datum + being imported, rather than the memory architecture. + +2003-01-31 Dave Jones + + * module/x86/op_model_athlon.c: Don't poke reserved bits in the counter. + Only rdmsr/wrmsr counters that we've enabled in the NMI handler. + ulong->uint conversion. + +2003-01-30 Philippe Elie + + From Randolph Chung : + + * daemon/opd_cookie.h: add parisc support + +2003-01-30 John Levon + + From Anton Blanchard : + + * daemon/opd_cookie.h: add ppc32/64 + + * utils/op_start_25: fix start of kernel for ppc + +2003-01-30 Will Cohen + + * utils/opcontrol(get_kernel_range): Avoid using perl arithmetic. + +2003-01-29 Dave Jones + + * utils/opcontrol: Trying to use the options --pid-filter=pid and + --pgmr-filter=pgmr, opcontrol returned "command not found. + This was due to 2 missing 'test' statements. + +2003-01-29 Philippe Elie + + * pp/op_to_source.cpp: read vma with strtoull not strtoul fixing + 32/64 failure to read output of objdump + +2003-01-29 Dave Jones + + * libop/op_cpu_type.c: Clue the user in on why the cpu type isn't + recognised, by suggesting the module wasn't loaded. + * libop/op_events.c: Doh, unit masks use bit numbers, not values. + +2003-01-28 Philippe Elie + + * utils/op_help.c: get cpu type only if not forced on command line. + Avoid wrong warning about unsupported cpu type. + +2003-01-27 Will Cohen + + * daemon/opd_cookie.h(opd_nr_lookup_dcookie): Add ia64 version. + +2003-01-27 Dave Jones + + * libop/op_events.c: K8 HT events are utm_exclusive, not utm_bitmask + * libop/op_events.c: Add additional K8 unit masks. + +2003-01-23 Philippe Elie + + * libop/op_interface_25.h: + * daemon/opd_image.c: prepare drop modules support. exit() when + receiving unknown escape code. + +2003-01-23 Randolph Chung + + Added minor change: backward compatibility, u_int to uint, fix + 32/64 bits escape code marker comparison. Phil + + * libop/op_interface_25.h: + * daemon/opd_kernel.c: + * daemon/opd_image.c: new scheme to recognize kernel or user space + eip, now kernel module pass the relevent information through + escape sequence. + +2003-01-21 Dave Jones + + * libop/op_events.c: Add unit mask for Hypertransport events. + +2003-01-21 Dave Jones + + * libop/op_events.c: Add x86-64 specific events. + +2003-01-21 Philippe Elie + + * daemon/opd_kernel.c: use sscanf to parse /proc/modules + +2003-01-20 Philippe Elie + + * daemon/opd_kernel.c: more robust /proc/modules parsing. + +2003-01-20 Philippe Elie + + * daemon/opd_kernel.c: 2.5 modules support, for now I keep + the code for /proc/ksyms parsing in daemon. Let's it living a few + weeks please. + +2003-01-18 Falk Hueffner + + I added to the original patch all %L to %ll, Phil + + * daemon/opd_image.c: + * daemon/opd_kernel.c: + * libutil/op_types.h: 64 bits printf/scanf safety. + +2003-01-18 Falk Hueffner + + * libop/op_cpu_type.h: + * libop/op_cpu_type.c: add Alpha CPU families. + * libop/op_events.h: make op_event.cpu_mask u32, since we now have + more than 16 CPU types + * libop/op_hw_config.h: bump OP_MAX_COUNTERS to 20 for Alpha + * libop/op_events.c: add Alpha events + * daemon/opd_cookie.h: add dcookie syscall number for Alpha + * utils/op_help.c (main): add help string for Alpha + +2003-01-18 John Levon + + * module/Makefile.in: + * module/x86/Makefile.in: + * module/ia64/Makefile.in: kernel headers are too fubar + for -Werror. So I'm taking my ball home. + +2003-01-17 John Levon + + * HACKING: + * doc/CodingStyle: add + +2003-01-17 John Levon + + * TODO: some updates + +2003-01-15 Philippe Elie + + * module/x86/op_model_p4.c: pmc_setup_one_p4_counter() show clearly + than event == 0 is an error + +2003-01-15 John Levon + + * utils/opcontrol: prefer oprofiled/op_help binaries in the same + dir as opcontrol + +2003-01-12 Philippe Elie + + * libop/op_events.c: rename OP_P4_HT2 to OP_P4_ALL + +2003-01-12 Philippe Elie + + * libop++/op_print_event.cpp: no event,nor unit mask for CPU_TIMER_INT, + problem reported by Ka Fai Lu. + +2003-01-12 John Levon + + From Graydon Hoare + + * libop/op_cpu_type.h: + * libop/op_cpu_type.c: add P4 HT + + * libop/op_events.c: tag P4 HT events + +2003-01-11 Randolph Chung + + * daemon/oprofiled.c: fix ELF sniff + +2003-01-11 John Levon + + * daemon/opd_image.c: bail out immediately on dcookie + lookup failure. + +2003-01-10 John Levon + + * daemon/opd_cookie.h: insulate against missing arch support + for sys_lookup_dcookie + + * daemon/opd_image.c: use the above + +2003-01-10 John Levon + + * daemon/opd_image.c: + * daemon/oprofiled.c: move complete_dump to a better place + +2003-01-10 John Levon + + * libutil/op_types.h: add cookie_t and vma_t + + * daemon/opd_image.c: + * daemon/opd_image.h: + * daemon/opd_kernel.c: + * daemon/opd_kernel.h: use above types, and kernel_pointer_size + + * daemon/oprofiled.c: sniff /proc/kcore for kernel_pointer_size + +2003-01-10 Philippe Elie + + * libopt++/popt_options.cpp: + * libopt++/popt_options.h: work-around to support both gcc new parser + and gcc 2.95 + +2003-01-08 John Levon + + * libop/op_type.cpp: support for ascii-string cpu types + +2003-01-08 Philippe Elie + + * libutil++/op_bfd.cpp: + * libutil++/op_bfd.h: + * pp/oprofpp.cpp: more use of bfd_vma + +2003-01-08 Philippe Elie + + * libdb/Makefile.am: fix include dir + * libdb/db_test.c: don't assume than sizeof(struct opd_header) == 128 + +2003-01-06 Philippe Elie + + * libutil++/op_bfd.h: fix for 64 bits. + +2003-01-06 Philippe Elie + + * libabi/abi.cpp: + * libabi/op_import.cpp: broken by my last change in libdb. + +2003-01-06 Philippe Elie + + * db/db_hash.h: do_hash() use db_key_t as parameter + +2003-01-04 John Levon + + * pp/op_time.cpp: suggest opcontrol --dump instead + + * utils/opcontrol: implement --start-daemon. Fix a number + of bugs + + * doc/oprofile.xml: + * doc/oprofile.1.in: document --start-daemon + +2003-01-03 Will Cohen + + * daemon/oprofiled.c (opd_do_samples): Typecast to match + arguments. + +See ChangeLog-2002 for earlier changelogs. diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..88d2dfc --- /dev/null +++ b/Makefile.am @@ -0,0 +1,92 @@ +SUBDIRS = \ + . \ + m4 \ + libutil \ + libop \ + libdb \ + libutil++ \ + libopt++ \ + libabi \ + daemon \ + utils \ + libregex \ + libpp \ + pp \ + events \ + doc \ + gui + +ACLOCAL_AMFLAGS = -I m4 + +# The module will not build under distcheck +DISTCHECK_CONFIGURE_FLAGS = --with-kernel-support + +if !kernel_support + +.PHONY: module + +all-local: module + +# This must use a fully-qualified SUBDIRS path, so we can't use ${top_srcdir} +module: + make -C libutil + make -C libop + (cd $(KSRC) && $(MAKE) SUBDIRS=$(OPROFILE_DIR)/module/@OPROFILE_MODULE_ARCH@ modules) || exit 1 ; + (cd $(KSRC) && $(MAKE) SUBDIRS=$(OPROFILE_DIR)/module modules) || exit 1 ; + +install-exec-local: + -mkdir -p $(MODINSTALLDIR)/oprofile + cp module/oprofile-module.o $(MODINSTALLDIR)/oprofile/oprofile.o + if test $(KVERS) = "`uname -r`"; then depmod -a ; fi + +clean-local: + rm -f module/*.o module/@OPROFILE_MODULE_ARCH@/*.o \ + module/.*.o.cmd module/.*.o.flags \ + module/@OPROFILE_MODULE_ARCH@/.*.o.cmd module/@OPROFILE_MODULE_ARCH@/.*.o.flags + +endif + +EXTRA_DIST = \ + ChangeLog-2001 \ + ChangeLog-2002 \ + ChangeLog-2003 \ + autogen.sh \ + include/sstream \ + module/Makefile.in \ + module/compat.c \ + module/op_dname.c \ + module/op_init.c \ + module/oprofile.c \ + module/op_util.c \ + module/compat22.h \ + module/compat24.h \ + module/compat.h \ + module/op_cache.h \ + module/op_dcache.h \ + module/oprofile.h \ + module/op_util.h \ + module/ia64/Makefile.in \ + module/ia64/oprofile_stubs.S \ + module/ia64/cpu_type.c \ + module/ia64/op_pmu.c \ + module/ia64/op_syscalls.c \ + module/ia64/IA64entry.h \ + module/ia64/IA64minstate.h \ + module/ia64/IA64syscallstub.h \ + module/ia64/op_ia64_model.h \ + module/x86/Makefile.in \ + module/x86/oprofile_nmi.S \ + module/x86/apic_compat.h \ + module/x86/op_apic.h \ + module/x86/op_arch.h \ + module/x86/op_x86_model.h \ + module/x86/op_msr.h \ + module/x86/cpu_type.c \ + module/x86/op_apic.c \ + module/x86/op_fixmap.c \ + module/x86/op_model_athlon.c \ + module/x86/op_model_p4.c \ + module/x86/op_model_ppro.c \ + module/x86/op_nmi.c \ + module/x86/op_rtc.c \ + module/x86/op_syscalls.c diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..cd823a4 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,739 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = . +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(top_srcdir)/configure $(top_srcdir)/doc/srcdoc/Doxyfile.in \ + $(top_srcdir)/doc/xsl/catalog-1.xml.in \ + $(top_srcdir)/module/Makefile.in \ + $(top_srcdir)/module/ia64/Makefile.in \ + $(top_srcdir)/module/x86/Makefile.in COPYING ChangeLog TODO \ + depcomp install-sh missing +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = doc/xsl/catalog-1.xml doc/srcdoc/Doxyfile \ + module/Makefile module/x86/Makefile module/ia64/Makefile +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +SUBDIRS = \ + . \ + m4 \ + libutil \ + libop \ + libdb \ + libutil++ \ + libopt++ \ + libabi \ + daemon \ + utils \ + libregex \ + libpp \ + pp \ + events \ + doc \ + gui + +ACLOCAL_AMFLAGS = -I m4 + +# The module will not build under distcheck +DISTCHECK_CONFIGURE_FLAGS = --with-kernel-support +EXTRA_DIST = \ + ChangeLog-2001 \ + ChangeLog-2002 \ + ChangeLog-2003 \ + autogen.sh \ + include/sstream \ + module/Makefile.in \ + module/compat.c \ + module/op_dname.c \ + module/op_init.c \ + module/oprofile.c \ + module/op_util.c \ + module/compat22.h \ + module/compat24.h \ + module/compat.h \ + module/op_cache.h \ + module/op_dcache.h \ + module/oprofile.h \ + module/op_util.h \ + module/ia64/Makefile.in \ + module/ia64/oprofile_stubs.S \ + module/ia64/cpu_type.c \ + module/ia64/op_pmu.c \ + module/ia64/op_syscalls.c \ + module/ia64/IA64entry.h \ + module/ia64/IA64minstate.h \ + module/ia64/IA64syscallstub.h \ + module/ia64/op_ia64_model.h \ + module/x86/Makefile.in \ + module/x86/oprofile_nmi.S \ + module/x86/apic_compat.h \ + module/x86/op_apic.h \ + module/x86/op_arch.h \ + module/x86/op_x86_model.h \ + module/x86/op_msr.h \ + module/x86/cpu_type.c \ + module/x86/op_apic.c \ + module/x86/op_fixmap.c \ + module/x86/op_model_athlon.c \ + module/x86/op_model_p4.c \ + module/x86/op_model_ppro.c \ + module/x86/op_nmi.c \ + module/x86/op_rtc.c \ + module/x86/op_syscalls.c + +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ + cd $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: $(am__configure_deps) + cd $(top_srcdir) && $(AUTOHEADER) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +doc/xsl/catalog-1.xml: $(top_builddir)/config.status $(top_srcdir)/doc/xsl/catalog-1.xml.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +doc/srcdoc/Doxyfile: $(top_builddir)/config.status $(top_srcdir)/doc/srcdoc/Doxyfile.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +module/Makefile: $(top_builddir)/config.status $(top_srcdir)/module/Makefile.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +module/x86/Makefile: $(top_builddir)/config.status $(top_srcdir)/module/x86/Makefile.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +module/ia64/Makefile: $(top_builddir)/config.status $(top_srcdir)/module/ia64/Makefile.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + $(mkdir_p) $(distdir)/doc $(distdir)/doc/srcdoc $(distdir)/doc/xsl $(distdir)/include $(distdir)/libregex $(distdir)/libregex/tests $(distdir)/m4 $(distdir)/module $(distdir)/module/ia64 $(distdir)/module/x86 + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +@kernel_support_TRUE@all-local: +all-am: Makefile config.h all-local +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +@kernel_support_TRUE@install-exec-local: +@kernel_support_TRUE@clean-local: +clean: clean-recursive + +clean-am: clean-generic clean-local mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-hdr distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: install-exec-local + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am all-local \ + am--refresh check check-am clean clean-generic clean-local \ + clean-recursive ctags ctags-recursive dist dist-all dist-bzip2 \ + dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ + distclean-generic distclean-hdr distclean-recursive \ + distclean-tags distcleancheck distdir distuninstallcheck dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-exec-local install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-generic \ + mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-info-am + + +@kernel_support_FALSE@.PHONY: module + +@kernel_support_FALSE@all-local: module + +# This must use a fully-qualified SUBDIRS path, so we can't use ${top_srcdir} +@kernel_support_FALSE@module: +@kernel_support_FALSE@ make -C libutil +@kernel_support_FALSE@ make -C libop +@kernel_support_FALSE@ (cd $(KSRC) && $(MAKE) SUBDIRS=$(OPROFILE_DIR)/module/@OPROFILE_MODULE_ARCH@ modules) || exit 1 ; +@kernel_support_FALSE@ (cd $(KSRC) && $(MAKE) SUBDIRS=$(OPROFILE_DIR)/module modules) || exit 1 ; + +@kernel_support_FALSE@install-exec-local: +@kernel_support_FALSE@ -mkdir -p $(MODINSTALLDIR)/oprofile +@kernel_support_FALSE@ cp module/oprofile-module.o $(MODINSTALLDIR)/oprofile/oprofile.o +@kernel_support_FALSE@ if test $(KVERS) = "`uname -r`"; then depmod -a ; fi + +@kernel_support_FALSE@clean-local: +@kernel_support_FALSE@ rm -f module/*.o module/@OPROFILE_MODULE_ARCH@/*.o \ +@kernel_support_FALSE@ module/.*.o.cmd module/.*.o.flags \ +@kernel_support_FALSE@ module/@OPROFILE_MODULE_ARCH@/.*.o.cmd module/@OPROFILE_MODULE_ARCH@/.*.o.flags +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/README b/README new file mode 100644 index 0000000..f44725b --- /dev/null +++ b/README @@ -0,0 +1,44 @@ +This is an alpha release version of oprofile, a transparent +low-overhead system-wide profiler. + +You can find some documentation in the doc/ directory. + +Please visit the oprofile website at : http://oprofile.sf.net/ + +oprofile was written by John Levon +and Philippe Elie . + +Dave Jones provided bug fixes and support for +the AMD Athlon, and AMD Hammer families of CPUs. + +Bob Montgomery provided bug fixes, the initial RTC +driver and the initial ia64 driver. + +Will Cohen integrated the ia64 driver into the +oprofile release, and contributed bug fixes and several cleanups. + +Graydon Hoare provided P4 port, bug fixes and cleanups. + +Ralf Baechle provided the MIPS port. + +Other contributors are listed in the ChangeLog. + +Building +-------- + +Please read the installation instructions in doc/oprofile.html or +http://oprofile.sourceforge.net/doc/install.html. + +Quick start : + +(If using CVS: ./autogen.sh first. You need automake 1.5 or higher. You +can specify a different version, e.g. +ACLOCAL=aclocal-1.5 AUTOMAKE=automake-1.5 AUTOCONF=autoconf-2.13 AUTOHEADER=autoheader-2.13 ./autogen.sh) + +2.4 kernels + + ./configure --with-linux=/path/to/kernel/source + +2.6 kernels + + ./configure --with-kernel-support diff --git a/TODO b/TODO new file mode 100644 index 0000000..09cc3ac --- /dev/null +++ b/TODO @@ -0,0 +1,164 @@ +This is an (incomplete) list of some of the stuff we want to look at doing. + +If you're interested in hacking on any of these, please contact the list first +for some pointers and/or read HACKING and doc/CodingStyle. + +0.9 release +----------- + +finish testing especially of anon region stuff + +1.0 release +----------- + +(this is a minimal selection of stuff I think we need) + + o amd64 32 bit build needs a sys32_lookup_dcookie() translator in the + kernel + o op_bfd.cpp:get_linenr() see FIXME about the use of ibfd/dbfd, needs test. + o decide on -m tgid semantics for anon regions + o if ev67 is not fixed, back it out + o opimport needs a man page + o add call graph option to oprof_start + +Later +----- + + o remove 2.95/2.2 support so we can use boost multi index container in + symbol/sample container + o consider if we can improve anon mapping growing support + + [moz@lambent pp]$ ./opreport -lf lib-image:/lib/tls/libc-2.3.2.so /bin/bash | grep vfprintf + 14 0.1301 6 0.0102 /lib/tls/libc-2.3.2.so vfprintf + [moz@lambent pp]$ ./opreport -lf lib-image:/lib/tls/libc-2.3.2.so /usr/bin/vim | grep vfprintf + 176 2.0927 349 1.2552 /lib/tls/libc-2.3.2.so vfprintf + [moz@lambent pp]$ ./opreport -lf lib-image:/lib/tls/libc-2.3.2.so { image:/bin/bash } { image:/usr/bin/vim } | grep vfprintf + 176 10.9657 +++ 349 7.8888 +++ vfprintf + 14 --- --- 6 --- --- vfprintf + it seems them as two separate symbols + but can we remove the app_name from rough_less and still be able to walk the two lists? + even if we could, it would still go wrong when we're profiling multiple apps + + o Java stuff?? + o with opreport -c I can get "warning: /no-vmlinux could not be found.". + Should be smarter ? + o opreport -c gives weird output for an image with no symbols: + + samples % symbol name + 15965 100.000 (no symbols) +253 100.000 (no symbols) + 15965 98.4400 (no symbols) + 253 1.5600 (no symbols) [self] + + o consider tagging opreport -c entries with a number like gprof + o --details for opreport -c, or diff?? + o should [self] entries be ommitted if 0 ?? + o stress test opreport -c: compile a Big Application w/o frame pointer and look + how driver and opreport -c react. + o oparchive could fix up {kern} paths with -p (what about diff between + archive and current though?) + o can say more in opcontrol --status + o consider a sort option for diff % + o opannotate is silent about symbols missing debug info + o opcontrol --reset should avoid to reload the module if it's unloaded + o oprofiled.log now contains various statistics about lost sample etc. from + the driver. Post profile tools must parse that and warn eventually, warning + must include a proposed work around. User need this: if nothing seems wrong + people are unlikely to get a look in oprofiled.log (I ran oprofile on 2.6.1 + 2 weeks before noticing at 30000 I lost a lot of samples, the profile seemed + ok du to the randomization of lost samples). As developper we need that too, + actually we have no clear idea of the behavior on different arch, NUMA etc. + Not perfect because if the profiler is running the oprofiled.log will show + those warning only after the first alarm signal, I think we must dump the + statistics information after each opcontrol --dump to avoid that. + o odb_insert() can fail on ftruncate or mremap() in db_manage.c but we don't + try to recover gracefully. + o output column shortname headers for opreport -l + o is relative_to_absolute_path guaranteeing a trailing '/' documented ? + o move oprofiled.log to OP_SAMPLE_DIR/current ? + o --buffer-size is useless on 2.5 without tuning of watershed + o pp tools must handle samples count overflow (marked as (unsigned)-1) + o the way we show kernel modules in 2.5 is not very obvious - "/oprofile" + o oparchive will be more usefull with a --root= options to allow profiling + on a small box, nfs mount / to another box and transfer sample file and + binary on a bigger box for analysis. There is also a problem in oparchive + you can use session: to get the right path to samples files but oprofiled.log + and abi files path are hardcoded to /var/lib/oprofile. + o callgraph patch: better way to skip ignored backtrace ? + o zwane problem with wrong text offset showed an interesting problem: if + op_bfd.cpp get any symbol below text offset for vmlinux or a module then + profile_t::sample_range() return a pair of iterator with first > second + and we throw + o lib-image: and image: behavior depend on --separate=, if --separate=library + opreport "lib-image:*libc*" --merge=lib works but not + opreport "image:*libc*" --merge=lib whilst the behavior is reversed if + --separate==none. Must we take care ? + o dependencies between profile_container.h symbol_container.h and + sample_container.h become more and more ugly, I needed to include them + in a specific order in some source (still true??) + o add event aliases for common things like icache misses, we must start to + think about metrics including simple like event alias mapped to two or more + events and intepreted specially by user space tools like using the ratio + of samples; more tricky will be to select an event used as call count (no + cg on it) and used to emulate the call count field in gprof. I think this is + a after 1.0 thing but event aliases must be specified in a way allowing such + extension + o do we need an opreport like opreport -c (showing caller/callee at binary + boundary not symbols) ? + o we should notice an opcontrol config change (--separate etc.) and + auto-restart the daemon if necessary (Run) + o we can add lots more unit tests yet + o Itanium event constraints are not implemented + o side-by-side opreport output (--compare - needs UI spec) ??? + o GUI still has a physical-counter interface, should have a general one + like opcontrol --event + o I think we should have the ability to have *fixed* width headers, e.g. : + +vma samples cum. samples % cum. % symbol name image name app name +0804c350 64582 64582 35.0757 35.0757 odb_insert /usr/loc...in/oprofiled /usr/local/oprofile-pp/bin/oprofiled + + Note the ellipsis + o should we make the sighup handler re-read counter config and re-start profiling too ? + o improve --smart-demangle + o allow user to add it's own pattern in user.pat, document it. + o hard code ${typename} regular definition to remove all current limitations (difficult, perhaps after 1.0 ?). + o oprof_start dialog size is too small initially + o oprof_start key movement through events doesn't change help text + o i18n. We need a good formatter, and also remember format_percent() + o opannotate --source --output-dir=~moz/op/ /usr/bin/oprofiled + will fail because the ~ is not expanded (no space around it) (popt bug I say) + o cpu names instead of numbers in 2.4 module/ ? + o remove 1 and 2 magic numbers for oprof_ready + o adapt Anton's patch for handling non-symbolled libraries ? (nowaday C++ + anon namespace symbol are static, 3.4 iirc, so with recent distro we are + more likely to get problems with a "fallback to dynamic symbols" approch) + o use standard C integer type int32_t int16_t etc. + o event multiplexing for real + o randomizing of reset value + o XML output + o profile the NMI handler code + +Documentation +------------- + + o the docs should mention the default event for each arch somewhere + o more discussion of problematic code needs to go in the "interpreting" section. + o document gcc 2.95 and linenr info problems especially for inline functions + o finish the internals manual + +General checks to make +---------------------- + + o rgrep FIXME + o valgrind (--show-reachable=yes --leak-check=yes) + o audit to track unnecessary include <> + o gcc 3.0/3.x compile + o Qt2/3 check, no Qt check + o verify builds (modversions, kernel versions, athlon etc.). I have the + necessary stuff to check kernel versions/configurations on PIII core (Phil) + o use nm and a little script to track unused function + o test it to hell and back + o compile all C++ programs with STL_port and test them (gcc 3.4 contain a + debug mode too but std::string iterator are not checked) + o There is probably place of post profile tools where looking at errno will give better error messages. + diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..8c37786 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,879 @@ +# generated automatically by aclocal 1.9.5 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.9.5])]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 7 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH]) +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 3 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. +AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 12 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.58])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $1 | $1:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. +# +# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories +# created by `make install' are always world readable, even if the +# installer happens to have an overly restrictive umask (e.g. 077). +# This was a mistake. There are at least two reasons why we must not +# use `-m 0755': +# - it causes special bits like SGID to be ignored, +# - it may be too restrictive (some setups expect 775 directories). +# +# Do not use -m 0755 and let people choose whatever they expect by +# setting umask. +# +# We cannot accept any implementation of `mkdir' that recognizes `-p'. +# Some implementations (such as Solaris 8's) are not thread-safe: if a +# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' +# concurrently, both version can detect that a/ is missing, but only +# one can create it and the other will error out. Consequently we +# restrict ourselves to GNU make (using the --version option ensures +# this.) +AC_DEFUN([AM_PROG_MKDIR_P], +[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi +AC_SUBST([mkdir_p])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + +m4_include([m4/binutils.m4]) +m4_include([m4/builtinexpect.m4]) +m4_include([m4/compileroption.m4]) +m4_include([m4/configmodule.m4]) +m4_include([m4/copyifchange.m4]) +m4_include([m4/docbook.m4]) +m4_include([m4/extradirs.m4]) +m4_include([m4/findkernel.m4]) +m4_include([m4/kerneloption.m4]) +m4_include([m4/kernelversion.m4]) +m4_include([m4/mallocattribute.m4]) +m4_include([m4/poptconst.m4]) +m4_include([m4/precompiledheader.m4]) +m4_include([m4/qt.m4]) +m4_include([m4/resultyn.m4]) +m4_include([m4/sstream.m4]) +m4_include([m4/typedef.m4]) diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..deff513 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# run to generate needed files not in CVS + +# NB: if you run this file with AUTOMAKE, AUTOCONF, etc. environment +# variables set, you *must* run "configure" with the same variables +# set. this is because "configure" will embed the values of these variables +# into the generated Makefiles, as @AUTOMAKE@, @AUTOCONF@ etc. and it will +# trigger regeneration of configuration state using those programs when any +# of Makefile.am etc. change. + +run() { + echo "Running $1 ..." + $1 +} + +set -e + +ACLOCAL=${ACLOCAL:-aclocal} +AUTOHEADER=${AUTOHEADER:-autoheader} +AUTOMAKE=${AUTOMAKE:-automake} +AUTOCONF=${AUTOCONF:-autoconf} + +if $AUTOMAKE --version | grep -q 1.4 + then + echo "" + echo "Automake 1.4 not supported. please set \$AUTOMAKE" + echo "to point to a newer automake, or upgrade." + echo "" + exit 1 +fi + +if test -n "$1"; then + echo "autogen.sh doesn't take any options" >&2 + exit 1 +fi + +run "$ACLOCAL -I m4" +run $AUTOHEADER +run "$AUTOMAKE --foreign --add-missing --copy" +run $AUTOCONF diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..4b00a99 --- /dev/null +++ b/config.h.in @@ -0,0 +1,100 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* whether popt prototype takes a const char ** */ +#undef CONST_POPT + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `bfd' library (-lbfd). */ +#undef HAVE_LIBBFD + +/* Define to 1 if you have the `iberty' library (-liberty). */ +#undef HAVE_LIBIBERTY + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBIBERTY_H + +/* Define to 1 if you have the `popt' library (-lpopt). */ +#undef HAVE_LIBPOPT + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `perfmonctl' function. */ +#undef HAVE_PERFMONCTL + +/* Define to 1 if you have the `sched_setaffinity' function. */ +#undef HAVE_SCHED_SETAFFINITY + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `xcalloc' function. */ +#undef HAVE_XCALLOC + +/* Define to 1 if you have the `xmemdup' function. */ +#undef HAVE_XMEMDUP + +/* whether malloc attribute is understood */ +#undef MALLOC_ATTRIBUTE_OK + +/* whether to build ABI tools */ +#undef OPROF_ABI + +/* package binary directory */ +#undef OP_BINDIR + +/* package data directory */ +#undef OP_DATADIR + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Synthesize special symbols when needed */ +#undef SYNTHESIZE_SYMBOLS + +/* whether bfd.h defines bool values */ +#undef TRUE_FALSE_ALREADY_DEFINED + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if the X Window System is missing or not being used. */ +#undef X_DISPLAY_MISSING diff --git a/configure b/configure new file mode 100755 index 0000000..36a1976 --- /dev/null +++ b/configure @@ -0,0 +1,10769 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.59. +# +# Copyright (C) 2003 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="libop/op_config.h" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar RANLIB ac_ct_RANLIB DATE OPROFILE_DIR CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE LD KSRC KINC kernel_support_TRUE kernel_support_FALSE KVERS OPROFILE_MODULE_ARCH MODINSTALLDIR EXTRA_CFLAGS_MODULE topdir EGREP SIZE_T_TYPE PTRDIFF_T_TYPE CXXCPP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS QT_INCLUDES QT_LDFLAGS MOC UIC QT_LIB QT_VERSION enable_abi_TRUE enable_abi_FALSE XSLTPROC have_xsltproc_TRUE have_xsltproc_FALSE XML_CATALOG XSLTPROC_FLAGS DOCBOOK_ROOT CAT_ENTRY_START CAT_ENTRY_END LIBERTY_LIBS BFD_LIBS POPT_LIBS have_qt_TRUE have_qt_FALSE OP_CFLAGS OP_CXXFLAGS OP_DOCDIR LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP +ac_env_CXX_set=${CXX+set} +ac_env_CXX_value=$CXX +ac_cv_env_CXX_set=${CXX+set} +ac_cv_env_CXX_value=$CXX +ac_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_env_CXXFLAGS_value=$CXXFLAGS +ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_cv_env_CXXFLAGS_value=$CXXFLAGS +ac_env_CXXCPP_set=${CXXCPP+set} +ac_env_CXXCPP_value=$CXXCPP +ac_cv_env_CXXCPP_set=${CXXCPP+set} +ac_cv_env_CXXCPP_value=$CXXCPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +X features: + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --enable-abi enable abi portability code (default is disabled) + --enable-pch enable precompiled header (default is disabled) + --enable-gcov enable option for gcov coverage testing (default is disabled) + --disable-werror disable -Werror flag (default is enabled for non-release) + --disable-optimization disable optimization flags (default is enabled) + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-binutils=dir Path to binutils installation to use + --with-gcc=dir Path to GCC installation to use + --with-kernel-support Use 2.6 kernel (no kernel source tree required) + --with-linux=dir Path to Linux source tree + --with-module-dir=dir Path to module installation directory + --with-extra-includes=DIR add extra include paths + --with-extra-libs=DIR add extra library paths + --with-x use the X Window System + --with-qt-dir where the root of Qt is installed + --with-qt-includes where the Qt includes are. + --with-qt-libraries where the Qt library is installed. + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + CPP C preprocessor + CXX C++ compiler command + CXXFLAGS C++ compiler flags + CXXCPP C++ preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright (C) 2003 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + +am__api_version="1.9" +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +test "$program_prefix" != NONE && + program_transform_name="s,^,$program_prefix,;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$,$program_suffix,;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE=oprofile + VERSION=0.9.1 + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + STRIP=$ac_ct_STRIP +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + ac_config_headers="$ac_config_headers config.h" + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + +DATE="`date '+%a %d %B %Y'`" + + +OPROFILE_DIR=`pwd` + + +# this needs to come before --with-gcc so we link with binutil's version +# of libiberty ... sigh + +# Check whether --with-binutils or --without-binutils was given. +if test "${with_binutils+set}" = set; then + withval="$with_binutils" + BINUTILSDIR=$withval +fi; + +if test "$BINUTILSDIR" != ""; then + LD="$BINUTILSDIR/ld" + if test "$CFLAGS" = ""; then + CFLAGS="-g -O2" + fi + if test "$CXXFLAGS" = ""; then + CXXFLAGS="-g -O2" + fi + CFLAGS="$CFLAGS -I $BINUTILSDIR/include" + CXXFLAGS="$CXXFLAGS -I $BINUTILSDIR/include" + LDFLAGS="$LDFLAGS -L $BINUTILSDIR/lib -Xlinker -R -Xlinker $BINUTILSDIR/lib" +fi + + +# Check whether --with-gcc or --without-gcc was given. +if test "${with_gcc+set}" = set; then + withval="$with_gcc" + GCCDIR=$withval +fi; + +if test "$GCCDIR" != ""; then + CC="$GCCDIR/bin/gcc" + CXX="$GCCDIR/bin/g++" + LDFLAGS="$LDFLAGS -L $GCCDIR/lib -Xlinker -R -Xlinker $GCCDIR/lib" +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + + ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6 +rm -f confinc confmf + +# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval="$enable_dependency_tracking" + +fi; +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + + +depcc="$CC" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CXX" && break +done +test -n "$ac_ct_CXX" || ac_ct_CXX="g++" + + CXX=$ac_ct_CXX +fi + + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C++ compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +CXXFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cxx_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CXX" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6 +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + +# Extract the first word of "ld", so it can be a program name with args. +set dummy ld; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$LD"; then + ac_cv_prog_LD="$LD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LD="ld" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +LD=$ac_cv_prog_LD +if test -n "$LD"; then + echo "$as_me:$LINENO: result: $LD" >&5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +test "$LD" || { { echo "$as_me:$LINENO: error: ld not found" >&5 +echo "$as_me: error: ld not found" >&2;} + { (exit 1); exit 1; }; } + + + +echo "$as_me:$LINENO: checking for kernel OProfile support" >&5 +echo $ECHO_N "checking for kernel OProfile support... $ECHO_C" >&6 + +# Check whether --with-kernel-support or --without-kernel-support was given. +if test "${with_kernel_support+set}" = set; then + withval="$with_kernel_support" + if test "$withval" = "yes"; then + OPROFILE_26=yes +fi + +fi; + +if test "$OPROFILE_26" != "yes"; then + + + KSRC=/lib/modules/`uname -r`/build + +# Check whether --with-linux or --without-linux was given. +if test "${with_linux+set}" = set; then + withval="$with_linux" + KSRC=$withval +fi; + KINC=$KSRC/include + + + +SAVE_CFLAGS=$CFLAGS +CFLAGS="-I$KINC -O2 -D__KERNEL__" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +#ifndef CONFIG_OPROFILE +break_me_hard(\\\); +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + OPROFILE_26=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +OPROFILE_26=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS + + +SAVE_CFLAGS=$CFLAGS +CFLAGS="-I$KINC -O2 -D__KERNEL__" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +#ifndef CONFIG_OPROFILE_MODULE +break_me_hard(\\\); +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + OPROFILE_26=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +OPROFILE_26=$OPROFILE_26 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS + +fi +echo "$as_me:$LINENO: result: $OPROFILE_26" >&5 +echo "${ECHO_T}$OPROFILE_26" >&6 + + + +if test "$OPROFILE_26" = yes; then + kernel_support_TRUE= + kernel_support_FALSE='#' +else + kernel_support_TRUE='#' + kernel_support_FALSE= +fi + + + + +if test "$OPROFILE_26" = "no"; then + +if test ! -f $KINC/linux/autoconf.h; then + { { echo "$as_me:$LINENO: error: no suitably configured kernel include tree found" >&5 +echo "$as_me: error: no suitably configured kernel include tree found" >&2;} + { (exit 1); exit 1; }; } +fi + + + +echo "$as_me:$LINENO: checking for kernel version" >&5 +echo $ECHO_N "checking for kernel version... $ECHO_C" >&6 +eval KVERS=`gcc -I$KINC -E -dM $KINC/linux/version.h | grep -w UTS_RELEASE | awk '{print $3}'` +echo "$as_me:$LINENO: result: $KVERS" >&5 +echo "${ECHO_T}$KVERS" >&6 +case "$KVERS" in +2.2.*|2.4.*) ;; +*) { { echo "$as_me:$LINENO: error: Unsupported kernel version" >&5 +echo "$as_me: error: Unsupported kernel version" >&2;} + { (exit 1); exit 1; }; } +esac + +echo "$as_me:$LINENO: checking kernel version" >&5 +echo $ECHO_N "checking kernel version... $ECHO_C" >&6 + +SAVE_CFLAGS=$CFLAGS +CFLAGS="-I$KINC -D__KERNEL__ -Werror" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + #include + +int +main () +{ + + #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 2, 10) + break_me_hard(\\\); + #endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: ok" >&5 +echo "${ECHO_T}ok" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: check html documentation install section" >&5 +echo "$as_me: error: check html documentation install section" >&2;} + { (exit 1); exit 1; }; } +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS + + +echo "$as_me:$LINENO: checking for $KINC/linux/spinlock.h" >&5 +echo $ECHO_N "checking for $KINC/linux/spinlock.h... $ECHO_C" >&6 +if test -f $KINC/linux/spinlock.h; then + EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DHAVE_LINUX_SPINLOCK_HEADER" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +echo "$as_me:$LINENO: checking for rtc_lock" >&5 +echo $ECHO_N "checking for rtc_lock... $ECHO_C" >&6 +gcc -I$KINC -E $KINC/linux/mc146818rtc.h | grep rtc_lock >/dev/null +if test "$?" -eq 0; then + EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DRTC_LOCK" + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +arch="unknown" +echo "$as_me:$LINENO: checking for x86 architecture" >&5 +echo $ECHO_N "checking for x86 architecture... $ECHO_C" >&6 + +SAVE_CFLAGS=$CFLAGS +CFLAGS="-I$KINC -O2 -D__KERNEL__" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +#ifndef CONFIG_X86 +break_me_hard(\\\); +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + x86=1 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +x86=0 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS + + +SAVE_CFLAGS=$CFLAGS +CFLAGS="-I$KINC -O2 -D__KERNEL__" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +#ifndef CONFIG_X86_WP_WORKS_OK +break_me_hard(\\\); +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + x86=1 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +x86=$x86 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS + +x=no +test "x$x86" = "x1" && x=yes +echo "$as_me:$LINENO: result: $x" >&5 +echo "${ECHO_T}$x" >&6 +test "$x86" = 1 && arch="x86" + +if test "$arch" = "unknown"; then + echo "$as_me:$LINENO: checking for ia64 architecture" >&5 +echo $ECHO_N "checking for ia64 architecture... $ECHO_C" >&6 + +SAVE_CFLAGS=$CFLAGS +CFLAGS="-I$KINC -O2 -D__KERNEL__" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +#ifndef CONFIG_IA64 +break_me_hard(\\\); +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ia64=1 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ia64=0 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS + + x=no +test "x$ia64" = "x1" && x=yes +echo "$as_me:$LINENO: result: $x" >&5 +echo "${ECHO_T}$x" >&6 + test "$ia64" = 1 && arch="ia64" +fi + +test "$arch" = "unknown" && { { echo "$as_me:$LINENO: error: Unsupported architecture" >&5 +echo "$as_me: error: Unsupported architecture" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking arch/kernel version combination" >&5 +echo $ECHO_N "checking arch/kernel version combination... $ECHO_C" >&6 +case "$arch" in +ia64) + +SAVE_CFLAGS=$CFLAGS +CFLAGS="-I$KINC -D__KERNEL__ -Werror" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + #include + +int +main () +{ + + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 18) + break_me_hard(\\\); + #endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: ok" >&5 +echo "${ECHO_T}ok" >&6 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: unsupported arch/kernel" >&5 +echo "$as_me: error: unsupported arch/kernel" >&2;} + { (exit 1); exit 1; }; } +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS + ;; +*) echo "$as_me:$LINENO: result: ok" >&5 +echo "${ECHO_T}ok" >&6 +esac + +echo "$as_me:$LINENO: checking for preempt patch" >&5 +echo $ECHO_N "checking for preempt patch... $ECHO_C" >&6 + +SAVE_CFLAGS=$CFLAGS +CFLAGS="-I$KINC -O2 -D__KERNEL__" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +#ifndef CONFIG_PREEMPT +break_me_hard(\\\); +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + preempt=1 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +preempt=0 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS + +x=no +test "x$preempt" = "x1" && x=yes +echo "$as_me:$LINENO: result: $x" >&5 +echo "${ECHO_T}$x" >&6 +test "$preempt" = 0 || { { echo "$as_me:$LINENO: error: unsupported kernel configuration : CONFIG_PREEMPT" >&5 +echo "$as_me: error: unsupported kernel configuration : CONFIG_PREEMPT" >&2;} + { (exit 1); exit 1; }; } + + + +MODINSTALLDIR=/lib/modules/$KVERS + +OPROFILE_MODULE_ARCH=$arch + + + +fi + + +# Check whether --with-module-dir or --without-module-dir was given. +if test "${with_module_dir+set}" = set; then + withval="$with_module_dir" + MODINSTALLDIR=$withval +fi; + + + +echo "$as_me:$LINENO: checking whether malloc attribute is understood" >&5 +echo $ECHO_N "checking whether malloc attribute is understood... $ECHO_C" >&6 +SAVE_CFLAGS=$CFLAGS +CFLAGS="-Werror $CFLAGS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + +void monkey() __attribute__((malloc)); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; +cat >>confdefs.h <<\_ACEOF +#define MALLOC_ATTRIBUTE_OK 1 +_ACEOF + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS + + + +echo "$as_me:$LINENO: checking whether __builtin_expect is understood" >&5 +echo $ECHO_N "checking whether __builtin_expect is understood... $ECHO_C" >&6 +SAVE_CFLAGS=$CFLAGS +CFLAGS="-Werror $CFLAGS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + +int i; +if (__builtin_expect(i, 0)) { } + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DEXPECT_OK" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS + + + + + +topdir=`pwd` + + + + +# Check whether --with-extra-includes or --without-extra-includes was given. +if test "${with_extra_includes+set}" = set; then + withval="$with_extra_includes" + use_extra_includes="$withval" +else + use_extra_includes=NO + +fi; +if test -n "$use_extra_includes" && \ + test "$use_extra_includes" != "NO"; then + ac_save_ifs=$IFS + IFS=':' + for dir in $use_extra_includes; do + extra_includes="$extra_includes -I$dir" + done + IFS=$ac_save_ifs + CPPFLAGS="$CPPFLAGS $extra_includes" +fi + + +# Check whether --with-extra-libs or --without-extra-libs was given. +if test "${with_extra_libs+set}" = set; then + withval="$with_extra_libs" + use_extra_libs=$withval +else + use_extra_libs=NO + +fi; +if test -n "$use_extra_libs" && \ + test "$use_extra_libs" != "NO"; then + ac_save_ifs=$IFS + IFS=':' + for dir in $use_extra_libs; do + extra_libraries="$extra_libraries -L$dir" + done + IFS=$ac_save_ifs + LDFLAGS="$LDFLAGS $extra_libraries" +fi + + + +ORIG_SAVE_LIBS="$LIBS" + + + +for ac_func in sched_setaffinity perfmonctl +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +echo "$as_me:$LINENO: checking for poptGetContext in -lpopt" >&5 +echo $ECHO_N "checking for poptGetContext in -lpopt... $ECHO_C" >&6 +if test "${ac_cv_lib_popt_poptGetContext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpopt $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char poptGetContext (); +int +main () +{ +poptGetContext (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_popt_poptGetContext=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_popt_poptGetContext=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_popt_poptGetContext" >&5 +echo "${ECHO_T}$ac_cv_lib_popt_poptGetContext" >&6 +if test $ac_cv_lib_popt_poptGetContext = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPOPT 1 +_ACEOF + + LIBS="-lpopt $LIBS" + +else + { { echo "$as_me:$LINENO: error: popt library not found" >&5 +echo "$as_me: error: popt library not found" >&2;} + { (exit 1); exit 1; }; } +fi + + + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + +for ac_header in libiberty.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +echo "$as_me:$LINENO: checking for cplus_demangle in -liberty" >&5 +echo $ECHO_N "checking for cplus_demangle in -liberty... $ECHO_C" >&6 +if test "${ac_cv_lib_iberty_cplus_demangle+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-liberty $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char cplus_demangle (); +int +main () +{ +cplus_demangle (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_iberty_cplus_demangle=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_iberty_cplus_demangle=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_iberty_cplus_demangle" >&5 +echo "${ECHO_T}$ac_cv_lib_iberty_cplus_demangle" >&6 +if test $ac_cv_lib_iberty_cplus_demangle = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBIBERTY 1 +_ACEOF + + LIBS="-liberty $LIBS" + +else + { { echo "$as_me:$LINENO: error: liberty library not found" >&5 +echo "$as_me: error: liberty library not found" >&2;} + { (exit 1); exit 1; }; } +fi + + +for ac_func in xcalloc +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +for ac_func in xmemdup +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen (); +int +main () +{ +dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dl_dlopen=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 +if test $ac_cv_lib_dl_dlopen = yes; then + LIBS="$LIBS -ldl"; DL_LIB="-ldl" +else + DL_LIB="" +fi + +echo "$as_me:$LINENO: checking for main in -lintl" >&5 +echo $ECHO_N "checking for main in -lintl... $ECHO_C" >&6 +if test "${ac_cv_lib_intl_main+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lintl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + +int +main () +{ +main (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_intl_main=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_intl_main=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_intl_main" >&5 +echo "${ECHO_T}$ac_cv_lib_intl_main" >&6 +if test $ac_cv_lib_intl_main = yes; then + LIBS="$LIBS -lintl"; INTL_LIB="-lintl" +else + INTL_LIB="" +fi + + +echo "$as_me:$LINENO: checking for bfd_openr in -lbfd" >&5 +echo $ECHO_N "checking for bfd_openr in -lbfd... $ECHO_C" >&6 +if test "${ac_cv_lib_bfd_bfd_openr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbfd $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char bfd_openr (); +int +main () +{ +bfd_openr (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_bfd_bfd_openr=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_bfd_bfd_openr=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_bfd_bfd_openr" >&5 +echo "${ECHO_T}$ac_cv_lib_bfd_bfd_openr" >&6 +if test $ac_cv_lib_bfd_bfd_openr = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBBFD 1 +_ACEOF + + LIBS="-lbfd $LIBS" + +else + { { echo "$as_me:$LINENO: error: bfd library not found" >&5 +echo "$as_me: error: bfd library not found" >&2;} + { (exit 1); exit 1; }; } +fi + + +# Determine if bfd_get_synthetic_symtab macro is available +OS="`uname`" +if test "$OS" = "Linux"; then + echo "$as_me:$LINENO: checking whether bfd_get_synthetic_symtab() exists in BFD library" >&5 +echo $ECHO_N "checking whether bfd_get_synthetic_symtab() exists in BFD library... $ECHO_C" >&6 + rm -f test-for-synth + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +asymbol * synthsyms; bfd * ibfd = 0; + long synth_count = bfd_get_synthetic_symtab(ibfd, 0, 0, 0, 0, &synthsyms); + extern const bfd_target bfd_elf64_powerpc_vec; + extern const bfd_target bfd_elf64_powerpcle_vec; + char * ppc_name = bfd_elf64_powerpc_vec.name; + char * ppcle_name = bfd_elf64_powerpcle_vec.name; + ; + return 0; +} + +_ACEOF + $CC conftest.$ac_ext $LIBS -o test-for-synth > /dev/null 2>&1 + if test -f test-for-synth; then + echo "yes" + SYNTHESIZE_SYMBOLS='1' + else + echo "no" + SYNTHESIZE_SYMBOLS='0' + fi + +cat >>confdefs.h <<_ACEOF +#define SYNTHESIZE_SYMBOLS $SYNTHESIZE_SYMBOLS +_ACEOF + + rm -f test-for-synth* + +fi + + + +# C++ tests + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + +echo "$as_me:$LINENO: checking popt prototype" >&5 +echo $ECHO_N "checking popt prototype... $ECHO_C" >&6 +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS="-Werror $CXXFLAGS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + +int c; char **v; +poptGetContext(0, c, v, 0, 0); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: takes char **" >&5 +echo "${ECHO_T}takes char **" >&6; +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: takes const char **" >&5 +echo "${ECHO_T}takes const char **" >&6; +cat >>confdefs.h <<\_ACEOF +#define CONST_POPT 1 +_ACEOF + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS="$SAVE_CXXFLAGS" + + + +echo "$as_me:$LINENO: checking whether to use included sstream" >&5 +echo $ECHO_N "checking whether to use included sstream... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CXXFLAGS="$OP_CXXFLAGS -I\${top_srcdir}/include" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + + +echo "$as_me:$LINENO: checking whether bfd defines bool" >&5 +echo $ECHO_N "checking whether bfd defines bool... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; +cat >>confdefs.h <<\_ACEOF +#define TRUE_FALSE_ALREADY_DEFINED 1 +_ACEOF + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + + echo "$as_me:$LINENO: checking type of size_t" >&5 +echo $ECHO_N "checking type of size_t... $ECHO_C" >&6 + for f in "unsigned" "unsigned long"; do + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +SAVE_CFLAGS=$CFLAGS +CFLAGS="-Werror $CFLAGS" + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + +int +main () +{ + + typedef void (*fct1)(size_t); + typedef void (*fct2)($f); + fct1 f1 = 0; + fct2 f2 = 0; + if (f1 == f2) {} + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + SIZE_T_TYPE="$f" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +SIZE_T_TYPE="" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +CFLAGS=$SAVE_CFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + if test -n "${SIZE_T_TYPE}"; then + break + fi + done + if test -n "${SIZE_T_TYPE}"; then + echo "$as_me:$LINENO: result: ${SIZE_T_TYPE}" >&5 +echo "${ECHO_T}${SIZE_T_TYPE}" >&6 + else + { { echo "$as_me:$LINENO: error: not found" >&5 +echo "$as_me: error: not found" >&2;} + { (exit 1); exit 1; }; } + fi + + + + echo "$as_me:$LINENO: checking type of ptrdiff_t" >&5 +echo $ECHO_N "checking type of ptrdiff_t... $ECHO_C" >&6 + for f in "int" "long"; do + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +SAVE_CFLAGS=$CFLAGS +CFLAGS="-Werror $CFLAGS" + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + +int +main () +{ + + typedef void (*fct1)(ptrdiff_t); + typedef void (*fct2)($f); + fct1 f1 = 0; + fct2 f2 = 0; + if (f1 == f2) {} + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + PTRDIFF_T_TYPE="$f" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +PTRDIFF_T_TYPE="" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +CFLAGS=$SAVE_CFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + if test -n "${PTRDIFF_T_TYPE}"; then + break + fi + done + if test -n "${PTRDIFF_T_TYPE}"; then + echo "$as_me:$LINENO: result: ${PTRDIFF_T_TYPE}" >&5 +echo "${ECHO_T}${PTRDIFF_T_TYPE}" >&6 + else + { { echo "$as_me:$LINENO: error: not found" >&5 +echo "$as_me: error: not found" >&2;} + { (exit 1); exit 1; }; } + fi + + + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 +echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 +if test -z "$CXXCPP"; then + if test "${ac_cv_prog_CXXCPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +echo "$as_me:$LINENO: result: $CXXCPP" >&5 +echo "${ECHO_T}$CXXCPP" >&6 +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +echo "$as_me:$LINENO: checking for X" >&5 +echo $ECHO_N "checking for X... $ECHO_C" >&6 + + +# Check whether --with-x or --without-x was given. +if test "${with_x+set}" = set; then + withval="$with_x" + +fi; +# $have_x is `yes', `no', `disabled', or empty when we do not yet know. +if test "x$with_x" = xno; then + # The user explicitly disabled X. + have_x=disabled +else + if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then + # Both variables are already set. + have_x=yes + else + if test "${ac_cv_have_x+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # One or both of the vars are not set, and there is no cached value. +ac_x_includes=no ac_x_libraries=no +rm -fr conftest.dir +if mkdir conftest.dir; then + cd conftest.dir + # Make sure to not put "make" in the Imakefile rules, since we grep it out. + cat >Imakefile <<'_ACEOF' +acfindx: + @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' +_ACEOF + if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then + # GNU make sometimes prints "make[1]: Entering...", which would confuse us. + eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` + # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. + for ac_extension in a so sl; do + if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && + test -f $ac_im_libdir/libX11.$ac_extension; then + ac_im_usrlibdir=$ac_im_libdir; break + fi + done + # Screen out bogus values from the imake configuration. They are + # bogus both because they are the default anyway, and because + # using them would break gcc on systems where it needs fixed includes. + case $ac_im_incroot in + /usr/include) ;; + *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;; + esac + case $ac_im_usrlibdir in + /usr/lib | /lib) ;; + *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;; + esac + fi + cd .. + rm -fr conftest.dir +fi + +# Standard set of common directories for X headers. +# Check X11 before X11Rn because it is often a symlink to the current release. +ac_x_header_dirs=' +/usr/X11/include +/usr/X11R6/include +/usr/X11R5/include +/usr/X11R4/include + +/usr/include/X11 +/usr/include/X11R6 +/usr/include/X11R5 +/usr/include/X11R4 + +/usr/local/X11/include +/usr/local/X11R6/include +/usr/local/X11R5/include +/usr/local/X11R4/include + +/usr/local/include/X11 +/usr/local/include/X11R6 +/usr/local/include/X11R5 +/usr/local/include/X11R4 + +/usr/X386/include +/usr/x386/include +/usr/XFree86/include/X11 + +/usr/include +/usr/local/include +/usr/unsupported/include +/usr/athena/include +/usr/local/x11r5/include +/usr/lpp/Xamples/include + +/usr/openwin/include +/usr/openwin/share/include' + +if test "$ac_x_includes" = no; then + # Guess where to find include files, by looking for Intrinsic.h. + # First, try using that file with no special directory specified. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # We can compile using X headers with no special include directory. +ac_x_includes= +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + for ac_dir in $ac_x_header_dirs; do + if test -r "$ac_dir/X11/Intrinsic.h"; then + ac_x_includes=$ac_dir + break + fi +done +fi +rm -f conftest.err conftest.$ac_ext +fi # $ac_x_includes = no + +if test "$ac_x_libraries" = no; then + # Check for the libraries. + # See if we find them without any special options. + # Don't add to $LIBS permanently. + ac_save_LIBS=$LIBS + LIBS="-lXt $LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +XtMalloc (0) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + LIBS=$ac_save_LIBS +# We can link X programs with no special library path. +ac_x_libraries= +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +LIBS=$ac_save_LIBS +for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` +do + # Don't even attempt the hair of trying to link an X program! + for ac_extension in a so sl; do + if test -r $ac_dir/libXt.$ac_extension; then + ac_x_libraries=$ac_dir + break 2 + fi + done +done +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi # $ac_x_libraries = no + +if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then + # Didn't find X anywhere. Cache the known absence of X. + ac_cv_have_x="have_x=no" +else + # Record where we found X for the cache. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" +fi +fi + + fi + eval "$ac_cv_have_x" +fi # $with_x != no + +if test "$have_x" != yes; then + echo "$as_me:$LINENO: result: $have_x" >&5 +echo "${ECHO_T}$have_x" >&6 + no_x=yes +else + # If each of the values was on the command line, it overrides each guess. + test "x$x_includes" = xNONE && x_includes=$ac_x_includes + test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries + # Update the cache value to reflect the command line values. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$x_includes ac_x_libraries=$x_libraries" + echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5 +echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6 +fi + +if test "$no_x" = yes; then + # Not all programs may use this symbol, but it does not hurt to define it. + +cat >>confdefs.h <<\_ACEOF +#define X_DISPLAY_MISSING 1 +_ACEOF + + X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= +else + if test -n "$x_includes"; then + X_CFLAGS="$X_CFLAGS -I$x_includes" + fi + + # It would also be nice to do this for all -L options, not just this one. + if test -n "$x_libraries"; then + X_LIBS="$X_LIBS -L$x_libraries" + # For Solaris; some versions of Sun CC require a space after -R and + # others require no space. Words are not sufficient . . . . + case `(uname -sr) 2>/dev/null` in + "SunOS 5"*) + echo "$as_me:$LINENO: checking whether -R must be followed by a space" >&5 +echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6 + ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_R_nospace=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_R_nospace=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test $ac_R_nospace = yes; then + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + X_LIBS="$X_LIBS -R$x_libraries" + else + LIBS="$ac_xsave_LIBS -R $x_libraries" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_R_space=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_R_space=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test $ac_R_space = yes; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + X_LIBS="$X_LIBS -R $x_libraries" + else + echo "$as_me:$LINENO: result: neither works" >&5 +echo "${ECHO_T}neither works" >&6 + fi + fi + LIBS=$ac_xsave_LIBS + esac + fi + + # Check for system-dependent libraries X programs must link with. + # Do this before checking for the system-independent R6 libraries + # (-lICE), since we may need -lsocket or whatever for X linking. + + if test "$ISC" = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" + else + # Martyn Johnson says this is needed for Ultrix, if the X + # libraries were built with DECnet support. And Karl Berry says + # the Alpha needs dnet_stub (dnet does not exist). + ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char XOpenDisplay (); +int +main () +{ +XOpenDisplay (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5 +echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6 +if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldnet $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dnet_ntoa (); +int +main () +{ +dnet_ntoa (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dnet_dnet_ntoa=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dnet_dnet_ntoa=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 +echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6 +if test $ac_cv_lib_dnet_dnet_ntoa = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" +fi + + if test $ac_cv_lib_dnet_dnet_ntoa = no; then + echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5 +echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6 +if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldnet_stub $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dnet_ntoa (); +int +main () +{ +dnet_ntoa (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dnet_stub_dnet_ntoa=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_dnet_stub_dnet_ntoa=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 +echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6 +if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" +fi + + fi +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$ac_xsave_LIBS" + + # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, + # to get the SysV transport functions. + # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4) + # needs -lnsl. + # The nsl library prevents programs from opening the X display + # on Irix 5.2, according to T.E. Dickey. + # The functions gethostbyname, getservbyname, and inet_addr are + # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. + echo "$as_me:$LINENO: checking for gethostbyname" >&5 +echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6 +if test "${ac_cv_func_gethostbyname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define gethostbyname to an innocuous variant, in case declares gethostbyname. + For example, HP-UX 11i declares gettimeofday. */ +#define gethostbyname innocuous_gethostbyname + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char gethostbyname (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef gethostbyname + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethostbyname (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) +choke me +#else +char (*f) () = gethostbyname; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != gethostbyname; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_gethostbyname=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_gethostbyname=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5 +echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6 + + if test $ac_cv_func_gethostbyname = no; then + echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5 +echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6 +if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethostbyname (); +int +main () +{ +gethostbyname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_nsl_gethostbyname=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_nsl_gethostbyname=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5 +echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6 +if test $ac_cv_lib_nsl_gethostbyname = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" +fi + + if test $ac_cv_lib_nsl_gethostbyname = no; then + echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5 +echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6 +if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbsd $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethostbyname (); +int +main () +{ +gethostbyname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_bsd_gethostbyname=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_bsd_gethostbyname=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5 +echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6 +if test $ac_cv_lib_bsd_gethostbyname = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" +fi + + fi + fi + + # lieder@skyler.mavd.honeywell.com says without -lsocket, + # socket/setsockopt and other routines are undefined under SCO ODT + # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary + # on later versions), says Simon Leinen: it contains gethostby* + # variants that don't use the name server (or something). -lsocket + # must be given before -lnsl if both are needed. We assume that + # if connect needs -lnsl, so does gethostbyname. + echo "$as_me:$LINENO: checking for connect" >&5 +echo $ECHO_N "checking for connect... $ECHO_C" >&6 +if test "${ac_cv_func_connect+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define connect to an innocuous variant, in case declares connect. + For example, HP-UX 11i declares gettimeofday. */ +#define connect innocuous_connect + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char connect (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef connect + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char connect (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_connect) || defined (__stub___connect) +choke me +#else +char (*f) () = connect; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != connect; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_connect=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_connect=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5 +echo "${ECHO_T}$ac_cv_func_connect" >&6 + + if test $ac_cv_func_connect = no; then + echo "$as_me:$LINENO: checking for connect in -lsocket" >&5 +echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6 +if test "${ac_cv_lib_socket_connect+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $X_EXTRA_LIBS $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char connect (); +int +main () +{ +connect (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_socket_connect=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_socket_connect=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5 +echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6 +if test $ac_cv_lib_socket_connect = yes; then + X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" +fi + + fi + + # Guillermo Gomez says -lposix is necessary on A/UX. + echo "$as_me:$LINENO: checking for remove" >&5 +echo $ECHO_N "checking for remove... $ECHO_C" >&6 +if test "${ac_cv_func_remove+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define remove to an innocuous variant, in case declares remove. + For example, HP-UX 11i declares gettimeofday. */ +#define remove innocuous_remove + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char remove (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef remove + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char remove (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_remove) || defined (__stub___remove) +choke me +#else +char (*f) () = remove; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != remove; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_remove=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_remove=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5 +echo "${ECHO_T}$ac_cv_func_remove" >&6 + + if test $ac_cv_func_remove = no; then + echo "$as_me:$LINENO: checking for remove in -lposix" >&5 +echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6 +if test "${ac_cv_lib_posix_remove+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lposix $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char remove (); +int +main () +{ +remove (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_posix_remove=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_posix_remove=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5 +echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6 +if test $ac_cv_lib_posix_remove = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" +fi + + fi + + # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. + echo "$as_me:$LINENO: checking for shmat" >&5 +echo $ECHO_N "checking for shmat... $ECHO_C" >&6 +if test "${ac_cv_func_shmat+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shmat to an innocuous variant, in case declares shmat. + For example, HP-UX 11i declares gettimeofday. */ +#define shmat innocuous_shmat + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shmat (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef shmat + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shmat (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shmat) || defined (__stub___shmat) +choke me +#else +char (*f) () = shmat; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != shmat; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_shmat=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_shmat=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5 +echo "${ECHO_T}$ac_cv_func_shmat" >&6 + + if test $ac_cv_func_shmat = no; then + echo "$as_me:$LINENO: checking for shmat in -lipc" >&5 +echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6 +if test "${ac_cv_lib_ipc_shmat+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lipc $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shmat (); +int +main () +{ +shmat (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_ipc_shmat=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_ipc_shmat=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5 +echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6 +if test $ac_cv_lib_ipc_shmat = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" +fi + + fi + fi + + # Check for libraries that X11R6 Xt/Xaw programs need. + ac_save_LDFLAGS=$LDFLAGS + test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" + # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to + # check for ICE first), but we must link in the order -lSM -lICE or + # we get undefined symbols. So assume we have SM if we have ICE. + # These have to be linked with before -lX11, unlike the other + # libraries we check for below, so use a different variable. + # John Interrante, Karl Berry + echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5 +echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6 +if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lICE $X_EXTRA_LIBS $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char IceConnectionNumber (); +int +main () +{ +IceConnectionNumber (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_ICE_IceConnectionNumber=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_ICE_IceConnectionNumber=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 +echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6 +if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then + X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" +fi + + LDFLAGS=$ac_save_LDFLAGS + +fi + +ORIG_X_SAVE_LIBS="$LIBS" +LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS" +X_LIBS="$LIBS" + + + FATAL=0 + + +# Check whether --with-qt-dir or --without-qt-dir was given. +if test "${with_qt_dir+set}" = set; then + withval="$with_qt_dir" + qt_cv_dir=`eval echo "$withval"/` +fi; + + +# Check whether --with-qt-includes or --without-qt-includes was given. +if test "${with_qt_includes+set}" = set; then + withval="$with_qt_includes" + qt_cv_includes=`eval echo "$withval"` +fi; + + +# Check whether --with-qt-libraries or --without-qt-libraries was given. +if test "${with_qt_libraries+set}" = set; then + withval="$with_qt_libraries" + qt_cv_libraries=`eval echo "$withval"` +fi; + + if test -z "$qt_cv_dir"; then + qt_cv_dir=$QTDIR + fi + + if test -n "$qt_cv_dir"; then + if test -z "$qt_cv_includes"; then + qt_cv_includes=$qt_cv_dir/include + fi + if test -z "$qt_cv_libraries"; then + qt_cv_libraries=$qt_cv_dir/lib + fi + fi + + QT_INCLUDES= + QT_LDFLAGS= + if test -n "$qt_cv_includes"; then + QT_INCLUDES="-isystem $qt_cv_includes" + fi + if test -n "$qt_cv_libraries"; then + QT_LDFLAGS="-L$qt_cv_libraries" + fi + + + + + + echo "$as_me:$LINENO: checking for moc2" >&5 +echo $ECHO_N "checking for moc2... $ECHO_C" >&6 + if test "${qt_cv_path_moc2+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + qt_cv_path_moc2="NONE" + if test -n "$ac_moc2"; then + qt_cv_path_moc2="$ac_moc2"; + else + dirs="$qt_cv_dir/bin" + qt_save_IFS=$IFS + IFS=':' + for dir in $PATH; do + dirs="$dirs $dir" + done + IFS=$qt_save_IFS + + for dir in $dirs; do + if test -x "$dir/moc2"; then + if test -n ""; then + evalstr="$dir/moc2 2>&1 " + if eval $evalstr; then + qt_cv_path_moc2="$dir/moc2" + break + fi + else + qt_cv_path_moc2="$dir/moc2" + break + fi + fi + done + fi + +fi + + + if test -z "$qt_cv_path_moc2" || test "$qt_cv_path_moc2" = "NONE"; then + echo "$as_me:$LINENO: result: not found" >&5 +echo "${ECHO_T}not found" >&6 + + else + echo "$as_me:$LINENO: result: $qt_cv_path_moc2" >&5 +echo "${ECHO_T}$qt_cv_path_moc2" >&6 + ac_moc2=$qt_cv_path_moc2 + fi + + + echo "$as_me:$LINENO: checking for moc" >&5 +echo $ECHO_N "checking for moc... $ECHO_C" >&6 + if test "${qt_cv_path_moc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + qt_cv_path_moc="NONE" + if test -n "$ac_moc1"; then + qt_cv_path_moc="$ac_moc1"; + else + dirs="$qt_cv_dir/bin" + qt_save_IFS=$IFS + IFS=':' + for dir in $PATH; do + dirs="$dirs $dir" + done + IFS=$qt_save_IFS + + for dir in $dirs; do + if test -x "$dir/moc"; then + if test -n ""; then + evalstr="$dir/moc 2>&1 " + if eval $evalstr; then + qt_cv_path_moc="$dir/moc" + break + fi + else + qt_cv_path_moc="$dir/moc" + break + fi + fi + done + fi + +fi + + + if test -z "$qt_cv_path_moc" || test "$qt_cv_path_moc" = "NONE"; then + echo "$as_me:$LINENO: result: not found" >&5 +echo "${ECHO_T}not found" >&6 + + else + echo "$as_me:$LINENO: result: $qt_cv_path_moc" >&5 +echo "${ECHO_T}$qt_cv_path_moc" >&6 + ac_moc1=$qt_cv_path_moc + fi + + + if test -n "$ac_moc1" -a -n "$ac_moc2"; then + $ac_moc1 -v 2>&1 | grep "Qt 3" >/dev/null + if test "$?" = 0; then + ac_moc=$ac_moc1; + else + ac_moc=$ac_moc2; + fi + else + if test -n "$ac_moc1"; then + ac_moc=$ac_moc1; + else + ac_moc=$ac_moc2; + fi + fi + + if test -z "$ac_moc" -a "$FATAL" = 1; then + { { echo "$as_me:$LINENO: error: moc binary not found in \$PATH or $qt_cv_dir/bin !" >&5 +echo "$as_me: error: moc binary not found in \$PATH or $qt_cv_dir/bin !" >&2;} + { (exit 1); exit 1; }; } + fi + + MOC=$ac_moc + + + + echo "$as_me:$LINENO: checking for uic" >&5 +echo $ECHO_N "checking for uic... $ECHO_C" >&6 + if test "${qt_cv_path_uic+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + qt_cv_path_uic="NONE" + if test -n "$ac_uic"; then + qt_cv_path_uic="$ac_uic"; + else + dirs="$qt_cv_dir/bin" + qt_save_IFS=$IFS + IFS=':' + for dir in $PATH; do + dirs="$dirs $dir" + done + IFS=$qt_save_IFS + + for dir in $dirs; do + if test -x "$dir/uic"; then + if test -n ""; then + evalstr="$dir/uic 2>&1 " + if eval $evalstr; then + qt_cv_path_uic="$dir/uic" + break + fi + else + qt_cv_path_uic="$dir/uic" + break + fi + fi + done + fi + +fi + + + if test -z "$qt_cv_path_uic" || test "$qt_cv_path_uic" = "NONE"; then + echo "$as_me:$LINENO: result: not found" >&5 +echo "${ECHO_T}not found" >&6 + + else + echo "$as_me:$LINENO: result: $qt_cv_path_uic" >&5 +echo "${ECHO_T}$qt_cv_path_uic" >&6 + ac_uic=$qt_cv_path_uic + fi + + if test -z "$ac_uic" -a "$FATAL" = 1; then + { { echo "$as_me:$LINENO: error: uic binary not found in \$PATH or $qt_cv_dir/bin !" >&5 +echo "$as_me: error: uic binary not found in \$PATH or $qt_cv_dir/bin !" >&2;} + { (exit 1); exit 1; }; } + fi + + UIC=$ac_uic + + + + echo "$as_me:$LINENO: checking for Qt library name" >&5 +echo $ECHO_N "checking for Qt library name... $ECHO_C" >&6 + + if test "${qt_cv_libname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + SAVE_CXXFLAGS=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS" + + for libname in -lqt-mt -lqt3 -lqt2 -lqt; + do + + SAVE_LIBS="$LIBS" + LIBS="$LIBS $libname" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + #include + +int +main () +{ + + QString s("mangle_failure"); + #if (QT_VERSION < 221) + break_me_(\\\); + #endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + qt_cv_libname=$libname +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$SAVE_LIBS" + + if test -n "$qt_cv_libname"; then + break; + fi + done + + CXXFLAGS=$SAVE_CXXFLAGS + +fi + + + if test -z "$qt_cv_libname"; then + echo "$as_me:$LINENO: result: failed" >&5 +echo "${ECHO_T}failed" >&6 + if test "$FATAL" = 1 ; then + { { echo "$as_me:$LINENO: error: Cannot compile a simple Qt executable. Check you have the right \$QTDIR !" >&5 +echo "$as_me: error: Cannot compile a simple Qt executable. Check you have the right \$QTDIR !" >&2;} + { (exit 1); exit 1; }; } + fi + else + echo "$as_me:$LINENO: result: $qt_cv_libname" >&5 +echo "${ECHO_T}$qt_cv_libname" >&6 + fi + + + QT_LIB=$qt_cv_libname; + + + if test -n "$qt_cv_libname"; then + + echo "$as_me:$LINENO: checking Qt version" >&5 +echo $ECHO_N "checking Qt version... $ECHO_C" >&6 +if test "${lyx_cv_qtversion+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + SAVE_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $QT_INCLUDES" + + cat > conftest.$ac_ext < +"%%%"QT_VERSION_STR"%%%" +EOF + lyx_cv_qtversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \ + grep '^"%%%"' 2>/dev/null | \ + sed -e 's/"%%%"//g' -e 's/"//g'` + rm -f conftest.$ac_ext + CPPFLAGS=$SAVE_CPPFLAGS + +fi +echo "$as_me:$LINENO: result: $lyx_cv_qtversion" >&5 +echo "${ECHO_T}$lyx_cv_qtversion" >&6 + + QT_VERSION=$lyx_cv_qtversion + + + fi + +LIBS="$ORIG_X_SAVE_LIBS" + +# Check whether --enable-abi or --disable-abi was given. +if test "${enable_abi+set}" = set; then + enableval="$enable_abi" + enable_abi=$enableval +else + enable_abi=no +fi; +if test "$enable_abi" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define OPROF_ABI 1 +_ACEOF + +fi + + +if test "$enable_abi" = yes; then + enable_abi_TRUE= + enable_abi_FALSE='#' +else + enable_abi_TRUE='#' + enable_abi_FALSE= +fi + + +# Check whether --enable-pch or --disable-pch was given. +if test "${enable_pch+set}" = set; then + enableval="$enable_pch" + enable_pch=$enableval +else + enable_pch=no +fi; +if test "$enable_pch" = yes; then + +echo "$as_me:$LINENO: checking whether ${CXX} support precompiled header" >&5 +echo $ECHO_N "checking whether ${CXX} support precompiled header... $ECHO_C" >&6 + + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS=-Winvalid-pch +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CXXFLAGS="${OP_CXXFLAGS} -include bits/stdc++.h" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS=$SAVE_CXXFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +fi + + +# It's just rude to go over the net to build +XSLTPROC_FLAGS=--nonet +DOCBOOK_ROOT= +if test ! -f /etc/xml/catalog; then + for i in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh /usr/share/sgml/docbook/xsl-stylesheets/; + do + if test -d "$i"; then + DOCBOOK_ROOT=$i + fi + done + + # Last resort - try net + if test -z "$DOCBOOK_ROOT"; then + XSLTPROC_FLAGS= + fi +else + XML_CATALOG=/etc/xml/catalog + CAT_ENTRY_START='' +fi + +# Extract the first word of "xsltproc", so it can be a program name with args. +set dummy xsltproc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_XSLTPROC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$XSLTPROC"; then + ac_cv_prog_XSLTPROC="$XSLTPROC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_XSLTPROC="xsltproc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +XSLTPROC=$ac_cv_prog_XSLTPROC +if test -n "$XSLTPROC"; then + echo "$as_me:$LINENO: result: $XSLTPROC" >&5 +echo "${ECHO_T}$XSLTPROC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +XSLTPROC_WORKS=no +if test -n "$XSLTPROC"; then + echo "$as_me:$LINENO: checking whether xsltproc works" >&5 +echo $ECHO_N "checking whether xsltproc works... $ECHO_C" >&6 + + if test -n "$XML_CATALOG"; then + DB_FILE="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl" + else + DB_FILE="$DOCBOOK_ROOT/docbook.xsl" + fi + + $XSLTPROC $XSLTPROC_FLAGS $DB_FILE >/dev/null 2>&1 << END + + + + +END + if test "$?" = 0; then + XSLTPROC_WORKS=yes + fi + echo "$as_me:$LINENO: result: $XSLTPROC_WORKS" >&5 +echo "${ECHO_T}$XSLTPROC_WORKS" >&6 +fi + + +if test "$XSLTPROC_WORKS" = "yes"; then + have_xsltproc_TRUE= + have_xsltproc_FALSE='#' +else + have_xsltproc_TRUE='#' + have_xsltproc_FALSE= +fi + + + + + + + + + +LIBS="$ORIG_SAVE_LIBS" +LIBERTY_LIBS="-liberty $DL_LIB $INTL_LIB" +BFD_LIBS="-lbfd -liberty $DL_LIB $INTL_LIB" +POPT_LIBS="-lpopt" + + + + +# do NOT put tests here, they will fail in the case X is not installed ! + + + +if test -n "$QT_LIB"; then + have_qt_TRUE= + have_qt_FALSE='#' +else + have_qt_TRUE='#' + have_qt_FALSE= +fi + + + +echo "$as_me:$LINENO: checking whether ${CC} -W is understood" >&5 +echo $ECHO_N "checking whether ${CC} -W is understood... $ECHO_C" >&6 + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +SAVE_CFLAGS=$CFLAGS +CFLAGS=-W +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CFLAGS="${OP_CFLAGS} -W" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CXX} -W is understood" >&5 +echo $ECHO_N "checking whether ${CXX} -W is understood... $ECHO_C" >&6 + + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS=-W +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CXXFLAGS="${OP_CXXFLAGS} -W" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS=$SAVE_CXXFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CC} -Wall is understood" >&5 +echo $ECHO_N "checking whether ${CC} -Wall is understood... $ECHO_C" >&6 + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +SAVE_CFLAGS=$CFLAGS +CFLAGS=-Wall +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CFLAGS="${OP_CFLAGS} -Wall" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CXX} -Wall is understood" >&5 +echo $ECHO_N "checking whether ${CXX} -Wall is understood... $ECHO_C" >&6 + + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS=-Wall +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CXXFLAGS="${OP_CXXFLAGS} -Wall" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS=$SAVE_CXXFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CC} -fno-common is understood" >&5 +echo $ECHO_N "checking whether ${CC} -fno-common is understood... $ECHO_C" >&6 + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +SAVE_CFLAGS=$CFLAGS +CFLAGS=-fno-common +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CFLAGS="${OP_CFLAGS} -fno-common" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CXX} -fno-common is understood" >&5 +echo $ECHO_N "checking whether ${CXX} -fno-common is understood... $ECHO_C" >&6 + + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS=-fno-common +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CXXFLAGS="${OP_CXXFLAGS} -fno-common" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS=$SAVE_CXXFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CXX} -ftemplate-depth-50 is understood" >&5 +echo $ECHO_N "checking whether ${CXX} -ftemplate-depth-50 is understood... $ECHO_C" >&6 + + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS=-ftemplate-depth-50 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CXXFLAGS="${OP_CXXFLAGS} -ftemplate-depth-50" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS=$SAVE_CXXFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CC} -Wdeclaration-after-statement is understood" >&5 +echo $ECHO_N "checking whether ${CC} -Wdeclaration-after-statement is understood... $ECHO_C" >&6 + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +SAVE_CFLAGS=$CFLAGS +CFLAGS=-Wdeclaration-after-statement +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CFLAGS="${OP_CFLAGS} -Wdeclaration-after-statement" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +# Check whether --enable-gcov or --disable-gcov was given. +if test "${enable_gcov+set}" = set; then + enableval="$enable_gcov" + enable_gcov=$enableval +else + enable_gcov=no +fi; +if test "$enable_gcov" = yes; then + +echo "$as_me:$LINENO: checking whether ${CC} -fprofile-arcs is understood" >&5 +echo $ECHO_N "checking whether ${CC} -fprofile-arcs is understood... $ECHO_C" >&6 + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +SAVE_CFLAGS=$CFLAGS +CFLAGS=-fprofile-arcs +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CFLAGS="${OP_CFLAGS} -fprofile-arcs" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CXX} -fprofile-arcs is understood" >&5 +echo $ECHO_N "checking whether ${CXX} -fprofile-arcs is understood... $ECHO_C" >&6 + + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS=-fprofile-arcs +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CXXFLAGS="${OP_CXXFLAGS} -fprofile-arcs" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS=$SAVE_CXXFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CC} -ftest-coverage is understood" >&5 +echo $ECHO_N "checking whether ${CC} -ftest-coverage is understood... $ECHO_C" >&6 + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +SAVE_CFLAGS=$CFLAGS +CFLAGS=-ftest-coverage +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CFLAGS="${OP_CFLAGS} -ftest-coverage" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CXX} -ftest-coverage is understood" >&5 +echo $ECHO_N "checking whether ${CXX} -ftest-coverage is understood... $ECHO_C" >&6 + + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS=-ftest-coverage +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CXXFLAGS="${OP_CXXFLAGS} -ftest-coverage" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS=$SAVE_CXXFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +fi + +# Check whether --enable-werror or --disable-werror was given. +if test "${enable_werror+set}" = set; then + enableval="$enable_werror" + enable_werror=$enableval +else + enable_werror=yes +fi; +if test "$enable_werror" = yes; then + # enable -Werror for non-release versions. + if echo "$VERSION" | grep cvs >/dev/null; then + +echo "$as_me:$LINENO: checking whether ${CC} -Werror is understood" >&5 +echo $ECHO_N "checking whether ${CC} -Werror is understood... $ECHO_C" >&6 + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +SAVE_CFLAGS=$CFLAGS +CFLAGS=-Werror +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CFLAGS="${OP_CFLAGS} -Werror" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS=$SAVE_CFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + +echo "$as_me:$LINENO: checking whether ${CXX} -Werror is understood" >&5 +echo $ECHO_N "checking whether ${CXX} -Werror is understood... $ECHO_C" >&6 + + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS=-Werror +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; OP_CXXFLAGS="${OP_CXXFLAGS} -Werror" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS=$SAVE_CXXFLAGS +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + fi +fi + +# Check whether --enable-optimization or --disable-optimization was given. +if test "${enable_optimization+set}" = set; then + enableval="$enable_optimization" + enable_optimization=$enableval +else + enable_optimisation=yes +fi; +if test "$enable_optimization" = "no"; then + CFLAGS=`echo $CFLAGS | sed 's/-O2//g'` + CXXFLAGS=`echo $CXXFLAGS | sed 's/-O2//g'` +fi + + + + +# fixups for config.h +if test "$prefix" = "NONE"; then + my_op_prefix="$ac_default_prefix" +else + my_op_prefix="$prefix" +fi +my_op_datadir="$my_op_prefix/share" + +if test "$exec_prefix" = "NONE"; then + my_op_exec_prefix="$my_op_prefix" +else + my_op_exec_prefix="$exec_prefix" +fi +my_op_bindir="$my_op_exec_prefix/bin" + +OP_DATADIR=`eval echo "$my_op_datadir/$PACKAGE/"` + +cat >>confdefs.h <<_ACEOF +#define OP_DATADIR "$OP_DATADIR" +_ACEOF + +OP_BINDIR=`eval echo "$my_op_bindir/"` + +cat >>confdefs.h <<_ACEOF +#define OP_BINDIR "$OP_BINDIR" +_ACEOF + +OP_DOCDIR=`eval echo "${my_op_prefix}/share/doc/$PACKAGE/"` + + + ac_config_files="$ac_config_files Makefile m4/Makefile libutil/Makefile libutil/tests/Makefile libutil++/Makefile libutil++/tests/Makefile libop/Makefile libop/tests/Makefile libopt++/Makefile libdb/Makefile libdb/tests/Makefile libabi/Makefile libabi/tests/Makefile libregex/Makefile libregex/tests/Makefile libregex/stl.pat libregex/tests/mangled-name daemon/Makefile daemon/liblegacy/Makefile events/Makefile utils/Makefile doc/Makefile doc/xsl/catalog-1.xml doc/oprofile.1 doc/opcontrol.1 doc/ophelp.1 doc/opreport.1 doc/opannotate.1 doc/opgprof.1 doc/oparchive.1 doc/srcdoc/Doxyfile libpp/Makefile pp/Makefile gui/Makefile gui/ui/Makefile module/Makefile module/x86/Makefile module/ia64/Makefile" +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${kernel_support_TRUE}" && test -z "${kernel_support_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"kernel_support\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"kernel_support\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${enable_abi_TRUE}" && test -z "${enable_abi_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"enable_abi\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"enable_abi\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${have_xsltproc_TRUE}" && test -z "${have_xsltproc_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"have_xsltproc\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"have_xsltproc\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${have_qt_TRUE}" && test -z "${have_qt_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"have_qt\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"have_qt\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.59. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.59, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2003 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS section. +# + +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "m4/Makefile" ) CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;; + "libutil/Makefile" ) CONFIG_FILES="$CONFIG_FILES libutil/Makefile" ;; + "libutil/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES libutil/tests/Makefile" ;; + "libutil++/Makefile" ) CONFIG_FILES="$CONFIG_FILES libutil++/Makefile" ;; + "libutil++/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES libutil++/tests/Makefile" ;; + "libop/Makefile" ) CONFIG_FILES="$CONFIG_FILES libop/Makefile" ;; + "libop/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES libop/tests/Makefile" ;; + "libopt++/Makefile" ) CONFIG_FILES="$CONFIG_FILES libopt++/Makefile" ;; + "libdb/Makefile" ) CONFIG_FILES="$CONFIG_FILES libdb/Makefile" ;; + "libdb/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES libdb/tests/Makefile" ;; + "libabi/Makefile" ) CONFIG_FILES="$CONFIG_FILES libabi/Makefile" ;; + "libabi/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES libabi/tests/Makefile" ;; + "libregex/Makefile" ) CONFIG_FILES="$CONFIG_FILES libregex/Makefile" ;; + "libregex/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES libregex/tests/Makefile" ;; + "libregex/stl.pat" ) CONFIG_FILES="$CONFIG_FILES libregex/stl.pat" ;; + "libregex/tests/mangled-name" ) CONFIG_FILES="$CONFIG_FILES libregex/tests/mangled-name" ;; + "daemon/Makefile" ) CONFIG_FILES="$CONFIG_FILES daemon/Makefile" ;; + "daemon/liblegacy/Makefile" ) CONFIG_FILES="$CONFIG_FILES daemon/liblegacy/Makefile" ;; + "events/Makefile" ) CONFIG_FILES="$CONFIG_FILES events/Makefile" ;; + "utils/Makefile" ) CONFIG_FILES="$CONFIG_FILES utils/Makefile" ;; + "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + "doc/xsl/catalog-1.xml" ) CONFIG_FILES="$CONFIG_FILES doc/xsl/catalog-1.xml" ;; + "doc/oprofile.1" ) CONFIG_FILES="$CONFIG_FILES doc/oprofile.1" ;; + "doc/opcontrol.1" ) CONFIG_FILES="$CONFIG_FILES doc/opcontrol.1" ;; + "doc/ophelp.1" ) CONFIG_FILES="$CONFIG_FILES doc/ophelp.1" ;; + "doc/opreport.1" ) CONFIG_FILES="$CONFIG_FILES doc/opreport.1" ;; + "doc/opannotate.1" ) CONFIG_FILES="$CONFIG_FILES doc/opannotate.1" ;; + "doc/opgprof.1" ) CONFIG_FILES="$CONFIG_FILES doc/opgprof.1" ;; + "doc/oparchive.1" ) CONFIG_FILES="$CONFIG_FILES doc/oparchive.1" ;; + "doc/srcdoc/Doxyfile" ) CONFIG_FILES="$CONFIG_FILES doc/srcdoc/Doxyfile" ;; + "libpp/Makefile" ) CONFIG_FILES="$CONFIG_FILES libpp/Makefile" ;; + "pp/Makefile" ) CONFIG_FILES="$CONFIG_FILES pp/Makefile" ;; + "gui/Makefile" ) CONFIG_FILES="$CONFIG_FILES gui/Makefile" ;; + "gui/ui/Makefile" ) CONFIG_FILES="$CONFIG_FILES gui/ui/Makefile" ;; + "module/Makefile" ) CONFIG_FILES="$CONFIG_FILES module/Makefile" ;; + "module/x86/Makefile" ) CONFIG_FILES="$CONFIG_FILES module/x86/Makefile" ;; + "module/ia64/Makefile" ) CONFIG_FILES="$CONFIG_FILES module/ia64/Makefile" ;; + "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@CYGPATH_W@,$CYGPATH_W,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@install_sh@,$install_sh,;t t +s,@STRIP@,$STRIP,;t t +s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@mkdir_p@,$mkdir_p,;t t +s,@AWK@,$AWK,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@am__leading_dot@,$am__leading_dot,;t t +s,@AMTAR@,$AMTAR,;t t +s,@am__tar@,$am__tar,;t t +s,@am__untar@,$am__untar,;t t +s,@RANLIB@,$RANLIB,;t t +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@DATE@,$DATE,;t t +s,@OPROFILE_DIR@,$OPROFILE_DIR,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@DEPDIR@,$DEPDIR,;t t +s,@am__include@,$am__include,;t t +s,@am__quote@,$am__quote,;t t +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t +s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t +s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t +s,@CPP@,$CPP,;t t +s,@CXX@,$CXX,;t t +s,@CXXFLAGS@,$CXXFLAGS,;t t +s,@ac_ct_CXX@,$ac_ct_CXX,;t t +s,@CXXDEPMODE@,$CXXDEPMODE,;t t +s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t +s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t +s,@LD@,$LD,;t t +s,@KSRC@,$KSRC,;t t +s,@KINC@,$KINC,;t t +s,@kernel_support_TRUE@,$kernel_support_TRUE,;t t +s,@kernel_support_FALSE@,$kernel_support_FALSE,;t t +s,@KVERS@,$KVERS,;t t +s,@OPROFILE_MODULE_ARCH@,$OPROFILE_MODULE_ARCH,;t t +s,@MODINSTALLDIR@,$MODINSTALLDIR,;t t +s,@EXTRA_CFLAGS_MODULE@,$EXTRA_CFLAGS_MODULE,;t t +s,@topdir@,$topdir,;t t +s,@EGREP@,$EGREP,;t t +s,@SIZE_T_TYPE@,$SIZE_T_TYPE,;t t +s,@PTRDIFF_T_TYPE@,$PTRDIFF_T_TYPE,;t t +s,@CXXCPP@,$CXXCPP,;t t +s,@X_CFLAGS@,$X_CFLAGS,;t t +s,@X_PRE_LIBS@,$X_PRE_LIBS,;t t +s,@X_LIBS@,$X_LIBS,;t t +s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;t t +s,@QT_INCLUDES@,$QT_INCLUDES,;t t +s,@QT_LDFLAGS@,$QT_LDFLAGS,;t t +s,@MOC@,$MOC,;t t +s,@UIC@,$UIC,;t t +s,@QT_LIB@,$QT_LIB,;t t +s,@QT_VERSION@,$QT_VERSION,;t t +s,@enable_abi_TRUE@,$enable_abi_TRUE,;t t +s,@enable_abi_FALSE@,$enable_abi_FALSE,;t t +s,@XSLTPROC@,$XSLTPROC,;t t +s,@have_xsltproc_TRUE@,$have_xsltproc_TRUE,;t t +s,@have_xsltproc_FALSE@,$have_xsltproc_FALSE,;t t +s,@XML_CATALOG@,$XML_CATALOG,;t t +s,@XSLTPROC_FLAGS@,$XSLTPROC_FLAGS,;t t +s,@DOCBOOK_ROOT@,$DOCBOOK_ROOT,;t t +s,@CAT_ENTRY_START@,$CAT_ENTRY_START,;t t +s,@CAT_ENTRY_END@,$CAT_ENTRY_END,;t t +s,@LIBERTY_LIBS@,$LIBERTY_LIBS,;t t +s,@BFD_LIBS@,$BFD_LIBS,;t t +s,@POPT_LIBS@,$POPT_LIBS,;t t +s,@have_qt_TRUE@,$have_qt_TRUE,;t t +s,@have_qt_FALSE@,$have_qt_FALSE,;t t +s,@OP_CFLAGS@,$OP_CFLAGS,;t t +s,@OP_CXXFLAGS@,$OP_CXXFLAGS,;t t +s,@OP_DOCDIR@,$OP_DOCDIR,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + # Do quote $f, to prevent DOS paths from being IFS'd. + echo "$f";; + *) # Relative + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi +# Compute $ac_file's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $ac_file | $ac_file:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null || +$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X$ac_file : 'X\(//\)[^/]' \| \ + X$ac_file : 'X\(//\)$' \| \ + X$ac_file : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X$ac_file | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'`/stamp-h$_am_stamp_count +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_dir=`(dirname "$ac_dest") 2>/dev/null || +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_dest" : 'X\(//\)[^/]' \| \ + X"$ac_dest" : 'X\(//\)$' \| \ + X"$ac_dest" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_dest" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac + + + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 +echo "$as_me: executing $ac_dest commands" >&6;} + case $ac_dest in + depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`(dirname "$mf") 2>/dev/null || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`(dirname "$file") 2>/dev/null || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p $dirpart/$fdir + else + as_dir=$dirpart/$fdir + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5 +echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;} + { (exit 1); exit 1; }; }; } + + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + esac +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + + + +if test -r doc/xsl/catalog.xml; then + if cmp doc/xsl/catalog-1.xml doc/xsl/catalog.xml > /dev/null; then + echo doc/xsl/catalog.xml is unchanged + else + cp -f doc/xsl/catalog-1.xml doc/xsl/catalog.xml + fi +else + cp -f doc/xsl/catalog-1.xml doc/xsl/catalog.xml +fi + + +if test -z "$QT_LIB"; then + echo "Warning: a working Qt not found; no GUI will be built" +fi diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..a785f16 --- /dev/null +++ b/configure.in @@ -0,0 +1,256 @@ +# Autoconf script for oprofile +# +# Copyright 1999 Olaf Titz +# Adapted for oprofile +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version +# 2 of the License, or (at your option) any later version. +# + +AC_PREREQ(2.13) + +AC_INIT(libop/op_config.h) +AM_INIT_AUTOMAKE(oprofile, 0.9.1) +AM_CONFIG_HEADER(config.h) + +AC_PROG_RANLIB + +dnl for the man page +DATE="`date '+%a %d %B %Y'`" +AC_SUBST(DATE) + +dnl needed for module build +OPROFILE_DIR=`pwd` +AC_SUBST(OPROFILE_DIR) + +# this needs to come before --with-gcc so we link with binutil's version +# of libiberty ... sigh +AC_ARG_WITH(binutils, +[ --with-binutils=dir Path to binutils installation to use], BINUTILSDIR=$withval) + +if test "$BINUTILSDIR" != ""; then + LD="$BINUTILSDIR/ld" + if test "$CFLAGS" = ""; then + CFLAGS="-g -O2" + fi + if test "$CXXFLAGS" = ""; then + CXXFLAGS="-g -O2" + fi + CFLAGS="$CFLAGS -I $BINUTILSDIR/include" + CXXFLAGS="$CXXFLAGS -I $BINUTILSDIR/include" + LDFLAGS="$LDFLAGS -L $BINUTILSDIR/lib -Xlinker -R -Xlinker $BINUTILSDIR/lib" +fi + +AC_ARG_WITH(gcc, +[ --with-gcc=dir Path to GCC installation to use], GCCDIR=$withval) + +if test "$GCCDIR" != ""; then + CC="$GCCDIR/bin/gcc" + CXX="$GCCDIR/bin/g++" + LDFLAGS="$LDFLAGS -L $GCCDIR/lib -Xlinker -R -Xlinker $GCCDIR/lib" +fi + +AC_PROG_CC +AC_PROG_CPP +AC_PROG_CXX +AC_CHECK_PROG(LD,ld,ld,) +test "$LD" || AC_ERROR(ld not found) + +AX_FIND_KERNEL + +if test "$OPROFILE_26" = "no"; then + AX_CONFIG_MODULE +fi + +AC_ARG_WITH(module-dir, +[ --with-module-dir=dir Path to module installation directory], MODINSTALLDIR=$withval) +AC_SUBST(MODINSTALLDIR) + +AX_MALLOC_ATTRIBUTE +AX_BUILTIN_EXPECT + +AC_SUBST(EXTRA_CFLAGS_MODULE) + +topdir=`pwd` +AC_SUBST(topdir) + +AX_EXTRA_DIRS + +ORIG_SAVE_LIBS="$LIBS" + +dnl advanced glibc features which we need but may not be present +AC_CHECK_FUNCS(sched_setaffinity perfmonctl) + +AC_CHECK_LIB(popt, poptGetContext,, AC_MSG_ERROR([popt library not found])) + +AX_BINUTILS + +# C++ tests + +AC_LANG_CPLUSPLUS + +AX_POPT_CONST +AX_CHECK_SSTREAM + +dnl bfd.h pre 1998 check only for gnu 2.xx series, so gcc 3.0 can't compile it +AC_MSG_CHECKING([whether bfd defines bool]) +AC_TRY_COMPILE([#include ], [], +AC_MSG_RESULT([no]);, +AC_MSG_RESULT([yes]); AC_DEFINE(TRUE_FALSE_ALREADY_DEFINED, 1, [whether bfd.h defines bool values])) + +dnl smart demangler need to know what are the underlined type for some typedef +AX_TYPEDEFED_NAME(size_t, "unsigned" "unsigned long", SIZE_T_TYPE) +AC_SUBST(SIZE_T_TYPE) +AX_TYPEDEFED_NAME(ptrdiff_t, "int" "long", PTRDIFF_T_TYPE) +AC_SUBST(PTRDIFF_T_TYPE) + +AC_PATH_XTRA +ORIG_X_SAVE_LIBS="$LIBS" +LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS" +X_LIBS="$LIBS" +AC_SUBST(X_LIBS) +QT_DO_IT_ALL +LIBS="$ORIG_X_SAVE_LIBS" + +dnl enable code to describe the binary layout of libdb files, for platform portability +AC_ARG_ENABLE(abi, + [ --enable-abi enable abi portability code (default is disabled)], + enable_abi=$enableval, enable_abi=no) +if test "$enable_abi" = yes; then + AC_DEFINE(OPROF_ABI, 1, [whether to build ABI tools]) +fi +AM_CONDITIONAL(enable_abi, test "$enable_abi" = yes) + +dnl enable pch for c++ +AC_ARG_ENABLE(pch, + [ --enable-pch enable precompiled header (default is disabled)], + enable_pch=$enableval, enable_pch=no) +if test "$enable_pch" = yes; then + AX_CHECK_PRECOMPILED_HEADER(OP_CXXFLAGS) +fi + +AX_CHECK_DOCBOOK + +dnl finally restore the original libs setting +LIBS="$ORIG_SAVE_LIBS" +LIBERTY_LIBS="-liberty $DL_LIB $INTL_LIB" +BFD_LIBS="-lbfd -liberty $DL_LIB $INTL_LIB" +POPT_LIBS="-lpopt" +AC_SUBST(LIBERTY_LIBS) +AC_SUBST(BFD_LIBS) +AC_SUBST(POPT_LIBS) + +# do NOT put tests here, they will fail in the case X is not installed ! + +AM_CONDITIONAL(have_qt, test -n "$QT_LIB") + +AX_CFLAGS_OPTION(OP_CFLAGS,[-W]) +AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-W]) +AX_CFLAGS_OPTION(OP_CFLAGS,[-Wall]) +AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-Wall]) +AX_CFLAGS_OPTION(OP_CFLAGS,[-fno-common]) +AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-fno-common]) +AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-ftemplate-depth-50]) +AX_CFLAGS_OPTION(OP_CFLAGS,[-Wdeclaration-after-statement]) + +dnl enable option to use GCC test coverage +AC_ARG_ENABLE(gcov, + [ --enable-gcov enable option for gcov coverage testing (default is disabled)], + enable_gcov=$enableval, enable_gcov=no) +if test "$enable_gcov" = yes; then + AX_CFLAGS_OPTION(OP_CFLAGS,[-fprofile-arcs]) + AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-fprofile-arcs]) + AX_CFLAGS_OPTION(OP_CFLAGS,[-ftest-coverage]) + AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-ftest-coverage]) +fi + +AC_ARG_ENABLE(werror, + [ --disable-werror disable -Werror flag (default is enabled for non-release)], + enable_werror=$enableval, enable_werror=yes) +if test "$enable_werror" = yes; then + # enable -Werror for non-release versions. + if echo "$VERSION" | grep cvs >/dev/null; then + AX_CFLAGS_OPTION(OP_CFLAGS,[-Werror]) + AX_CXXFLAGS_OPTION(OP_CXXFLAGS,[-Werror]) + fi +fi + +AC_ARG_ENABLE(optimization, + [ --disable-optimization disable optimization flags (default is enabled)], + enable_optimization=$enableval, enable_optimisation=yes) +if test "$enable_optimization" = "no"; then + CFLAGS=`echo $CFLAGS | sed 's/-O2//g'` + CXXFLAGS=`echo $CXXFLAGS | sed 's/-O2//g'` +fi + +AC_SUBST(OP_CFLAGS) +AC_SUBST(OP_CXXFLAGS) + +# fixups for config.h +if test "$prefix" = "NONE"; then + my_op_prefix="$ac_default_prefix" +else + my_op_prefix="$prefix" +fi +my_op_datadir="$my_op_prefix/share" + +if test "$exec_prefix" = "NONE"; then + my_op_exec_prefix="$my_op_prefix" +else + my_op_exec_prefix="$exec_prefix" +fi +my_op_bindir="$my_op_exec_prefix/bin" + +OP_DATADIR=`eval echo "$my_op_datadir/$PACKAGE/"` +AC_DEFINE_UNQUOTED(OP_DATADIR, "$OP_DATADIR", [package data directory]) +OP_BINDIR=`eval echo "$my_op_bindir/"` +AC_DEFINE_UNQUOTED(OP_BINDIR, "$OP_BINDIR", [package binary directory]) +OP_DOCDIR=`eval echo "${my_op_prefix}/share/doc/$PACKAGE/"` +AC_SUBST(OP_DOCDIR) + +AC_OUTPUT(Makefile \ + m4/Makefile \ + libutil/Makefile \ + libutil/tests/Makefile \ + libutil++/Makefile \ + libutil++/tests/Makefile \ + libop/Makefile \ + libop/tests/Makefile \ + libopt++/Makefile \ + libdb/Makefile \ + libdb/tests/Makefile \ + libabi/Makefile \ + libabi/tests/Makefile \ + libregex/Makefile \ + libregex/tests/Makefile \ + libregex/stl.pat \ + libregex/tests/mangled-name \ + daemon/Makefile \ + daemon/liblegacy/Makefile \ + events/Makefile \ + utils/Makefile \ + doc/Makefile \ + doc/xsl/catalog-1.xml \ + doc/oprofile.1 \ + doc/opcontrol.1 \ + doc/ophelp.1 \ + doc/opreport.1 \ + doc/opannotate.1 \ + doc/opgprof.1 \ + doc/oparchive.1 \ + doc/srcdoc/Doxyfile \ + libpp/Makefile \ + pp/Makefile \ + gui/Makefile \ + gui/ui/Makefile \ + module/Makefile \ + module/x86/Makefile \ + module/ia64/Makefile) + +AX_COPY_IF_CHANGE(doc/xsl/catalog-1.xml, doc/xsl/catalog.xml) + +if test -z "$QT_LIB"; then + echo "Warning: a working Qt not found; no GUI will be built" +fi diff --git a/daemon/Makefile.am b/daemon/Makefile.am new file mode 100644 index 0000000..bbcc1b3 --- /dev/null +++ b/daemon/Makefile.am @@ -0,0 +1,58 @@ +SUBDIRS = liblegacy . + +oprofiled_SOURCES = \ + init.c \ + oprofiled.c \ + oprofiled.h \ + opd_stats.c \ + opd_sfile.c \ + opd_sfile.h \ + opd_kernel.c \ + opd_kernel.h \ + opd_trans.c \ + opd_trans.h \ + opd_printf.h \ + opd_stats.h \ + opd_cookie.c \ + opd_cookie.h \ + opd_events.c \ + opd_events.h \ + opd_interface.h \ + opd_mangling.c \ + opd_mangling.h \ + opd_perfmon.h \ + opd_perfmon.c \ + opd_anon.h \ + opd_anon.c + +LIBS=@POPT_LIBS@ @LIBERTY_LIBS@ + +AM_CPPFLAGS = \ + -I ${top_srcdir}/libabi \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libdb + +# -fno-omit-frame-pointer needed for daemon build: see ChangeLog 2004-02-23 +AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer + +bin_PROGRAMS = oprofiled + +if enable_abi +oprofiled_LDADD = \ + liblegacy/liblegacy.a \ + ../libabi/libabi.a \ + ../libdb/libodb.a \ + ../libop/libop.a \ + ../libutil/libutil.a +LINKER=$(CXX) +else +oprofiled_LDADD = \ + liblegacy/liblegacy.a \ + ../libdb/libodb.a \ + ../libop/libop.a \ + ../libutil/libutil.a +LINKER=$(CC) +endif + +oprofiled_LINK = $(LINKER) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ diff --git a/daemon/Makefile.in b/daemon/Makefile.in new file mode 100644 index 0000000..ee19898 --- /dev/null +++ b/daemon/Makefile.in @@ -0,0 +1,634 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(oprofiled_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +bin_PROGRAMS = oprofiled$(EXEEXT) +subdir = daemon +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_oprofiled_OBJECTS = init.$(OBJEXT) oprofiled.$(OBJEXT) \ + opd_stats.$(OBJEXT) opd_sfile.$(OBJEXT) opd_kernel.$(OBJEXT) \ + opd_trans.$(OBJEXT) opd_cookie.$(OBJEXT) opd_events.$(OBJEXT) \ + opd_mangling.$(OBJEXT) opd_perfmon.$(OBJEXT) \ + opd_anon.$(OBJEXT) +oprofiled_OBJECTS = $(am_oprofiled_OBJECTS) +@enable_abi_FALSE@oprofiled_DEPENDENCIES = liblegacy/liblegacy.a \ +@enable_abi_FALSE@ ../libdb/libodb.a ../libop/libop.a \ +@enable_abi_FALSE@ ../libutil/libutil.a +@enable_abi_TRUE@oprofiled_DEPENDENCIES = liblegacy/liblegacy.a \ +@enable_abi_TRUE@ ../libabi/libabi.a ../libdb/libodb.a \ +@enable_abi_TRUE@ ../libop/libop.a ../libutil/libutil.a +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(oprofiled_SOURCES) +DIST_SOURCES = $(oprofiled_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @POPT_LIBS@ @LIBERTY_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +SUBDIRS = liblegacy . +oprofiled_SOURCES = \ + init.c \ + oprofiled.c \ + oprofiled.h \ + opd_stats.c \ + opd_sfile.c \ + opd_sfile.h \ + opd_kernel.c \ + opd_kernel.h \ + opd_trans.c \ + opd_trans.h \ + opd_printf.h \ + opd_stats.h \ + opd_cookie.c \ + opd_cookie.h \ + opd_events.c \ + opd_events.h \ + opd_interface.h \ + opd_mangling.c \ + opd_mangling.h \ + opd_perfmon.h \ + opd_perfmon.c \ + opd_anon.h \ + opd_anon.c + +AM_CPPFLAGS = \ + -I ${top_srcdir}/libabi \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libdb + + +# -fno-omit-frame-pointer needed for daemon build: see ChangeLog 2004-02-23 +AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer +@enable_abi_FALSE@oprofiled_LDADD = \ +@enable_abi_FALSE@ liblegacy/liblegacy.a \ +@enable_abi_FALSE@ ../libdb/libodb.a \ +@enable_abi_FALSE@ ../libop/libop.a \ +@enable_abi_FALSE@ ../libutil/libutil.a + +@enable_abi_TRUE@oprofiled_LDADD = \ +@enable_abi_TRUE@ liblegacy/liblegacy.a \ +@enable_abi_TRUE@ ../libabi/libabi.a \ +@enable_abi_TRUE@ ../libdb/libodb.a \ +@enable_abi_TRUE@ ../libop/libop.a \ +@enable_abi_TRUE@ ../libutil/libutil.a + +@enable_abi_FALSE@LINKER = $(CC) +@enable_abi_TRUE@LINKER = $(CXX) +oprofiled_LINK = $(LINKER) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign daemon/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign daemon/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +oprofiled$(EXEEXT): $(oprofiled_OBJECTS) $(oprofiled_DEPENDENCIES) + @rm -f oprofiled$(EXEEXT) + $(oprofiled_LINK) $(oprofiled_LDFLAGS) $(oprofiled_OBJECTS) $(oprofiled_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_anon.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_cookie.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_events.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_kernel.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_mangling.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_perfmon.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_sfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_stats.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_trans.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oprofiled.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(PROGRAMS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: install-binPROGRAMS + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-binPROGRAMS clean-generic clean-recursive ctags \ + ctags-recursive distclean distclean-compile distclean-generic \ + distclean-recursive distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/daemon/init.c b/daemon/init.c new file mode 100644 index 0000000..076ddd8 --- /dev/null +++ b/daemon/init.c @@ -0,0 +1,276 @@ +/** + * @file daemon/init.c + * Daemon set up and main loop for 2.6 + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "config.h" + +#include "oprofiled.h" +#include "opd_stats.h" +#include "opd_sfile.h" +#include "opd_kernel.h" +#include "opd_trans.h" +#include "opd_anon.h" +#include "opd_perfmon.h" +#include "opd_printf.h" + +#include "op_version.h" +#include "op_config.h" +#include "op_deviceio.h" +#include "op_get_time.h" +#include "op_libiberty.h" +#include "op_fileio.h" + +#include +#include +#include +#include + +size_t kernel_pointer_size; + +static fd_t devfd; +static char * sbuf; +static size_t s_buf_bytesize; + +static void opd_sighup(void); +static void opd_alarm(void); +static void opd_sigterm(void); + +/** + * opd_open_files - open necessary files + * + * Open the device files and the log file, + * and mmap() the hash map. + */ +static void opd_open_files(void) +{ + devfd = op_open_device("/dev/oprofile/buffer"); + if (devfd == -1) { + if (errno == EINVAL) + fprintf(stderr, "Failed to open device. Possibly you have passed incorrect\n" + "parameters. Check /var/log/messages."); + else + perror("Failed to open profile device"); + exit(EXIT_FAILURE); + } + + /* give output before re-opening stdout as the logfile */ + printf("Using log file " OP_LOG_FILE "\n"); + + /* set up logfile */ + close(0); + close(1); + + if (open("/dev/null", O_RDONLY) == -1) { + perror("oprofiled: couldn't re-open stdin as /dev/null: "); + exit(EXIT_FAILURE); + } + + opd_open_logfile(); + + printf("oprofiled started %s", op_get_time()); + printf("kernel pointer size: %lu\n", + (unsigned long)kernel_pointer_size); + fflush(stdout); +} + + +/** Done writing out the samples, indicate with complete_dump file */ +static void complete_dump(void) +{ + FILE * status_file; + +retry: + status_file = fopen(OP_DUMP_STATUS, "w"); + + if (!status_file && errno == EMFILE) { + if (sfile_lru_clear()) { + printf("LRU cleared but file open fails for %s.\n", + OP_DUMP_STATUS); + abort(); + } + goto retry; + } + + if (!status_file) { + perror("warning: couldn't set complete_dump: "); + return; + } + + fprintf(status_file, "1\n"); + fclose(status_file); +} + + +/** + * opd_do_samples - process a sample buffer + * @param opd_buf buffer to process + * + * Process a buffer of samples. + * + * If the sample could be processed correctly, it is written + * to the relevant sample file. + */ +static void opd_do_samples(char const * opd_buf, ssize_t count) +{ + size_t num = count / kernel_pointer_size; + + opd_stats[OPD_DUMP_COUNT]++; + + verbprintf(vmisc, "Read buffer of %d entries.\n", (unsigned int)num); + + opd_process_samples(opd_buf, num); + + complete_dump(); +} + + +/** + * opd_do_read - enter processing loop + * @param buf buffer to read into + * @param size size of buffer + * + * Read some of a buffer from the device and process + * the contents. + */ +static void opd_do_read(char * buf, size_t size) +{ + while (1) { + ssize_t count = -1; + + /* loop to handle EINTR */ + while (count < 0) { + count = op_read_device(devfd, buf, size); + + /* we can lose an alarm or a hup but + * we don't care. + */ + if (signal_alarm) { + signal_alarm = 0; + opd_alarm(); + } + + if (signal_hup) { + signal_hup = 0; + opd_sighup(); + } + + if (signal_term) + opd_sigterm(); + + if (signal_usr1) { + signal_usr1 = 0; + perfmon_start(); + } + + if (signal_usr2) { + signal_usr2 = 0; + perfmon_stop(); + } + } + + opd_do_samples(buf, count); + } +} + + +/** opd_alarm - sync files and report stats */ +static void opd_alarm(void) +{ + sfile_sync_files(); + opd_print_stats(); + alarm(60 * 10); +} + + +/** re-open files for logrotate/opcontrol --reset */ +static void opd_sighup(void) +{ + printf("Received SIGHUP.\n"); + /* We just close them, and re-open them lazily as usual. */ + sfile_close_files(); + close(1); + close(2); + opd_open_logfile(); +} + + +static void clean_exit(void) +{ + perfmon_exit(); + unlink(OP_LOCK_FILE); +} + + +static void opd_sigterm(void) +{ + opd_print_stats(); + printf("oprofiled stopped %s", op_get_time()); + exit(EXIT_FAILURE); +} + + +static void opd_26_init(void) +{ + size_t i; + size_t opd_buf_size; + + opd_create_vmlinux(vmlinux, kernel_range); + + opd_buf_size = opd_read_fs_int("/dev/oprofile/", "buffer_size", 1); + kernel_pointer_size = opd_read_fs_int("/dev/oprofile/", "pointer_size", 1); + + s_buf_bytesize = opd_buf_size * kernel_pointer_size; + + sbuf = xmalloc(s_buf_bytesize); + + opd_reread_module_info(); + + for (i = 0; i < OPD_MAX_STATS; i++) + opd_stats[i] = 0; + + perfmon_init(); + + cookie_init(); + sfile_init(); + anon_init(); + + /* must be /after/ perfmon_init() at least */ + if (atexit(clean_exit)) { + perfmon_exit(); + perror("oprofiled: couldn't set exit cleanup: "); + exit(EXIT_FAILURE); + } +} + + +static void opd_26_start(void) +{ + opd_open_files(); + + /* simple sleep-then-process loop */ + opd_do_read(sbuf, s_buf_bytesize); +} + + +static void opd_26_exit(void) +{ + opd_print_stats(); + printf("oprofiled stopped %s", op_get_time()); + + free(sbuf); + free(vmlinux); + /* FIXME: free kernel images, sfiles etc. */ +} + +struct oprofiled_ops opd_26_ops = { + .init = opd_26_init, + .start = opd_26_start, + .exit = opd_26_exit, +}; diff --git a/daemon/liblegacy/Makefile.am b/daemon/liblegacy/Makefile.am new file mode 100644 index 0000000..23bfc2f --- /dev/null +++ b/daemon/liblegacy/Makefile.am @@ -0,0 +1,28 @@ +noinst_LIBRARIES = liblegacy.a + +# -fno-omit-frame-pointer needed for daemon build: see ChangeLog 2004-02-23 +AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer + +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libdb \ + -I ${top_srcdir}/daemon + +liblegacy_a_SOURCES = \ + opd_24_stats.c \ + opd_24_stats.h \ + opd_kernel.c \ + opd_proc.c \ + opd_image.c \ + opd_mapping.c \ + opd_parse_proc.c \ + opd_image.h \ + opd_mapping.h \ + p_module.h \ + opd_kernel.h \ + opd_parse_proc.h \ + opd_proc.h \ + opd_sample_files.c \ + opd_sample_files.h \ + init.c diff --git a/daemon/liblegacy/Makefile.in b/daemon/liblegacy/Makefile.in new file mode 100644 index 0000000..9476108 --- /dev/null +++ b/daemon/liblegacy/Makefile.in @@ -0,0 +1,468 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(liblegacy_a_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = daemon/liblegacy +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +liblegacy_a_AR = $(AR) $(ARFLAGS) +liblegacy_a_LIBADD = +am_liblegacy_a_OBJECTS = opd_24_stats.$(OBJEXT) opd_kernel.$(OBJEXT) \ + opd_proc.$(OBJEXT) opd_image.$(OBJEXT) opd_mapping.$(OBJEXT) \ + opd_parse_proc.$(OBJEXT) opd_sample_files.$(OBJEXT) \ + init.$(OBJEXT) +liblegacy_a_OBJECTS = $(am_liblegacy_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(liblegacy_a_SOURCES) +DIST_SOURCES = $(liblegacy_a_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +noinst_LIBRARIES = liblegacy.a + +# -fno-omit-frame-pointer needed for daemon build: see ChangeLog 2004-02-23 +AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libdb \ + -I ${top_srcdir}/daemon + +liblegacy_a_SOURCES = \ + opd_24_stats.c \ + opd_24_stats.h \ + opd_kernel.c \ + opd_proc.c \ + opd_image.c \ + opd_mapping.c \ + opd_parse_proc.c \ + opd_image.h \ + opd_mapping.h \ + p_module.h \ + opd_kernel.h \ + opd_parse_proc.h \ + opd_proc.h \ + opd_sample_files.c \ + opd_sample_files.h \ + init.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign daemon/liblegacy/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign daemon/liblegacy/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +liblegacy.a: $(liblegacy_a_OBJECTS) $(liblegacy_a_DEPENDENCIES) + -rm -f liblegacy.a + $(liblegacy_a_AR) liblegacy.a $(liblegacy_a_OBJECTS) $(liblegacy_a_LIBADD) + $(RANLIB) liblegacy.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_24_stats.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_image.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_kernel.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_mapping.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_parse_proc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_proc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_sample_files.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/daemon/liblegacy/init.c b/daemon/liblegacy/init.c new file mode 100644 index 0000000..1ed3c46 --- /dev/null +++ b/daemon/liblegacy/init.c @@ -0,0 +1,392 @@ +/** + * @file daemon/liblegacy/init.c + * Daemon set up and main loop for 2.4 + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "config.h" + +#include "opd_proc.h" +#include "opd_mapping.h" +#include "opd_24_stats.h" +#include "opd_sample_files.h" +#include "opd_image.h" +#include "opd_parse_proc.h" +#include "opd_kernel.h" +#include "opd_printf.h" +#include "oprofiled.h" + +#include "op_sample_file.h" +#include "op_config_24.h" +#include "op_interface.h" +#include "op_libiberty.h" +#include "op_deviceio.h" +#include "op_events.h" +#include "op_get_time.h" +#include "op_fileio.h" + +#include +#include +#include +#include +#include + +fd_t hashmapdevfd; + +int cpu_number; + +static fd_t devfd; +static fd_t notedevfd; +static struct op_buffer_head * sbuf; +static size_t s_buf_bytesize; +static struct op_note * nbuf; +static size_t n_buf_bytesize; + +static void opd_sighup(void); +static void opd_alarm(void); +static void opd_sigterm(void); + + +/** + * op_open_files - open necessary files + * + * Open the device files and the log file, + * and mmap() the hash map. + */ +static void op_open_files(void) +{ + hashmapdevfd = op_open_device(OP_HASH_DEVICE); + if (hashmapdevfd == -1) { + perror("Failed to open hash map device"); + exit(EXIT_FAILURE); + } + + notedevfd = op_open_device(OP_NOTE_DEVICE); + if (notedevfd == -1) { + if (errno == EINVAL) + fprintf(stderr, "Failed to open note device. Possibly you have passed incorrect\n" + "parameters. Check /var/log/messages."); + else + perror("Failed to open note device"); + exit(EXIT_FAILURE); + } + + devfd = op_open_device(OP_DEVICE); + if (devfd == -1) { + if (errno == EINVAL) + fprintf(stderr, "Failed to open device. Possibly you have passed incorrect\n" + "parameters. Check /var/log/messages."); + else + perror("Failed to open profile device"); + exit(EXIT_FAILURE); + } + + opd_init_hash_map(); + + /* give output before re-opening stdout as the logfile */ + printf("Using log file " OP_LOG_FILE "\n"); + + /* set up logfile */ + close(0); + close(1); + + if (open("/dev/null", O_RDONLY) == -1) { + perror("oprofiled: couldn't re-open stdin as /dev/null: "); + exit(EXIT_FAILURE); + } + + opd_open_logfile(); + + printf("oprofiled started %s", op_get_time()); + fflush(stdout); +} + + +static void opd_do_samples(struct op_buffer_head const * buf); +static void opd_do_notes(struct op_note const * opd_buf, size_t count); + +/** + * do_shutdown - shutdown cleanly, reading as much remaining data as possible. + * @param buf sample buffer area + * @param size size of sample buffer + * @param nbuf note buffer area + * @param nsize size of note buffer + */ +static void opd_shutdown(struct op_buffer_head * buf, size_t size, struct op_note * nbuf, size_t nsize) +{ + ssize_t count = -1; + ssize_t ncount = -1; + + /* the dump may have added no samples, so we must set + * non-blocking */ + if (fcntl(devfd, F_SETFL, fcntl(devfd, F_GETFL) | O_NONBLOCK) < 0) { + perror("Failed to set non-blocking read for device: "); + exit(EXIT_FAILURE); + } + + /* it's always OK to read the note device */ + while (ncount < 0) { + ncount = op_read_device(notedevfd, nbuf, nsize); + } + + if (ncount > 0) { + opd_do_notes(nbuf, ncount); + } + + /* read as much as we can until we have exhausted the data + * (EAGAIN is returned). + * + * This will not livelock as the profiler has been partially + * shut down by now. + */ + while (1) { + count = op_read_device(devfd, buf, size); + if (count < 0 && errno == EAGAIN) + break; + verbprintf(vmisc, "Shutting down, state %d\n", buf->state); + opd_do_samples(buf); + } +} + + +/** + * opd_do_read - enter processing loop + * @param buf buffer to read into + * @param size size of buffer + * @param nbuf note buffer + * @param nsize size of note buffer + * + * Read some of a buffer from the device and process + * the contents. + */ +static void opd_do_read(struct op_buffer_head * buf, size_t size, struct op_note * nbuf, size_t nsize) +{ + while (1) { + ssize_t count = -1; + ssize_t ncount = -1; + + /* loop to handle EINTR */ + while (count < 0) { + count = op_read_device(devfd, buf, size); + + } + + while (ncount < 0) { + ncount = op_read_device(notedevfd, nbuf, nsize); + } + + opd_do_notes(nbuf, ncount); + opd_do_samples(buf); + + // we can lost a signal alarm or a signal hup but we don't + // take care. + if (signal_alarm) { + signal_alarm = 0; + opd_alarm(); + } + + if (signal_hup) { + signal_hup = 0; + opd_sighup(); + } + + if (signal_term) + opd_sigterm(); + + /* request to stop arrived */ + if (buf->state == STOPPING) { + verbprintf(vmisc, "Shutting down by request.\n"); + opd_shutdown(buf, size, nbuf, nsize); + return; + } + } +} + +/** + * opd_do_notes - process a notes buffer + * @param opd_buf buffer to process + * @param count number of bytes in buffer + * + * Process a buffer of notes. + */ +static void opd_do_notes(struct op_note const * opd_buf, size_t count) +{ + uint i; + struct op_note const * note; + + for (i = 0; i < count/sizeof(struct op_note); i++) { + note = &opd_buf[i]; + + opd_24_stats[OPD_NOTIFICATIONS]++; + + switch (note->type) { + case OP_MAP: + case OP_EXEC: + if (note->type == OP_EXEC) + opd_handle_exec(note->pid, note->tgid); + opd_handle_mapping(note); + break; + + case OP_FORK: + opd_handle_fork(note); + break; + + case OP_DROP_MODULES: + opd_clear_module_info(); + break; + + case OP_EXIT: + opd_handle_exit(note); + break; + + default: + fprintf(stderr, "Received unknown notification type %u\n", note->type); + abort(); + break; + } + } +} + +/** + * opd_do_samples - process a sample buffer + * @param opd_buf buffer to process + * + * Process a buffer of samples. + * The signals specified by the global variable maskset are + * masked. + * + * If the sample could be processed correctly, it is written + * to the relevant sample file. Additionally mapping and + * process notifications are handled here. + */ +static void opd_do_samples(struct op_buffer_head const * opd_buf) +{ + uint i; + struct op_sample const * buffer = opd_buf->buffer; + + opd_24_stats[OPD_DUMP_COUNT]++; + + verbprintf(vmisc, "Read buffer of %d entries for cpu %d.\n", + (unsigned int)opd_buf->count, opd_buf->cpu_nr); + + if (separate_cpu) + cpu_number = opd_buf->cpu_nr; + for (i = 0; i < opd_buf->count; i++) { + verbprintf(vsamples, "%.6u: EIP: 0x%.8lx pid: %.6d\n", + i, buffer[i].eip, buffer[i].pid); + opd_put_sample(&buffer[i]); + } +} + + +/** + * opd_alarm - clean up old procs, msync, and report stats + */ +static void opd_alarm(void) +{ + opd_sync_samples_files(); + + opd_age_procs(); + + opd_print_24_stats(); + + alarm(60 * 10); +} + + +/* re-open logfile for logrotate */ +static void opd_sighup(void) +{ + printf("Received SIGHUP.\n"); + close(1); + close(2); + opd_open_logfile(); + /* We just close them, and re-open them lazily as usual. */ + opd_for_each_image(opd_close_image_samples_files); +} + + +static void clean_exit(void) +{ + opd_cleanup_hash_name(); + op_free_events(); + unlink(OP_LOCK_FILE); +} + + +static void opd_sigterm(void) +{ + opd_print_24_stats(); + printf("oprofiled stopped %s", op_get_time()); + exit(EXIT_FAILURE); +} + + +static void opd_24_init(void) +{ + size_t i; + int opd_buf_size = OP_DEFAULT_BUF_SIZE; + int opd_note_buf_size = OP_DEFAULT_NOTE_SIZE; + + if (!no_vmlinux) + opd_parse_kernel_range(kernel_range); + opd_buf_size = opd_read_fs_int(OP_MOUNT, "bufsize", 1); + opd_note_buf_size = opd_read_fs_int(OP_MOUNT, "notesize", 1); + + s_buf_bytesize = sizeof(struct op_buffer_head) + opd_buf_size * sizeof(struct op_sample); + + sbuf = xmalloc(s_buf_bytesize); + + n_buf_bytesize = opd_note_buf_size * sizeof(struct op_note); + nbuf = xmalloc(n_buf_bytesize); + + opd_init_images(); + opd_init_procs(); + opd_init_kernel_image(); + + for (i = 0; i < OPD_MAX_STATS; i++) + opd_24_stats[i] = 0; + + if (atexit(clean_exit)) { + perror("oprofiled: couldn't set exit cleanup: "); + exit(EXIT_FAILURE); + } +} + + +static void opd_24_start(void) +{ + op_open_files(); + + /* yes, this is racey. */ + opd_get_ascii_procs(); + + /* simple sleep-then-process loop */ + opd_do_read(sbuf, s_buf_bytesize, nbuf, n_buf_bytesize); +} + + +static void opd_24_exit(void) +{ + opd_print_24_stats(); + printf("oprofiled stopped %s", op_get_time()); + + free(sbuf); + free(nbuf); + opd_clear_module_info(); + opd_proc_cleanup(); + /* kernel/module image are not owned by a proc, we must cleanup them */ + opd_for_each_image(opd_delete_image); +} + + +struct oprofiled_ops opd_24_ops = { + .init = opd_24_init, + .start = opd_24_start, + .exit = opd_24_exit +}; diff --git a/daemon/liblegacy/opd_24_stats.c b/daemon/liblegacy/opd_24_stats.c new file mode 100644 index 0000000..52425c4 --- /dev/null +++ b/daemon/liblegacy/opd_24_stats.c @@ -0,0 +1,62 @@ +/** + * @file opd_24_stats.c + * Management of daemon statistics + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "opd_24_stats.h" +#include "opd_proc.h" +#include "opd_image.h" +#include "oprofiled.h" + +#include "op_get_time.h" + +#include +#include + +unsigned long opd_24_stats[OPD_MAX_STATS]; + +void opd_print_24_stats(void) +{ + printf("\n%s\n", op_get_time()); + printf("Nr. proc struct: %d\n", opd_get_nr_procs()); + printf("Nr. image struct: %d\n", opd_get_nr_images()); + printf("Nr. kernel samples: %lu\n", opd_24_stats[OPD_KERNEL]); + printf("Nr. modules samples: %lu\n", opd_24_stats[OPD_MODULE]); + printf("Nr. modules samples lost: %lu\n", opd_24_stats[OPD_LOST_MODULE]); + printf("Nr. samples lost due to no process information: %lu\n", + opd_24_stats[OPD_LOST_PROCESS]); + printf("Nr. samples lost due to sample file open failure: %lu\n", + opd_24_stats[OPD_LOST_SAMPLEFILE]); + printf("Nr. process samples in user-space: %lu\n", opd_24_stats[OPD_PROCESS]); + printf("Nr. samples lost due to no map information: %lu\n", + opd_24_stats[OPD_LOST_MAP_PROCESS]); + if (opd_24_stats[OPD_PROC_QUEUE_ACCESS]) { + printf("Average depth of search of proc queue: %f\n", + (double)opd_24_stats[OPD_PROC_QUEUE_DEPTH] + / (double)opd_24_stats[OPD_PROC_QUEUE_ACCESS]); + } + if (opd_24_stats[OPD_MAP_ARRAY_ACCESS]) { + printf("Average depth of iteration through mapping array: %f\n", + (double)opd_24_stats[OPD_MAP_ARRAY_DEPTH] + / (double)opd_24_stats[OPD_MAP_ARRAY_ACCESS]); + } + if (opd_24_stats[OPD_IMAGE_HASH_ACCESS]) { + printf("Average depth of iteration through image hash array: %f\n", + (double)opd_24_stats[OPD_IMAGE_HASH_DEPTH] + / (double)opd_24_stats[OPD_IMAGE_HASH_ACCESS]); + } + printf("Nr. sample dumps: %lu\n", opd_24_stats[OPD_DUMP_COUNT]); + printf("Nr. samples total: %lu\n", opd_24_stats[OPD_SAMPLES]); + printf("Nr. notifications: %lu\n", opd_24_stats[OPD_NOTIFICATIONS]); + printf("Nr. kernel note buffer overflow: %u\n", + opd_read_fs_int(OP_MOUNT, "note_buffer_overflow", 0)); + printf("Nr. kernel samples buffer overflow: %u\n", + opd_read_fs_int(OP_MOUNT, "buffer_overflow", 0)); + fflush(stdout); +} diff --git a/daemon/liblegacy/opd_24_stats.h b/daemon/liblegacy/opd_24_stats.h new file mode 100644 index 0000000..4acd860 --- /dev/null +++ b/daemon/liblegacy/opd_24_stats.h @@ -0,0 +1,39 @@ +/** + * @file opd_24_stats.h + * Management of daemon statistics + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_24_STATS_H +#define OPD_24_STATS_H + +extern unsigned long opd_24_stats[]; + +enum { OPD_KERNEL, /**< nr kernel samples */ + OPD_MODULE, /**< nr module samples */ + OPD_LOST_MODULE, /**< nr samples in module for which modules can not be located */ + OPD_LOST_PROCESS, /**< nr samples for which process info couldn't be accessed */ + OPD_PROCESS, /**< nr userspace samples */ + OPD_LOST_MAP_PROCESS, /**< nr samples for which map info couldn't be accessed */ + OPD_LOST_SAMPLEFILE, /**< nr samples for which sample file can't be opened */ + OPD_PROC_QUEUE_ACCESS, /**< nr accesses of proc queue */ + OPD_PROC_QUEUE_DEPTH, /**< cumulative depth of proc queue accesses */ + OPD_DUMP_COUNT, /**< nr of times buffer is read */ + OPD_MAP_ARRAY_ACCESS, /**< nr accesses of map array */ + OPD_MAP_ARRAY_DEPTH, /**< cumulative depth of map array accesses */ + OPD_IMAGE_HASH_ACCESS, /**< nr opd_find_image() */ + OPD_IMAGE_HASH_DEPTH, /**< cumulative depth of image search */ + OPD_SAMPLES, /**< nr distinct samples */ + OPD_NOTIFICATIONS, /**< nr notifications */ + OPD_MAX_STATS /**< end of stats */ + }; + +/** opd_print_24_stats - print out latest statistics */ +void opd_print_24_stats(void); + +#endif /* OPD_24_STATS_H */ diff --git a/daemon/liblegacy/opd_image.c b/daemon/liblegacy/opd_image.c new file mode 100644 index 0000000..ff8e068 --- /dev/null +++ b/daemon/liblegacy/opd_image.c @@ -0,0 +1,265 @@ +/** + * @file opd_image.c + * Management of binary images + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "opd_image.h" +#include "opd_printf.h" +#include "opd_sample_files.h" +#include "opd_24_stats.h" +#include "oprofiled.h" + +#include "op_file.h" +#include "op_config_24.h" +#include "op_libiberty.h" +#include "op_string.h" + +#include +#include +#include + +/* maintained for statistics purpose only */ +static int nr_images; + +/* list of images */ +#define OPD_IMAGE_HASH_SIZE 2048 +static struct list_head opd_images[OPD_IMAGE_HASH_SIZE]; + + +void opd_init_images(void) +{ + int i; + for (i = 0; i < OPD_IMAGE_HASH_SIZE; ++i) { + list_init(&opd_images[i]); + } +} + + +int opd_get_nr_images(void) +{ + return nr_images; +} + + +void opd_delete_image(struct opd_image * image) +{ + verbprintf(vmisc, "Deleting image: name %s app_name %s, kernel %d, " + "tid %d, tgid %d ref count %u\n", + image->name, image->app_name, image->kernel, + image->tid, image->tgid, (int)image->ref_count); + + if (image->ref_count <= 0) { + printf("image->ref_count < 0 for image: name %s app_name %s, " + "kernel %d, tid %d, tgid %d ref count %u\n", + image->name, image->app_name, image->kernel, + image->tid, image->tgid, image->ref_count); + abort(); + } + + if (--image->ref_count != 0) + return; + + if (image->name) + free(image->name); + if (image->app_name) + free(image->app_name); + list_del(&image->hash_next); + opd_close_image_samples_files(image); + free(image); + + nr_images--; +} + + +void opd_for_each_image(opd_image_cb image_cb) +{ + struct list_head * pos; + struct list_head * pos2; + int i; + + for (i = 0; i < OPD_IMAGE_HASH_SIZE; ++i) { + list_for_each_safe(pos, pos2, &opd_images[i]) { + struct opd_image * image = + list_entry(pos, struct opd_image, hash_next); + image_cb(image); + } + } +} + + +/** + * opd_hash_image - hash an image + * @param hash hash of image name + * @param tid thread id + * @param tgid thread group id + * + * return the hash code for the passed parameters + */ +static size_t opd_hash_image(char const * name, pid_t tid, pid_t tgid) +{ + size_t hash = op_hash_string(name); + if (separate_thread) + hash += tid + tgid; + return hash % OPD_IMAGE_HASH_SIZE; +} + + +/** + * opd_new_image - create an image sample file + * @param app_name the application name where belongs this image + * @param name name of the image to add + * @param kernel is the image a kernel/module image + * @param tid thread id + * @param tgid thread group id + * + * image at funtion entry is uninitialised + * name is copied i.e. should be GC'd separately from the + * image structure if appropriate. + * + * Initialise an opd_image struct for the image image + * without opening the associated samples files. At return + * the image is fully initialized. + */ +static struct opd_image * +opd_new_image(char const * name, char const * app_name, int kernel, + pid_t tid, pid_t tgid) +{ + size_t hash_image; + struct opd_image * image; + + verbprintf(vmisc, "Creating image: %s %s, kernel %d, tid %d, " + "tgid %d\n", name, app_name, kernel, tid, tgid); + + image = xmalloc(sizeof(struct opd_image)); + + list_init(&image->hash_next); + image->name = xstrdup(name); + image->kernel = kernel; + image->tid = tid; + image->tgid = tgid; + image->ref_count = 0; + image->app_name = app_name ? xstrdup(app_name) : NULL; + image->mtime = op_get_mtime(image->name); + + image->ignored = 1; + if (separate_lib && app_name) + image->ignored = is_image_ignored(app_name); + if (image->ignored) + image->ignored = is_image_ignored(name); + + memset(image->sfiles, '\0', NR_CPUS * sizeof(struct opd_24_sfile **)); + + hash_image = opd_hash_image(name, tid, tgid); + list_add(&image->hash_next, &opd_images[hash_image]); + + nr_images++; + + return image; +} + + +/** + * is_same_image - check for identical image + * @param image image to compare + * @param name name of image + * @param app_name image must belong to this application name + * @param tid thread id + * @param tgid thread group id + * + * on entry caller have checked than strcmp(image->name, name) == 0 + * return 0 if the couple (name, app_name) refers to same image + */ +static int is_same_image(struct opd_image const * image, char const * app_name, + pid_t tid, pid_t tgid) +{ + /* correctness is really important here, if we fail to recognize + * identical image we will open/mmap multiple time the same samples + * files which is not supported by the kernel, strange assertion + * failure in libfd is a typical symptom of that */ + + if (separate_thread) { + if (image->tid != tid || image->tgid != tgid) + return 1; + } + + /* if !separate_lib, the comparison made by caller is enough */ + if (!separate_lib) + return 0; + + if (image->app_name == NULL && app_name == NULL) + return 0; + + if (image->app_name != NULL && app_name != NULL && + !strcmp(image->app_name, app_name)) + return 0; + + /* /proc parsed image come with a non null app_name but notification + * for application itself come with a null app_name, in this case + * the test above fail so check for this case. */ + if (image->app_name && !app_name && !strcmp(image->app_name, image->name)) + return 0; + + return 1; +} + + +/** + * opd_find_image - find an image + * @param name name of image to find + * @param hash hash of image to find + * @param app_name the application name where belongs this image + * @param tid thread id + * @param tgid thread group id + * + * Returns the image pointer for the file specified by name, or %NULL. + */ +static struct opd_image * opd_find_image(char const * name, + char const * app_name, pid_t tid, pid_t tgid) +{ + /* suppress uninitialized use warning */ + struct opd_image * image = 0; + struct list_head * pos; + size_t bucket; + + opd_24_stats[OPD_IMAGE_HASH_ACCESS]++; + bucket = opd_hash_image(name, tid, tgid); + list_for_each(pos, &opd_images[bucket]) { + opd_24_stats[OPD_IMAGE_HASH_DEPTH]++; + image = list_entry(pos, struct opd_image, hash_next); + + if (!strcmp(image->name, name)) { + if (!is_same_image(image, app_name, tid, tgid)) + break; + } + } + + if (pos == &opd_images[bucket]) + return NULL; + + /* The app_name field is always valid */ + return image; +} + + +struct opd_image * opd_get_image(char const * name, char const * app_name, + int kernel, pid_t tid, pid_t tgid) +{ + struct opd_image * image; + if ((image = opd_find_image(name, app_name, tid, tgid)) == NULL) + image = opd_new_image(name, app_name, kernel, tid, tgid); + + return image; +} + + +struct opd_image * opd_get_kernel_image(char const * name, + char const * app_name, pid_t tid, pid_t tgid) +{ + return opd_get_image(name, app_name, 1, tid, tgid); +} diff --git a/daemon/liblegacy/opd_image.h b/daemon/liblegacy/opd_image.h new file mode 100644 index 0000000..5d55270 --- /dev/null +++ b/daemon/liblegacy/opd_image.h @@ -0,0 +1,111 @@ +/** + * @file opd_image.h + * Management of binary images + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_IMAGE_H +#define OPD_IMAGE_H + +#include "op_list.h" +#include "op_config_24.h" +#include "op_types.h" + +#include + +struct opd_24_sfile; + +/** + * A binary (library, application, kernel or module) + * is represented by a struct opd_image. + */ +struct opd_image { + /** used by container of opd_images */ + struct list_head hash_next; + /** how many time this opd_image is referenced */ + int ref_count; + /** all samples files belonging to this image */ + struct opd_24_sfile ** sfiles[NR_CPUS]; + /** name of this image */ + char * name; + /** the application name where belongs this image, NULL if image has + * no owner (such as vmlinux or module) */ + char * app_name; + /** thread id, on 2.2 kernel always == to tgid */ + pid_t tid; + /** thread group id */ + pid_t tgid; + /** time of last modification */ + time_t mtime; + /** kernel image or not */ + int kernel; + /** non zero if this image must be profiled */ + int ignored; +}; + +/** callback function passed to opd_for_each_image() */ +typedef void (*opd_image_cb)(struct opd_image *); + +/** + * @param imagecb callback to apply onto each existing image struct + * + * the callback receive a struct opd_image * (not a const struct) and is + * allowed to freeze the image struct itself. + */ +void opd_for_each_image(opd_image_cb imagecb); + +/** + * initialize opd_image container + */ +void opd_init_images(void); + +/** + * @param image the image pointer + * + * Decrement reference count of image, if reference count is zero flush and + * close the samples files then freeze all memory belonging to this image. + */ +void opd_delete_image(struct opd_image * image); + +/** + * opd_get_kernel_image - get a kernel image + * @param name of image + * @param app_name application owner of this kernel image. non-null only + * when separate_kernel_sample != 0 + * @param tid thread id + * @param tgid thread group id + * + * Create and initialise an image adding it to the image lists and to image + * hash list. Note than at creation reference count is zero, it's caller + * responsabilities to incr this count. + */ +struct opd_image * opd_get_kernel_image(char const * name, + char const * app_name, pid_t tid, pid_t tgid); + +/** + * opd_get_image - get an image from the image structure + * @param name name of image + * @param app_name the application name where belongs this image + * @param kernel is the image a kernel/module image + * @param tid thread id + * @param tgid thread group id + * + * Get the image specified by the file name name from the + * image structure. If it is not present, the image is + * added to the structure. In either case, the image number + * is returned. + */ +struct opd_image * opd_get_image(char const * name, char const * app_name, + int kernel, pid_t tid, pid_t tgid); + +/** + * opd_get_nr_images - return number of images + */ +int opd_get_nr_images(void); + +#endif /* OPD_IMAGE_H */ diff --git a/daemon/liblegacy/opd_kernel.c b/daemon/liblegacy/opd_kernel.c new file mode 100644 index 0000000..1131aa7 --- /dev/null +++ b/daemon/liblegacy/opd_kernel.c @@ -0,0 +1,464 @@ +/** + * @file daemon/liblegacy/opd_kernel.c + * Dealing with the kernel and kernel module samples + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "opd_kernel.h" +#include "opd_proc.h" +#include "opd_image.h" +#include "opd_mapping.h" +#include "opd_printf.h" +#include "opd_24_stats.h" +#include "oprofiled.h" + +#include "op_fileio.h" +#include "op_config_24.h" +#include "op_libiberty.h" + +#include "p_module.h" +#include +#include +#include + +/* kernel module */ +struct opd_module { + char * name; + struct opd_image * image; + unsigned long start; + unsigned long end; + struct list_head module_list; +}; + +static struct opd_image * kernel_image; + +/* kernel and module support */ +static unsigned long kernel_start; +static unsigned long kernel_end; +static struct list_head opd_modules = { &opd_modules, &opd_modules }; +static unsigned int nr_modules=0; + +void opd_init_kernel_image(void) +{ + /* for no vmlinux */ + if (!vmlinux) + vmlinux = "no-vmlinux"; + kernel_image = opd_get_kernel_image(vmlinux, NULL, 0, 0); + kernel_image->ref_count++; +} + + +void opd_parse_kernel_range(char const * arg) +{ + sscanf(arg, "%lx,%lx", &kernel_start, &kernel_end); + + verbprintf(vmisc, "OPD_PARSE_KERNEL_RANGE: kernel_start = %lx, kernel_end = %lx\n", + kernel_start, kernel_end); + + if (!kernel_start && !kernel_end) { + fprintf(stderr, + "Warning: mis-parsed kernel range: %lx-%lx\n", + kernel_start, kernel_end); + fprintf(stderr, "kernel profiles will be wrong.\n"); + } +} + + +/** + * opd_create_module - allocate and initialise a module description + * @param name module name + * @param start start address + * @param end end address + */ +static struct opd_module * +opd_create_module(char * name, unsigned long start, unsigned long end) +{ + struct opd_module * module = xmalloc(sizeof(struct opd_module)); + + module->name = xstrdup(name); + module->image = NULL; + module->start = start; + module->end = end; + list_add(&module->module_list, &opd_modules); + + return module; +} + + +/** + * opd_find_module_by_name - find a module by name, ccreating a new once if + * search fail + * @param name module name + */ +static struct opd_module * opd_find_module_by_name(char * name) +{ + struct list_head * pos; + struct opd_module * module; + + list_for_each(pos, &opd_modules) { + module = list_entry(pos, struct opd_module, module_list); + if (!strcmp(name, module->name)) + return module; + } + + return opd_create_module(name, 0, 0); +} + + +void opd_clear_module_info(void) +{ + struct list_head * pos; + struct list_head * pos2; + struct opd_module * module; + + verbprintf(vmodule, "Removing module list\n"); + list_for_each_safe(pos, pos2, &opd_modules) { + module = list_entry(pos, struct opd_module, module_list); + free(module->name); + free(module); + } + + list_init(&opd_modules); + + opd_clear_kernel_mapping(); +} + + +/** + * opd_get_module_info - parse mapping information for kernel modules + * + * Parse the file /proc/ksyms to read in mapping information for + * all kernel modules. The modutils package adds special symbols + * to this file which allows determination of the module image + * and mapping addresses of the form : + * + * __insmod_modulename_Oobjectfile_Mmtime_Vversion + * __insmod_modulename_Ssectionname_Llength + * + * Currently the image file "objectfile" is stored, and details of + * ".text" sections. + * + * There is no query_module API that allow to get directly the pathname + * of a module so we need to parse all the /proc/ksyms. + */ +static void opd_get_module_info(void) +{ + char * line; + char * cp, * cp2, * cp3; + FILE * fp; + struct opd_module * mod; + char * modname; + char * filename; + + nr_modules=0; + + fp = op_try_open_file("/proc/ksyms", "r"); + + if (!fp) { + printf("oprofiled: /proc/ksyms not readable, can't process module samples.\n"); + return; + } + + verbprintf(vmodule, "Read module info.\n"); + + while (1) { + line = op_get_line(fp); + + if (!line) + break; + + if (!strcmp("", line)) { + free(line); + continue; + } + + if (strlen(line) < 9) { + printf("oprofiled: corrupt /proc/ksyms line \"%s\"\n", line); + break; + } + + if (strncmp("__insmod_", line + 9, 9)) { + free(line); + continue; + } + + cp = line + 18; + cp2 = cp; + while ((*cp2) && !!strncmp("_S", cp2+1, 2) && !!strncmp("_O", cp2+1, 2)) + cp2++; + + if (!*cp2) { + printf("oprofiled: corrupt /proc/ksyms line \"%s\"\n", line); + break; + } + + cp2++; + + modname = xmalloc((size_t)((cp2-cp) + 1)); + strncpy(modname, cp, (size_t)((cp2-cp))); + modname[cp2-cp] = '\0'; + + mod = opd_find_module_by_name(modname); + + free(modname); + + switch (*(++cp2)) { + case 'O': + /* get filename */ + cp2++; + cp3 = cp2; + + while ((*cp3) && !!strncmp("_M", cp3+1, 2)) + cp3++; + + if (!*cp3) { + free(line); + continue; + } + + cp3++; + filename = xmalloc((size_t)(cp3 - cp2 + 1)); + strncpy(filename, cp2, (size_t)(cp3 - cp2)); + filename[cp3-cp2] = '\0'; + + mod->image = opd_get_kernel_image(filename, NULL, 0, 0); + mod->image->ref_count++; + free(filename); + break; + + case 'S': + /* get extent of .text section */ + cp2++; + if (strncmp(".text_L", cp2, 7)) { + free(line); + continue; + } + + cp2 += 7; + sscanf(line, "%lx", &mod->start); + sscanf(cp2, "%lu", &mod->end); + mod->end += mod->start; + break; + } + + free(line); + } + + if (line) + free(line); + op_close_file(fp); +} + + +/** + * opd_drop_module_sample - drop a module sample efficiently + * @param eip eip of sample + * + * This function is called to recover from failing to put a samples even + * after re-reading /proc/ksyms. It's either a rogue sample, or from a module + * that didn't create symbols (like in some initrd setups). So we check with + * query_module() if we can place it in a symbol-less module, and if so create + * a negative entry for it, to quickly ignore future samples. + * + * Problem uncovered by Bob Montgomery + * + */ +static void opd_drop_module_sample(unsigned long eip) +{ + char * module_names; + char * name; + size_t size = 1024; + size_t ret; + uint nr_mods; + uint mod = 0; + + opd_24_stats[OPD_LOST_MODULE]++; + + module_names = xmalloc(size); + while (query_module(NULL, QM_MODULES, module_names, size, &ret)) { + if (errno != ENOSPC) { + verbprintf(vmodule, "query_module failed: %s\n", strerror(errno)); + return; + } + size = ret; + module_names = xrealloc(module_names, size); + } + + nr_mods = ret; + name = module_names; + + while (mod < nr_mods) { + struct module_info info; + if (!query_module(name, QM_INFO, &info, sizeof(info), &ret)) { + if (eip >= info.addr && eip < info.addr + info.size) { + verbprintf(vmodule, "Sample from unprofilable module %s\n", name); + opd_create_module(name, info.addr, info.addr + info.size); + break; + } + } + mod++; + name += strlen(name) + 1; + } + + if (module_names) + free(module_names); +} + + +/** + * opd_find_module_by_eip - find a module by its eip + * @param eip EIP value + * + * find in the modules container the module which + * contain this eip return %NULL if not found. + * caller must check than the module image is valid + */ +static struct opd_module * opd_find_module_by_eip(unsigned long eip) +{ + struct list_head * pos; + struct opd_module * module; + + list_for_each(pos, &opd_modules) { + module = list_entry(pos, struct opd_module, module_list); + if (module->start <= eip && module->end > eip) + return module; + } + + return NULL; +} + + +/** + * opd_handle_module_sample - process a module sample + * @param eip EIP value + * @param counter counter number + * + * Process a sample in module address space. The sample eip + * is matched against module information. If the search was + * successful, the sample is output to the relevant file. + * + * Note that for modules and the kernel, the offset will be + * wrong in the file, as it is not a file offset, but the offset + * from the text section. This is fixed up in pp. + * + * If the sample could not be located in a module, it is treated + * as a kernel sample. + */ +static void opd_handle_module_sample(unsigned long eip, u32 counter) +{ + struct opd_module * module; + + module = opd_find_module_by_eip(eip); + if (!module) { + /* not found in known modules, re-read our info and retry */ + opd_clear_module_info(); + opd_get_module_info(); + + module = opd_find_module_by_eip(eip); + } + + if (module) { + if (module->image != NULL) { + opd_24_stats[OPD_MODULE]++; + opd_put_image_sample(module->image, + eip - module->start, counter); + } else { + opd_24_stats[OPD_LOST_MODULE]++; + verbprintf(vmodule, "No image for sampled module %s\n", + module->name); + } + } else { + opd_drop_module_sample(eip); + } +} + + +void opd_handle_kernel_sample(unsigned long eip, u32 counter) +{ + if (no_vmlinux || eip < kernel_end) { + opd_24_stats[OPD_KERNEL]++; + opd_put_image_sample(kernel_image, eip - kernel_start, counter); + return; + } + + /* in a module */ + opd_handle_module_sample(eip, counter); +} + + +int opd_eip_is_kernel(unsigned long eip) +{ +#ifdef __i386 +#define KERNEL_OFFSET 0xC0000000 + /* + * kernel_start == 0 when using --no-vmlinux. + * This is wrong, wrong, wrong, wrong, but we don't have much + * choice. It obviously breaks for IA64. + */ + if (!kernel_start) + return eip >= KERNEL_OFFSET; +#endif + + return eip >= kernel_start; +} + + +void opd_add_kernel_map(struct opd_proc * proc, unsigned long eip) +{ + struct opd_module * module; + struct opd_image * image; + char const * app_name; + + app_name = proc->name; + if (!app_name) { + verbprintf(vmisc, "un-named proc for tid %d\n", proc->tid); + return; + } + + + if (eip < kernel_end) { + image = opd_get_kernel_image(vmlinux, app_name, proc->tid, proc->tgid); + if (!image) { + verbprintf(vmisc, "Can't create image for %s %s\n", vmlinux, app_name); + return; + } + + opd_add_mapping(proc, image, kernel_start, 0, kernel_end); + return; + } + + module = opd_find_module_by_eip(eip); + if (!module) { + /* not found in known modules, re-read our info and retry */ + opd_clear_module_info(); + opd_get_module_info(); + + module = opd_find_module_by_eip(eip); + } + + if (module) { + /* module->name is only the module name not the full path */ + char const * module_name = 0; + if (module->image) + module_name = module->image->name; + if (!module_name) { + verbprintf(vmodule, "unable to get path name for module %s\n", + module->name); + module_name = module->name; + } + image = opd_get_kernel_image(module_name, app_name, proc->tid, proc->tgid); + if (!image) { + verbprintf(vmodule, "Can't create image for %s %s\n", + module->name, app_name); + return; + } + opd_add_mapping(proc, image, module->start, 0, module->end); + } else { + opd_drop_module_sample(eip); + } +} diff --git a/daemon/liblegacy/opd_kernel.h b/daemon/liblegacy/opd_kernel.h new file mode 100644 index 0000000..f854ae0 --- /dev/null +++ b/daemon/liblegacy/opd_kernel.h @@ -0,0 +1,67 @@ +/** + * @file daemon/liblegacy/opd_kernel.h + * Dealing with the kernel and kernel module samples + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_KERNEL_H +#define OPD_KERNEL_H + +#include "op_types.h" + +struct opd_proc; + +/** + * opd_init_kernel_image - initialise the kernel image + */ +void opd_init_kernel_image(void); + +/** + * opd_parse_kernel_range - parse the kernel range values + */ +void opd_parse_kernel_range(char const * arg); + +/** + * opd_clear_module_info - clear kernel module information + * + * Clear and free all kernel module information and reset + * values. + */ +void opd_clear_module_info(void); + +/** + * opd_handle_kernel_sample - process a kernel sample + * @param eip EIP value of sample + * @param counter counter number + * + * Handle a sample in kernel address space or in a module. The sample is + * output to the relevant image file. + */ +void opd_handle_kernel_sample(unsigned long eip, u32 counter); + +/** + * opd_eip_is_kernel - is the sample from kernel/module space + * @param eip EIP value + * + * Returns %1 if eip is in the address space starting at + * kernel_start, %0 otherwise. + */ +int opd_eip_is_kernel(unsigned long eip); + +/** + * opd_add_kernel_map - add a module or kernel maps to a proc struct + * + * @param proc owning proc of the new mapping + * @param eip eip inside the new mapping + * + * We assume than eip >= kernel_start + * + */ +void opd_add_kernel_map(struct opd_proc * proc, unsigned long eip); + +#endif /* OPD_KERNEL_H */ diff --git a/daemon/liblegacy/opd_mapping.c b/daemon/liblegacy/opd_mapping.c new file mode 100644 index 0000000..699c475 --- /dev/null +++ b/daemon/liblegacy/opd_mapping.c @@ -0,0 +1,170 @@ +/** + * @file opd_mapping.c + * Management of process mappings + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "opd_mapping.h" +#include "opd_proc.h" +#include "opd_image.h" +#include "opd_printf.h" + +#include "op_interface.h" +#include "op_config_24.h" +#include "op_libiberty.h" + +#include +#include +#include +#include +#include + +/* hash map device mmap */ +static struct op_hash_index * hashmap; +/* already seen mapping name */ +static char const * hash_name[OP_HASH_MAP_NR]; + + +void opd_cleanup_hash_name(void) +{ + int i; + for (i = 0; i < OP_HASH_MAP_NR; ++i) + free((char *)hash_name[i]); + +} + + +void opd_init_hash_map(void) +{ + extern fd_t hashmapdevfd; + + hashmap = mmap(0, OP_HASH_MAP_SIZE, PROT_READ, MAP_SHARED, hashmapdevfd, 0); + if ((long)hashmap == -1) { + perror("oprofiled: couldn't mmap hash map"); + exit(EXIT_FAILURE); + } + +} + + +void opd_kill_maps(struct opd_proc * proc) +{ + struct list_head * pos, * pos2; + + list_for_each_safe(pos, pos2, &proc->maps) { + struct opd_map * map = list_entry(pos, struct opd_map, next); + list_del(pos); + opd_delete_image(map->image); + free(map); + } +} + + +void opd_add_mapping(struct opd_proc * proc, struct opd_image * image, + unsigned long start, unsigned long offset, unsigned long end) +{ + struct opd_map * map; + + verbprintf(vmisc, "Adding mapping for process %d: 0x%.8lx-0x%.8lx, off 0x%.8lx, \"%s\"\n", + proc->tid, start, end, offset, image->name); + + map = malloc(sizeof(struct opd_map)); + + /* first map is the primary image */ + if (list_empty(&proc->maps)) { + if (proc->name) + free((char *)proc->name); + proc->name = xstrdup(image->name); + } + + image->ref_count++; + + map->image = image; + map->start = start; + map->offset = offset; + map->end = end; + list_add_tail(&map->next, &proc->maps); +} + + +/** + * get_from_pool - retrieve string from hash map pool + * @param ind index into pool + */ +inline static char * get_from_pool(uint ind) +{ + return ((char *)(hashmap + OP_HASH_MAP_NR) + ind); +} + + +/** + * opg_get_hash_name - find a mapping name from a hash + * @param hash hash value for this name + */ +static char const * opd_get_hash_name(int hash) +{ + char file[PATH_MAX]; + char * c = &file[PATH_MAX-1]; + int orighash = hash; + + if (hash_name[hash]) + return hash_name[hash]; + + *c = '\0'; + while (hash) { + char * name = get_from_pool(hashmap[hash].name); + + if (strlen(name) + 1 + strlen(c) >= PATH_MAX) { + fprintf(stderr, "String \"%s\" too large.\n", c); + exit(EXIT_FAILURE); + } + + c -= strlen(name) + 1; + *c = '/'; + strncpy(c + 1, name, strlen(name)); + + /* move onto parent */ + hash = hashmap[hash].parent; + } + + return hash_name[orighash] = xstrdup(c); +} + + +void opd_handle_mapping(struct op_note const * note) +{ + struct opd_proc * proc; + struct opd_image * image; + int hash; + char const * name; + + proc = opd_get_proc(note->pid, note->tgid); + + if (!proc) { + verbprintf(vmisc, "Told about mapping for non-existent process %u.\n", note->pid); + proc = opd_new_proc(note->pid, note->tgid); + } + + hash = note->hash; + + if (hash == -1) { + /* possibly deleted file */ + return; + } + + if (hash < 0 || hash >= OP_HASH_MAP_NR) { + fprintf(stderr, "hash value %u out of range.\n", hash); + return; + } + + name = opd_get_hash_name(hash); + image = opd_get_image(name, proc->name, 0, note->pid, note->tgid); + + opd_add_mapping(proc, image, note->addr, note->offset, + note->addr + note->len); +} diff --git a/daemon/liblegacy/opd_mapping.h b/daemon/liblegacy/opd_mapping.h new file mode 100644 index 0000000..f10b0c8 --- /dev/null +++ b/daemon/liblegacy/opd_mapping.h @@ -0,0 +1,111 @@ +/** + * @file opd_mapping.h + * Management of process mappings + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_MAPPING_H +#define OPD_MAPPING_H + +#include "op_list.h" + +struct opd_image; +struct opd_proc; +struct op_note; + +/** + * represent a mmap'ed area, we create such area only for vma area with exec + * access right + */ +struct opd_map { + /** next mapping for this image */ + struct list_head next; + /** owning image */ + struct opd_image * image; + /** mapping start vma */ + unsigned long start; + /** mapping offset */ + unsigned long offset; + /** mapping end vma */ + unsigned long end; +}; + +/** + * opd_init_hash_map - initialise the hashmap + */ +void opd_init_hash_map(void); + +/** + * op_cleanup_hash_name + * + * release resource owned by hash_name array + */ +void opd_cleanup_hash_name(void); + +/** + * opd_handle_mapping - deal with mapping notification + * @param note mapping notification + * + * Deal with one notification that a process has mapped + * in a new executable file. The mapping information is + * added to the process structure. + */ +void opd_handle_mapping(struct op_note const * note); + +/** + * opd_put_mapping - add a mapping to a process + * @param proc process to add map to + * @param image mapped image pointer + * @param start start of mapping + * @param offset file offset of mapping + * @param end end of mapping + * + * Add the mapping specified to the process proc growing the maps array + * if necessary. + */ +void opd_add_mapping(struct opd_proc * proc, struct opd_image * image, + unsigned long start, unsigned long offset, unsigned long end); + +/** + * opd_kill_maps - delete mapping information for a process + * @param proc process to work on + * + * Frees structures holding mapping information + */ +void opd_kill_maps(struct opd_proc * proc); + +/** + * opd_is_in_map - check whether an EIP is within a mapping + * @param map map to check + * @param eip EIP value + * + * Return %1 if the EIP value @eip is within the boundaries + * of the map @map, %0 otherwise. + */ +inline static int opd_is_in_map(struct opd_map * map, unsigned long eip) +{ + return (eip >= map->start && eip < map->end); +} + + +/* + * opd_map_offset - return offset of sample against map + * @param map map to use + * @param eip EIP value to use + * + * Returns the offset of the EIP value @eip into + * the map @map, which is the same as the file offset + * for the relevant binary image. + */ +inline static unsigned long opd_map_offset(struct opd_map * map, + unsigned long eip) +{ + return (eip - map->start) + map->offset; +} + +#endif /* OPD_MAPPING_H */ diff --git a/daemon/liblegacy/opd_parse_proc.c b/daemon/liblegacy/opd_parse_proc.c new file mode 100644 index 0000000..c20f7be --- /dev/null +++ b/daemon/liblegacy/opd_parse_proc.c @@ -0,0 +1,224 @@ +/** + * @file opd_parse_proc.c + * Parsing of /proc/#pid + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "op_libiberty.h" + +#include "opd_parse_proc.h" +#include "opd_proc.h" +#include "opd_mapping.h" +#include "opd_image.h" +#include "opd_printf.h" + +#include "op_file.h" +#include "op_fileio.h" + +#include +#include +#include +#include + +/** + * opd_add_ascii_map - parse an ASCII map string for a process + * @param proc process to add map to + * @param line 0-terminated ASCII string + * @param image_name the binary application name + * + * Attempt to parse the string @line for map information + * and add the info to the process @proc. Returns %1 + * on success, %0 otherwise. + * + * The parsing is based on Linux 2.4 format, which looks like this : + * + * 4001e000-400fc000 r-xp 00000000 03:04 31011 /lib/libc-2.1.2.so + */ +/* FIXME: handle (deleted) */ +static int opd_add_ascii_map(struct opd_proc * proc, char const * line, + char * const image_name) +{ + unsigned long offset, start, end; + struct opd_image * image; + char const * cp = line; + + /* skip to protection field */ + while (*cp && *cp != ' ') + cp++; + + /* handle rwx */ + if (!*cp || (!*(++cp)) || (!*(++cp)) || (*(++cp) != 'x')) + return 0; + + /* get start and end from "40000000-4001f000" */ + if (sscanf(line, "%lx-%lx", &start, &end) != 2) + return 0; + + /* "p " */ + cp += 2; + + /* read offset */ + if (sscanf(cp, "%lx", &offset) != 1) + return 0; + + while (*cp && *cp != '/') + cp++; + + if (!*cp) + return 0; + + image = opd_get_image(cp, image_name, 0, proc->tid, proc->tgid); + if (!image) + return 0; + + opd_add_mapping(proc, image, start, offset, end); + + return 1; +} + + +/** + * opd_get_ascii_maps - read all maps for a process + * @param proc process to work on + * + * Read the /proc//maps file and add all + * mapping information found to the process @proc. + */ +static void opd_get_ascii_maps(struct opd_proc * proc) +{ + FILE * fp; + char mapsfile[20] = "/proc/"; + char * line; + char exe_name[20]; + char * image_name; + struct list_head * pos; + + snprintf(mapsfile + 6, 6, "%hu", proc->tid); + + strcpy(exe_name, mapsfile); + + strcat(mapsfile, "/maps"); + + fp = op_try_open_file(mapsfile, "r"); + if (!fp) + return; + + strcat(exe_name, "/exe"); + image_name = xmalloc(PATH_MAX); + if (!realpath(exe_name, image_name)) + /* kernel thread are invalid symlink */ + strcpy(image_name, exe_name); + + verbprintf(vmisc, "image name %s for pid %u %u\n", image_name, proc->tid, proc->tgid); + + while (1) { + line = op_get_line(fp); + if (!line) + break; + + opd_add_ascii_map(proc, line, image_name); + free(line); + } + + /* dae assume than the first map added is the primary image name, this + * is always true at exec time but not for /proc/pid so restore + * the primary image name + */ + list_for_each(pos, &proc->maps) { + struct opd_map * map = list_entry(pos, struct opd_map, next); + if (!strcmp(map->image->name, image_name)) { + if (pos != proc->maps.next) { + fprintf(stderr, "swap map for image %s from %s to %s\n", image_name, proc->name, map->image->name); + free((char *)proc->name); + proc->name = xstrdup(map->image->name); + } + break; + } + } + + if (list_empty(&proc->maps)) { + /* we always need a valid proc->maps[0], we artificially give + * a map of length zero so on no samples will never go to this + * map. This is used only with --separate-samples and kernel + * thread when adding vmlinux and module maps to proc->maps[] + */ + /* FIXME: use the first field of /proc/pid/status as proc name + * for now we use /proc/%pid/exe as name */ + struct opd_image * image = opd_get_image(image_name, + image_name, 0, proc->tid, proc->tgid); + if (image) { + opd_add_mapping(proc, image, 0, 0, 0); + } + } + + if (image_name) + free(image_name); + + op_close_file(fp); +} + + +static u32 read_tgid(u32 tid) +{ + char status_file[30] = "/proc/"; + char * line; + FILE * fp; + u32 tgid; + + snprintf(status_file + 6, 6, "%hu", tid); + + strcat(status_file, "/status"); + + fp = op_try_open_file(status_file, "r"); + if (!fp) + return 0; + + while (1) { + line = op_get_line(fp); + if (!line) + break; + + if (sscanf(line, "Tgid: %u", &tgid) == 1) { + free(line); + op_close_file(fp); + return tgid; + } + free(line); + } + + op_close_file(fp); + + return 0; +} + + +void opd_get_ascii_procs(void) +{ + DIR * dir; + struct dirent * dirent; + struct opd_proc * proc; + u32 pid; + + if (!(dir = opendir("/proc"))) { + perror("oprofiled: /proc directory could not be opened. "); + exit(EXIT_FAILURE); + } + + while ((dirent = readdir(dir))) { + if (sscanf(dirent->d_name, "%u", &pid) == 1) { + u32 tgid = read_tgid(pid); + verbprintf(vmisc, "ASCII added %u %u\n", pid, tgid); + proc = opd_get_proc(pid, tgid); + if (!proc) + proc = opd_new_proc(pid, tgid); + opd_get_ascii_maps(proc); + } + } + + closedir(dir); +} diff --git a/daemon/liblegacy/opd_parse_proc.h b/daemon/liblegacy/opd_parse_proc.h new file mode 100644 index 0000000..a224be4 --- /dev/null +++ b/daemon/liblegacy/opd_parse_proc.h @@ -0,0 +1,23 @@ +/** + * @file opd_parse_proc.h + * Parsing of /proc/#pid + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_PARSE_PROC_H +#define OPD_PARSE_PROC_H + +/** + * opd_get_ascii_procs - read process and mapping information from /proc + * + * Read information on each process and its mappings from the /proc + * filesystem. + */ +void opd_get_ascii_procs(void); + +#endif /* OPD_PARSE_PROC_H */ diff --git a/daemon/liblegacy/opd_proc.c b/daemon/liblegacy/opd_proc.c new file mode 100644 index 0000000..ff5a5a5 --- /dev/null +++ b/daemon/liblegacy/opd_proc.c @@ -0,0 +1,432 @@ +/** + * @file opd_proc.c + * Management of processes + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "op_hw_config.h" +#include "opd_proc.h" +#include "opd_image.h" +#include "opd_mapping.h" +#include "opd_sample_files.h" +#include "opd_kernel.h" +#include "opd_24_stats.h" +#include "opd_printf.h" +#include "oprofiled.h" + +#include "op_interface.h" +#include "op_libiberty.h" + +#include +#include +#include +#include + +/* size of process hash table */ +#define OPD_MAX_PROC_HASH 1024 + +extern int cpu_number; + +/* hash of process lists */ +static struct list_head opd_procs[OPD_MAX_PROC_HASH]; + +/* statistics purpose */ +static int nr_procs; + + +void opd_init_procs(void) +{ + int i; + for (i = 0; i < OPD_MAX_PROC_HASH; i++) + list_init(&opd_procs[i]); +} + + +int opd_get_nr_procs(void) +{ + return nr_procs; +} + + +/** + * proc_hash - hash pid value + * @param tid pid value to hash + * + */ +inline static uint proc_hash(pid_t tid) +{ + /* FIXME: hash tgid too! */ + return ((tid >> 4) ^ (tid)) % OPD_MAX_PROC_HASH; +} + + +struct opd_proc * opd_new_proc(pid_t tid, pid_t tgid) +{ + struct opd_proc * proc; + + nr_procs++; + proc = xmalloc(sizeof(struct opd_proc)); + list_init(&proc->maps); + proc->name = NULL; + proc->tid = tid; + proc->tgid = tgid; + proc->dead = 0; + proc->accessed = 0; + list_add(&proc->next, &opd_procs[proc_hash(tid)]); + return proc; +} + + +struct opd_proc * opd_get_proc(pid_t tid, pid_t tgid) +{ + struct opd_proc * proc; + uint hash = proc_hash(tid); + struct list_head * pos, *pos2; + + opd_24_stats[OPD_PROC_QUEUE_ACCESS]++; + list_for_each_safe(pos, pos2, &opd_procs[hash]) { + opd_24_stats[OPD_PROC_QUEUE_DEPTH]++; + proc = list_entry(pos, struct opd_proc, next); + if (tid == proc->tid && tgid == proc->tgid) { + /* LRU to head */ + list_del(&proc->next); + list_add(&proc->next, &opd_procs[hash]); + return proc; + } + } + + return NULL; +} + + +/** + * verb_show_sample - print the sample out to the log + * @param offset the offset value + * @param map map to print + */ +inline static void +verb_show_sample(unsigned long offset, struct opd_map * map) +{ + verbprintf(vsamples, "DO_PUT_SAMPLE : calc offset 0x%.8lx, " + "map start 0x%.8lx, end 0x%.8lx, offset 0x%.8lx, name \"%s\"\n", + offset, map->start, map->end, map->offset, + map->image->name); +} + + +void opd_put_image_sample(struct opd_image * image, unsigned long offset, + u32 counter) +{ + struct opd_24_sfile * sfile; + int err; + + if (image->ignored) + return; + + if (!image->sfiles[cpu_number]) { + image->sfiles[cpu_number] = + xcalloc(OP_MAX_COUNTERS, sizeof(struct op_24_sfile *)); + } + sfile = image->sfiles[cpu_number][counter]; + + if (!sfile || !odb_open_count(&sfile->sample_file)) { + if (opd_open_24_sample_file(image, counter, cpu_number)) { + /* opd_open_24_sample_file output an error message */ + opd_24_stats[OPD_LOST_SAMPLEFILE]++; + return; + } + sfile = image->sfiles[cpu_number][counter]; + } + + err = odb_insert(&sfile->sample_file, offset, 1); + if (err) { + fprintf(stderr, "%s\n", strerror(err)); + abort(); + } + + opd_24_sfile_lru(sfile); +} + + +/** + * opd_lookup_maps - lookup a proc mappings for a sample + * @param proc proc to lookup + * @param sample sample to lookup + * + * iterate through the proc maps searching the mapping which owns sample + * if sucessful sample count will be updated and we return non-zero + */ +static int opd_lookup_maps(struct opd_proc * proc, + struct op_sample const * sample) +{ + struct list_head * pos; + + proc->accessed = 1; + + opd_24_stats[OPD_MAP_ARRAY_ACCESS]++; + list_for_each(pos, &proc->maps) { + struct opd_map * map = list_entry(pos, struct opd_map, next); + if (opd_is_in_map(map, sample->eip)) { + unsigned long offset = opd_map_offset(map, sample->eip); + if (map->image != NULL) { + verb_show_sample(offset, map); + opd_put_image_sample(map->image, offset, sample->counter); + } + opd_24_stats[OPD_PROCESS]++; + return 1; + } + opd_24_stats[OPD_MAP_ARRAY_DEPTH]++; + } + + return 0; +} + + +void opd_put_sample(struct op_sample const * sample) +{ + struct opd_proc * proc; + int in_kernel_eip = opd_eip_is_kernel(sample->eip); + + opd_24_stats[OPD_SAMPLES]++; + + verbprintf(vsamples, "DO_PUT_SAMPLE: c%d, EIP 0x%.8lx, tgid %.6d pid %.6d\n", + sample->counter, sample->eip, sample->tgid, sample->pid); + + if (!separate_kernel && in_kernel_eip) { + opd_handle_kernel_sample(sample->eip, sample->counter); + return; + } + + if (!(proc = opd_get_proc(sample->pid, sample->tgid))) { + if (in_kernel_eip || no_vmlinux) { + /* idle task get a 0 pid and is hidden we can never get + * a proc so on we fall back to put sample in vmlinux + * or module samples files. Here we will catch also + * sample for newly created kernel thread, currently + * we can handle properly only kenel thread created + * at daemon startup time */ + opd_handle_kernel_sample(sample->eip, sample->counter); + } else { + verbprintf(vmisc, "No proc info for tgid %.6d pid %.6d.\n", + sample->tgid, sample->pid); + opd_24_stats[OPD_LOST_PROCESS]++; + } + return; + } + + if (opd_lookup_maps(proc, sample)) + return; + + if (in_kernel_eip) { + opd_add_kernel_map(proc, sample->eip); + if (opd_lookup_maps(proc, sample)) + return; + } + + /* couldn't locate it */ + verbprintf(vsamples, "Couldn't find map for pid %.6d, EIP 0x%.8lx.\n", + sample->pid, sample->eip); + opd_24_stats[OPD_LOST_MAP_PROCESS]++; +} + + +void opd_handle_fork(struct op_note const * note) +{ + struct opd_proc * old; + struct opd_proc * proc; + struct list_head * pos; + + verbprintf(vmisc, "DO_FORK: from %d, %d to %ld, %ld\n", note->pid, note->tgid, + note->addr, note->len); + + old = opd_get_proc(note->pid, note->tgid); + + /* we can quite easily get a fork() after the execve() because the + * notifications are racy. In particular, the fork notification is + * done on parent return (so we know the pid), but this will often be + * after the execve is done by the child. + * + * So we only create a new setup if it doesn't exist already, allowing + * both the clone() and the execve() cases to work. + */ + if (opd_get_proc(note->addr, note->len)) + return; + + /* eip/len is actually tid/tgid of new process */ + proc = opd_new_proc(note->addr, note->len); + + if (!old) + return; + + /* copy the maps */ + list_for_each(pos, &old->maps) { + struct opd_map * map = list_entry(pos, struct opd_map, next); + if (!separate_thread) { + opd_add_mapping(proc, map->image, map->start, + map->offset, map->end); + } else { + /* when separating thread we can't create blindly a new + * image e.g. pid re-use, multiple mapping with the + * same mapping name etc. */ + struct opd_image * image = + opd_get_image(map->image->name, old->name, + map->image->kernel, note->addr, note->len); + opd_add_mapping(proc, image, map->start, map->offset, + map->end); + } + } +} + + +void opd_handle_exec(pid_t tid, pid_t tgid) +{ + struct opd_proc * proc; + + verbprintf(vmisc, "DO_EXEC: pid %u %u\n", tid, tgid); + + /* There is a race for samples received between fork/exec sequence. + * These samples belong to the old mapping but we can not say if + * samples has been received before the exec or after. This explains + * the message "Couldn't find map for ..." in verbose mode. + * + * Unhappily, it is difficult to get an estimation of these misplaced + * samples, the error message can count only out of mapping samples but + * not samples between the race and inside the mapping of the exec'ed + * process :/. + * + * Trying to save old mapping is not correct due the above reason. The + * only manner to handle this is to flush the module samples hash table + * after each fork which is unacceptable for performance reasons */ + proc = opd_get_proc(tid, tgid); + if (proc) { + opd_kill_maps(proc); + /* proc->name will be set when the next mapping occurs */ + free((char *)proc->name); + proc->name = NULL; + } else { + opd_new_proc(tid, tgid); + } +} + + +void opd_handle_exit(struct op_note const * note) +{ + struct opd_proc * proc; + + verbprintf(vmisc, "DO_EXIT: process %d\n", note->pid); + + proc = opd_get_proc(note->pid, note->tgid); + if (proc) { + proc->dead = 1; + proc->accessed = 1; + } else { + verbprintf(vmisc, "unknown proc %u just exited.\n", note->pid); + } +} + + +typedef void (*opd_proc_cb)(struct opd_proc *); + +/** + * @param proc_cb callback to apply onto each existing proc struct + * + * the callback receive a struct opd_proc * (not a const struct) and is + * allowed to freeze the proc struct itself. + */ +static void opd_for_each_proc(opd_proc_cb proc_cb) +{ + struct list_head * pos; + struct list_head * pos2; + int i; + + for (i = 0; i < OPD_MAX_PROC_HASH; ++i) { + list_for_each_safe(pos, pos2, &opd_procs[i]) { + struct opd_proc * proc = + list_entry(pos, struct opd_proc, next); + proc_cb(proc); + } + } +} + + +/** + * opd_delete_proc - delete a process + * @param proc process to delete + * + * Remove the process proc from the process list and free + * the associated structures. + */ +static void opd_delete_proc(struct opd_proc * proc) +{ + --nr_procs; + list_del(&proc->next); + opd_kill_maps(proc); + if (proc->name) + free((char *)proc->name); + free(proc); +} + + +void opd_proc_cleanup(void) +{ + opd_for_each_proc(opd_delete_proc); +} + + +/** + * opd_age_proc - age a struct opd_proc + * @param proc proc to age + * + * age dead proc in such way if a proc doesn't receive any samples + * between two age_proc the opd_proc struct is deleted + */ +static void opd_age_proc(struct opd_proc * proc) +{ + // delay death whilst its still being accessed + if (proc->dead) { + proc->dead += proc->accessed; + proc->accessed = 0; + if (--proc->dead == 0) + opd_delete_proc(proc); + } +} + + +void opd_age_procs(void) +{ + opd_for_each_proc(opd_age_proc); +} + + +/** + * opd_remove_kernel_mapping - remove all kernel mapping for an opd_proc + * @param proc proc where mappings must be updated. + * + * invalidate (by removing them) all kernel mapping. This function do nothing + * when separate_kernel == 0 because we don't add mapping for kernel + * sample in proc struct. + */ +static void opd_remove_kernel_mapping(struct opd_proc * proc) +{ + struct list_head * pos, * pos2; + + list_for_each_safe(pos, pos2, &proc->maps) { + struct opd_map * map = list_entry(pos, struct opd_map, next); + if (opd_eip_is_kernel(map->start + map->offset)) { + list_del(pos); + opd_delete_image(map->image); + free(map); + } + } +} + + +void opd_clear_kernel_mapping(void) +{ + opd_for_each_proc(opd_remove_kernel_mapping); +} diff --git a/daemon/liblegacy/opd_proc.h b/daemon/liblegacy/opd_proc.h new file mode 100644 index 0000000..8140a46 --- /dev/null +++ b/daemon/liblegacy/opd_proc.h @@ -0,0 +1,151 @@ +/** + * @file opd_proc.h + * Management of processes + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_PROC_H +#define OPD_PROC_H + +#include "op_types.h" +#include "op_list.h" + +struct opd_map; +struct opd_image; +struct op_note; +struct op_sample; + +/** + * track process, created either by a fork or an exec notification. + */ +struct opd_proc { + /** maps are always added to the end of head, so search will be done + * from the newest map to the oldest which mean we don't care about + * munmap. First added map must be the primary image */ + struct list_head maps; + /** process name */ + char const * name; + /** thread id for this process, always equal to tgid for 2.2 kernel */ + pid_t tid; + /** thread group id for this process */ + pid_t tgid; + /** non-zero if this process receive any samples, this field + * is used with dead field to defer opd_proc deletion */ + int accessed; + /** Set to non-zero when an exit notification occur for this process */ + int dead; + /** used by container of opd_proc */ + struct list_head next; +}; + +/** + * initialize opd_proc container + */ +void opd_init_procs(void); + +/** + * opd_put_sample - process a sample + * @param sample sample to process + * + * Write out the sample to the appropriate sample file. This + * routine handles kernel and module samples as well as ordinary ones. + */ +void opd_put_sample(struct op_sample const * sample); + +/** + * opd_put_image_sample - write sample to file + * @param image image for sample + * @param offset (file) offset to write to + * @param counter counter number + * + * Add to the count stored at position offset in the + * image file. Overflow pins the count at the maximum + * value. + */ +void opd_put_image_sample(struct opd_image * image, unsigned long offset, u32 counter); + +/** + * opd_handle_fork - deal with fork notification + * @param note note to handle + * + * Deal with a fork() notification by creating a new process + * structure, and copying mapping information from the old process. + * + * sample->pid contains the process id of the old process. + * sample->eip contains the process id of the new process. + */ +void opd_handle_fork(struct op_note const * note); + +/** + * opd_handle_exec - deal with notification of execve() + * @param tid tid for this process + * @param tgid tgid for this process + * + * Drop all mapping information for the process. + */ +void opd_handle_exec(pid_t tid, pid_t tgid); + +/** + * opd_handle_exit - deal with exit notification + * @param note note to handle + * + * Deal with an exit() notification by setting the flag "dead" + * on a process. These will be later cleaned up by the %SIGALRM + * handler. + * + * sample->pid contains the process id of the exited process. + */ +void opd_handle_exit(struct op_note const * note); + +/** + * opd_get_proc - get process from process list + * @param tid tid for this process + * @param tgid tgid for this process + * + * A process with pid tid is searched on the process list, + * maintaining LRU order. If it is not found, %NULL is returned, + * otherwise the process structure is returned. + */ +struct opd_proc * opd_get_proc(pid_t tid, pid_t tgid); + +/** + * opd_new_proc - create a new process structure + * @param tid tid for this process + * @param tgid tgid for this process + * + * Allocate and initialise a process structure and insert + * it into the procs hash table. + */ +struct opd_proc * opd_new_proc(pid_t tid, pid_t tgid); + +/** + * opd_get_nr_procs - return number of processes tracked + */ +int opd_get_nr_procs(void); + +/** + * opd_age_procs - age all dead process preparing them for a deletion + */ +void opd_age_procs(void); + +/** + * freeze all resource used by opd_procs managment + */ +void opd_proc_cleanup(void); + +/** + * opd_clear_kernel_mapping - remove all kernel mapping for all opd_proc + * + * invalidate (by removing them) all kernel mapping. This function do nothing + * when separate_kernel == 0 because we don't add mapping for kernel + * sample in proc struct. As side effect decrease reference count of + * associated with these mapping which eventually close this image + */ +void opd_clear_kernel_mapping(void); + +#endif /* OPD_PROC_H */ diff --git a/daemon/liblegacy/opd_sample_files.c b/daemon/liblegacy/opd_sample_files.c new file mode 100644 index 0000000..4cbb47e --- /dev/null +++ b/daemon/liblegacy/opd_sample_files.c @@ -0,0 +1,179 @@ +/** + * @file opd_sample_files.c + * Management of sample files + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include "opd_sample_files.h" +#include "opd_image.h" +#include "opd_printf.h" +#include "opd_events.h" +#include "oprofiled.h" + +#include "op_sample_file.h" +#include "op_file.h" +#include "op_config.h" +#include "op_mangle.h" +#include "op_events.h" + +#include +#include +#include +#include + +/** All sfiles are on this list. */ +static LIST_HEAD(lru_list); + +/* this value probably doesn't matter too much */ +#define LRU_AMOUNT 1000 +static int opd_24_sfile_lru_clear(void) +{ + struct list_head * pos; + struct list_head * pos2; + struct opd_24_sfile * sfile; + int amount = LRU_AMOUNT; + + verbprintf(vsfile, "image lru clear\n"); + + if (list_empty(&lru_list)) + return 1; + + list_for_each_safe(pos, pos2, &lru_list) { + if (!--amount) + break; + sfile = list_entry(pos, struct opd_24_sfile, lru_next); + odb_close(&sfile->sample_file); + list_del_init(&sfile->lru_next); + } + + return 0; +} + + +void opd_24_sfile_lru(struct opd_24_sfile * sfile) +{ + list_del(&sfile->lru_next); + list_add_tail(&sfile->lru_next, &lru_list); +} + + +static char * opd_mangle_filename(struct opd_image const * image, int counter, + int cpu_nr) +{ + char * mangled; + struct mangle_values values; + struct opd_event * event = find_counter_event(counter); + + values.flags = 0; + if (image->kernel) + values.flags |= MANGLE_KERNEL; + + if (separate_thread) { + values.flags |= MANGLE_TGID | MANGLE_TID; + values.tid = image->tid; + values.tgid = image->tgid; + } + + if (separate_cpu) { + values.flags |= MANGLE_CPU; + values.cpu = cpu_nr; + } + + values.event_name = event->name; + values.count = event->count; + values.unit_mask = event->um; + + values.image_name = image->name; + values.dep_name = separate_lib && image->app_name + ? image->app_name : image->name; + + mangled = op_mangle_filename(&values); + + return mangled; +} + + +int opd_open_24_sample_file(struct opd_image * image, int counter, int cpu_nr) +{ + char * mangled; + struct opd_24_sfile * sfile; + int err; + + mangled = opd_mangle_filename(image, counter, cpu_nr); + + verbprintf(vsfile, "Opening \"%s\"\n", mangled); + + create_path(mangled); + + sfile = image->sfiles[cpu_nr][counter]; + if (!sfile) { + sfile = malloc(sizeof(struct opd_24_sfile)); + list_init(&sfile->lru_next); + odb_init(&sfile->sample_file); + image->sfiles[cpu_nr][counter] = sfile; + } + + list_del(&sfile->lru_next); + list_add_tail(&sfile->lru_next, &lru_list); + +retry: + err = odb_open(&sfile->sample_file, mangled, ODB_RDWR, + sizeof(struct opd_header)); + + /* This can naturally happen when racing against opcontrol --reset. */ + if (err) { + if (err == EMFILE) { + if (opd_24_sfile_lru_clear()) { + printf("LRU cleared but odb_open() fails for %s.\n", mangled); + abort(); + } + goto retry; + } + + fprintf(stderr, "oprofiled: open of %s failed: %s\n", + mangled, strerror(err)); + goto out; + } + + fill_header(odb_get_data(&sfile->sample_file), counter, 0, 0, + image->kernel, 0, image->mtime); + +out: + free(mangled); + return err; +} + + +void opd_sync_samples_files(void) +{ + struct list_head * pos; + struct opd_24_sfile * sfile; + + list_for_each(pos, &lru_list) { + sfile = list_entry(pos, struct opd_24_sfile, lru_next); + odb_sync(&sfile->sample_file); + } +} + + +void opd_close_image_samples_files(struct opd_image * image) +{ + uint i, j; + for (i = 0 ; i < op_nr_counters ; ++i) { + for (j = 0; j < NR_CPUS; ++j) { + if (image->sfiles[j] && image->sfiles[j][i]) { + odb_close(&image->sfiles[j][i]->sample_file); + list_del(&image->sfiles[j][i]->lru_next); + free(image->sfiles[j][i]); + image->sfiles[j][i] = 0; + } + } + } +} diff --git a/daemon/liblegacy/opd_sample_files.h b/daemon/liblegacy/opd_sample_files.h new file mode 100644 index 0000000..20555a9 --- /dev/null +++ b/daemon/liblegacy/opd_sample_files.h @@ -0,0 +1,63 @@ +/** + * @file opd_sample_files.h + * Management of sample files + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_SAMPLE_FILES_H +#define OPD_SAMPLE_FILES_H + +#include "op_list.h" +#include "odb.h" + +struct opd_image; + +/** one samples file when profiling on a 2.2/2.4 kernel */ +struct opd_24_sfile { + /** lru list of sample file */ + struct list_head lru_next; + /** the sample file itself */ + odb_t sample_file; +}; + +/** + * sync all samples files + */ +void opd_sync_samples_files(void); + +/** + * @param image the image pointer to work on + * + * close all samples files belonging to this image + */ +void opd_close_image_samples_files(struct opd_image * image); + +/** + * opd_open_24_sample_file - open an image sample file + * @param image image to open file for + * @param counter counter number + * @param cpu_nr cpu number + * + * Open image sample file for the image, counter + * counter and set up memory mappings for it. + * image->kernel and image->name must have meaningful + * values. + * + * Returns 0 on success. + */ +int opd_open_24_sample_file(struct opd_image * image, int counter, int cpu_nr); + +/** + * @param sfile sample file to act on + * + * put sfile at the head of samples files lru list + */ +void opd_24_sfile_lru(struct opd_24_sfile * sfile); + + +#endif /* OPD_SAMPLE_FILES_H */ diff --git a/daemon/liblegacy/p_module.h b/daemon/liblegacy/p_module.h new file mode 100644 index 0000000..9367508 --- /dev/null +++ b/daemon/liblegacy/p_module.h @@ -0,0 +1,207 @@ +/* Definitions for the Linux module syscall interface. + Copyright 1996, 1997 Linux International. + + Contributed by Richard Henderson + + This file is part of the Linux modutils. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef MODUTILS_MODULE_H +#define MODUTILS_MODULE_H 1 + +/* This file contains the structures used by the 2.0 and 2.1 kernels. + We do not use the kernel headers directly because we do not wish + to be dependant on a particular kernel version to compile insmod. */ + + +/*======================================================================*/ +/* The structures used by Linux 2.0. */ + +/* The symbol format used by get_kernel_syms(2). */ +struct old_kernel_sym +{ + unsigned long value; + char name[60]; +}; + +struct old_module_ref +{ + unsigned long module; /* kernel addresses */ + unsigned long next; +}; + +struct old_module_symbol +{ + unsigned long addr; + unsigned long name; +}; + +struct old_symbol_table +{ + int size; /* total, including string table!!! */ + int n_symbols; + int n_refs; + struct old_module_symbol symbol[0]; /* actual size defined by n_symbols */ + struct old_module_ref ref[0]; /* actual size defined by n_refs */ +}; + +struct old_mod_routines +{ + unsigned long init; + unsigned long cleanup; +}; + +struct old_module +{ + unsigned long next; + unsigned long ref; /* the list of modules that refer to me */ + unsigned long symtab; + unsigned long name; + int size; /* size of module in pages */ + unsigned long addr; /* address of module */ + int state; + unsigned long cleanup; /* cleanup routine */ +}; + +/* Sent to init_module(2) or'ed into the code size parameter. */ +#define OLD_MOD_AUTOCLEAN 0x40000000 /* big enough, but no sign problems... */ + +int get_kernel_syms(struct old_kernel_sym *); +int old_sys_init_module(char const * name, char *code, unsigned codesize, + struct old_mod_routines *, struct old_symbol_table *); + +/*======================================================================*/ +/* For sizeof() which are related to the module platform and not to the + environment isnmod is running in, use sizeof_xx instead of sizeof(xx). */ + +#define tgt_sizeof_char sizeof(char) +#define tgt_sizeof_short sizeof(short) +#define tgt_sizeof_int sizeof(int) +#define tgt_sizeof_long sizeof(long) +#define tgt_sizeof_char_p sizeof(char *) +#define tgt_sizeof_void_p sizeof(void *) +#define tgt_long long +#define tgt_long_fmt "l" + +/* This assumes that long long on a 32 bit system is equivalent to long on the + * equivalent 64 bit system. Also that void and char pointers are 8 bytes on + * all 64 bit systems. Add per system tweaks if it ever becomes necessary. + */ +#if defined(COMMON_3264) && defined(ONLY_64) +#undef tgt_long +#undef tgt_long_fmt +#undef tgt_sizeof_long +#undef tgt_sizeof_char_p +#undef tgt_sizeof_void_p +#define tgt_long long long +#define tgt_long_fmt "ll" +#define tgt_sizeof_long 8 +#define tgt_sizeof_char_p 8 +#define tgt_sizeof_void_p 8 +#endif + +/*======================================================================*/ +/* The structures used in Linux 2.1 onwards. */ + +/* Note: module_symbol does not use tgt_long intentionally */ +struct module_symbol +{ + unsigned long value; + unsigned long name; +}; + +struct module_ref +{ + unsigned tgt_long dep; /* kernel addresses */ + unsigned tgt_long ref; + unsigned tgt_long next_ref; +}; + +struct module +{ + unsigned tgt_long size_of_struct; /* == sizeof(module) */ + unsigned tgt_long next; + unsigned tgt_long name; + unsigned tgt_long size; + + tgt_long usecount; + unsigned tgt_long flags; /* AUTOCLEAN et al */ + + unsigned nsyms; + unsigned ndeps; + + unsigned tgt_long syms; + unsigned tgt_long deps; + unsigned tgt_long refs; + unsigned tgt_long init; + unsigned tgt_long cleanup; + unsigned tgt_long ex_table_start; + unsigned tgt_long ex_table_end; +#ifdef __alpha__ + unsigned tgt_long gp; +#endif + /* Everything after here is extension. */ + unsigned tgt_long read_start; /* Read data from existing module */ + unsigned tgt_long read_end; + unsigned tgt_long can_unload; + unsigned tgt_long runsize; + unsigned tgt_long kallsyms_start; + unsigned tgt_long kallsyms_end; + unsigned tgt_long archdata_start; + unsigned tgt_long archdata_end; + unsigned tgt_long kernel_data; +}; + +struct module_info +{ + unsigned long addr; + unsigned long size; + unsigned long flags; + long usecount; +}; + +/* Bits of module.flags. */ +#define NEW_MOD_RUNNING 1 +#define NEW_MOD_DELETED 2 +#define NEW_MOD_AUTOCLEAN 4 +#define NEW_MOD_VISITED 8 +#define NEW_MOD_USED_ONCE 16 +#define NEW_MOD_INITIALIZING 64 + +int sys_init_module(char const * name, const struct module *); +int query_module(char const * name, int which, void *buf, size_t bufsize, + size_t *ret); + +/* Values for query_module's which. */ + +#define QM_MODULES 1 +#define QM_DEPS 2 +#define QM_REFS 3 +#define QM_SYMBOLS 4 +#define QM_INFO 5 + +/*======================================================================*/ +/* The system calls unchanged between 2.0 and 2.1. */ + +unsigned long create_module(const char *, size_t); +int delete_module(const char *); + +/* In safe mode the last parameter is forced to be a module name and meta + * expansion is not allowed on that name. + */ +extern unsigned int safemode; + +#endif /* module.h */ diff --git a/daemon/opd_anon.c b/daemon/opd_anon.c new file mode 100644 index 0000000..f4c8b2a --- /dev/null +++ b/daemon/opd_anon.c @@ -0,0 +1,221 @@ +/** + * @file opd_anon.c + * Anonymous region handling. + * + * Our caching of maps has some problems: if we get tgid reuse, + * and it's the same application, we might end up with wrong + * maps. The same happens in an unmap-remap case. There's not much + * we can do about this, we just hope it's not too common... + * + * What is relatively common is expanding anon maps, which leaves us + * with lots of separate sample files. + * + * @remark Copyright 2005 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#include "opd_anon.h" +#include "opd_trans.h" +#include "opd_sfile.h" +#include "opd_printf.h" +#include "op_libiberty.h" + +#include +#include +#include + +#define HASH_SIZE 1024 +#define HASH_BITS (HASH_SIZE - 1) + +#define LRU_SIZE 1000 +#define LRU_AMOUNT (LRU_SIZE/5) + +static struct list_head hashes[HASH_SIZE]; +static struct list_head lru; +static size_t nr_lru; + +/* never called in buffer-processing context, so we don't need + * to update struct transient. Note the 'U' of LRU is based on + * parsing time, not actual use. + */ +static void do_lru(struct transient * trans) +{ + size_t nr_to_kill = LRU_AMOUNT; + struct list_head * pos; + struct list_head * pos2; + struct anon_mapping * entry; + + list_for_each_safe(pos, pos2, &lru) { + entry = list_entry(pos, struct anon_mapping, lru_list); + if (trans->anon == entry) + clear_trans_current(trans); + if (trans->last_anon == entry) + clear_trans_last(trans); + list_del(&entry->list); + list_del(&entry->lru_list); + --nr_lru; + free(entry); + if (nr_to_kill-- == 0) + break; + } + + sfile_clear_anon(); +} + + +static unsigned long hash_anon(pid_t tgid, cookie_t app) +{ + return ((app >> DCOOKIE_SHIFT) ^ (tgid >> 2)) & (HASH_SIZE - 1); +} + + +static void clear_anon_maps(struct transient * trans) +{ + unsigned long hash = hash_anon(trans->tgid, trans->app_cookie); + pid_t tgid = trans->tgid; + cookie_t app = trans->app_cookie; + struct list_head * pos; + struct list_head * pos2; + struct anon_mapping * entry; + + clear_trans_current(trans); + + list_for_each_safe(pos, pos2, &hashes[hash]) { + entry = list_entry(pos, struct anon_mapping, list); + if (entry->tgid == tgid && entry->app_cookie == app) { + if (trans->last_anon == entry) + clear_trans_last(trans); + list_del(&entry->list); + list_del(&entry->lru_list); + --nr_lru; + free(entry); + } + } + + sfile_clear_anon(); + if (vmisc) { + char const * name = verbose_cookie(app); + printf("Cleared anon maps for tgid %u (%s).\n", tgid, name); + } +} + + +static void +add_anon_mapping(struct transient * trans, vma_t start, vma_t end) +{ + unsigned long hash = hash_anon(trans->tgid, trans->app_cookie); + struct anon_mapping * m = xmalloc(sizeof(struct anon_mapping)); + m->tgid = trans->tgid; + m->app_cookie = trans->app_cookie; + m->start = start; + m->end = end; + list_add_tail(&m->list, &hashes[hash]); + list_add_tail(&m->lru_list, &lru); + if (++nr_lru == LRU_SIZE) + do_lru(trans); + if (vmisc) { + char const * name = verbose_cookie(m->app_cookie); + printf("Added anon map 0x%llx-0x%llx for tgid %u (%s).\n", + start, end, m->tgid, name); + } +} + + +/* 42000000-4212f000 r-xp 00000000 16:03 424334 /lib/tls/libc-2.3.2.so */ +static void get_anon_maps(struct transient * trans) +{ + FILE * fp = NULL; + char buf[PATH_MAX]; + unsigned long start; + unsigned long end; + int ret; + + snprintf(buf, PATH_MAX, "/proc/%d/maps", trans->tgid); + fp = fopen(buf, "r"); + if (!fp) + return; + + while (fgets(buf, PATH_MAX, fp) != NULL) { + char tmp[20]; + /* Note that this actually includes all mappings, + * since we want stuff like [heap] + */ + ret = sscanf(buf, "%lx-%lx %20s %20s %20s %20s %20s", + &start, &end, tmp, tmp, tmp, tmp, tmp); + if (ret < 6) + continue; + + add_anon_mapping(trans, start, end); + } + + fclose(fp); +} + + +static int +anon_match(struct transient const * trans, struct anon_mapping const * anon) +{ + if (!anon) + return 0; + if (trans->tgid != anon->tgid) + return 0; + if (trans->app_cookie != anon->app_cookie) + return 0; + if (trans->pc < anon->start) + return 0; + return (trans->pc < anon->end); +} + + +struct anon_mapping * find_anon_mapping(struct transient * trans) +{ + unsigned long hash = hash_anon(trans->tgid, trans->app_cookie); + struct list_head * pos; + struct anon_mapping * entry; + int tried = 0; + + if (anon_match(trans, trans->anon)) + return (trans->anon); + +retry: + list_for_each(pos, &hashes[hash]) { + entry = list_entry(pos, struct anon_mapping, list); + if (anon_match(trans, entry)) + goto success; + } + + if (!tried) { + clear_anon_maps(trans); + get_anon_maps(trans); + tried = 1; + goto retry; + } + + return NULL; + +success: + /* + * Typically, there's one big mapping that matches. Let's go + * faster. + */ + list_del(&entry->list); + list_add(&entry->list, &hashes[hash]); + + verbprintf(vmisc, "Found range 0x%llx-0x%llx for tgid %u, pc %llx.\n", + entry->start, entry->end, (unsigned int)entry->tgid, + trans->pc); + return entry; +} + + +void anon_init(void) +{ + size_t i; + + for (i = 0; i < HASH_SIZE; ++i) + list_init(&hashes[i]); + + list_init(&lru); +} diff --git a/daemon/opd_anon.h b/daemon/opd_anon.h new file mode 100644 index 0000000..63a7723 --- /dev/null +++ b/daemon/opd_anon.h @@ -0,0 +1,50 @@ +/** + * @file opd_anon.h + * Anonymous region handling. + * + * @remark Copyright 2005 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#ifndef OPD_ANON_H +#define OPD_ANON_H + +#include "op_types.h" +#include "op_list.h" + +#include "opd_cookie.h" + +#include + +struct transient; + +/** + * Shift useful bits into play for VMA hashing. + */ +#define VMA_SHIFT 13 + +struct anon_mapping { + /** start of the mapping */ + vma_t start; + /** end of the mapping */ + vma_t end; + /** tgid of the app */ + pid_t tgid; + /** cookie of the app */ + cookie_t app_cookie; + /** hash list */ + struct list_head list; + /** lru list */ + struct list_head lru_list; +}; + +/** + * Try to find an anonymous mapping for the given pc/tgid pair. + */ +struct anon_mapping * find_anon_mapping(struct transient *); + +void anon_init(void); + +#endif /* OPD_ANON_H */ diff --git a/daemon/opd_cookie.c b/daemon/opd_cookie.c new file mode 100644 index 0000000..48e1e80 --- /dev/null +++ b/daemon/opd_cookie.c @@ -0,0 +1,197 @@ +/** + * @file opd_cookie.c + * cookie -> name cache + * + * @remark Copyright 2002, 2005 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#include "opd_cookie.h" +#include "oprofiled.h" +#include "op_list.h" +#include "op_libiberty.h" + +#include +#include +#include +#include +#include +#include + +#ifndef __NR_lookup_dcookie +#if defined(__i386__) +#define __NR_lookup_dcookie 253 +#elif defined(__x86_64__) +#define __NR_lookup_dcookie 212 +#elif defined(__powerpc__) +#define __NR_lookup_dcookie 235 +#elif defined(__alpha__) +#define __NR_lookup_dcookie 406 +#elif defined(__hppa__) +#define __NR_lookup_dcookie 223 +#elif defined(__ia64__) +#define __NR_lookup_dcookie 1237 +#elif defined(__sparc__) +/* untested */ +#define __NR_lookup_dcookie 208 +#elif defined(__s390__) || defined (__s390x__) +#define __NR_lookup_dcookie 110 +#elif defined(__arm__) +#define __NR_lookup_dcookie (__NR_SYSCALL_BASE+249) +#elif defined(__mips__) +#include +/* O32 */ +#if _MIPS_SIM == _MIPS_SIM_ABI32 +#define __NR_lookup_dcookie 4247 +/* N64 */ +#elif _MIPS_SIM == _MIPS_SIM_ABI64 +#define __NR_lookup_dcookie 5206 +/* N32 */ +#elif _MIPS_SIM == _MIPS_SIM_NABI32 +#define __NR_lookup_dcookie 6206 +#else +#error Unknown MIPS ABI: Dunno __NR_lookup_dcookie +#endif +#else +#error Please define __NR_lookup_dcookie for your architecture +#endif +#endif /* __NR_lookup_dcookie */ + +#if (defined(__powerpc__) && !defined(__powerpc64__)) || defined(__hppa__)\ + || (defined(__s390__) && !defined(__s390x__)) +static inline int lookup_dcookie(cookie_t cookie, char * buf, size_t size) +{ + return syscall(__NR_lookup_dcookie, (unsigned long)(cookie >> 32), + (unsigned long)(cookie & 0xffffffff), buf, size); +} +#else +static inline int lookup_dcookie(cookie_t cookie, char * buf, size_t size) +{ + return syscall(__NR_lookup_dcookie, cookie, buf, size); +} +#endif + + +struct cookie_entry { + cookie_t value; + char * name; + int ignored; + struct list_head list; +}; + + +#define HASH_SIZE 512 +#define HASH_BITS (HASH_SIZE - 1) + +static struct list_head hashes[HASH_SIZE]; + +static struct cookie_entry * create_cookie(cookie_t cookie) +{ + int err; + struct cookie_entry * entry = xmalloc(sizeof(struct cookie_entry)); + + entry->value = cookie; + entry->name = xmalloc(PATH_MAX + 1); + + err = lookup_dcookie(cookie, entry->name, PATH_MAX); + + if (err < 0) { + fprintf(stderr, "Lookup of cookie %llx failed, errno=%d\n", + cookie, errno); + free(entry->name); + entry->name = NULL; + entry->ignored = 0; + } else { + entry->ignored = is_image_ignored(entry->name); + } + + return entry; +} + + +/* Cookie monster want cookie! */ +static unsigned long hash_cookie(cookie_t cookie) +{ + return (cookie >> DCOOKIE_SHIFT) & (HASH_SIZE - 1); +} + + +char const * find_cookie(cookie_t cookie) +{ + unsigned long hash = hash_cookie(cookie); + struct list_head * pos; + struct cookie_entry * entry; + + if (cookie == INVALID_COOKIE || cookie == NO_COOKIE) + return NULL; + + list_for_each(pos, &hashes[hash]) { + entry = list_entry(pos, struct cookie_entry, list); + if (entry->value == cookie) + goto out; + } + + /* not sure this can ever happen due to is_cookie_ignored */ + entry = create_cookie(cookie); + list_add(&entry->list, &hashes[hash]); +out: + return entry->name; +} + + +int is_cookie_ignored(cookie_t cookie) +{ + unsigned long hash = hash_cookie(cookie); + struct list_head * pos; + struct cookie_entry * entry; + + if (cookie == INVALID_COOKIE || cookie == NO_COOKIE) + return 1; + + list_for_each(pos, &hashes[hash]) { + entry = list_entry(pos, struct cookie_entry, list); + if (entry->value == cookie) + goto out; + } + + entry = create_cookie(cookie); + list_add(&entry->list, &hashes[hash]); +out: + return entry->ignored; +} + + +char const * verbose_cookie(cookie_t cookie) +{ + unsigned long hash = hash_cookie(cookie); + struct list_head * pos; + struct cookie_entry * entry; + + if (cookie == INVALID_COOKIE) + return "invalid"; + + if (cookie == NO_COOKIE) + return "anonymous"; + + list_for_each(pos, &hashes[hash]) { + entry = list_entry(pos, struct cookie_entry, list); + if (entry->value == cookie) { + if (!entry->name) + return "failed lookup"; + return entry->name; + } + } + + return "not hashed"; +} + + +void cookie_init(void) +{ + size_t i; + + for (i = 0; i < HASH_SIZE; ++i) + list_init(&hashes[i]); +} diff --git a/daemon/opd_cookie.h b/daemon/opd_cookie.h new file mode 100644 index 0000000..a9f13b1 --- /dev/null +++ b/daemon/opd_cookie.h @@ -0,0 +1,39 @@ +/** + * @file opd_cookie.h + * cookie -> name cache + * + * @remark Copyright 2002, 2005 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#ifndef OPD_COOKIE_H +#define OPD_COOKIE_H + +typedef unsigned long long cookie_t; + +#define INVALID_COOKIE ~0LLU +#define NO_COOKIE 0LLU + +/** + * Shift value to remove trailing zero on a dcookie value, 7 is sufficient + * for most architecture + */ +#define DCOOKIE_SHIFT 7 + +/** + * Return the name of the given dcookie. May return + * NULL on failure. + */ +char const * find_cookie(cookie_t cookie); + +/** return true if this cookie should be ignored */ +int is_cookie_ignored(cookie_t cookie); + +/** give a textual description of the cookie */ +char const * verbose_cookie(cookie_t cookie); + +void cookie_init(void); + +#endif /* OPD_COOKIE_H */ diff --git a/daemon/opd_events.c b/daemon/opd_events.c new file mode 100644 index 0000000..f9346df --- /dev/null +++ b/daemon/opd_events.c @@ -0,0 +1,162 @@ +/** + * @file daemon/opd_events.c + * Event details for each counter + * + * @remark Copyright 2002, 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "config.h" + +#include "opd_events.h" +#include "opd_printf.h" +#include "oprofiled.h" + +#include "op_string.h" +#include "op_config.h" +#include "op_cpufreq.h" +#include "op_cpu_type.h" +#include "op_libiberty.h" +#include "op_hw_config.h" +#include "op_sample_file.h" + +#include +#include + +extern op_cpu cpu_type; + +struct opd_event opd_events[OP_MAX_COUNTERS]; + +static double cpu_speed; + +static void malformed_events(void) +{ + fprintf(stderr, "oprofiled: malformed events passed " + "on the command line\n"); + exit(EXIT_FAILURE); +} + + +static char * copy_token(char ** c, char delim) +{ + char * tmp = *c; + char * tmp2 = *c; + char * str; + + if (!**c) + return NULL; + + while (*tmp2 && *tmp2 != delim) + ++tmp2; + + if (tmp2 == tmp) + return NULL; + + str = op_xstrndup(tmp, tmp2 - tmp); + *c = tmp2; + if (**c) + ++*c; + return str; +} + + +static unsigned long copy_ulong(char ** c, char delim) +{ + unsigned long val = 0; + char * str = copy_token(c, delim); + if (!str) + malformed_events(); + val = strtoul(str, NULL, 0); + free(str); + return val; +} + + +void opd_parse_events(char const * events) +{ + char * ev = xstrdup(events); + char * c; + size_t cur = 0; + + if (cpu_type == CPU_TIMER_INT) { + struct opd_event * event = &opd_events[0]; + event->name = xstrdup("TIMER"); + event->value = event->counter + = event->count = event->um = 0; + event->kernel = 1; + event->user = 1; + return; + } + + if (!ev || !strlen(ev)) { + fprintf(stderr, "oprofiled: no events passed.\n"); + exit(EXIT_FAILURE); + } + + verbprintf(vmisc, "Events: %s\n", ev); + + c = ev; + + while (*c && cur < op_nr_counters) { + struct opd_event * event = &opd_events[cur]; + + if (!(event->name = copy_token(&c, ':'))) + malformed_events(); + event->value = copy_ulong(&c, ':'); + event->counter = copy_ulong(&c, ':'); + event->count = copy_ulong(&c, ':'); + event->um = copy_ulong(&c, ':'); + event->kernel = copy_ulong(&c, ':'); + event->user = copy_ulong(&c, ','); + ++cur; + } + + if (*c) { + fprintf(stderr, "oprofiled: too many events passed.\n"); + exit(EXIT_FAILURE); + } + + free(ev); + + cpu_speed = op_cpu_frequency(); +} + + +struct opd_event * find_counter_event(unsigned long counter) +{ + size_t i; + + for (i = 0; i < op_nr_counters && opd_events[i].name; ++i) { + if (counter == opd_events[i].counter) + return &opd_events[i]; + } + + fprintf(stderr, "Unknown event for counter %lu\n", counter); + abort(); + return NULL; +} + + +void fill_header(struct opd_header * header, unsigned long counter, + vma_t anon_start, vma_t cg_to_anon_start, + int is_kernel, int cg_to_is_kernel, time_t mtime) +{ + struct opd_event * event = find_counter_event(counter); + + memset(header, '\0', sizeof(struct opd_header)); + header->version = OPD_VERSION; + memcpy(header->magic, OPD_MAGIC, sizeof(header->magic)); + header->cpu_type = cpu_type; + header->ctr_event = event->value; + header->ctr_count = event->count; + header->ctr_um = event->um; + header->is_kernel = is_kernel; + header->cg_to_is_kernel = cg_to_is_kernel; + header->cpu_speed = cpu_speed; + header->mtime = mtime; + header->anon_start = anon_start; + header->cg_to_anon_start = cg_to_anon_start; +} diff --git a/daemon/opd_events.h b/daemon/opd_events.h new file mode 100644 index 0000000..5b86836 --- /dev/null +++ b/daemon/opd_events.h @@ -0,0 +1,45 @@ +/** + * @file daemon/opd_events.h + * Event details for each counter + * + * @remark Copyright 2002, 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_EVENTS_H + +#include "op_types.h" + +#include + +/** event description for setup (perfmon) and mangling */ +struct opd_event { + char * name; + unsigned long value; + unsigned long counter; + unsigned long count; + unsigned long um; + unsigned long kernel; + unsigned long user; +}; + +/* needed for opd_perfmon.c */ +extern struct opd_event opd_events[]; + +/** parse the events into the opd_events array */ +void opd_parse_events(char const * events); + +/** Find the event for the given counter */ +struct opd_event * find_counter_event(unsigned long counter); + +struct opd_header; + +/** fill the sample file header with event info etc. */ +void fill_header(struct opd_header * header, unsigned long counter, + vma_t anon_start, vma_t anon_end, + int is_kernel, int cg_to_is_kernel, time_t mtime); + +#endif /* OPD_EVENTS_H */ diff --git a/daemon/opd_interface.h b/daemon/opd_interface.h new file mode 100644 index 0000000..8abb2c4 --- /dev/null +++ b/daemon/opd_interface.h @@ -0,0 +1,26 @@ +/** + * @file opd_interface.h + * + * Module / user space interface for 2.6 kernels and above + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_INTERFACE_H +#define OPD_INTERFACE_H + +#define CTX_SWITCH_CODE 1 +#define CPU_SWITCH_CODE 2 +#define COOKIE_SWITCH_CODE 3 +#define KERNEL_ENTER_SWITCH_CODE 4 +#define KERNEL_EXIT_SWITCH_CODE 5 +#define MODULE_LOADED_CODE 6 +#define CTX_TGID_CODE 7 +#define TRACE_BEGIN_CODE 8 +#define LAST_CODE 9 + +#endif /* OPD_INTERFACE_H */ diff --git a/daemon/opd_kernel.c b/daemon/opd_kernel.c new file mode 100644 index 0000000..a2e3fdd --- /dev/null +++ b/daemon/opd_kernel.c @@ -0,0 +1,196 @@ +/** + * @file daemon/opd_kernel.c + * Dealing with the kernel and kernel module samples + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "opd_kernel.h" +#include "opd_sfile.h" +#include "opd_trans.h" +#include "opd_printf.h" +#include "opd_stats.h" +#include "oprofiled.h" + +#include "op_fileio.h" +#include "op_config.h" +#include "op_libiberty.h" + +#include +#include +#include +#include + +static LIST_HEAD(modules); + +static struct kernel_image vmlinux_image; + +void opd_create_vmlinux(char const * name, char const * arg) +{ + /* vmlinux is *not* on the list of modules */ + list_init(&vmlinux_image.list); + + /* for no vmlinux */ + if (no_vmlinux) { + vmlinux_image.name = "no-vmlinux"; + return; + } + + vmlinux_image.name = xstrdup(name); + + sscanf(arg, "%llx,%llx", &vmlinux_image.start, &vmlinux_image.end); + + verbprintf(vmisc, "kernel_start = %llx, kernel_end = %llx\n", + vmlinux_image.start, vmlinux_image.end); + + if (!vmlinux_image.start && !vmlinux_image.end) { + fprintf(stderr, "error: mis-parsed kernel range: %llx-%llx\n", + vmlinux_image.start, vmlinux_image.end); + exit(EXIT_FAILURE); + } +} + + +/** + * Allocate and initialise a kernel image description + * @param name image name + * @param start start address + * @param end end address + */ +static struct kernel_image * +opd_create_module(char const * name, vma_t start, vma_t end) +{ + struct kernel_image * image = xmalloc(sizeof(struct kernel_image)); + + image->name = xstrdup(name); + image->start = start; + image->end = end; + list_add(&image->list, &modules); + + return image; +} + + +/** + * Clear and free all kernel image information and reset + * values. + */ +static void opd_clear_modules(void) +{ + struct list_head * pos; + struct list_head * pos2; + struct kernel_image * image; + + list_for_each_safe(pos, pos2, &modules) { + image = list_entry(pos, struct kernel_image, list); + if (image->name) + free(image->name); + free(image); + } + + list_init(&modules); + + /* clear out lingering references */ + sfile_clear_kernel(); +} + + +/* + * each line is in the format: + * + * module_name 16480 1 dependencies Live 0xe091e000 + * + * without any blank space in each field + */ +void opd_reread_module_info(void) +{ + FILE * fp; + char * line; + struct kernel_image * image; + int module_size; + char ref_count[32]; + int ret; + char module_name[256+1]; + char live_info[32]; + char dependencies[4096]; + unsigned long long start_address; + + if (no_vmlinux) + return; + + opd_clear_modules(); + + printf("Reading module info.\n"); + + fp = op_try_open_file("/proc/modules", "r"); + + if (!fp) { + printf("oprofiled: /proc/modules not readable, " + "can't process module samples.\n"); + return; + } + + while (1) { + line = op_get_line(fp); + + if (!line) + break; + + if (line[0] == '\0') { + free(line); + continue; + } + + ret = sscanf(line, "%256s %u %32s %4096s %32s %llx", + module_name, &module_size, ref_count, + dependencies, live_info, &start_address); + if (ret != 6) { + printf("bad /proc/modules entry: %s\n", line); + free(line); + continue; + } + + image = opd_create_module(module_name, start_address, + start_address + module_size); + + verbprintf(vmodule, "module %s start %llx end %llx\n", + image->name, image->start, image->end); + + free(line); + } + + op_close_file(fp); +} + + +/** + * find a kernel image by PC value + * @param trans holds PC value to look up + * + * find the kernel image which contains this PC. + * + * Return %NULL if not found. + */ +struct kernel_image * find_kernel_image(struct transient const * trans) +{ + struct list_head * pos; + struct kernel_image * image = &vmlinux_image; + + if (no_vmlinux) + return image; + + if (image->start <= trans->pc && image->end > trans->pc) + return image; + + list_for_each(pos, &modules) { + image = list_entry(pos, struct kernel_image, list); + if (image->start <= trans->pc && image->end > trans->pc) + return image; + } + + return NULL; +} diff --git a/daemon/opd_kernel.h b/daemon/opd_kernel.h new file mode 100644 index 0000000..7c035ee --- /dev/null +++ b/daemon/opd_kernel.h @@ -0,0 +1,38 @@ +/** + * @file daemon/opd_kernel.h + * Dealing with the kernel and kernel module images + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_KERNEL_H +#define OPD_KERNEL_H + +#include "op_types.h" +#include "op_list.h" + +struct transient; + +/** create the kernel image */ +void opd_create_vmlinux(char const * name, char const * arg); + +/** opd_reread_module_info - parse /proc/modules for kernel modules */ +void opd_reread_module_info(void); + +/** Describes a kernel module or vmlinux itself */ +struct kernel_image { + char * name; + vma_t start; + vma_t end; + struct list_head list; +}; + +/** Find a kernel_image based upon the given parameters in trans. */ +struct kernel_image * +find_kernel_image(struct transient const * trans); + +#endif /* OPD_KERNEL_H */ diff --git a/daemon/opd_mangling.c b/daemon/opd_mangling.c new file mode 100644 index 0000000..a22f98c --- /dev/null +++ b/daemon/opd_mangling.c @@ -0,0 +1,196 @@ +/** + * @file daemon/opd_mangling.c + * Mangling and opening of sample files + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include "opd_mangling.h" +#include "opd_kernel.h" +#include "opd_cookie.h" +#include "opd_sfile.h" +#include "opd_anon.h" +#include "opd_printf.h" +#include "opd_events.h" +#include "oprofiled.h" + +#include "op_file.h" +#include "op_sample_file.h" +#include "op_config.h" +#include "op_mangle.h" +#include "op_events.h" +#include "op_libiberty.h" + +#include +#include +#include +#include +#include + + +static char const * get_dep_name(struct sfile const * sf) +{ + if (sf->anon) + return find_cookie(sf->app_cookie); + + /* avoid to call find_cookie(), caller can recover using image_name */ + if (sf->cookie == sf->app_cookie) + return NULL; + + if (!separate_kernel && !(separate_lib && !sf->kernel)) + return NULL; + + /* this will fail if e.g. kernel thread */ + if (sf->app_cookie == 0) + return NULL; + + return find_cookie(sf->app_cookie); +} + + +static char * mangle_anon(struct anon_mapping const * anon) +{ + char * name = xmalloc(PATH_MAX); + snprintf(name, 1024, "%u.0x%llx.0x%llx", (unsigned int)anon->tgid, + anon->start, anon->end); + return name; +} + + +static char * +mangle_filename(struct sfile * last, struct sfile const * sf, int counter, int cg) +{ + char * mangled; + struct mangle_values values; + struct opd_event * event = find_counter_event(counter); + + values.flags = 0; + + if (sf->kernel) { + values.image_name = sf->kernel->name; + values.flags |= MANGLE_KERNEL; + } else if (sf->anon) { + values.flags |= MANGLE_ANON; + values.image_name = mangle_anon(sf->anon); + } else { + values.image_name = find_cookie(sf->cookie); + } + + values.dep_name = get_dep_name(sf); + if (!values.dep_name) + values.dep_name = values.image_name; + + /* FIXME: log */ + if (!values.image_name || !values.dep_name) + return NULL; + + if (separate_thread) { + values.flags |= MANGLE_TGID | MANGLE_TID; + values.tid = sf->tid; + values.tgid = sf->tgid; + } + + if (separate_cpu) { + values.flags |= MANGLE_CPU; + values.cpu = sf->cpu; + } + + if (cg) { + values.flags |= MANGLE_CALLGRAPH; + if (last->kernel) { + values.cg_image_name = last->kernel->name; + } else if (last->anon) { + values.flags |= MANGLE_CG_ANON; + values.cg_image_name = mangle_anon(last->anon); + } else { + values.cg_image_name = find_cookie(last->cookie); + } + + /* FIXME: log */ + if (!values.cg_image_name) { + if (values.flags & MANGLE_ANON) + free((char *)values.image_name); + return NULL; + } + } + + values.event_name = event->name; + values.count = event->count; + values.unit_mask = event->um; + + mangled = op_mangle_filename(&values); + + if (values.flags & MANGLE_ANON) + free((char *)values.image_name); + if (values.flags & MANGLE_CG_ANON) + free((char *)values.cg_image_name); + return mangled; +} + + +int opd_open_sample_file(odb_t * file, struct sfile * last, + struct sfile * sf, int counter, int cg) +{ + char * mangled; + char const * binary; + vma_t last_start = 0; + int err; + + mangled = mangle_filename(last, sf, counter, cg); + + if (!mangled) + return EINVAL; + + verbprintf(vsfile, "Opening \"%s\"\n", mangled); + + create_path(mangled); + + /* locking sf will lock associated cg files too */ + sfile_get(sf); + if (sf != last) + sfile_get(last); + +retry: + err = odb_open(file, mangled, ODB_RDWR, sizeof(struct opd_header)); + + /* This can naturally happen when racing against opcontrol --reset. */ + if (err) { + if (err == EMFILE) { + if (sfile_lru_clear()) { + printf("LRU cleared but odb_open() fails for %s.\n", mangled); + abort(); + } + goto retry; + } + + fprintf(stderr, "oprofiled: open of %s failed: %s\n", + mangled, strerror(err)); + goto out; + } + + if (!sf->kernel) + binary = find_cookie(sf->cookie); + else + binary = sf->kernel->name; + + if (last && last->anon) + last_start = last->anon->start; + + fill_header(odb_get_data(file), counter, + sf->anon ? sf->anon->start : 0, last_start, + !!sf->kernel, last ? !!last->kernel : 0, + binary ? op_get_mtime(binary) : 0); + +out: + sfile_put(sf); + if (sf != last) + sfile_put(last); + free(mangled); + return err; +} diff --git a/daemon/opd_mangling.h b/daemon/opd_mangling.h new file mode 100644 index 0000000..0e46ec4 --- /dev/null +++ b/daemon/opd_mangling.h @@ -0,0 +1,33 @@ +/** + * @file daemon/opd_mangling.h + * Mangling and opening of sample files + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_MANGLING_H +#define OPD_MANGLING_H + +#include "odb.h" + +struct sfile; + +/* + * opd_open_sample_file - open a sample file + * @param sf sfile to open sample file for + * @param counter counter number + * @param cg if this is a callgraph file + * + * Open image sample file for the sfile, counter + * counter and set up memory mappings for it. + * + * Returns 0 on success. + */ +int opd_open_sample_file(odb_t * file, struct sfile * last, + struct sfile * sf, int counter, int cg); + +#endif /* OPD_MANGLING_H */ diff --git a/daemon/opd_perfmon.c b/daemon/opd_perfmon.c new file mode 100644 index 0000000..d95030d --- /dev/null +++ b/daemon/opd_perfmon.c @@ -0,0 +1,464 @@ +/** + * @file opd_perfmon.c + * perfmonctl() handling + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#ifdef __ia64__ + +/* need this for sched_setaffinity() in */ +#define _GNU_SOURCE + +#include "oprofiled.h" +#include "opd_perfmon.h" +#include "opd_events.h" + +#include "op_cpu_type.h" +#include "op_libiberty.h" +#include "op_hw_config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_SCHED_SETAFFINITY +#include +#endif + +extern op_cpu cpu_type; + +#ifndef HAVE_SCHED_SETAFFINITY + +/* many glibc's are not yet up to date */ +#ifndef __NR_sched_setaffinity +#define __NR_sched_setaffinity 1231 +#endif + +/* Copied from glibc's and and munged */ +#define CPU_SETSIZE 1024 +#define __NCPUBITS (8 * sizeof (unsigned long)) +typedef struct +{ + unsigned long __bits[CPU_SETSIZE / __NCPUBITS]; +} cpu_set_t; + +#define CPU_SET(cpu, cpusetp) \ + ((cpusetp)->__bits[(cpu)/__NCPUBITS] |= (1UL << ((cpu) % __NCPUBITS))) +#define CPU_ZERO(cpusetp) \ + memset((cpusetp), 0, sizeof(cpu_set_t)) + +static int +sched_setaffinity(pid_t pid, size_t len, cpu_set_t const * cpusetp) +{ + return syscall(__NR_sched_setaffinity, pid, len, cpusetp); +} +#endif + + +#ifndef HAVE_PERFMONCTL +#ifndef __NR_perfmonctl +#define __NR_perfmonctl 1175 +#endif + +static int perfmonctl(int fd, int cmd, void * arg, int narg) +{ + return syscall(__NR_perfmonctl, fd, cmd, arg, narg); +} +#endif + + +static unsigned char uuid[16] = { + 0x77, 0x7a, 0x6e, 0x61, 0x20, 0x65, 0x73, 0x69, + 0x74, 0x6e, 0x72, 0x20, 0x61, 0x65, 0x0a, 0x6c +}; + + +static size_t nr_cpus; + +struct child { + pid_t pid; + int up_pipe[2]; + int ctx_fd; + sig_atomic_t sigusr1; + sig_atomic_t sigusr2; + sig_atomic_t sigterm; +}; + +static struct child * children; + +static void perfmon_start_child(int ctx_fd) +{ + if (perfmonctl(ctx_fd, PFM_START, 0, 0) == -1) { + perror("Couldn't start perfmon: "); + exit(EXIT_FAILURE); + } +} + + +static void perfmon_stop_child(int ctx_fd) +{ + if (perfmonctl(ctx_fd, PFM_STOP, 0, 0) == -1) { + perror("Couldn't stop perfmon: "); + exit(EXIT_FAILURE); + } +} + + +static void child_sigusr1(int val __attribute__((unused))) +{ + size_t i; + + for (i = 0; i < nr_cpus; ++i) { + if (children[i].pid == getpid()) { + children[i].sigusr1 = 1; + return; + } + } +} + + +static void child_sigusr2(int val __attribute__((unused))) +{ + size_t i; + + for (i = 0; i < nr_cpus; ++i) { + if (children[i].pid == getpid()) { + children[i].sigusr2 = 1; + return; + } + } +} + + +static void child_sigterm(int val __attribute__((unused))) +{ + printf("Child received SIGTERM, killing parent.\n"); + kill(getppid(), SIGTERM); +} + + +static void set_affinity(size_t cpu) +{ + cpu_set_t set; + + CPU_ZERO(&set); + CPU_SET(cpu, &set); + + int err = sched_setaffinity(getpid(), sizeof(set), &set); + + if (err == -1) { + fprintf(stderr, "Failed to set affinity: %s\n", + strerror(errno)); + exit(EXIT_FAILURE); + } +} + + +static void setup_signals(void) +{ + struct sigaction act; + sigset_t mask; + + sigemptyset(&mask); + sigaddset(&mask, SIGUSR1); + sigaddset(&mask, SIGUSR2); + sigprocmask(SIG_BLOCK, &mask, NULL); + + act.sa_handler = child_sigusr1; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + + if (sigaction(SIGUSR1, &act, NULL)) { + perror("oprofiled: install of SIGUSR1 handler failed: "); + exit(EXIT_FAILURE); + } + + act.sa_handler = child_sigusr2; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + + if (sigaction(SIGUSR2, &act, NULL)) { + perror("oprofiled: install of SIGUSR2 handler failed: "); + exit(EXIT_FAILURE); + } + + act.sa_handler = child_sigterm; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + + if (sigaction(SIGTERM, &act, NULL)) { + perror("oprofiled: install of SIGTERM handler failed: "); + exit(EXIT_FAILURE); + } +} + + +/** create the per-cpu context */ +static void create_context(struct child * self) +{ + pfarg_context_t ctx; + int err; + + memset(&ctx, 0, sizeof(pfarg_context_t)); + memcpy(&ctx.ctx_smpl_buf_id, &uuid, 16); + ctx.ctx_flags = PFM_FL_SYSTEM_WIDE; + + err = perfmonctl(0, PFM_CREATE_CONTEXT, &ctx, 1); + if (err == -1) { + fprintf(stderr, "CREATE_CONTEXT failed: %s\n", + strerror(errno)); + exit(EXIT_FAILURE); + } + + self->ctx_fd = ctx.ctx_fd; +} + + +/** program the perfmon counters */ +static void write_pmu(struct child * self) +{ + pfarg_reg_t pc[OP_MAX_COUNTERS]; + pfarg_reg_t pd[OP_MAX_COUNTERS]; + int err; + size_t i; + + memset(pc, 0, sizeof(pc)); + memset(pd, 0, sizeof(pd)); + +#define PMC_GEN_INTERRUPT (1UL << 5) +#define PMC_PRIV_MONITOR (1UL << 6) +/* McKinley requires pmc4 to have bit 23 set (enable PMU). + * It is supposedly ignored in other pmc registers. + */ +#define PMC_MANDATORY (1UL << 23) +#define PMC_USER (1UL << 3) +#define PMC_KERNEL (1UL << 0) + for (i = 0; i < op_nr_counters && opd_events[i].name; ++i) { + struct opd_event * event = &opd_events[i]; + pc[i].reg_num = event->counter + 4; + pc[i].reg_value = PMC_GEN_INTERRUPT; + pc[i].reg_value |= PMC_PRIV_MONITOR; + pc[i].reg_value |= PMC_MANDATORY; + (event->user) ? (pc[i].reg_value |= PMC_USER) + : (pc[i].reg_value &= ~PMC_USER); + (event->kernel) ? (pc[i].reg_value |= PMC_KERNEL) + : (pc[i].reg_value &= ~PMC_KERNEL); + pc[i].reg_value &= ~(0xff << 8); + pc[i].reg_value |= ((event->value & 0xff) << 8); + pc[i].reg_value &= ~(0xf << 16); + pc[i].reg_value |= ((event->um & 0xf) << 16); + pc[i].reg_smpl_eventid = event->counter; + } + + for (i = 0; i < op_nr_counters && opd_events[i].name; ++i) { + struct opd_event * event = &opd_events[i]; + pd[i].reg_value = ~0UL - event->count + 1; + pd[i].reg_short_reset = ~0UL - event->count + 1; + pd[i].reg_num = event->counter + 4; + } + + err = perfmonctl(self->ctx_fd, PFM_WRITE_PMCS, pc, i); + if (err == -1) { + perror("Couldn't write PMCs: "); + exit(EXIT_FAILURE); + } + + err = perfmonctl(self->ctx_fd, PFM_WRITE_PMDS, pd, i); + if (err == -1) { + perror("Couldn't write PMDs: "); + exit(EXIT_FAILURE); + } +} + + +static void load_context(struct child * self) +{ + pfarg_load_t load_args; + int err; + + memset(&load_args, 0, sizeof(load_args)); + load_args.load_pid = self->pid; + + err = perfmonctl(self->ctx_fd, PFM_LOAD_CONTEXT, &load_args, 1); + if (err == -1) { + perror("Couldn't load context: "); + exit(EXIT_FAILURE); + } +} + + +static void notify_parent(struct child * self, size_t cpu) +{ + for (;;) { + ssize_t ret; + ret = write(self->up_pipe[1], &cpu, sizeof(size_t)); + if (ret == sizeof(size_t)) + break; + if (ret < 0 && errno != EINTR) { + fprintf(stderr, "Failed to write child pipe with %s\n", + strerror(errno)); + exit(EXIT_FAILURE); + } + } +} + + +static void run_child(size_t cpu) +{ + struct child * self = &children[cpu]; + + self->pid = getpid(); + self->sigusr1 = 0; + self->sigusr2 = 0; + self->sigterm = 0; + + setup_signals(); + + set_affinity(cpu); + + create_context(self); + + write_pmu(self); + + load_context(self); + + notify_parent(self, cpu); + + for (;;) { + sigset_t sigmask; + sigfillset(&sigmask); + sigdelset(&sigmask, SIGUSR1); + sigdelset(&sigmask, SIGUSR2); + sigdelset(&sigmask, SIGTERM); + + if (self->sigusr1) { + printf("PFM_START on CPU%d\n", (int)cpu); + fflush(stdout); + perfmon_start_child(self->ctx_fd); + self->sigusr1 = 0; + } + + if (self->sigusr2) { + printf("PFM_STOP on CPU%d\n", (int)cpu); + fflush(stdout); + perfmon_stop_child(self->ctx_fd); + self->sigusr2 = 0; + } + + sigsuspend(&sigmask); + } +} + + +static void wait_for_child(struct child * child) +{ + size_t tmp; + for (;;) { + ssize_t ret; + ret = read(child->up_pipe[0], &tmp, sizeof(size_t)); + if (ret == sizeof(size_t)) + break; + if (ret < 0 && errno != EINTR) { + fprintf(stderr, "Failed to read child pipe with %s\n", + strerror(errno)); + exit(EXIT_FAILURE); + } + } + printf("Perfmon child up on CPU%d\n", (int)tmp); + fflush(stdout); + + close(child->up_pipe[0]); + close(child->up_pipe[1]); +} + + +void perfmon_init(void) +{ + size_t i; + long nr; + + if (cpu_type == CPU_TIMER_INT) + return; + + nr = sysconf(_SC_NPROCESSORS_ONLN); + if (nr == -1) { + fprintf(stderr, "Couldn't determine number of CPUs.\n"); + exit(EXIT_FAILURE); + } + + nr_cpus = nr; + + children = xmalloc(sizeof(struct child) * nr_cpus); + + for (i = 0; i < nr_cpus; ++i) { + int ret; + + if (pipe(children[i].up_pipe)) { + perror("Couldn't create child pipe.\n"); + exit(EXIT_FAILURE); + } + + ret = fork(); + if (ret == -1) { + fprintf(stderr, "Couldn't fork perfmon child.\n"); + exit(EXIT_FAILURE); + } else if (ret == 0) { + printf("Running perfmon child on CPU%d.\n", (int)i); + fflush(stdout); + run_child(i); + } else { + children[i].pid = ret; + printf("Waiting on CPU%d\n", (int)i); + wait_for_child(&children[i]); + } + } +} + + +void perfmon_exit(void) +{ + size_t i; + + if (cpu_type == CPU_TIMER_INT) + return; + + for (i = 0; i < nr_cpus; ++i) { + kill(children[i].pid, SIGKILL); + waitpid(children[i].pid, NULL, 0); + } +} + + +void perfmon_start(void) +{ + size_t i; + + if (cpu_type == CPU_TIMER_INT) + return; + + for (i = 0; i < nr_cpus; ++i) + kill(children[i].pid, SIGUSR1); +} + + +void perfmon_stop(void) +{ + size_t i; + + if (cpu_type == CPU_TIMER_INT) + return; + + for (i = 0; i < nr_cpus; ++i) + kill(children[i].pid, SIGUSR2); +} + +#endif /* __ia64__ */ diff --git a/daemon/opd_perfmon.h b/daemon/opd_perfmon.h new file mode 100644 index 0000000..9b4267f --- /dev/null +++ b/daemon/opd_perfmon.h @@ -0,0 +1,106 @@ +/** + * @file opd_perfmon.h + * perfmonctl() handling + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#ifndef OPD_PERFMON_H +#define OPD_PERFMON_H + +#ifdef __ia64__ + +#include + +void perfmon_init(void); +void perfmon_exit(void); +void perfmon_start(void); +void perfmon_stop(void); + +/* The following is from asm/perfmon.h. When it's installed on + * enough boxes, we can remove this and include the platform + * perfmon.h + */ + +typedef unsigned char pfm_uuid_t[16]; /* custom sampling buffer identifier type */ + +/* + * Request structure used to define a context + */ +typedef struct { + pfm_uuid_t ctx_smpl_buf_id; /* which buffer format to use (if needed) */ + unsigned long ctx_flags; /* noblock/block */ + unsigned short ctx_nextra_sets; /* number of extra event sets (you always get 1) */ + unsigned short ctx_reserved1; /* for future use */ + int ctx_fd; /* return arg: unique identification for context */ + void *ctx_smpl_vaddr; /* return arg: virtual address of sampling buffer, is used */ + unsigned long ctx_reserved2[11];/* for future use */ +} pfarg_context_t; + +/* + * Request structure used to write/read a PMC or PMD + */ +typedef struct { + unsigned int reg_num; /* which register */ + unsigned short reg_set; /* event set for this register */ + unsigned short reg_reserved1; /* for future use */ + + unsigned long reg_value; /* initial pmc/pmd value */ + unsigned long reg_flags; /* input: pmc/pmd flags, return: reg error */ + + unsigned long reg_long_reset; /* reset after buffer overflow notification */ + unsigned long reg_short_reset; /* reset after counter overflow */ + + unsigned long reg_reset_pmds[4]; /* which other counters to reset on overflow */ + unsigned long reg_random_seed; /* seed value when randomization is used */ + unsigned long reg_random_mask; /* bitmask used to limit random value */ + unsigned long reg_last_reset_val;/* return: PMD last reset value */ + + unsigned long reg_smpl_pmds[4]; /* which pmds are accessed when PMC overflows */ + unsigned long reg_smpl_eventid; /* opaque sampling event identifier */ + + unsigned long reg_reserved2[3]; /* for future use */ +} pfarg_reg_t; + +typedef struct { + pid_t load_pid; /* process to load the context into */ + unsigned short load_set; /* first event set to load */ + unsigned short load_reserved1; /* for future use */ + unsigned long load_reserved2[3]; /* for future use */ +} pfarg_load_t; + +#define PFM_WRITE_PMCS 0x01 +#define PFM_WRITE_PMDS 0x02 +#define PFM_STOP 0x04 +#define PFM_START 0x05 +#define PFM_CREATE_CONTEXT 0x08 +#define PFM_LOAD_CONTEXT 0x10 +#define PFM_FL_SYSTEM_WIDE 0x02 + +#else + +void perfmon_init(void) +{ +} + + +void perfmon_exit(void) +{ +} + + +void perfmon_start(void) +{ +} + + +void perfmon_stop(void) +{ +} + +#endif /* __ia64__ */ + +#endif /* OPD_PERFMON_H */ diff --git a/daemon/opd_printf.h b/daemon/opd_printf.h new file mode 100644 index 0000000..e1f8476 --- /dev/null +++ b/daemon/opd_printf.h @@ -0,0 +1,35 @@ +/** + * @file daemon/opd_printf.h + * Output routines + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_PRINTF_H +#define OPD_PRINTF_H + +/// log all sample file name manipulation; sample files open, close, +/// sfile LRU etc. voluminous. FIXME need to be splitted (filename manip, files +/// handling) ? +extern int vsfile; +/// log samples, voluminous. +extern int vsamples; +/// log arc, very voluminous. +extern int varcs; +/// kernel module handling +extern int vmodule; +/// all others not fitting in above category, not voluminous. +extern int vmisc; + +#define verbprintf(x, args...) \ + do { \ + /* look like fragile but we must catch verbrintf("%s", "") */ \ + if (x == 1) \ + printf(args); \ + } while (0) + +#endif /* OPD_PRINTF_H */ diff --git a/daemon/opd_sfile.c b/daemon/opd_sfile.c new file mode 100644 index 0000000..58fdccd --- /dev/null +++ b/daemon/opd_sfile.c @@ -0,0 +1,608 @@ +/** + * @file daemon/opd_sfile.c + * Management of sample files + * + * @remark Copyright 2002, 2005 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "opd_sfile.h" + +#include "opd_trans.h" +#include "opd_kernel.h" +#include "opd_mangling.h" +#include "opd_anon.h" +#include "opd_printf.h" +#include "opd_stats.h" +#include "oprofiled.h" + +#include "op_libiberty.h" + +#include +#include +#include + +#define HASH_SIZE 2048 +#define HASH_BITS (HASH_SIZE - 1) + +/** All sfiles are hashed into these lists */ +static struct list_head hashes[HASH_SIZE]; + +/** All sfiles are on this list. */ +static LIST_HEAD(lru_list); + + +/* FIXME: can undoubtedly improve this hashing */ +/** Hash the transient parameters for lookup. */ +static unsigned long +sfile_hash(struct transient const * trans, struct kernel_image * ki) +{ + unsigned long val = 0; + + if (separate_thread) { + val ^= trans->tid << 2; + val ^= trans->tgid << 2; + } + + if (separate_kernel || ((trans->anon || separate_lib) && !ki)) + val ^= trans->app_cookie >> (DCOOKIE_SHIFT + 3); + + if (separate_cpu) + val ^= trans->cpu; + + /* cookie meaningless for kernel, shouldn't hash */ + if (trans->in_kernel) { + val ^= ki->start >> 14; + val ^= ki->end >> 7; + return val & HASH_BITS; + } + + if (trans->cookie != NO_COOKIE) { + val ^= trans->cookie >> DCOOKIE_SHIFT; + return val & HASH_BITS; + } + + if (!separate_thread) + val ^= trans->tgid << 2; + + if (trans->anon) { + val ^= trans->anon->start >> VMA_SHIFT; + val ^= trans->anon->end >> (VMA_SHIFT + 1); + } + + return val & HASH_BITS; +} + + +static int +do_match(struct sfile const * sf, cookie_t cookie, cookie_t app_cookie, + struct kernel_image const * ki, struct anon_mapping const * anon, + pid_t tgid, pid_t tid, unsigned int cpu) +{ + /* this is a simplified check for "is a kernel image" AND + * "is the right kernel image". Also handles no-vmlinux + * correctly. + */ + if (sf->kernel != ki) + return 0; + + if (separate_thread) { + if (sf->tid != tid || sf->tgid != tgid) + return 0; + } + + if (separate_cpu) { + if (sf->cpu != cpu) + return 0; + } + + if (separate_kernel || ((anon || separate_lib) && !ki)) { + if (sf->app_cookie != app_cookie) + return 0; + } + + /* ignore the cached trans->cookie for kernel images, + * it's meaningless and we checked all others already + */ + if (ki) + return 1; + + if (sf->anon != anon) + return 0; + + return sf->cookie == cookie; +} + + +static int +trans_match(struct transient const * trans, struct sfile const * sfile, + struct kernel_image const * ki) +{ + return do_match(sfile, trans->cookie, trans->app_cookie, ki, + trans->anon, trans->tgid, trans->tid, trans->cpu); +} + + +static int +sfile_equal(struct sfile const * sf, struct sfile const * sf2) +{ + return do_match(sf, sf2->cookie, sf2->app_cookie, sf2->kernel, + sf2->anon, sf2->tgid, sf2->tid, sf2->cpu); +} + + +static int +is_sf_ignored(struct sfile const * sf) +{ + if (sf->kernel) { + if (!is_image_ignored(sf->kernel->name)) + return 0; + + /* Let a dependent kernel image redeem the sf if we're + * executing on behalf of an application. + */ + return is_cookie_ignored(sf->app_cookie); + } + + /* Anon regions are always dependent on the application. + * Otherwise, let a dependent image redeem the sf. + */ + if (sf->anon || is_cookie_ignored(sf->cookie)) + return is_cookie_ignored(sf->app_cookie); + + return 0; +} + + +/** create a new sfile matching the current transient parameters */ +static struct sfile * +create_sfile(unsigned long hash, struct transient const * trans, + struct kernel_image * ki) +{ + size_t i; + struct sfile * sf; + + sf = xmalloc(sizeof(struct sfile)); + + sf->hashval = hash; + + /* The logic here: if we're in the kernel, the cached cookie is + * meaningless (though not the app_cookie if separate_kernel) + */ + sf->cookie = trans->in_kernel ? INVALID_COOKIE : trans->cookie; + sf->app_cookie = INVALID_COOKIE; + sf->tid = (pid_t)-1; + sf->tgid = (pid_t)-1; + sf->cpu = 0; + sf->kernel = ki; + sf->anon = trans->anon; + + for (i = 0 ; i < op_nr_counters ; ++i) + odb_init(&sf->files[i]); + + for (i = 0; i < CG_HASH_SIZE; ++i) + list_init(&sf->cg_hash[i]); + + if (separate_thread) + sf->tid = trans->tid; + if (separate_thread || trans->cookie == NO_COOKIE) + sf->tgid = trans->tgid; + + if (separate_cpu) + sf->cpu = trans->cpu; + + if (separate_kernel || ((trans->anon || separate_lib) && !ki)) + sf->app_cookie = trans->app_cookie; + + sf->ignored = is_sf_ignored(sf); + + return sf; +} + + +struct sfile * sfile_find(struct transient const * trans) +{ + struct sfile * sf; + struct list_head * pos; + struct kernel_image * ki = NULL; + unsigned long hash; + + if (trans->tracing != TRACING_ON) { + opd_stats[OPD_SAMPLES]++; + opd_stats[trans->in_kernel == 1 ? OPD_KERNEL : OPD_PROCESS]++; + } + + /* There is a small race where this *can* happen, see + * caller of cpu_buffer_reset() in the kernel + */ + if (trans->in_kernel == -1) { + verbprintf(vsamples, "Losing sample at 0x%llx of unknown provenance.\n", + trans->pc); + opd_stats[OPD_NO_CTX]++; + return NULL; + } + + /* we might need a kernel image start/end to hash on */ + if (trans->in_kernel) { + ki = find_kernel_image(trans); + if (!ki) { + verbprintf(vsamples, "Lost kernel sample %llx\n", trans->pc); + opd_stats[OPD_LOST_KERNEL]++; + return NULL; + } + } else if (trans->cookie == NO_COOKIE && !trans->anon) { + if (vsamples) { + char const * app = verbose_cookie(trans->app_cookie); + printf("No anon map for pc %llx, app %s.\n", + trans->pc, app); + } + opd_stats[OPD_LOST_NO_MAPPING]++; + return NULL; + } + + hash = sfile_hash(trans, ki); + list_for_each(pos, &hashes[hash]) { + sf = list_entry(pos, struct sfile, hash); + if (trans_match(trans, sf, ki)) { + sfile_get(sf); + goto lru; + } + } + + sf = create_sfile(hash, trans, ki); + list_add(&sf->hash, &hashes[hash]); + +lru: + sfile_put(sf); + return sf; +} + + +static void sfile_dup(struct sfile * to, struct sfile * from) +{ + size_t i; + + memcpy(to, from, sizeof (struct sfile)); + + for (i = 0 ; i < op_nr_counters ; ++i) + odb_init(&to->files[i]); + + for (i = 0; i < CG_HASH_SIZE; ++i) + list_init(&to->cg_hash[i]); + + list_init(&to->hash); + list_init(&to->lru); +} + + +static odb_t * get_file(struct transient const * trans, int is_cg) +{ + struct sfile * sf = trans->current; + struct sfile * last = trans->last; + struct cg_entry * cg; + struct list_head * pos; + unsigned long hash; + odb_t * file; + + if (trans->event >= op_nr_counters) { + fprintf(stderr, "%s: Invalid counter %lu\n", __FUNCTION__, + trans->event); + abort(); + } + + file = &sf->files[trans->event]; + + if (!is_cg) + goto open; + + hash = last->hashval & (CG_HASH_SIZE - 1); + + /* Need to look for the right 'to'. Since we're looking for + * 'last', we use its hash. + */ + list_for_each(pos, &sf->cg_hash[hash]) { + cg = list_entry(pos, struct cg_entry, hash); + if (sfile_equal(last, &cg->to)) { + file = &cg->to.files[trans->event]; + goto open; + } + } + + cg = xmalloc(sizeof(struct cg_entry)); + sfile_dup(&cg->to, last); + list_add(&cg->hash, &sf->cg_hash[hash]); + file = &cg->to.files[trans->event]; + +open: + if (!odb_open_count(file)) + opd_open_sample_file(file, last, sf, trans->event, is_cg); + + /* Error is logged by opd_open_sample_file */ + if (!odb_open_count(file)) + return NULL; + + return file; +} + + +static void verbose_print_sample(struct sfile * sf, vma_t pc, uint counter) +{ + char const * app = verbose_cookie(sf->app_cookie); + printf("0x%llx(%u): ", pc, counter); + if (sf->anon) { + printf("anon (tgid %u, 0x%llx-0x%llx), ", + (unsigned int)sf->anon->tgid, + sf->anon->start, sf->anon->end); + } else if (sf->kernel) { + printf("kern (name %s, 0x%llx-0x%llx), ", sf->kernel->name, + sf->kernel->start, sf->kernel->end); + } else { + printf("%s(%llx), ", verbose_cookie(sf->cookie), sf->cookie); + } + printf("app %s(%llx)", app, sf->app_cookie); +} + + +static void verbose_sample(struct transient const * trans, vma_t pc) +{ + printf("Sample "); + verbose_print_sample(trans->current, pc, trans->event); + printf("\n"); +} + + +static void +verbose_arc(struct transient const * trans, vma_t from, vma_t to) +{ + printf("Arc "); + verbose_print_sample(trans->current, from, trans->event); + printf(" -> 0x%llx", to); + printf("\n"); +} + + +static void sfile_log_arc(struct transient const * trans) +{ + int err; + vma_t from = trans->pc; + vma_t to = trans->last_pc; + uint64_t key; + odb_t * file; + + file = get_file(trans, 1); + + /* absolute value -> offset */ + if (trans->current->kernel) + from -= trans->current->kernel->start; + + if (trans->last->kernel) + to -= trans->last->kernel->start; + + if (trans->current->anon) + from -= trans->current->anon->start; + + if (trans->last->anon) + to -= trans->last->anon->start; + + if (varcs) + verbose_arc(trans, from, to); + + if (!file) { + opd_stats[OPD_LOST_SAMPLEFILE]++; + return; + } + + /* Possible narrowings to 32-bit value only. */ + key = to & (0xffffffff); + key |= ((uint64_t)from) << 32; + + err = odb_insert(file, key, 1); + if (err) { + fprintf(stderr, "%s: %s\n", __FUNCTION__, strerror(err)); + abort(); + } +} + + +void sfile_log_sample(struct transient const * trans) +{ + int err; + vma_t pc = trans->pc; + odb_t * file; + + if (trans->tracing == TRACING_ON) { + /* can happen if kernel sample falls through the cracks, + * see opd_put_sample() */ + if (trans->last) + sfile_log_arc(trans); + return; + } + + file = get_file(trans, 0); + + /* absolute value -> offset */ + if (trans->current->kernel) + pc -= trans->current->kernel->start; + + if (trans->current->anon) + pc -= trans->current->anon->start; + + if (vsamples) + verbose_sample(trans, pc); + + if (!file) { + opd_stats[OPD_LOST_SAMPLEFILE]++; + return; + } + + err = odb_insert(file, (uint64_t)pc, 1); + if (err) { + fprintf(stderr, "%s: %s\n", __FUNCTION__, strerror(err)); + abort(); + } +} + + +static int close_sfile(struct sfile * sf) +{ + size_t i; + + /* it's OK to close a non-open odb file */ + for (i = 0; i < op_nr_counters; ++i) + odb_close(&sf->files[i]); + + return 0; +} + + +static void kill_sfile(struct sfile * sf) +{ + close_sfile(sf); + list_del(&sf->hash); + list_del(&sf->lru); +} + + +static int sync_sfile(struct sfile * sf) +{ + size_t i; + + for (i = 0; i < op_nr_counters; ++i) + odb_sync(&sf->files[i]); + + return 0; +} + + +static int is_sfile_kernel(struct sfile * sf) +{ + return !!sf->kernel; +} + + +static int is_sfile_anon(struct sfile * sf) +{ + return !!sf->anon; +} + + +static void for_one_sfile(struct sfile * sf, int (*func)(struct sfile *)) +{ + size_t i; + int free_sf = func(sf); + + for (i = 0; i < CG_HASH_SIZE; ++i) { + struct list_head * pos; + struct list_head * pos2; + list_for_each_safe(pos, pos2, &sf->cg_hash[i]) { + struct cg_entry * cg = + list_entry(pos, struct cg_entry, hash); + if (free_sf || func(&cg->to)) { + kill_sfile(&cg->to); + list_del(&cg->hash); + free(cg); + } + } + } + + if (free_sf) { + kill_sfile(sf); + free(sf); + } +} + + +static void for_each_sfile(int (*func)(struct sfile *)) +{ + struct list_head * pos; + struct list_head * pos2; + + list_for_each_safe(pos, pos2, &lru_list) { + struct sfile * sf = list_entry(pos, struct sfile, lru); + for_one_sfile(sf, func); + } +} + + +void sfile_clear_kernel(void) +{ + for_each_sfile(is_sfile_kernel); +} + + +void sfile_clear_anon(void) +{ + for_each_sfile(is_sfile_anon); +} + + +void sfile_sync_files(void) +{ + for_each_sfile(sync_sfile); +} + + +void sfile_close_files(void) +{ + for_each_sfile(close_sfile); +} + + +static int always_true(void) +{ + return 1; +} + + +#define LRU_AMOUNT 256 + +/* + * Clear out older sfiles. Note the current sfiles we're using + * will not be present in this list, due to sfile_get/put() pairs + * around the caller of this. + */ +int sfile_lru_clear(void) +{ + struct list_head * pos; + struct list_head * pos2; + int amount = LRU_AMOUNT; + + if (list_empty(&lru_list)) + return 1; + + list_for_each_safe(pos, pos2, &lru_list) { + struct sfile * sf; + if (!--amount) + break; + sf = list_entry(pos, struct sfile, lru); + for_one_sfile(sf, (int (*)(struct sfile *))always_true); + } + + return 0; +} + + +void sfile_get(struct sfile * sf) +{ + if (sf) + list_del(&sf->lru); +} + + +void sfile_put(struct sfile * sf) +{ + if (sf) + list_add_tail(&sf->lru, &lru_list); +} + + +void sfile_init(void) +{ + size_t i = 0; + + for (; i < HASH_SIZE; ++i) + list_init(&hashes[i]); +} diff --git a/daemon/opd_sfile.h b/daemon/opd_sfile.h new file mode 100644 index 0000000..56ed25b --- /dev/null +++ b/daemon/opd_sfile.h @@ -0,0 +1,108 @@ +/** + * @file daemon/opd_sfile.h + * Management of sample files + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_SFILE_H +#define OPD_SFILE_H + +#include "opd_cookie.h" + +#include "odb.h" +#include "op_hw_config.h" +#include "op_types.h" +#include "op_list.h" + +#include + +struct kernel_image; +struct transient; + +#define CG_HASH_SIZE 16 + +/** + * Each set of sample files (where a set is over the physical counter + * types) will have one of these for it. We match against the + * descriptions here to find which sample DB file we need to modify. + * + * cg files are stored in the hash. + */ +struct sfile { + /** hash value for this sfile */ + unsigned long hashval; + /** cookie value for the binary profiled */ + cookie_t cookie; + /** cookie value for the application owner, INVALID_COOKIE if not set */ + cookie_t app_cookie; + /** thread ID, -1 if not set */ + pid_t tid; + /** thread group ID, -1 if not set */ + pid_t tgid; + /** CPU number */ + unsigned int cpu; + /** kernel image if applicable */ + struct kernel_image * kernel; + /** anonymous mapping */ + struct anon_mapping * anon; + + /** hash table link */ + struct list_head hash; + /** lru list */ + struct list_head lru; + /** true if this file should be ignored in profiles */ + int ignored; + /** opened sample files */ + odb_t files[OP_MAX_COUNTERS]; + /** hash table of opened cg sample files */ + struct list_head cg_hash[CG_HASH_SIZE]; +}; + +/** a call-graph entry */ +struct cg_entry { + /** where arc is to */ + struct sfile to; + /** next in the hash slot */ + struct list_head hash; +}; + +/** clear any sfiles that are for the kernel */ +void sfile_clear_kernel(void); + +/** clear any sfiles that are for anon mappings */ +void sfile_clear_anon(void); + +/** sync sample files */ +void sfile_sync_files(void); + +/** close sample files */ +void sfile_close_files(void); + +/** clear out a certain amount of LRU entries + * return non-zero if the lru is already empty */ +int sfile_lru_clear(void); + +/** remove a sfile from the lru list, protecting it from sfile_lru_clear() */ +void sfile_get(struct sfile * sf); + +/** add this sfile to lru list */ +void sfile_put(struct sfile * sf); + +/** + * Find the sfile for the current parameters. Note that is required + * that the PC value be set appropriately (needed for kernel images) + */ +struct sfile * sfile_find(struct transient const * trans); + +/** Log the sample in a previously located sfile. */ +void sfile_log_sample(struct transient const * trans); + +/** initialise hashes */ +void sfile_init(void); + +#endif /* OPD_SFILE_H */ diff --git a/daemon/opd_stats.c b/daemon/opd_stats.c new file mode 100644 index 0000000..59a6960 --- /dev/null +++ b/daemon/opd_stats.c @@ -0,0 +1,83 @@ +/** + * @file daemon/opd_stats.c + * Management of daemon statistics + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "opd_stats.h" +#include "oprofiled.h" + +#include "op_get_time.h" + +#include +#include +#include + +unsigned long opd_stats[OPD_MAX_STATS]; + +/** + * print_if - print an integer value read from file filename, + * do nothing if the value read == -1 except if force is non-zero + */ +static void print_if(char const * fmt, char const * path, char const * filename, int force) +{ + int value = opd_read_fs_int(path, filename, 0); + if (value != -1 || force) + printf(fmt, value); +} + +/** + * opd_print_stats - print out latest statistics + */ +void opd_print_stats(void) +{ + DIR * dir; + struct dirent * dirent; + + printf("\n%s\n", op_get_time()); + printf("Nr. sample dumps: %lu\n", opd_stats[OPD_DUMP_COUNT]); + printf("Nr. non-backtrace samples: %lu\n", opd_stats[OPD_SAMPLES]); + printf("Nr. kernel samples: %lu\n", opd_stats[OPD_KERNEL]); + printf("Nr. lost samples (no kernel/user): %lu\n", opd_stats[OPD_NO_CTX]); + printf("Nr. lost kernel samples: %lu\n", opd_stats[OPD_LOST_KERNEL]); + printf("Nr. incomplete code structs: %lu\n", opd_stats[OPD_DANGLING_CODE]); + printf("Nr. samples lost due to sample file open failure: %lu\n", + opd_stats[OPD_LOST_SAMPLEFILE]); + printf("Nr. samples lost due to no permanent mapping: %lu\n", + opd_stats[OPD_LOST_NO_MAPPING]); + print_if("Nr. event lost due to buffer overflow: %u\n", + "/dev/oprofile/stats", "event_lost_overflow", 1); + print_if("Nr. samples lost due to no mapping: %u\n", + "/dev/oprofile/stats", "sample_lost_no_mapping", 1); + print_if("Nr. backtraces skipped due to no file mapping: %u\n", + "/dev/oprofile/stats", "bt_lost_no_mapping", 0); + print_if("Nr. samples lost due to no mm: %u\n", + "/dev/oprofile/stats", "sample_lost_no_mm", 1); + + if (!(dir = opendir("/dev/oprofile/stats/"))) + goto out; + while ((dirent = readdir(dir))) { + int cpu_nr; + char path[256]; + if (sscanf(dirent->d_name, "cpu%d", &cpu_nr) != 1) + continue; + snprintf(path, 256, "/dev/oprofile/stats/%s", dirent->d_name); + + print_if("Nr. samples lost cpu buffer overflow: %u\n", + path, "sample_lost_overflow", 1); + print_if("Nr. samples lost task exit: %u\n", + path, "sample_lost_task_exit", 0); + print_if("Nr. samples received: %u\n", + path, "sample_received", 1); + print_if("Nr. backtrace aborted: %u\n", + path, "backtrace_aborted", 0); + } + closedir(dir); +out: + fflush(stdout); +} diff --git a/daemon/opd_stats.h b/daemon/opd_stats.h new file mode 100644 index 0000000..177b86a --- /dev/null +++ b/daemon/opd_stats.h @@ -0,0 +1,31 @@ +/** + * @file daemon/opd_stats.h + * Management of daemon statistics + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_STATS_H +#define OPD_STATS_H + +extern unsigned long opd_stats[]; + +enum { OPD_SAMPLES, /**< nr. samples */ + OPD_KERNEL, /**< nr. kernel samples */ + OPD_PROCESS, /**< nr. userspace samples */ + OPD_NO_CTX, /**< nr. samples lost due to not knowing if in the kernel or not */ + OPD_LOST_KERNEL, /**< nr. kernel samples lost */ + OPD_LOST_SAMPLEFILE, /**< nr samples for which sample file can't be opened */ + OPD_LOST_NO_MAPPING, /**< nr samples lost due to no mapping */ + OPD_DUMP_COUNT, /**< nr. of times buffer is read */ + OPD_DANGLING_CODE, /**< nr. partial code notifications (buffer overflow */ + OPD_MAX_STATS /**< end of stats */ +}; + +void opd_print_stats(void); + +#endif /* OPD_STATS_H */ diff --git a/daemon/opd_trans.c b/daemon/opd_trans.c new file mode 100644 index 0000000..eb22e5f --- /dev/null +++ b/daemon/opd_trans.c @@ -0,0 +1,319 @@ +/** + * @file daemon/opd_trans.c + * Processing the sample buffer + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "opd_trans.h" +#include "opd_kernel.h" +#include "opd_sfile.h" +#include "opd_anon.h" +#include "opd_stats.h" +#include "opd_printf.h" +#include "opd_interface.h" + +#include +#include +#include +#include +#include +#include + +extern size_t kernel_pointer_size; + + +void clear_trans_last(struct transient * trans) +{ + trans->last = NULL; + trans->last_anon = NULL; +} + + +void clear_trans_current(struct transient * trans) +{ + trans->current = NULL; + trans->anon = NULL; +} + + +void update_trans_last(struct transient * trans) +{ + trans->last = trans->current; + trans->last_anon = trans->anon; + trans->last_pc = trans->pc; +} + + +static inline int is_escape_code(uint64_t code) +{ + return kernel_pointer_size == 4 ? code == ~0LU : code == ~0LLU; +} + + +static uint64_t pop_buffer_value(struct transient * trans) +{ + uint64_t val; + + if (!trans->remaining) { + fprintf(stderr, "BUG: popping empty buffer !\n"); + abort(); + } + + if (kernel_pointer_size == 4) { + uint32_t const * lbuf = (void const *)trans->buffer; + val = *lbuf; + } else { + uint64_t const * lbuf = (void const *)trans->buffer; + val = *lbuf; + } + + trans->remaining--; + trans->buffer += kernel_pointer_size; + return val; +} + + +static int enough_remaining(struct transient * trans, size_t size) +{ + if (trans->remaining >= size) + return 1; + + verbprintf(vmisc, "Dangling ESCAPE_CODE.\n"); + opd_stats[OPD_DANGLING_CODE]++; + return 0; +} + + +static void opd_put_sample(struct transient * trans, unsigned long long pc) +{ + unsigned long long event; + + if (!enough_remaining(trans, 1)) { + trans->remaining = 0; + return; + } + + event = pop_buffer_value(trans); + + if (trans->tracing != TRACING_ON) + trans->event = event; + + trans->pc = pc; + + /* sfile can change at each sample for kernel */ + if (trans->in_kernel != 0) + clear_trans_current(trans); + + if (!trans->in_kernel && trans->cookie == NO_COOKIE) + trans->anon = find_anon_mapping(trans); + + /* get the current sfile if needed */ + if (!trans->current) + trans->current = sfile_find(trans); + + /* + * can happen if kernel sample falls through the cracks, or if + * it's a sample from an anon region we couldn't find + */ + if (!trans->current) + goto out; + + /* FIXME: this logic is perhaps too harsh? */ + if (trans->current->ignored || (trans->last && trans->last->ignored)) + goto out; + + /* log the sample or arc */ + sfile_log_sample(trans); + +out: + /* switch to trace mode */ + if (trans->tracing == TRACING_START) + trans->tracing = TRACING_ON; + + update_trans_last(trans); +} + + +static void code_unknown(struct transient * trans __attribute__((unused))) +{ + fprintf(stderr, "Unknown code !\n"); + abort(); +} + + +static void code_ctx_switch(struct transient * trans) +{ + clear_trans_current(trans); + + if (!enough_remaining(trans, 5)) { + trans->remaining = 0; + return; + } + + trans->tid = pop_buffer_value(trans); + trans->app_cookie = pop_buffer_value(trans); + /* must be ESCAPE_CODE, CTX_TGID_CODE, tgid. Like this + * because tgid was added later in a compatible manner. + */ + pop_buffer_value(trans); + pop_buffer_value(trans); + trans->tgid = pop_buffer_value(trans); + + if (vmisc) { + char const * app = find_cookie(trans->app_cookie); + printf("CTX_SWITCH to tid %lu, tgid %lu, cookie %llx(%s)\n", + (unsigned long)trans->tid, (unsigned long)trans->tgid, + trans->app_cookie, app ? app : "none"); + } +} + + +static void code_cpu_switch(struct transient * trans) +{ + clear_trans_current(trans); + + if (!enough_remaining(trans, 1)) { + trans->remaining = 0; + return; + } + + trans->cpu = pop_buffer_value(trans); + verbprintf(vmisc, "CPU_SWITCH to %lu\n", trans->cpu); +} + + +static void code_cookie_switch(struct transient * trans) +{ + clear_trans_current(trans); + + if (!enough_remaining(trans, 1)) { + trans->remaining = 0; + return; + } + + trans->cookie = pop_buffer_value(trans); + + if (vmisc) { + char const * name = verbose_cookie(trans->cookie); + verbprintf(vmisc, "COOKIE_SWITCH to cookie %s(%llx)\n", + name, trans->cookie); + } +} + + +static void code_kernel_enter(struct transient * trans) +{ + verbprintf(vmisc, "KERNEL_ENTER_SWITCH to kernel\n"); + trans->in_kernel = 1; + clear_trans_current(trans); + /* subtlety: we must keep trans->cookie cached, + * even though it's meaningless for the kernel - + * we won't necessarily get a cookie switch on + * kernel exit. See comments in opd_sfile.c + */ +} + + +static void code_kernel_exit(struct transient * trans) +{ + verbprintf(vmisc, "KERNEL_EXIT_SWITCH to user-space\n"); + trans->in_kernel = 0; + clear_trans_current(trans); + clear_trans_last(trans); +} + + +static void code_module_loaded(struct transient * trans __attribute__((unused))) +{ + verbprintf(vmodule, "MODULE_LOADED_CODE\n"); + opd_reread_module_info(); + clear_trans_current(trans); + clear_trans_last(trans); +} + + +/* + * This also implicitly signals the end of the previous + * trace, so we never explicitly set TRACING_OFF when + * processing a buffer. + */ +static void code_trace_begin(struct transient * trans) +{ + verbprintf(varcs, "TRACE_BEGIN\n"); + trans->tracing = TRACING_START; +} + + +typedef void (*handler_t)(struct transient *); + +static handler_t handlers[LAST_CODE + 1] = { + &code_unknown, + &code_ctx_switch, + &code_cpu_switch, + &code_cookie_switch, + &code_kernel_enter, + &code_kernel_exit, + &code_module_loaded, + /* tgid handled differently */ + &code_unknown, + &code_trace_begin, +}; + + +void opd_process_samples(char const * buffer, size_t count) +{ + struct transient trans = { + .buffer = buffer, + .remaining = count, + .tracing = TRACING_OFF, + .current = NULL, + .last = NULL, + .cookie = INVALID_COOKIE, + .app_cookie = INVALID_COOKIE, + .anon = NULL, + .last_anon = NULL, + .pc = 0, + .last_pc = 0, + .event = 0, + .in_kernel = -1, + .cpu = -1, + .tid = -1, + .tgid = -1 + }; + + /* FIXME: was uint64_t but it can't compile on alpha where uint64_t + * is an unsigned long and below the printf("..." %llu\n", code) + * generate a warning, this look like a stopper to use c98 types :/ + */ + unsigned long long code; + + while (trans.remaining) { + code = pop_buffer_value(&trans); + + if (!is_escape_code(code)) { + opd_put_sample(&trans, code); + continue; + } + + if (!trans.remaining) { + verbprintf(vmisc, "Dangling ESCAPE_CODE.\n"); + opd_stats[OPD_DANGLING_CODE]++; + break; + } + + // started with ESCAPE_CODE, next is type + code = pop_buffer_value(&trans); + + if (code >= LAST_CODE) { + fprintf(stderr, "Unknown code %llu\n", code); + abort(); + } + + handlers[code](&trans); + } +} diff --git a/daemon/opd_trans.h b/daemon/opd_trans.h new file mode 100644 index 0000000..d5d601b --- /dev/null +++ b/daemon/opd_trans.h @@ -0,0 +1,60 @@ +/** + * @file daemon/opd_trans.h + * Processing the sample buffer + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPD_TRANS_H +#define OPD_TRANS_H + +#include "opd_cookie.h" +#include "op_types.h" + +struct sfile; +struct anon_mapping; + +enum tracing_type { + TRACING_OFF, + TRACING_START, + TRACING_ON +}; + +/** + * Transient values used for parsing the event buffer. + * Note that these are reset for each buffer read, but + * that should be ok as in the kernel, cpu_buffer_reset() + * ensures that a correct context starts off the buffer. + */ +struct transient { + char const * buffer; + size_t remaining; + enum tracing_type tracing; + struct sfile * current; + struct sfile * last; + struct anon_mapping * anon; + struct anon_mapping * last_anon; + cookie_t cookie; + cookie_t app_cookie; + vma_t pc; + vma_t last_pc; + unsigned long event; + int in_kernel; + unsigned long cpu; + pid_t tid; + pid_t tgid; +}; + +void opd_process_samples(char const * buffer, size_t count); + +/** used when we need to clear data that's been freed */ +void clear_trans_last(struct transient * trans); + +/** used when we need to clear data that's been freed */ +void clear_trans_current(struct transient * trans); + +#endif /* OPD_TRANS_H */ diff --git a/daemon/oprofiled.c b/daemon/oprofiled.c new file mode 100644 index 0000000..a7bf151 --- /dev/null +++ b/daemon/oprofiled.c @@ -0,0 +1,477 @@ +/** + * @file daemon/oprofiled.c + * Initialisation and setup + * + * @remark Copyright 2002, 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "config.h" + +#include "oprofiled.h" +#include "opd_printf.h" +#include "opd_events.h" + +#include "op_config.h" +#include "op_version.h" +#include "op_hw_config.h" +#include "op_libiberty.h" +#include "op_file.h" +#include "op_abi.h" +#include "op_string.h" +#include "op_cpu_type.h" +#include "op_popt.h" +#include "op_lockfile.h" +#include "op_list.h" +#include "op_fileio.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +sig_atomic_t signal_alarm; +sig_atomic_t signal_hup; +sig_atomic_t signal_term; +sig_atomic_t signal_usr1; +sig_atomic_t signal_usr2; + +uint op_nr_counters; +op_cpu cpu_type; +int vsfile; +int vsamples; +int varcs; +int vmodule; +int vmisc; +int separate_lib; +int separate_kernel; +int separate_thread; +int separate_cpu; +int no_vmlinux; +char * vmlinux; +char * kernel_range; +static char * verbose; +static char * binary_name_filter; +static char * events; +static int showvers; +static struct oprofiled_ops * opd_ops; +extern struct oprofiled_ops opd_24_ops; +extern struct oprofiled_ops opd_26_ops; + +#define OPD_IMAGE_FILTER_HASH_SIZE 32 +static struct list_head images_filter[OPD_IMAGE_FILTER_HASH_SIZE]; + +static struct poptOption options[] = { + { "kernel-range", 'r', POPT_ARG_STRING, &kernel_range, 0, "Kernel VMA range", "start-end", }, + { "vmlinux", 'k', POPT_ARG_STRING, &vmlinux, 0, "vmlinux kernel image", "file", }, + { "no-vmlinux", 0, POPT_ARG_NONE, &no_vmlinux, 0, "vmlinux kernel image file not available", NULL, }, + { "image", 0, POPT_ARG_STRING, &binary_name_filter, 0, "image name filter", "profile these comma separated image" }, + { "separate-lib", 0, POPT_ARG_INT, &separate_lib, 0, "separate library samples for each distinct application", "[0|1]", }, + { "separate-kernel", 0, POPT_ARG_INT, &separate_kernel, 0, "separate kernel samples for each distinct application", "[0|1]", }, + { "separate-thread", 0, POPT_ARG_INT, &separate_thread, 0, "thread-profiling mode", "[0|1]" }, + { "separate-cpu", 0, POPT_ARG_INT, &separate_cpu, 0, "separate samples for each CPU", "[0|1]" }, + { "events", 'e', POPT_ARG_STRING, &events, 0, "events list", "[events]" }, + { "version", 'v', POPT_ARG_NONE, &showvers, 0, "show version", NULL, }, + { "verbose", 'V', POPT_ARG_STRING, &verbose, 0, "be verbose in log file", "all,sfile,arcs,samples,module,misc", }, + POPT_AUTOHELP + { NULL, 0, 0, NULL, 0, NULL, NULL, }, +}; + + +void opd_open_logfile(void) +{ + if (open(OP_LOG_FILE, O_WRONLY|O_CREAT|O_NOCTTY|O_APPEND, 0755) == -1) { + perror("oprofiled: couldn't re-open stdout: "); + exit(EXIT_FAILURE); + } + + if (dup2(1, 2) == -1) { + perror("oprofiled: couldn't dup stdout to stderr: "); + exit(EXIT_FAILURE); + } +} + + +/** + * opd_fork - fork and return as child + * + * fork() and exit the parent with _exit(). + * Failure is fatal. + */ +static void opd_fork(void) +{ + switch (fork()) { + case -1: + perror("oprofiled: fork() failed: "); + exit(EXIT_FAILURE); + break; + case 0: + break; + default: + /* parent */ + _exit(EXIT_SUCCESS); + break; + } +} + + +static void opd_go_daemon(void) +{ + opd_fork(); + + if (chdir(OP_BASE_DIR)) { + fprintf(stderr, "oprofiled: opd_go_daemon: couldn't chdir to " + OP_BASE_DIR ": %s", strerror(errno)); + exit(EXIT_FAILURE); + } + + if (setsid() < 0) { + perror("oprofiled: opd_go_daemon: couldn't setsid: "); + exit(EXIT_FAILURE); + } + + opd_fork(); +} + + +static void opd_write_abi(void) +{ +#ifdef OPROF_ABI + char * cbuf; + + cbuf = xmalloc(strlen(OP_BASE_DIR) + 5); + strcpy(cbuf, OP_BASE_DIR); + strcat(cbuf, "/abi"); + op_write_abi_to_file(cbuf); + free(cbuf); +#endif +} + + +/** + * opd_alarm - sync files and report stats + */ +static void opd_alarm(int val __attribute__((unused))) +{ + signal_alarm = 1; +} + + +/* re-open logfile for logrotate */ +static void opd_sighup(int val __attribute__((unused))) +{ + signal_hup = 1; +} + + +static void opd_sigterm(int val __attribute__((unused))) +{ + signal_term = 1; +} + + +static void opd_sigusr1(int val __attribute__((unused))) +{ + signal_usr1 = 1; +} + + +static void opd_sigusr2(int val __attribute__((unused))) +{ + signal_usr2 = 1; +} + + +static void opd_setup_signals(void) +{ + struct sigaction act; + + act.sa_handler = opd_alarm; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + + if (sigaction(SIGALRM, &act, NULL)) { + perror("oprofiled: install of SIGALRM handler failed: "); + exit(EXIT_FAILURE); + } + + act.sa_handler = opd_sighup; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask, SIGALRM); + + if (sigaction(SIGHUP, &act, NULL)) { + perror("oprofiled: install of SIGHUP handler failed: "); + exit(EXIT_FAILURE); + } + + act.sa_handler = opd_sigterm; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask, SIGTERM); + + if (sigaction(SIGTERM, &act, NULL)) { + perror("oprofiled: install of SIGTERM handler failed: "); + exit(EXIT_FAILURE); + } + + act.sa_handler = opd_sigusr1; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask, SIGTERM); + + if (sigaction(SIGUSR1, &act, NULL)) { + perror("oprofiled: install of SIGUSR1 handler failed: "); + exit(EXIT_FAILURE); + } + + act.sa_handler = opd_sigusr2; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask, SIGTERM); + + if (sigaction(SIGUSR2, &act, NULL)) { + perror("oprofiled: install of SIGUSR1 handler failed: "); + exit(EXIT_FAILURE); + } +} + + +struct opd_hashed_name { + char * name; + struct list_head next; +}; + + +static void add_image_filter(char const * name) +{ + size_t hash; + struct opd_hashed_name * elt = xmalloc(sizeof(struct opd_hashed_name)); + elt->name = xmalloc(PATH_MAX); + if (!realpath(name, elt->name)) { + free(elt->name); + free(elt); + return; + } + hash = op_hash_string(elt->name); + verbprintf(vmisc, "Adding to image filter: \"%s\"\n", elt->name); + list_add(&elt->next, &images_filter[hash % OPD_IMAGE_FILTER_HASH_SIZE]); +} + + +static void opd_parse_image_filter(void) +{ + size_t i; + char const * last = binary_name_filter; + char const * cur = binary_name_filter; + + if (!binary_name_filter) + return; + + for (i = 0; i < OPD_IMAGE_FILTER_HASH_SIZE; ++i) + list_init(&images_filter[i]); + + while ((cur = strchr(last, ',')) != NULL) { + char * tmp = op_xstrndup(last, cur - last); + add_image_filter(tmp); + free(tmp); + last = cur + 1; + } + add_image_filter(last); +} + + +int is_image_ignored(char const * name) +{ + size_t hash; + struct list_head * pos; + + if (!binary_name_filter) + return 0; + + hash = op_hash_string(name); + + list_for_each(pos, &images_filter[hash % OPD_IMAGE_FILTER_HASH_SIZE]) { + struct opd_hashed_name * hashed_name = + list_entry(pos, struct opd_hashed_name, next); + if (!strcmp(hashed_name->name, name)) + return 0; + } + + return 1; +} + + +/** return the int in the given oprofilefs file */ +int opd_read_fs_int(char const * path, char const * name, int fatal) +{ + char filename[PATH_MAX + 1]; + snprintf(filename, PATH_MAX, "%s/%s", path, name); + return op_read_int_from_file(filename, fatal); +} + + +static void opd_handle_verbose_option(char const * name) +{ + if (!strcmp(name, "all")) { + vsfile = 1; + vsamples = 1; + varcs = 1; + vmodule = 1; + vmisc = 1; + } else if (!strcmp(name, "sfile")) { + vsfile = 1; + } else if (!strcmp(name, "arcs")) { + varcs = 1; + } else if (!strcmp(name, "samples")) { + vsamples = 1; + } else if (!strcmp(name, "module")) { + vmodule = 1; + } else if (!strcmp(name, "misc")) { + vmisc = 1; + } else { + fprintf(stderr, "unknown verbose options\n"); + exit(EXIT_FAILURE); + } +} + +static void opd_parse_verbose(void) +{ + char const * last = verbose; + char const * cur = verbose; + + if (!verbose) + return; + + while ((cur = strchr(last, ',')) != NULL) { + char * tmp = op_xstrndup(last, cur - last); + opd_handle_verbose_option(tmp); + free(tmp); + last = cur + 1; + } + opd_handle_verbose_option(last); +} + + +static void opd_options(int argc, char const * argv[]) +{ + poptContext optcon; + char * tmp; + + optcon = op_poptGetContext(NULL, argc, argv, options, 0); + + if (showvers) + show_version(argv[0]); + + opd_parse_verbose(); + + if (separate_kernel) + separate_lib = 1; + + cpu_type = op_get_cpu_type(); + op_nr_counters = op_get_nr_counters(cpu_type); + + if (!no_vmlinux) { + if (!vmlinux || !strcmp("", vmlinux)) { + fprintf(stderr, "oprofiled: no vmlinux specified.\n"); + poptPrintHelp(optcon, stderr, 0); + exit(EXIT_FAILURE); + } + + /* canonicalise vmlinux filename. fix #637805 */ + tmp = xmalloc(PATH_MAX); + if (realpath(vmlinux, tmp)) + vmlinux = tmp; + else + free(tmp); + + if (!kernel_range || !strcmp("", kernel_range)) { + fprintf(stderr, "oprofiled: no kernel VMA range specified.\n"); + poptPrintHelp(optcon, stderr, 0); + exit(EXIT_FAILURE); + } + } + + if (events == NULL) { + fprintf(stderr, "oprofiled: no events specified.\n"); + poptPrintHelp(optcon, stderr, 0); + exit(EXIT_FAILURE); + } + + opd_parse_events(events); + + opd_parse_image_filter(); + + poptFreeContext(optcon); +} + + +/* determine what kernel we're running and which daemon + * to use + */ +static struct oprofiled_ops * get_ops(void) +{ + switch (op_get_interface()) { + case OP_INTERFACE_24: + printf("Using 2.4 OProfile kernel interface.\n"); + return &opd_24_ops; + case OP_INTERFACE_26: + printf("Using 2.6+ OProfile kernel interface.\n"); + return &opd_26_ops; + default: + break; + } + + fprintf(stderr, "Couldn't determine kernel version.\n"); + exit(EXIT_FAILURE); + return NULL; +} + + +int main(int argc, char const * argv[]) +{ + int err; + struct rlimit rlim = { 2048, 2048 }; + + opd_options(argc, argv); + + opd_setup_signals(); + + err = setrlimit(RLIMIT_NOFILE, &rlim); + if (err) { + perror("warning: could not set RLIMIT_NOFILE to 2048: "); + } + + opd_write_abi(); + + opd_ops = get_ops(); + + opd_ops->init(); + + opd_go_daemon(); + + /* clean up every 10 minutes */ + alarm(60 * 10); + + if (op_write_lock_file(OP_LOCK_FILE)) { + fprintf(stderr, "oprofiled: could not create lock file " + OP_LOCK_FILE "\n"); + exit(EXIT_FAILURE); + } + + opd_ops->start(); + + opd_ops->exit(); + + return 0; +} diff --git a/daemon/oprofiled.h b/daemon/oprofiled.h new file mode 100644 index 0000000..23f40d2 --- /dev/null +++ b/daemon/oprofiled.h @@ -0,0 +1,62 @@ +/** + * @file daemon/oprofiled.h + * Initialisation and setup + * + * @remark Copyright 2002, 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPROFILED_H + +#include + +struct oprofiled_ops { + void (*init)(void); + void (*start)(void); + void (*exit)(void); +}; + + +/** + * opd_open_logfile - open the log file + * + * Open the logfile on stdout and stderr. This function + * assumes that 1 and 2 are the lowest close()d file + * descriptors. Failure to open on either descriptor is + * a fatal error. + */ +void opd_open_logfile(void); + + +/** + * is_image_ignored - check if we must ignore this image + * @param name the name to check + * + * Return true if the image should not be profiled + */ +int is_image_ignored(char const * name); + +/** return the int in the given oprofilefs file, error is fatal if !is_fatal */ +int opd_read_fs_int(char const * path, char const * name, int is_fatal); + + +/** global variable positioned by signal handler */ +extern sig_atomic_t signal_alarm; +extern sig_atomic_t signal_hup; +extern sig_atomic_t signal_term; +extern sig_atomic_t signal_usr1; +extern sig_atomic_t signal_usr2; + +extern unsigned int op_nr_counters; +extern int separate_lib; +extern int separate_kernel; +extern int separate_thread; +extern int separate_cpu; +extern int no_vmlinux; +extern char * vmlinux; +extern char * kernel_range; + +#endif /* OPROFILED_H */ diff --git a/depcomp b/depcomp new file mode 100755 index 0000000..ffcd540 --- /dev/null +++ b/depcomp @@ -0,0 +1,529 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2005-02-09.22 + +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + stat=$? + + if test -f "$tmpdepfile"; then : + else + stripped=`echo "$stripped" | sed 's,^.*/,,'` + tmpdepfile="$stripped.u" + fi + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + outname="$stripped.o" + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mecanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..be76bac --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,79 @@ +RM=rm +MANDIR=$(DESTDIR)@mandir@/man1 + +XSLTPROC=xsltproc +XSLTPROC_FLAGS=@XSLTPROC_FLAGS@ +XHTML_STYLESHEET=$(srcdir)/xsl/xhtml.xsl +CHUNK_XHTML_STYLESHEET=$(srcdir)/xsl/xhtml-chunk.xsl +XML_CATALOG_FILES=xsl/catalog.xml +STYLESHEETS=$(CHUNK_XHTML_STYLESHEET) $(srcdir)/xsl/xhtml-common.xsl + +man_MANS = \ + oprofile.1 \ + opcontrol.1 \ + opreport.1 \ + opannotate.1 \ + opgprof.1 \ + ophelp.1 \ + oparchive.1 + +htmldir = $(prefix)/share/doc/oprofile +dist_html_DATA = oprofile.html internals.html + +if have_xsltproc + +oprofile.html: ${top_srcdir}/doc/oprofile.xml + XML_CATALOG_FILES=$(XML_CATALOG_FILES) $(XSLTPROC) $(XSLTPROC_FLAGS) -o $@ --stringparam version @VERSION@ $(XHTML_STYLESHEET) $< + +internals.html: ${top_srcdir}/doc/internals.xml + XML_CATALOG_FILES=$(XML_CATALOG_FILES) $(XSLTPROC) $(XSLTPROC_FLAGS) -o $@ --stringparam version @VERSION@ $(XHTML_STYLESHEET) $< + +# rules to generate oprofile.sf.net/doc files + +doc/index.html: ${top_srcdir}/doc/oprofile.xml + -mkdir doc/ + $(XSLTPROC) -o doc/ $(XSLTPROC_FLAGS) --stringparam version @VERSION@ $(CHUNK_XHTML_STYLESHEET) $< + +doc/internals/index.html: ${top_srcdir}/doc/internals.xml + -mkdir doc/internals/ + $(XSLTPROC) -o doc/internals/ $(XSLTPROC_FLAGS) --stringparam version @VERSION@ $(CHUNK_XHTML_STYLESHEET) $< + +chunk: doc/index.html doc/internals/index.html + cp ${top_srcdir}/doc/buffers.png doc/internals/ + +else + +oprofile.html: + touch $@ + +internals.html: + touch $@ + +chunk: + +endif + +distclean-local: + $(RM) -f xsl/catalog-1.xml xsl/catalog.xml + +clean-local: + $(RM) -f $(generated_mans) + +# these files are not cleaned by make uninstall automake bug ? +uninstall-local: + rm -f @mandir@/cat1/oprofile.1.gz + @for f in $(LINK_LIST); do \ + rm -f $(CATDIR)/cat1/$$f.gz; \ + done + +EXTRA_DIST = \ + oprofile.1 \ + oprofile.1.in \ + oprofile.xml \ + internals.xml \ + xsl/catalog-1.xml.in \ + xsl/xhtml.xsl \ + xsl/xhtml-common.xsl \ + xsl/xhtml-chunk.xsl \ + srcdoc/Doxyfile.in \ + srcdoc/Makefile diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 0000000..e44f3ff --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,506 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = doc +DIST_COMMON = $(dist_html_DATA) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/opannotate.1.in \ + $(srcdir)/oparchive.1.in $(srcdir)/opcontrol.1.in \ + $(srcdir)/opgprof.1.in $(srcdir)/ophelp.1.in \ + $(srcdir)/opreport.1.in $(srcdir)/oprofile.1.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = oprofile.1 opcontrol.1 ophelp.1 opreport.1 \ + opannotate.1 opgprof.1 oparchive.1 +SOURCES = +DIST_SOURCES = +man1dir = $(mandir)/man1 +am__installdirs = "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(htmldir)" +NROFF = nroff +MANS = $(man_MANS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +dist_htmlDATA_INSTALL = $(INSTALL_DATA) +DATA = $(dist_html_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = xsltproc +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +RM = rm +MANDIR = $(DESTDIR)@mandir@/man1 +XHTML_STYLESHEET = $(srcdir)/xsl/xhtml.xsl +CHUNK_XHTML_STYLESHEET = $(srcdir)/xsl/xhtml-chunk.xsl +XML_CATALOG_FILES = xsl/catalog.xml +STYLESHEETS = $(CHUNK_XHTML_STYLESHEET) $(srcdir)/xsl/xhtml-common.xsl +man_MANS = \ + oprofile.1 \ + opcontrol.1 \ + opreport.1 \ + opannotate.1 \ + opgprof.1 \ + ophelp.1 \ + oparchive.1 + +htmldir = $(prefix)/share/doc/oprofile +dist_html_DATA = oprofile.html internals.html +EXTRA_DIST = \ + oprofile.1 \ + oprofile.1.in \ + oprofile.xml \ + internals.xml \ + xsl/catalog-1.xml.in \ + xsl/xhtml.xsl \ + xsl/xhtml-common.xsl \ + xsl/xhtml-chunk.xsl \ + srcdoc/Doxyfile.in \ + srcdoc/Makefile + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign doc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +oprofile.1: $(top_builddir)/config.status $(srcdir)/oprofile.1.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +opcontrol.1: $(top_builddir)/config.status $(srcdir)/opcontrol.1.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +ophelp.1: $(top_builddir)/config.status $(srcdir)/ophelp.1.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +opreport.1: $(top_builddir)/config.status $(srcdir)/opreport.1.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +opannotate.1: $(top_builddir)/config.status $(srcdir)/opannotate.1.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +opgprof.1: $(top_builddir)/config.status $(srcdir)/opgprof.1.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +oparchive.1: $(top_builddir)/config.status $(srcdir)/oparchive.1.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +uninstall-info-am: +install-man1: $(man1_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)" + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \ + done +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 1*) ;; \ + *) ext='1' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \ + rm -f "$(DESTDIR)$(man1dir)/$$inst"; \ + done +install-dist_htmlDATA: $(dist_html_DATA) + @$(NORMAL_INSTALL) + test -z "$(htmldir)" || $(mkdir_p) "$(DESTDIR)$(htmldir)" + @list='$(dist_html_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(dist_htmlDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \ + $(dist_htmlDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \ + done + +uninstall-dist_htmlDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_html_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(htmldir)/$$f'"; \ + rm -f "$(DESTDIR)$(htmldir)/$$f"; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/srcdoc $(distdir)/xsl + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(MANS) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(htmldir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-local mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-local + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-dist_htmlDATA install-man + +install-exec-am: + +install-info: install-info-am + +install-man: install-man1 + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-dist_htmlDATA uninstall-info-am \ + uninstall-local uninstall-man + +uninstall-man: uninstall-man1 + +.PHONY: all all-am check check-am clean clean-generic clean-local \ + distclean distclean-generic distclean-local distdir dvi dvi-am \ + html html-am info info-am install install-am install-data \ + install-data-am install-dist_htmlDATA install-exec \ + install-exec-am install-info install-info-am install-man \ + install-man1 install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ + uninstall-am uninstall-dist_htmlDATA uninstall-info-am \ + uninstall-local uninstall-man uninstall-man1 + + +@have_xsltproc_TRUE@oprofile.html: ${top_srcdir}/doc/oprofile.xml +@have_xsltproc_TRUE@ XML_CATALOG_FILES=$(XML_CATALOG_FILES) $(XSLTPROC) $(XSLTPROC_FLAGS) -o $@ --stringparam version @VERSION@ $(XHTML_STYLESHEET) $< + +@have_xsltproc_TRUE@internals.html: ${top_srcdir}/doc/internals.xml +@have_xsltproc_TRUE@ XML_CATALOG_FILES=$(XML_CATALOG_FILES) $(XSLTPROC) $(XSLTPROC_FLAGS) -o $@ --stringparam version @VERSION@ $(XHTML_STYLESHEET) $< + +# rules to generate oprofile.sf.net/doc files + +@have_xsltproc_TRUE@doc/index.html: ${top_srcdir}/doc/oprofile.xml +@have_xsltproc_TRUE@ -mkdir doc/ +@have_xsltproc_TRUE@ $(XSLTPROC) -o doc/ $(XSLTPROC_FLAGS) --stringparam version @VERSION@ $(CHUNK_XHTML_STYLESHEET) $< + +@have_xsltproc_TRUE@doc/internals/index.html: ${top_srcdir}/doc/internals.xml +@have_xsltproc_TRUE@ -mkdir doc/internals/ +@have_xsltproc_TRUE@ $(XSLTPROC) -o doc/internals/ $(XSLTPROC_FLAGS) --stringparam version @VERSION@ $(CHUNK_XHTML_STYLESHEET) $< + +@have_xsltproc_TRUE@chunk: doc/index.html doc/internals/index.html +@have_xsltproc_TRUE@ cp ${top_srcdir}/doc/buffers.png doc/internals/ + +@have_xsltproc_FALSE@oprofile.html: +@have_xsltproc_FALSE@ touch $@ + +@have_xsltproc_FALSE@internals.html: +@have_xsltproc_FALSE@ touch $@ + +@have_xsltproc_FALSE@chunk: + +distclean-local: + $(RM) -f xsl/catalog-1.xml xsl/catalog.xml + +clean-local: + $(RM) -f $(generated_mans) + +# these files are not cleaned by make uninstall automake bug ? +uninstall-local: + rm -f @mandir@/cat1/oprofile.1.gz + @for f in $(LINK_LIST); do \ + rm -f $(CATDIR)/cat1/$$f.gz; \ + done +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/doc/internals.html b/doc/internals.html new file mode 100644 index 0000000..2305168 --- /dev/null +++ b/doc/internals.html @@ -0,0 +1,1616 @@ + + + + + + OProfile Internals + + + +
+
+
+
+

OProfile Internals

+
+
+
+
+

John Levon

+
+ +
+
+
+
+
+ +
+
+
+
+
+

+ Table of Contents +

+
+
+ + 1. Introduction + +
+
+
+
+ + 1. Overview + +
+
+ + 2. Components of the OProfile system + +
+
+
+
+ + 2.1. Architecture-specific components + +
+
+ + 2.2. oprofilefs + +
+
+ + 2.3. Generic kernel driver + +
+
+ + 2.4. The OProfile daemon + +
+
+ + 2.5. Post-profiling tools + +
+
+
+
+
+
+ + 2. Performance counter management + +
+
+
+
+ + 1. Providing a user interface + +
+
+ + 2. Programming the performance counter registers + +
+
+
+
+ + 2.1. Starting and stopping the counters + +
+
+ + 2.2. IA64 and perfmon + +
+
+
+
+
+
+ + 3. Collecting and processing samples + +
+
+
+
+ + 1. Receiving interrupts + +
+
+ + 2. Core data structures + +
+
+ + 3. Logging a sample + +
+
+ + 4. Logging stack traces + +
+
+ + 5. Synchronising the CPU buffers to the event buffer + +
+
+ + 6. Identifying binary images + +
+
+ + 7. Finding a sample's binary image and offset + +
+
+
+
+ + 4. Generating sample files + +
+
+
+
+ + 1. Processing the buffer + +
+
+
+
+ + 1.1. Handling kernel samples + +
+
+
+
+ + 2. Locating and creating sample files + +
+
+ + 3. Writing data to a sample file + +
+
+
+
+ + 5. Generating useful output + +
+
+
+
+ + 1. Handling the profile specification + +
+
+ + 2. Collating the candidate sample files + +
+
+
+
+ + 2.1. Classifying sample files + +
+
+ + 2.2. Creating inverted profile lists + +
+
+
+
+ + 3. Generating profile data + +
+
+
+
+ + 3.1. Processing the binary image + +
+
+ + 3.2. Processing the sample files + +
+
+
+
+ + 4. Generating output + +
+
+
+
+ + Glossary of OProfile source concepts and types + +
+
+
+
+

+ List of Figures +

+
+
3.1. The OProfile buffers
+
+
+
+
+
+
+

Chapter 1. Introduction

+
+
+
+
+

+ Table of Contents +

+
+
+ + 1. Overview + +
+
+ + 2. Components of the OProfile system + +
+
+
+
+ + 2.1. Architecture-specific components + +
+
+ + 2.2. oprofilefs + +
+
+ + 2.3. Generic kernel driver + +
+
+ + 2.4. The OProfile daemon + +
+
+ + 2.5. Post-profiling tools + +
+
+
+
+
+

+This document is current for OProfile version 0.9.1cvs. +This document provides some details on the internal workings of OProfile for the +interested hacker. This document assumes strong C, working C++, plus some knowledge of +kernel internals and CPU hardware. +

+
+

Note

+

+Only the "new" implementation associated with kernel 2.6 and above is covered here. 2.4 +uses a very different kernel module implementation and daemon to produce the sample files. +

+
+
+
+
+
+

1. Overview

+
+
+
+

+OProfile is a statistical continuous profiler. In other words, profiles are generated by +regularly sampling the current registers on each CPU (from an interrupt handler, the +saved PC value at the time of interrupt is stored), and converting that runtime PC +value into something meaningful to the programmer. +

+

+OProfile achieves this by taking the stream of sampled PC values, along with the detail +of which task was running at the time of the interrupt, and converting into a file offset +against a particular binary file. Because applications mmap() +the code they run (be it /bin/bash, /lib/libfoo.so +or whatever), it's possible to find the relevant binary file and offset by walking +the task's list of mapped memory areas. Each PC value is thus converted into a tuple +of binary-image,offset. This is something that the userspace tools can use directly +to reconstruct where the code came from, including the particular assembly instructions, +symbol, and source line (via the binary's debug information if present). +

+

+Regularly sampling the PC value like this approximates what actually was executed and +how often - more often than not, this statistical approximation is good enough to +reflect reality. In common operation, the time between each sample interrupt is regulated +by a fixed number of clock cycles. This implies that the results will reflect where +the CPU is spending the most time; this is obviously a very useful information source +for performance analysis. +

+

+Sometimes though, an application programmer needs different kinds of information: for example, +"which of the source routines cause the most cache misses ?". The rise in importance of +such metrics in recent years has led many CPU manufacturers to provide hardware performance +counters capable of measuring these events on the hardware level. Typically, these counters +increment once per each event, and generate an interrupt on reaching some pre-defined +number of events. OProfile can use these interrupts to generate samples: then, the +profile results are a statistical approximation of which code caused how many of the +given event. +

+

+Consider a simplified system that only executes two functions A and B. A +takes one cycle to execute, whereas B takes 99 cycles. Imagine we run at +100 cycles a second, and we've set the performance counter to create an +interrupt after a set number of "events" (in this case an event is one +clock cycle). It should be clear that the chances of the interrupt +occurring in function A is 1/100, and 99/100 for function B. Thus, we +statistically approximate the actual relative performance features of +the two functions over time. This same analysis works for other types of +events, providing that the interrupt is tied to the number of events +occurring (that is, after N events, an interrupt is generated). +

+

+There are typically more than one of these counters, so it's possible to set up profiling +for several different event types. Using these counters gives us a powerful, low-overhead +way of gaining performance metrics. If OProfile, or the CPU, does not support performance +counters, then a simpler method is used: the kernel timer interrupt feeds samples +into OProfile itself. +

+

+The rest of this document concerns itself with how we get from receiving samples at +interrupt time to producing user-readable profile information. +

+
+
+
+
+
+

2. Components of the OProfile system

+
+
+
+
+
+
+
+

2.1. Architecture-specific components

+
+
+
+

+If OProfile supports the hardware performance counters found on +a particular architecture, code for managing the details of setting +up and managing these counters can be found in the kernel source +tree in the relevant arch/arch/oprofile/ +directory. The architecture-specific implementation works via +filling in the oprofile_operations structure at init time. This +provides a set of operations such as setup(), +start(), stop(), etc. +that manage the hardware-specific details of fiddling with the +performance counter registers. +

+

+The other important facility available to the architecture code is +oprofile_add_sample(). This is where a particular sample +taken at interrupt time is fed into the generic OProfile driver code. +

+
+
+
+
+
+

2.2. oprofilefs

+
+
+
+

+OProfile implements a pseudo-filesystem known as "oprofilefs", mounted from +userspace at /dev/oprofile. This consists of small +files for reporting and receiving configuration from userspace, as well +as the actual character device that the OProfile userspace receives samples +from. At setup() time, the architecture-specific may +add further configuration files related to the details of the performance +counters. For example, on x86, one numbered directory for each hardware +performance counter is added, with files in each for the event type, +reset value, etc. +

+

+The filesystem also contains a stats directory with +a number of useful counters for various OProfile events. +

+
+
+
+
+
+

2.3. Generic kernel driver

+
+
+
+

+This lives in drivers/oprofile/, and forms the core of +how OProfile works in the kernel. Its job is to take samples delivered +from the architecture-specific code (via oprofile_add_sample()), +and buffer this data, in a transformed form as described later, until releasing +the data to the userspace daemon via the /dev/oprofile/buffer +character device. +

+
+
+
+
+
+

2.4. The OProfile daemon

+
+
+
+

+The OProfile userspace daemon's job is to take the raw data provided by the +kernel and write it to the disk. It takes the single data stream from the +kernel and logs sample data against a number of sample files (found in +/var/lib/oprofile/samples/current/. For the benefit +of the "separate" functionality, the names/paths of these sample files +are mangled to reflect where the samples were from: this can include +thread IDs, the binary file path, the event type used, and more. +

+

+After this final step from interrupt to disk file, the data is now +persistent (that is, changes in the running of the system do not invalidate +stored data). So the post-profiling tools can run on this data at any +time (assuming the original binary files are still available and unchanged, +naturally). +

+
+

2.5. Post-profiling tools

+So far, we've collected data, but we've yet to present it in a useful form +to the user. This is the job of the post-profiling tools. In general form, +they collate a subset of the available sample files, load and process each one +correlated against the relevant binary file, and finally produce user-readable +information. +
+
+
+
+
+
+
+

Chapter 2. Performance counter management

+
+
+
+ +
+
+
+
+

1. Providing a user interface

+
+
+
+

+The performance counter registers need programming in order to set the +type of event to count, etc. OProfile uses a standard model across all +CPUs for defining these events as follows : +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ event + The event type e.g. DATA_MEM_REFS
+ unit mask + The sub-events to count (more detailed specification)
+ counter + The hardware counter(s) that can count this event
+ count + The reset value (how many events before an interrupt)
+ kernel + Whether the counter should increment when in kernel space
+ user + Whether the counter should increment when in user space
+
+

+The term "unit mask" is borrowed from the Intel architectures, and can +further specify exactly when a counter is incremented (for example, +cache-related events can be restricted to particular state transitions +of the cache lines). +

+

+All of the available hardware events and their details are specified in +the textual files in the events directory. The +syntax of these files should be fairly obvious. The user specifies the +names and configuration details of the chosen counters via +opcontrol. These are then written to the kernel +module (in numerical form) via /dev/oprofile/N/ +where N is the physical hardware counter (some events can only be used +on specific counters; OProfile hides these details from the user when +possible). On IA64, the perfmon-based interface behaves somewhat +differently, as described later. +

+
+
+
+
+
+

2. Programming the performance counter registers

+
+
+
+

+We have described how the user interface fills in the desired +configuration of the counters and transmits the information to the +kernel. It is the job of the ->setup() method +to actually program the performance counter registers. Clearly, the +details of how this is done is architecture-specific; it is also +model-specific on many architectures. For example, i386 provides methods +for each model type that programs the counter registers correctly +(see the op_model_* files in +arch/i386/oprofile for the details). The method +reads the values stored in the virtual oprofilefs files and programs +the registers appropriately, ready for starting the actual profiling +session. +

+

+The architecture-specific drivers make sure to save the old register +settings before doing OProfile setup. They are restored when OProfile +shuts down. This is useful, for example, on i386, where the NMI watchdog +uses the same performance counter registers as OProfile; they cannot +run concurrently, but OProfile makes sure to restore the setup it found +before it was running. +

+

+In addition to programming the counter registers themselves, other setup +is often necessary. For example, on i386, the local APIC needs +programming in order to make the counter's overflow interrupt appear as +an NMI (non-maskable interrupt). This allows sampling (and therefore +profiling) of regions where "normal" interrupts are masked, enabling +more reliable profiles. +

+
+
+
+
+

2.1. Starting and stopping the counters

+
+
+
+

+Initiating a profiling session is done via writing an ASCII '1' +to the file /dev/oprofile/enable. This sets up the +core, and calls into the architecture-specific driver to actually +enable each configured counter. Again, the details of how this is +done is model-specific (for example, the Athlon models can disable +or enable on a per-counter basis, unlike the PPro models). +

+
+
+
+
+
+

2.2. IA64 and perfmon

+
+
+
+

+The IA64 architecture provides a different interface from the other +architectures, using the existing perfmon driver. Register programming +is handled entirely in user-space (see +daemon/opd_perfmon.c for the details). A process +is forked for each CPU, which creates a perfmon context and sets the +counter registers appropriately via the +sys_perfmonctl interface. In addition, the actual +initiation and termination of the profiling session is handled via the +same interface using PFM_START and +PFM_STOP. On IA64, then, there are no oprofilefs +files for the performance counters, as the kernel driver does not +program the registers itself. +

+

+Instead, the perfmon driver for OProfile simply registers with the +OProfile core with an OProfile-specific UUID. During a profiling +session, the perfmon core calls into the OProfile perfmon driver and +samples are registered with the OProfile core itself as usual (with +oprofile_add_sample()). +

+
+
+
+
+
+
+
+

Chapter 3. Collecting and processing samples

+
+
+
+ +
+
+
+
+

1. Receiving interrupts

+
+
+
+

+Naturally, how the overflow interrupts are received is specific +to the hardware architecture, unless we are in "timer" mode, where the +logging routine is called directly from the standard kernel timer +interrupt handler. +

+

+On the i386 architecture, the local APIC is programmed such that when a +counter overflows (that is, it receives an event that causes an integer +overflow of the register value to zero), an NMI is generated. This calls +into the general handler do_nmi(); because OProfile +has registered itself as capable of handling NMI interrupts, this will +call into the OProfile driver code in +arch/i386/oprofile. Here, the saved PC value (the +CPU saves the register set at the time of interrupt on the stack +available for inspection) is extracted, and the counters are examined to +find out which one generated the interrupt. Also determined is whether +the system was inside kernel or user space at the time of the interrupt. +These three pieces of information are then forwarded onto the OProfile +core via oprofile_add_sample(). Finally, the +counter values are reset to the chosen count value, to ensure another +interrupt happens after another N events have occurred. Other +architectures behave in a similar manner. +

+
+
+
+
+
+

2. Core data structures

+
+
+
+

+Before considering what happens when we log a sample, we shall digress +for a moment and look at the general structure of the data collection +system. +

+

+OProfile maintains a small buffer for storing the logged samples for +each CPU on the system. Only this buffer is altered when we actually log +a sample (remember, we may still be in an NMI context, so no locking is +possible). The buffer is managed by a two-handed system; the "head" +iterator dictates where the next sample data should be placed in the +buffer. Of course, overflow of the buffer is possible, in which case +the sample is discarded. +

+

+It is critical to remember that at this point, the PC value is an +absolute value, and is therefore only meaningful in the context of which +task it was logged against. Thus, these per-CPU buffers also maintain +details of which task each logged sample is for, as described in the +next section. In addition, we store whether the sample was in kernel +space or user space (on some architectures and configurations, the address +space is not sub-divided neatly at a specific PC value, so we must store +this information). +

+

+As well as these small per-CPU buffers, we have a considerably larger +single buffer. This holds the data that is eventually copied out into +the OProfile daemon. On certain system events, the per-CPU buffers are +processed and entered (in mutated form) into the main buffer, known in +the source as the "event buffer". The "tail" iterator indicates the +point from which the CPU may be read, up to the position of the "head" +iterator. This provides an entirely lock-free method for extracting data +from the CPU buffers. This process is described in detail later in this chapter. +

+
+ +

+ Figure 3.1. The OProfile buffers +

+
+ The OProfile buffers +
+
+
+
+
+
+
+

3. Logging a sample

+
+
+
+

+As mentioned, the sample is logged into the buffer specific to the +current CPU. The CPU buffer is a simple array of pairs of unsigned long +values; for a sample, they hold the PC value and the counter for the +sample. (The counter value is later used to translate back into the relevant +event type the counter was programmed to). +

+

+In addition to logging the sample itself, we also log task switches. +This is simply done by storing the address of the last task to log a +sample on that CPU in a data structure, and writing a task switch entry +into the buffer if the new value of current() has +changed. Note that later we will directly de-reference this pointer; +this imposes certain restrictions on when and how the CPU buffers need +to be processed. +

+

+Finally, as mentioned, we log whether we have changed between kernel and +userspace using a similar method. Both of these variables +(last_task and last_is_kernel) are +reset when the CPU buffer is read. +

+
+
+
+
+
+

4. Logging stack traces

+
+
+
+

+OProfile can also provide statistical samples of call chains (on x86). To +do this, at sample time, the frame pointer chain is traversed, recording +the return address for each stack frame. This will only work if the code +was compiled with frame pointers, but we're careful to abort the +traversal if the frame pointer appears bad. We store the set of return +addresses straight into the CPU buffer. Note that, since this traversal +is keyed off the standard sample interrupt, the number of times a +function appears in a stack trace is not an indicator of how many times +the call site was executed: rather, it's related to the number of +samples we took where that call site was involved. Thus, the results for +stack traces are not necessarily proportional to the call counts: +typical programs will have many main() samples. +

+
+
+
+
+
+

5. Synchronising the CPU buffers to the event buffer

+
+
+
+

+At some point, we have to process the data in each CPU buffer and enter +it into the main (event) buffer. The file +buffer_sync.c contains the relevant code. We +periodically (currently every HZ/4 jiffies) start +the synchronisation process. In addition, we process the buffers on +certain events, such as an application calling +munmap(). This is particularly important for +exit() - because the CPU buffers contain pointers +to the task structure, if we don't process all the buffers before the +task is actually destroyed and the task structure freed, then we could +end up trying to dereference a bogus pointer in one of the CPU buffers. +

+

+We also add a notification when a kernel module is loaded; this is so +that user-space can re-read /proc/modules to +determine the load addresses of kernel module text sections. Without +this notification, samples for a newly-loaded module could get lost or +be attributed to the wrong module. +

+

+The synchronisation itself works in the following manner: first, mutual +exclusion on the event buffer is taken. Remember, we do not need to do +that for each CPU buffer, as we only read from the tail iterator (whilst +interrupts might be arriving at the same buffer, but they will write to +the position of the head iterator, leaving previously written entries +intact). Then, we process each CPU buffer in turn. A CPU switch +notification is added to the buffer first (for +--separate=cpu support). Then the processing of the +actual data starts. +

+

+As mentioned, the CPU buffer consists of task switch entries and the +actual samples. When the routine sync_buffer() sees +a task switch, the process ID and process group ID are recorded into the +event buffer, along with a dcookie (see below) identifying the +application binary (e.g. /bin/bash). The +mmap_sem for the task is then taken, to allow safe +iteration across the tasks' list of mapped areas. Each sample is then +processed as described in the next section. +

+

+After a buffer has been read, the tail iterator is updated to reflect +how much of the buffer was processed. Note that when we determined how +much data there was to read in the CPU buffer, we also called +cpu_buffer_reset() to reset +last_task and last_is_kernel, as +we've already mentioned. During the processing, more samples may have +been arriving in the CPU buffer; this is OK because we are careful to +only update the tail iterator to how much we actually read - on the next +buffer synchronisation, we will start again from that point. +

+
+
+
+
+
+

6. Identifying binary images

+
+
+
+

+In order to produce useful profiles, we need to be able to associate a +particular PC value sample with an actual ELF binary on the disk. This +leaves us with the problem of how to export this information to +user-space. We create unique IDs that identify a particular directory +entry (dentry), and write those IDs into the event buffer. Later on, +the user-space daemon can call the lookup_dcookie +system call, which looks up the ID and fills in the full path of +the binary image in the buffer user-space passes in. These IDs are +maintained by the code in fs/dcookies.c; the +cache lasts for as long as the daemon has the event buffer open. +

+
+
+
+
+
+

7. Finding a sample's binary image and offset

+
+
+
+

+We haven't yet described how we process the absolute PC value into +something usable by the user-space daemon. When we find a sample entered +into the CPU buffer, we traverse the list of mappings for the task +(remember, we will have seen a task switch earlier, so we know which +task's lists to look at). When a mapping is found that contains the PC +value, we look up the mapped file's dentry in the dcookie cache. This +gives the dcookie ID that will uniquely identify the mapped file. Then +we alter the absolute value such that it is an offset from the start of +the file being mapped (the mapping need not start at the start of the +actual file, so we have to consider the offset value of the mapping). We +store this dcookie ID into the event buffer; this identifies which +binary the samples following it are against. +In this manner, we have converted a PC value, which has transitory +meaning only, into a static offset value for later processing by the +daemon. +

+

+We also attempt to avoid the relatively expensive lookup of the dentry +cookie value by storing the cookie value directly into the dentry +itself; then we can simply derive the cookie value immediately when we +find the correct mapping. +

+
+
+
+
+
+
+

Chapter 4. Generating sample files

+
+
+
+
+

+ Table of Contents +

+
+
+ + 1. Processing the buffer + +
+
+
+
+ + 1.1. Handling kernel samples + +
+
+
+
+ + 2. Locating and creating sample files + +
+
+ + 3. Writing data to a sample file + +
+
+
+
+
+
+
+

1. Processing the buffer

+
+
+
+

+Now we can move onto user-space in our description of how raw interrupt +samples are processed into useful information. As we described in +previous sections, the kernel OProfile driver creates a large buffer of +sample data consisting of offset values, interspersed with +notification of changes in context. These context changes indicate how +following samples should be attributed, and include task switches, CPU +changes, and which dcookie the sample value is against. By processing +this buffer entry-by-entry, we can determine where the samples should +be accredited to. This is particularly important when using the +--separate. +

+

+The file daemon/opd_trans.c contains the basic routine +for the buffer processing. The struct transient +structure is used to hold changes in context. Its members are modified +as we process each entry; it is passed into the routines in +daemon/opd_sfile.c for actually logging the sample +to a particular sample file (which will be held in +/var/lib/oprofile/samples/current). +

+

+The buffer format is designed for conciseness, as high sampling rates +can easily generate a lot of data. Thus, context changes are prefixed +by an escape code, identified by is_escape_code(). +If an escape code is found, the next entry in the buffer identifies +what type of context change is being read. These are handed off to +various handlers (see the handlers array), which +modify the transient structure as appropriate. If it's not an escape +code, then it must be a PC offset value, and the very next entry will +be the numeric hardware counter. These values are read and recorded +in the transient structure; we then do a lookup to find the correct +sample file, and log the sample, as described in the next section. +

+
+
+
+
+

1.1. Handling kernel samples

+
+
+
+

+Samples from kernel code require a little special handling. Because +the binary text which the sample is against does not correspond to +any file that the kernel directly knows about, the OProfile driver +stores the absolute PC value in the buffer, instead of the file offset. +Of course, we need an offset against some particular binary. To handle +this, we keep a list of loaded modules by parsing +/proc/modules as needed. When a module is loaded, +a notification is placed in the OProfile buffer, and this triggers a +re-read. We store the module name, and the loading address and size. +This is also done for the main kernel image, as specified by the user. +The absolute PC value is matched against each address range, and +modified into an offset when the matching module is found. See +daemon/opd_kernel.c for the details. +

+
+
+
+
+
+
+

2. Locating and creating sample files

+
+
+
+

+We have a sample value and its satellite data stored in a +struct transient, and we must locate an +actual sample file to store the sample in, using the context +information in the transient structure as a key. The transient data to +sample file lookup is handled in +daemon/opd_sfile.c. A hash is taken of the +transient values that are relevant (depending upon the setting of +--separate, some values might be irrelevant), and the +hash value is used to lookup the list of currently open sample files. +Of course, the sample file might not be found, in which case we need +to create and open it. +

+

+OProfile uses a rather complex scheme for naming sample files, in order +to make selecting relevant sample files easier for the post-profiling +utilities. The exact details of the scheme are given in +oprofile-tests/pp_interface, but for now it will +suffice to remember that the filename will include only relevant +information for the current settings, taken from the transient data. A +fully-specified filename looks something like : +

+ +/var/lib/oprofile/samples/current/{root}/usr/bin/xmms/{dep}/{root}/lib/tls/libc-2.3.2.so/CPU_CLK_UNHALTED.100000.0.28082.28089.0 + +

+It should be clear that this identifies such information as the +application binary, the dependent (library) binary, the hardware event, +and the process and thread ID. Typically, not all this information is +needed, in which cases some values may be replaced with the token +all. +

+

+The code that generates this filename and opens the file is found in +daemon/opd_mangling.c. You may have realised that +at this point, we do not have the binary image file names, only the +dcookie values. In order to determine a file name, a dcookie value is +looked up in the dcookie cache. This is to be found in +daemon/opd_cookie.c. Since dcookies are both +persistent and unique during a sampling session, we can cache the +values. If the value is not found in the cache, then we ask the kernel +to do the lookup from value to file name for us by calling +lookup_dcookie(). This looks up the value in a +kernel-side cache (see fs/dcookies.c) and returns +the fully-qualified file name to userspace. +

+
+
+
+
+
+

3. Writing data to a sample file

+
+
+
+

+Each specific sample file is a hashed collection, where the key is +the PC offset from the transient data, and the value is the number of +samples recorded against that offset. The files are +mmap()ed into the daemon's memory space. The code +to actually log the write against the sample file can be found in +libdb/. +

+

+For recording stack traces, we have a more complicated sample filename +mangling scheme that allows us to identify cross-binary calls. We use +the same sample file format, where the key is a 64-bit value composed +from the from,to pair of offsets. +

+
+
+
+
+
+
+

Chapter 5. Generating useful output

+
+
+
+ +

+All of the tools used to generate human-readable output have to take +roughly the same steps to collect the data for processing. First, the +profile specification given by the user has to be parsed. Next, a list +of sample files matching the specification has to obtained. Using this +list, we need to locate the binary file for each sample file, and then +use them to extract meaningful data, before a final collation and +presentation to the user. +

+
+
+
+
+

1. Handling the profile specification

+
+
+
+

+The profile specification presented by the user is parsed in +the function profile_spec::create(). This +creates an object representing the specification. Then we +use profile_spec::generate_file_list() +to search for all sample files and match them against the +profile_spec. +

+

+To enable this matching process to work, the attributes of +each sample file is encoded in its filename. This is a low-tech +approach to matching specifications against candidate sample +files, but it works reasonably well. A typical sample file +might look like these: +

+ + + + +
+
+/var/lib/oprofile/samples/current/{root}/bin/ls/{dep}/{root}/bin/ls/{cg}/{root}/bin/ls/CPU_CLK_UNHALTED.100000.0.all.all.all
+/var/lib/oprofile/samples/current/{root}/bin/ls/{dep}/{root}/bin/ls/CPU_CLK_UNHALTED.100000.0.all.all.all
+/var/lib/oprofile/samples/current/{root}/bin/ls/{dep}/{root}/bin/ls/CPU_CLK_UNHALTED.100000.0.7423.7424.0
+/var/lib/oprofile/samples/current/{kern}/r128/{dep}/{kern}/r128/CPU_CLK_UNHALTED.100000.0.all.all.all
+
+
+

+This looks unnecessarily complex, but it's actually fairly simple. First +we have the session of the sample, here +/var/lib/oprofile/samples/current. This could +equally well be inside an archive from oparchive. +Next we have one of the tokens {root} or +{kern}. {root} indicates +that the binary is found on a file system, and we will encode its path +in the next section (e.g. /bin/ls). +{kern} indicates a kernel module - on 2.6 kernels +the path information is not available from the kernel, so we have to +special-case kernel modules like this; we encode merely the name of the +module as loaded. +

+

+Next there is a {dep} token, indicating another +token/path which identifies the dependent binary image. This is used even for +the "primary" binary (i.e. the one that was +execve()d), as it simplifies processing. Finally, +if this sample file is a normal flat profile, the actual file is next in +the path. If it's a call-graph sample file, we need one further +specification, to allow us to identify cross-binary arcs in the call +graph. +

+

+The actual sample file name is dot-separated, where the fields are, in +order: event name, event count, unit mask, task group ID, task ID, and +CPU number. +

+

+This sample file can be reliably parsed (with +parse_filename()) into a +filename_spec. Finally, we can check whether to +include the sample file in the final results by comparing this +filename_spec against the +profile_spec the user specified (for the interested, +see valid_candidate() and +profile_spec::match). Then comes the really +complicated bit... +

+
+
+
+
+
+

2. Collating the candidate sample files

+
+
+
+

+At this point we have a duplicate-free list of sample files we need +to process. But first we need to do some further arrangement: we +need to classify each sample file, and we may also need to "invert" +the profiles. +

+
+
+
+
+

2.1. Classifying sample files

+
+
+
+

+It's possible for utilities like opreport to show +data in columnar format: for example, we might want to show the results +of two threads within a process side-by-side. To do this, we need +to classify each sample file into classes - the classes correspond +with each opreport column. The function that handles +this is arrange_profiles(). Each sample file +is added to a particular class. If the sample file is the first in +its class, a template is generated from the sample file. Each template +describes a particular class (thus, in our example above, each template +will have a different thread ID, and this uniquely identifies each +class). +

+

+Each class has a list of "profile sets" matching that class's template. +A profile set is either a profile of the primary binary image, or any of +its dependent images. After all sample files have been listed in one of +the profile sets belonging to the classes, we have to name each class and +perform error-checking. This is done by +identify_classes(); each class is checked to ensure +that its "axis" is the same as all the others. This is needed because +opreport can't produce results in 3D format: we can +only differ in one aspect, such as thread ID or event name. +

+
+
+
+
+
+

2.2. Creating inverted profile lists

+
+
+
+

+Remember that if we're using certain profile separation options, such as +"--separate=lib", a single binary could be a dependent image to many +different binaries. For example, the C library image would be a +dependent image for most programs that have been profiled. As it +happens, this can cause severe performance problems: without some +re-arrangement, these dependent binary images would be opened each +time we need to process sample files for each program. +

+

+The solution is to "invert" the profiles via +invert_profiles(). We create a new data structure +where the dependent binary is first, and the primary binary images using +that dependent binary are listed as sub-images. This helps our +performance problem, as now we only need to open each dependent image +once, when we process the list of inverted profiles. +

+
+
+
+
+
+
+

3. Generating profile data

+
+
+
+

+Things don't get any simpler at this point, unfortunately. At this point +we've collected and classified the sample files into the set of inverted +profiles, as described in the previous section. Now we need to process +each inverted profile and make something of the data. The entry point +for this is populate_for_image(). +

+
+
+
+
+

3.1. Processing the binary image

+
+
+
+

+The first thing we do with an inverted profile is attempt to open the +binary image (remember each inverted profile set is only for one binary +image, but may have many sample files to process). The +op_bfd class provides an abstracted interface to +this; internally it uses libbfd. The main purpose +of this class is to process the symbols for the binary image; this is +also where symbol filtering happens. This is actually quite tricky, but +should be clear from the source. +

+
+
+
+
+
+

3.2. Processing the sample files

+
+
+
+

+The class profile_container is a hold-all that +contains all the processed results. It is a container of +profile_t objects. The +add_sample_files() method uses +libdb to open the given sample file and add the +key/value types to the profile_t. Once this has been +done, profile_container::add() is passed the +profile_t plus the op_bfd for +processing. +

+

+profile_container::add() walks through the symbols +collected in the op_bfd. +op_bfd::get_symbol_range() gives us the start and +end of the symbol as an offset from the start of the binary image, +then we interrogate the profile_t for the relevant samples +for that offset range. We create a symbol_entry +object for this symbol and fill it in. If needed, here we also collect +debug information from the op_bfd, and possibly +record the detailed sample information (as used by opreport +-d and opannotate). +Finally the symbol_entry is added to +a private container of profile_container - this +symbol_container holds all such processed symbols. +

+
+
+
+
+
+
+

4. Generating output

+
+
+
+

+After the processing described in the previous section, we've now got +full details of what we need to output stored in the +profile_container on a symbol-by-symbol basis. To +produce output, we need to replay that data and format it suitably. +

+

+opreport first asks the +profile_container for a +symbol_collection (this is also where thresholding +happens). +This is sorted, then a +opreport_formatter is initialised. +This object initialises a set of field formatters as requested. Then +opreport_formatter::output() is called. This +iterates through the (sorted) symbol_collection; +for each entry, the selected fields (as set by the +format_flags options) are output by calling the +field formatters, with the symbol_entry passed in. +

+
+
+
+
+
+
+

Glossary of OProfile source concepts and types

+
+
+
+
+
application image
+
+

+The primary binary image used by an application. This is derived +from the kernel and corresponds to the binary started upon running +an application: for example, /bin/bash. +

+
+
binary image
+
+

+An ELF file containing executable code: this includes kernel modules, +the kernel itself (a.k.a. vmlinux), shared libraries, +and application binaries. +

+
+
dcookie
+
+

+Short for "dentry cookie". A unique ID that can be looked up to provide +the full path name of a binary image. +

+
+
dependent image
+
+

+A binary image that is dependent upon an application, used with +per-application separation. Most commonly, shared libraries. For example, +if /bin/bash is running and we take +some samples inside the C library itself due to bash +calling library code, then the image /lib/libc.so +would be dependent upon /bin/bash. +

+
+
merging
+
+

+This refers to the ability to merge several distinct sample files +into one set of data at runtime, in the post-profiling tools. For example, +per-thread sample files can be merged into one set of data, because +they are compatible (i.e. the aggregation of the data is meaningful), +but it's not possible to merge sample files for two different events, +because there would be no useful meaning to the results. +

+
+
profile class
+
+

+A collection of profile data that has been collected under the same +class template. For example, if we're using opreport +to show results after profiling with two performance counters enabled +profiling DATA_MEM_REFS and CPU_CLK_UNHALTED, +there would be two profile classes, one for each event. Or if we're on +an SMP system and doing per-cpu profiling, and we request +opreport to show results for each CPU side-by-side, +there would be a profile class for each CPU. +

+
+
profile specification
+
+

+The parameters the user passes to the post-profiling tools that limit +what sample files are used. This specification is matched against +the available sample files to generate a selection of profile data. +

+
+
profile template
+
+

+The parameters that define what goes in a particular profile class. +This includes a symbolic name (e.g. "cpu:1") and the code-usable +equivalent. +

+
+
+
+
+ + diff --git a/doc/internals.xml b/doc/internals.xml new file mode 100644 index 0000000..d2e89f4 --- /dev/null +++ b/doc/internals.xml @@ -0,0 +1,972 @@ + + + + + + OProfile Internals + + + + John + Levon + +
levon@movementarian.org
+
+
+
+ + + 2003 + John Levon + +
+ + + + +Introduction + + +This document is current for OProfile version . +This document provides some details on the internal workings of OProfile for the +interested hacker. This document assumes strong C, working C++, plus some knowledge of +kernel internals and CPU hardware. + + + +Only the "new" implementation associated with kernel 2.6 and above is covered here. 2.4 +uses a very different kernel module implementation and daemon to produce the sample files. + + + + +Overview + +OProfile is a statistical continuous profiler. In other words, profiles are generated by +regularly sampling the current registers on each CPU (from an interrupt handler, the +saved PC value at the time of interrupt is stored), and converting that runtime PC +value into something meaningful to the programmer. + + +OProfile achieves this by taking the stream of sampled PC values, along with the detail +of which task was running at the time of the interrupt, and converting into a file offset +against a particular binary file. Because applications mmap() +the code they run (be it /bin/bash, /lib/libfoo.so +or whatever), it's possible to find the relevant binary file and offset by walking +the task's list of mapped memory areas. Each PC value is thus converted into a tuple +of binary-image,offset. This is something that the userspace tools can use directly +to reconstruct where the code came from, including the particular assembly instructions, +symbol, and source line (via the binary's debug information if present). + + +Regularly sampling the PC value like this approximates what actually was executed and +how often - more often than not, this statistical approximation is good enough to +reflect reality. In common operation, the time between each sample interrupt is regulated +by a fixed number of clock cycles. This implies that the results will reflect where +the CPU is spending the most time; this is obviously a very useful information source +for performance analysis. + + +Sometimes though, an application programmer needs different kinds of information: for example, +"which of the source routines cause the most cache misses ?". The rise in importance of +such metrics in recent years has led many CPU manufacturers to provide hardware performance +counters capable of measuring these events on the hardware level. Typically, these counters +increment once per each event, and generate an interrupt on reaching some pre-defined +number of events. OProfile can use these interrupts to generate samples: then, the +profile results are a statistical approximation of which code caused how many of the +given event. + + +Consider a simplified system that only executes two functions A and B. A +takes one cycle to execute, whereas B takes 99 cycles. Imagine we run at +100 cycles a second, and we've set the performance counter to create an +interrupt after a set number of "events" (in this case an event is one +clock cycle). It should be clear that the chances of the interrupt +occurring in function A is 1/100, and 99/100 for function B. Thus, we +statistically approximate the actual relative performance features of +the two functions over time. This same analysis works for other types of +events, providing that the interrupt is tied to the number of events +occurring (that is, after N events, an interrupt is generated). + + +There are typically more than one of these counters, so it's possible to set up profiling +for several different event types. Using these counters gives us a powerful, low-overhead +way of gaining performance metrics. If OProfile, or the CPU, does not support performance +counters, then a simpler method is used: the kernel timer interrupt feeds samples +into OProfile itself. + + +The rest of this document concerns itself with how we get from receiving samples at +interrupt time to producing user-readable profile information. + + + + +Components of the OProfile system + + +Architecture-specific components + +If OProfile supports the hardware performance counters found on +a particular architecture, code for managing the details of setting +up and managing these counters can be found in the kernel source +tree in the relevant arch/arch/oprofile/ +directory. The architecture-specific implementation works via +filling in the oprofile_operations structure at init time. This +provides a set of operations such as setup(), +start(), stop(), etc. +that manage the hardware-specific details of fiddling with the +performance counter registers. + + +The other important facility available to the architecture code is +oprofile_add_sample(). This is where a particular sample +taken at interrupt time is fed into the generic OProfile driver code. + + + + +oprofilefs + +OProfile implements a pseudo-filesystem known as "oprofilefs", mounted from +userspace at /dev/oprofile. This consists of small +files for reporting and receiving configuration from userspace, as well +as the actual character device that the OProfile userspace receives samples +from. At setup() time, the architecture-specific may +add further configuration files related to the details of the performance +counters. For example, on x86, one numbered directory for each hardware +performance counter is added, with files in each for the event type, +reset value, etc. + + +The filesystem also contains a stats directory with +a number of useful counters for various OProfile events. + + + + +Generic kernel driver + +This lives in drivers/oprofile/, and forms the core of +how OProfile works in the kernel. Its job is to take samples delivered +from the architecture-specific code (via oprofile_add_sample()), +and buffer this data, in a transformed form as described later, until releasing +the data to the userspace daemon via the /dev/oprofile/buffer +character device. + + + + +The OProfile daemon + +The OProfile userspace daemon's job is to take the raw data provided by the +kernel and write it to the disk. It takes the single data stream from the +kernel and logs sample data against a number of sample files (found in +/var/lib/oprofile/samples/current/. For the benefit +of the "separate" functionality, the names/paths of these sample files +are mangled to reflect where the samples were from: this can include +thread IDs, the binary file path, the event type used, and more. + + +After this final step from interrupt to disk file, the data is now +persistent (that is, changes in the running of the system do not invalidate +stored data). So the post-profiling tools can run on this data at any +time (assuming the original binary files are still available and unchanged, +naturally). + + + + +Post-profiling tools +So far, we've collected data, but we've yet to present it in a useful form +to the user. This is the job of the post-profiling tools. In general form, +they collate a subset of the available sample files, load and process each one +correlated against the relevant binary file, and finally produce user-readable +information. + + + + + + + +Performance counter management + + +Providing a user interface + + +The performance counter registers need programming in order to set the +type of event to count, etc. OProfile uses a standard model across all +CPUs for defining these events as follows : + + + + +The event type e.g. DATA_MEM_REFS +The sub-events to count (more detailed specification) +The hardware counter(s) that can count this event +The reset value (how many events before an interrupt) +Whether the counter should increment when in kernel space +Whether the counter should increment when in user space + + + + +The term "unit mask" is borrowed from the Intel architectures, and can +further specify exactly when a counter is incremented (for example, +cache-related events can be restricted to particular state transitions +of the cache lines). + + +All of the available hardware events and their details are specified in +the textual files in the events directory. The +syntax of these files should be fairly obvious. The user specifies the +names and configuration details of the chosen counters via +opcontrol. These are then written to the kernel +module (in numerical form) via /dev/oprofile/N/ +where N is the physical hardware counter (some events can only be used +on specific counters; OProfile hides these details from the user when +possible). On IA64, the perfmon-based interface behaves somewhat +differently, as described later. + + + + + +Programming the performance counter registers + + +We have described how the user interface fills in the desired +configuration of the counters and transmits the information to the +kernel. It is the job of the ->setup() method +to actually program the performance counter registers. Clearly, the +details of how this is done is architecture-specific; it is also +model-specific on many architectures. For example, i386 provides methods +for each model type that programs the counter registers correctly +(see the op_model_* files in +arch/i386/oprofile for the details). The method +reads the values stored in the virtual oprofilefs files and programs +the registers appropriately, ready for starting the actual profiling +session. + + +The architecture-specific drivers make sure to save the old register +settings before doing OProfile setup. They are restored when OProfile +shuts down. This is useful, for example, on i386, where the NMI watchdog +uses the same performance counter registers as OProfile; they cannot +run concurrently, but OProfile makes sure to restore the setup it found +before it was running. + + +In addition to programming the counter registers themselves, other setup +is often necessary. For example, on i386, the local APIC needs +programming in order to make the counter's overflow interrupt appear as +an NMI (non-maskable interrupt). This allows sampling (and therefore +profiling) of regions where "normal" interrupts are masked, enabling +more reliable profiles. + + + +Starting and stopping the counters + +Initiating a profiling session is done via writing an ASCII '1' +to the file /dev/oprofile/enable. This sets up the +core, and calls into the architecture-specific driver to actually +enable each configured counter. Again, the details of how this is +done is model-specific (for example, the Athlon models can disable +or enable on a per-counter basis, unlike the PPro models). + + + + +IA64 and perfmon + +The IA64 architecture provides a different interface from the other +architectures, using the existing perfmon driver. Register programming +is handled entirely in user-space (see +daemon/opd_perfmon.c for the details). A process +is forked for each CPU, which creates a perfmon context and sets the +counter registers appropriately via the +sys_perfmonctl interface. In addition, the actual +initiation and termination of the profiling session is handled via the +same interface using PFM_START and +PFM_STOP. On IA64, then, there are no oprofilefs +files for the performance counters, as the kernel driver does not +program the registers itself. + + +Instead, the perfmon driver for OProfile simply registers with the +OProfile core with an OProfile-specific UUID. During a profiling +session, the perfmon core calls into the OProfile perfmon driver and +samples are registered with the OProfile core itself as usual (with +oprofile_add_sample()). + + + + + + + + +Collecting and processing samples + + +Receiving interrupts + +Naturally, how the overflow interrupts are received is specific +to the hardware architecture, unless we are in "timer" mode, where the +logging routine is called directly from the standard kernel timer +interrupt handler. + + +On the i386 architecture, the local APIC is programmed such that when a +counter overflows (that is, it receives an event that causes an integer +overflow of the register value to zero), an NMI is generated. This calls +into the general handler do_nmi(); because OProfile +has registered itself as capable of handling NMI interrupts, this will +call into the OProfile driver code in +arch/i386/oprofile. Here, the saved PC value (the +CPU saves the register set at the time of interrupt on the stack +available for inspection) is extracted, and the counters are examined to +find out which one generated the interrupt. Also determined is whether +the system was inside kernel or user space at the time of the interrupt. +These three pieces of information are then forwarded onto the OProfile +core via oprofile_add_sample(). Finally, the +counter values are reset to the chosen count value, to ensure another +interrupt happens after another N events have occurred. Other +architectures behave in a similar manner. + + + + +Core data structures + +Before considering what happens when we log a sample, we shall digress +for a moment and look at the general structure of the data collection +system. + + +OProfile maintains a small buffer for storing the logged samples for +each CPU on the system. Only this buffer is altered when we actually log +a sample (remember, we may still be in an NMI context, so no locking is +possible). The buffer is managed by a two-handed system; the "head" +iterator dictates where the next sample data should be placed in the +buffer. Of course, overflow of the buffer is possible, in which case +the sample is discarded. + + +It is critical to remember that at this point, the PC value is an +absolute value, and is therefore only meaningful in the context of which +task it was logged against. Thus, these per-CPU buffers also maintain +details of which task each logged sample is for, as described in the +next section. In addition, we store whether the sample was in kernel +space or user space (on some architectures and configurations, the address +space is not sub-divided neatly at a specific PC value, so we must store +this information). + + +As well as these small per-CPU buffers, we have a considerably larger +single buffer. This holds the data that is eventually copied out into +the OProfile daemon. On certain system events, the per-CPU buffers are +processed and entered (in mutated form) into the main buffer, known in +the source as the "event buffer". The "tail" iterator indicates the +point from which the CPU may be read, up to the position of the "head" +iterator. This provides an entirely lock-free method for extracting data +from the CPU buffers. This process is described in detail later in this chapter. + +
The OProfile buffers + +
+
+ + +Logging a sample + +As mentioned, the sample is logged into the buffer specific to the +current CPU. The CPU buffer is a simple array of pairs of unsigned long +values; for a sample, they hold the PC value and the counter for the +sample. (The counter value is later used to translate back into the relevant +event type the counter was programmed to). + + +In addition to logging the sample itself, we also log task switches. +This is simply done by storing the address of the last task to log a +sample on that CPU in a data structure, and writing a task switch entry +into the buffer if the new value of current() has +changed. Note that later we will directly de-reference this pointer; +this imposes certain restrictions on when and how the CPU buffers need +to be processed. + + +Finally, as mentioned, we log whether we have changed between kernel and +userspace using a similar method. Both of these variables +(last_task and last_is_kernel) are +reset when the CPU buffer is read. + + + + +Logging stack traces + +OProfile can also provide statistical samples of call chains (on x86). To +do this, at sample time, the frame pointer chain is traversed, recording +the return address for each stack frame. This will only work if the code +was compiled with frame pointers, but we're careful to abort the +traversal if the frame pointer appears bad. We store the set of return +addresses straight into the CPU buffer. Note that, since this traversal +is keyed off the standard sample interrupt, the number of times a +function appears in a stack trace is not an indicator of how many times +the call site was executed: rather, it's related to the number of +samples we took where that call site was involved. Thus, the results for +stack traces are not necessarily proportional to the call counts: +typical programs will have many main() samples. + + + + +Synchronising the CPU buffers to the event buffer + + +At some point, we have to process the data in each CPU buffer and enter +it into the main (event) buffer. The file +buffer_sync.c contains the relevant code. We +periodically (currently every HZ/4 jiffies) start +the synchronisation process. In addition, we process the buffers on +certain events, such as an application calling +munmap(). This is particularly important for +exit() - because the CPU buffers contain pointers +to the task structure, if we don't process all the buffers before the +task is actually destroyed and the task structure freed, then we could +end up trying to dereference a bogus pointer in one of the CPU buffers. + + +We also add a notification when a kernel module is loaded; this is so +that user-space can re-read /proc/modules to +determine the load addresses of kernel module text sections. Without +this notification, samples for a newly-loaded module could get lost or +be attributed to the wrong module. + + +The synchronisation itself works in the following manner: first, mutual +exclusion on the event buffer is taken. Remember, we do not need to do +that for each CPU buffer, as we only read from the tail iterator (whilst +interrupts might be arriving at the same buffer, but they will write to +the position of the head iterator, leaving previously written entries +intact). Then, we process each CPU buffer in turn. A CPU switch +notification is added to the buffer first (for + support). Then the processing of the +actual data starts. + + +As mentioned, the CPU buffer consists of task switch entries and the +actual samples. When the routine sync_buffer() sees +a task switch, the process ID and process group ID are recorded into the +event buffer, along with a dcookie (see below) identifying the +application binary (e.g. /bin/bash). The +mmap_sem for the task is then taken, to allow safe +iteration across the tasks' list of mapped areas. Each sample is then +processed as described in the next section. + + +After a buffer has been read, the tail iterator is updated to reflect +how much of the buffer was processed. Note that when we determined how +much data there was to read in the CPU buffer, we also called +cpu_buffer_reset() to reset +last_task and last_is_kernel, as +we've already mentioned. During the processing, more samples may have +been arriving in the CPU buffer; this is OK because we are careful to +only update the tail iterator to how much we actually read - on the next +buffer synchronisation, we will start again from that point. + + + + +Identifying binary images + +In order to produce useful profiles, we need to be able to associate a +particular PC value sample with an actual ELF binary on the disk. This +leaves us with the problem of how to export this information to +user-space. We create unique IDs that identify a particular directory +entry (dentry), and write those IDs into the event buffer. Later on, +the user-space daemon can call the lookup_dcookie +system call, which looks up the ID and fills in the full path of +the binary image in the buffer user-space passes in. These IDs are +maintained by the code in fs/dcookies.c; the +cache lasts for as long as the daemon has the event buffer open. + + + + +Finding a sample's binary image and offset + +We haven't yet described how we process the absolute PC value into +something usable by the user-space daemon. When we find a sample entered +into the CPU buffer, we traverse the list of mappings for the task +(remember, we will have seen a task switch earlier, so we know which +task's lists to look at). When a mapping is found that contains the PC +value, we look up the mapped file's dentry in the dcookie cache. This +gives the dcookie ID that will uniquely identify the mapped file. Then +we alter the absolute value such that it is an offset from the start of +the file being mapped (the mapping need not start at the start of the +actual file, so we have to consider the offset value of the mapping). We +store this dcookie ID into the event buffer; this identifies which +binary the samples following it are against. +In this manner, we have converted a PC value, which has transitory +meaning only, into a static offset value for later processing by the +daemon. + + +We also attempt to avoid the relatively expensive lookup of the dentry +cookie value by storing the cookie value directly into the dentry +itself; then we can simply derive the cookie value immediately when we +find the correct mapping. + + + +
+ + +Generating sample files + + +Processing the buffer + + +Now we can move onto user-space in our description of how raw interrupt +samples are processed into useful information. As we described in +previous sections, the kernel OProfile driver creates a large buffer of +sample data consisting of offset values, interspersed with +notification of changes in context. These context changes indicate how +following samples should be attributed, and include task switches, CPU +changes, and which dcookie the sample value is against. By processing +this buffer entry-by-entry, we can determine where the samples should +be accredited to. This is particularly important when using the +. + + +The file daemon/opd_trans.c contains the basic routine +for the buffer processing. The struct transient +structure is used to hold changes in context. Its members are modified +as we process each entry; it is passed into the routines in +daemon/opd_sfile.c for actually logging the sample +to a particular sample file (which will be held in +/var/lib/oprofile/samples/current). + + +The buffer format is designed for conciseness, as high sampling rates +can easily generate a lot of data. Thus, context changes are prefixed +by an escape code, identified by is_escape_code(). +If an escape code is found, the next entry in the buffer identifies +what type of context change is being read. These are handed off to +various handlers (see the handlers array), which +modify the transient structure as appropriate. If it's not an escape +code, then it must be a PC offset value, and the very next entry will +be the numeric hardware counter. These values are read and recorded +in the transient structure; we then do a lookup to find the correct +sample file, and log the sample, as described in the next section. + + + +Handling kernel samples + + +Samples from kernel code require a little special handling. Because +the binary text which the sample is against does not correspond to +any file that the kernel directly knows about, the OProfile driver +stores the absolute PC value in the buffer, instead of the file offset. +Of course, we need an offset against some particular binary. To handle +this, we keep a list of loaded modules by parsing +/proc/modules as needed. When a module is loaded, +a notification is placed in the OProfile buffer, and this triggers a +re-read. We store the module name, and the loading address and size. +This is also done for the main kernel image, as specified by the user. +The absolute PC value is matched against each address range, and +modified into an offset when the matching module is found. See +daemon/opd_kernel.c for the details. + + + + + + + + +Locating and creating sample files + + +We have a sample value and its satellite data stored in a +struct transient, and we must locate an +actual sample file to store the sample in, using the context +information in the transient structure as a key. The transient data to +sample file lookup is handled in +daemon/opd_sfile.c. A hash is taken of the +transient values that are relevant (depending upon the setting of +, some values might be irrelevant), and the +hash value is used to lookup the list of currently open sample files. +Of course, the sample file might not be found, in which case we need +to create and open it. + + +OProfile uses a rather complex scheme for naming sample files, in order +to make selecting relevant sample files easier for the post-profiling +utilities. The exact details of the scheme are given in +oprofile-tests/pp_interface, but for now it will +suffice to remember that the filename will include only relevant +information for the current settings, taken from the transient data. A +fully-specified filename looks something like : + + +/var/lib/oprofile/samples/current/{root}/usr/bin/xmms/{dep}/{root}/lib/tls/libc-2.3.2.so/CPU_CLK_UNHALTED.100000.0.28082.28089.0 + + +It should be clear that this identifies such information as the +application binary, the dependent (library) binary, the hardware event, +and the process and thread ID. Typically, not all this information is +needed, in which cases some values may be replaced with the token +all. + + +The code that generates this filename and opens the file is found in +daemon/opd_mangling.c. You may have realised that +at this point, we do not have the binary image file names, only the +dcookie values. In order to determine a file name, a dcookie value is +looked up in the dcookie cache. This is to be found in +daemon/opd_cookie.c. Since dcookies are both +persistent and unique during a sampling session, we can cache the +values. If the value is not found in the cache, then we ask the kernel +to do the lookup from value to file name for us by calling +lookup_dcookie(). This looks up the value in a +kernel-side cache (see fs/dcookies.c) and returns +the fully-qualified file name to userspace. + + + + + +Writing data to a sample file + + +Each specific sample file is a hashed collection, where the key is +the PC offset from the transient data, and the value is the number of +samples recorded against that offset. The files are +mmap()ed into the daemon's memory space. The code +to actually log the write against the sample file can be found in +libdb/. + + +For recording stack traces, we have a more complicated sample filename +mangling scheme that allows us to identify cross-binary calls. We use +the same sample file format, where the key is a 64-bit value composed +from the from,to pair of offsets. + + + + + + + +Generating useful output + + +All of the tools used to generate human-readable output have to take +roughly the same steps to collect the data for processing. First, the +profile specification given by the user has to be parsed. Next, a list +of sample files matching the specification has to obtained. Using this +list, we need to locate the binary file for each sample file, and then +use them to extract meaningful data, before a final collation and +presentation to the user. + + + +Handling the profile specification + + +The profile specification presented by the user is parsed in +the function profile_spec::create(). This +creates an object representing the specification. Then we +use profile_spec::generate_file_list() +to search for all sample files and match them against the +profile_spec. + + + +To enable this matching process to work, the attributes of +each sample file is encoded in its filename. This is a low-tech +approach to matching specifications against candidate sample +files, but it works reasonably well. A typical sample file +might look like these: + + +/var/lib/oprofile/samples/current/{root}/bin/ls/{dep}/{root}/bin/ls/{cg}/{root}/bin/ls/CPU_CLK_UNHALTED.100000.0.all.all.all +/var/lib/oprofile/samples/current/{root}/bin/ls/{dep}/{root}/bin/ls/CPU_CLK_UNHALTED.100000.0.all.all.all +/var/lib/oprofile/samples/current/{root}/bin/ls/{dep}/{root}/bin/ls/CPU_CLK_UNHALTED.100000.0.7423.7424.0 +/var/lib/oprofile/samples/current/{kern}/r128/{dep}/{kern}/r128/CPU_CLK_UNHALTED.100000.0.all.all.all + + +This looks unnecessarily complex, but it's actually fairly simple. First +we have the session of the sample, here +/var/lib/oprofile/samples/current. This could +equally well be inside an archive from oparchive. +Next we have one of the tokens {root} or +{kern}. {root} indicates +that the binary is found on a file system, and we will encode its path +in the next section (e.g. /bin/ls). +{kern} indicates a kernel module - on 2.6 kernels +the path information is not available from the kernel, so we have to +special-case kernel modules like this; we encode merely the name of the +module as loaded. + + +Next there is a {dep} token, indicating another +token/path which identifies the dependent binary image. This is used even for +the "primary" binary (i.e. the one that was +execve()d), as it simplifies processing. Finally, +if this sample file is a normal flat profile, the actual file is next in +the path. If it's a call-graph sample file, we need one further +specification, to allow us to identify cross-binary arcs in the call +graph. + + +The actual sample file name is dot-separated, where the fields are, in +order: event name, event count, unit mask, task group ID, task ID, and +CPU number. + + +This sample file can be reliably parsed (with +parse_filename()) into a +filename_spec. Finally, we can check whether to +include the sample file in the final results by comparing this +filename_spec against the +profile_spec the user specified (for the interested, +see valid_candidate() and +profile_spec::match). Then comes the really +complicated bit... + + + + + +Collating the candidate sample files + + +At this point we have a duplicate-free list of sample files we need +to process. But first we need to do some further arrangement: we +need to classify each sample file, and we may also need to "invert" +the profiles. + + + +Classifying sample files + + +It's possible for utilities like opreport to show +data in columnar format: for example, we might want to show the results +of two threads within a process side-by-side. To do this, we need +to classify each sample file into classes - the classes correspond +with each opreport column. The function that handles +this is arrange_profiles(). Each sample file +is added to a particular class. If the sample file is the first in +its class, a template is generated from the sample file. Each template +describes a particular class (thus, in our example above, each template +will have a different thread ID, and this uniquely identifies each +class). + + + +Each class has a list of "profile sets" matching that class's template. +A profile set is either a profile of the primary binary image, or any of +its dependent images. After all sample files have been listed in one of +the profile sets belonging to the classes, we have to name each class and +perform error-checking. This is done by +identify_classes(); each class is checked to ensure +that its "axis" is the same as all the others. This is needed because +opreport can't produce results in 3D format: we can +only differ in one aspect, such as thread ID or event name. + + + + + +Creating inverted profile lists + + +Remember that if we're using certain profile separation options, such as +"--separate=lib", a single binary could be a dependent image to many +different binaries. For example, the C library image would be a +dependent image for most programs that have been profiled. As it +happens, this can cause severe performance problems: without some +re-arrangement, these dependent binary images would be opened each +time we need to process sample files for each program. + + + +The solution is to "invert" the profiles via +invert_profiles(). We create a new data structure +where the dependent binary is first, and the primary binary images using +that dependent binary are listed as sub-images. This helps our +performance problem, as now we only need to open each dependent image +once, when we process the list of inverted profiles. + + + + + + + +Generating profile data + + +Things don't get any simpler at this point, unfortunately. At this point +we've collected and classified the sample files into the set of inverted +profiles, as described in the previous section. Now we need to process +each inverted profile and make something of the data. The entry point +for this is populate_for_image(). + + + +Processing the binary image + +The first thing we do with an inverted profile is attempt to open the +binary image (remember each inverted profile set is only for one binary +image, but may have many sample files to process). The +op_bfd class provides an abstracted interface to +this; internally it uses libbfd. The main purpose +of this class is to process the symbols for the binary image; this is +also where symbol filtering happens. This is actually quite tricky, but +should be clear from the source. + + + + +Processing the sample files + +The class profile_container is a hold-all that +contains all the processed results. It is a container of +profile_t objects. The +add_sample_files() method uses +libdb to open the given sample file and add the +key/value types to the profile_t. Once this has been +done, profile_container::add() is passed the +profile_t plus the op_bfd for +processing. + + +profile_container::add() walks through the symbols +collected in the op_bfd. +op_bfd::get_symbol_range() gives us the start and +end of the symbol as an offset from the start of the binary image, +then we interrogate the profile_t for the relevant samples +for that offset range. We create a symbol_entry +object for this symbol and fill it in. If needed, here we also collect +debug information from the op_bfd, and possibly +record the detailed sample information (as used by opreport +-d and opannotate). +Finally the symbol_entry is added to +a private container of profile_container - this +symbol_container holds all such processed symbols. + + + + + + +Generating output + + +After the processing described in the previous section, we've now got +full details of what we need to output stored in the +profile_container on a symbol-by-symbol basis. To +produce output, we need to replay that data and format it suitably. + + +opreport first asks the +profile_container for a +symbol_collection (this is also where thresholding +happens). +This is sorted, then a +opreport_formatter is initialised. +This object initialises a set of field formatters as requested. Then +opreport_formatter::output() is called. This +iterates through the (sorted) symbol_collection; +for each entry, the selected fields (as set by the +format_flags options) are output by calling the +field formatters, with the symbol_entry passed in. + + + + + + + +Glossary of OProfile source concepts and types + +application image + +The primary binary image used by an application. This is derived +from the kernel and corresponds to the binary started upon running +an application: for example, /bin/bash. + + +binary image + +An ELF file containing executable code: this includes kernel modules, +the kernel itself (a.k.a. vmlinux), shared libraries, +and application binaries. + + +dcookie + +Short for "dentry cookie". A unique ID that can be looked up to provide +the full path name of a binary image. + + +dependent image + +A binary image that is dependent upon an application, used with +per-application separation. Most commonly, shared libraries. For example, +if /bin/bash is running and we take +some samples inside the C library itself due to bash +calling library code, then the image /lib/libc.so +would be dependent upon /bin/bash. + + +merging + +This refers to the ability to merge several distinct sample files +into one set of data at runtime, in the post-profiling tools. For example, +per-thread sample files can be merged into one set of data, because +they are compatible (i.e. the aggregation of the data is meaningful), +but it's not possible to merge sample files for two different events, +because there would be no useful meaning to the results. + + +profile class + +A collection of profile data that has been collected under the same +class template. For example, if we're using opreport +to show results after profiling with two performance counters enabled +profiling DATA_MEM_REFS and CPU_CLK_UNHALTED, +there would be two profile classes, one for each event. Or if we're on +an SMP system and doing per-cpu profiling, and we request +opreport to show results for each CPU side-by-side, +there would be a profile class for each CPU. + + +profile specification + +The parameters the user passes to the post-profiling tools that limit +what sample files are used. This specification is matched against +the available sample files to generate a selection of profile data. + + +profile template + +The parameters that define what goes in a particular profile class. +This includes a symbolic name (e.g. "cpu:1") and the code-usable +equivalent. + + + + +
diff --git a/doc/opannotate.1.in b/doc/opannotate.1.in new file mode 100644 index 0000000..4a5d5d0 --- /dev/null +++ b/doc/opannotate.1.in @@ -0,0 +1,111 @@ +.TH OPANNOTATE 1 "@DATE@" "oprofile @VERSION@" +.UC 4 +.SH NAME +opannotate \- produce source or assembly annotated with profile data +.SH SYNOPSIS +.br +.B opannotate +[ +.I options +] +[profile specification] +.SH DESCRIPTION + +.B opannotate +outputs annotated source and/or assembly from profile data of an OProfile +session. + +.SH OPTIONS +.TP +.BI "--assembly / -a" +Output annotated assembly. If this is combined with --source, then mixed +source / assembly annotations are output. +.br +.TP +.BI "--demangle / -D none|smart|normal" +none: no demangling. normal: use default demangler (default) smart: use +pattern-matching to make C++ symbol demangling more readable. +.br +.TP +.BI "--exclude-dependent / -x" +Do not include application-specific images for libraries, kernel modules +and the kernel. This option only makes sense if the profile session +used --separate. +.br +.TP +.BI "--exclude-file [files]" +Exclude all files in the given comma-separated list of glob patterns. +.br +.TP +.BI "--exclude-symbols / -e [symbols]" +Exclude all the symbols in the given comma-separated list. +.br +.TP +.BI "--help / -? / --usage" +Show help message. +.br +.TP +.BI "--image-path / -p [paths]" +Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. +.br +.TP +.BI "--include-file [files]" +Only include files in the given comma-separated list of glob patterns. +.br +.TP +.BI "--include-symbols / -i [symbols]" +Only include symbols in the given comma-separated list. +.br +.TP +.BI "--objdump-params [params]" +Pass the given parameters as extra values when calling objdump. +.br +.TP +.BI "--output-dir / -o [dir]" +Output directory. This makes opannotate output one annotated file for each +source file. This option can't be used in conjunction with --assembly. +.br +.TP +.BI "--search-dirs / -d [paths]" +Comma-separated list of paths to search for source files. You may need to use +this option when the debug information for an image contains relative paths. +.br +.TP +.BI "--base-dirs / -b [paths]" +Comma-separated list of paths to strip from debug source files, prior to +looking for them in --search-dirs. +.br +.TP +.BI "--source / -s" +Output annotated source. This requires debugging information to be available +for the binaries. +.br +.TP +.BI "--threshold / -t [percentage]" +Only output data for symbols that have more than the given percentage +of total samples. +.br +.TP +.BI "--verbose / -V [options]" +Give verbose debugging output. +.br +.TP +.BI "--version / -v" +Show version. + +.SH ENVIRONMENT +No special environment variables are recognised by opannotate. + +.SH FILES +.TP +.I /var/lib/oprofile/samples/ +The location of the generated sample files. + +.SH VERSION +.TP +This man page is current for @PACKAGE@-@VERSION@. + +.SH SEE ALSO +.BR @OP_DOCDIR@, +.BR oprofile(1) diff --git a/doc/oparchive.1.in b/doc/oparchive.1.in new file mode 100644 index 0000000..8b9301c --- /dev/null +++ b/doc/oparchive.1.in @@ -0,0 +1,63 @@ +.TH OPARCHIVE 1 "@DATE@" "oprofile @VERSION@" +.UC 4 +.SH NAME +oparchive \- produce archive of oprofile data for offline analysis +.SH SYNOPSIS +.br +.B oparchive +[ +.I options +] +[profile specification] +.B -o +[directory] +.SH DESCRIPTION + +.B oparchive +generates a directory populated with executable, debug, and oprofile sample +files. This directory can be move to another machine via tar and analyzed +without further use of the data collection machine. + +.SH OPTIONS +.TP +.BI "--help / -? / --usage" +Show help message. +.br +.TP +.BI "--version / -v" +Show version. +.br +.TP +.BI "--verbose / -V [options]" +Give verbose debugging output. +.br +.TP +.BI "--image-path / -p [paths]" +Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. +.br +.TP +.BI "--output-directory / -o [directory]" +Output to the given directory. There is no default. This must be specified. +.br +.TP +.BI "--exclude-dependent / -x" +Do not include application-specific images for libraries, kernel modules +and the kernel. This option only makes sense if the profile session +used --separate. + +.SH ENVIRONMENT +No special environment variables are recognised by oparchive. + +.SH FILES +.TP +.I /var/lib/oprofile/samples/ +The location of the generated sample files. + +.SH VERSION +.TP +This man page is current for @PACKAGE@-@VERSION@. + +.SH SEE ALSO +.BR @OP_DOCDIR@, +.BR oprofile(1) diff --git a/doc/opcontrol.1.in b/doc/opcontrol.1.in new file mode 100644 index 0000000..7dcc745 --- /dev/null +++ b/doc/opcontrol.1.in @@ -0,0 +1,149 @@ +.TH OPCONTROL 1 "@DATE@" "oprofile @VERSION@" +.UC 4 +.SH NAME +opcontrol \- control OProfile profiling +.SH SYNOPSIS +.br +.B opcontrol +[ +.I options +] +.SH DESCRIPTION +.B opcontrol +can be used to start profiling, end a profiling session, +dump profile data, and set up the profiling parameters. + +.SH OPTIONS +.TP +.BI "--help" +Show help message. +.br +.TP +.BI "--version" +Show version. +.br +.TP +.BI "--list-events" +Shows the monitorable events. +.br +.TP +.BI "--init" +Load the OProfile module if required and make the OProfile driver +interface available. +.br +.TP +.BI "--setup" +Followed by list options for profiling setup. Store setup +in ~root/.oprofile/daemonrc. Optional. +.br +.TP +.BI "--status" +Show configuration information. +.br +.TP +.BI "--start-daemon" +Start the oprofile daemon without starting profiling. Not available +in 2.2/2.4 kernels. +.br +.TP +.BI "--start" +Start data collection with either arguments provided by --setup +of information saved in ~root/.oprofile/daemonrc. +.br +.TP +.BI "--dump" +Force a flush of the collected profiling data to the daemon. +.br +.TP +.BI "--stop" +Stop data collection. Not available in 2.2/2.4 kernels. +.br +.TP +.BI "--shutdown" +Stop data collection and kill the daemon. +.br +.TP +.BI "--reset" +Clear out data from current session, but leaves saved sessions. +.br +.TP +.BI "--save="sessionname +Save data from current session to sessionname. +.br +.TP +.BI "--deinit" +Shut down daemon. Unload the oprofile module and oprofilefs. +.br +.TP +.BI "--buffer-size="num +Set kernel buffer to num samples. +.br +.TP +.BI "--cpu-buffer-size="num +Set kernel per cpu buffer to num samples (2.6 only). If you profile at high +rate it can help to increase this if the log file show excessive count of +sample lost cpu buffer overflow. +.br +.TP +.BI "--event="[event|"default"] +Add an event to measure for the hardware performance counters, +or "default" for the default event. The event is of the form +"CPU_CLK_UNHALTED:30000:0:1:1" where the numeric values are +count, unit mask, kernel-space counting, user-space counting, +respectively. +.br +.TP +.BI "--separate="[none,lib,kernel,thread,cpu,all] +Separate samples based on the given separator. 'lib' separates +dynamically linked library samples per application. 'kernel' separates +kernel and kernel module samples per application; 'kernel' +implies 'library'. 'thread' gives separation for each thread and +task. 'cpu' separates for each CPU. 'all' implies all of the above +options and 'none' turns off separation. +.br +.TP +.BI "--callgraph=#depth" +Enable callgraph sample collection with a maximum depth. Use 0 to disable +callgraph profiling. This option is currently only usable on x86, using a +2.6+ kernel with callgraph support enabled. +.br +.TP +.BI "--image="[name,name...|"all"] +Only profile the given absolute paths to binaries, or "all" to profile +everything (the default). +.br +.TP +.BI "--vmlinux="file +vmlinux kernel image. +.br +.TP +.BI "--no-vmlinux" +Use this when you don't have a kernel vmlinux file, and you don't want to +profile the kernel. +.br +.TP +.BI "--verbose" +Be verbose in the daemon log. This has a high overhead. +.br +.TP +.BI "--kernel-range="start,end +Set kernel range vma address in hexadecimal. + +.SH ENVIRONMENT +No special environment variables are recognised by opreport. + +.SH FILES +.TP +.I /root/.oprofile/daemonrc +Configuration file for opcontrol +.TP +.I /var/lib/oprofile/samples/ +The location of the generated sample files. + +.SH VERSION +.TP +This man page is current for @PACKAGE@-@VERSION@. + +.SH SEE ALSO +.BR @OP_DOCDIR@, +.BR oprofile(1) diff --git a/doc/opgprof.1.in b/doc/opgprof.1.in new file mode 100644 index 0000000..1909d54 --- /dev/null +++ b/doc/opgprof.1.in @@ -0,0 +1,59 @@ +.TH OPGPROF 1 "@DATE@" "oprofile @VERSION@" +.UC 4 +.SH NAME +opgprof \- produce gprof-format profile data +.SH SYNOPSIS +.br +.B opgprof +[ +.I options +] +[profile specification] +.SH DESCRIPTION + +.B opgprof +outputs gprof-format profile data for a given binary image, +from an OProfile session. + +.SH OPTIONS +.TP +.BI "--help / -? / --usage" +Show help message. +.br +.TP +.BI "--version / -v" +Show version. +.br +.TP +.BI "--verbose / -V [options]" +Give verbose debugging output. +.br +.TP +.BI "--image-path / -p [paths]" +Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. +.br +.TP +.BI "--threshold / -t [percentage]" +Only output data for symbols that have more than the given percentage +of total samples. +.br +.TP +.BI "--output-filename / -o [file]" +Output to the given file instead of the default, gmon.out + +.SH ENVIRONMENT +No special environment variables are recognised by opgprof. + +.SH FILES +.TP +.I /var/lib/oprofile/samples/ +The location of the generated sample files. + +.SH VERSION +.TP +This man page is current for @PACKAGE@-@VERSION@. + +.SH SEE ALSO +.BR @OP_DOCDIR@, +.BR oprofile(1) diff --git a/doc/ophelp.1.in b/doc/ophelp.1.in new file mode 100644 index 0000000..f8d6832 --- /dev/null +++ b/doc/ophelp.1.in @@ -0,0 +1,54 @@ +.TH OPHELP 1 "@DATE@" "oprofile @VERSION@" +.UC 4 +.SH NAME +ophelp \- list OProfile events +.SH SYNOPSIS +.br +.B ophelp +[ +.I options +] +[event name] +.SH DESCRIPTION + +By default, +.B ophelp +lists the available performance counter options. If you +give it a symbolic event name, it will return the hardware +value (e.g. "ophelp DATA_MEM_REFS"). + +.SH OPTIONS +.TP +.BI "--cpu-type / -c" +Show the events for the given numerical CPU type. +.br +.TP +.BI "--get-cpu-type / -r" +Show the symbolic CPU name. +.br +.TP +.BI "--help / -? / --usage" +Show help message. +.br +.TP +.BI "--version / -v" +Show version. + +.SH ENVIRONMENT +No special environment variables are recognised by ophelp. + +.SH FILES +.TP +.I $prefix/share/oprofile/ +Event description files used by OProfile. +.TP +.I /var/lib/oprofile/samples/ +The location of the generated sample files. + +.SH VERSION +.TP +This man page is current for @PACKAGE@-@VERSION@. + +.SH SEE ALSO +.BR @OP_DOCDIR@, +.BR oprofile(1) diff --git a/doc/opreport.1.in b/doc/opreport.1.in new file mode 100644 index 0000000..035d26c --- /dev/null +++ b/doc/opreport.1.in @@ -0,0 +1,128 @@ +.TH OPREPORT 1 "@DATE@" "oprofile @VERSION@" +.UC 4 +.SH NAME +opreport \- produce symbol or binary image summaries +.SH SYNOPSIS +.br +.B opreport +[ +.I options +] +[profile specification] +.SH DESCRIPTION + +.B opreport +outputs binary image summaries, or per-symbol data, from OProfile profiling +sessions. + +.SH OPTIONS +.TP +.BI "--accumulated / -a" +Accumulate sample and percentage counts in the symbol list. +.br +.TP +.BI "--debug-info / -g" +Show source file and line for each symbol. +.br +.TP +.BI "--demangle / -D none|smart|normal" +none: no demangling. normal: use default demangler (default) smart: use +pattern-matching to make C++ symbol demangling more readable. +.br +.TP +.BI "--callgraph / -c" +Show call graph information if available. +.br +.TP +.BI "--details / -d" +Show per-instruction details for all selected symbols. +.br +.TP +.BI "--exclude-dependent / -x" +Do not include application-specific images for libraries, kernel modules +and the kernel. This option only makes sense if the profile session +used --separate. +.br +.TP +.BI "--exclude-symbols / -e [symbols]" +Exclude all the symbols in the given comma-separated list. +.br +.TP +.BI "--global-percent / -%" +Make all percentages relative to the whole profile. +.br +.TP +.BI "--help / -? / --usage" +Show help message. +.br +.TP +.BI "--image-path / -p [paths]" +Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. +.br +.TP +.BI "--include-symbols / -i [symbols]" +Only include symbols in the given comma-separated list. +.br +.TP +.BI "--long-filenames / -l" +Output full paths instead of basenames. +.br +.TP +.BI "--merge / -m [lib,cpu,tid,tgid,unitmask,all]" +Merge any profiles separated in a --separate session. +.br +.TP +.BI "--no-header" +Don't output a header detailing profiling parameters. +.br +.TP +.BI "--output-file / -o [file]" +Output to the given file instead of stdout. +.br +.TP +.BI "--reverse-sort / -r" +Reverse the sort from the default. +.br +.TP +.BI "--show-address / -w" +Show each symbol's VMA address. +.br +.TP +.BI "--sort / -s [vma,sample,symbol,debug,image]" +Sort the list of symbols by, respectively, symbol address, +number of samples, symbol name, debug filename and line number, +binary image filename. +.br +.TP +.BI "--symbols / -l" +List per-symbol information instead of a binary image summary. +.br +.TP +.BI "--threshold / -t [percentage]" +Only output data for symbols that have more than the given percentage +of total samples. +.br +.TP +.BI "--verbose / -V [options]" +Give verbose debugging output. +.br +.TP +.BI "--version / -v" +Show version. + +.SH ENVIRONMENT +No special environment variables are recognised by opreport. + +.SH FILES +.TP +.I /var/lib/oprofile/samples/ +The location of the generated sample files. + +.SH VERSION +.TP +This man page is current for @PACKAGE@-@VERSION@. + +.SH SEE ALSO +.BR @OP_DOCDIR@, +.BR oprofile(1) diff --git a/doc/oprofile.1 b/doc/oprofile.1 new file mode 100644 index 0000000..d5d7363 --- /dev/null +++ b/doc/oprofile.1 @@ -0,0 +1,186 @@ +.TH OPROFILE 1 "Mon 18 July 2005" "oprofile 0.9.1" +.UC 4 +.SH NAME +oprofile \- a system-wide profiler +.SH SYNOPSIS +.br +.B opcontrol +[ +.I options +] +.br +.B opreport +[ +.I options +] +[ profile specification ] +.br +.B opannotate +[ +.I options +] +[ profile specification ] +.br +.B oparchive +[ +.I options +] +[ profile specification ] +.br +.B opgprof +[ +.I options +] +[ profile specification ] +.br +.SH DESCRIPTION +OProfile is a profiling system for systems running Linux +2.2, 2.4, and 2.6. Profiling runs transparently in the background and profile +data can be collected at any time. OProfile makes use of the hardware +performance counters provided on Intel, AMD, and other processors, +and uses a timer-interrupt based mechanism on CPUs without counters. +OProfile can profile the whole system in high detail. +.br +For a gentle guide to using OProfile, please read the HTML documentation +listed in SEE ALSO. +.br +.SH OPCONTROL +.B opcontrol +is used for starting and stopping the OProfile daemon, and providing set-up +parameters. +.SH OPREPORT +.B opreport +gives image and symbol-based profile summaries for the whole system or +a subset of binary images. +.SH OPANNOTATE +.B opannotate +can produce annotated source or mixed source and assembly output. +.SH OPARCHIVE +.B oparchive +produces oprofile archive for offline analysis +.SH OPGPROF +.B opgprof +can produce a gprof-format profile for a single binary. + +.SH PROFILE SPECIFICATIONS +All of the post-profiling tools can take profile specifications, +which is some combination of the following parameters. Enclosing +part of a profile specification in curly braces { } can be used +for differential profiles with +.B opreport +. + +.TP +.BI "session:"sessionlist +A comma-separated list of session names to resolve in. Absence of this +tag, unlike all others, means "the current session", equivalent to +specifying "session:current". +.br +.TP +.BI "session-exclude:"sessionlist +A comma-separated list of sessions to exclude. +.br +.TP +.BI "image:"imagelist +A comma-separated list of image names to resolve. Each entry may be relative +path, glob-style name, or full path, e.g. +opreport 'image:/usr/bin/oprofiled,*op*,./oprofpp' +.br +.TP +.BI "image-exclude:"imagelist +Same as image:, but the matching images are excluded. +.br +.TP +.BI "lib-image:"imagelist +Same as image:, but only for images that are for +a particular primary binary image (namely, an application). This only +makes sense to use if you're using --separate. +This includes kernel modules and the kernel when using +--separate=kernel. +.br +.TP +.BI "lib-image-exclude:"imagelist +Same as , but the matching images +are excluded. +.br +.TP +.BI "event:"eventname +The symbolic event name to match on, e.g. event:DATA_MEM_REFS. +.br +.TP +.BI "count:"eventcount +The event count to match on, e.g. event:DATA_MEM_REFS count:30000. +.br +.TP +.BI "unit-mask:"maskvalue +The unit mask value of the event to match on, e.g. unit-mask:1. +.br +.TP +.BI "cpu:"cpulist +Only consider profiles for the given numbered CPU (starting from zero). +This is only useful when using CPU profile separation. +.br +.TP +.BI "tgid:"pidlist +Only consider profiles for the given task groups. Unless some program is +using threads, the task group ID of a process is the same as its process +ID. This option corresponds to the POSIX notion of a thread group. This +is only useful when using per-process profile separation. +.br +.TP +.BI "tid:"tidlist +Only consider profiles for the given threads. When using recent thread +libraries, all threads in a process share the same task group ID, but +have different thread IDs. You can use this option in combination with +tgid: to restrict the results to particular threads within a process. +This is only useful when using per-process profile separation. + +.SH ENVIRONMENT +No special environment variables are recognised by oprofile. + +.SH FILES +.TP +.I $HOME/.oprofile/ +Configuration files +.TP +.I /root/.oprofile/daemonrc +Configuration file for opcontrol +.TP +.I $prefix/share/oprofile/ +Event description files used by OProfile. +.TP +.I /var/lib/oprofile/oprofiled.log +The user-space daemon logfile. +.TP +.I /var/lib/oprofile/opdev, /var/lib/oprofile/ophashmapdev, /var/lib/oprofile/opnotedev +The device files for communication with the Linux 2.4 kernel module. +.TP +.I /dev/oprofile +The device filesystem for communication with the Linux 2.6 kernel module. +.TP +.I /var/lib/oprofile/samples/ +The location of the generated sample files. + +.SH VERSION +.TP +This man page is current for oprofile-0.9.1. + +.SH SEE ALSO +.BR /usr/local/oprofile/share/doc/oprofile/, +.BR opcontrol(1), +.BR opreport(1), +.BR opannotate(1), +.BR oparchive(1), +.BR opgprof(1), +.BR gprof(1), +.BR readprofile(1), +.BR CPU vendor architecture manuals + +.SH COPYRIGHT +oprofile is Copyright (C) 1998-2004 University of Manchester, UK, John Levon, +and others. +OProfile is released under the GNU General Public License, Version 2, +or (at your option) any later version. +.SH AUTHORS +John Levon is the primary author. See the documentation +for other contributors. diff --git a/doc/oprofile.1.in b/doc/oprofile.1.in new file mode 100644 index 0000000..bce94a9 --- /dev/null +++ b/doc/oprofile.1.in @@ -0,0 +1,186 @@ +.TH OPROFILE 1 "@DATE@" "oprofile @VERSION@" +.UC 4 +.SH NAME +oprofile \- a system-wide profiler +.SH SYNOPSIS +.br +.B opcontrol +[ +.I options +] +.br +.B opreport +[ +.I options +] +[ profile specification ] +.br +.B opannotate +[ +.I options +] +[ profile specification ] +.br +.B oparchive +[ +.I options +] +[ profile specification ] +.br +.B opgprof +[ +.I options +] +[ profile specification ] +.br +.SH DESCRIPTION +OProfile is a profiling system for systems running Linux +2.2, 2.4, and 2.6. Profiling runs transparently in the background and profile +data can be collected at any time. OProfile makes use of the hardware +performance counters provided on Intel, AMD, and other processors, +and uses a timer-interrupt based mechanism on CPUs without counters. +OProfile can profile the whole system in high detail. +.br +For a gentle guide to using OProfile, please read the HTML documentation +listed in SEE ALSO. +.br +.SH OPCONTROL +.B opcontrol +is used for starting and stopping the OProfile daemon, and providing set-up +parameters. +.SH OPREPORT +.B opreport +gives image and symbol-based profile summaries for the whole system or +a subset of binary images. +.SH OPANNOTATE +.B opannotate +can produce annotated source or mixed source and assembly output. +.SH OPARCHIVE +.B oparchive +produces oprofile archive for offline analysis +.SH OPGPROF +.B opgprof +can produce a gprof-format profile for a single binary. + +.SH PROFILE SPECIFICATIONS +All of the post-profiling tools can take profile specifications, +which is some combination of the following parameters. Enclosing +part of a profile specification in curly braces { } can be used +for differential profiles with +.B opreport +. + +.TP +.BI "session:"sessionlist +A comma-separated list of session names to resolve in. Absence of this +tag, unlike all others, means "the current session", equivalent to +specifying "session:current". +.br +.TP +.BI "session-exclude:"sessionlist +A comma-separated list of sessions to exclude. +.br +.TP +.BI "image:"imagelist +A comma-separated list of image names to resolve. Each entry may be relative +path, glob-style name, or full path, e.g. +opreport 'image:/usr/bin/oprofiled,*op*,./oprofpp' +.br +.TP +.BI "image-exclude:"imagelist +Same as image:, but the matching images are excluded. +.br +.TP +.BI "lib-image:"imagelist +Same as image:, but only for images that are for +a particular primary binary image (namely, an application). This only +makes sense to use if you're using --separate. +This includes kernel modules and the kernel when using +--separate=kernel. +.br +.TP +.BI "lib-image-exclude:"imagelist +Same as , but the matching images +are excluded. +.br +.TP +.BI "event:"eventname +The symbolic event name to match on, e.g. event:DATA_MEM_REFS. +.br +.TP +.BI "count:"eventcount +The event count to match on, e.g. event:DATA_MEM_REFS count:30000. +.br +.TP +.BI "unit-mask:"maskvalue +The unit mask value of the event to match on, e.g. unit-mask:1. +.br +.TP +.BI "cpu:"cpulist +Only consider profiles for the given numbered CPU (starting from zero). +This is only useful when using CPU profile separation. +.br +.TP +.BI "tgid:"pidlist +Only consider profiles for the given task groups. Unless some program is +using threads, the task group ID of a process is the same as its process +ID. This option corresponds to the POSIX notion of a thread group. This +is only useful when using per-process profile separation. +.br +.TP +.BI "tid:"tidlist +Only consider profiles for the given threads. When using recent thread +libraries, all threads in a process share the same task group ID, but +have different thread IDs. You can use this option in combination with +tgid: to restrict the results to particular threads within a process. +This is only useful when using per-process profile separation. + +.SH ENVIRONMENT +No special environment variables are recognised by oprofile. + +.SH FILES +.TP +.I $HOME/.oprofile/ +Configuration files +.TP +.I /root/.oprofile/daemonrc +Configuration file for opcontrol +.TP +.I $prefix/share/oprofile/ +Event description files used by OProfile. +.TP +.I /var/lib/oprofile/oprofiled.log +The user-space daemon logfile. +.TP +.I /var/lib/oprofile/opdev, /var/lib/oprofile/ophashmapdev, /var/lib/oprofile/opnotedev +The device files for communication with the Linux 2.4 kernel module. +.TP +.I /dev/oprofile +The device filesystem for communication with the Linux 2.6 kernel module. +.TP +.I /var/lib/oprofile/samples/ +The location of the generated sample files. + +.SH VERSION +.TP +This man page is current for @PACKAGE@-@VERSION@. + +.SH SEE ALSO +.BR @OP_DOCDIR@, +.BR opcontrol(1), +.BR opreport(1), +.BR opannotate(1), +.BR oparchive(1), +.BR opgprof(1), +.BR gprof(1), +.BR readprofile(1), +.BR CPU vendor architecture manuals + +.SH COPYRIGHT +oprofile is Copyright (C) 1998-2004 University of Manchester, UK, John Levon, +and others. +OProfile is released under the GNU General Public License, Version 2, +or (at your option) any later version. +.SH AUTHORS +John Levon is the primary author. See the documentation +for other contributors. diff --git a/doc/oprofile.html b/doc/oprofile.html new file mode 100644 index 0000000..57cfd7e --- /dev/null +++ b/doc/oprofile.html @@ -0,0 +1,4392 @@ + + + + + + OProfile manual + + + +
+
+
+
+

OProfile manual

+
+
+
+
+

John Levon

+
+ +
+
+
+
+
+ +
+
+
+
+
+

+ Table of Contents +

+
+
+ + 1. Introduction + +
+
+
+
+ + 1. Applications of OProfile + +
+
+ + 2. System requirements + +
+
+ + 3. Internet resources + +
+
+ + 4. Installation + +
+
+ + 5. Uninstalling OProfile + +
+
+
+
+ + 2. Overview + +
+
+
+
+ + 1. Getting started + +
+
+ + 2. Tools summary + +
+
+
+
+ + 3. Controlling the profiler + +
+
+
+
+ + 1. Using opcontrol + +
+
+
+
+ + 1.1. Examples + +
+
+ + 1.2. Specifying performance counter events + +
+
+
+
+ + 2. Using oprof_start + +
+
+ + 3. Configuration details + +
+
+
+
+ + 3.1. Hardware performance counters + +
+
+ + 3.2. OProfile in RTC mode + +
+
+ + 3.3. OProfile in timer interrupt mode + +
+
+ + 3.4. Pentium 4 support + +
+
+ + 3.5. Intel Itanium 2 support + +
+
+ + 3.6. PowerPC64 support + +
+
+ + 3.7. Dangerous counter settings + +
+
+
+
+
+
+ + 4. Obtaining results + +
+
+
+
+ + 1. Profile specifications + +
+
+
+
+ + 1.1. Examples + +
+
+ + 1.2. Profile specification parameters + +
+
+ + 1.3. Locating and managing binary images + +
+
+ + 1.4. What to do when you don't get any results + +
+
+
+
+ + 2. Image summaries and symbol summaries (opreport) + +
+
+
+
+ + 2.1. Merging separate profiles + +
+
+ + 2.2. Side-by-side multiple results + +
+
+ + 2.3. Callgraph output + +
+
+ + 2.4. Differential profiles with opreport + +
+
+ + 2.5. Anonymous executable mappings + +
+
+ + 2.6. Options for opreport + +
+
+
+
+ + 3. Outputting annotated source (opannotate) + +
+
+
+
+ + 3.1. Locating source files + +
+
+ + 3.2. Usage of opannotate + +
+
+
+
+ + 4. gprof-compatible output (opgprof) + +
+
+
+
+ + 4.1. Usage of opgprof + +
+
+
+
+ + 5. Archiving measurements (oparchive) + +
+
+
+
+ + 5.1. Usage of oparchive + +
+
+
+
+
+
+ + 5. Interpreting profiling results + +
+
+
+
+ + 1. Profiling interrupt latency + +
+
+ + 2. Kernel profiling + +
+
+
+
+ + 2.1. Interrupt masking + +
+
+ + 2.2. Idle time + +
+
+ + 2.3. Profiling kernel modules + +
+
+
+
+ + 3. Interpreting call-graph profiles + +
+
+ + 4. Inaccuracies in annotated source + +
+
+
+
+ + 4.1. Side effects of optimizations + +
+
+ + 4.2. Prologues and epilogues + +
+
+ + 4.3. Inlined functions + +
+
+ + 4.4. Inaccuracy in line number information + +
+
+
+
+ + 5. Assembly functions + +
+
+ + 6. Other discrepancies + +
+
+
+
+ + 6. Acknowledgments + +
+
+
+
+
+
+
+

Chapter 1. Introduction

+
+
+
+
+

+ Table of Contents +

+
+
+ + 1. Applications of OProfile + +
+
+ + 2. System requirements + +
+
+ + 3. Internet resources + +
+
+ + 4. Installation + +
+
+ + 5. Uninstalling OProfile + +
+
+
+

+This manual applies to OProfile version 0.9.1cvs. +OProfile is a profiling system for Linux 2.2/2.4/2.6 systems on a number of architectures. It is capable of profiling +all parts of a running system, from the kernel (including modules and interrupt handlers) to shared libraries +to binaries. It runs transparently in the background collecting information at a low overhead. These +features make it ideal for profiling entire systems to determine bottle necks in real-world systems. +

+

+Many CPUs provide "performance counters", hardware registers that can count "events"; for example, +cache misses, or CPU cycles. OProfile provides profiles of code based on the number of these occurring events: +repeatedly, every time a certain (configurable) number of events has occurred, the PC value is recorded. +This information is aggregated into profiles for each binary image.

+

+Some hardware setups do not allow OProfile to use performance counters: in these cases, no +events are available, and OProfile operates in timer/RTC mode, as described in later chapters. +

+
+
+
+
+

1. Applications of OProfile

+
+
+
+

+OProfile is useful in a number of situations. You might want to use OProfile when you : +

+
+
    +
  • +

    need low overhead

    +
  • +
  • +

    cannot use highly intrusive profiling methods

    +
  • +
  • +

    need to profile interrupt handlers

    +
  • +
  • +

    need to profile an application and its shared libraries

    +
  • +
  • +

    need to capture the performance behaviour of entire system

    +
  • +
  • +

    want to examine hardware effects such as cache misses

    +
  • +
  • +

    want detailed source annotation

    +
  • +
  • +

    want instruction-level profiles

    +
  • +
  • +

    want call-graph profiles

    +
  • +
+
+

+OProfile is not a panacea. OProfile might not be a complete solution when you : +

+
+
    +
  • +

    require call graph profiles on platforms other than 2.6/x86

    +
  • +
  • +

    don't have root permissions

    +
  • +
  • +

    require 100% instruction-accurate profiles

    +
  • +
  • +

    need function call counts or an interstitial profiling API

    +
  • +
  • +

    cannot tolerate any disturbance to the system whatsoever

    +
  • +
  • +

    need to profile interpreted or dynamically compiled code such as Java or Python

    +
  • +
+
+
+
+
+
+
+

2. System requirements

+
+
+
+
+
+
+ Linux kernel 2.2/2.4/2.6 +
+
+

+ OProfile uses a kernel module that can be compiled for + 2.2.11 or later and 2.4. Versions 2.4.10 or above are recommended, and required if you use the + boot-time kernel option nosmp. 2.6 kernels are supported with the in-kernel + OProfile driver. Note that only 32-bit x86 and IA64 are supported on 2.2/2.4 kernels. + +

+

+ PPC64 processors (Power4/Power5/PPC970) require a recent (> 2.6.5) kernel with the line + #define PV_970 present in include/asm-ppc64/processor.h. + +

+
+
+ modutils 2.4.6 or above +
+
+

+ You should have installed modutils 2.4.6 or higher (in fact earlier versions work well in almost all + cases). +

+
+
+ Supported architecture +
+
+

+ For Intel IA32, a CPU with either a P6 generation or Pentium 4 core is + required. In marketing terms this translates to anything + between an Intel Pentium Pro (not Pentium Classics) and + a Pentium 4 / Xeon, including all Celerons. The AMD + Athlon, and Duron CPUs are also supported. Other IA32 + CPU types only support the RTC mode of OProfile; please + see later in this manual for details. Hyper-threaded Pentium IVs + are not supported in 2.4. For 2.4 kernels, the Intel + IA-64 CPUs are also supported. For 2.6 kernels, there is additionally + support for Alpha processors, MIPS, ARM, x86-64, sparc64, ppc64, and, + in timer mode, PA-RISC and s390. +

+
+
+ Uniprocessor or SMP +
+
+

+ SMP machines are fully supported. +

+
+
+ Required libraries +
+
+

+ These libraries are required : popt, bfd, + liberty (debian users: libiberty is provided in binutils-dev package), dl, + plus the standard C++ libraries. +

+
+
+ Bash version 2 +
+
+

+ The opcontrol script requires bash version 2 at least to be installed + as /bin/bash or /bin/bash2 +

+
+
+ OProfile GUI +
+
+

+ The use of the GUI to start the profiler requires the Qt 2 library. Qt 3 should + also work. +

+
+
+ + ELF + +
+
+

+ Probably not too strenuous a requirement, but older A.OUT binaries/libraries are not supported. +

+
+
+ K&R coding style +
+
+

+ OK, so it's not really a requirement, but I wish it was... +

+
+
+
+
+
+
+
+
+

3. Internet resources

+
+
+
+
+
+
+ Web page +
+
+

+ There is a web page (which you may be reading now) at + http://oprofile.sf.net/. +

+
+
+ Download +
+
+

+ You can download a source tarball or get anonymous CVS at the sourceforge page, + http://sf.net/projects/oprofile/. +

+
+
+ Mailing list +
+
+

+ There is a low-traffic OProfile-specific mailing list, details at + http://sf.net/mail/?group_id=16191. +

+
+
+ Bug tracker +
+
+

+ There is a bug tracker for OProfile at SourceForge, + http://sf.net/tracker/?group_id=16191&atid=116191. +

+
+
+ IRC channel +
+
+

+ Several OProfile developers and users sometimes hang out on channel #oprofile + on the freenode network. +

+
+
+
+
+
+
+
+
+

4. Installation

+
+
+
+

+First you need to build OProfile and install it. ./configure, make, make install +is often all you need, but note these arguments to ./configure : +

+
+
+
+ + --with-linux + +
+
+

+ Use this option to specify the location of the kernel source tree you wish + to compile against. The kernel module is built against this source and + will only work with a running kernel built from the same source with + exact same options, so it is important you specify this option if you need + to. +

+
+
+ + --with-kernel-support + +
+
+

+ Use this option with 2.6 and above kernels to indicate the + kernel provides the OProfile device driver. +

+
+
+ + --with-qt-dir/includes/libraries + +
+
+

+ Specify the location of Qt headers and libraries. It defaults to searching in + $QTDIR if these are not specified. +

+
+
+ + + --enable-abi + +
+
+

+ Activate code within the OProfile sample collection daemon + oprofiled which records information about the binary + format of sample files in /var/lib/oprofile/abi, to + permit their transport between hosts using the + opimport utility. See opimport. This option is primarily intended for embedded + systems or remote analysis of production machines; if you will be + performing all sample analysis on the same machine as you are profiling, + it is safe to omit this option. +

+
+
+ + + --disable-werror + +
+
+

+ Development versions of OProfile build by + default with -Werror. This option turns + -Werror off. +

+
+
+ + + --disable-optimization + +
+
+

+ Disable the -O2 compiler flag + (useful if you discover an OProfile bug and want to give a useful + back-trace etc.) +

+
+
+
+

+You'll need to have a configured kernel source for the current kernel +to build the module for 2.4 kernels. Since all distributions provide different kernels it's unlikely the running kernel match the configured source +you installed. The safest way is to recompile your own kernel, run it and compile oprofile. It is also recommended that if you have a +uniprocessor machine, you enable the local APIC / IO_APIC support for +your kernel (this is automatically enabled for SMP kernels). With many BIOS, kernel >= 2.6.9 and UP kernel it's not sufficient to enable the local APIC you must also turn it on explicitely at boot time by providing "lapic" option to the kernel. On +machines with power management, such as laptops, the power management +must be turned off when using OProfile with 2.4 kernels. The power management software +in the BIOS cannot handle the non-maskable interrupts (NMIs) used by +OProfile for data collection. If you use the NMI watchdog, be aware that +the watchdog is disabled when profiling starts, and not re-enabled until the +OProfile module is removed (or, in 2.6, when OProfile is not running). If you compile OProfile for +a 2.2 kernel you must be root to compile the module. If you are using +2.6 kernels or higher, you do not need kernel source, as long as the +OProfile driver is enabled; additionally, you should not need to disable +power management. +

+

+Please note that you must save or have available the vmlinux file +generated during a kernel compile, as OProfile needs it (you can use +--no-vmlinux, but this will prevent kernel profiling). +

+
+
+
+
+
+

5. Uninstalling OProfile

+
+
+
+

+You must have the source tree available to uninstall OProfile; a make uninstall will +remove all installed files except your configuration file in the directory ~/.oprofile. +

+
+
+
+
+
+
+

Chapter 2. Overview

+
+
+
+
+

+ Table of Contents +

+
+
+ + 1. Getting started + +
+
+ + 2. Tools summary + +
+
+
+
+
+
+
+

1. Getting started

+
+
+
+

+Before you can use OProfile, you must set it up. The minimum setup required for this +is to tell OProfile where the vmlinux file corresponding to the +running kernel is, for example : +

+ + + + +
+
opcontrol --vmlinux=/boot/vmlinux-`uname -r`
+
+

+If you don't want to profile the kernel itself, +you can tell OProfile you don't have a vmlinux file : +

+ + + + +
+
opcontrol --no-vmlinux
+
+

+Now we are ready to start the daemon (oprofiled) which collects +the profile data : +

+ + + + +
+
opcontrol --start
+
+

+When I want to stop profiling, I can do so with : +

+ + + + +
+
opcontrol --shutdown
+
+

+Note that unlike gprof, no instrumentation (-pg +and -a options to gcc) +is necessary. +

+

+Periodically (or on opcontrol --shutdown or opcontrol --dump) +the profile data is written out into the /var/lib/oprofile/samples directory. +These profile files cover shared libraries, applications, the kernel (vmlinux), and kernel modules. +You can clear the profile data (at any time) with opcontrol --reset. +

+

+You can get summaries of this data in a number of ways at any time. To get a summary of +data across the entire system for all of these profiles, you can do : +

+ + + + +
+
opreport
+
+

+Or to get a more detailed summary, for a particular image, you can do something like : +

+ + + + +
+
opreport -l /boot/vmlinux-`uname -r`
+
+

+There are also a number of other ways of presenting the data, as described later in this manual. +Note that OProfile will choose a default profiling setup for you. However, there are a number +of options you can pass to opcontrol if you need to change something, +also detailed later. +

+
+
+
+
+
+

2. Tools summary

+
+
+
+

+This section gives a brief description of the available OProfile utilities and their purpose. +

+
+
+
+ + ophelp + +
+
+

+ This utility lists the available events and short descriptions. +

+
+
+ + opcontrol + +
+
+

+ Used for controlling the OProfile data collection, discussed in Chapter 3, Controlling the profiler. +

+
+
+ + opreport + +
+
+

+ This is the main tool for retrieving useful profile data, described in + Section 2, “Image summaries and symbol summaries (opreport)”. +

+
+
+ + opannotate + +
+
+

+ This utility can be used to produce annotated source, assembly or mixed source/assembly. + Source level annotation is available only if the application was compiled with + debugging symbols. See Section 3, “Outputting annotated source (opannotate)”. +

+
+
+ + opgprof + +
+
+

+ This utility can output gprof-style data files for a binary, for use with + gprof -p. See Section 4, “gprof-compatible output (opgprof)”. +

+
+
+ + oparchive + +
+
+

+ This utility can be used to collect executables, debuginfo, + and sample files and copy the files into an archive. + The archive is self-contained and can be moved to another + machine for further analysis. + See Section 5, “Archiving measurements (oparchive)”. +

+
+
+ + + opimport + +
+
+

+ This utility converts sample database files from a foreign binary format (abi) to + the native format. This is useful only when moving sample files between hosts, + for analysis on platforms other than the one used for collection. The abi format + of the file to be imported is described in a text file located in + /var/lib/oprofile/abi, if the --enable-abi + configure-time option was enabled. Furthermore, the opimport + tool is not built unless --enable-abi is given. See --enable-abi. +

+
+
+
+
+
+
+
+
+
+

Chapter 3. Controlling the profiler

+
+
+
+ +
+
+
+
+

1. Using opcontrol

+
+
+
+

+In this section we describe the configuration and control of the profiling system +with opcontrol in more depth. +The opcontrol script has a default setup, but you +can alter this with the options given below. In particular, +if your hardware supports performance counters, you can configure them. +There are a number of counters (for example, counter 0 and counter 1 +on the Pentium III). Each of these counters can be programmed with +an event to count, such as cache misses or MMX operations. The event +chosen for each counter is reflected in the profile data collected +by OProfile: functions and binaries at the top of the profiles reflect +that most of the chosen events happened within that code. +

+

+Additionally, each counter has a "count" value: this corresponds to how +detailed the profile is. The lower the value, the more frequently profile +samples are taken. A counter can choose to sample only kernel code, user-space code, +or both (both is the default). Finally, some events have a "unit mask" +- this is a value that further restricts the types of event that are counted. +The event types and unit masks for your CPU are listed by opcontrol +--list-events. +

+

+The opcontrol script provides the following actions : +

+
+
+
+ + --init + +
+
+

+ Loads the OProfile module if required and makes the OProfile driver + interface available. +

+
+
+ + --setup + +
+
+

+ Followed by list arguments for profiling set up. List of arguments + saved in /root/.oprofile/daemonrc. + Giving this option is not necessary; you can just directly pass one + of the setup options, e.g. opcontrol --no-vmlinux. +

+
+
+ + --status + +
+
+

+ Show configuration information. +

+
+
+ + --start-daemon + +
+
+

+ Start the oprofile daemon without starting actual profiling. The profiling + can then be started using --start. This is useful for avoiding + measuring the cost of daemon startup, as --start is a simple + write to a file in oprofilefs. Not available in 2.2/2.4 kernels. +

+
+
+ + --start + +
+
+

+ Start data collection with either arguments provided by --setup + or information saved in /root/.oprofile/daemonrc. Specifying + the addition --verbose makes the daemon generate lots of debug data + whilst it is running. +

+
+
+ + --dump + +
+
+

+ Force a flush of the collected profiling data to the daemon. +

+
+
+ + --stop + +
+
+

+ Stop data collection (this separate step is not possible with 2.2 or 2.4 kernels). +

+
+
+ + --shutdown + +
+
+

+ Stop data collection and kill the daemon. +

+
+
+ + --reset + +
+
+

+ Clears out data from current session, but leaves saved sessions. +

+
+
+ --save=session_name +
+
+

+ Save data from current session to session_name. +

+
+
+ + --deinit + +
+
+

+ Shuts down daemon. Unload the OProfile module and oprofilefs. +

+
+
+ + --list-events + +
+
+

+ List event types and unit masks. +

+
+
+ + --help + +
+
+

+ Generate usage messages. +

+
+
+
+

+There are a number of possible settings, of which, only +--vmlinux (or --no-vmlinux) +is required. These settings are stored in ~/.oprofile/daemonrc. +

+
+
+
+ --buffer-size=num +
+
+

+ Number of samples in kernel buffer. +

+
+
+ --cpu-buffer-size=num +
+
+

+ Number of samples in kernel per-cpu buffer (2.6 only). If you + profile at high rate it can help to increase this if the log + file show excessive count of sample lost cpu buffer overflow. +

+
+
+ --event=[eventspec] +
+
+

+ Use the given performance counter event to profile. + See Section 1.2, “Specifying performance counter events” below. +

+
+
+ --separate=[none,lib,kernel,thread,cpu,all] +
+
+

+ By default, every profile is stored in a single file. Thus, for example, + samples in the C library are all accredited to the /lib/libc.o + profile. However, you choose to create separate sample files by specifying + one of the below options. +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ none + No profile separation (default)
+ lib + Create per-application profiles for libraries
+ kernel + Create per-application profiles for the kernel and kernel modules
+ thread + Create profiles for each thread and each task
+ cpu + Create profiles for each CPU
+ all + All of the above options
+
+

+ Note that --separate=kernel also turns on --separate=lib. + + When using --separate=kernel, samples in hardware interrupts, soft-irqs, or other + asynchronous kernel contexts are credited to the task currently running. This means you will see + seemingly nonsense profiles such as /bin/bash showing samples for the PPP modules, + etc. +

+

+ On 2.2/2.4 only kernel threads already started when profiling begins are correctly profiled; + newly started kernel thread samples are credited to the vmlinux (kernel) profile. +

+

+ Using --separate=thread creates a lot + of sample files if you leave OProfile running for a while; it's most + useful when used for short sessions, or when using image filtering. +

+
+
+ --callgraph=#depth +
+
+

+ Enable call-graph sample collection with a maximum depth. Use 0 to disable + callgraph profiling. Currently this requires a recent + 2.6 kernel, and x86. +

+
+
+ --image=image,[images]|"all" +
+
+

+ Image filtering. If you specify one or more absolute + paths to binaries, OProfile will only produce profile results for those + binary images. This is useful for restricting the sometimes voluminous + output you may get otherwise, especially with + --separate=thread. Note that if you are using + --separate=lib or + --separate=kernel, then if you specification an + application binary, the shared libraries and kernel code + are included. Specify the value + "all" to profile everything (the default). +

+
+
+ --vmlinux=file +
+
+

+ vmlinux kernel image. +

+
+
+ + --no-vmlinux + +
+
+

+ Use this when you don't have a kernel vmlinux file, and you don't want + to profile the kernel. This still counts the total number of kernel samples, + but can't give symbol-based results for the kernel or any modules. +

+
+
+
+
+
+
+
+

1.1. Examples

+
+
+
+
+
+
+
+

1.1.1. Intel performance counter setup

+
+
+
+

+Here, we have a Pentium III running at 800MHz, and we want to look at where data memory +references are happening most, and also get results for CPU time. +

+ + + + +
+
+# opcontrol --event=CPU_CLK_UNHALTED:400000 --event=DATA_MEM_REFS:10000
+# opcontrol --vmlinux=/boot/2.6.0/vmlinux
+# opcontrol --start
+
+
+
+
+
+
+
+

1.1.2. RTC mode

+
+
+
+

+Here, we have an Intel laptop without support for performance counters, running on 2.4 kernels. +

+ + + + +
+
+# ophelp -r
+CPU with RTC device
+# opcontrol --vmlinux=/boot/2.4.13/vmlinux --event=RTC_INTERRUPTS:1024
+# opcontrol --start
+
+
+
+
+
+
+
+

1.1.3. Starting the daemon separately

+
+
+
+

+If we're running 2.6 kernels, we can use --start-daemon to avoid +the profiler startup affecting results. +

+ + + + +
+
+# opcontrol --vmlinux=/boot/2.6.0/vmlinux
+# opcontrol --start-daemon
+# my_favourite_benchmark --init
+# opcontrol --start ; my_favourite_benchmark --run ; opcontrol --stop
+
+
+
+
+
+
+
+

1.1.4. Separate profiles for libraries and the kernel

+
+
+
+

+Here, we want to see a profile of the OProfile daemon itself, including when +it was running inside the kernel driver, and its use of shared libraries. +

+ + + + +
+
+# opcontrol --separate=kernel --vmlinux=/boot/2.6.0/vmlinux
+# opcontrol --start
+# my_favourite_stress_test --run
+# opreport -l -p /lib/modules/2.6.0/kernel /usr/local/bin/oprofiled
+
+
+
+
+
+
+
+

1.1.5. Profiling sessions

+
+
+
+

+It can often be useful to split up profiling data into several different +time periods. For example, you may want to collect data on an application's +startup separately from the normal runtime data. You can use the simple +command opcontrol --save to do this. For example : +

+ + + + +
+
+# opcontrol --save=blah
+
+
+

+will create a sub-directory in /var/lib/oprofile/samples containing the samples +up to that point (the current session's sample files are moved into this +directory). You can then pass this session name as a parameter to the post-profiling +analysis tools, to only get data up to the point you named the +session. If you do not want to save a session, you can do +rm -rf /var/lib/oprofile/samples/sessionname or, for the +current session, opcontrol --reset. +

+
+
+
+
+
+
+

1.2. Specifying performance counter events

+
+
+
+

+The --event option to opcontrol +takes a specification that indicates how the details of each +hardware performance counter should be setup. If you want to +revert to OProfile's default setting (--event +is strictly optional), use --event=default. +

+

+You can pass multiple event specifications. OProfile will allocate +hardware counters as necessary. Note that some combinations are not +allowed by the CPU; running opcontrol --list-events gives the details +of each event. The event specification is a colon-separated string +of the form name:count:unitmask:kernel:user as described in this table: +

+
+

Note

+

+For the PowerPC platforms, all events specified must be in the same group; i.e., the group number +appended to the event name (e.g. <some-event-name>_GRP9) must be the same. +

+
+

+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ name + The symbolic event name, e.g. CPU_CLK_UNHALTED
+ count + The counter reset value, e.g. 100000
+ unitmask + The unit mask, as given in the events list, e.g. 0x0f
+ kernel + Whether to profile kernel code
+ user + Whether to profile userspace code
+
+

+The last three values are optional, if you omit them (e.g. --event=DATA_MEM_REFS:30000), +they will be set to the default values (a unit mask of 0, and profiling both kernel and +userspace code). Note that some events require a unit mask. +

+

+If OProfile is using RTC mode, and you want to alter the default counter value, +you can use something like --event=RTC_INTERRUPTS:2048. Note the last +three values here are ignored. +If OProfile is using timer-interrupt mode, there is no configuration possible. +

+

+The table below lists the events selected by default +(--event=default) for the various computer architectures: +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Processorcpu_typeDefault event
Alpha EV4alpha/ev4CYCLES:100000:0:1:1
Alpha EV5alpha/ev5CYCLES:100000:0:1:1
Alpha PCA56alpha/pca56CYCLES:100000:0:1:1
Alpha EV6alpha/ev6CYCLES:100000:0:1:1
Alpha EV67alpha/ev67CYCLES:100000:0:1:1
ARM/XScale PMU1arm/xscale1CPU_CYCLES:100000:0:1:1
ARM/XScale PMU2arm/xscale2CPU_CYCLES:100000:0:1:1
Athloni386/athlonCPU_CLK_UNHALTED:100000:0:1:1
Pentium Proi386/pproCPU_CLK_UNHALTED:100000:0:1:1
Pentium IIi386/piiCPU_CLK_UNHALTED:100000:0:1:1
Pentium IIIi386/piiiCPU_CLK_UNHALTED:100000:0:1:1
Pentium M (P6 core)i386/p6_mobileCPU_CLK_UNHALTED:100000:0:1:1
Pentium 4 (non-HT)i386/p4GLOBAL_POWER_EVENTS:100000:1:1:1
Pentium 4 (HT)i386/p4-htGLOBAL_POWER_EVENTS:100000:1:1:1
Hammerx86-64/hammerCPU_CLK_UNHALTED:100000:0:1:1
Itaniumia64/itaniumCPU_CYCLES:100000:0:1:1
Itanium 2ia64/itanium2CPU_CYCLES:100000:0:1:1
TIMER_INTtimerNone selectable
IBM iseriesPowerPC 4/5/970CYCLES:10000:0:1:1
IBM pseriesPowerPC 4/5/970CYCLES:10000:0:1:1
IBM s390timerNone selectable
IBM s390xtimerNone selectable
+
+
+
+
+
+
+
+

2. Using oprof_start

+
+
+
+

+The oprof_start application provides a convenient way to start the profiler. +Note that oprof_start is just a wrapper around the opcontrol script, +so it does not provide more services than the script itself. +

+

+After oprof_start is started you can select the event type for each counter; +the sampling rate and other related parameters are explained in Section 1, “Using opcontrol. +The "Configuration" section allows you to set general parameters such as the buffer size, kernel filename +etc. The counter setup interface should be self-explanatory; Section 3.1, “Hardware performance counters” and related +links contain information on using unit masks. +

+

+A status line shows the current status of the profiler: how long it has been running, and the average +number of interrupts received per second and the total, over all processors. +Note that quitting oprof_start does not stop the profiler. +

+

+Your configuration is saved in the same file as opcontrol uses; that is, +~/.oprofile/daemonrc. +

+
+
+
+
+
+

3. Configuration details

+
+
+
+
+
+
+
+

3.1. Hardware performance counters

+
+
+
+
+

Note

+

+Your CPU type may not include the requisite support for hardware performance counters, in which case +you must use OProfile in RTC mode in 2.4 (see Section 3.2, “OProfile in RTC mode”), or timer mode in 2.6 (see Section 3.3, “OProfile in timer interrupt mode”). +You do not really need to read this section unless you are interested in using +events other than the default event chosen by OProfile. +

+
+

+The Intel hardware performance counters are detailed in the Intel IA-32 Architecture Manual, Volume 3, available +from http://developer.intel.com/. The AMD Athlon/Duron +implementation is detailed in +http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/22007.pdf. +For PowerPC64 processors in IBM iSeries and pSeries systems, processor documentation +is available at +http://www-306.ibm.com/chips/techlib/techlib.nsf/productfamilies/PowerPC. (For example, the +specific publication containing information on the performance monitor unit for the PowerPC970 is +"IBM PowerPC 970FX RISC Microprocessor User's Manual.") +These processors are capable of delivering an interrupt when a counter overflows. +This is the basic mechanism on which OProfile is based. The delivery mode is NMI, +so blocking interrupts in the kernel does not prevent profiling. When the interrupt handler is called, +the current PC value and the current task are recorded into the profiling structure. +This allows the overflow event to be attached to a specific assembly instruction in a binary image. +The daemon receives this data from the kernel, and writes it to the sample files. +

+

+If we use an event such as CPU_CLK_UNHALTED or INST_RETIRED +(GLOBAL_POWER_EVENTS or INSTR_RETIRED, respectively, on the Pentium 4), we can +use the overflow counts as an estimate of actual time spent in each part of code. Alternatively we can profile interesting +data such as the cache behaviour of routines with the other available counters. +

+

+However there are several caveats. First, there are those issues listed in the Intel manual. There is a delay +between the counter overflow and the interrupt delivery that can skew results on a small scale - this means +you cannot rely on the profiles at the instruction level as being perfectly accurate. +If you are using an "event-mode" counter such as the cache counters, a count registered against it doesn't mean +that it is responsible for that event. However, it implies that the counter overflowed in the dynamic +vicinity of that instruction, to within a few instructions. Further details on this problem can be found in +Chapter 5, Interpreting profiling results and also in the Digital paper "ProfileMe: A Hardware Performance Counter". +

+

+Each counter has several configuration parameters. +First, there is the unit mask: this simply further specifies what to count. +Second, there is the counter value, discussed below. Third, there is a parameter whether to increment counts +whilst in kernel or user space. You can configure these separately for each counter. +

+

+After each overflow event, the counter will be re-initialized +such that another overflow will occur after this many events have been counted. Thus, higher +values mean less-detailed profiling, and lower values mean more detail, but higher overhead. +Picking a good value for this +parameter is, unfortunately, somewhat of a black art. It is of course dependent on the event +you have chosen. +Specifying too large a value will mean not enough interrupts are generated +to give a realistic profile (though this problem can be ameliorated by profiling for longer). +Specifying too small a value can lead to higher performance overhead. +

+
+
+
+
+
+

3.2. OProfile in RTC mode

+
+
+
+
+

Note

+

+This section applies to 2.2/2.4 kernels only. +

+
+

+Some CPU types do not provide the needed hardware support to use the hardware performance counters. This includes +some laptops, classic Pentiums, and other CPU types not yet supported by OProfile (such as Cyrix). +On these machines, OProfile falls +back to using the real-time clock interrupt to collect samples. This interrupt is also used by the rtc +module: you cannot have both the OProfile and rtc modules loaded nor the rtc support compiled in the kernel. +

+

+RTC mode is less capable than the hardware counters mode; in particular, it is unable to profile sections of +the kernel where interrupts are disabled. There is just one available event, "RTC interrupts", and its value +corresponds to the number of interrupts generated per second (that is, a higher number means a better profiling +resolution, and higher overhead). The current implementation of the real-time clock supports only power-of-two +sampling rates from 2 to 4096 per second. Other values within this range are rounded to the nearest power of +two. +

+

+Setting the value from the GUI should be straightforward. On the command line, you need to specify the +event to opcontrol, e.g. : +

+

+ + opcontrol --event=RTC_INTERRUPTS:256 + +

+
+
+
+
+
+

3.3. OProfile in timer interrupt mode

+
+
+
+
+

Note

+

+This section applies to 2.6 kernels and above only. +

+
+

+In 2.6 kernels on CPUs without OProfile support for the hardware performance counters, the driver +falls back to using the timer interrupt for profiling. Like the RTC mode in 2.4 kernels, this is not able to +profile code that has interrupts disabled. Note that there are no configuration parameters for +setting this, unlike the RTC and hardware performance counter setup. +

+

+You can force use of the timer interrupt by using the timer=1 module +parameter (or oprofile.timer=1 on the boot command line if OProfile is +built-in). +

+
+
+
+
+
+

3.4. Pentium 4 support

+
+
+
+

+The Pentium 4 / Xeon performance counters are organized around 3 types of model specific registers (MSRs): 45 event +selection control registers (ESCRs), 18 counter configuration control registers (CCCRs) and 18 counters. ESCRs describe a +particular set of events which are to be recorded, and CCCRs bind ESCRs to counters and configure their +operation. Unfortunately the relationship between these registers is quite complex; they cannot all be used with one +another at any time. There is, however, a subset of 8 counters, 8 ESCRs, and 8 CCCRs which can be used independently of +one another, so OProfile only accesses those registers, treating them as a bank of 8 "normal" counters, similar +to those in the P6 or Athlon families of CPU. +

+

+There is currently no support for Precision Event-Based Sampling (PEBS), nor any advanced uses of the Debug Store +(DS). Current support is limited to the conservative extension of OProfile's existing interrupt-based model described +above. Performance monitoring hardware on Pentium 4 / Xeon processors with Hyperthreading enabled (multiple logical +processors on a single die) is not supported in 2.4 kernels (you can use OProfile if you disable hyper-threading, +though). +

+
+
+
+
+
+

3.5. Intel Itanium 2 support

+
+
+
+

+The Itanium 2 performance monitoring unit (PMU) organizes the counters as four +pairs of performance event monitoring registers. Each pair is composed of a +Performance Monitoring Configuration (PMC) register and Performance Monitoring +Data (PMD) register. The PMC selects the performance event being monitored and +the PMD determines the sampling interval. The IA64 Performance Monitoring Unit +(PMU) triggers sampling with maskable interrupts. Thus, samples will not occur +in sections of the IA64 kernel where interrupts are disabled. +

+

+None of the advance features of the Itanium 2 performance monitoring unit +such as opcode matching, address range matching, or precise event sampling are +supported by this version of OProfile. The Itanium 2 support only maps OProfile's +existing interrupt-based model to the PMU hardware. +

+
+
+
+
+
+

3.6. PowerPC64 support

+
+
+
+

+The performance monitoring unit (PMU) for the PowerPC 64-bit processors +consists of between 6 and 8 counters (depending on the model), plus three +special purpose registers used for programming the counters -- MMCR0, MMCR1, +and MMCRA. Advanced features such as instruction matching and thresholding are +not supported by this version of OProfile. +

+
+
+
+
+
+

3.7. Dangerous counter settings

+
+
+
+

+OProfile is a low-level profiler which allow continuous profiling with a low-overhead cost. +If too low a count reset value is set for a counter, the system can become overloaded with counter +interrupts, and seem as if the system has frozen. Whilst some validation is done, it +is not foolproof. +

+
+

Note

+

+This can happen as follows: When the profiler count +reaches zero an NMI handler is called which stores the sample values in an internal buffer, then resets the counter +to its original value. If the count is very low, a pending NMI can be sent before the NMI handler has +completed. Due to the priority of the NMI, the local APIC delivers the pending interrupt immediately after +completion of the previous interrupt handler, and control never returns to other parts of the system. +In this way the system seems to be frozen. +

+
+

If this happens, it will be impossible to bring the system back to a workable state. +There is no way to provide real security against this happening, other than making sure to use a reasonable value +for the counter reset. For example, setting CPU_CLK_UNHALTED event type with a ridiculously low reset count (e.g. 500) +is likely to freeze the system. +

+

+In short : Don't try a foolish sample count value. Unfortunately the definition of a foolish value +is really dependent on the event type - if ever in doubt, e-mail

+ +
+
+
+
+
+
+
+

Chapter 4. Obtaining results

+
+
+
+ +

+OK, so the profiler has been running, but it's not much use unless we can get some data out. Fairly often, +OProfile does a little too good a job of keeping overhead low, and no data reaches +the profiler. This can happen on lightly-loaded machines. Remember you can force a dump at any time with : +

+

+ + opcontrol --dump + +

+

Remember to do this before complaining there is no profiling data ! +Now that we've got some data, it has to be processed. That's the job of opreport, +opannotate, or opgprof. +

+
+
+
+
+

1. Profile specifications

+
+
+
+

+All of the analysis tools take a profile specification. +This is a set of definitions that describe which actual profiles should be +examined. The simplest profile specification is empty: this will match all +the available profile files for the current session (this is what happens +when you do opreport). +

+

+Specification parameters are of the form name:value[,value]. +For example, if I wanted to get a combined symbol summary for +/bin/myprog and /bin/myprog2, +I could do opreport -l image:/bin/myprog,/bin/myprog2. +As a special case, you don't actually need to specify the image: +part here: anything left on the command line is assumed to be an +image: name. Similarly, if no session: +is specified, then session:current is assumed ("current" +is a special name of the current / last profiling session). +

+

+In addition to the comma-separated list shown above, some of the +specification parameters can take glob-style +values. For example, if I want to see image summaries for all +binaries profiled in /usr/bin/, I could do +opreport image:/usr/bin/\*. Note the necessity +to escape the special character from the shell. +

+

+For opreport, profile specifications can be used to +define two profiles, giving differential output. This is done by +enclosing each of the two specifications within curly braces, as shown +in the examples below. Any specifications outside of curly braces are +shared across both. +

+
+
+
+
+

1.1. Examples

+
+
+
+

+Image summaries for all profiles with DATA_MEM_REFS +samples in the saved session called "stresstest" : +

+ + + + +
+
+# opreport session:stresstest event:DATA_MEM_REFS
+
+
+

+Symbol summary for the application called "test_sym53c8xx,9xx". Note the +escaping is necessary as image: takes a comma-separated list. +

+ + + + +
+
+# opreport -l ./test/test_sym53c8xx\,9xx
+
+
+

+Image summaries for all binaries in the test directory, +excepting boring-test : +

+ + + + +
+
+# opreport image:./test/\* image-exclude:./test/boring-test
+
+
+

+Differential profile of a binary stored in two archives : +

+ + + + +
+
+# opreport -l /bin/bash { archive:./orig } { archive:./new }
+
+
+

+Differential profile of an archived binary with the current session : +

+ + + + +
+
+# opreport -l /bin/bash { archive:./orig } { }
+
+
+
+
+
+
+
+

1.2. Profile specification parameters

+
+
+
+
+
+
+ + archive: + + archivepath + + +
+
+

+ A path to an archive made with oparchive. + Absence of this tag, unlike others, means "the current system", + equivalent to specifying "archive:". +

+
+
+ + session: + + sessionlist + + +
+
+

+ A comma-separated list of session names to resolve in. Absence of this + tag, unlike others, means "the current session", equivalent to + specifying "session:current". +

+
+
+ + session-exclude: + + sessionlist + + +
+
+

+ A comma-separated list of sessions to exclude. +

+
+
+ + image: + + imagelist + + +
+
+

+ A comma-separated list of image names to resolve. Each entry may be relative + path, glob-style name, or full path, e.g.

+ + + + +
+
opreport 'image:/usr/bin/oprofiled,*op*,./opreport'
+
+
+
+ + image-exclude: + + imagelist + + +
+
+

+ Same as image:, but the matching images are excluded. +

+
+
+ + lib-image: + + imagelist + + +
+
+

+ Same as image:, but only for images that are for + a particular primary binary image (namely, an application). This only + makes sense to use if you're using --separate. + This includes kernel modules and the kernel when using + --separate=kernel. +

+
+
+ + lib-image-exclude: + + imagelist + + +
+
+

+ Same as lib-image:, but the matching images + are excluded. +

+
+
+ + event: + + eventlist + + +
+
+

+ The symbolic event name to match on, e.g. event:DATA_MEM_REFS. + You can pass a list of events for side-by-side comparison with opreport. + When using the timer interrupt, the event is always "TIMER". +

+
+
+ + count: + + eventcountlist + + +
+
+

+ The event count to match on, e.g. event:DATA_MEM_REFS count:30000. + Note that this value refers to the setting used for opcontrol + only, and has nothing to do with the sample counts in the profile data + itself. + You can pass a list of events for side-by-side comparison with opreport. + When using the timer interrupt, the count is always 0 (indicating it cannot be set). +

+
+
+ + unit-mask: + + masklist + + +
+
+

+ The unit mask value of the event to match on, e.g. unit-mask:1. + You can pass a list of events for side-by-side comparison with opreport. +

+
+
+ + cpu: + + cpulist + + +
+
+

+ Only consider profiles for the given numbered CPU (starting from zero). + This is only useful when using CPU profile separation. +

+
+
+ + tgid: + + pidlist + + +
+
+

+ Only consider profiles for the given task groups. Unless some program + is using threads, the task group ID of a process is the same + as its process ID. This option corresponds to the POSIX + notion of a thread group. + This is only useful when using per-process profile separation. +

+
+
+ + tid: + + tidlist + + +
+
+

+ Only consider profiles for the given threads. When using + recent thread libraries, all threads in a process share the + same task group ID, but have different thread IDs. You can + use this option in combination with tgid: to + restrict the results to particular threads within a process. + This is only useful when using per-process profile separation. +

+
+
+
+
+
+
+
+
+

1.3. Locating and managing binary images

+
+
+
+

+Each session's sample files can be found in the /var/lib/oprofile/samples/ directory. +These are used, along with the binary image files, to produce human-readable data. +In some circumstances (kernel modules in an initrd, or modules on 2.6 kernels), OProfile +will not be able to find the binary images. All the tools have an --image-path +option to which you can pass a comma-separated list of alternate paths to search. For example, +I can let OProfile find my 2.6 modules by using --image-path /lib/modules/2.6.0/kernel/. +It is your responsibility to ensure that the correct images are found when using this +option. +

+

+Note that if a binary image changes after the sample file was created, you won't be able to get useful +symbol-based data out. This situation is detected for you. If you replace a binary, you should +make sure to save the old binary if you need to do comparative profiles. +

+
+
+
+
+
+

1.4. What to do when you don't get any results

+
+
+
+

+When attempting to get output, you may see the error : +

+ + + + +
+
+error: no sample files found: profile specification too strict ?
+
+
+

+What this is saying is that the profile specification you passed in, +when matched against the available sample files, resulted in no matches. +There are a number of reasons this might happen: +

+
+
+
+ spelling +
+
+

+You specified a binary name, but spelt it wrongly. Check your spelling ! +

+
+
+ profiler wasn't running +
+
+

+Make very sure that OProfile was actually up and running when you ran +the binary. +

+
+
+ binary didn't run long enough +
+
+

+Remember OProfile is a statistical profiler - you're not guaranteed to +get samples for short-running programs. You can help this by using a +lower count for the performance counter, so there are a lot more samples +taken per second. +

+
+
+ binary spent most of its time in libraries +
+
+

+Similarly, if the binary spends little time in the main binary image +itself, with most of it spent in shared libraries it uses, you might +not see any samples for the binary image itself. You can check this +by using opcontrol --separate=lib before the +profiling session, so opreport and friends show +the library profiles on a per-application basis. +

+
+
+ specification was really too strict +
+
+

+For example, you specified something like tgid:3433, +but no task with that group ID ever ran the code. +

+
+
+ binary didn't generate any events +
+
+

+If you're using a particular event counter, for example counting MMX +operations, the code might simply have not generated any events in the +first place. Verify the code you're profiling does what you expect it +to. +

+
+
+ you didn't specify kernel module name correctly +
+
+

+If you're using 2.6 kernels, and trying to get reports for a kernel +module, make sure to use the -p option, and specify the +module name with the .ko +extension. Check if the module is one loaded from initrd. +

+
+
+
+
+
+
+
+
+
+

2. Image summaries and symbol summaries (opreport)

+
+
+
+

+The opreport utility is the primary utility you will use for +getting formatted data out of OProfile. It produces two types of data: image summaries +and symbol summaries. An image summary lists the number of samples for individual +binary images such as libraries or applications. Symbol summaries provide per-symbol +profile data. In the following example, we're getting an image summary for the whole +system: +

+ + + + +
+
+$ opreport --long-filenames
+CPU: PIII, speed 863.195 MHz (estimated)
+Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a unit mask of 0x00 (No unit mask) count 23150
+   905898 59.7415 /usr/lib/gcc-lib/i386-redhat-linux/3.2/cc1plus
+   214320 14.1338 /boot/2.6.0/vmlinux
+   103450  6.8222 /lib/i686/libc-2.3.2.so
+    60160  3.9674 /usr/local/bin/madplay
+    31769  2.0951 /usr/local/oprofile-pp/bin/oprofiled
+    26550  1.7509 /usr/lib/libartsflow.so.1.0.0
+    23906  1.5765 /usr/bin/as
+    18770  1.2378 /oprofile
+    15528  1.0240 /usr/lib/qt-3.0.5/lib/libqt-mt.so.3.0.5
+    11979  0.7900 /usr/X11R6/bin/XFree86
+    11328  0.7471 /bin/bash
+    ...
+
+
+

+If we had specified --symbols in the previous command, we would have +gotten a symbol summary of all the images across the entire system. We can restrict this to only +part of the system profile; for example, +below is a symbol summary of the OProfile daemon. Note that as we used +opcontrol --separate=kernel, symbols from images that oprofiled +has used are also shown. +

+ + + + +
+
+$ opreport -l `which oprofiled` 2>/dev/null | more
+CPU: PIII, speed 863.195 MHz (estimated)
+Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a unit mask of 0x00 (No unit mask) count 23150
+vma      samples  %           image name               symbol name
+0804be10 14971    28.1993     oprofiled                odb_insert
+0804afdc 7144     13.4564     oprofiled                pop_buffer_value
+c01daea0 6113     11.5144     vmlinux                  __copy_to_user_ll
+0804b060 2816      5.3042     oprofiled                opd_put_sample
+0804b4a0 2147      4.0441     oprofiled                opd_process_samples
+0804acf4 1855      3.4941     oprofiled                opd_put_image_sample
+0804ad84 1766      3.3264     oprofiled                opd_find_image
+0804a5ec 1084      2.0418     oprofiled                opd_find_module
+0804ba5c 741       1.3957     oprofiled                odb_hash_add_node
+...
+
+
+

+These are the two basic ways you are most likely to use regularly, but opreport +can do a lot more than that, as described below. +

+

2.1. Merging separate profiles

+ +If you have used one of the --separate= options +whilst profiling, there can be several separate profiles for +a single binary image within a session. Normally the output +will keep these images separated (so, for example, the image summary +output shows library image summaries on a per-application basis, +when using --separate=lib). +Sometimes it can be useful to merge these results back together +before getting results. The --merge option allows +you to do that. +
+

2.2. Side-by-side multiple results

+If you have used multiple events when profiling, by default you get +side-by-side results of each event's sample values from opreport. +You can restrict which events to list by appropriate use of the +event: profile specifications, etc. +
+
+
+
+
+

2.3. Callgraph output

+
+
+
+

+When using the opcontrol --callgraph option, you can see what +functions are calling other functions in the output. Consider the +following program: +

+ + + + +
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define SIZE 500000
+
+static int compare(const void *s1, const void *s2)
+{
+        return strcmp(s1, s2);
+}
+
+static void repeat(void)
+{
+        int i;
+        char *strings[SIZE];
+        char str[] = "abcdefghijklmnopqrstuvwxyz";
+
+        for (i = 0; i < SIZE; ++i) {
+                strings[i] = strdup(str);
+                strfry(strings[i]);
+        }
+
+        qsort(strings, SIZE, sizeof(char *), compare);
+}
+
+int main()
+{
+        while (1)
+                repeat();
+}
+
+
+

+When running with the call-graph option, OProfile will +record the function stack every time it takes a sample. +opreport --callgraph outputs an entry for each +function, where each entry looks similar to: +

+ + + + +
+
+samples  %        image name               symbol name
+  197       0.1548  cg                       main
+  127036   99.8452  cg                       repeat
+84590    42.5084  libc-2.3.2.so            strfry
+  84590    66.4838  libc-2.3.2.so            strfry [self]
+  39169    30.7850  libc-2.3.2.so            random_r
+  3475      2.7312  libc-2.3.2.so            __i686.get_pc_thunk.bx
+-------------------------------------------------------------------------------
+
+
+

+Here the non-indented line is the function we're focussing upon +(strfry()). This +line is the same as you'd get from a normal opreport +output. +

+

+Above the non-indented line we find the functions that called this +function (for example, repeat() calls +strfry()). The samples and percentage values here +refer to the number of times we took a sample where this call was found +in the stack; the percentage is relative to all other callers of the +function we're focussing on. Note that these values are +not call counts; they only reflect the call stack +every time a sample is taken; that is, if a call is found in the stack +at the time of a sample, it is recorded in this count. +

+

+Below the line are functions that are called by +strfry() (called callees). +It's clear here that strfry() calls +random_r(). We also see a special entry with a +"[self]" marker. This records the normal samples for the function, but +the percentage becomes relative to all callees. This allows you to +compare time spent in the function itself compared to functions it +calls. Note that if a function calls itself, then it will appear in the +list of callees of itself, but without the "[self]" marker; so recursive +calls are still clearly separable. +

+

+You may have noticed that the output lists main() +as calling strfry(), but it's clear from the source +that this doesn't actually happen. See Section 3, “Interpreting call-graph profiles” for an explanation. +

+
+
+
+
+
+

2.4. Differential profiles with opreport

+
+
+
+

+Often, we'd like to be able to compare two profiles. For example, when +analysing the performance of an application, we'd like to make code +changes and examine the effect of the change. This is supported in +opreport by giving a profile specification that +identifies two different profiles. The general form is of: +

+ + + + +
+
+$ opreport <shared-spec> { <first-profile> } { <second-profile> }
+
+
+

+For each of the profiles, the shared section is prefixed, and then the +specification is analysed. The usual parameters work both within the +shared section, and in the sub-specification within the curly braces. +

+

+A typical way to use this feature is with archives created with +oparchive. Let's look at an example: +

+ + + + +
+
+$ ./a
+$ oparchive -o orig ./a
+$ opcontrol --reset
+  # edit and recompile a
+$ ./a
+  # now compare the current profile of a with the archived profile
+$ opreport -xl ./a { archive:./orig } { }
+CPU: PIII, speed 863.233 MHz (estimated)
+Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a
+unit mask of 0x00 (No unit mask) count 100000
+samples  %        diff %    symbol name
+92435    48.5366  +0.4999   a
+54226    ---      ---       c
+49222    25.8459  +++       d
+48787    25.6175  -2.2e-01  b
+
+
+

+Note that we specified an empty second profile in the curly braces, as +we wanted to use the current session; alternatively, we could +have specified another archive, or a tgid etc. We specified the binary +a in the shared section, so we matched that in both +the profiles we're diffing. +

+

+As in the normal output, the results are sorted by the number of +samples, and the percentage field represents the relative percentage of +the symbol's samples in the second profile. +

+

+Notice the new column in the output. This value represents the +percentage change of the relative percent between the first and the +second profile: roughly, "how much more important this symbol is". +Looking at the symbol a(), we can see that it took +roughly the same amount of the total profile in both the first and the +second profile. The function c() was not in the new +profile, so has been marked with ---. Note that the +sample value is the number of samples in the first profile; since we're +displaying results for the second profile, we don't list a percentage +value for it, as it would be meaningless. d() is +new in the second profile, and consequently marked with ++++. +

+

+When comparing profiles between different binaries, it should be clear +that functions can change in terms of VMA and size. To avoid this +problem, opreport considers a symbol to be the same +if the symbol name, image name, and owning application name all match; +any other factors are ignored. Note that the check for application name +means that trying to compare library profiles between two different +applications will not work as you might expect: each symbol will be +considered different. +

+
+
+
+
+
+

2.5. Anonymous executable mappings

+
+
+
+

+Many applications, typically ones involving dynamic compilation into +machine code, have executable mappings that are not backed by an ELF +file. opreport has basic support for showing the +samples taken in these regions; for example: +

+ + + + +
+
+$ opreport /usr/jre1.5.0/bin/java
+CPU: PIII, speed 863.195 MHz (estimated)
+Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a unit mask of 0x00 (No unit mask) count 100000
+CPU_CLK_UNHALT...|
+  samples|      %|
+------------------
+    27344 100.000 java
+        CPU_CLK_UNHALT...|
+          samples|      %|
+        ------------------
+            27236  99.605 anon (tgid:12135 range:0xb2cb8000-0xb2e80000)
+              108  0.3949 java
+
+
+

+Currently, there is no support for getting symbol-based summaries for +such regions. Note that, since such mappings are dependent upon +individual invocations of a binary, these mappings are always listed as +a dependent image, even when using --separate=none. +Equally, the results are not affected by the --merge +option. +

+
+
+
+
+
+

2.6. Options for opreport

+
+
+
+
+
+
+ + --accumulated / -a + +
+
+

+Accumulate sample and percentage counts in the symbol list. +

+
+
+ + --callgraph / -c + +
+
+

+Show callgraph information. +

+
+
+ + --debug-info / -g + +
+
+

+Show source file and line for each symbol. +

+
+
+ + --demangle / -D none|normal|smart + +
+
+

+none: no demangling. normal: use default demangler (default) smart: use +pattern-matching to make C++ symbol demangling more readable. +

+
+
+ + --details / -d + +
+
+

+Show per-instruction details for all selected symbols. Note that, for +binaries without symbol information, the VMA values shown are raw file +offsets for the image binary. +

+
+
+ + --exclude-dependent / -x + +
+
+

+Do not include application-specific images for libraries, kernel modules +and the kernel. This option only makes sense if the profile session +used --separate. +

+
+
+ + --exclude-symbols / -e [symbols] + +
+
+

+Exclude all the symbols in the given comma-separated list. +

+
+
+ + --global-percent / -% + +
+
+

+Make all percentages relative to the whole profile. +

+
+
+ + --help / -? / --usage + +
+
+

+Show help message. +

+
+
+ + --image-path / -p [paths] + +
+
+

+Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. +

+
+
+ + --include-symbols / -i [symbols] + +
+
+

+Only include symbols in the given comma-separated list. +

+
+
+ + --long-filenames / -l + +
+
+

+Output full paths instead of basenames. +

+
+
+ + --merge / -m [lib,cpu,tid,tgid,unitmask,all] + +
+
+

+Merge any profiles separated in a --separate session. +

+
+
+ + --no-header + +
+
+

+Don't output a header detailing profiling parameters. +

+
+
+ + --output-file / -o [file] + +
+
+

+Output to the given file instead of stdout. +

+
+
+ + --reverse-sort / -r + +
+
+

+Reverse the sort from the default. +

+
+
+ + --show-address / -w + +
+
+

+Show the VMA address of each symbol (off by default). +

+
+
+ + --sort / -s [vma,sample,symbol,debug,image] + +
+
+

+Sort the list of symbols by, respectively, symbol address, +number of samples, symbol name, debug filename and line number, +binary image filename. +

+
+
+ + --symbols / -l + +
+
+

+List per-symbol information instead of a binary image summary. +

+
+
+ + --threshold / -t [percentage] + +
+
+

+Only output data for symbols that have more than the given percentage +of total samples. +

+
+
+ + --verbose / -V [options] + +
+
+

+Give verbose debugging output. +

+
+
+ + --version / -v + +
+
+

+Show version. +

+
+
+
+
+
+
+
+
+
+

3. Outputting annotated source (opannotate)

+
+
+
+

+The opannotate utility generates annotated source files or assembly listings, optionally +mixed with source. +If you want to see the source file, the profiled application needs to have debug information, and the source +must be available through this debug information. For GCC, you must use the -g option +when you are compiling. +If the binary doesn't contain sufficient debug information, you can still +use opannotate --assembly to get annotated assembly. +

+

+Note that for the reason explained in Section 3.1, “Hardware performance counters” the results can be +inaccurate. The debug information itself can add other problems; for example, the line number for a symbol can be +incorrect. Assembly instructions can be re-ordered and moved by the compiler, and this can lead to +crediting source lines with samples not really "owned" by this line. Also see +Chapter 5, Interpreting profiling results. +

+

+You can output the annotation to one single file, containing all the source found using the +--source. You can use this in conjunction with --assembly +to get combined source/assembly output. +

+

+You can also output a directory of annotated source files that maintains the structure of +the original sources. Each line in the annotated source is prepended with the samples +for that line. Additionally, each symbol is annotated giving details for the symbol +as a whole. An example: +

+ + + + +
+
+$ opannotate --source --output-dir=annotated /usr/local/oprofile-pp/bin/oprofiled
+$ ls annotated/home/moz/src/oprofile-pp/daemon/
+opd_cookie.h  opd_image.c  opd_kernel.c  opd_sample_files.c  oprofiled.c
+
+
+

+Line numbers are maintained in the source files, but each file has +a footer appended describing the profiling details. The actual annotation +looks something like this : +

+ + + + +
+
+...
+               :static uint64_t pop_buffer_value(struct transient * trans)
+ 11510  1.9661 :{ /* pop_buffer_value total:  89901 15.3566 */
+               :        uint64_t val;
+               :
+ 10227  1.7469 :        if (!trans->remaining) {
+               :                fprintf(stderr, "BUG: popping empty buffer !\n");
+               :                exit(EXIT_FAILURE);
+               :        }
+               :
+               :        val = get_buffer_value(trans->buffer, 0);
+  2281  0.3896 :        trans->remaining--;
+  2296  0.3922 :        trans->buffer += kernel_pointer_size;
+               :        return val;
+ 10454  1.7857 :}
+...
+
+
+

+The first number on each line is the number of samples, whilst the second is +the relative percentage of total samples. +

+
+
+
+
+

3.1. Locating source files

+
+
+
+

+Of course, opannotate needs to be able to locate the source files +for the binary image(s) in order to produce output. Some binary images have debug +information where the given source file paths are relative, not absolute. You can +specify search paths to look for these files (similar to gdb's +dir command) with the --search-dirs option. +

+

+Sometimes you may have a binary image which gives absolute paths for the source files, +but you have the actual sources elsewhere (commonly, you've installed an SRPM for +a binary on your system and you want annotation from an existing profile). You can +use the --base-dirs option to redirect OProfile to look somewhere +else for source files. For example, imagine we have a binary generated from a source +file that is given in the debug information as /tmp/build/libfoo/foo.c, +and you have the source tree matching that binary installed in /home/user/libfoo/. +You can redirect OProfile to find foo.c correctly like this : +

+ + + + +
+
+$ opannotate --source --base-dirs=/tmp/build/libfoo/ --search-dirs=/home/user/libfoo/ --output-dir=annotated/ /lib/libfoo.so
+
+
+

+You can specify multiple (comma-separated) paths to both options. +

+
+
+
+
+
+

3.2. Usage of opannotate

+
+
+
+
+
+
+ + --assembly / -a + +
+
+

+Output annotated assembly. If this is combined with --source, then mixed +source / assembly annotations are output. +

+
+
+ + --base-dirs / -b [paths]/ + +
+
+

+Comma-separated list of path prefixes. This can be used to point OProfile to a +different location for source files when the debug information specifies an +absolute path on your system for the source that does not exist. The prefix +is stripped from the debug source file paths, then searched in the search dirs +specified by --search-dirs. +

+
+
+ + --demangle / -D none|normal|smart + +
+
+

+none: no demangling. normal: use default demangler (default) smart: use +pattern-matching to make C++ symbol demangling more readable. +

+
+
+ + --exclude-dependent / -x + +
+
+

+Do not include application-specific images for libraries, kernel modules +and the kernel. This option only makes sense if the profile session +used --separate. +

+
+
+ + --exclude-file [files] + +
+
+

+Exclude all files in the given comma-separated list of glob patterns. +

+
+
+ + --exclude-symbols / -e [symbols] + +
+
+

+Exclude all the symbols in the given comma-separated list. +

+
+
+ + --help / -? / --usage + +
+
+

+Show help message. +

+
+
+ + --image-path / -p [paths] + +
+
+

+Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. +

+
+
+ + --include-file [files] + +
+
+

+Only include files in the given comma-separated list of glob patterns. +

+
+
+ + --include-symbols / -i [symbols] + +
+
+

+Only include symbols in the given comma-separated list. +

+
+
+ + --objdump-params [params] + +
+
+

+Pass the given parameters as extra values when calling objdump. +

+
+
+ + --output-dir / -o [dir] + +
+
+

+Output directory. This makes opannotate output one annotated file for each +source file. This option can't be used in conjunction with --assembly. +

+
+
+ + --search-dirs / -d [paths] + +
+
+

+Comma-separated list of paths to search for source files. This is useful to find +source files when the debug information only contains relative paths. +

+
+
+ + --source / -s + +
+
+

+Output annotated source. This requires debugging information to be available +for the binaries. +

+
+
+ + --threshold / -t [percentage] + +
+
+

+Only output data for symbols that have more than the given percentage +of total samples. +

+
+
+ + --verbose / -V [options] + +
+
+

+Give verbose debugging output. +

+
+
+ + --version / -v + +
+
+

+Show version. +

+
+
+
+
+
+
+
+
+
+

4. gprof-compatible output (opgprof)

+
+
+
+

+If you're familiar with the output produced by GNU gprof, +you may find opgprof useful. It takes a single binary +as an argument, and produces a gmon.out file for use +with gprof -p. If call-graph profiling is enabled, +then this is also included. +

+ + + + +
+
+$ opgprof `which oprofiled` # generates gmon.out file
+$ gprof -p `which oprofiled` | head
+Flat profile:
+
+Each sample counts as 1 samples.
+  %   cumulative   self              self     total
+ time   samples   samples    calls  T1/call  T1/call  name
+ 33.13 206237.00 206237.00                             odb_insert
+ 22.67 347386.00 141149.00                             pop_buffer_value
+  9.56 406881.00 59495.00                             opd_put_sample
+  7.34 452599.00 45718.00                             opd_find_image
+  7.19 497327.00 44728.00                             opd_process_samples
+
+
+
+
+
+
+

4.1. Usage of opgprof

+
+
+
+
+
+
+ + --help / -? / --usage + +
+
+

+Show help message. +

+
+
+ + --image-path / -p [paths] + +
+
+

+Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. +

+
+
+ + --output-filename / -o [file] + +
+
+

+Output to the given file instead of the default, gmon.out +

+
+
+ + --threshold / -t [percentage] + +
+
+

+Only output data for symbols that have more than the given percentage +of total samples. +

+
+
+ + --verbose / -V [options] + +
+
+

+Give verbose debugging output. +

+
+
+ + --version / -v + +
+
+

+Show version. +

+
+
+
+
+
+
+
+
+
+

5. Archiving measurements (oparchive)

+
+
+
+

+ The oparchive utility generates a directory populated + with executable, debug, and oprofile sample files. This directory can be + moved to another machine via tar and analyzed without + further use of the data collection machine. +

+

+ The following command would collect the sample files, the executables + associated with the sample files, and the debuginfo files associated + with the executables and copy them into + /tmp/current_data: +

+ + + + +
+
+# oparchive -o /tmp/current_data
+
+
+
+
+
+
+

5.1. Usage of oparchive

+
+
+
+
+
+
+ + --help / -? / --usage + +
+
+

+Show help message. +

+
+
+ + --exclude-dependent / -x + +
+
+

+Do not include application-specific images for libraries, kernel modules +and the kernel. This option only makes sense if the profile session +used --separate. +

+
+
+ + --image-path / -p [paths] + +
+
+

+Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. +

+
+
+ + --output-directory / -o [directory] + +
+
+

+Output to the given directory. There is no default. This must be specified. +

+
+
+ + --verbose / -V [options] + +
+
+

+Give verbose debugging output. +

+
+
+ + --version / -v + +
+
+

+Show version. +

+
+
+
+
+
+
+
+
+
+
+

Chapter 5. Interpreting profiling results

+
+
+
+ +

+The standard caveats of profiling apply in interpreting the results from OProfile: +profile realistic situations, profile different scenarios, profile +for as long as a time as possible, avoid system-specific artifacts, don't trust +the profile data too much. Also bear in mind the comments on the performance +counters above - you cannot rely on totally accurate +instruction-level profiling. However, for almost all circumstances the data +can be useful. Ideally a utility such as Intel's VTUNE would be available to +allow careful instruction-level analysis; go hassle Intel for this, not me ;) +

+
+
+
+
+

1. Profiling interrupt latency

+
+
+
+

+This is an example of how the latency of delivery of profiling interrupts +can impact the reliability of the profiling data. This is pretty much a +worst-case-scenario example: these problems are fairly rare. +

+ + + + +
+
+double fun(double a, double b, double c)
+{
+ double result = 0;
+ for (int i = 0 ; i < 10000; ++i) {
+  result += a;
+  result *= b;
+  result /= c;
+ }
+ return result;
+}
+
+
+

+Here the last instruction of the loop is very costly, and you would expect the result +reflecting that - but (cutting the instructions inside the loop): +

+ + + + +
+
+$ opannotate -a -t 10 ./a.out
+
+     88 15.38% : 8048337:       fadd   %st(3),%st
+     48 8.391% : 8048339:       fmul   %st(2),%st
+     68 11.88% : 804833b:       fdiv   %st(1),%st
+    368 64.33% : 804833d:       inc    %eax
+               : 804833e:       cmp    $0x270f,%eax
+               : 8048343:       jle    8048337
+
+
+

+The problem comes from the x86 hardware; when the counter overflows the IRQ +is asserted but the hardware has features that can delay the NMI interrupt: +x86 hardware is synchronous (i.e. cannot interrupt during an instruction); +there is also a latency when the IRQ is asserted, and the multiple +execution units and the out-of-order model of modern x86 CPUs also causes +problems. This is the same function, with annotation : +

+ + + + +
+
+$ opannotate -s -t 10 ./a.out
+
+               :double fun(double a, double b, double c)
+               :{ /* _Z3funddd total:     572 100.0% */
+               : double result = 0;
+    368 64.33% : for (int i = 0 ; i < 10000; ++i) {
+     88 15.38% :  result += a;
+     48 8.391% :  result *= b;
+     68 11.88% :  result /= c;
+               : }
+               : return result;
+               :}
+
+
+

+The conclusion: don't trust samples coming at the end of a loop, +particularly if the last instruction generated by the compiler is costly. This +case can also occur for branches. Always bear in mind that samples +can be delayed by a few cycles from its real position. That's a hardware +problem and OProfile can do nothing about it. +

+
+
+
+
+
+

2. Kernel profiling

+
+
+
+
+
+
+
+

2.1. Interrupt masking

+
+
+
+

+OProfile uses non-maskable interrupts (NMI) on the P6 generation, Pentium 4, +Athlon and Duron processors. These interrupts can occur even in section of the +Linux where interrupts are disabled, allowing collection of samples in virtually +all executable code. The RTC, timer interrupt mode, and Itanium 2 collection mechanisms +use maskable interrupts. Thus, the RTC and Itanium 2 data collection mechanism have "sample +shadows", or blind spots: regions where no samples will be collected. Typically, the samples +will be attributed to the code immediately after the interrupts are re-enabled. +

+
+
+
+
+
+

2.2. Idle time

+
+
+
+

+Your kernel is likely to support halting the processor when a CPU is idle. As +the typical hardware events like CPU_CLK_UNHALTED do not +count when the CPU is halted, the kernel profile will not reflect the actual +amount of time spent idle. You can change this behaviour by booting with +the idle=poll option, which uses a different idle routine. This +will appear as poll_idle() in your kernel profile. +

+
+
+
+
+
+

2.3. Profiling kernel modules

+
+
+
+

+OProfile profiles kernel modules by default. However, there are a couple of problems +you may have when trying to get results. First, you may have booted via an initrd; +this means that the actual path for the module binaries cannot be determined automatically. +To get around this, you can use the -p option to the profiling tools +to specify where to look for the kernel modules. +

+

+In 2.6, the information on where kernel module binaries are located has been removed. +This means OProfile needs guiding with the -p option to find your +modules. Normally, you can just use your standard module top-level directory for this. +Note that due to this problem, OProfile cannot check that the modification times match; +it is your responsibility to make sure you do not modify a binary after a profile +has been created. +

+

+If you have run insmod or modprobe to insert a module +in a particular directory, it is important that you specify this directory with the +-p option first, so that it over-rides an older module binary that might +exist in other directories you've specified with -p. It is up to you +to make sure that these values are correct: 2.6 kernels simply do not provide enough +information for OProfile to get this information. +

+
+
+
+
+
+
+

3. Interpreting call-graph profiles

+
+
+
+

+Sometimes the results from call-graph profiles may be different to what +you expect to see. The first thing to check is whether the target +binaries where compiled with frame pointers enabled (if the binary was +compiled using gcc's +-fomit-frame-pointer option, you will not get +meaningful results). Note that as of this writing, the GCC developers +plan to disable frame pointers by default. The Linux kernel is built +without frame pointers by default; there is a configuration option you +can use to turn it on under the "Kernel Hacking" menu. +

+

+Often you may see a caller of a function that does not actually directly +call the function you're looking at (e.g. if a() +calls b(), which in turn calls +c(), you may see an entry for +a()->c()). What's actually occurring is that we +are taking samples at the very start (or the very end) of +c(); at these few instructions, we haven't yet +created the new function's frame, so it appears as if +a() is calling directly into +c(). Be careful not to be misled by these +entries. +

+

+Like the rest of OProfile, call-graph profiling uses a statistical +approach; this means that sometimes a backtrace sample is truncated, or +even partially wrong. Bear this in mind when examining results. +

+
+
+
+
+
+

4. Inaccuracies in annotated source

+
+
+
+
+
+
+
+

4.1. Side effects of optimizations

+
+
+
+

+The compiler can introduce some pitfalls in the annotated source output. +The optimizer can move pieces of code in such manner that two line of codes +are interlaced (instruction scheduling). Also debug info generated by the compiler +can show strange behavior. This is especially true for complex expressions e.g. inside +an if statement: +

+ + + + +
+
+	if (a && ..
+	    b && ..
+	    c &&)
+
+
+

+here the problem come from the position of line number. The available debug +info does not give enough details for the if condition, so all samples are +accumulated at the position of the right brace of the expression. Using +opannotate -a can help to show the real +samples at an assembly level. +

+
+
+
+
+
+

4.2. Prologues and epilogues

+
+
+
+

+The compiler generally needs to generate "glue" code across function calls, dependent +on the particular function call conventions used. Additionally other things +need to happen, like stack pointer adjustment for the local variables; this +code is known as the function prologue. Similar code is needed at function return, +and is known as the function epilogue. This will show up in annotations as +samples at the very start and end of a function, where there is no apparent +executable code in the source. +

+
+
+
+
+
+

4.3. Inlined functions

+
+
+
+

+You may see that a function is credited with a certain number of samples, but +the listing does not add up to the correct total. To pick a real example : +

+ + + + +
+
+               :internal_sk_buff_alloc_security(struct sk_buff *skb)
+ 353 2.342%    :{ /* internal_sk_buff_alloc_security total: 1882 12.48% */
+               :
+               :        sk_buff_security_t *sksec;
+  15 0.0995%   :        int rc = 0;
+               :
+  10 0.06633%  :        sksec = skb->lsm_security;
+ 468 3.104%    :        if (sksec && sksec->magic == DSI_MAGIC) {
+               :                goto out;
+               :        }
+               :
+               :        sksec = (sk_buff_security_t *) get_sk_buff_memory(skb);
+   3 0.0199%   :        if (!sksec) {
+  38 0.2521%   :                rc = -ENOMEM;
+               :                goto out;
+  10 0.06633%  :        }
+               :        memset(sksec, 0, sizeof (sk_buff_security_t));
+  44 0.2919%   :        sksec->magic = DSI_MAGIC;
+  32 0.2123%   :        sksec->skb = skb;
+  45 0.2985%   :        sksec->sid = DSI_SID_NORMAL;
+  31 0.2056%   :        skb->lsm_security = sksec;
+               :
+               :      out:
+               :
+ 146 0.9685%   :        return rc;
+               :
+  98 0.6501%   :}
+
+
+

+Here, the function is credited with 1,882 samples, but the annotations +below do not account for this. This is usually because of inline functions - +the compiler marks such code with debug entries for the inline function +definition, and this is where opannotate annotates +such samples. In the case above, memset is the most +likely candidate for this problem. Examining the mixed source/assembly +output can help identify such results. +

+

+When running opannotate, you may get a warning +"some functions compiled without debug information may have incorrect source line attributions". +In some rare cases, OProfile is not able to verify that the derived source line +is correct (when some parts of the binary image are compiled without debugging +information). Be wary of results if this warning appears. +

+

+Furthermore, for some languages the compiler can implicitly generate functions, +such as default copy constructors. Such functions are labelled by the compiler +as having a line number of 0, which means the source annotation can be confusing. +

+
+
+
+
+
+

4.4. Inaccuracy in line number information

+
+
+
+

+Depending on your compiler you can fall into the following problem: +

+ + + + +
+
+struct big_object { int a[500]; };
+
+int main()
+{
+	big_object a, b;
+	for (int i = 0 ; i != 1000 * 1000; ++i)
+		b = a;
+	return 0;
+}
+
+
+
+

+Compiled with gcc 3.0.4 the annotated source is clearly inaccurate: +

+ + + + +
+
+               :int main()
+               :{  /* main total: 7871 100% */
+               :        big_object a, b;
+               :        for (int i = 0 ; i != 1000 * 1000; ++i)
+               :                b = a;
+ 7871 100%     :        return 0;
+               :}
+
+
+

+The problem here is distinct from the IRQ latency problem; the debug line number +information is not precise enough; again, looking at output of opannoatate -as can help. +

+ + + + +
+
+               :int main()
+               :{
+               :        big_object a, b;
+               :        for (int i = 0 ; i != 1000 * 1000; ++i)
+               : 80484c0:       push   %ebp
+               : 80484c1:       mov    %esp,%ebp
+               : 80484c3:       sub    $0xfac,%esp
+               : 80484c9:       push   %edi
+               : 80484ca:       push   %esi
+               : 80484cb:       push   %ebx
+               :                b = a;
+               : 80484cc:       lea    0xfffff060(%ebp),%edx
+               : 80484d2:       lea    0xfffff830(%ebp),%eax
+               : 80484d8:       mov    $0xf423f,%ebx
+               : 80484dd:       lea    0x0(%esi),%esi
+               :        return 0;
+    3 0.03811% : 80484e0:       mov    %edx,%edi
+               : 80484e2:       mov    %eax,%esi
+    1 0.0127%  : 80484e4:       cld
+    8 0.1016%  : 80484e5:       mov    $0x1f4,%ecx
+ 7850 99.73%   : 80484ea:       repz movsl %ds:(%esi),%es:(%edi)
+    9 0.1143%  : 80484ec:       dec    %ebx
+               : 80484ed:       jns    80484e0
+               : 80484ef:       xor    %eax,%eax
+               : 80484f1:       pop    %ebx
+               : 80484f2:       pop    %esi
+               : 80484f3:       pop    %edi
+               : 80484f4:       leave
+               : 80484f5:       ret
+
+
+

+So here it's clear that copying is correctly credited with of all the samples, but the +line number information is misplaced. objdump -dS exposes the +same problem. Note that maintaining accurate debug information for compilers when optimizing is difficult, so this problem is not suprising. +The problem of debug information +accuracy is also dependent on the binutils version used; some BFD library versions +contain a work-around for known problems of gcc, some others do not. This is unfortunate but we must live with that, +since profiling is pointless when you disable optimisation (which would give better debugging entries). +

+
+
+
+
+
+
+

5. Assembly functions

+
+
+
+

+Often the assembler cannot generate debug information automatically. +This means that you cannot get a source report unless +you manually define the neccessary debug information; read your assembler documentation for how you might +do that. The only +debugging info needed currently by OProfile is the line-number/filename-VMA association. When profiling assembly +without debugging info you can always get report for symbols, and optionally for VMA, through opreport -l +or opreport -d, but this works only for symbols with the right attributes. +For gas you can get this by +

+ + + + +
+
+.globl foo
+	.type	foo,@function
+
+
+

+whilst for nasm you must use +

+ + + + +
+
+	  GLOBAL foo:function		; [1]
+
+
+

+Note that OProfile does not need the global attribute, only the function attribute. +

+
+
+
+
+
+

6. Other discrepancies

+
+
+
+

+Another cause of apparent problems is the hidden cost of instructions. A very +common example is two memory reads: one from L1 cache and the other from memory: +the second memory read is likely to have more samples. +There are many other causes of hidden cost of instructions. A non-exhaustive +list: mis-predicted branch, TLB cache miss, partial register stall, +partial register dependencies, memory mismatch stall, re-executed µops. If you want to write +programs at the assembly level, be sure to take a look at the Intel and +AMD documentation at http://developer.intel.com/ +and http://www.amd.com/products/cpg/athlon/techdocs/. +

+
+
+
+
+
+
+

Chapter 6. Acknowledgments

+
+
+
+

+Thanks to (in no particular order) : Arjan van de Ven, Rik van Riel, Juan Quintela, Philippe Elie, +Phillipp Rumpf, Tigran Aivazian, Alex Brown, Alisdair Rawsthorne, Bob Montgomery, Ray Bryant, H.J. Lu, +Jeff Esper, Will Cohen, Graydon Hoare, Cliff Woolley, Alex Tsariounov, Al Stone, Jason Yeh, +Randolph Chung, Anton Blanchard, Richard Henderson, Andries Brouwer, Bryan Rittmeyer, +Maynard P. Johnson, +Richard Reich (rreich@rdrtech.com), Zwane Mwaikambo, Dave Jones, Charles Filtness; and finally Pulp, for "Intro". +

+
+
+ + diff --git a/doc/oprofile.xml b/doc/oprofile.xml new file mode 100644 index 0000000..3e0f296 --- /dev/null +++ b/doc/oprofile.xml @@ -0,0 +1,2367 @@ + + + + + + OProfile manual + + + + John + Levon + +
levon@movementarian.org
+
+
+
+ + + 2000-2004 + Victoria University of Manchester, John Levon and others + +
+ + + + +Introduction + + +This manual applies to OProfile version . +OProfile is a profiling system for Linux 2.2/2.4/2.6 systems on a number of architectures. It is capable of profiling +all parts of a running system, from the kernel (including modules and interrupt handlers) to shared libraries +to binaries. It runs transparently in the background collecting information at a low overhead. These +features make it ideal for profiling entire systems to determine bottle necks in real-world systems. + + +Many CPUs provide "performance counters", hardware registers that can count "events"; for example, +cache misses, or CPU cycles. OProfile provides profiles of code based on the number of these occurring events: +repeatedly, every time a certain (configurable) number of events has occurred, the PC value is recorded. +This information is aggregated into profiles for each binary image. + +Some hardware setups do not allow OProfile to use performance counters: in these cases, no +events are available, and OProfile operates in timer/RTC mode, as described in later chapters. + + +Applications of OProfile + +OProfile is useful in a number of situations. You might want to use OProfile when you : + + +need low overhead +cannot use highly intrusive profiling methods +need to profile interrupt handlers +need to profile an application and its shared libraries +need to capture the performance behaviour of entire system +want to examine hardware effects such as cache misses +want detailed source annotation +want instruction-level profiles +want call-graph profiles + + +OProfile is not a panacea. OProfile might not be a complete solution when you : + + +require call graph profiles on platforms other than 2.6/x86 +don't have root permissions +require 100% instruction-accurate profiles +need function call counts or an interstitial profiling API +cannot tolerate any disturbance to the system whatsoever +need to profile interpreted or dynamically compiled code such as Java or Python + + + + +System requirements + + + + Linux kernel 2.2/2.4/2.6 + + OProfile uses a kernel module that can be compiled for + 2.2.11 or later and 2.4. Versions 2.4.10 or above are recommended, and required if you use the + boot-time kernel option . 2.6 kernels are supported with the in-kernel + OProfile driver. Note that only 32-bit x86 and IA64 are supported on 2.2/2.4 kernels. + + + + PPC64 processors (Power4/Power5/PPC970) require a recent (> 2.6.5) kernel with the line + #define PV_970 present in include/asm-ppc64/processor.h. + + + + + modutils 2.4.6 or above + + You should have installed modutils 2.4.6 or higher (in fact earlier versions work well in almost all + cases). + + + + Supported architecture + + For Intel IA32, a CPU with either a P6 generation or Pentium 4 core is + required. In marketing terms this translates to anything + between an Intel Pentium Pro (not Pentium Classics) and + a Pentium 4 / Xeon, including all Celerons. The AMD + Athlon, and Duron CPUs are also supported. Other IA32 + CPU types only support the RTC mode of OProfile; please + see later in this manual for details. Hyper-threaded Pentium IVs + are not supported in 2.4. For 2.4 kernels, the Intel + IA-64 CPUs are also supported. For 2.6 kernels, there is additionally + support for Alpha processors, MIPS, ARM, x86-64, sparc64, ppc64, and, + in timer mode, PA-RISC and s390. + + + + Uniprocessor or SMP + + SMP machines are fully supported. + + + + Required libraries + + These libraries are required : popt, bfd, + liberty (debian users: libiberty is provided in binutils-dev package), dl, + plus the standard C++ libraries. + + + + Bash version 2 + + The opcontrol script requires bash version 2 at least to be installed + as /bin/bash or /bin/bash2 + + + + OProfile GUI + + The use of the GUI to start the profiler requires the Qt 2 library. Qt 3 should + also work. + + + + ELF + + Probably not too strenuous a requirement, but older A.OUT binaries/libraries are not supported. + + + + K&R coding style + + OK, so it's not really a requirement, but I wish it was... + + + + + + + + +Internet resources + + + + Web page + + There is a web page (which you may be reading now) at + http://oprofile.sf.net/. + + + + Download + + You can download a source tarball or get anonymous CVS at the sourceforge page, + http://sf.net/projects/oprofile/. + + + + Mailing list + + There is a low-traffic OProfile-specific mailing list, details at + http://sf.net/mail/?group_id=16191. + + + + Bug tracker + + There is a bug tracker for OProfile at SourceForge, + http://sf.net/tracker/?group_id=16191&atid=116191. + + + + IRC channel + + Several OProfile developers and users sometimes hang out on channel #oprofile + on the freenode network. + + + + + + + +Installation + + +First you need to build OProfile and install it. ./configure, make, make install +is often all you need, but note these arguments to ./configure : + + + + + + Use this option to specify the location of the kernel source tree you wish + to compile against. The kernel module is built against this source and + will only work with a running kernel built from the same source with + exact same options, so it is important you specify this option if you need + to. + + + + + + Use this option with 2.6 and above kernels to indicate the + kernel provides the OProfile device driver. + + + + + + Specify the location of Qt headers and libraries. It defaults to searching in + $QTDIR if these are not specified. + + + + + + Activate code within the OProfile sample collection daemon + oprofiled which records information about the binary + format of sample files in /var/lib/oprofile/abi, to + permit their transport between hosts using the + opimport utility. See . This option is primarily intended for embedded + systems or remote analysis of production machines; if you will be + performing all sample analysis on the same machine as you are profiling, + it is safe to omit this option. + + + + + + Development versions of OProfile build by + default with . This option turns + off. + + + + + + Disable the compiler flag + (useful if you discover an OProfile bug and want to give a useful + back-trace etc.) + + + + +You'll need to have a configured kernel source for the current kernel +to build the module for 2.4 kernels. Since all distributions provide different kernels it's unlikely the running kernel match the configured source +you installed. The safest way is to recompile your own kernel, run it and compile oprofile. It is also recommended that if you have a +uniprocessor machine, you enable the local APIC / IO_APIC support for +your kernel (this is automatically enabled for SMP kernels). With many BIOS, kernel >= 2.6.9 and UP kernel it's not sufficient to enable the local APIC you must also turn it on explicitely at boot time by providing "lapic" option to the kernel. On +machines with power management, such as laptops, the power management +must be turned off when using OProfile with 2.4 kernels. The power management software +in the BIOS cannot handle the non-maskable interrupts (NMIs) used by +OProfile for data collection. If you use the NMI watchdog, be aware that +the watchdog is disabled when profiling starts, and not re-enabled until the +OProfile module is removed (or, in 2.6, when OProfile is not running). If you compile OProfile for +a 2.2 kernel you must be root to compile the module. If you are using +2.6 kernels or higher, you do not need kernel source, as long as the +OProfile driver is enabled; additionally, you should not need to disable +power management. + + +Please note that you must save or have available the vmlinux file +generated during a kernel compile, as OProfile needs it (you can use +, but this will prevent kernel profiling). + + + + + +Uninstalling OProfile + +You must have the source tree available to uninstall OProfile; a make uninstall will +remove all installed files except your configuration file in the directory ~/.oprofile. + + + + + + +Overview + + +Getting started + +Before you can use OProfile, you must set it up. The minimum setup required for this +is to tell OProfile where the vmlinux file corresponding to the +running kernel is, for example : + +opcontrol --vmlinux=/boot/vmlinux-`uname -r` + +If you don't want to profile the kernel itself, +you can tell OProfile you don't have a vmlinux file : + +opcontrol --no-vmlinux + +Now we are ready to start the daemon (oprofiled) which collects +the profile data : + +opcontrol --start + +When I want to stop profiling, I can do so with : + +opcontrol --shutdown + +Note that unlike gprof, no instrumentation ( +and options to gcc) +is necessary. + + +Periodically (or on opcontrol --shutdown or opcontrol --dump) +the profile data is written out into the /var/lib/oprofile/samples directory. +These profile files cover shared libraries, applications, the kernel (vmlinux), and kernel modules. +You can clear the profile data (at any time) with opcontrol --reset. + + +You can get summaries of this data in a number of ways at any time. To get a summary of +data across the entire system for all of these profiles, you can do : + +opreport + +Or to get a more detailed summary, for a particular image, you can do something like : + +opreport -l /boot/vmlinux-`uname -r` + +There are also a number of other ways of presenting the data, as described later in this manual. +Note that OProfile will choose a default profiling setup for you. However, there are a number +of options you can pass to opcontrol if you need to change something, +also detailed later. + + + + + +Tools summary + +This section gives a brief description of the available OProfile utilities and their purpose. + + + + ophelp + + This utility lists the available events and short descriptions. + + + + + opcontrol + + Used for controlling the OProfile data collection, discussed in . + + + + + opreport + + This is the main tool for retrieving useful profile data, described in + . + + + + + opannotate + + This utility can be used to produce annotated source, assembly or mixed source/assembly. + Source level annotation is available only if the application was compiled with + debugging symbols. See . + + + + + opgprof + + This utility can output gprof-style data files for a binary, for use with + gprof -p. See . + + + + + oparchive + + This utility can be used to collect executables, debuginfo, + and sample files and copy the files into an archive. + The archive is self-contained and can be moved to another + machine for further analysis. + See . + + + + + opimport + + This utility converts sample database files from a foreign binary format (abi) to + the native format. This is useful only when moving sample files between hosts, + for analysis on platforms other than the one used for collection. The abi format + of the file to be imported is described in a text file located in + /var/lib/oprofile/abi, if the + configure-time option was enabled. Furthermore, the opimport + tool is not built unless is given. See . + + + + + + + + + +Controlling the profiler + + +Using <command>opcontrol</command> + +In this section we describe the configuration and control of the profiling system +with opcontrol in more depth. +The opcontrol script has a default setup, but you +can alter this with the options given below. In particular, +if your hardware supports performance counters, you can configure them. +There are a number of counters (for example, counter 0 and counter 1 +on the Pentium III). Each of these counters can be programmed with +an event to count, such as cache misses or MMX operations. The event +chosen for each counter is reflected in the profile data collected +by OProfile: functions and binaries at the top of the profiles reflect +that most of the chosen events happened within that code. + + +Additionally, each counter has a "count" value: this corresponds to how +detailed the profile is. The lower the value, the more frequently profile +samples are taken. A counter can choose to sample only kernel code, user-space code, +or both (both is the default). Finally, some events have a "unit mask" +- this is a value that further restricts the types of event that are counted. +The event types and unit masks for your CPU are listed by opcontrol +--list-events. + + +The opcontrol script provides the following actions : + + + + + + Loads the OProfile module if required and makes the OProfile driver + interface available. + + + + + + Followed by list arguments for profiling set up. List of arguments + saved in /root/.oprofile/daemonrc. + Giving this option is not necessary; you can just directly pass one + of the setup options, e.g. opcontrol --no-vmlinux. + + + + + + Show configuration information. + + + + + + Start the oprofile daemon without starting actual profiling. The profiling + can then be started using . This is useful for avoiding + measuring the cost of daemon startup, as is a simple + write to a file in oprofilefs. Not available in 2.2/2.4 kernels. + + + + + + Start data collection with either arguments provided by + or information saved in /root/.oprofile/daemonrc. Specifying + the addition makes the daemon generate lots of debug data + whilst it is running. + + + + + + Force a flush of the collected profiling data to the daemon. + + + + + + Stop data collection (this separate step is not possible with 2.2 or 2.4 kernels). + + + + + + Stop data collection and kill the daemon. + + + + + + Clears out data from current session, but leaves saved sessions. + + + + session_name + + Save data from current session to session_name. + + + + + + Shuts down daemon. Unload the OProfile module and oprofilefs. + + + + + + List event types and unit masks. + + + + + + Generate usage messages. + + + + + +There are a number of possible settings, of which, only + (or ) +is required. These settings are stored in ~/.oprofile/daemonrc. + + + + num + + Number of samples in kernel buffer. + + + + num + + Number of samples in kernel per-cpu buffer (2.6 only). If you + profile at high rate it can help to increase this if the log + file show excessive count of sample lost cpu buffer overflow. + + + + [eventspec] + + Use the given performance counter event to profile. + See below. + + + + [none,lib,kernel,thread,cpu,all] + + By default, every profile is stored in a single file. Thus, for example, + samples in the C library are all accredited to the /lib/libc.o + profile. However, you choose to create separate sample files by specifying + one of the below options. + + + + + No profile separation (default) + Create per-application profiles for libraries + Create per-application profiles for the kernel and kernel modules + Create profiles for each thread and each task + Create profiles for each CPU + All of the above options + + + + + Note that also turns on . + + When using , samples in hardware interrupts, soft-irqs, or other + asynchronous kernel contexts are credited to the task currently running. This means you will see + seemingly nonsense profiles such as /bin/bash showing samples for the PPP modules, + etc. + + + On 2.2/2.4 only kernel threads already started when profiling begins are correctly profiled; + newly started kernel thread samples are credited to the vmlinux (kernel) profile. + + + Using creates a lot + of sample files if you leave OProfile running for a while; it's most + useful when used for short sessions, or when using image filtering. + + + + + #depth + + Enable call-graph sample collection with a maximum depth. Use 0 to disable + callgraph profiling. Currently this requires a recent + 2.6 kernel, and x86. + + + + image,[images]|"all" + + Image filtering. If you specify one or more absolute + paths to binaries, OProfile will only produce profile results for those + binary images. This is useful for restricting the sometimes voluminous + output you may get otherwise, especially with + . Note that if you are using + or + , then if you specification an + application binary, the shared libraries and kernel code + are included. Specify the value + "all" to profile everything (the default). + + + + file + + vmlinux kernel image. + + + + + + Use this when you don't have a kernel vmlinux file, and you don't want + to profile the kernel. This still counts the total number of kernel samples, + but can't give symbol-based results for the kernel or any modules. + + + + + +Examples + + +Intel performance counter setup + +Here, we have a Pentium III running at 800MHz, and we want to look at where data memory +references are happening most, and also get results for CPU time. + + +# opcontrol --event=CPU_CLK_UNHALTED:400000 --event=DATA_MEM_REFS:10000 +# opcontrol --vmlinux=/boot/2.6.0/vmlinux +# opcontrol --start + + + + +RTC mode + +Here, we have an Intel laptop without support for performance counters, running on 2.4 kernels. + + +# ophelp -r +CPU with RTC device +# opcontrol --vmlinux=/boot/2.4.13/vmlinux --event=RTC_INTERRUPTS:1024 +# opcontrol --start + + + + +Starting the daemon separately + +If we're running 2.6 kernels, we can use to avoid +the profiler startup affecting results. + + +# opcontrol --vmlinux=/boot/2.6.0/vmlinux +# opcontrol --start-daemon +# my_favourite_benchmark --init +# opcontrol --start ; my_favourite_benchmark --run ; opcontrol --stop + + + + +Separate profiles for libraries and the kernel + +Here, we want to see a profile of the OProfile daemon itself, including when +it was running inside the kernel driver, and its use of shared libraries. + + +# opcontrol --separate=kernel --vmlinux=/boot/2.6.0/vmlinux +# opcontrol --start +# my_favourite_stress_test --run +# opreport -l -p /lib/modules/2.6.0/kernel /usr/local/bin/oprofiled + + + + +Profiling sessions + +It can often be useful to split up profiling data into several different +time periods. For example, you may want to collect data on an application's +startup separately from the normal runtime data. You can use the simple +command opcontrol --save to do this. For example : + + +# opcontrol --save=blah + + +will create a sub-directory in /var/lib/oprofile/samples containing the samples +up to that point (the current session's sample files are moved into this +directory). You can then pass this session name as a parameter to the post-profiling +analysis tools, to only get data up to the point you named the +session. If you do not want to save a session, you can do +rm -rf /var/lib/oprofile/samples/sessionname or, for the +current session, opcontrol --reset. + + + + + +Specifying performance counter events + +The option to opcontrol +takes a specification that indicates how the details of each +hardware performance counter should be setup. If you want to +revert to OProfile's default setting ( +is strictly optional), use . + + +You can pass multiple event specifications. OProfile will allocate +hardware counters as necessary. Note that some combinations are not +allowed by the CPU; running opcontrol --list-events gives the details +of each event. The event specification is a colon-separated string +of the form as described in this table: + +For the PowerPC platforms, all events specified must be in the same group; i.e., the group number +appended to the event name (e.g. <some-event-name>_GRP9) must be the same. + + + + + +The symbolic event name, e.g. CPU_CLK_UNHALTED +The counter reset value, e.g. 100000 +The unit mask, as given in the events list, e.g. 0x0f +Whether to profile kernel code +Whether to profile userspace code + + + + +The last three values are optional, if you omit them (e.g. ), +they will be set to the default values (a unit mask of 0, and profiling both kernel and +userspace code). Note that some events require a unit mask. + + +If OProfile is using RTC mode, and you want to alter the default counter value, +you can use something like . Note the last +three values here are ignored. +If OProfile is using timer-interrupt mode, there is no configuration possible. + + +The table below lists the events selected by default +() for the various computer architectures: + + + + +Processorcpu_typeDefault event +Alpha EV4alpha/ev4CYCLES:100000:0:1:1 +Alpha EV5alpha/ev5CYCLES:100000:0:1:1 +Alpha PCA56alpha/pca56CYCLES:100000:0:1:1 +Alpha EV6alpha/ev6CYCLES:100000:0:1:1 +Alpha EV67alpha/ev67CYCLES:100000:0:1:1 +ARM/XScale PMU1arm/xscale1CPU_CYCLES:100000:0:1:1 +ARM/XScale PMU2arm/xscale2CPU_CYCLES:100000:0:1:1 +Athloni386/athlonCPU_CLK_UNHALTED:100000:0:1:1 +Pentium Proi386/pproCPU_CLK_UNHALTED:100000:0:1:1 +Pentium IIi386/piiCPU_CLK_UNHALTED:100000:0:1:1 +Pentium IIIi386/piiiCPU_CLK_UNHALTED:100000:0:1:1 +Pentium M (P6 core)i386/p6_mobileCPU_CLK_UNHALTED:100000:0:1:1 +Pentium 4 (non-HT)i386/p4GLOBAL_POWER_EVENTS:100000:1:1:1 +Pentium 4 (HT)i386/p4-htGLOBAL_POWER_EVENTS:100000:1:1:1 +Hammerx86-64/hammerCPU_CLK_UNHALTED:100000:0:1:1 +Itaniumia64/itaniumCPU_CYCLES:100000:0:1:1 +Itanium 2ia64/itanium2CPU_CYCLES:100000:0:1:1 +TIMER_INTtimerNone selectable +IBM iseriesPowerPC 4/5/970CYCLES:10000:0:1:1 +IBM pseriesPowerPC 4/5/970CYCLES:10000:0:1:1 +IBM s390timerNone selectable +IBM s390xtimerNone selectable + + + + + + + + + +Using <command>oprof_start</command> + +The oprof_start application provides a convenient way to start the profiler. +Note that oprof_start is just a wrapper around the opcontrol script, +so it does not provide more services than the script itself. + + +After oprof_start is started you can select the event type for each counter; +the sampling rate and other related parameters are explained in . +The "Configuration" section allows you to set general parameters such as the buffer size, kernel filename +etc. The counter setup interface should be self-explanatory; and related +links contain information on using unit masks. + + +A status line shows the current status of the profiler: how long it has been running, and the average +number of interrupts received per second and the total, over all processors. +Note that quitting oprof_start does not stop the profiler. + + +Your configuration is saved in the same file as opcontrol uses; that is, +~/.oprofile/daemonrc. + + + + + +Configuration details + + +Hardware performance counters + + +Your CPU type may not include the requisite support for hardware performance counters, in which case +you must use OProfile in RTC mode in 2.4 (see ), or timer mode in 2.6 (see ). +You do not really need to read this section unless you are interested in using +events other than the default event chosen by OProfile. + + + +The Intel hardware performance counters are detailed in the Intel IA-32 Architecture Manual, Volume 3, available +from http://developer.intel.com/. The AMD Athlon/Duron +implementation is detailed in +http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/22007.pdf. +For PowerPC64 processors in IBM iSeries and pSeries systems, processor documentation +is available at +http://www-306.ibm.com/chips/techlib/techlib.nsf/productfamilies/PowerPC. (For example, the +specific publication containing information on the performance monitor unit for the PowerPC970 is +"IBM PowerPC 970FX RISC Microprocessor User's Manual.") +These processors are capable of delivering an interrupt when a counter overflows. +This is the basic mechanism on which OProfile is based. The delivery mode is NMI, +so blocking interrupts in the kernel does not prevent profiling. When the interrupt handler is called, +the current PC value and the current task are recorded into the profiling structure. +This allows the overflow event to be attached to a specific assembly instruction in a binary image. +The daemon receives this data from the kernel, and writes it to the sample files. + + +If we use an event such as CPU_CLK_UNHALTED or INST_RETIRED +(GLOBAL_POWER_EVENTS or INSTR_RETIRED, respectively, on the Pentium 4), we can +use the overflow counts as an estimate of actual time spent in each part of code. Alternatively we can profile interesting +data such as the cache behaviour of routines with the other available counters. + + +However there are several caveats. First, there are those issues listed in the Intel manual. There is a delay +between the counter overflow and the interrupt delivery that can skew results on a small scale - this means +you cannot rely on the profiles at the instruction level as being perfectly accurate. +If you are using an "event-mode" counter such as the cache counters, a count registered against it doesn't mean +that it is responsible for that event. However, it implies that the counter overflowed in the dynamic +vicinity of that instruction, to within a few instructions. Further details on this problem can be found in + and also in the Digital paper "ProfileMe: A Hardware Performance Counter". + + +Each counter has several configuration parameters. +First, there is the unit mask: this simply further specifies what to count. +Second, there is the counter value, discussed below. Third, there is a parameter whether to increment counts +whilst in kernel or user space. You can configure these separately for each counter. + + +After each overflow event, the counter will be re-initialized +such that another overflow will occur after this many events have been counted. Thus, higher +values mean less-detailed profiling, and lower values mean more detail, but higher overhead. +Picking a good value for this +parameter is, unfortunately, somewhat of a black art. It is of course dependent on the event +you have chosen. +Specifying too large a value will mean not enough interrupts are generated +to give a realistic profile (though this problem can be ameliorated by profiling for longer). +Specifying too small a value can lead to higher performance overhead. + + + + + +OProfile in RTC mode + +This section applies to 2.2/2.4 kernels only. + + +Some CPU types do not provide the needed hardware support to use the hardware performance counters. This includes +some laptops, classic Pentiums, and other CPU types not yet supported by OProfile (such as Cyrix). +On these machines, OProfile falls +back to using the real-time clock interrupt to collect samples. This interrupt is also used by the rtc +module: you cannot have both the OProfile and rtc modules loaded nor the rtc support compiled in the kernel. + + +RTC mode is less capable than the hardware counters mode; in particular, it is unable to profile sections of +the kernel where interrupts are disabled. There is just one available event, "RTC interrupts", and its value +corresponds to the number of interrupts generated per second (that is, a higher number means a better profiling +resolution, and higher overhead). The current implementation of the real-time clock supports only power-of-two +sampling rates from 2 to 4096 per second. Other values within this range are rounded to the nearest power of +two. + + +Setting the value from the GUI should be straightforward. On the command line, you need to specify the +event to opcontrol, e.g. : + +opcontrol --event=RTC_INTERRUPTS:256 + + + +OProfile in timer interrupt mode + +This section applies to 2.6 kernels and above only. + + +In 2.6 kernels on CPUs without OProfile support for the hardware performance counters, the driver +falls back to using the timer interrupt for profiling. Like the RTC mode in 2.4 kernels, this is not able to +profile code that has interrupts disabled. Note that there are no configuration parameters for +setting this, unlike the RTC and hardware performance counter setup. + + +You can force use of the timer interrupt by using the module +parameter (or on the boot command line if OProfile is +built-in). + + + + +Pentium 4 support + +The Pentium 4 / Xeon performance counters are organized around 3 types of model specific registers (MSRs): 45 event +selection control registers (ESCRs), 18 counter configuration control registers (CCCRs) and 18 counters. ESCRs describe a +particular set of events which are to be recorded, and CCCRs bind ESCRs to counters and configure their +operation. Unfortunately the relationship between these registers is quite complex; they cannot all be used with one +another at any time. There is, however, a subset of 8 counters, 8 ESCRs, and 8 CCCRs which can be used independently of +one another, so OProfile only accesses those registers, treating them as a bank of 8 "normal" counters, similar +to those in the P6 or Athlon families of CPU. + + +There is currently no support for Precision Event-Based Sampling (PEBS), nor any advanced uses of the Debug Store +(DS). Current support is limited to the conservative extension of OProfile's existing interrupt-based model described +above. Performance monitoring hardware on Pentium 4 / Xeon processors with Hyperthreading enabled (multiple logical +processors on a single die) is not supported in 2.4 kernels (you can use OProfile if you disable hyper-threading, +though). + + + + +Intel Itanium 2 support + +The Itanium 2 performance monitoring unit (PMU) organizes the counters as four +pairs of performance event monitoring registers. Each pair is composed of a +Performance Monitoring Configuration (PMC) register and Performance Monitoring +Data (PMD) register. The PMC selects the performance event being monitored and +the PMD determines the sampling interval. The IA64 Performance Monitoring Unit +(PMU) triggers sampling with maskable interrupts. Thus, samples will not occur +in sections of the IA64 kernel where interrupts are disabled. + + +None of the advance features of the Itanium 2 performance monitoring unit +such as opcode matching, address range matching, or precise event sampling are +supported by this version of OProfile. The Itanium 2 support only maps OProfile's +existing interrupt-based model to the PMU hardware. + + + + +PowerPC64 support + +The performance monitoring unit (PMU) for the PowerPC 64-bit processors +consists of between 6 and 8 counters (depending on the model), plus three +special purpose registers used for programming the counters -- MMCR0, MMCR1, +and MMCRA. Advanced features such as instruction matching and thresholding are +not supported by this version of OProfile. + + + + +Dangerous counter settings + +OProfile is a low-level profiler which allow continuous profiling with a low-overhead cost. +If too low a count reset value is set for a counter, the system can become overloaded with counter +interrupts, and seem as if the system has frozen. Whilst some validation is done, it +is not foolproof. + + +This can happen as follows: When the profiler count +reaches zero an NMI handler is called which stores the sample values in an internal buffer, then resets the counter +to its original value. If the count is very low, a pending NMI can be sent before the NMI handler has +completed. Due to the priority of the NMI, the local APIC delivers the pending interrupt immediately after +completion of the previous interrupt handler, and control never returns to other parts of the system. +In this way the system seems to be frozen. + +If this happens, it will be impossible to bring the system back to a workable state. +There is no way to provide real security against this happening, other than making sure to use a reasonable value +for the counter reset. For example, setting CPU_CLK_UNHALTED event type with a ridiculously low reset count (e.g. 500) +is likely to freeze the system. + + +In short : Don't try a foolish sample count value. Unfortunately the definition of a foolish value +is really dependent on the event type - if ever in doubt, e-mail +
oprofile-list@lists.sf.net.
+
+ +
+ +
+ + +Obtaining results + +OK, so the profiler has been running, but it's not much use unless we can get some data out. Fairly often, +OProfile does a little too good a job of keeping overhead low, and no data reaches +the profiler. This can happen on lightly-loaded machines. Remember you can force a dump at any time with : + +opcontrol --dump +Remember to do this before complaining there is no profiling data ! +Now that we've got some data, it has to be processed. That's the job of opreport, +opannotate, or opgprof. + + + +Profile specifications + + +All of the analysis tools take a profile specification. +This is a set of definitions that describe which actual profiles should be +examined. The simplest profile specification is empty: this will match all +the available profile files for the current session (this is what happens +when you do opreport). + + +Specification parameters are of the form . +For example, if I wanted to get a combined symbol summary for +/bin/myprog and /bin/myprog2, +I could do opreport -l image:/bin/myprog,/bin/myprog2. +As a special case, you don't actually need to specify the +part here: anything left on the command line is assumed to be an + name. Similarly, if no +is specified, then is assumed ("current" +is a special name of the current / last profiling session). + + +In addition to the comma-separated list shown above, some of the +specification parameters can take glob-style +values. For example, if I want to see image summaries for all +binaries profiled in /usr/bin/, I could do +opreport image:/usr/bin/\*. Note the necessity +to escape the special character from the shell. + + +For opreport, profile specifications can be used to +define two profiles, giving differential output. This is done by +enclosing each of the two specifications within curly braces, as shown +in the examples below. Any specifications outside of curly braces are +shared across both. + + + +Examples + + +Image summaries for all profiles with DATA_MEM_REFS +samples in the saved session called "stresstest" : + + +# opreport session:stresstest event:DATA_MEM_REFS + + + +Symbol summary for the application called "test_sym53c8xx,9xx". Note the +escaping is necessary as takes a comma-separated list. + + +# opreport -l ./test/test_sym53c8xx\,9xx + + + +Image summaries for all binaries in the test directory, +excepting boring-test : + + +# opreport image:./test/\* image-exclude:./test/boring-test + + + +Differential profile of a binary stored in two archives : + + +# opreport -l /bin/bash { archive:./orig } { archive:./new } + + + +Differential profile of an archived binary with the current session : + + +# opreport -l /bin/bash { archive:./orig } { } + + + + + +Profile specification parameters + + + + archivepath + + A path to an archive made with oparchive. + Absence of this tag, unlike others, means "the current system", + equivalent to specifying "archive:". + + + + sessionlist + + A comma-separated list of session names to resolve in. Absence of this + tag, unlike others, means "the current session", equivalent to + specifying "session:current". + + + + sessionlist + + A comma-separated list of sessions to exclude. + + + + imagelist + + A comma-separated list of image names to resolve. Each entry may be relative + path, glob-style name, or full path, e.g. + opreport 'image:/usr/bin/oprofiled,*op*,./opreport' + + + + + imagelist + + Same as , but the matching images are excluded. + + + + + imagelist + + Same as , but only for images that are for + a particular primary binary image (namely, an application). This only + makes sense to use if you're using . + This includes kernel modules and the kernel when using + . + + + + + imagelist + + Same as , but the matching images + are excluded. + + + + + eventlist + + The symbolic event name to match on, e.g. . + You can pass a list of events for side-by-side comparison with opreport. + When using the timer interrupt, the event is always "TIMER". + + + + + eventcountlist + + The event count to match on, e.g. . + Note that this value refers to the setting used for opcontrol + only, and has nothing to do with the sample counts in the profile data + itself. + You can pass a list of events for side-by-side comparison with opreport. + When using the timer interrupt, the count is always 0 (indicating it cannot be set). + + + + + masklist + + The unit mask value of the event to match on, e.g. . + You can pass a list of events for side-by-side comparison with opreport. + + + + + cpulist + + Only consider profiles for the given numbered CPU (starting from zero). + This is only useful when using CPU profile separation. + + + + + pidlist + + Only consider profiles for the given task groups. Unless some program + is using threads, the task group ID of a process is the same + as its process ID. This option corresponds to the POSIX + notion of a thread group. + This is only useful when using per-process profile separation. + + + + + tidlist + + Only consider profiles for the given threads. When using + recent thread libraries, all threads in a process share the + same task group ID, but have different thread IDs. You can + use this option in combination with to + restrict the results to particular threads within a process. + This is only useful when using per-process profile separation. + + + + + + + +Locating and managing binary images + +Each session's sample files can be found in the /var/lib/oprofile/samples/ directory. +These are used, along with the binary image files, to produce human-readable data. +In some circumstances (kernel modules in an initrd, or modules on 2.6 kernels), OProfile +will not be able to find the binary images. All the tools have an +option to which you can pass a comma-separated list of alternate paths to search. For example, +I can let OProfile find my 2.6 modules by using --image-path /lib/modules/2.6.0/kernel/. +It is your responsibility to ensure that the correct images are found when using this +option. + + +Note that if a binary image changes after the sample file was created, you won't be able to get useful +symbol-based data out. This situation is detected for you. If you replace a binary, you should +make sure to save the old binary if you need to do comparative profiles. + + + + + +What to do when you don't get any results + +When attempting to get output, you may see the error : + + +error: no sample files found: profile specification too strict ? + + +What this is saying is that the profile specification you passed in, +when matched against the available sample files, resulted in no matches. +There are a number of reasons this might happen: + + +spelling +You specified a binary name, but spelt it wrongly. Check your spelling ! + +profiler wasn't running +Make very sure that OProfile was actually up and running when you ran +the binary. + +binary didn't run long enough +Remember OProfile is a statistical profiler - you're not guaranteed to +get samples for short-running programs. You can help this by using a +lower count for the performance counter, so there are a lot more samples +taken per second. + +binary spent most of its time in libraries +Similarly, if the binary spends little time in the main binary image +itself, with most of it spent in shared libraries it uses, you might +not see any samples for the binary image itself. You can check this +by using opcontrol --separate=lib before the +profiling session, so opreport and friends show +the library profiles on a per-application basis. + +specification was really too strict +For example, you specified something like , +but no task with that group ID ever ran the code. + +binary didn't generate any events +If you're using a particular event counter, for example counting MMX +operations, the code might simply have not generated any events in the +first place. Verify the code you're profiling does what you expect it +to. + +you didn't specify kernel module name correctly +If you're using 2.6 kernels, and trying to get reports for a kernel +module, make sure to use the option, and specify the +module name with the .ko +extension. Check if the module is one loaded from initrd. + + + + + + + + +Image summaries and symbol summaries (<command>opreport</command>) + +The opreport utility is the primary utility you will use for +getting formatted data out of OProfile. It produces two types of data: image summaries +and symbol summaries. An image summary lists the number of samples for individual +binary images such as libraries or applications. Symbol summaries provide per-symbol +profile data. In the following example, we're getting an image summary for the whole +system: + + +$ opreport --long-filenames +CPU: PIII, speed 863.195 MHz (estimated) +Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a unit mask of 0x00 (No unit mask) count 23150 + 905898 59.7415 /usr/lib/gcc-lib/i386-redhat-linux/3.2/cc1plus + 214320 14.1338 /boot/2.6.0/vmlinux + 103450 6.8222 /lib/i686/libc-2.3.2.so + 60160 3.9674 /usr/local/bin/madplay + 31769 2.0951 /usr/local/oprofile-pp/bin/oprofiled + 26550 1.7509 /usr/lib/libartsflow.so.1.0.0 + 23906 1.5765 /usr/bin/as + 18770 1.2378 /oprofile + 15528 1.0240 /usr/lib/qt-3.0.5/lib/libqt-mt.so.3.0.5 + 11979 0.7900 /usr/X11R6/bin/XFree86 + 11328 0.7471 /bin/bash + ... + + +If we had specified in the previous command, we would have +gotten a symbol summary of all the images across the entire system. We can restrict this to only +part of the system profile; for example, +below is a symbol summary of the OProfile daemon. Note that as we used +opcontrol --separate=kernel, symbols from images that oprofiled +has used are also shown. + + +$ opreport -l `which oprofiled` 2>/dev/null | more +CPU: PIII, speed 863.195 MHz (estimated) +Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a unit mask of 0x00 (No unit mask) count 23150 +vma samples % image name symbol name +0804be10 14971 28.1993 oprofiled odb_insert +0804afdc 7144 13.4564 oprofiled pop_buffer_value +c01daea0 6113 11.5144 vmlinux __copy_to_user_ll +0804b060 2816 5.3042 oprofiled opd_put_sample +0804b4a0 2147 4.0441 oprofiled opd_process_samples +0804acf4 1855 3.4941 oprofiled opd_put_image_sample +0804ad84 1766 3.3264 oprofiled opd_find_image +0804a5ec 1084 2.0418 oprofiled opd_find_module +0804ba5c 741 1.3957 oprofiled odb_hash_add_node +... + + + +These are the two basic ways you are most likely to use regularly, but opreport +can do a lot more than that, as described below. + + + +Merging separate profiles + +If you have used one of the options +whilst profiling, there can be several separate profiles for +a single binary image within a session. Normally the output +will keep these images separated (so, for example, the image summary +output shows library image summaries on a per-application basis, +when using ). +Sometimes it can be useful to merge these results back together +before getting results. The option allows +you to do that. + + + +Side-by-side multiple results +If you have used multiple events when profiling, by default you get +side-by-side results of each event's sample values from opreport. +You can restrict which events to list by appropriate use of the + profile specifications, etc. + + + +Callgraph output + +When using the option, you can see what +functions are calling other functions in the output. Consider the +following program: + + +#include <string.h> +#include <stdlib.h> +#include <stdio.h> + +#define SIZE 500000 + +static int compare(const void *s1, const void *s2) +{ + return strcmp(s1, s2); +} + +static void repeat(void) +{ + int i; + char *strings[SIZE]; + char str[] = "abcdefghijklmnopqrstuvwxyz"; + + for (i = 0; i < SIZE; ++i) { + strings[i] = strdup(str); + strfry(strings[i]); + } + + qsort(strings, SIZE, sizeof(char *), compare); +} + +int main() +{ + while (1) + repeat(); +} + + +When running with the call-graph option, OProfile will +record the function stack every time it takes a sample. +opreport --callgraph outputs an entry for each +function, where each entry looks similar to: + + +samples % image name symbol name + 197 0.1548 cg main + 127036 99.8452 cg repeat +84590 42.5084 libc-2.3.2.so strfry + 84590 66.4838 libc-2.3.2.so strfry [self] + 39169 30.7850 libc-2.3.2.so random_r + 3475 2.7312 libc-2.3.2.so __i686.get_pc_thunk.bx +------------------------------------------------------------------------------- + + +Here the non-indented line is the function we're focussing upon +(strfry()). This +line is the same as you'd get from a normal opreport +output. + + +Above the non-indented line we find the functions that called this +function (for example, repeat() calls +strfry()). The samples and percentage values here +refer to the number of times we took a sample where this call was found +in the stack; the percentage is relative to all other callers of the +function we're focussing on. Note that these values are +not call counts; they only reflect the call stack +every time a sample is taken; that is, if a call is found in the stack +at the time of a sample, it is recorded in this count. + + +Below the line are functions that are called by +strfry() (called callees). +It's clear here that strfry() calls +random_r(). We also see a special entry with a +"[self]" marker. This records the normal samples for the function, but +the percentage becomes relative to all callees. This allows you to +compare time spent in the function itself compared to functions it +calls. Note that if a function calls itself, then it will appear in the +list of callees of itself, but without the "[self]" marker; so recursive +calls are still clearly separable. + + +You may have noticed that the output lists main() +as calling strfry(), but it's clear from the source +that this doesn't actually happen. See for an explanation. + + + + + +Differential profiles with <command>opreport</command> + + +Often, we'd like to be able to compare two profiles. For example, when +analysing the performance of an application, we'd like to make code +changes and examine the effect of the change. This is supported in +opreport by giving a profile specification that +identifies two different profiles. The general form is of: + + +$ opreport <shared-spec> { <first-profile> } { <second-profile> } + + +For each of the profiles, the shared section is prefixed, and then the +specification is analysed. The usual parameters work both within the +shared section, and in the sub-specification within the curly braces. + + +A typical way to use this feature is with archives created with +oparchive. Let's look at an example: + + +$ ./a +$ oparchive -o orig ./a +$ opcontrol --reset + # edit and recompile a +$ ./a + # now compare the current profile of a with the archived profile +$ opreport -xl ./a { archive:./orig } { } +CPU: PIII, speed 863.233 MHz (estimated) +Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a +unit mask of 0x00 (No unit mask) count 100000 +samples % diff % symbol name +92435 48.5366 +0.4999 a +54226 --- --- c +49222 25.8459 +++ d +48787 25.6175 -2.2e-01 b + + +Note that we specified an empty second profile in the curly braces, as +we wanted to use the current session; alternatively, we could +have specified another archive, or a tgid etc. We specified the binary +a in the shared section, so we matched that in both +the profiles we're diffing. + + +As in the normal output, the results are sorted by the number of +samples, and the percentage field represents the relative percentage of +the symbol's samples in the second profile. + + +Notice the new column in the output. This value represents the +percentage change of the relative percent between the first and the +second profile: roughly, "how much more important this symbol is". +Looking at the symbol a(), we can see that it took +roughly the same amount of the total profile in both the first and the +second profile. The function c() was not in the new +profile, so has been marked with ---. Note that the +sample value is the number of samples in the first profile; since we're +displaying results for the second profile, we don't list a percentage +value for it, as it would be meaningless. d() is +new in the second profile, and consequently marked with ++++. + + +When comparing profiles between different binaries, it should be clear +that functions can change in terms of VMA and size. To avoid this +problem, opreport considers a symbol to be the same +if the symbol name, image name, and owning application name all match; +any other factors are ignored. Note that the check for application name +means that trying to compare library profiles between two different +applications will not work as you might expect: each symbol will be +considered different. + + + + + +Anonymous executable mappings + +Many applications, typically ones involving dynamic compilation into +machine code, have executable mappings that are not backed by an ELF +file. opreport has basic support for showing the +samples taken in these regions; for example: + + +$ opreport /usr/jre1.5.0/bin/java +CPU: PIII, speed 863.195 MHz (estimated) +Counted CPU_CLK_UNHALTED events (clocks processor is not halted) with a unit mask of 0x00 (No unit mask) count 100000 +CPU_CLK_UNHALT...| + samples| %| +------------------ + 27344 100.000 java + CPU_CLK_UNHALT...| + samples| %| + ------------------ + 27236 99.605 anon (tgid:12135 range:0xb2cb8000-0xb2e80000) + 108 0.3949 java + + +Currently, there is no support for getting symbol-based summaries for +such regions. Note that, since such mappings are dependent upon +individual invocations of a binary, these mappings are always listed as +a dependent image, even when using . +Equally, the results are not affected by the +option. + + + + +Options for <command>opreport</command> + + + +Accumulate sample and percentage counts in the symbol list. + + +Show callgraph information. + + +Show source file and line for each symbol. + + +none: no demangling. normal: use default demangler (default) smart: use +pattern-matching to make C++ symbol demangling more readable. + + +Show per-instruction details for all selected symbols. Note that, for +binaries without symbol information, the VMA values shown are raw file +offsets for the image binary. + + +Do not include application-specific images for libraries, kernel modules +and the kernel. This option only makes sense if the profile session +used --separate. + + +Exclude all the symbols in the given comma-separated list. + + +Make all percentages relative to the whole profile. + + +Show help message. + + +Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. + + +Only include symbols in the given comma-separated list. + + +Output full paths instead of basenames. + + +Merge any profiles separated in a --separate session. + + +Don't output a header detailing profiling parameters. + + +Output to the given file instead of stdout. + + +Reverse the sort from the default. + + +Show the VMA address of each symbol (off by default). + + +Sort the list of symbols by, respectively, symbol address, +number of samples, symbol name, debug filename and line number, +binary image filename. + + +List per-symbol information instead of a binary image summary. + + +Only output data for symbols that have more than the given percentage +of total samples. + + +Give verbose debugging output. + + +Show version. + + + + + + + + +Outputting annotated source (<command>opannotate</command>) + +The opannotate utility generates annotated source files or assembly listings, optionally +mixed with source. +If you want to see the source file, the profiled application needs to have debug information, and the source +must be available through this debug information. For GCC, you must use the option +when you are compiling. +If the binary doesn't contain sufficient debug information, you can still +use opannotate to get annotated assembly. + + +Note that for the reason explained in the results can be +inaccurate. The debug information itself can add other problems; for example, the line number for a symbol can be +incorrect. Assembly instructions can be re-ordered and moved by the compiler, and this can lead to +crediting source lines with samples not really "owned" by this line. Also see +. + + +You can output the annotation to one single file, containing all the source found using the +. You can use this in conjunction with +to get combined source/assembly output. + + +You can also output a directory of annotated source files that maintains the structure of +the original sources. Each line in the annotated source is prepended with the samples +for that line. Additionally, each symbol is annotated giving details for the symbol +as a whole. An example: + + +$ opannotate --source --output-dir=annotated /usr/local/oprofile-pp/bin/oprofiled +$ ls annotated/home/moz/src/oprofile-pp/daemon/ +opd_cookie.h opd_image.c opd_kernel.c opd_sample_files.c oprofiled.c + + +Line numbers are maintained in the source files, but each file has +a footer appended describing the profiling details. The actual annotation +looks something like this : + + +... + :static uint64_t pop_buffer_value(struct transient * trans) + 11510 1.9661 :{ /* pop_buffer_value total: 89901 15.3566 */ + : uint64_t val; + : + 10227 1.7469 : if (!trans->remaining) { + : fprintf(stderr, "BUG: popping empty buffer !\n"); + : exit(EXIT_FAILURE); + : } + : + : val = get_buffer_value(trans->buffer, 0); + 2281 0.3896 : trans->remaining--; + 2296 0.3922 : trans->buffer += kernel_pointer_size; + : return val; + 10454 1.7857 :} +... + + + +The first number on each line is the number of samples, whilst the second is +the relative percentage of total samples. + + + +Locating source files + +Of course, opannotate needs to be able to locate the source files +for the binary image(s) in order to produce output. Some binary images have debug +information where the given source file paths are relative, not absolute. You can +specify search paths to look for these files (similar to gdb's + command) with the option. + + +Sometimes you may have a binary image which gives absolute paths for the source files, +but you have the actual sources elsewhere (commonly, you've installed an SRPM for +a binary on your system and you want annotation from an existing profile). You can +use the option to redirect OProfile to look somewhere +else for source files. For example, imagine we have a binary generated from a source +file that is given in the debug information as /tmp/build/libfoo/foo.c, +and you have the source tree matching that binary installed in /home/user/libfoo/. +You can redirect OProfile to find foo.c correctly like this : + + +$ opannotate --source --base-dirs=/tmp/build/libfoo/ --search-dirs=/home/user/libfoo/ --output-dir=annotated/ /lib/libfoo.so + + +You can specify multiple (comma-separated) paths to both options. + + + + +Usage of <command>opannotate</command> + + + +Output annotated assembly. If this is combined with --source, then mixed +source / assembly annotations are output. + + +Comma-separated list of path prefixes. This can be used to point OProfile to a +different location for source files when the debug information specifies an +absolute path on your system for the source that does not exist. The prefix +is stripped from the debug source file paths, then searched in the search dirs +specified by . + + +none: no demangling. normal: use default demangler (default) smart: use +pattern-matching to make C++ symbol demangling more readable. + + +Do not include application-specific images for libraries, kernel modules +and the kernel. This option only makes sense if the profile session +used --separate. + + +Exclude all files in the given comma-separated list of glob patterns. + + +Exclude all the symbols in the given comma-separated list. + + +Show help message. + + +Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. + + +Only include files in the given comma-separated list of glob patterns. + + +Only include symbols in the given comma-separated list. + + +Pass the given parameters as extra values when calling objdump. + + +Output directory. This makes opannotate output one annotated file for each +source file. This option can't be used in conjunction with --assembly. + + +Comma-separated list of paths to search for source files. This is useful to find +source files when the debug information only contains relative paths. + + +Output annotated source. This requires debugging information to be available +for the binaries. + + +Only output data for symbols that have more than the given percentage +of total samples. + + +Give verbose debugging output. + + +Show version. + + + + + + + + + +<command>gprof</command>-compatible output (<command>opgprof</command>) + +If you're familiar with the output produced by GNU gprof, +you may find opgprof useful. It takes a single binary +as an argument, and produces a gmon.out file for use +with gprof -p. If call-graph profiling is enabled, +then this is also included. + + +$ opgprof `which oprofiled` # generates gmon.out file +$ gprof -p `which oprofiled` | head +Flat profile: + +Each sample counts as 1 samples. + % cumulative self self total + time samples samples calls T1/call T1/call name + 33.13 206237.00 206237.00 odb_insert + 22.67 347386.00 141149.00 pop_buffer_value + 9.56 406881.00 59495.00 opd_put_sample + 7.34 452599.00 45718.00 opd_find_image + 7.19 497327.00 44728.00 opd_process_samples + + + +Usage of <command>opgprof</command> + + + +Show help message. + + +Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. + + +Output to the given file instead of the default, gmon.out + + +Only output data for symbols that have more than the given percentage +of total samples. + + +Give verbose debugging output. + + +Show version. + + + + + + + + +Archiving measurements (<command>oparchive</command>) + + The oparchive utility generates a directory populated + with executable, debug, and oprofile sample files. This directory can be + moved to another machine via tar and analyzed without + further use of the data collection machine. + + + + The following command would collect the sample files, the executables + associated with the sample files, and the debuginfo files associated + with the executables and copy them into + /tmp/current_data: + + + +# oparchive -o /tmp/current_data + + + +Usage of <command>oparchive</command> + + + +Show help message. + + +Do not include application-specific images for libraries, kernel modules +and the kernel. This option only makes sense if the profile session +used --separate. + + +Comma-separated list of additional paths to search for binaries. +This is needed to find modules in kernels 2.6 and upwards. + + +Output to the given directory. There is no default. This must be specified. + + +Give verbose debugging output. + + +Show version. + + + + + + + + + + +Interpreting profiling results + +The standard caveats of profiling apply in interpreting the results from OProfile: +profile realistic situations, profile different scenarios, profile +for as long as a time as possible, avoid system-specific artifacts, don't trust +the profile data too much. Also bear in mind the comments on the performance +counters above - you cannot rely on totally accurate +instruction-level profiling. However, for almost all circumstances the data +can be useful. Ideally a utility such as Intel's VTUNE would be available to +allow careful instruction-level analysis; go hassle Intel for this, not me ;) + + +Profiling interrupt latency + +This is an example of how the latency of delivery of profiling interrupts +can impact the reliability of the profiling data. This is pretty much a +worst-case-scenario example: these problems are fairly rare. + + +double fun(double a, double b, double c) +{ + double result = 0; + for (int i = 0 ; i < 10000; ++i) { + result += a; + result *= b; + result /= c; + } + return result; +} + + +Here the last instruction of the loop is very costly, and you would expect the result +reflecting that - but (cutting the instructions inside the loop): + + +$ opannotate -a -t 10 ./a.out + + 88 15.38% : 8048337: fadd %st(3),%st + 48 8.391% : 8048339: fmul %st(2),%st + 68 11.88% : 804833b: fdiv %st(1),%st + 368 64.33% : 804833d: inc %eax + : 804833e: cmp $0x270f,%eax + : 8048343: jle 8048337 + + +The problem comes from the x86 hardware; when the counter overflows the IRQ +is asserted but the hardware has features that can delay the NMI interrupt: +x86 hardware is synchronous (i.e. cannot interrupt during an instruction); +there is also a latency when the IRQ is asserted, and the multiple +execution units and the out-of-order model of modern x86 CPUs also causes +problems. This is the same function, with annotation : + + +$ opannotate -s -t 10 ./a.out + + :double fun(double a, double b, double c) + :{ /* _Z3funddd total: 572 100.0% */ + : double result = 0; + 368 64.33% : for (int i = 0 ; i < 10000; ++i) { + 88 15.38% : result += a; + 48 8.391% : result *= b; + 68 11.88% : result /= c; + : } + : return result; + :} + + +The conclusion: don't trust samples coming at the end of a loop, +particularly if the last instruction generated by the compiler is costly. This +case can also occur for branches. Always bear in mind that samples +can be delayed by a few cycles from its real position. That's a hardware +problem and OProfile can do nothing about it. + + + +Kernel profiling + +Interrupt masking + +OProfile uses non-maskable interrupts (NMI) on the P6 generation, Pentium 4, +Athlon and Duron processors. These interrupts can occur even in section of the +Linux where interrupts are disabled, allowing collection of samples in virtually +all executable code. The RTC, timer interrupt mode, and Itanium 2 collection mechanisms +use maskable interrupts. Thus, the RTC and Itanium 2 data collection mechanism have "sample +shadows", or blind spots: regions where no samples will be collected. Typically, the samples +will be attributed to the code immediately after the interrupts are re-enabled. + + + +Idle time + +Your kernel is likely to support halting the processor when a CPU is idle. As +the typical hardware events like CPU_CLK_UNHALTED do not +count when the CPU is halted, the kernel profile will not reflect the actual +amount of time spent idle. You can change this behaviour by booting with +the option, which uses a different idle routine. This +will appear as poll_idle() in your kernel profile. + + + +Profiling kernel modules + +OProfile profiles kernel modules by default. However, there are a couple of problems +you may have when trying to get results. First, you may have booted via an initrd; +this means that the actual path for the module binaries cannot be determined automatically. +To get around this, you can use the option to the profiling tools +to specify where to look for the kernel modules. + + +In 2.6, the information on where kernel module binaries are located has been removed. +This means OProfile needs guiding with the option to find your +modules. Normally, you can just use your standard module top-level directory for this. +Note that due to this problem, OProfile cannot check that the modification times match; +it is your responsibility to make sure you do not modify a binary after a profile +has been created. + + +If you have run insmod or modprobe to insert a module +in a particular directory, it is important that you specify this directory with the + option first, so that it over-rides an older module binary that might +exist in other directories you've specified with . It is up to you +to make sure that these values are correct: 2.6 kernels simply do not provide enough +information for OProfile to get this information. + + + + + +Interpreting call-graph profiles + +Sometimes the results from call-graph profiles may be different to what +you expect to see. The first thing to check is whether the target +binaries where compiled with frame pointers enabled (if the binary was +compiled using gcc's + option, you will not get +meaningful results). Note that as of this writing, the GCC developers +plan to disable frame pointers by default. The Linux kernel is built +without frame pointers by default; there is a configuration option you +can use to turn it on under the "Kernel Hacking" menu. + + +Often you may see a caller of a function that does not actually directly +call the function you're looking at (e.g. if a() +calls b(), which in turn calls +c(), you may see an entry for +a()->c()). What's actually occurring is that we +are taking samples at the very start (or the very end) of +c(); at these few instructions, we haven't yet +created the new function's frame, so it appears as if +a() is calling directly into +c(). Be careful not to be misled by these +entries. + + +Like the rest of OProfile, call-graph profiling uses a statistical +approach; this means that sometimes a backtrace sample is truncated, or +even partially wrong. Bear this in mind when examining results. + + + + + +Inaccuracies in annotated source + +Side effects of optimizations + +The compiler can introduce some pitfalls in the annotated source output. +The optimizer can move pieces of code in such manner that two line of codes +are interlaced (instruction scheduling). Also debug info generated by the compiler +can show strange behavior. This is especially true for complex expressions e.g. inside +an if statement: + + + if (a && .. + b && .. + c &&) + + +here the problem come from the position of line number. The available debug +info does not give enough details for the if condition, so all samples are +accumulated at the position of the right brace of the expression. Using +opannotate can help to show the real +samples at an assembly level. + + + +Prologues and epilogues + +The compiler generally needs to generate "glue" code across function calls, dependent +on the particular function call conventions used. Additionally other things +need to happen, like stack pointer adjustment for the local variables; this +code is known as the function prologue. Similar code is needed at function return, +and is known as the function epilogue. This will show up in annotations as +samples at the very start and end of a function, where there is no apparent +executable code in the source. + + + +Inlined functions + +You may see that a function is credited with a certain number of samples, but +the listing does not add up to the correct total. To pick a real example : + + + :internal_sk_buff_alloc_security(struct sk_buff *skb) + 353 2.342% :{ /* internal_sk_buff_alloc_security total: 1882 12.48% */ + : + : sk_buff_security_t *sksec; + 15 0.0995% : int rc = 0; + : + 10 0.06633% : sksec = skb->lsm_security; + 468 3.104% : if (sksec && sksec->magic == DSI_MAGIC) { + : goto out; + : } + : + : sksec = (sk_buff_security_t *) get_sk_buff_memory(skb); + 3 0.0199% : if (!sksec) { + 38 0.2521% : rc = -ENOMEM; + : goto out; + 10 0.06633% : } + : memset(sksec, 0, sizeof (sk_buff_security_t)); + 44 0.2919% : sksec->magic = DSI_MAGIC; + 32 0.2123% : sksec->skb = skb; + 45 0.2985% : sksec->sid = DSI_SID_NORMAL; + 31 0.2056% : skb->lsm_security = sksec; + : + : out: + : + 146 0.9685% : return rc; + : + 98 0.6501% :} + + +Here, the function is credited with 1,882 samples, but the annotations +below do not account for this. This is usually because of inline functions - +the compiler marks such code with debug entries for the inline function +definition, and this is where opannotate annotates +such samples. In the case above, memset is the most +likely candidate for this problem. Examining the mixed source/assembly +output can help identify such results. + + +When running opannotate, you may get a warning +"some functions compiled without debug information may have incorrect source line attributions". +In some rare cases, OProfile is not able to verify that the derived source line +is correct (when some parts of the binary image are compiled without debugging +information). Be wary of results if this warning appears. + + +Furthermore, for some languages the compiler can implicitly generate functions, +such as default copy constructors. Such functions are labelled by the compiler +as having a line number of 0, which means the source annotation can be confusing. + + + + +Inaccuracy in line number information + +Depending on your compiler you can fall into the following problem: + + +struct big_object { int a[500]; }; + +int main() +{ + big_object a, b; + for (int i = 0 ; i != 1000 * 1000; ++i) + b = a; + return 0; +} + + + +Compiled with gcc 3.0.4 the annotated source is clearly inaccurate: + + + :int main() + :{ /* main total: 7871 100% */ + : big_object a, b; + : for (int i = 0 ; i != 1000 * 1000; ++i) + : b = a; + 7871 100% : return 0; + :} + + +The problem here is distinct from the IRQ latency problem; the debug line number +information is not precise enough; again, looking at output of opannoatate -as can help. + + + :int main() + :{ + : big_object a, b; + : for (int i = 0 ; i != 1000 * 1000; ++i) + : 80484c0: push %ebp + : 80484c1: mov %esp,%ebp + : 80484c3: sub $0xfac,%esp + : 80484c9: push %edi + : 80484ca: push %esi + : 80484cb: push %ebx + : b = a; + : 80484cc: lea 0xfffff060(%ebp),%edx + : 80484d2: lea 0xfffff830(%ebp),%eax + : 80484d8: mov $0xf423f,%ebx + : 80484dd: lea 0x0(%esi),%esi + : return 0; + 3 0.03811% : 80484e0: mov %edx,%edi + : 80484e2: mov %eax,%esi + 1 0.0127% : 80484e4: cld + 8 0.1016% : 80484e5: mov $0x1f4,%ecx + 7850 99.73% : 80484ea: repz movsl %ds:(%esi),%es:(%edi) + 9 0.1143% : 80484ec: dec %ebx + : 80484ed: jns 80484e0 + : 80484ef: xor %eax,%eax + : 80484f1: pop %ebx + : 80484f2: pop %esi + : 80484f3: pop %edi + : 80484f4: leave + : 80484f5: ret + + +So here it's clear that copying is correctly credited with of all the samples, but the +line number information is misplaced. objdump -dS exposes the +same problem. Note that maintaining accurate debug information for compilers when optimizing is difficult, so this problem is not suprising. +The problem of debug information +accuracy is also dependent on the binutils version used; some BFD library versions +contain a work-around for known problems of gcc, some others do not. This is unfortunate but we must live with that, +since profiling is pointless when you disable optimisation (which would give better debugging entries). + + + + +Assembly functions + +Often the assembler cannot generate debug information automatically. +This means that you cannot get a source report unless +you manually define the neccessary debug information; read your assembler documentation for how you might +do that. The only +debugging info needed currently by OProfile is the line-number/filename-VMA association. When profiling assembly +without debugging info you can always get report for symbols, and optionally for VMA, through opreport -l +or opreport -d, but this works only for symbols with the right attributes. +For gas you can get this by + + +.globl foo + .type foo,@function + + +whilst for nasm you must use + + + GLOBAL foo:function ; [1] + + +Note that OProfile does not need the global attribute, only the function attribute. + + + + +Other discrepancies + +Another cause of apparent problems is the hidden cost of instructions. A very +common example is two memory reads: one from L1 cache and the other from memory: +the second memory read is likely to have more samples. +There are many other causes of hidden cost of instructions. A non-exhaustive +list: mis-predicted branch, TLB cache miss, partial register stall, +partial register dependencies, memory mismatch stall, re-executed µops. If you want to write +programs at the assembly level, be sure to take a look at the Intel and +AMD documentation at http://developer.intel.com/ +and http://www.amd.com/products/cpg/athlon/techdocs/. + + + + + +Acknowledgments + +Thanks to (in no particular order) : Arjan van de Ven, Rik van Riel, Juan Quintela, Philippe Elie, +Phillipp Rumpf, Tigran Aivazian, Alex Brown, Alisdair Rawsthorne, Bob Montgomery, Ray Bryant, H.J. Lu, +Jeff Esper, Will Cohen, Graydon Hoare, Cliff Woolley, Alex Tsariounov, Al Stone, Jason Yeh, +Randolph Chung, Anton Blanchard, Richard Henderson, Andries Brouwer, Bryan Rittmeyer, +Maynard P. Johnson, +Richard Reich (rreich@rdrtech.com), Zwane Mwaikambo, Dave Jones, Charles Filtness; and finally Pulp, for "Intro". + + + +
diff --git a/doc/srcdoc/Doxyfile.in b/doc/srcdoc/Doxyfile.in new file mode 100644 index 0000000..1f76ff4 --- /dev/null +++ b/doc/srcdoc/Doxyfile.in @@ -0,0 +1,184 @@ +# Doxyfile 1.2.13-20020210 + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = @PACKAGE@ +PROJECT_NUMBER = @VERSION@ +OUTPUT_DIRECTORY = +OUTPUT_LANGUAGE = English +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +INTERNAL_DOCS = NO +STRIP_CODE_COMMENTS = NO +CASE_SENSE_NAMES = YES +SHORT_NAMES = NO +HIDE_SCOPE_NAMES = NO +VERBATIM_HEADERS = YES +SHOW_INCLUDE_FILES = YES +JAVADOC_AUTOBRIEF = YES +INHERIT_DOCS = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +GENERATE_TODOLIST = NO +GENERATE_TESTLIST = NO +GENERATE_BUGLIST = NO +ALIASES = +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +SHOW_USED_FILES = YES +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = ../../ +FILE_PATTERNS = *.cpp *.c *.h +RECURSIVE = YES +EXCLUDE = ../../module +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = *.moc.cpp *.moc.h oprof_start.base.cpp +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +TEMPLATE_RELATIONS = YES +HIDE_UNDOC_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +GRAPHICAL_HIERARCHY = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO +#CGI_NAME = search.cgi +#CGI_URL = +#DOC_URL = +#DOC_ABSPATH = +#BIN_ABSPATH = /usr/local/bin/ +#EXT_DOC_PATHS = diff --git a/doc/srcdoc/Makefile b/doc/srcdoc/Makefile new file mode 100644 index 0000000..e848669 --- /dev/null +++ b/doc/srcdoc/Makefile @@ -0,0 +1,9 @@ +DOXYGEN=doxygen + +.PHONY: clean + +all: clean + doxygen Doxyfile + +clean: + rm -rf html/ diff --git a/doc/xsl/catalog-1.xml.in b/doc/xsl/catalog-1.xml.in new file mode 100644 index 0000000..6ab6e7a --- /dev/null +++ b/doc/xsl/catalog-1.xml.in @@ -0,0 +1,16 @@ + + + + + + + @CAT_ENTRY_START@ + + + @CAT_ENTRY_END@ + + + diff --git a/doc/xsl/xhtml-chunk.xsl b/doc/xsl/xhtml-chunk.xsl new file mode 100644 index 0000000..b3320e8 --- /dev/null +++ b/doc/xsl/xhtml-chunk.xsl @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + Error + + is not a chunk! + + + + + + + + + + + + + + + -//W3C//DTD XHTML 1.0 Transitional//EN + http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd + + + + + + + + + + diff --git a/doc/xsl/xhtml-common.xsl b/doc/xsl/xhtml-common.xsl new file mode 100644 index 0000000..99f2bf7 --- /dev/null +++ b/doc/xsl/xhtml-common.xsl @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+        
+          
+        
+      
+
+
+ + + +
+
+        
+      
+
+
+
+
+ +
diff --git a/doc/xsl/xhtml.xsl b/doc/xsl/xhtml.xsl new file mode 100644 index 0000000..31217a6 --- /dev/null +++ b/doc/xsl/xhtml.xsl @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/events/Makefile.am b/events/Makefile.am new file mode 100644 index 0000000..fb27244 --- /dev/null +++ b/events/Makefile.am @@ -0,0 +1,56 @@ +event_files = \ + alpha/ev4/events alpha/ev4/unit_masks \ + alpha/ev5/events alpha/ev5/unit_masks \ + alpha/ev67/events alpha/ev67/unit_masks \ + alpha/ev6/events alpha/ev6/unit_masks \ + alpha/pca56/events alpha/pca56/unit_masks \ + i386/athlon/events i386/athlon/unit_masks \ + i386/p4/events i386/p4-ht/events \ + i386/p4-ht/unit_masks i386/p4/unit_masks \ + i386/pii/events i386/pii/unit_masks \ + i386/piii/events i386/piii/unit_masks \ + i386/ppro/events i386/ppro/unit_masks \ + i386/p6_mobile/events i386/p6_mobile/unit_masks \ + ia64/ia64/events ia64/ia64/unit_masks \ + ia64/itanium2/events ia64/itanium2/unit_masks \ + ia64/itanium/events ia64/itanium/unit_masks \ + ppc64/power4/events ppc64/power4/event_mappings ppc64/power4/unit_masks \ + ppc64/power5/events ppc64/power5/event_mappings ppc64/power5/unit_masks \ + ppc64/970/events ppc64/970/event_mappings ppc64/970/unit_masks \ + rtc/events rtc/unit_masks \ + x86-64/hammer/events x86-64/hammer/unit_masks \ + arm/xscale1/events arm/xscale1/unit_masks \ + arm/xscale2/events arm/xscale2/unit_masks \ + mips/24K/events mips/24K/unit_masks \ + mips/rm7000/events mips/rm7000/unit_masks \ + mips/rm9000/events mips/rm9000/unit_masks \ + mips/sb1/events mips/sb1/unit_masks \ + mips/r10000/events mips/r10000/unit_masks \ + mips/r12000/events mips/r12000/unit_masks \ + mips/vr5432/events mips/vr5432/unit_masks \ + mips/vr5500/events mips/vr5500/unit_masks \ + ppc/e500/events ppc/e500/unit_masks + +install-data-local: + for i in ${event_files} ; do \ + dir=`dirname $$i` ; \ + mkdir -p $(DESTDIR)$(pkgdatadir)/$$dir ; \ + $(INSTALL_DATA) $(top_srcdir)/events/$$i $(DESTDIR)$(pkgdatadir)/$$i ; \ + done + +uninstall-local: + for i in ${event_files} ; do \ + dir=`dirname $$i` ; \ + archdir=`dirname $$dir` ; \ + if test -f $(DESTDIR)$(pkgdatadir)/$$i ; then \ + rm $(DESTDIR)$(pkgdatadir)/$$i ; \ + fi; \ + if test -d $(DESTDIR)$(pkgdatadir)/$$dir ; then \ + rmdir --ignore-fail-on-non-empty $(DESTDIR)$(pkgdatadir)/$$dir ; \ + fi; \ + if test $$archdir != "." -a -d $(DESTDIR)$(pkgdatadir)/$$archdir ; then \ + rmdir --ignore-fail-on-non-empty $(DESTDIR)$(pkgdatadir)/$$archdir ; \ + fi; \ + done + +EXTRA_DIST = $(event_files) diff --git a/events/Makefile.in b/events/Makefile.in new file mode 100644 index 0000000..fbd7bbe --- /dev/null +++ b/events/Makefile.in @@ -0,0 +1,392 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = events +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +event_files = \ + alpha/ev4/events alpha/ev4/unit_masks \ + alpha/ev5/events alpha/ev5/unit_masks \ + alpha/ev67/events alpha/ev67/unit_masks \ + alpha/ev6/events alpha/ev6/unit_masks \ + alpha/pca56/events alpha/pca56/unit_masks \ + i386/athlon/events i386/athlon/unit_masks \ + i386/p4/events i386/p4-ht/events \ + i386/p4-ht/unit_masks i386/p4/unit_masks \ + i386/pii/events i386/pii/unit_masks \ + i386/piii/events i386/piii/unit_masks \ + i386/ppro/events i386/ppro/unit_masks \ + i386/p6_mobile/events i386/p6_mobile/unit_masks \ + ia64/ia64/events ia64/ia64/unit_masks \ + ia64/itanium2/events ia64/itanium2/unit_masks \ + ia64/itanium/events ia64/itanium/unit_masks \ + ppc64/power4/events ppc64/power4/event_mappings ppc64/power4/unit_masks \ + ppc64/power5/events ppc64/power5/event_mappings ppc64/power5/unit_masks \ + ppc64/970/events ppc64/970/event_mappings ppc64/970/unit_masks \ + rtc/events rtc/unit_masks \ + x86-64/hammer/events x86-64/hammer/unit_masks \ + arm/xscale1/events arm/xscale1/unit_masks \ + arm/xscale2/events arm/xscale2/unit_masks \ + mips/24K/events mips/24K/unit_masks \ + mips/rm7000/events mips/rm7000/unit_masks \ + mips/rm9000/events mips/rm9000/unit_masks \ + mips/sb1/events mips/sb1/unit_masks \ + mips/r10000/events mips/r10000/unit_masks \ + mips/r12000/events mips/r12000/unit_masks \ + mips/vr5432/events mips/vr5432/unit_masks \ + mips/vr5500/events mips/vr5500/unit_masks \ + ppc/e500/events ppc/e500/unit_masks + +EXTRA_DIST = $(event_files) +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign events/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign events/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/alpha/ev4 $(distdir)/alpha/ev5 $(distdir)/alpha/ev6 $(distdir)/alpha/ev67 $(distdir)/alpha/pca56 $(distdir)/arm/xscale1 $(distdir)/arm/xscale2 $(distdir)/i386/athlon $(distdir)/i386/p4 $(distdir)/i386/p4-ht $(distdir)/i386/p6_mobile $(distdir)/i386/pii $(distdir)/i386/piii $(distdir)/i386/ppro $(distdir)/ia64/ia64 $(distdir)/ia64/itanium $(distdir)/ia64/itanium2 $(distdir)/mips/24K $(distdir)/mips/r10000 $(distdir)/mips/r12000 $(distdir)/mips/rm7000 $(distdir)/mips/rm9000 $(distdir)/mips/sb1 $(distdir)/mips/vr5432 $(distdir)/mips/vr5500 $(distdir)/ppc/e500 $(distdir)/ppc64/970 $(distdir)/ppc64/power4 $(distdir)/ppc64/power5 $(distdir)/rtc $(distdir)/x86-64/hammer + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-data-local + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am uninstall-local + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-data-local install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am uninstall uninstall-am uninstall-info-am \ + uninstall-local + + +install-data-local: + for i in ${event_files} ; do \ + dir=`dirname $$i` ; \ + mkdir -p $(DESTDIR)$(pkgdatadir)/$$dir ; \ + $(INSTALL_DATA) $(top_srcdir)/events/$$i $(DESTDIR)$(pkgdatadir)/$$i ; \ + done + +uninstall-local: + for i in ${event_files} ; do \ + dir=`dirname $$i` ; \ + archdir=`dirname $$dir` ; \ + if test -f $(DESTDIR)$(pkgdatadir)/$$i ; then \ + rm $(DESTDIR)$(pkgdatadir)/$$i ; \ + fi; \ + if test -d $(DESTDIR)$(pkgdatadir)/$$dir ; then \ + rmdir --ignore-fail-on-non-empty $(DESTDIR)$(pkgdatadir)/$$dir ; \ + fi; \ + if test $$archdir != "." -a -d $(DESTDIR)$(pkgdatadir)/$$archdir ; then \ + rmdir --ignore-fail-on-non-empty $(DESTDIR)$(pkgdatadir)/$$archdir ; \ + fi; \ + done +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/events/alpha/ev4/events b/events/alpha/ev4/events new file mode 100644 index 0000000..8b193d1 --- /dev/null +++ b/events/alpha/ev4/events @@ -0,0 +1,18 @@ +# Alpha EV4 events. +# +event:0x00 counters:0 um:zero minimum:4096 name:ISSUES : Total issues divided by 2 +event:0x02 counters:0 um:zero minimum:4096 name:PIPELINE_DRY : Nothing issued, no valid I-stream data +event:0x04 counters:0 um:zero minimum:4096 name:LOAD_INSNS : All load instructions +event:0x06 counters:0 um:zero minimum:4096 name:PIPELINE_FROZEN : Nothing issued, resource conflict +event:0x08 counters:0 um:zero minimum:4096 name:BRANCH_INSNS : All branches (conditional, unconditional, jsr, hw_rei) +event:0x0a counters:0 um:zero minimum:4096 name:CYCLES : Total cycles +event:0x0b counters:0 um:zero minimum:4096 name:PAL_MODE : Cycles while in PALcode environment +event:0x0c counters:0 um:zero minimum:4096 name:NON_ISSUES : Total nonissues divided by 2 +event:0x10 counters:0 um:zero minimum:256 name:DCACHE_MISSES : Total D-cache misses +event:0x11 counters:0 um:zero minimum:256 name:ICACHE_MISSES : Total I-cache misses +event:0x12 counters:0 um:zero minimum:256 name:DUAL_ISSUE_CYCLES : Cycles of dual issue +event:0x13 counters:0 um:zero minimum:256 name:BRANCH_MISPREDICTS : Branch mispredicts (conditional, jsr, hw_rei) +event:0x14 counters:0 um:zero minimum:256 name:FP_INSNS : FP operate instructions (not br, load, store) +event:0x15 counters:0 um:zero minimum:256 name:INTEGER_OPERATE : Integer operate instructions +event:0x16 counters:0 um:zero minimum:256 name:STORE_INSNS : Store instructions +# There's also EXTERNAL, by which we could monitor the 21066/21068 bus controller. diff --git a/events/alpha/ev4/unit_masks b/events/alpha/ev4/unit_masks new file mode 100644 index 0000000..bc77cc8 --- /dev/null +++ b/events/alpha/ev4/unit_masks @@ -0,0 +1,4 @@ +# Alpha EV4 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/alpha/ev5/events b/events/alpha/ev5/events new file mode 100644 index 0000000..709e06a --- /dev/null +++ b/events/alpha/ev5/events @@ -0,0 +1,49 @@ +# Alpha EV5 events +# +event:0x00 counters:0,2 um:zero minimum:256 name:CYCLES : Total cycles +event:0x01 counters:0 um:zero minimum:256 name:ISSUES : Total issues +event:0x02 counters:1 um:zero minimum:256 name:NON_ISSUE_CYCLES : Nothing issued, pipeline frozen +event:0x03 counters:1 um:zero minimum:256 name:SPLIT_ISSUE_CYCLES : Some but not all issuable instructions issued +event:0x04 counters:1 um:zero minimum:256 name:PIPELINE_DRY : Nothing issued, pipeline dry +event:0x05 counters:1 um:zero minimum:256 name:REPLAY_TRAP : Replay traps (ldu, wb/maf, litmus test) +event:0x06 counters:1 um:zero minimum:256 name:SINGLE_ISSUE_CYCLES : Single issue cycles +event:0x07 counters:1 um:zero minimum:256 name:DUAL_ISSUE_CYCLES : Dual issue cycles +event:0x08 counters:1 um:zero minimum:256 name:TRIPLE_ISSUE_CYCLES : Triple issue cycles +event:0x09 counters:1 um:zero minimum:256 name:QUAD_ISSUE_CYCLES : Quad issue cycles +event:0x0a counters:1 um:zero minimum:256 name:FLOW_CHANGE : Flow change (meaning depends on counter 2) +# ??? This one's dependent on the value in PCSEL2: If measuring PC_MISPR, +# this is jsr-ret instructions, if measuring BRANCH_MISPREDICTS, this is +# conditional branches, otherwise this is all branch insns, including hw_rei. +event:0x0b counters:1 um:zero minimum:256 name:INTEGER_OPERATE : Integer operate instructions +event:0x0c counters:1 um:zero minimum:256 name:FP_INSNS : FP operate instructions (not br, load, store) +# FIXME: Bug carried over +event:0x0c counters:1 um:zero minimum:256 name:LOAD_INSNS : Load instructions +event:0x0d counters:1 um:zero minimum:256 name:STORE_INSNS : Store instructions +event:0x0e counters:1 um:zero minimum:256 name:ICACHE_ACCESS : Instruction cache access +event:0x0f um:zero minimum:256 name:DCACHE_ACCESS : Data cache access +event:0x10 counters:2 um:zero minimum:256 name:LONG_STALLS : Stalls longer than 15 cycles +event:0x11 counters:2 um:zero minimum:256 name:PC_MISPR : PC mispredicts +event:0x12 counters:2 um:zero minimum:256 name:BRANCH_MISPREDICTS : Branch mispredicts +event:0x13 counters:2 um:zero minimum:256 name:ICACHE_MISSES : Instruction cache misses +event:0x14 counters:2 um:zero minimum:256 name:ITB_MISS : Instruction TLB miss +event:0x15 counters:2 um:zero minimum:256 name:DCACHE_MISSES : Data cache misses +event:0x16 counters:2 um:zero minimum:256 name:DTB_MISS : Data TLB miss +event:0x17 counters:2 um:zero minimum:256 name:LOADS_MERGED : Loads merged in MAF +event:0x18 counters:2 um:zero minimum:256 name:LDU_REPLAYS : LDU replay traps +event:0x19 counters:2 um:zero minimum:256 name:WB_MAF_FULL_REPLAYS : WB/MAF full replay traps +event:0x1a counters:2 um:zero minimum:256 name:MEM_BARRIER : Memory barrier instructions +event:0x1b counters:2 um:zero minimum:256 name:LOAD_LOCKED : LDx/L instructions +event:0x1c counters:1 um:zero minimum:256 name:SCACHE_ACCESS : S-cache access +event:0x1d counters:1 um:zero minimum:256 name:SCACHE_READ : S-cache read +event:0x1e counters:1,2 um:zero minimum:256 name:SCACHE_WRITE : S-cache write +event:0x1f counters:1 um:zero minimum:256 name:SCACHE_VICTIM : S-cache victim +event:0x20 counters:2 um:zero minimum:256 name:SCACHE_MISS : S-cache miss +event:0x21 counters:2 um:zero minimum:256 name:SCACHE_READ_MISS : S-cache read miss +event:0x22 counters:2 um:zero minimum:256 name:SCACHE_WRITE_MISS : S-cache write miss +event:0x23 counters:2 um:zero minimum:256 name:SCACHE_SH_WRITE : S-cache shared writes +event:0x24 counters:1 um:zero minimum:256 name:BCACHE_HIT : B-cache hit +event:0x25 counters:1 um:zero minimum:256 name:BCACHE_VICTIM : B-cache victim +event:0x26 counters:2 um:zero minimum:256 name:BCACHE_MISS : B-cache miss +event:0x27 counters:1 um:zero minimum:256 name:SYS_REQ : System requests +event:0x28 counters:2 um:zero minimum:256 name:SYS_INV : System invalidates +event:0x29 counters:2 um:zero minimum:256 name:SYS_READ_REQ : System read requests diff --git a/events/alpha/ev5/unit_masks b/events/alpha/ev5/unit_masks new file mode 100644 index 0000000..4f24fa9 --- /dev/null +++ b/events/alpha/ev5/unit_masks @@ -0,0 +1,4 @@ +# Alpha EV-5 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/alpha/ev6/events b/events/alpha/ev6/events new file mode 100644 index 0000000..2039cef --- /dev/null +++ b/events/alpha/ev6/events @@ -0,0 +1,11 @@ +# Alpha EV6 events +# +event:0x00 counters:0,1 um:zero minimum:500 name:CYCLES : Total cycles +event:0x01 counters:1 um:zero minimum:500 name:RETIRED : Retired instructions +event:0x02 counters:1 um:zero minimum:500 name:COND_BRANCHES : Retired conditional branches +event:0x03 counters:1 um:zero minimum:500 name:BRANCH_MISPREDICTS : Retired branch mispredicts +event:0x04 counters:1 um:zero minimum:500 name:DTB_MISS : Retired DTB single misses * 2 +event:0x05 counters:1 um:zero minimum:500 name:DTB_DD_MISS : Retired DTB double double misses +event:0x06 counters:1 um:zero minimum:500 name:ITB_MISS : Retired ITB misses +event:0x07 counters:1 um:zero minimum:500 name:UNALIGNED_TRAP : Retired unaligned traps +event:0x08 counters:1 um:zero minimum:500 name:REPLAY_TRAP : Replay traps diff --git a/events/alpha/ev6/unit_masks b/events/alpha/ev6/unit_masks new file mode 100644 index 0000000..bbe38c6 --- /dev/null +++ b/events/alpha/ev6/unit_masks @@ -0,0 +1,4 @@ +# Alpha EV-6 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/alpha/ev67/events b/events/alpha/ev67/events new file mode 100644 index 0000000..b603871 --- /dev/null +++ b/events/alpha/ev67/events @@ -0,0 +1,27 @@ +# Alpha EV-67 Events +# +event:0x00 counters:0 um:zero minimum:500 name:CYCLES : Total cycles +event:0x01 counters:1 um:zero minimum:500 name:DELAYED_CYCLES : Cycles of delayed retire pointer advance +# FIXME: bug carried over +event:0x00 counters:0,1 um:zero minimum:500 name:RETIRED : Retired instructions +event:0x02 counters:1 um:zero minimum:500 name:BCACHE_MISS : Bcache misses/long probe latency +event:0x03 counters:1 um:zero minimum:500 name:MBOX_REPLAY : Mbox replay traps +# FIXME: all the below used PM_CTR +event:0x04 counters:0 um:zero minimum:500 name:STALLED_0 : PCTR0 triggered; stalled between fetch and map stages +event:0x05 counters:0 um:zero minimum:500 name:TAKEN_0 : PCTR0 triggered; branch was not mispredicted and taken +event:0x06 counters:0 um:zero minimum:500 name:MISPREDICT_0 : PCTR0 triggered; branch was mispredicted +event:0x07 counters:0 um:zero minimum:500 name:ITB_MISS_0 : PCTR0 triggered; ITB miss +event:0x08 counters:0 um:zero minimum:500 name:DTB_MISS_0 : PCTR0 triggered; DTB miss +event:0x09 counters:0 um:zero minimum:500 name:REPLAY_0 : PCTR0 triggered; replay trap +event:0x0a counters:0 um:zero minimum:500 name:LOAD_STORE_0 : PCTR0 triggered; load-store order replay trap +event:0x0b counters:0 um:zero minimum:500 name:ICACHE_MISS_0 : PCTR0 triggered; Icache miss +event:0x0c counters:0 um:zero minimum:500 name:UNALIGNED_0 : PCTR0 triggered; unaligned load/store trap +event:0x0d counters:0 um:zero minimum:500 name:STALLED_1 : PCTR1 triggered; stalled between fetch and map stages +event:0x0e counters:0 um:zero minimum:500 name:TAKEN_1 : PCTR1 triggered; branch was not mispredicted and taken +event:0x0f counters:0 um:zero minimum:500 name:MISPREDICT_1 : PCTR1 triggered; branch was mispredicted +event:0x10 counters:0 um:zero minimum:500 name:ITB_MISS_1 : PCTR1 triggered; ITB miss +event:0x11 counters:0 um:zero minimum:500 name:DTB_MISS_1 : PCTR1 triggered; DTB miss +event:0x12 counters:0 um:zero minimum:500 name:REPLAY_1 : PCTR1 triggered; replay trap +event:0x13 counters:0 um:zero minimum:500 name:LOAD_STORE_1 : PCTR1 triggered; load-store order replay trap +event:0x14 counters:0 um:zero minimum:500 name:ICACHE_MISS_1 : PCTR1 triggered; Icache miss +event:0x15 counters:0 um:zero minimum:500 name:UNALIGNED_1 : PCTR1 triggered; unaligned load/store trap diff --git a/events/alpha/ev67/unit_masks b/events/alpha/ev67/unit_masks new file mode 100644 index 0000000..3461e49 --- /dev/null +++ b/events/alpha/ev67/unit_masks @@ -0,0 +1,4 @@ +# Alpha EV-67 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/alpha/pca56/events b/events/alpha/pca56/events new file mode 100644 index 0000000..334babe --- /dev/null +++ b/events/alpha/pca56/events @@ -0,0 +1,2 @@ +# PCA-56 +# FIXME: no events ? What's going on here Falk ? diff --git a/events/alpha/pca56/unit_masks b/events/alpha/pca56/unit_masks new file mode 100644 index 0000000..2b807b7 --- /dev/null +++ b/events/alpha/pca56/unit_masks @@ -0,0 +1,3 @@ +# Alpha PCA-56 possible unit masks +# +# FIXME: any events ...? diff --git a/events/arm/xscale1/events b/events/arm/xscale1/events new file mode 100644 index 0000000..a502135 --- /dev/null +++ b/events/arm/xscale1/events @@ -0,0 +1,19 @@ +# XScale 1 events +# +event:0x00 counters:1,2 um:zero minimum:500 name:IFU_IFETCH_MISS : number of instruction fetch misses +event:0x01 counters:1,2 um:zero minimum:500 name:CYCLES_IFU_MEM_STALL : cycles instruction fetch pipe is stalled +event:0x02 counters:1,2 um:zero minimum:500 name:CYCLES_DATA_STALL : cycles stall occurs for due to data dependency +event:0x03 counters:1,2 um:zero minimum:500 name:ITLB_MISS : number of ITLB misses +event:0x04 counters:1,2 um:zero minimum:500 name:DTLB_MISS : number of DTLB misses +event:0x05 counters:1,2 um:zero minimum:500 name:BR_INST_EXECUTED : branch instruction executed w/ or w/o program flow change +event:0x06 counters:1,2 um:zero minimum:500 name:BR_INST_MISS_PRED : branch mispredicted +event:0x07 counters:1,2 um:zero minimum:500 name:INSN_EXECUTED : instruction executed +event:0x08 counters:1,2 um:zero minimum:500 name:CYCLES_DCACHE_FULL_STALL : cycles in stall due to full dcache +event:0x09 counters:1,1 um:zero minimum:500 name:DCACHE_FULL_STALL_CNT : number of stalls due to dcache full condition +event:0x0a counters:1,2 um:zero minimum:500 name:DCACHE_ACCESS : data cache access +event:0x0b counters:1,2 um:zero minimum:500 name:DCACHE_MISS : data cache miss +event:0x0c counters:1,2 um:zero minimum:500 name:DCACHE_WB : data cache writeback, 1 event for every half cacheline +event:0x0d counters:1,2 um:zero minimum:500 name:PC_CHANGE : number of times the program counter was changed without a mode switch +event:0xfe counters:0 um:zero minimum:500 name:CPU_CYCLES : clock cycles counter +#0x10 through 0x17 Defined by ASSP. See the Intel® XScale" core implementation option section of the ASSP +#architecture specification for more details. diff --git a/events/arm/xscale1/unit_masks b/events/arm/xscale1/unit_masks new file mode 100644 index 0000000..f45eb10 --- /dev/null +++ b/events/arm/xscale1/unit_masks @@ -0,0 +1,4 @@ +# XScale 1 possible unit masks +# +name:zero type:mandatory default:0x00 + 0x00 No unit mask diff --git a/events/arm/xscale2/events b/events/arm/xscale2/events new file mode 100644 index 0000000..e080efd --- /dev/null +++ b/events/arm/xscale2/events @@ -0,0 +1,19 @@ +# XScale 2 events +# +event:0x00 counters:1,2,3,4 um:zero minimum:500 name:IFU_IFETCH_MISS : number of instruction fetch misses +event:0x01 counters:1,2,3,4 um:zero minimum:500 name:CYCLES_IFU_MEM_STALL : cycles instruction fetch pipe is stalled +event:0x02 counters:1,2,3,4 um:zero minimum:500 name:CYCLES_DATA_STALL : cycles stall occurs for due to data dependency +event:0x03 counters:1,2,3,4 um:zero minimum:500 name:ITLB_MISS : number of ITLB misses +event:0x04 counters:1,2,3,4 um:zero minimum:500 name:DTLB_MISS : number of DTLB misses +event:0x05 counters:1,2,3,4 um:zero minimum:500 name:BR_INST_EXECUTED : branch instruction executed w/ or w/o program flow change +event:0x06 counters:1,2,3,4 um:zero minimum:500 name:BR_INST_MISS_PRED : branch mispredicted +event:0x07 counters:1,2,3,4 um:zero minimum:500 name:INSN_EXECUTED : instruction executed +event:0x08 counters:1,2,3,4 um:zero minimum:500 name:CYCLES_DCACHE_FULL_STALL : cycles in stall due to full dcache +event:0x09 counters:1,2,3,4 um:zero minimum:500 name:DCACHE_FULL_STALL_CNT : number of stalls due to dcache full condition +event:0x0a counters:1,2,3,4 um:zero minimum:500 name:DCACHE_ACCESS : data cache access +event:0x0b counters:1,2,3,4 um:zero minimum:500 name:DCACHE_MISS : data cache miss +event:0x0c counters:1,2,3,4 um:zero minimum:500 name:DCACHE_WB : data cache writeback, 1 event for every half cacheline +event:0x0d counters:1,2,3,4 um:zero minimum:500 name:PC_CHANGE : number of times the program counter was changed without a mode switch +event:0xfe counters:0 um:zero minimum:500 name:CPU_CYCLES : clock cycles counter +#0x10 through 0x17 Defined by ASSP. See the Intel® XScale" core implementation option section of the ASSP +#architecture specification for more details. diff --git a/events/arm/xscale2/unit_masks b/events/arm/xscale2/unit_masks new file mode 100644 index 0000000..437aab5 --- /dev/null +++ b/events/arm/xscale2/unit_masks @@ -0,0 +1,4 @@ +# XScale 2 possible unit masks +# +name:zero type:mandatory default:0x00 + 0x00 No unit mask diff --git a/events/i386/athlon/events b/events/i386/athlon/events new file mode 100644 index 0000000..830f4f7 --- /dev/null +++ b/events/i386/athlon/events @@ -0,0 +1,27 @@ +# Athlon Events +# +event:0x76 counters:0,1,2,3 um:zero minimum:3000 name:CPU_CLK_UNHALTED : Cycles outside of halt state +event:0xc0 counters:0,1,2,3 um:zero minimum:3000 name:RETIRED_INSNS : Retired instructions (includes exceptions, interrupts, resyncs) +event:0xc1 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_OPS : Retired Ops +event:0x80 counters:0,1,2,3 um:zero minimum:500 name:ICACHE_FETCHES : Instruction cache fetches +event:0x81 counters:0,1,2,3 um:zero minimum:500 name:ICACHE_MISSES : Instruction cache misses +event:0x40 counters:0,1,2,3 um:zero minimum:500 name:DATA_CACHE_ACCESSES : Data cache accesses +event:0x41 counters:0,1,2,3 um:zero minimum:500 name:DATA_CACHE_MISSES : Data cache misses +event:0x42 counters:0,1,2,3 um:moesi minimum:500 name:DATA_CACHE_REFILLS_FROM_L2 : Data cache refills from L2 +event:0x43 counters:0,1,2,3 um:moesi minimum:500 name:DATA_CACHE_REFILLS_FROM_SYSTEM : Data cache refills from system +event:0x44 counters:0,1,2,3 um:moesi minimum:500 name:DATA_CACHE_WRITEBACKS : Data cache write backs +event:0xc2 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_BRANCHES : Retired branches (conditional, unconditional, exceptions, interrupts) +event:0xc3 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_BRANCHES_MISPREDICTED : Retired branches mispredicted +event:0xc4 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_TAKEN_BRANCHES : Retired taken branches +event:0xc5 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_TAKEN_BRANCHES_MISPREDICTED : Retired taken branches mispredicted +event:0x45 counters:0,1,2,3 um:zero minimum:500 name:L1_DTLB_MISSES_L2_DTLD_HITS : L1 DTLB misses and L2 DTLB hits +event:0x46 counters:0,1,2,3 um:zero minimum:500 name:L1_AND_L2_DTLB_MISSES : L1 and L2 DTLB misses +event:0x47 counters:0,1,2,3 um:zero minimum:500 name:MISALIGNED_DATA_REFS : Misaligned data references +event:0x84 counters:0,1,2,3 um:zero minimum:500 name:L1_ITLB_MISSES_L2_ITLB_HITS : L1 ITLB misses (and L2 ITLB hits) +event:0x85 counters:0,1,2,3 um:zero minimum:500 name:L1_AND_L2_ITLB_MISSES : L1 and L2 ITLB misses +event:0xc6 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_FAR_CONTROL_TRANSFERS : Retired far control transfers +event:0xc7 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_RESYNC_BRANCHES : Retired resync branches (only non-control transfer branches counted) +event:0xcd counters:0,1,2,3 um:zero minimum:500 name:INTERRUPTS_MASKED : Interrupts masked cycles (IF=0) +event:0xce counters:0,1,2,3 um:zero minimum:500 name:INTERRUPTS_MASKED_PENDING : Interrupts masked while pending cycles (INTR while IF=0) +event:0xcf counters:0,1,2,3 um:zero minimum:10 name:HARDWARE_INTERRUPTS : Number of taken hardware interrupts +# There are other events, but they were removed from the architecture manuals diff --git a/events/i386/athlon/unit_masks b/events/i386/athlon/unit_masks new file mode 100644 index 0000000..b5b0da8 --- /dev/null +++ b/events/i386/athlon/unit_masks @@ -0,0 +1,11 @@ +# Athlon possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask +name:moesi type:bitmask default:0x1f + 0x10 (M)odified cache state + 0x08 (O)wner cache state + 0x04 (E)xclusive cache state + 0x02 (S)hared cache state + 0x01 (I)nvalid cache state + 0x1f All cache states diff --git a/events/i386/p4-ht/events b/events/i386/p4-ht/events new file mode 100644 index 0000000..00c6bc9 --- /dev/null +++ b/events/i386/p4-ht/events @@ -0,0 +1,25 @@ +# Pentium IV HyperThreading events +# +# NOTE: events cannot currently be 0x00 due to event binding checks in +# driver +# +event:0x1d counters:0 um:global_power_events minimum:6000 name:GLOBAL_POWER_EVENTS : time during which processor is not stopped +event:0x01 counters:3 um:branch_retired minimum:6000 name:BRANCH_RETIRED : retired branches +event:0x02 counters:3 um:mispred_branch_retired minimum:6000 name:MISPRED_BRANCH_RETIRED : retired mispredicted branches +event:0x04 counters:0 um:bpu_fetch_request minimum:6000 name:BPU_FETCH_REQUEST : instruction fetch requests from the branch predict unit +event:0x05 counters:0 um:itlb_reference minimum:6000 name:ITLB_REFERENCE : translations using the instruction translation lookaside buffer +event:0x06 counters:2 um:memory_cancel minimum:6000 name:MEMORY_CANCEL : cancelled requesets in data cache address control unit +event:0x07 counters:2 um:memory_complete minimum:6000 name:MEMORY_COMPLETE : completed split +event:0x08 counters:2 um:load_port_replay minimum:6000 name:LOAD_PORT_REPLAY : replayed events at the load port +event:0x09 counters:2 um:store_port_replay minimum:6000 name:STORE_PORT_REPLAY : replayed events at the store port +event:0x0a counters:0 um:mob_load_replay minimum:6000 name:MOB_LOAD_REPLAY : replayed loads from the memory order buffer +event:0x0c counters:0 um:bsq_cache_reference minimum:6000 name:BSQ_CACHE_REFERENCE : cache references seen by the bus unit +event:0x12 counters:3 um:x87_assist minimum:6000 name:X87_ASSIST : retired x87 instructions which required special handling +event:0x1c counters:3 um:machine_clear minimum:6000 name:MACHINE_CLEAR : cycles with entire machine pipeline cleared +event:0x1e counters:1 um:tc_ms_xfer minimum:6000 name:TC_MS_XFER : number of times uops deliver changed from TC to MS ROM +event:0x1f counters:1 um:uop_queue_writes minimum:6000 name:UOP_QUEUE_WRITES : number of valid uops written to the uop queue +event:0x23 counters:3 um:instr_retired minimum:6000 name:INSTR_RETIRED : retired instructions +event:0x24 counters:3 um:uops_retired minimum:6000 name:UOPS_RETIRED : retired uops +event:0x25 counters:3 um:uop_type minimum:6000 name:UOP_TYPE : type of uop tagged by front-end tagging +event:0x26 counters:1 um:branch_type minimum:6000 name:RETIRED_MISPRED_BRANCH_TYPE : retired mispredicted branched, selected by type +event:0x27 counters:1 um:branch_type minimum:6000 name:RETIRED_BRANCH_TYPE : retired branches, selected by type diff --git a/events/i386/p4-ht/unit_masks b/events/i386/p4-ht/unit_masks new file mode 100644 index 0000000..8bfc6fa --- /dev/null +++ b/events/i386/p4-ht/unit_masks @@ -0,0 +1,79 @@ +# Pentium IV HyperThreading possible unit masks +# +name:branch_retired type:bitmask default:0x0c + 0x01 branch not-taken predicted + 0x02 branch not-taken mispredicted + 0x04 branch taken predicted + 0x08 branch taken mispredicted +name:mispred_branch_retired type:bitmask default:0x01 + 0x01 retired instruction is non-bogus +# FIXME: 0 count nothing, 0xff count more than 0x01, docs says it's a bitmask: +# something wrong in documentation ? +name:bpu_fetch_request type:bitmask default:0x01 + 0x01 trace cache lookup miss +name:itlb_reference type:bitmask default:0x07 + 0x01 ITLB hit + 0x02 ITLB miss + 0x04 uncacheable ITLB hit +name:memory_cancel type:bitmask default:0x08 + 0x04 replayed because no store request buffer available + 0x08 conflicts due to 64k aliasing +name:memory_complete type:bitmask default:0x03 + 0x01 load split completed, excluding UC/WC loads + 0x02 any split stores completed + 0x04 uncacheable load split completed + 0x08 uncacheable store split complete +name:load_port_replay type:mandatory default:0x02 + 0x02 split load +name:store_port_replay type:mandatory default:0x02 + 0x02 split store +name:mob_load_replay type:bitmask default:0x3a + 0x02 replay cause: unknown store address + 0x08 replay cause: unknown store data + 0x10 replay cause: partial overlap between load and store + 0x20 replay cause: mismatched low 4 bits between load and store addr +name:bsq_cache_reference type:bitmask default:0x073f + 0x01 read 2nd level cache hit shared + 0x02 read 2nd level cache hit exclusive + 0x04 read 2nd level cache hit modified + 0x08 read 3rd level cache hit shared + 0x10 read 3rd level cache hit exclusive + 0x20 read 3rd level cache hit modified + 0x100 read 2nd level cache miss + 0x200 read 3rd level cache miss + 0x400 writeback lookup from DAC misses 2nd level cache +name:x87_assist type:bitmask default:0x1f + 0x01 handle FP stack underflow + 0x02 handle FP stack overflow + 0x04 handle x87 output overflow + 0x08 handle x87 output underflow + 0x10 handle x87 input assist +name:machine_clear type:bitmask default:0x01 + 0x01 count a portion of cycles the machine is cleared for any cause + 0x04 count each time the machine is cleared due to memory ordering issues + 0x40 count each time the machine is cleared due to self modifying code +name:global_power_events type:mandatory default:0x01 + 0x01 mandatory +name:tc_ms_xfer type:mandatory default:0x01 + 0x01 count TC to MS transfers +name:uop_queue_writes type:bitmask default:0x07 + 0x01 count uops written to queue from TC build mode + 0x02 count uops written to queue from TC deliver mode + 0x04 count uops written to queue from microcode ROM +name:instr_retired type:bitmask default:0x01 + 0x01 count non-bogus instructions which are not tagged + 0x02 count non-bogus instructions which are tagged + 0x04 count bogus instructions which are not tagged + 0x08 count bogus instructions which are tagged +name:uops_retired type:bitmask default:0x01 + 0x01 count marked uops which are non-bogus + 0x02 count marked uops which are bogus +name:uop_type type:bitmask default:0x02 + 0x02 count uops which are load operations + 0x04 count uops which are store operations +name:branch_type type:bitmask default:0x1f + 0x01 count unconditional jumps + 0x02 count conditional jumps + 0x04 count call branches + 0x08 count return branches + 0x10 count indirect jumps diff --git a/events/i386/p4/events b/events/i386/p4/events new file mode 100644 index 0000000..2978fd5 --- /dev/null +++ b/events/i386/p4/events @@ -0,0 +1,44 @@ +# Pentium IV events +# +# NOTE: events cannot currently be 0x00 due to event binding checks in +# driver +# +event:0x1d counters:0,4 um:global_power_events minimum:3000 name:GLOBAL_POWER_EVENTS : time during which processor is not stopped +event:0x01 counters:3,7 um:branch_retired minimum:3000 name:BRANCH_RETIRED : retired branches +event:0x02 counters:3,7 um:mispred_branch_retired minimum:3000 name:MISPRED_BRANCH_RETIRED : retired mispredicted branches +event:0x04 counters:0,4 um:bpu_fetch_request minimum:3000 name:BPU_FETCH_REQUEST : instruction fetch requests from the branch predict unit +event:0x05 counters:0,4 um:itlb_reference minimum:3000 name:ITLB_REFERENCE : translations using the instruction translation lookaside buffer +event:0x06 counters:2,6 um:memory_cancel minimum:3000 name:MEMORY_CANCEL : cancelled requesets in data cache address control unit +event:0x07 counters:2,6 um:memory_complete minimum:3000 name:MEMORY_COMPLETE : completed split +event:0x08 counters:2,6 um:load_port_replay minimum:3000 name:LOAD_PORT_REPLAY : replayed events at the load port +event:0x09 counters:2,6 um:store_port_replay minimum:3000 name:STORE_PORT_REPLAY : replayed events at the store port +event:0x0a counters:0,4 um:mob_load_replay minimum:3000 name:MOB_LOAD_REPLAY : replayed loads from the memory order buffer +event:0x0c counters:0,4 um:bsq_cache_reference minimum:3000 name:BSQ_CACHE_REFERENCE : cache references seen by the bus unit +# intel doc vol 3 table A-1 P4 and xeon with cpuid signature < 0xf27 doen't allow MSR_FSB_ESCR1 so on only counter 0 is available +event:0x0d counters:0 um:ioq minimum:3000 name:IOQ_ALLOCATION : bus transactions +# FIXME the unit mask associated is known to get different behavior between cpu +# step id, it need to be documented in P4 events doc +event:0x0e counters:4 um:ioq minimum:3000 name:IOQ_ACTIVE_ENTRIES : number of entries in the IOQ which are active +event:0x10 counters:0 um:bsq minimum:3000 name:BSQ_ALLOCATION : allocations in the bus sequence unit +event:0x12 counters:3,7 um:x87_assist minimum:3000 name:X87_ASSIST : retired x87 instructions which required special handling +event:0x1c counters:3,7 um:machine_clear minimum:3000 name:MACHINE_CLEAR : cycles with entire machine pipeline cleared +event:0x1e counters:1,5 um:tc_ms_xfer minimum:3000 name:TC_MS_XFER : number of times uops deliver changed from TC to MS ROM +event:0x1f counters:1,5 um:uop_queue_writes minimum:3000 name:UOP_QUEUE_WRITES : number of valid uops written to the uop queue +event:0x23 counters:3,7 um:instr_retired minimum:3000 name:INSTR_RETIRED : retired instructions +event:0x24 counters:3,7 um:uops_retired minimum:3000 name:UOPS_RETIRED : retired uops +event:0x25 counters:3,7 um:uop_type minimum:3000 name:UOP_TYPE : type of uop tagged by front-end tagging +event:0x26 counters:1,5 um:branch_type minimum:3000 name:RETIRED_MISPRED_BRANCH_TYPE : retired mispredicted branched, selected by type +event:0x27 counters:1,5 um:branch_type minimum:3000 name:RETIRED_BRANCH_TYPE : retired branches, selected by type +event:0x03 counters:1,5 um:tc_deliver_mode minimum:3000 name:TC_DELIVER_MODE : duration (in clock cycles) in the trace cache and decode engine +event:0x0b counters:0,4 um:page_walk_type minimum:3000 name:PAGE_WALK_TYPE : page walks by the page miss handler +event:0x0f counters:0,4 um:fsb_data_activity minimum:3000 name:FSB_DATA_ACTIVITY : DRDY or DBSY events on the front side bus +event:0x11 counters:4 um:bsq minimum:3000 name:BSQ_ACTIVE_ENTRIES : number of entries in the bus sequence unit which are active +event:0x13 counters:2,6 um:flame_uop minimum:3000 name:SSE_INPUT_ASSIST : input assists requested for SSE or SSE2 operands +event:0x14 counters:2,6 um:flame_uop minimum:3000 name:PACKED_SP_UOP : packed single precision uops +event:0x15 counters:2,6 um:flame_uop minimum:3000 name:PACKED_DP_UOP : packed double precision uops +event:0x16 counters:2,6 um:flame_uop minimum:3000 name:SCALAR_SP_UOP : scalar single precision uops +event:0x17 counters:2,6 um:flame_uop minimum:3000 name:SCALAR_DP_UOP : scalar double presision uops +event:0x18 counters:2,6 um:flame_uop minimum:3000 name:64BIT_MMX_UOP : 64 bit integer SIMD MMX uops +event:0x19 counters:2,6 um:flame_uop minimum:3000 name:128BIT_MMX_UOP : 128 bit integer SIMD SSE2 uops +event:0x1a counters:2,6 um:flame_uop minimum:3000 name:X87_FP_UOP : x87 floating point uops +event:0x1b counters:2,6 um:x87_simd_moves_uop minimum:3000 name:X87_SIMD_MOVES_UOP : x87 FPU, MMX, SSE, or SSE2 loads, stores and reg-to-reg moves diff --git a/events/i386/p4/unit_masks b/events/i386/p4/unit_masks new file mode 100644 index 0000000..7946fdd --- /dev/null +++ b/events/i386/p4/unit_masks @@ -0,0 +1,127 @@ +# Pentium IV possible unit masks +# +name:branch_retired type:bitmask default:0x0c + 0x01 branch not-taken predicted + 0x02 branch not-taken mispredicted + 0x04 branch taken predicted + 0x08 branch taken mispredicted +name:mispred_branch_retired type:bitmask default:0x01 + 0x01 retired instruction is non-bogus +# FIXME: 0 count nothing, 0xff count more than 0x01, docs says it's a bitmask: +# something wrong in documentation ? +name:bpu_fetch_request type:bitmask default:0x01 + 0x01 trace cache lookup miss +name:itlb_reference type:bitmask default:0x07 + 0x01 ITLB hit + 0x02 ITLB miss + 0x04 uncacheable ITLB hit +name:memory_cancel type:bitmask default:0x08 + 0x04 replayed because no store request buffer available + 0x08 conflicts due to 64k aliasing +name:memory_complete type:bitmask default:0x03 + 0x01 load split completed, excluding UC/WC loads + 0x02 any split stores completed + 0x04 uncacheable load split completed + 0x08 uncacheable store split complete +name:load_port_replay type:mandatory default:0x02 + 0x02 split load +name:store_port_replay type:mandatory default:0x02 + 0x02 split store +name:mob_load_replay type:bitmask default:0x3a + 0x02 replay cause: unknown store address + 0x08 replay cause: unknown store data + 0x10 replay cause: partial overlap between load and store + 0x20 replay cause: mismatched low 4 bits between load and store addr +name:bsq_cache_reference type:bitmask default:0x073f + 0x01 read 2nd level cache hit shared + 0x02 read 2nd level cache hit exclusive + 0x04 read 2nd level cache hit modified + 0x08 read 3rd level cache hit shared + 0x10 read 3rd level cache hit exclusive + 0x20 read 3rd level cache hit modified + 0x100 read 2nd level cache miss + 0x200 read 3rd level cache miss + 0x400 writeback lookup from DAC misses 2nd level cache +name:ioq type:bitmask default:0xefe1 + 0x01 bus request type bit 0 + 0x02 bus request type bit 1 + 0x04 bus request type bit 2 + 0x08 bus request type bit 3 + 0x10 bus request type bit 4 + 0x20 count read entries + 0x40 count write entries + 0x80 count UC memory access entries + 0x100 count WC memory access entries + 0x200 count write-through memory access entries + 0x400 count write-protected memory access entries + 0x800 count WB memory access entries + 0x2000 count own store requests + 0x4000 count other / DMA store requests + 0x8000 count HW/SW prefetch requests +name:bsq type:bitmask default:0x21 + 0x01 (r)eq (t)ype (e)ncoding, bit 0: see next bit + 0x02 rte bit 1: 00=read, 01=read invalidate, 10=write, 11=writeback + 0x04 req len bit 0 + 0x08 req len bit 1 + 0x20 request type is input (0=output) + 0x40 request type is bus lock + 0x80 request type is cacheable + 0x100 request type is 8-byte chunk split across 8-byte boundary + 0x200 request type is demand (0=prefetch) + 0x400 request type is ordered + 0x800 (m)emory (t)ype (e)ncoding, bit 0: see next bits + 0x1000 mte bit 1: see next bits + 0x2000 mte bit 2: 000=UC, 001=USWC, 100=WT, 101=WP, 110=WB +name:x87_assist type:bitmask default:0x1f + 0x01 handle FP stack underflow + 0x02 handle FP stack overflow + 0x04 handle x87 output overflow + 0x08 handle x87 output underflow + 0x10 handle x87 input assist +name:machine_clear type:bitmask default:0x01 + 0x01 count a portion of cycles the machine is cleared for any cause + 0x04 count each time the machine is cleared due to memory ordering issues + 0x40 count each time the machine is cleared due to self modifying code +name:global_power_events type:mandatory default:0x01 + 0x01 mandatory +name:tc_ms_xfer type:mandatory default:0x01 + 0x01 count TC to MS transfers +name:uop_queue_writes type:bitmask default:0x07 + 0x01 count uops written to queue from TC build mode + 0x02 count uops written to queue from TC deliver mode + 0x04 count uops written to queue from microcode ROM +name:instr_retired type:bitmask default:0x01 + 0x01 count non-bogus instructions which are not tagged + 0x02 count non-bogus instructions which are tagged + 0x04 count bogus instructions which are not tagged + 0x08 count bogus instructions which are tagged +name:uops_retired type:bitmask default:0x01 + 0x01 count marked uops which are non-bogus + 0x02 count marked uops which are bogus +name:uop_type type:bitmask default:0x02 + 0x02 count uops which are load operations + 0x04 count uops which are store operations +name:branch_type type:bitmask default:0x1f + 0x01 count unconditional jumps + 0x02 count conditional jumps + 0x04 count call branches + 0x08 count return branches + 0x10 count indirect jumps +name:tc_deliver_mode type:bitmask default:0x04 + 0x04 processor is in deliver mode + 0x20 processor is in build mode +name:page_walk_type type:bitmask default:0x01 + 0x01 page walk for data TLB miss + 0x02 page walk for instruction TLB miss +name:fsb_data_activity type:bitmask default:0x3f + 0x01 count when this processor drives data onto bus + 0x02 count when this processor reads data from bus + 0x04 count when data is on bus but not sampled by this processor + 0x08 count when this processor reserves bus for driving + 0x10 count when other reserves bus and this processor will sample + 0x20 count when other reserves bus and this processor will not sample +name:flame_uop type:mandatory default:0x8000 + 0x8000 count all uops of this type +name:x87_simd_moves_uop type:bitmask default:0x18 + 0x08 count all x87 SIMD store/move uops + 0x10 count all x87 SIMD load uops diff --git a/events/i386/p6_mobile/events b/events/i386/p6_mobile/events new file mode 100644 index 0000000..86de7bb --- /dev/null +++ b/events/i386/p6_mobile/events @@ -0,0 +1,115 @@ +# Pentium M events +# +event:0x79 counters:0,1 um:zero minimum:6000 name:CPU_CLK_UNHALTED : clocks processor is not halted, and not in a thermal trip +event:0x43 counters:0,1 um:zero minimum:500 name:DATA_MEM_REFS : all memory references, cachable and non +event:0x45 counters:0,1 um:zero minimum:500 name:DCU_LINES_IN : total lines allocated in the DCU +event:0x46 counters:0,1 um:zero minimum:500 name:DCU_M_LINES_IN : number of M state lines allocated in DCU +event:0x47 counters:0,1 um:zero minimum:500 name:DCU_M_LINES_OUT : number of M lines evicted from the DCU +event:0x48 counters:0,1 um:zero minimum:500 name:DCU_MISS_OUTSTANDING : number of cycles while DCU miss outstanding +event:0x80 counters:0,1 um:zero minimum:500 name:IFU_IFETCH : number of non/cachable instruction fetches +event:0x81 counters:0,1 um:zero minimum:500 name:IFU_IFETCH_MISS : number of instruction fetch misses +event:0x85 counters:0,1 um:zero minimum:500 name:ITLB_MISS : number of ITLB misses +event:0x86 counters:0,1 um:zero minimum:500 name:IFU_MEM_STALL : cycles instruction fetch pipe is stalled +event:0x87 counters:0,1 um:zero minimum:500 name:ILD_STALL : cycles instruction length decoder is stalled +event:0x28 counters:0,1 um:mesi minimum:500 name:L2_IFETCH : number of L2 instruction fetches +event:0x29 counters:0,1 um:mesi minimum:500 name:L2_LD : number of L2 data loads +event:0x2a counters:0,1 um:mesi minimum:500 name:L2_ST : number of L2 data stores +event:0x24 counters:0,1 um:zero minimum:500 name:L2_LINES_IN : number of allocated lines in L2 +event:0x26 counters:0,1 um:zero minimum:500 name:L2_LINES_OUT : number of recovered lines from L2 +event:0x25 counters:0,1 um:zero minimum:500 name:L2_M_LINES_INM : number of modified lines allocated in L2 +event:0x27 counters:0,1 um:zero minimum:500 name:L2_M_LINES_OUTM : number of modified lines removed from L2 +event:0x2e counters:0,1 um:mesi minimum:500 name:L2_RQSTS : number of L2 requests +event:0x21 counters:0,1 um:zero minimum:500 name:L2_ADS : number of L2 address strobes +event:0x22 counters:0,1 um:zero minimum:500 name:L2_DBUS_BUSY : number of cycles data bus was busy +event:0x23 counters:0,1 um:zero minimum:500 name:L2_DBUS_BUSY_RD : cycles data bus was busy in xfer from L2 to CPU +event:0x62 counters:0,1 um:ebl minimum:500 name:BUS_DRDY_CLOCKS : number of clocks DRDY is asserted +event:0x63 counters:0,1 um:ebl minimum:500 name:BUS_LOCK_CLOCKS : number of clocks LOCK is asserted +event:0x60 counters:0,1 um:zero minimum:500 name:BUS_REQ_OUTSTANDING : number of outstanding bus requests +event:0x65 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_BRD : number of burst read transactions +event:0x66 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_RFO : number of read for ownership transactions +event:0x67 counters:0,1 um:ebl minimum:500 name:BUS_TRANS_WB : number of write back transactions +event:0x68 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_IFETCH : number of instruction fetch transactions +event:0x69 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_INVAL : number of invalidate transactions +event:0x6a counters:0,1 um:ebl minimum:500 name:BUS_TRAN_PWR : number of partial write transactions +event:0x6b counters:0,1 um:ebl minimum:500 name:BUS_TRANS_P : number of partial transactions +event:0x6c counters:0,1 um:ebl minimum:500 name:BUS_TRANS_IO : number of I/O transactions +event:0x6d counters:0,1 um:ebl minimum:500 name:BUS_TRANS_DEF : number of deferred transactions +event:0x6e counters:0,1 um:ebl minimum:500 name:BUS_TRAN_BURST : number of burst transactions +event:0x70 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_ANY : number of all transactions +event:0x6f counters:0,1 um:ebl minimum:500 name:BUS_TRAN_MEM : number of memory transactions +event:0x64 counters:0,1 um:zero minimum:500 name:BUS_DATA_RCV : bus cycles this processor is receiving data +event:0x61 counters:0,1 um:zero minimum:500 name:BUS_BNR_DRV : bus cycles this processor is driving BNR pin +event:0x7a counters:0,1 um:zero minimum:500 name:BUS_HIT_DRV : bus cycles this processor is driving HIT pin +event:0x7b counters:0,1 um:zero minimum:500 name:BUS_HITM_DRV : bus cycles this processor is driving HITM pin +event:0x7e counters:0,1 um:zero minimum:500 name:BUS_SNOOP_STALL : cycles during bus snoop stall +event:0xc1 counters:0 um:zero minimum:3000 name:COMP_FLOP_RET : number of computational FP operations retired +event:0x10 counters:0 um:zero minimum:3000 name:FLOPS : number of computational FP operations executed +event:0x11 counters:1 um:zero minimum:500 name:FP_ASSIST : number of FP exceptions handled by microcode +event:0x12 counters:1 um:zero minimum:1000 name:MUL : number of multiplies +event:0x13 counters:1 um:zero minimum:500 name:DIV : number of divides +event:0x14 counters:0 um:zero minimum:1000 name:CYCLES_DIV_BUSY : cycles divider is busy +event:0x03 counters:0,1 um:zero minimum:500 name:LD_BLOCKS : number of store buffer blocks +event:0x04 counters:0,1 um:zero minimum:500 name:SB_DRAINS : number of store buffer drain cycles +event:0x05 counters:0,1 um:zero minimum:500 name:MISALIGN_MEM_REF : number of misaligned data memory references +event:0x07 counters:0,1 um:kni_prefetch minimum:500 name:EMON_KNI_PREF_DISPATCHED : number of KNI pre-fetch/weakly ordered insns dispatched +event:0x4b counters:0,1 um:kni_prefetch minimum:500 name:EMON_KNI_PREF_MISS : number of KNI pre-fetch/weakly ordered insns that miss all caches +event:0xc0 counters:0,1 um:zero minimum:6000 name:INST_RETIRED : number of instructions retired +event:0xc2 counters:0,1 um:zero minimum:6000 name:UOPS_RETIRED : number of UOPs retired +# Errata lists INST_DECODE as not accurate. See 25266507.pdf. +event:0xd0 counters:0,1 um:zero minimum:6000 name:INST_DECODED : number of instructions decoded +event:0xd8 counters:0,1 um:sse_sse2_inst_retired minimum:3000 name:EMON_SSE_SSE2_INST_RETIRED : Streaming SIMD Extensions Instructions Retired +event:0xd9 counters:0,1 um:sse_sse2_inst_retired minimum:3000 name:EMON_SSE_SSE2_COMP_INST_RETIRED : Computational SSE Instructions Retired +event:0xc8 counters:0,1 um:zero minimum:500 name:HW_INT_RX : number of hardware interrupts received +event:0xc6 counters:0,1 um:zero minimum:500 name:CYCLES_INT_MASKED : cycles interrupts are disabled +event:0xc7 counters:0,1 um:zero minimum:500 name:CYCLES_INT_PENDING_AND_MASKED : cycles interrupts are disabled with pending interrupts +event:0xc4 counters:0,1 um:zero minimum:500 name:BR_INST_RETIRED : number of branch instructions retired +event:0xc5 counters:0,1 um:zero minimum:500 name:BR_MISS_PRED_RETIRED : number of mispredicted branches retired +event:0xc9 counters:0,1 um:zero minimum:500 name:BR_TAKEN_RETIRED : number of taken branches retired +event:0xca counters:0,1 um:zero minimum:500 name:BR_MISS_PRED_TAKEN_RET : number of taken mispredictions branches retired +event:0xe0 counters:0,1 um:zero minimum:500 name:BR_INST_DECODED : number of branch instructions decoded +event:0xe2 counters:0,1 um:zero minimum:500 name:BTB_MISSES : number of branches that miss the BTB +event:0xe4 counters:0,1 um:zero minimum:500 name:BR_BOGUS : number of bogus branches +event:0xe6 counters:0,1 um:zero minimum:500 name:BACLEARS : number of times BACLEAR is asserted +event:0xa2 counters:0,1 um:zero minimum:500 name:RESOURCE_STALLS : cycles during resource related stalls +event:0xd2 counters:0,1 um:zero minimum:500 name:PARTIAL_RAT_STALLS : cycles or events for partial stalls +event:0x06 counters:0,1 um:zero minimum:500 name:SEGMENT_REG_LOADS : number of segment register loads +event:0xb1 counters:0,1 um:zero minimum:3000 name:MMX_SAT_INSTR_EXEC : number of MMX saturating instructions executed +event:0xb2 counters:0,1 um:mmx_uops minimum:3000 name:MMX_UOPS_EXEC : number of MMX UOPS executed +event:0xb3 counters:0,1 um:mmx_instr_type_exec minimum:3000 name:MMX_INSTR_TYPE_EXEC : number of MMX packing instructions +event:0xcc counters:0,1 um:mmx_trans minimum:3000 name:FP_MMX_TRANS : MMX-floating point transitions +event:0xcd counters:0,1 um:zero minimum:500 name:MMX_ASSIST : number of EMMS instructions executed +event:0xce counters:0,1 um:zero minimum:3000 name:MMX_INSTR_RET : number of MMX instructions retired +# +# Pentium M Specific events from A-7 +# +# +# Power Management +event:0x58 counters:0,1 um:freq minimum:3000 name:EMON_EST_TRANS : Number of Enhanced Intel SpeedStep +# Errata lists EMON_THERMAL_TRIP as not accurate. See 25266507.pdf. +event:0x59 counters:0,1 um:zero minimum:3000 name:EMON_THERMAL_TRIP : Duration/Occurrences in thermal trip +# +# BPU +event:0x88 counters:0,1 um:zero minimum:3000 name:BR_INST_EXEC : Branch instructions executed (not necessarily retired) +event:0x89 counters:0,1 um:zero minimum:3000 name:BR_MISSP_EXEC : Branch instructions executed that were mispredicted at execution +event:0x8a counters:0,1 um:zero minimum:3000 name:BR_BAC_MISSP_EXEC : Branch instructions executed that were mispredicted at Front End (BAC) +event:0x8b counters:0,1 um:zero minimum:3000 name:BR_CND_EXEC : Conditional Branch instructions executed +event:0x8c counters:0,1 um:zero minimum:3000 name:BR_CND_MISSP_EXEC : Conditional Branch instructions executed that were mispredicted +event:0x8d counters:0,1 um:zero minimum:3000 name:BR_IND_EXEC : Indirect Branch instructions executed +event:0x8e counters:0,1 um:zero minimum:3000 name:BR_IND_MISSP_EXEC : Indirect Branch instructions executed that were mispredicted +event:0x8f counters:0,1 um:zero minimum:3000 name:BR_RET_EXEC : Return Branch instructions executed +event:0x90 counters:0,1 um:zero minimum:3000 name:BR_RET_MISSP_EXEC : Return Branch instructions executed that were mispredicted at Execution +event:0x91 counters:0,1 um:zero minimum:3000 name:BR_RET_BAC_MISSP_EXEC :Return Branch instructions executed that were mispredicted at Front End (BAC) +event:0x92 counters:0,1 um:zero minimum:3000 name:BR_CALL_EXEC : CALL instruction executed +event:0x93 counters:0,1 um:zero minimum:3000 name:BR_CALL_MISSP_EXEC : CALL instruction executed and miss predicted +event:0x94 counters:0,1 um:zero minimum:3000 name:BR_IND_CALL_EXEC : Indirect CALL instruction executed +# +# Decoder +event:0xce counters:0,1 um:zero minimum:3000 name:EMON_SIMD_INSTR_RETIRED : Number of retired MMX instructions +event:0xd3 counters:0,1 um:zero minimum:3000 name:EMON_SYNCH_UOPS : Sync micro-ops +event:0xd7 counters:0,1 um:zero minimum:3000 name:EMON_SYNCH_UOPS : Total number of micro-ops +event:0xda counters:0,1 um:fused minimum:3000 name:EMON_FUSED_UOPS_RET : Number of retired fused micro-ops +event:0xdb counters:0,1 um:zero minimum:3000 name:EMON_UNFUSION : Number of unfusion events in the ROB, happened on a FP exception to a fused uOp +# +# Prefetcher +event:0xf0 counters:0,1 um:zero minimum:3000 name:EMON_PREF_RQSTS_UP : Number of upward prefetches issued +event:0xf8 counters:0,1 um:zero minimum:3000 name:EMON_PREF_RQSTS_DN : Number of downward prefetches issued diff --git a/events/i386/p6_mobile/unit_masks b/events/i386/p6_mobile/unit_masks new file mode 100644 index 0000000..2905a2b --- /dev/null +++ b/events/i386/p6_mobile/unit_masks @@ -0,0 +1,47 @@ +# Pentium M possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask +name:mesi type:bitmask default:0x0f + 0x08 (M)odified cache state + 0x04 (E)xclusive cache state + 0x02 (S)hared cache state + 0x01 (I)nvalid cache state + 0x0f All cache states + 0x10 HW prefetched line only + 0x20 all prefetched line w/o regarding mask 0x10. +name:ebl type:exclusive default:0x20 + 0x00 self-generated transactions + 0x20 any transactions +name:kni_prefetch type:exclusive default:0x0 + 0x00 prefetch NTA + 0x01 prefetch T1 + 0x02 prefetch T2 + 0x03 weakly-ordered stores +# this bitmask can seems weirds but is correct, note there is no way to only +# count scalar SIMD instructions +name:sse_sse2_inst_retired type:exclusive default:0x0 + 0x00 SSE Packed Single + 0x01 SSE Scalar-Single + 0x02 SSE2 Packed-Double + 0x03 SSE2 Scalar-Double +name:mmx_uops type:mandatory default:0xf + 0x0f mandatory +name:mmx_instr_type_exec type:bitmask default:0x3f + 0x01 MMX packed multiplies + 0x02 MMX packed shifts + 0x04 MMX pack operations + 0x08 MMX unpack operations + 0x10 MMX packed logical + 0x20 MMX packed arithmetic + 0x3f all of the above +name:mmx_trans type:exclusive default:0x0 + 0x00 MMX->float operations + 0x01 float->MMX operations +name:freq type:exclusive default:0x0 + 0x00 All transitions + 0x02 Only Frequency transitions +name:fused type:exclusive default:0x0 + 0x00 All fused micro-ops + 0x01 Only load+Op micro-ops + 0x02 Only std+sta micro-ops diff --git a/events/i386/pii/events b/events/i386/pii/events new file mode 100644 index 0000000..c5b3beb --- /dev/null +++ b/events/i386/pii/events @@ -0,0 +1,80 @@ +# Pentium II events +# +event:0x79 counters:0,1 um:zero minimum:6000 name:CPU_CLK_UNHALTED : clocks processor is not halted +event:0x43 counters:0,1 um:zero minimum:500 name:DATA_MEM_REFS : all memory references, cachable and non +event:0x45 counters:0,1 um:zero minimum:500 name:DCU_LINES_IN : total lines allocated in the DCU +event:0x46 counters:0,1 um:zero minimum:500 name:DCU_M_LINES_IN : number of M state lines allocated in DCU +event:0x47 counters:0,1 um:zero minimum:500 name:DCU_M_LINES_OUT : number of M lines evicted from the DCU +event:0x48 counters:0,1 um:zero minimum:500 name:DCU_MISS_OUTSTANDING : number of cycles while DCU miss outstanding +event:0x80 counters:0,1 um:zero minimum:500 name:IFU_IFETCH : number of non/cachable instruction fetches +event:0x81 counters:0,1 um:zero minimum:500 name:IFU_IFETCH_MISS : number of instruction fetch misses +event:0x85 counters:0,1 um:zero minimum:500 name:ITLB_MISS : number of ITLB misses +event:0x86 counters:0,1 um:zero minimum:500 name:IFU_MEM_STALL : cycles instruction fetch pipe is stalled +event:0x87 counters:0,1 um:zero minimum:500 name:ILD_STALL : cycles instruction length decoder is stalled +event:0x28 counters:0,1 um:mesi minimum:500 name:L2_IFETCH : number of L2 instruction fetches +event:0x29 counters:0,1 um:mesi minimum:500 name:L2_LD : number of L2 data loads +event:0x2a counters:0,1 um:mesi minimum:500 name:L2_ST : number of L2 data stores +event:0x24 counters:0,1 um:zero minimum:500 name:L2_LINES_IN : number of allocated lines in L2 +event:0x26 counters:0,1 um:zero minimum:500 name:L2_LINES_OUT : number of recovered lines from L2 +event:0x25 counters:0,1 um:zero minimum:500 name:L2_M_LINES_INM : number of modified lines allocated in L2 +event:0x27 counters:0,1 um:zero minimum:500 name:L2_M_LINES_OUTM : number of modified lines removed from L2 +event:0x2e counters:0,1 um:mesi minimum:500 name:L2_RQSTS : number of L2 requests +event:0x21 counters:0,1 um:zero minimum:500 name:L2_ADS : number of L2 address strobes +event:0x22 counters:0,1 um:zero minimum:500 name:L2_DBUS_BUSY : number of cycles data bus was busy +event:0x23 counters:0,1 um:zero minimum:500 name:L2_DBUS_BUSY_RD : cycles data bus was busy in xfer from L2 to CPU +event:0x62 counters:0,1 um:ebl minimum:500 name:BUS_DRDY_CLOCKS : number of clocks DRDY is asserted +event:0x63 counters:0,1 um:ebl minimum:500 name:BUS_LOCK_CLOCKS : number of clocks LOCK is asserted +event:0x60 counters:0,1 um:zero minimum:500 name:BUS_REQ_OUTSTANDING : number of outstanding bus requests +event:0x65 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_BRD : number of burst read transactions +event:0x66 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_RFO : number of read for ownership transactions +event:0x67 counters:0,1 um:ebl minimum:500 name:BUS_TRANS_WB : number of write back transactions +event:0x68 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_IFETCH : number of instruction fetch transactions +event:0x69 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_INVAL : number of invalidate transactions +event:0x6a counters:0,1 um:ebl minimum:500 name:BUS_TRAN_PWR : number of partial write transactions +event:0x6b counters:0,1 um:ebl minimum:500 name:BUS_TRANS_P : number of partial transactions +event:0x6c counters:0,1 um:ebl minimum:500 name:BUS_TRANS_IO : number of I/O transactions +event:0x6d counters:0,1 um:ebl minimum:500 name:BUS_TRANS_DEF : number of deferred transactions +event:0x6e counters:0,1 um:ebl minimum:500 name:BUS_TRAN_BURST : number of burst transactions +event:0x70 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_ANY : number of all transactions +event:0x6f counters:0,1 um:ebl minimum:500 name:BUS_TRAN_MEM : number of memory transactions +event:0x64 counters:0,1 um:zero minimum:500 name:BUS_DATA_RCV : bus cycles this processor is receiving data +event:0x61 counters:0,1 um:zero minimum:500 name:BUS_BNR_DRV : bus cycles this processor is driving BNR pin +event:0x7a counters:0,1 um:zero minimum:500 name:BUS_HIT_DRV : bus cycles this processor is driving HIT pin +event:0x7b counters:0,1 um:zero minimum:500 name:BUS_HITM_DRV : bus cycles this processor is driving HITM pin +event:0x7e counters:0,1 um:zero minimum:500 name:BUS_SNOOP_STALL : cycles during bus snoop stall +event:0xc1 counters:0 um:zero minimum:3000 name:COMP_FLOP_RET : number of computational FP operations retired +event:0x10 counters:0 um:zero minimum:3000 name:FLOPS : number of computational FP operations executed +event:0x11 counters:1 um:zero minimum:500 name:FP_ASSIST : number of FP exceptions handled by microcode +event:0x12 counters:1 um:zero minimum:1000 name:MUL : number of multiplies +event:0x13 counters:1 um:zero minimum:500 name:DIV : number of divides +event:0x14 counters:0 um:zero minimum:1000 name:CYCLES_DIV_BUSY : cycles divider is busy +event:0x03 counters:0,1 um:zero minimum:500 name:LD_BLOCKS : number of store buffer blocks +event:0x04 counters:0,1 um:zero minimum:500 name:SB_DRAINS : number of store buffer drain cycles +event:0x05 counters:0,1 um:zero minimum:500 name:MISALIGN_MEM_REF : number of misaligned data memory references +event:0xc0 counters:0,1 um:zero minimum:6000 name:INST_RETIRED : number of instructions retired +event:0xc2 counters:0,1 um:zero minimum:6000 name:UOPS_RETIRED : number of UOPs retired +event:0xd0 counters:0,1 um:zero minimum:6000 name:INST_DECODED : number of instructions decoded +event:0xc8 counters:0,1 um:zero minimum:500 name:HW_INT_RX : number of hardware interrupts received +event:0xc6 counters:0,1 um:zero minimum:500 name:CYCLES_INT_MASKED : cycles interrupts are disabled +event:0xc7 counters:0,1 um:zero minimum:500 name:CYCLES_INT_PENDING_AND_MASKED : cycles interrupts are disabled with pending interrupts +event:0xc4 counters:0,1 um:zero minimum:500 name:BR_INST_RETIRED : number of branch instructions retired +event:0xc5 counters:0,1 um:zero minimum:500 name:BR_MISS_PRED_RETIRED : number of mispredicted branches retired +event:0xc9 counters:0,1 um:zero minimum:500 name:BR_TAKEN_RETIRED : number of taken branches retired +event:0xca counters:0,1 um:zero minimum:500 name:BR_MISS_PRED_TAKEN_RET : number of taken mispredictions branches retired +event:0xe0 counters:0,1 um:zero minimum:500 name:BR_INST_DECODED : number of branch instructions decoded +event:0xe2 counters:0,1 um:zero minimum:500 name:BTB_MISSES : number of branches that miss the BTB +event:0xe4 counters:0,1 um:zero minimum:500 name:BR_BOGUS : number of bogus branches +event:0xe6 counters:0,1 um:zero minimum:500 name:BACLEARS : number of times BACLEAR is asserted +event:0xa2 counters:0,1 um:zero minimum:500 name:RESOURCE_STALLS : cycles during resource related stalls +event:0xd2 counters:0,1 um:zero minimum:500 name:PARTIAL_RAT_STALLS : cycles or events for partial stalls +event:0x06 counters:0,1 um:zero minimum:500 name:SEGMENT_REG_LOADS : number of segment register loads +event:0xb0 counters:0,1 um:zero minimum:3000 name:MMX_INSTR_EXEC : number of MMX instructions executed +event:0xb1 counters:0,1 um:zero minimum:3000 name:MMX_SAT_INSTR_EXEC : number of MMX saturating instructions executed +event:0xb2 counters:0,1 um:mmx_uops minimum:3000 name:MMX_UOPS_EXEC : number of MMX UOPS executed +event:0xb3 counters:0,1 um:mmx_instr_type_exec minimum:3000 name:MMX_INSTR_TYPE_EXEC : number of MMX packing instructions +event:0xcc counters:0,1 um:mmx_trans minimum:3000 name:FP_MMX_TRANS : MMX-floating point transitions +event:0xcd counters:0,1 um:zero minimum:500 name:MMX_ASSIST : number of EMMS instructions executed +event:0xce counters:0,1 um:zero minimum:3000 name:MMX_INSTR_RET : number of MMX instructions retired +event:0xd4 counters:0,1 um:seg_rename minimum:500 name:SEG_RENAME_STALLS : number of segment register renaming stalls +event:0xd5 counters:0,1 um:seg_rename minimum:500 name:SEG_REG_RENAMES : number of segment register renames +event:0xd6 counters:0,1 um:zero minimum:500 name:RET_SEG_RENAMES : number of segment register rename events retired diff --git a/events/i386/pii/unit_masks b/events/i386/pii/unit_masks new file mode 100644 index 0000000..cd55867 --- /dev/null +++ b/events/i386/pii/unit_masks @@ -0,0 +1,34 @@ +# Pentium II possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask +name:mesi type:bitmask default:0x0f + 0x08 (M)odified cache state + 0x04 (E)xclusive cache state + 0x02 (S)hared cache state + 0x01 (I)nvalid cache state + 0x0f All cache states +name:ebl type:exclusive default:0x20 + 0x00 self-generated transactions + 0x20 any transactions +name:mmx_uops type:mandatory default:0xf + 0x0f mandatory +name:mmx_instr_type_exec type:bitmask default:0x3f + 0x01 MMX packed multiplies + 0x02 MMX packed shifts + 0x04 MMX pack operations + 0x08 MMX unpack operations + 0x10 MMX packed logical + 0x20 MMX packed arithmetic + 0x3f all of the above +name:mmx_trans type:exclusive default:0x0 + 0x00 MMX->float operations + 0x01 float->MMX operations +name:seg_rename type:bitmask default:0xf + 0x1 ES register + 0x2 DS register + 0x4 FS register +# IA manual says this is actually FS again - no mention in errata +# but test show that is really a typo error from IA manual + 0x8 GS register + 0xf ES, DS, FS, GS registers diff --git a/events/i386/piii/events b/events/i386/piii/events new file mode 100644 index 0000000..e5bb41f --- /dev/null +++ b/events/i386/piii/events @@ -0,0 +1,80 @@ +# Pentium III events +# +event:0x79 counters:0,1 um:zero minimum:6000 name:CPU_CLK_UNHALTED : clocks processor is not halted +event:0x43 counters:0,1 um:zero minimum:500 name:DATA_MEM_REFS : all memory references, cachable and non +event:0x45 counters:0,1 um:zero minimum:500 name:DCU_LINES_IN : total lines allocated in the DCU +event:0x46 counters:0,1 um:zero minimum:500 name:DCU_M_LINES_IN : number of M state lines allocated in DCU +event:0x47 counters:0,1 um:zero minimum:500 name:DCU_M_LINES_OUT : number of M lines evicted from the DCU +event:0x48 counters:0,1 um:zero minimum:500 name:DCU_MISS_OUTSTANDING : number of cycles while DCU miss outstanding +event:0x80 counters:0,1 um:zero minimum:500 name:IFU_IFETCH : number of non/cachable instruction fetches +event:0x81 counters:0,1 um:zero minimum:500 name:IFU_IFETCH_MISS : number of instruction fetch misses +event:0x85 counters:0,1 um:zero minimum:500 name:ITLB_MISS : number of ITLB misses +event:0x86 counters:0,1 um:zero minimum:500 name:IFU_MEM_STALL : cycles instruction fetch pipe is stalled +event:0x87 counters:0,1 um:zero minimum:500 name:ILD_STALL : cycles instruction length decoder is stalled +event:0x28 counters:0,1 um:mesi minimum:500 name:L2_IFETCH : number of L2 instruction fetches +event:0x29 counters:0,1 um:mesi minimum:500 name:L2_LD : number of L2 data loads +event:0x2a counters:0,1 um:mesi minimum:500 name:L2_ST : number of L2 data stores +event:0x24 counters:0,1 um:zero minimum:500 name:L2_LINES_IN : number of allocated lines in L2 +event:0x26 counters:0,1 um:zero minimum:500 name:L2_LINES_OUT : number of recovered lines from L2 +event:0x25 counters:0,1 um:zero minimum:500 name:L2_M_LINES_INM : number of modified lines allocated in L2 +event:0x27 counters:0,1 um:zero minimum:500 name:L2_M_LINES_OUTM : number of modified lines removed from L2 +event:0x2e counters:0,1 um:mesi minimum:500 name:L2_RQSTS : number of L2 requests +event:0x21 counters:0,1 um:zero minimum:500 name:L2_ADS : number of L2 address strobes +event:0x22 counters:0,1 um:zero minimum:500 name:L2_DBUS_BUSY : number of cycles data bus was busy +event:0x23 counters:0,1 um:zero minimum:500 name:L2_DBUS_BUSY_RD : cycles data bus was busy in xfer from L2 to CPU +event:0x62 counters:0,1 um:ebl minimum:500 name:BUS_DRDY_CLOCKS : number of clocks DRDY is asserted +event:0x63 counters:0,1 um:ebl minimum:500 name:BUS_LOCK_CLOCKS : number of clocks LOCK is asserted +event:0x60 counters:0,1 um:zero minimum:500 name:BUS_REQ_OUTSTANDING : number of outstanding bus requests +event:0x65 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_BRD : number of burst read transactions +event:0x66 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_RFO : number of read for ownership transactions +event:0x67 counters:0,1 um:ebl minimum:500 name:BUS_TRANS_WB : number of write back transactions +event:0x68 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_IFETCH : number of instruction fetch transactions +event:0x69 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_INVAL : number of invalidate transactions +event:0x6a counters:0,1 um:ebl minimum:500 name:BUS_TRAN_PWR : number of partial write transactions +event:0x6b counters:0,1 um:ebl minimum:500 name:BUS_TRANS_P : number of partial transactions +event:0x6c counters:0,1 um:ebl minimum:500 name:BUS_TRANS_IO : number of I/O transactions +event:0x6d counters:0,1 um:ebl minimum:500 name:BUS_TRANS_DEF : number of deferred transactions +event:0x6e counters:0,1 um:ebl minimum:500 name:BUS_TRAN_BURST : number of burst transactions +event:0x70 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_ANY : number of all transactions +event:0x6f counters:0,1 um:ebl minimum:500 name:BUS_TRAN_MEM : number of memory transactions +event:0x64 counters:0,1 um:zero minimum:500 name:BUS_DATA_RCV : bus cycles this processor is receiving data +event:0x61 counters:0,1 um:zero minimum:500 name:BUS_BNR_DRV : bus cycles this processor is driving BNR pin +event:0x7a counters:0,1 um:zero minimum:500 name:BUS_HIT_DRV : bus cycles this processor is driving HIT pin +event:0x7b counters:0,1 um:zero minimum:500 name:BUS_HITM_DRV : bus cycles this processor is driving HITM pin +event:0x7e counters:0,1 um:zero minimum:500 name:BUS_SNOOP_STALL : cycles during bus snoop stall +event:0xc1 counters:0 um:zero minimum:3000 name:COMP_FLOP_RET : number of computational FP operations retired +event:0x10 counters:0 um:zero minimum:3000 name:FLOPS : number of computational FP operations executed +event:0x11 counters:1 um:zero minimum:500 name:FP_ASSIST : number of FP exceptions handled by microcode +event:0x12 counters:1 um:zero minimum:1000 name:MUL : number of multiplies +event:0x13 counters:1 um:zero minimum:500 name:DIV : number of divides +event:0x14 counters:0 um:zero minimum:1000 name:CYCLES_DIV_BUSY : cycles divider is busy +event:0x03 counters:0,1 um:zero minimum:500 name:LD_BLOCKS : number of store buffer blocks +event:0x04 counters:0,1 um:zero minimum:500 name:SB_DRAINS : number of store buffer drain cycles +event:0x05 counters:0,1 um:zero minimum:500 name:MISALIGN_MEM_REF : number of misaligned data memory references +event:0x07 counters:0,1 um:kni_prefetch minimum:500 name:EMON_KNI_PREF_DISPATCHED : number of KNI pre-fetch/weakly ordered insns dispatched +event:0x4b counters:0,1 um:kni_prefetch minimum:500 name:EMON_KNI_PREF_MISS : number of KNI pre-fetch/weakly ordered insns that miss all caches +event:0xc0 counters:0,1 um:zero minimum:6000 name:INST_RETIRED : number of instructions retired +event:0xc2 counters:0,1 um:zero minimum:6000 name:UOPS_RETIRED : number of UOPs retired +event:0xd0 counters:0,1 um:zero minimum:6000 name:INST_DECODED : number of instructions decoded +event:0xd8 counters:0,1 um:kni_inst_retired minimum:3000 name:EMON_KNI_INST_RETIRED : number of KNI instructions retired +event:0xd9 counters:0,1 um:kni_inst_retired minimum:3000 name:EMON_KNI_COMP_INST_RET : number of KNI computation instructions retired +event:0xc8 counters:0,1 um:zero minimum:500 name:HW_INT_RX : number of hardware interrupts received +event:0xc6 counters:0,1 um:zero minimum:500 name:CYCLES_INT_MASKED : cycles interrupts are disabled +event:0xc7 counters:0,1 um:zero minimum:500 name:CYCLES_INT_PENDING_AND_MASKED : cycles interrupts are disabled with pending interrupts +event:0xc4 counters:0,1 um:zero minimum:500 name:BR_INST_RETIRED : number of branch instructions retired +event:0xc5 counters:0,1 um:zero minimum:500 name:BR_MISS_PRED_RETIRED : number of mispredicted branches retired +event:0xc9 counters:0,1 um:zero minimum:500 name:BR_TAKEN_RETIRED : number of taken branches retired +event:0xca counters:0,1 um:zero minimum:500 name:BR_MISS_PRED_TAKEN_RET : number of taken mispredictions branches retired +event:0xe0 counters:0,1 um:zero minimum:500 name:BR_INST_DECODED : number of branch instructions decoded +event:0xe2 counters:0,1 um:zero minimum:500 name:BTB_MISSES : number of branches that miss the BTB +event:0xe4 counters:0,1 um:zero minimum:500 name:BR_BOGUS : number of bogus branches +event:0xe6 counters:0,1 um:zero minimum:500 name:BACLEARS : number of times BACLEAR is asserted +event:0xa2 counters:0,1 um:zero minimum:500 name:RESOURCE_STALLS : cycles during resource related stalls +event:0xd2 counters:0,1 um:zero minimum:500 name:PARTIAL_RAT_STALLS : cycles or events for partial stalls +event:0x06 counters:0,1 um:zero minimum:500 name:SEGMENT_REG_LOADS : number of segment register loads +event:0xb1 counters:0,1 um:zero minimum:3000 name:MMX_SAT_INSTR_EXEC : number of MMX saturating instructions executed +event:0xb2 counters:0,1 um:mmx_uops minimum:3000 name:MMX_UOPS_EXEC : number of MMX UOPS executed +event:0xb3 counters:0,1 um:mmx_instr_type_exec minimum:3000 name:MMX_INSTR_TYPE_EXEC : number of MMX packing instructions +event:0xcc counters:0,1 um:mmx_trans minimum:3000 name:FP_MMX_TRANS : MMX-floating point transitions +event:0xcd counters:0,1 um:zero minimum:500 name:MMX_ASSIST : number of EMMS instructions executed +event:0xce counters:0,1 um:zero minimum:3000 name:MMX_INSTR_RET : number of MMX instructions retired diff --git a/events/i386/piii/unit_masks b/events/i386/piii/unit_masks new file mode 100644 index 0000000..6fea980 --- /dev/null +++ b/events/i386/piii/unit_masks @@ -0,0 +1,36 @@ +# Pentium III possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask +name:mesi type:bitmask default:0x0f + 0x08 (M)odified cache state + 0x04 (E)xclusive cache state + 0x02 (S)hared cache state + 0x01 (I)nvalid cache state + 0x0f All cache states +name:ebl type:exclusive default:0x20 + 0x00 self-generated transactions + 0x20 any transactions +name:kni_prefetch type:exclusive default:0x0 + 0x00 prefetch NTA + 0x01 prefetch T1 + 0x02 prefetch T2 + 0x03 weakly-ordered stores +# this bitmask can seems weirds but is correct, note there is no way to only +# count scalar SIMD instructions +name:kni_inst_retired type:exclusive default:0x0 + 0x00 packed and scalar + 0x01 packed +name:mmx_uops type:mandatory default:0xf + 0x0f mandatory +name:mmx_instr_type_exec type:bitmask default:0x3f + 0x01 MMX packed multiplies + 0x02 MMX packed shifts + 0x04 MMX pack operations + 0x08 MMX unpack operations + 0x10 MMX packed logical + 0x20 MMX packed arithmetic + 0x3f all of the above +name:mmx_trans type:exclusive default:0x0 + 0x00 MMX->float operations + 0x01 float->MMX operations diff --git a/events/i386/ppro/events b/events/i386/ppro/events new file mode 100644 index 0000000..8182bc3 --- /dev/null +++ b/events/i386/ppro/events @@ -0,0 +1,70 @@ +# Pentium Pro events +# +event:0x79 counters:0,1 um:zero minimum:6000 name:CPU_CLK_UNHALTED : clocks processor is not halted +event:0x43 counters:0,1 um:zero minimum:500 name:DATA_MEM_REFS : all memory references, cachable and non +event:0x45 counters:0,1 um:zero minimum:500 name:DCU_LINES_IN : total lines allocated in the DCU +event:0x46 counters:0,1 um:zero minimum:500 name:DCU_M_LINES_IN : number of M state lines allocated in DCU +event:0x47 counters:0,1 um:zero minimum:500 name:DCU_M_LINES_OUT : number of M lines evicted from the DCU +event:0x48 counters:0,1 um:zero minimum:500 name:DCU_MISS_OUTSTANDING : number of cycles while DCU miss outstanding +event:0x80 counters:0,1 um:zero minimum:500 name:IFU_IFETCH : number of non/cachable instruction fetches +event:0x81 counters:0,1 um:zero minimum:500 name:IFU_IFETCH_MISS : number of instruction fetch misses +event:0x85 counters:0,1 um:zero minimum:500 name:ITLB_MISS : number of ITLB misses +event:0x86 counters:0,1 um:zero minimum:500 name:IFU_MEM_STALL : cycles instruction fetch pipe is stalled +event:0x87 counters:0,1 um:zero minimum:500 name:ILD_STALL : cycles instruction length decoder is stalled +event:0x28 counters:0,1 um:mesi minimum:500 name:L2_IFETCH : number of L2 instruction fetches +event:0x29 counters:0,1 um:mesi minimum:500 name:L2_LD : number of L2 data loads +event:0x2a counters:0,1 um:mesi minimum:500 name:L2_ST : number of L2 data stores +event:0x24 counters:0,1 um:zero minimum:500 name:L2_LINES_IN : number of allocated lines in L2 +event:0x26 counters:0,1 um:zero minimum:500 name:L2_LINES_OUT : number of recovered lines from L2 +event:0x25 counters:0,1 um:zero minimum:500 name:L2_M_LINES_INM : number of modified lines allocated in L2 +event:0x27 counters:0,1 um:zero minimum:500 name:L2_M_LINES_OUTM : number of modified lines removed from L2 +event:0x2e counters:0,1 um:mesi minimum:500 name:L2_RQSTS : number of L2 requests +event:0x21 counters:0,1 um:zero minimum:500 name:L2_ADS : number of L2 address strobes +event:0x22 counters:0,1 um:zero minimum:500 name:L2_DBUS_BUSY : number of cycles data bus was busy +event:0x23 counters:0,1 um:zero minimum:500 name:L2_DBUS_BUSY_RD : cycles data bus was busy in xfer from L2 to CPU +event:0x62 counters:0,1 um:ebl minimum:500 name:BUS_DRDY_CLOCKS : number of clocks DRDY is asserted +event:0x63 counters:0,1 um:ebl minimum:500 name:BUS_LOCK_CLOCKS : number of clocks LOCK is asserted +event:0x60 counters:0,1 um:zero minimum:500 name:BUS_REQ_OUTSTANDING : number of outstanding bus requests +event:0x65 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_BRD : number of burst read transactions +event:0x66 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_RFO : number of read for ownership transactions +event:0x67 counters:0,1 um:ebl minimum:500 name:BUS_TRANS_WB : number of write back transactions +event:0x68 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_IFETCH : number of instruction fetch transactions +event:0x69 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_INVAL : number of invalidate transactions +event:0x6a counters:0,1 um:ebl minimum:500 name:BUS_TRAN_PWR : number of partial write transactions +event:0x6b counters:0,1 um:ebl minimum:500 name:BUS_TRANS_P : number of partial transactions +event:0x6c counters:0,1 um:ebl minimum:500 name:BUS_TRANS_IO : number of I/O transactions +event:0x6d counters:0,1 um:ebl minimum:500 name:BUS_TRANS_DEF : number of deferred transactions +event:0x6e counters:0,1 um:ebl minimum:500 name:BUS_TRAN_BURST : number of burst transactions +event:0x70 counters:0,1 um:ebl minimum:500 name:BUS_TRAN_ANY : number of all transactions +event:0x6f counters:0,1 um:ebl minimum:500 name:BUS_TRAN_MEM : number of memory transactions +event:0x64 counters:0,1 um:zero minimum:500 name:BUS_DATA_RCV : bus cycles this processor is receiving data +event:0x61 counters:0,1 um:zero minimum:500 name:BUS_BNR_DRV : bus cycles this processor is driving BNR pin +event:0x7a counters:0,1 um:zero minimum:500 name:BUS_HIT_DRV : bus cycles this processor is driving HIT pin +event:0x7b counters:0,1 um:zero minimum:500 name:BUS_HITM_DRV : bus cycles this processor is driving HITM pin +event:0x7e counters:0,1 um:zero minimum:500 name:BUS_SNOOP_STALL : cycles during bus snoop stall +event:0xc1 counters:0 um:zero minimum:3000 name:COMP_FLOP_RET : number of computational FP operations retired +event:0x10 counters:0 um:zero minimum:3000 name:FLOPS : number of computational FP operations executed +event:0x11 counters:1 um:zero minimum:500 name:FP_ASSIST : number of FP exceptions handled by microcode +event:0x12 counters:1 um:zero minimum:1000 name:MUL : number of multiplies +event:0x13 counters:1 um:zero minimum:500 name:DIV : number of divides +event:0x14 counters:0 um:zero minimum:1000 name:CYCLES_DIV_BUSY : cycles divider is busy +event:0x03 counters:0,1 um:zero minimum:500 name:LD_BLOCKS : number of store buffer blocks +event:0x04 counters:0,1 um:zero minimum:500 name:SB_DRAINS : number of store buffer drain cycles +event:0x05 counters:0,1 um:zero minimum:500 name:MISALIGN_MEM_REF : number of misaligned data memory references +event:0xc0 counters:0,1 um:zero minimum:6000 name:INST_RETIRED : number of instructions retired +event:0xc2 counters:0,1 um:zero minimum:6000 name:UOPS_RETIRED : number of UOPs retired +event:0xd0 counters:0,1 um:zero minimum:6000 name:INST_DECODED : number of instructions decoded +event:0xc8 counters:0,1 um:zero minimum:500 name:HW_INT_RX : number of hardware interrupts received +event:0xc6 counters:0,1 um:zero minimum:500 name:CYCLES_INT_MASKED : cycles interrupts are disabled +event:0xc7 counters:0,1 um:zero minimum:500 name:CYCLES_INT_PENDING_AND_MASKED : cycles interrupts are disabled with pending interrupts +event:0xc4 counters:0,1 um:zero minimum:500 name:BR_INST_RETIRED : number of branch instructions retired +event:0xc5 counters:0,1 um:zero minimum:500 name:BR_MISS_PRED_RETIRED : number of mispredicted branches retired +event:0xc9 counters:0,1 um:zero minimum:500 name:BR_TAKEN_RETIRED : number of taken branches retired +event:0xca counters:0,1 um:zero minimum:500 name:BR_MISS_PRED_TAKEN_RET : number of taken mispredictions branches retired +event:0xe0 counters:0,1 um:zero minimum:500 name:BR_INST_DECODED : number of branch instructions decoded +event:0xe2 counters:0,1 um:zero minimum:500 name:BTB_MISSES : number of branches that miss the BTB +event:0xe4 counters:0,1 um:zero minimum:500 name:BR_BOGUS : number of bogus branches +event:0xe6 counters:0,1 um:zero minimum:500 name:BACLEARS : number of times BACLEAR is asserted +event:0xa2 counters:0,1 um:zero minimum:500 name:RESOURCE_STALLS : cycles during resource related stalls +event:0xd2 counters:0,1 um:zero minimum:500 name:PARTIAL_RAT_STALLS : cycles or events for partial stalls +event:0x06 counters:0,1 um:zero minimum:500 name:SEGMENT_REG_LOADS : number of segment register loads diff --git a/events/i386/ppro/unit_masks b/events/i386/ppro/unit_masks new file mode 100644 index 0000000..959b8b5 --- /dev/null +++ b/events/i386/ppro/unit_masks @@ -0,0 +1,13 @@ +# Pentium Pro possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask +name:mesi type:bitmask default:0x0f + 0x08 (M)odified cache state + 0x04 (E)xclusive cache state + 0x02 (S)hared cache state + 0x01 (I)nvalid cache state + 0x0f All cache states +name:ebl type:exclusive default:0x20 + 0x00 self-generated transactions + 0x20 any transactions diff --git a/events/ia64/ia64/events b/events/ia64/ia64/events new file mode 100644 index 0000000..8ae41dd --- /dev/null +++ b/events/ia64/ia64/events @@ -0,0 +1,3 @@ +# IA-64 events +event:0x12 counters:0,1,2,3 um:zero minimum:500 name:CPU_CYCLES : CPU Cycles +event:0x08 counters:0,1,2,3 um:zero minimum:500 name:IA64_INST_RETIRED : IA-64 Instructions Retired diff --git a/events/ia64/ia64/unit_masks b/events/ia64/ia64/unit_masks new file mode 100644 index 0000000..7dd854a --- /dev/null +++ b/events/ia64/ia64/unit_masks @@ -0,0 +1,4 @@ +# IA-64 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/ia64/itanium/events b/events/ia64/itanium/events new file mode 100644 index 0000000..b0ce10f --- /dev/null +++ b/events/ia64/itanium/events @@ -0,0 +1,5 @@ +# IA-64 Itanium 1 events +event:0x12 counters:0,1,2,3 um:zero minimum:500 name:CPU_CYCLES : CPU Cycles +event:0x08 counters:0,1 um:zero minimum:500 name:IA64_INST_RETIRED : IA-64 Instructions Retired +event:0x15 counters:0,1,2,3 um:zero minimum:500 name:IA32_INST_RETIRED : IA-32 Instructions Retired +# FIXME: itanium doc describe a lot of other events, should we add them w/o any testing ? diff --git a/events/ia64/itanium/unit_masks b/events/ia64/itanium/unit_masks new file mode 100644 index 0000000..6a9f77b --- /dev/null +++ b/events/ia64/itanium/unit_masks @@ -0,0 +1,4 @@ +# IA-64 Itanium 1 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/ia64/itanium2/events b/events/ia64/itanium2/events new file mode 100644 index 0000000..c979022 --- /dev/null +++ b/events/ia64/itanium2/events @@ -0,0 +1,267 @@ +# IA-64 Itanium 2 events + +# IA64_2 Basic Events, Table 11-1 +event:0x12 counters:0,1,2,3 um:zero minimum:500 name:CPU_CYCLES : CPU Cycles +event:0x08 counters:0,1,2,3 um:zero minimum:500 name:IA64_INST_RETIRED : IA-64 Instructions Retired +event:0x59 counters:0,1,2,3 um:zero minimum:5000 name:IA32_INST_RETIRED : IA-32 Instructions Retired +event:0x07 counters:0,1,2,3 um:zero minimum:500 name:IA32_ISA_TRANSITIONS : Itanium to/from IA-32 ISA Transitions + +# IA64_2 Instruction Disperal Events, Table 11-3 +event:0x49 counters:0,1,2,3 um:zero minimum:5000 name:DISP_STALLED : Number of cycles dispersal stalled +event:0x4d counters:0,1,2,3 um:zero minimum:5000 name:INST_DISPERSED : Syllables Dispersed from REN to REG stage +event:0x4e counters:0,1,2,3 um:syll_not_dispersed minimum:5000 name:SYLL_NOT_DISPERSED : Syllables not dispersed +event:0x4f counters:0,1,2,3 um:syll_overcount minimum:5000 name:SYLL_OVERCOUNT : Syllables overcounted + +# IA64_2 Instruction Execution Events, Table 11-4 +event:0x58 counters:0,1,2,3 um:alat_capacity_miss minimum:5000 name:ALAT_CAPACITY_MISS : ALAT Entry Replaced +event:0x06 counters:0,1,2,3 um:zero minimum:5000 name:FP_FAILED_FCHKF : Failed fchkf +event:0x05 counters:0,1,2,3 um:zero minimum:5000 name:FP_FALSE_SIRSTALL : SIR stall without a trap +event:0x0b counters:0,1,2,3 um:zero minimum:5000 name:FP_FLUSH_TO_ZERO : Result Flushed to Zero +event:0x09 counters:0,1,2,3 um:zero minimum:5000 name:FP_OPS_RETIRED : Retired FP operations +event:0x03 counters:0,1,2,3 um:zero minimum:5000 name:FP_TRUE_SIRSTALL : SIR stall asserted and leads to a trap +event:0x08 counters:0,1,2,3 um:tagged_inst_retired minimum:5000 name:IA64_TAGGED_INST_RETIRED : Retired Tagged Instructions +event:0x56 counters:0,1,2,3 um:alat_capacity_miss minimum:5000 name:INST_CHKA_LDC_ALAT : Advanced Check Loads +event:0x57 counters:0,1,2,3 um:alat_capacity_miss minimum:5000 name:INST_FAILED_CHKA_LDC_ALAT : Failed Advanced Check Loads +event:0x55 counters:0,1,2,3 um:alat_capacity_miss minimum:5000 name:INST_FAILED_CHKS_RETIRED : Failed Speculative Check Loads +# To avoid duplication from other tables the following events commented out +#event:0xcd counters:0,1,2,3 um:zero minimum:5000 name:LOADS_RETIRED : Retired Loads +#event:0xce counters:0,1,2,3 um:zero minimum:5000 name:MISALIGNED_LOADS_RETIRED : Retired Misaligned Load Instructions +#event:0xcf counters:0,1,2,3 um:zero minimum:5000 name:UC_LOADS_RETIRED : Retired Uncacheable Loads +#event:0xd1 counters:0,1,2,3 um:zero minimum:5000 name:STORES_RETIRED : Retired Stores +#event:0xd2 counters:0,1,2,3 um:zero minimum:5000 name:MISALIGNED_STORES_RETIRED : Retired Misaligned Store Instructions +#event:0xd0 counters:0,1,2,3 um:zero minimum:5000 name:UC_STORES_RETIRED : Retired Uncacheable Stores +event:0x50 counters:0,1,2,3 um:zero minimum:5000 name:NOPS_RETIRED : Retired NOP Instructions +event:0x51 counters:0,1,2,3 um:zero minimum:5000 name:PREDICATE_SQUASHED_RETIRED : Instructions Squashed Due to Predicate Off` + +# IA64_2 Stall Events, Table 11-6 +event:0x00 counters:0,1,2,3 um:back_end_bubble minimum:5000 name:BACK_END_BUBBLE : Full pipe bubbles in main pipe +event:0x02 counters:0,1,2,3 um:be_exe_bubble minimum:5000 name:BE_EXE_BUBBLE : Full pipe bubbles in main pipe due to Execution unit stalls +event:0x04 counters:0,1,2,3 um:be_flush_bubble minimum:5000 name:BE_FLUSH_BUBBLE : Full pipe bubbles in main pipe due to flushes +event:0xca counters:0,1,2,3 um:be_l1d_fpu_bubble minimum:5000 name:BE_L1D_FPU_BUBBLE : Full pipe bubbles in main pipe due to FP or L1 dcache +# To avoid duplication from other tables the following events commented out +#event:0x72 counters:0,1,2,3 um:be_lost_bw_due_to_fe minimum:5000 name:BE_LOST_BW_DUE_TO_FE : Invalid bundles if BE not stalled for other reasons +event:0x01 counters:0,1,2,3 um:be_rse_bubble minimum:5000 name:BE_RSE_BUBBLE : Full pipe bubbles in main pipe due to RSE stalls +event:0x71 counters:0,1,2,3 um:fe_bubble minimum:5000 name:FE_BUBBLE : Bubbles seen by FE +event:0x70 counters:0,1,2,3 um:fe_lost minimum:5000 name:FE_LOST_BW : Invalid bundles at the entrance to IB +event:0x73 counters:0,1,2,3 um:fe_lost minimum:5000 name:IDEAL_BE_LOST_BW_DUE_TO_FE : Invalid bundles at the exit from IB + +# IA64_2 Branch Events, Table 11-7 +event:0x61 counters:0,1,2,3 um:be_br_mispredict_detail minimum:5000 name:BE_BR_MISPRED_DETAIL : BE branch misprediction detail +event:0x11 counters:0,1,2,3 um:zero minimum:5000 name:BRANCH_EVENT : Branch Event Captured +event:0x5b counters:0,1,2,3 um:br_mispred_detail minimum:5000 name:BR_MISPRED_DETAIL : Branch Mispredict Detail +event:0x68 counters:0,1,2,3 um:br_mispredict_detail2 minimum:5000 name:BR_MISPRED_DETAIL2 : FE Branch Mispredict Detail (Unknown path component) +event:0x54 counters:0,1,2,3 um:br_path_pred minimum:5000 name:BR_PATH_PRED : FE Branch Path Prediction Detail +event:0x6a counters:0,1,2,3 um:br_path_pred2 minimum:5000 name:BR_PATH_PRED2 : FE Branch Path Prediction Detail (Unknown prediction component) +event:0x63 counters:0,1,2,3 um:encbr_mispred_detail minimum:5000 name:ENCBR_MISPRED_DETAIL : Number of encoded branches retired + +# IA64_2 L1 Instruction Cache and Prefetch Events, Table 11-8 +event:0x46 counters:0,1,2,3 um:zero minimum:5000 name:ISB_BUNPAIRS_IN : Bundle pairs written from L2 into FE +event:0x43 counters:0,1,2,3 um:zero minimum:5000 name:L1I_EAR_EVENTS : Instruction EAR Events +event:0x66 counters:0,1,2,3 um:zero minimum:5000 name:L1I_FETCH_ISB_HIT : "\"Just-in-time\" instruction fetch hitting in and being bypassed from ISB +event:0x65 counters:0,1,2,3 um:zero minimum:5000 name:L1I_FETCH_RAB_HIT : Instruction fetch hitting in RAB +event:0x41 counters:0,1,2,3 um:zero minimum:5000 name:L1I_FILLS : L1 Instruction Cache Fills +event:0x44 counters:0,1,2,3 um:zero minimum:5000 name:L1I_PREFETCHES : Instruction Prefetch Requests +event:0x42 counters:0,1,2,3 um:zero minimum:5000 name:L2_INST_DEMAND_READS : L1 Instruction Cache and ISB Misses +event:0x67 counters:0,1,2,3 um:l1i_prefetch_stall minimum:5000 name:L1I_PREFETCH_STALL : Why prefetch pipeline is stalled? +event:0x4b counters:0,1,2,3 um:zero minimum:5000 name:L1I_PURGE : L1ITLB purges handled by L1I +event:0x69 counters:0,1,2,3 um:zero minimum:5000 name:L1I_PVAB_OVERFLOW : PVAB overflow +event:0x64 counters:0,1,2,3 um:zero minimum:5000 name:L1I_RAB_ALMOST_FULL : Is RAB almost full? +event:0x60 counters:0,1,2,3 um:zero minimum:500 name:L1I_RAB_FULL : Is RAB full? +event:0x40 counters:0,1,2,3 um:zero minimum:5000 name:L1I_READS : L1 Instruction Cache Read +event:0x4a counters:0,1,2,3 um:zero minimum:5000 name:L1I_SNOOP : Snoop requests handled by L1I +event:0x5f counters:0,1,2,3 um:zero minimum:5000 name:L1I_STRM_PREFETCHES : L1 Instruction Cache line prefetch requests +event:0x45 counters:0,1,2,3 um:zero minimum:5000 name:L2_INST_PREFETCHES : Instruction Prefetch Requests + +# IA64_2 L1 Data Cache Events, Table 11-10 +event:0xc8 counters:0,1,2,3 um:zero minimum:5000 name:DATA_EAR_EVENTS : Data Cache EAR Events +# To avoid duplication from other tables the following events commented out +#event:0xc2 counters:0,1,2,3 um:zero minimum:5000 name:L1D_READS_SET0 : L1 Data Cache Reads +#event:0xc3 counters:0,1,2,3 um:zero minimum:5000 name:DATA_REFERENCES_SET0 : Data memory references issued to memory pipeline +#event:0xc4 counters:0,1,2,3 um:zero minimum:5000 name:L1D_READS_SET1 : L1 Data Cache Reads +#event:0xc5 counters:0,1,2,3 um:zero minimum:5000 name:DATA_REFERENCES_SET1 : Data memory references issued to memory pipeline +#event:0xc7 counters:0,1,2,3 um:l1d_read_misses minimum:5000 name:L1D_READ_MISSES : L1 Data Cache Read Misses + +# IA64_2 L1 Data Cache Set 0 Events, Table 11-11 +event:0xc0 counters:1 um:zero minimum:5000 name:L1DTLB_TRANSFER : L1DTLB misses that hit in the L2DTLB for accesses counted in L1D_READS +event:0xc1 counters:1 um:zero minimum:5000 name:L2DTLB_MISSES : L2DTLB Misses +event:0xc2 counters:1 um:zero minimum:5000 name:L1D_READS_SET0 : L1 Data Cache Reads +event:0xc3 counters:1 um:zero minimum:5000 name:DATA_REFERENCES_SET0 : Data memory references issued to memory pipeline + +# IA64_2 L1 Data Cache Set 1 Events, Table 11-12 +event:0xc4 counters:1 um:zero minimum:5000 name:L1D_READS_SET1 : L1 Data Cache Reads +event:0xc5 counters:1 um:zero minimum:5000 name:DATA_REFERENCES_SET1 : Data memory references issued to memory pipeline +event:0xc7 counters:1 um:l1d_read_misses minimum:5000 name:L1D_READ_MISSES : L1 Data Cache Read Misses + +# IA64_2 L1 Data Cache Set 2 Events, Table 11-13 +event:0xca counters:1 um:be_l1d_fpu_bubble minimum:5000 name:BE_L1D_FPU_BUBBLE : Full pipe bubbles in main pipe due to FP or L1 dcache + +# IA64_2 L1 Data Cache Set 3 Events, Table 11-14 +event:0xcd counters:1 um:zero minimum:5000 name:LOADS_RETIRED : Retired Loads +event:0xce counters:1 um:zero minimum:5000 name:MISALIGNED_LOADS_RETIRED : Retired Misaligned Load Instructions +event:0xcf counters:1 um:zero minimum:5000 name:UC_LOADS_RETIRED : Retired Uncacheable Loads + +# IA64_2 L1 Data Cache Set 4 Events, Table 11-15 +event:0xd1 counters:1 um:zero minimum:5000 name:STORES_RETIRED : Retired Stores +event:0xd2 counters:1 um:zero minimum:5000 name:MISALIGNED_STORES_RETIRED : Retired Misaligned Store Instructions +event:0xd0 counters:1 um:zero minimum:5000 name:UC_STORES_RETIRED : Retired Uncacheable Stores + +# IA64_2 L2 Unified Cache Events, Table 11-16 +# To avoid duplication from other tables the following events commented out +#event:0xb9 counters:0,1,2,3 um:zero minimum:5000 name:L2_BAD_LINES_SELECTED : Valid line replaced when invalid line is available +#event:0xb8 counters:0,1,2,3 um:l2_bypass minimum:5000 name:L2_BYPASS : Count bypass +#event:0xb2 counters:0,1,2,3 um:l2_data_references minimum:5000 name:L2_DATA_REFERENCES : Data read/write access to L2 +event:0xbf counters:0,1,2,3 um:zero minimum:5000 name:L2_FILLB_FULL : L2D Fill buffer is full +#event:0xb4 counters:0,1,2,3 um:l2_force_recirc minimum:5000 name:L2_FORCE_RECIRC : Forced recirculates +event:0xba counters:0,1,2,3 um:recirc_ifetch minimum:5000 name:L2_GOT_RECIRC_IFETCH : Instruction fetch recirculates received by L2D +#event:0xb6 counters:0,1,2,3 um:zero minimum:5000 name:L2_GOT_RECIRC_OZQ_ACC : Counts number of OZQ accesses recirculated back to L1D +#event:0xa1 counters:0,1,2,3 um:l2_ifet_cancels minimum:5000 name:L2_IFET_CANCELS : Instruction fetch cancels by the L2. +#event:0xa5 counters:0,1,2,3 um:l2_ifet_cancels minimum:5000 name:L2_IFET_CANCELS : Instruction fetch cancels by the L2. +#event:0xa9 counters:0,1,2,3 um:l2_ifet_cancels minimum:5000 name:L2_IFET_CANCELS : Instruction fetch cancels by the L2. +#event:0xad counters:0,1,2,3 um:l2_ifet_cancels minimum:5000 name:L2_IFET_CANCELS : Instruction fetch cancels by the L2. +event:0xb9 counters:0,1,2,3 um:recirc_ifetch minimum:5000 name:L2_ISSUED_RECIRC_IFETCH : Instruction fetch recirculates issued by L2D +#event:0xb5 counters:0,1,2,3 um:zero minimum:5000 name:L2_ISSUED_RECIRC_OZQ_ACC : Count number of times a recirculate issue was attempted and not preempted +#event:0xb0 counters:0,1,2,3 um:l2_l3_access_cancel minimum:5000 name:L2_L3ACCESS_CANCEL : Canceled L3 accesses +event:0xcb counters:0,1,2,3 um:zero minimum:5000 name:L2_MISSES : L2 Misses +event:0xb8 counters:0,1,2,3 um:l2_ops_issued minimum:5000 name:L2_OPS_ISSUED : Different operations issued by L2D +#event:0xbd counters:0,1,2,3 um:zero minimum:5000 name:L2_OZDB_FULL : L2D OZQ is full +#event:0xa2 counters:0,1,2,3 um:zero minimum:5000 name:L2_OZQ_ACQUIRE : Clocks with acquire ordering attribute existed in L2 OZQ +#event:0xa6 counters:0,1,2,3 um:zero minimum:5000 name:L2_OZQ_ACQUIRE : Clocks with acquire ordering attribute existed in L2 OZQ +#event:0xaa counters:0,1,2,3 um:zero minimum:5000 name:L2_OZQ_ACQUIRE : Clocks with acquire ordering attribute existed in L2 OZQ +#event:0xae counters:0,1,2,3 um:zero minimum:5000 name:L2_OZQ_ACQUIRE : Clocks with acquire ordering attribute existed in L2 OZQ +#event:0xa0 counters:0,1,2,3 um:l2_ozq_cancels0 minimum:5000 name:L2_OZQ_CANCELS0 : L2 OZQ cancels +#event:0xac counters:0,1,2,3 um:l2_ozq_cancels1 minimum:5000 name:L2_OZQ_CANCELS1 : L2 OZQ cancels +#event:0xa8 counters:0,1,2,3 um:l2_ozq_cancels2 minimum:5000 name:L2_OZQ_CANCELS2 : L2 OZQ cancels +#event:0xbc counters:0,1,2,3 um:zero minimum:5000 name:L2_OZQ_FULL : L2D OZQ is full +#event:0xa3 counters:0,1,2,3 um:zero minimum:5000 name:L2_OZQ_RELEASE : Clocks with release ordering attribute existed in L2 OZQ +#event:0xa7 counters:0,1,2,3 um:zero minimum:5000 name:L2_OZQ_RELEASE : Clocks with release ordering attribute existed in L2 OZQ +#event:0xab counters:0,1,2,3 um:zero minimum:5000 name:L2_OZQ_RELEASE : Clocks with release ordering attribute existed in L2 OZQ +#event:0xaf counters:0,1,2,3 um:zero minimum:5000 name:L2_OZQ_RELEASE : Clocks with release ordering attribute existed in L2 OZQ +#event:0xb1 counters:0,1,2,3 um:zero minimum:5000 name:L2_REFERENCES : Requests made from L2 +#event:0xba counters:0,1,2,3 um:zero minimum:5000 name:L2_STORE_HIT_SHARED : Store hit a shared line +#event:0xb7 counters:0,1,2,3 um:zero minimum:5000 name:L2_SYNTH_PROBE : Synthesized Probe +#event:0xbe counters:0,1,2,3 um:zero minimum:5000 name:L2_VICTIMB_FULL : L2D victim buffer is full + +# IA64_2 L2 Cache Events Set 0, Table 11-18 +# FIXME all sorts of restrictions on how these can be combined +event:0xa1 counters:0 um:l2_ifet_cancels minimum:5000 name:L2_IFET_CANCELS : Instruction fetch cancels by the L2. +event:0xa5 counters:0 um:l2_ifet_cancels minimum:5000 name:L2_IFET_CANCELS : Instruction fetch cancels by the L2. +event:0xa9 counters:0 um:l2_ifet_cancels minimum:5000 name:L2_IFET_CANCELS : Instruction fetch cancels by the L2. +event:0xad counters:0 um:l2_ifet_cancels minimum:5000 name:L2_IFET_CANCELS : Instruction fetch cancels by the L2. +event:0xa2 counters:0 um:zero minimum:5000 name:L2_OZQ_ACQUIRE : Clocks with acquire ordering attribute existed in L2 OZQ +event:0xa6 counters:0 um:zero minimum:5000 name:L2_OZQ_ACQUIRE : Clocks with acquire ordering attribute existed in L2 OZQ +event:0xaa counters:0 um:zero minimum:5000 name:L2_OZQ_ACQUIRE : Clocks with acquire ordering attribute existed in L2 OZQ +event:0xae counters:0 um:zero minimum:5000 name:L2_OZQ_ACQUIRE : Clocks with acquire ordering attribute existed in L2 OZQ +event:0xa0 counters:0 um:l2_ozq_cancels0 minimum:5000 name:L2_OZQ_CANCELS0 : L2 OZQ cancels +event:0xac counters:0 um:l2_ozq_cancels1 minimum:5000 name:L2_OZQ_CANCELS1 : L2 OZQ cancels +event:0xa8 counters:0 um:l2_ozq_cancels2 minimum:5000 name:L2_OZQ_CANCELS2 : L2 OZQ cancels +event:0xa3 counters:0 um:zero minimum:5000 name:L2_OZQ_RELEASE : Clocks with release ordering attribute existed in L2 OZQ +event:0xa7 counters:0 um:zero minimum:5000 name:L2_OZQ_RELEASE : Clocks with release ordering attribute existed in L2 OZQ +event:0xab counters:0 um:zero minimum:5000 name:L2_OZQ_RELEASE : Clocks with release ordering attribute existed in L2 OZQ +event:0xaf counters:0 um:zero minimum:5000 name:L2_OZQ_RELEASE : Clocks with release ordering attribute existed in L2 OZQ + +# IA64_2 L2 Cache Events Set 1, Table 11-19 +# manual states that L2_L3ACCESS_CANCEL must be measured in PMD4. +# FIXME Don't have any way of enforcing the constraints +# so only l2_l3_access_cancel allowed. +event:0xb0 counters:0 um:l2_l3_access_cancel minimum:5000 name:L2_L3ACCESS_CANCEL : Canceled L3 accesses +#event:0xb2 counters:0,1,2,3 um:l2_data_references minimum:5000 name:L2_DATA_REFERENCES : Data read/write access to L2 +#event:0xb1 counters:0,1,2,3 um:zero minimum:5000 name:L2_REFERENCES : Requests made from L2 + +# IA64_2 L2 Cache Events Set 2, Table 11-20 +# manual states that L2_FORCE_RECIRC must be measured in PMD4. +# FIXME Don't have anyway of enforcing thes constraint +# so only L2_FORCE_RECIRC allowed. +event:0xb4 counters:0 um:l2_force_recirc minimum:5000 name:L2_FORCE_RECIRC : Forced recirculates +#event:0xb5 counters:0,1,2,3 um:zero minimum:5000 name:L2_ISSUED_RECIRC_OZQ_ACC : Count number of times a recirculate issue was attempted and not preempted +#event:0xb6 counters:0,1,2,3 um:zero minimum:5000 name:L2_GOT_RECIRC_OZQ_ACC : Counts number of OZQ accesses recirculated back to L1D +#event:0xb7 counters:0,1,2,3 um:zero minimum:5000 name:L2_SYNTH_PROBE : Synthesized Probe + +# IA64_2 L2 Cache Events Set 3, Table 11-21 +# The manual states that all events in this set share the same umask. +event:0xb9 counters:0 um:zero minimum:5000 name:L2_BAD_LINES_SELECTED : Valid line replaced when invalid line is available +event:0xb8 counters:0 um:l2_bypass minimum:5000 name:L2_BYPASS : Count bypass +event:0xba counters:0 um:zero minimum:5000 name:L2_STORE_HIT_SHARED : Store hit a shared line + +# IA64_2 L2 Cache Events Set 4, Table 11-22 +# The manual states one of the following needs to be in pmd4 and these events +# share the same umask. +event:0xba counters:0 um:recirc_ifetch minimum:5000 name:L2_GOT_RECIRC_IFETCH : Instruction fetch recirculates received by L2D +event:0xb9 counters:0 um:recirc_ifetch minimum:5000 name:L2_ISSUED_RECIRC_IFETCH : Instruction fetch recirculates issued by L2D +event:0xb8 counters:0 um:l2_ops_issued minimum:5000 name:L2_OPS_ISSUED : Different operations issued by L2D + +# IA64_2 L2 Cache Events Set 5, Table 11-23 +# manual states one of the following needs to be in pmd4 and +# these events share the same umask +event:0xbc counters:0 um:zero minimum:5000 name:L2_OZQ_FULL : L2D OZQ is full +event:0xbd counters:0 um:zero minimum:5000 name:L2_OZDB_FULL : L2D OZQ is full +event:0xbe counters:0 um:zero minimum:5000 name:L2_VICTIMB_FULL : L2D victim buffer is full +event:0xbf counters:0 um:zero minimum:5000 name:L2_FILLB_FULL : L2D Fill buffer is full + +# IA64_2 L3 Cache Events, Table 11-24 +event:0xdf counters:0,1,2,3 um:zero minimum:5000 name:L3_LINES_REPLACED : Cache Lines Replaced +event:0xdc counters:0,1,2,3 um:zero minimum:5000 name:L3_MISSES : L3 Misses +event:0xdb counters:0,1,2,3 um:zero minimum:5000 name:L3_REFERENCES : L3 References +event:0xdd counters:0,1,2,3 um:l3_reads minimum:5000 name:L3_READS : L3 Reads +event:0xde counters:0,1,2,3 um:l3_writes minimum:5000 name:L3_WRITES : L3 Writes + +# IA64_2 System Events, Table 11-26 +event:0x13 counters:0,1,2,3 um:zero minimum:5000 name:CPU_CPL_CHANGES : Privilege Level Changes +event:0x52 counters:0,1,2,3 um:zero minimum:5000 name:DATA_DEBUG_REGISTER_FAULT : Fault due to data debug reg. Match to load/store instruction +event:0xc6 counters:0,1,2,3 um:zero minimum:5000 name:DATA_DEBUG_REGISTER_MATCHES : Data debug register matches data address of memory reference +event:0x9e counters:0,1,2,3 um:extern_dp_pins_0_to_3 minimum:5000 name:EXTERN_DP_PINS_0_TO_3 : DP pins 0-3 asserted +event:0x9f counters:0,1,2,3 um:extern_dp_pins_4_to_5 minimum:5000 name:EXTERN_DP_PINS_4_TO_5 : DP pins 4-5 asserted +event:0x53 counters:0,1,2,3 um:zero minimum:5000 name:SERIALIZATION_EVENTS : Number of srlz.I instructions + +# IA64_2 TLB Events, Table 11-28 +event:0xc9 counters:0,1,2,3 um:zero minimum:5000 name:DTLB_INSERTS_HPW : Hardware Page Walker Installs to DTLB" +event:0x2c counters:0,1,2,3 um:zero minimum:500 name:DTLB_INSERTS_HPW_RETIRED : VHPT entries inserted into DTLB by HW PW +event:0x2d counters:0,1,2,3 um:zero minimum:500 name:HPW_DATA_REFERENCES : Data memory references to VHPT +#event:0xc1 counters:1 um:zero minimum:5000 name:L2DTLB_MISSES : L2DTLB Misses +event:0x48 counters:0,1,2,3 um:zero minimum:5000 name:L1ITLB_INSERTS_HPW : L1ITLB Hardware Page Walker Inserts +event:0x47 counters:0,1,2,3 um:itlb_misses_fetch minimum:5000 name:ITLB_MISSES_FETCH : ITLB Misses Demand Fetch +#event:0xc0 counters:1 um:zero minimum:5000 name:L1DTLB_TRANSFER : L1DTLB misses that hit in the L2DTLB for accesses counted in L1D_READS + +# IA64_2 System Bus Events, Table 11-30 +event:0x87 counters:0,1,2,3 um:bus minimum:5000 name:BUS_ALL : Bus Transactions +event:0x9c counters:0,1,2,3 um:zero minimum:5000 name:BUS_BRQ_LIVE_REQ_HI : BRQ Live Requests (two most-significant-bit of the 5-bit outstanding BRQ request count) +event:0x9b counters:0,1,2,3 um:zero minimum:5000 name:BUS_BRQ_LIVE_REQ_LO : BRQ Live Requests (three least-significant-bit of the 5-bit outstanding BRQ request count +event:0x9d counters:0,1,2,3 um:zero minimum:5000 name:BUS_BRQ_REQ_INSERTED : BRQ Requests Inserted +event:0x88 counters:0,1,2,3 um:zero minimum:5000 name:BUS_DATA_CYCLE : Valid data cycle on the Bus +event:0x84 counters:0,1,2,3 um:zero minimum:5000 name:BUS_HITM : Bus Hit Modified Line Transactions +event:0x90 counters:0,1,2,3 um:bus minimum:5000 name:BUS_IO : IA-32 Compatible IO Bus Transactions +event:0x98 counters:0,1,2,3 um:zero minimum:5000 name:BUS_IOQ_LIVE_REQ_HI : Inorder Bus Queue Requests (two most-significant-bit of the 4-bit outstanding IOQ request count) +event:0x97 counters:0,1,2,3 um:zero minimum:5000 name:BUS_IOQ_LIVE_REQ_LO : Inorder Bus Queue Requests (two least-significant-bit of the 4-bit outstanding IOQ request count) +event:0x93 counters:0,1,2,3 um:bus_lock minimum:5000 name:BUS_LOCK : IA-32 Compatible Bus Lock Transactions +event:0x8e counters:0,1,2,3 um:bus_backsnp_req minimum:5000 name:BUS_BACKSNP_REQ : Bus Back Snoop Requests +event:0x8a counters:0,1,2,3 um:bus_memory minimum:5000 name:BUS_MEMORY : Bus Memory Transactions +event:0x8b counters:0,1,2,3 um:bus_mem_read minimum:5000 name:BUS_MEM_READ : Full Cache line D/I memory RD, RD invalidate, and BRIL +event:0x94 counters:0,1,2,3 um:zero minimum:5000 name:BUS_MEM_READ_OUT_HI : Outstanding memory RD transactions +event:0x95 counters:0,1,2,3 um:zero minimum:5000 name:BUS_MEM_READ_OUT_LO : Outstanding memory RD transactions +event:0x9a counters:0,1,2,3 um:zero minimum:5000 name:BUS_OOQ_LIVE_REQ_HI : Out-of-order Bus Queue Requests (two most-significant-bit of the 4-bit outstanding OOQ request count) +event:0x99 counters:0,1,2,3 um:zero minimum:5000 name:BUS_OOQ_LIVE_REQ_LO : Out-of-order Bus Queue Requests (three least-significant-bit of the 4-bit outstanding OOQ request count) +event:0x8c counters:0,1,2,3 um:bus minimum:5000 name:BUS_RD_DATA : Bus Read Data Transactions +event:0x80 counters:0,1,2,3 um:zero minimum:5000 name:BUS_RD_HIT : Bus Read Hit Clean Non-local Cache Transactions +event:0x81 counters:0,1,2,3 um:zero minimum:5000 name:BUS_RD_HITM : Bus Read Hit Modified Non-local Cache Transactions +event:0x83 counters:0,1,2,3 um:zero minimum:5000 name:BUS_RD_INVAL_ALL_HITM : Bus BIL or BRIL Transaction Results in HITM +event:0x82 counters:0,1,2,3 um:zero minimum:5000 name:BUS_RD_INVAL_HITM : Bus BIL Transaction Results in HITM +event:0x91 counters:0,1,2,3 um:bus minimum:5000 name:BUS_RD_IO : IA-32 Compatible IO Read Transactions +event:0x8d counters:0,1,2,3 um:bus minimum:5000 name:BUS_RD_PRTL : Bus Read Partial Transactions +event:0x96 counters:0,1,2,3 um:zero minimum:5000 name:BUS_SNOOPQ_REQ : Bus Snoop Queue Requests +event:0x86 counters:0,1,2,3 um:bus minimum:5000 name:BUS_SNOOPS : Bus Snoops Total +event:0x85 counters:0,1,2,3 um:bus_snoop minimum:5000 name:BUS_SNOOPS_HITM : Bus Snoops HIT Modified Cache Line +event:0x8f counters:0,1,2,3 um:bus_snoop minimum:5000 name:BUS_SNOOP_STALL_CYCLES : Bus Snoop Stall Cycles (from any agent) +event:0x92 counters:0,1,2,3 um:bus_wr_wb minimum:5000 name:BUS_WR_WB : Bus Write Back Transactions +event:0x89 counters:0,1,2,3 um:mem_read_current minimum:5000 name:MEM_READ_CURRENT : Current Mem Read Transactions On Bus + +# RSE Events, Table 11-34 +event:0x2b counters:0,1,2,3 um:zero minimum:500 name:RSE_CURRENT_REGS_2_TO_0 : Current RSE registers +event:0x2a counters:0,1,2,3 um:zero minimum:500 name:RSE_CURRENT_REGS_5_TO_3 : Current RSE registers +event:0x26 counters:0,1,2,3 um:zero minimum:500 name:RSE_CURRENT_REGS_6 : Current RSE registers +event:0x29 counters:0,1,2,3 um:zero minimum:500 name:RSE_DIRTY_REGS_2_TO_0 : Dirty RSE registers +event:0x28 counters:0,1,2,3 um:zero minimum:500 name:RSE_DIRTY_REGS_5_TO_3 : Dirty RSE registers +event:0x24 counters:0,1,2,3 um:zero minimum:500 name:RSE_DIRTY_REGS_6 : Dirty RSE registers +event:0x32 counters:0,1,2,3 um:zero minimum:500 name:RSE_EVENT_RETIRED : Retired RSE operations +event:0x20 counters:0,1,2,3 um:rse_references_retired minimum:500 name:RSE_REFERENCES_RETIRED : RSE Accesses + +# IA64 Performance Monitors Ordered by Code, Table 11-36 +event:0xbb counters:0,1,2,3 um:zero minimum:5000 name:TAGGED_L2_DATA_RETURN_POR : Tagged L2 Data Return Ports 0/1 diff --git a/events/ia64/itanium2/unit_masks b/events/ia64/itanium2/unit_masks new file mode 100644 index 0000000..bc74f5d --- /dev/null +++ b/events/ia64/itanium2/unit_masks @@ -0,0 +1,465 @@ +# IA-64 Itanium 2 possible unit masks +# +# The information for the following entries for the Itanium 2 +# came from Intel Itanium 2 Processor Reference Manual For +# Software Development and Optimization, June 2002, Document +# number 251110-001. + +name:zero type:mandatory default:0x0 + 0x0 No unit mask + +# CPU_IA64_2 Table 11-37, 11-72 +name:alat_capacity_miss type:bitmask default:0x03 + 0x1 INT + 0x2 FP + 0x3 ALL + +# CPU_IA64_2 Table 11-38 +name:back_end_bubble type:exclusive default:0x00 + 0x0 ALL + 0x1 FE + 0x2 L1D_FPU_RSE + +# CPU_IA64_2 Table 11-39 +name:be_br_mispredict_detail type:exclusive default:0x00 + 0x0 ANY + 0x1 STG + 0x2 ROT + 0x3 PFS + +# CPU_IA64_2 Table 11-40 +name:be_exe_bubble type:exclusive default:0x00 + 0x0 ALL + 0x1 GRALL + 0x2 FRALL + 0x3 PR + 0x4 ARCR + 0x5 GRCR + 0x6 CANCEL + 0x7 BANK_SWITCH + 0x8 ARCR_PR_CANCEL_BANK + +# CPU_IA64_2 Table 11-41 +name:be_flush_bubble type:exclusive default:0x00 + 0x0 ALL + 0x1 BRU + 0x2 XPN + +# CPU_IA64_2 Table 11-42 +name:be_l1d_fpu_bubble type:exclusive default:0x00 + 0x0 ALL + 0x1 FPU + 0x2 L1D + 0x3 L1D_FULLSTBUF + 0x4 L1D_DCURECIR + 0x5 L1D_HPW + 0x7 L1D_FILLCONF + 0x8 L1D_DCS + 0x9 L1D_L2BPRESS + 0xa L1D_TLB + 0xb L1D_LDCONF + 0xc L1D_LDCHK + 0xd L1D_NAT + 0xe L1D_STBUFRECIR + 0xf L1D_NATCONF + +# CPU_IA64_2 Table 11-43 +# FIXME: events using this is commented out in events +#name:be_lost_bw_due_to_fe type:exclusive default:0x00 +# 0x0 ALL +# 0x1 FEFLUSH +# 0x4 UNREACHED +# 0x5 IBFULL +# 0x6 IMISS +# 0x7 TLBMISS +# 0x8 FILL_RECIRC +# 0x9 BI +# 0xa BRQ +# 0xb PLP +# 0xc BR_ILOCK +# 0xd BUBBLE + +# CPU_IA64_2 Table 11-44 +name:be_rse_bubble type:exclusive default:0x00 + 0x0 ALL + 0x1 BANK_SWITCH + 0x2 AR_DEP + 0x3 OVERFLOW + 0x4 UNDERFLOW + 0x5 LOADRS + +# CPU_IA64_2 Table 11-45 +name:br_mispred_detail type:exclusive default:0x00 + 0x0 ALL.ALL_PRED + 0x1 ALL.CORRECT_PRED + 0x2 ALL.WRONG_PATH + 0x3 ALL.WRONG_TARGET + 0x4 IPREL.ALL_PRED + 0x5 IPREL.CORRECT_PRED + 0x6 IPREL.WRONG_PATH + 0x7 IPREL.WRONG_TARGET + 0x8 RETURN.ALL_PRED + 0x9 RETURN.CORRECT_PRED + 0xa RETURN.WRONG_PATH + 0xb RETURN.WRONG_TARGET + 0xc NRETIND.ALL_PRED + 0xd NRETIND.CORRECT_PRED + 0xe NRETIND.WRONG_PATH + 0xf NRETIND.WRONG_TARGET + +# CPU_IA64_2 Table 11-46 +name:br_mispredict_detail2 type:exclusive default:0x00 + 0x0 ALL.ALL_UNKNOWN_PRED + 0x1 ALL.UKNOWN_PATH_CORRECT_PRED + 0x2 ALL.UKNOWN_PATH_WRONG_PATH + 0x4 IPREL.ALL_UNKNOWN_PRED + 0x5 IPREL.UNKNOWN_PATH_CORRECT_PRED + 0x6 IPREL.UNKNOWN_PATH_WRONG_PATH + 0x8 RETURN.ALL_UNKNOWN_PRED + 0x9 RETURN.UNKNOWN_PATH_CORRECT_PRED + 0xa RETURN.UNKNOWN_PATH_WRONG_PATH + 0xc NRETIND.ALL_UNKNOWN_PRED + 0xd NRETIND.UNKNOWN_PATH_CORRECT_PRED + 0xe NRETIND.UNKNOWN_PATH_WRONG_PATH + +# CPU_IA64_2 Table 11-47 +name:br_path_pred type:exclusive default:0x00 + 0x0 ALL.MISPRED_NOTTAKEN + 0x1 ALL.MISPRED_TAKEN + 0x2 ALL.OKPRED_NOTTAKEN + 0x3 ALL.OKPRED_TAKEN + 0x4 IPREL.MISPRED_NOTTAKEN + 0x5 IPREL.MISPRED_TAKEN + 0x6 IPREL.OKPRED_NOTTAKEN + 0x7 IPREL.OKPRED_TAKEN + 0x8 RETURN.MISPRED_NOTTAKEN + 0x9 RETURN.MISPRED_TAKEN + 0xa RETURN.OKPRED_NOTTAKEN + 0xb RETURN.OKPRED_TAKEN + 0xc NRETIND.MISPRED_NOTTAKEN + 0xd NRETIND.MISPRED_TAKEN + 0xe NRETIND.OKPRED_NOTTAKEN + 0xf NRETIND.OKPRED_TAKEN + +# CPU_IA64_2 Table 11-48 +name:br_path_pred2 type:exclusive default:0x00 + 0x0 ALL.UNKNOWNPRED_NOTTAKEN + 0x1 ALL.UNKNOWNPRED_TAKEN + 0x4 IPREL.UNKNOWNPRED_NOTTAKEN + 0x5 IPREL.UNKNOWNPRED__TAKEN + 0x8 RETURN.UNKNOWNPRED_NOTTAKEN + 0x9 RETURN.UNKNOWNPRED_TAKEN + 0xc NRETIND.UNKNOWNPRED_NOTTAKEN + 0xd NRETIND.UNKNOWNPRED_TAKEN + +# CPU_IA64_2 Table 11-49, 11-51, 11-55, 11-56, 11-57, 11-58 +name:bus type:exclusive default:0x03 + 0x1 IO + 0x2 SELF + 0x3 ANY + +# CPU_IA64_2 Table 11-50 b0001 +name:bus_backsnp_req type:mandatory default:0x01 + 0x1 0x0 + +# CPU_IA64_2 Table 11-52 +name:bus_lock type:exclusive default:0x03 + 0x2 SELF + 0x3 ANY + +# CPU_IA64_2 Table 11-53 +name:bus_memory type:exclusive default:0x0f + 0x5 EQ_128BYTEIO + 0x6 EQ_128BYTE_SELF + 0x7 EQ_128BYTE_ANY + 0x9 LT_128BYTEIO + 0xa LT_128BYTE_SELF + 0xb LT_128BYTE_ANY + 0xd ALL IO + 0xe ALL SELF + 0xf ALL ANY + +# CPU_IA64_2 Table 11-54 +name:bus_mem_read type:exclusive default:0x0f + 0x1 BIL IO + 0x2 BIL SELF + 0x3 BIL ANY + 0x5 BRL IO + 0x6 BRL SELF + 0x7 BRL_ANY + 0x9 BRIL IO + 0xa BRIL SELF + 0xb BRIL ANY + 0xd ALL IO + 0xe ALL SELF + 0xf ALL ANY + +# CPU_IA64_2 Table 11-59, 11-60 +name:bus_snoop type:exclusive default:0x03 + 0x2 SELF + 0x3 ANY + +# CPU_IA64_2 Table 11-61 +name:bus_wr_wb type:exclusive default:0x0f + 0x5 EQ_128BYTE IO + 0x6 EQ_128BYTE SELF + 0x7 EQ_128BYTE ANY + 0xa CCASTOUT SELF + 0xb CCASTOUT ANY + 0xd ALL IO + 0xe ALL SELF + 0xf ALL ANY + +# CPU_IA64_2 Table 11-62 +name:encbr_mispred_detail type:exclusive default:0x0 + 0x0 ALL.ALL_PRED + 0x1 ALL.CORRECT_PRED + 0x2 ALL.WRONG_PATH + 0x3 ALL.WRONG_TARGET + 0x8 OVERSUB.ALL_PRED + 0x9 OVERSUB.CORRECT_PRED + 0xa OVERSUB.CORRECT_PRED + 0xb OVERSUB.WRONGPATH + 0xc ALL2.ALL_PRED + 0xd ALL2.CORRECT_PRED + 0xe ALL2.WRONG_PATH + 0xf ALL2.WRONG_TARGET + +# CPU_IA64_2 Table 11-63 +name:extern_dp_pins_0_to_3 type:bitmask default:0xf + 0x1 PIN0 + 0x2 PIN1 + 0x4 PIN2 + 0x8 PIN3 + 0xf ALL + +# CPU_IA64_2 Table 11-64 +name:extern_dp_pins_4_to_5 type:bitmask default:0x03 + 0x1 PIN4 + 0x2 PIN5 + 0xf ALL + +# CPU_IA64_2 Table 11-65 +name:fe_bubble type:exclusive default:0x0 + 0x0 ALL + 0x1 FEFLUSH + 0x3 GROUP1 + 0x4 GROUP2 + 0x5 IBFULL + 0x6 IMISS + 0x7 TLBMISS + 0x8 FILL_RECIRC + 0x9 BRANCH + 0xa GROUP3 + 0xb ALLBUT_FEFLUSH_BUBBLE + 0xc ALLBUT_IBFULL + 0xd BUBBLE + +# CPU_IA64_2 Table 11-66, 11-69*/ +name:fe_lost type:exclusive default:0x0 + 0x0 ALL + 0x1 FEFLUSH + 0x4 UNREACHED + 0x5 IBFULL + 0x6 IMISS + 0x7 TLBMISS + 0x8 FILL_RECIRC + 0x9 BI + 0xa BRQ + 0xb PLP + 0xc BR_ILOCK + 0xd BUBBLE + +# CPU_IA64_2 Table 11-67, 11-79, 11-86, 11-90, 11-92 b0000 +# FIXME: events using this is commented out in events +#name:this type:exclusive default:0x0 +# 0x0 THIS + +# CPU_IA64_2 Table 11-68 +name:tagged_inst_retired type:exclusive default:0x0 + 0x0 IBRP0_PMB8 + 0x1 IBRP1_PMB9 + 0x2 IBRP2_PMC8 + 0x3 IBRP3_PMC9 + +# CPU_IA64_2 Table 11-73 +name:itlb_misses_fetch type:exclusive default:0x3 + 0x1 L1ITLB + 0x2 L2ITLB + 0x3 ALL + +# CPU_IA64_2 Table 11-74 +name:l1d_read_misses type:exclusive default:0x0 + 0x0 ALL + 0x1 RSE_FILL + +# CPU_IA64_2 Table 11-75 +name:l1i_prefetch_stall type:exclusive default:0x3 + 0x2 FLOW + 0x3 ALL + +# CPU_IA64_2 Table 11-76, 11-91 b0000 +# FIXME: events using this is commented out in events +#name:l2_lines type:exclusive default:0x0 +# 0x0 ANY + +# CPU_IA64_2 Table 11-77 +name:l2_bypass type:exclusive default:0x0 + 0x0 L2_DATA1 + 0x1 L2_DATA2 + 0x2 L3_DATA1 + 0x4 L2_INST1 + 0x5 L2_INST2 + 0x6 L3_INST1 + +# CPU_IA64_2 Table 11-78 +# FIXME: events using this is commented out in events +#name:l2_data_references type:bitmask default:0x3 +# 0x1 L2_DATA_READS +# 0x2 L2_DATA_WRITES +# 0x3 L2_ALL + +# CPU_IA64_2 Table 11-80 +name:l2_force_recirc type:exclusive default:0x0 + 0x0 ANY + 0x1 SMC_HIT + 0x2 L1W + 0x4 TAG_NOTOK + 0x5 TRAN_PREF + 0x6 SNP_OR_L3 + 0x8 VIC_PEND + 0x9 FILL_HIT + 0xa IPF_MISS + 0xb VIC_BUF_FULL + 0xc OZQ_MISS + 0xd SAME_INDEX + 0xe FRC_RECIRC + +# CPU_IA64_2 Table 11-81, 11-83 b1000 +name:recirc_ifetch type:mandatory default:0x8 + 0x8 default:0x0} } }; + +# CPU_IA64_2 Table 11-82 +name:l2_ifet_cancels type:exclusive default:0x0 + 0x0 ANY + 0x2 BYPASS + 0x4 DIDNT_RECIR + 0x5 RECIRC_OVER_SUB + 0x6 ST_FILL_WB + 0x7 DATA_RD + 0x8 PREEMPT + 0xc CHG_PRIO + 0xd IFETCH_BYP + +# CPU_IA64_2 Table 11-84 +name:l2_l3_access_cancel type:exclusive default:0x9 + 0x1 SPEC_L3_BYP + 0x2 FILLD_FULL + 0x5 UC_BLOCKED + 0x6 INV_L3_BYP + 0x8 EBL_REJECT + 0x9 ANY + 0xa DFETCH + 0xb IFETCH + +# CPU_IA64_2 Table 11-85 +name:l2_ops_issued type:exclusive default:0x8 + 0x8 INT_LOAD + 0x9 FP_LOAD + 0xa RMW + 0xb STORE + 0xc NST_NLD + +# CPU_IA64_2 Table 11-87 +name:l2_ozq_cancels0 type:exclusive default:0x0 + 0x0 ANY + 0x1 LATE_SPEC_BYP + 0x2 LATE_RELEASE + 0x3 LATE_ACQUIRE + 0x4 LATE_BYP_EFFRELEASE + +# CPU_IA64_2 Table 11-88 +name:l2_ozq_cancels1 type:exclusive default:0x1 + 0x0 REL + 0x1 BANK_CONF + 0x2 L2D_ST_MAT + 0x4 SYNC + 0x5 HPW_IFETCH_CONF + 0x6 CANC_L2M_ST + 0x7 L1_FILL_CONF + 0x8 ST_FILL_CONF + 0x9 CCV + 0xa SEM + 0xb L2M_ST_MAT + 0xc MFA + 0xd L2A_ST_MAT + 0xe L1DF_L2M + 0xf ECC + +# CPU_IA64_2 Table 11-89 +name:l2_ozq_cancels2 type:exclusive default:0x0 + 0x0 RECIRC_OVER_SUB + 0x1 CANC_L2C_ST + 0x2 L2C_ST_MAT + 0x3 SCRUB + 0x4 ACQ + 0x5 READ_WB_CONF + 0x6 OZ_DATA_CONF + 0x8 L2FILL_ST_CONF + 0x9 DIDNT_RECIRC + 0xa WEIRD + 0xc OVER_SUB + 0xd CANC_L2D_ST + 0xf D_IFET + +# CPU_IA64_2 Table 11-93 +name:l3_reads type:exclusive default:0x3 + 0x1 DINST_FETCH.HIT + 0x2 DINST_FETCH.MISS + 0x3 DINST_FETCH.ALL + 0x5 INST_FETCH.HIT + 0x6 INST_FETCH.MISS + 0x7 INST_FETCH.ALL + 0x9 DATA_READ.HIT + 0xa DATA_READ.MISS + 0xb DATA_READ.ALL + 0xd ALL.HIT + 0xe ALL.MISS + 0xf ALL.ALL + +# CPU_IA64_2 Table 11-94 +name:l3_writes type:exclusive default:0x7 + 0x5 DATA_WRITE.HIT + 0x6 DATA_WRITE.MISS + 0x7 DATA_WRITE.ALL + 0x9 L2_WB.HIT + 0xa L2_WB.MISS + 0xb L2_WB.ALL + 0xd ALL.HIT + 0xe ALL.MISS + 0xf ALL.ALL + +# CPU_IA64_2 Table 11-95 +name:mem_read_current type:exclusive default:0x3 + 0x1 IO + 0x3 ANY + +# CPU_IA64_2 Table 11-96 +name:rse_references_retired type:bitmask default:0x3 + 0x1 LOAD + 0x2 STORE + 0x3 ALL + +# CPU_IA64_2 Table 11-97 bitmask +name:syll_not_dispersed type:bitmask default:0xf + 0x1 EXPL + 0x2 IMPL + 0x4 FE + 0x8 MLI + 0xf ALL + +# CPU_IA64_2 Table 11-98 +name:syll_overcount type:exclusive default:0x3 + 0x1 EXPL + 0x2 IMPL + 0x3 ALL diff --git a/events/mips/24K/events b/events/mips/24K/events new file mode 100644 index 0000000..345d458 --- /dev/null +++ b/events/mips/24K/events @@ -0,0 +1,54 @@ +# +# MIPS 24K +# +# As standard the CPU supports 2 performance counters. Event 0, 1, 11, 22, +# are available on both counters; events 12, 13, 24 - 63 are reserved; +# the remaining are counter-specific. +# +event:0 counters:0,1 um:zero minimum:500 name:CYCLES : Cycles +event:1 counters:0,1 um:zero minimum:500 name:INSTRUCTIONS : Instructions completed +event:11 counters:0,1 um:zero minimum:500 name:DCACHE_MISS : Data cache misses +event:22 counters:0,1 um:zero minimum:500 name:L2_MISSES : L2 cache misses + +# +# Events specific to counter 0 +# +event:2 counters:0 um:zero minimum:500 name:BRANCHES_LAUNCHED : Branch instructions launched (whether completed or mispredicted) +event:3 counters:0 um:zero minimum:500 name:JR_31_LAUNCHED : jr r31 (return) instructions launched (whether completed or mispredicted) +event:4 counters:0 um:zero minimum:500 name:JR_NON_31_LAUNCHED : jr (not r31) issues, which cost the same as a mispredict. +event:5 counters:0 um:zero minimum:500 name:ITLB_ACCESSES : Instruction micro-TLB accesses +event:6 counters:0 um:zero minimum:500 name:DTLB_ACCESSES : Data micro-TLB accesses +event:7 counters:0 um:zero minimum:500 name:JTLB_DATA_ACCESSES : Joint TLB instruction accesses +event:8 counters:0 um:zero minimum:500 name:JTLB_INSTRUCTION_ACCESSES : Joint TLB data (non-instruction) accesses +event:9 counters:0 um:zero minimum:500 name:INSTRUCTION_CACHE_ACCESSES : Instruction cache accesses +event:10 counters:0 um:zero minimum:500 name:DCACHE_ACCESSES : Data cache accesses +event:14 counters:0 um:zero minimum:500 name:INTEGER_INSNS_COMPLETED : Integer instructions completed +event:15 counters:0 um:zero minimum:500 name:LOADS_COMPLETED : Loads completed (including FP) +event:16 counters:0 um:zero minimum:500 name:J_JAL_INSNS_COMPLETED : j/jal instructions completed +event:17 counters:0 um:zero minimum:500 name:NOPS_COMPLETED : no-ops completed, ie instructions writing $0 +event:18 counters:0 um:zero minimum:500 name:STALLS : Stalls +event:19 counters:0 um:zero minimum:500 name:SC_COMPLETED : sc instructions completed +event:20 counters:0 um:zero minimum:500 name:PREFETCH_COMPLETED : Prefetch instructions completed +event:21 counters:0 um:zero minimum:500 name:SCACHE_WRITEBACKS : L2 cache writebacks +event:23 counters:0 um:zero minimum:500 name:EXCEPTIONS_TAKEN : Exceptions taken +event:24 counters:0 um:zero minimum:500 name:CACHE_FIXUPS : ``cache fixup'' events (specific to the 24K family microarchitecture). + +# +# Events specific to counter 1 +# +event:2 counters:1 um:zero minimum:500 name:BRANCH_MISSPREDICTS : Branch mispredictions +event:3 counters:1 um:zero minimum:500 name:JR_31_MISSPREDICTS : jr r31 (return) mispredictions +event:5 counters:1 um:zero minimum:500 name:ITLB_MISSES : Instruction micro-TLB misses +event:6 counters:1 um:zero minimum:500 name:DTLB_MISSES : Data micro-TLB misses +event:7 counters:1 um:zero minimum:500 name:JTLB_INSN_MISSES : Joint TLB instruction misses +event:8 counters:1 um:zero minimum:500 name:JTLB_DATA_MISSES : Joint TLB data (non-instruction) misses +event:9 counters:1 um:zero minimum:500 name:ICACHE_MISSES : Instruction cache misses +event:10 counters:1 um:zero minimum:500 name:DCACHE_WRITEBACKS : Data cache writebacks +event:14 counters:1 um:zero minimum:500 name:FPU_INSNS_NON_LOAD_STORE_COMPLETED : FPU instructions completed (not including loads/stores) +event:15 counters:1 um:zero minimum:500 name:STORES_COMPLETED : Stores completed (including FP) +event:16 counters:1 um:zero minimum:500 name:MIPS16_INSTRUCTIONS_COMPLETED : MIPS16 instructions completed +event:17 counters:1 um:zero minimum:500 name:INTEGER_MUL_DIV_COMPLETED : integer multiply/divide unit instructions completed +event:18 counters:1 um:zero minimum:500 name:REPLAY_TRAPS_NOT_UTLB : ``replay traps'' (other than micro-TLB related) +event:19 counters:1 um:zero minimum:500 name:SC_COMPLETE_BUT_FAILED : sc instructions completed, but store failed (because the link bit had been cleared). +event:20 counters:1 um:zero minimum:500 name:SUPERFLUOUS_INSTRUCTIONS : ``superfluous'' prefetch instructions (data was already in cache). +event:21 counters:1 um:zero minimum:500 name:SCACHE_ACCESSES : L2 cache accesses diff --git a/events/mips/24K/unit_masks b/events/mips/24K/unit_masks new file mode 100644 index 0000000..70d028a --- /dev/null +++ b/events/mips/24K/unit_masks @@ -0,0 +1,5 @@ +# +# MIPS 24K possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/mips/r10000/events b/events/mips/r10000/events new file mode 100644 index 0000000..237cc06 --- /dev/null +++ b/events/mips/r10000/events @@ -0,0 +1,36 @@ +# +# R10000 events +# +# The same event numbers mean different things on the two counters +# +event:0x00 counters:0,1 um:zero minimum:500 name:CYCLES : Cycles +event:0x01 counters:0 um:zero minimum:500 name:INSTRUCTIONS_ISSUED : Instructions issued +event:0x01 counters:1 um:zero minimum:500 name:INSTRUCTIONS_GRADUATED : Instructions graduated +event:0x02 counters:0 um:zero minimum:500 name:LOAD_PREFETC_SYNC_CACHEOP_ISSUED : Load / prefetch / sync / CacheOp issued +event:0x02 counters:1 um:zero minimum:500 name:LOAD_PREFETC_SYNC_CACHEOP_GRADUATED : Load / prefetch / sync / CacheOp graduated +event:0x03 counters:0 um:zero minimum:500 name:STORES_ISSUED : Stores issued +event:0x03 counters:1 um:zero minimum:500 name:STORES_GRADUATED : Stores graduated +event:0x04 counters:0 um:zero minimum:500 name:STORE_COND_ISSUED : Store conditional issued +event:0x04 counters:1 um:zero minimum:500 name:STORE_COND_GRADUATED : Store conditional graduated +event:0x05 counters:0 um:zero minimum:500 name:FAILED_STORE_CONDITIONAL : Failed store conditional +event:0x05 counters:1 um:zero minimum:500 name:FP_INSTRUCTON_GRADUATED : Floating-point instructions graduated +event:0x06 counters:0 um:zero minimum:500 name:BRANCHES_RESOLVED : Branches resolved +event:0x06 counters:1 um:zero minimum:500 name:QUADWORDS_WB_FROM_PRIMARY_DCACHE : Quadwords written back from primary data cache +event:0x07 counters:0 um:zero minimum:500 name:QUADWORDS_WB_FROM_SCACHE : Quadwords written back from secondary cache +event:0x07 counters:1 um:zero minimum:500 name:TLB_REFILL_EXCEPTIONS : TLB refill exceptions +event:0x08 counters:0 um:zero minimum:500 name:CORRECTABLE_ECC_ERRORS_SCACHE : Correctable ECC errors on secondary cache data +event:0x08 counters:1 um:zero minimum:500 name:BRANCHES_MISPREDICTED : Branches mispredicted +event:0x09 counters:0 um:zero minimum:500 name:INSTRUCTION_CACHE_MISSES : Instruction cache misses +event:0x09 counters:1 um:zero minimum:500 name:SCACHE_LOAD_STORE_CACHEOP_OPERATIONS : Secondary cache load / store and cache-ops operations +event:0x0a counters:0 um:zero minimum:500 name:SCACHE_MISSES_INSTRUCTION : Secondary cache misses (instruction) +event:0x0a counters:1 um:zero minimum:500 name:SCACHE_MISSES_DATA : Secondary cache misses (data) +event:0x0b counters:0 um:zero minimum:500 name:SCACHE_WAY_MISPREDICTED_INSN : Secondary cache way mispredicted (instruction) +event:0x0b counters:1 um:zero minimum:500 name:SCACHE_WAY_MISPREDICTED_DATA : Secondary cache way mispredicted (data) +event:0x0c counters:0 um:zero minimum:500 name:EXTERNAL_INTERVENTION_RQ : External intervention requests +event:0x0c counters:1 um:zero minimum:500 name:EXTERNAL_INTERVENTION_RQ_HITS_SCACHE : External intervention request is determined to have hit in secondary cache +event:0x0d counters:0 um:zero minimum:500 name:EXTERNAL_INVALIDATE_RQ : External invalidate requests +event:0x0d counters:1 um:zero minimum:500 name:EXTERNAL_INVALIDATE_RQ_HITS_SCACHE : External invalidate request is determined to have hit in secondary cache +event:0x0e counters:0 um:zero minimum:500 name:FUNCTIONAL_UNIT_COMPLETION_CYCLES : Functional unit completion cycles +event:0x0e counters:1 um:zero minimum:500 name:STORES_OR_STORE_PREF_TO_CLEANEXCLUSIVE_SCACHE_BLOCKS : Stores or prefetches with store hint to CleanExclusive secondary cache blocks +event:0x0f counters:0 um:zero minimum:500 name:INSTRUCTION_GRADUATED : Instructions graduated +event:0x0f counters:1 um:zero minimum:500 name:STORES_OR_STORE_PREF_TO_SHD_SCACHE_BLOCKS : Stores or prefetches with store hint to Shared secondary cache blocks diff --git a/events/mips/r10000/unit_masks b/events/mips/r10000/unit_masks new file mode 100644 index 0000000..fab7d83 --- /dev/null +++ b/events/mips/r10000/unit_masks @@ -0,0 +1,5 @@ +# +# MIPS R10000 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/mips/r12000/events b/events/mips/r12000/events new file mode 100644 index 0000000..4c8530a --- /dev/null +++ b/events/mips/r12000/events @@ -0,0 +1,35 @@ +# +# R12000 events +# +event:0 counters:0,1,2,3 um:zero minimum:500 name:CYCLES : Cycles +event:1 counters:0,1,2,3 um:zero minimum:500 name:DECODED_INSTRUCTIONS : Decoded instructions +event:2 counters:0,1,2,3 um:zero minimum:500 name:DECODED_LOADS : Decoded loads +event:3 counters:0,1,2,3 um:zero minimum:500 name:DECODED_STORES : Decoded stores +event:4 counters:0,1,2,3 um:zero minimum:500 name:MISS_TABLE_OCCUPANCY : Miss Handling Table Occupancy +event:5 counters:0,1,2,3 um:zero minimum:500 name:FAILED_STORE_CONDITIONAL : Failed store conditional +event:6 counters:0,1,2,3 um:zero minimum:500 name:RESOLVED_BRANCH_CONDITIONAL : Resolved conditional branches +event:7 counters:0,1,2,3 um:zero minimum:500 name:QUADWORRDS_WRITEBACK_FROM_SC : Quadwords written back from secondary cache +event:8 counters:0,1,2,3 um:zero minimum:500 name:CORRECTABLE_ECC_ERRORS : Correctable ECC errors on secondary cache data +event:9 counters:0,1,2,3 um:zero minimum:500 name:ICACHE_MISSES : Instruction cache misses +event:10 counters:0,1,2,3 um:zero minimum:500 name:INSTRUCTION_SECONDARY_CACHE_MISSES : Secondary cache misses (instruction) +event:11 counters:0,1,2,3 um:zero minimum:500 name:SECONDARY_CACHE_WAY_MISSPREDICTED : Secondary cache way mispredicted (instruction) +event:12 counters:0,1,2,3 um:zero minimum:500 name:INTERVENTION_REQUESTS : External intervention requests +event:13 counters:0,1,2,3 um:zero minimum:500 name:EXTERNAL_REQUESTS : External invalidate requests + +event:15 counters:0,1,2,3 um:zero minimum:500 name:INSTRUCTIONS_GRADUATED : Instructions graduated +event:16 counters:0,1,2,3 um:zero minimum:500 name:PREFETCH_INSTRUCTIONS_EXECUTED : Executed prefetch instructions +event:17 counters:0,1,2,3 um:zero minimum:500 name:PREFETCH_MISSES_IN_DCACHE : Primary data cache misses by prefetch instructions +event:18 counters:0,1,2,3 um:zero minimum:500 name:GRADUATED_LOADS : Graduated loads +event:19 counters:0,1,2,3 um:zero minimum:500 name:GRADUATED_STORES : Graduated stores +event:20 counters:0,1,2,3 um:zero minimum:500 name:GRADUATED_STORE_CONDITIONALS : Graduated store conditionals +event:21 counters:0,1,2,3 um:zero minimum:500 name:GRADUATED_FP_INSTRUCTIONS : Graduated floating point instructions +event:22 counters:0,1,2,3 um:zero minimum:500 name:QUADWORDS : Quadwords written back from primary data cache +event:23 counters:0,1,2,3 um:zero minimum:500 name:TLB_MISSES : TLB misses +event:24 counters:0,1,2,3 um:zero minimum:500 name:MISPREDICTED_BRANCHES : Mispredicted branches +event:25 counters:0,1,2,3 um:zero minimum:500 name:DCACHE_MISSES : Primary data cache misses +event:26 counters:0,1,2,3 um:zero minimum:500 name:SCACHE_MISSES : Secondary cache misses (data) +event:27 counters:0,1,2,3 um:zero minimum:500 name:SCACHE_WAY_MISPREDICTION : Misprediction from scache way prediction table (data) +event:28 counters:0,1,2,3 um:zero minimum:500 name:STATE_OF_SCACHE_INTERVENTION_HIT : State of external intervention hit in secondary cache +event:29 counters:0,1,2,3 um:zero minimum:500 name:STATE_OF_EXTERNAL_INVALIDATION_HIT : State of external invalidation hits in secondary cache +event:30 counters:0,1,2,3 um:zero minimum:500 name:STORE_PREFETCH_EXCLUSIVE_TO_CLEAN_SC_BLOCK : Store/prefetch exclusive to clean block in secondary cache +event:31 counters:0,1,2,3 um:zero minimum:500 name:STORE_PREFETCH_EXCLUSIVE_SHARED_SC_BLOCK : Store/prefetch exclusive to shared block in secondary diff --git a/events/mips/r12000/unit_masks b/events/mips/r12000/unit_masks new file mode 100644 index 0000000..20c8250 --- /dev/null +++ b/events/mips/r12000/unit_masks @@ -0,0 +1,7 @@ +# +# MIPS R12000 possible unit masks +# +# We don't support the R12000 conditional count feature yet. +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/mips/rm7000/events b/events/mips/rm7000/events new file mode 100644 index 0000000..bfcde7a --- /dev/null +++ b/events/mips/rm7000/events @@ -0,0 +1,34 @@ +# +# RM7000 events +# +event:0x00 counters:0,1 um:zero minimum:500 name:CYCLES : Clock cycles +event:0x01 counters:0,1 um:zero minimum:500 name:INSTRUCTIONS_ISSUED : Total instructions issued +event:0x02 counters:0,1 um:zero minimum:500 name:FP_INSTRUCTIONS_ISSUED : Floating-point instructions issued +event:0x03 counters:0,1 um:zero minimum:500 name:INTEGER_INSTRUCTIONS_ISSUED : Integer instructions issued +event:0x04 counters:0,1 um:zero minimum:500 name:LOAD_INSTRUCTIONS_ISSUED : Load instructions issued +event:0x05 counters:0,1 um:zero minimum:500 name:STORE_INSTRUCTIONS_ISSUED : Store instructions issued +event:0x06 counters:0,1 um:zero minimum:500 name:DUAL_ISSUED_PAIRS : Dual issued pairs +event:0x07 counters:0,1 um:zero minimum:500 name:BRANCH_PREFETCHES : Branch prefetches +event:0x08 counters:0,1 um:zero minimum:500 name:EXTERNAL_CACHE_MISSES : External Cache Misses +event:0x09 counters:0,1 um:zero minimum:500 name:STALL_CYCLES : Stall cycles +event:0x0a counters:0,1 um:zero minimum:500 name:SCACHE_MISSES : Secondary cache misses +event:0x0b counters:0,1 um:zero minimum:500 name:ICACHE_MISSES : Instruction cache misses +event:0x0c counters:0,1 um:zero minimum:500 name:DCACHE_MISSES : Data cache misses +event:0x0d counters:0,1 um:zero minimum:500 name:DTLB_MISSES : Data TLB misses +event:0x0e counters:0,1 um:zero minimum:500 name:ITLB_MISSES : Instruction TLB misses +event:0x0f counters:0,1 um:zero minimum:500 name:JTLB_INSTRUCTION_MISSES : Joint TLB instruction misses +event:0x10 counters:0,1 um:zero minimum:500 name:JTLB_DATA_MISSES : Joint TLB data misses +event:0x11 counters:0,1 um:zero minimum:500 name:BRANCHES_TAKEN : Branches taken +event:0x12 counters:0,1 um:zero minimum:500 name:BRANCHES_ISSUED : Branches issued +event:0x13 counters:0,1 um:zero minimum:500 name:SCACHE_WRITEBACKS : Secondary cache writebacks +event:0x14 counters:0,1 um:zero minimum:500 name:PCACHE_WRITEBACKS : Primary cache writebacks +event:0x15 counters:0,1 um:zero minimum:500 name:DCACHE_MISS_STALL_CYCLES : Dcache miss stall cycles (cycles where both cache miss tokens taken and a third try is requested) +event:0x16 counters:0,1 um:zero minimum:500 name:CACHE_MISSES : Cache misses +event:0x17 counters:0,1 um:zero minimum:500 name:FP_EXCEPTION_STALL_CYCLES : FP possible exception cycles +event:0x18 counters:0,1 um:zero minimum:500 name:SLIP_CYCLES_DUE_MULTIPLIER_BUSY : Slip Cycles due to multiplier busy +event:0x19 counters:0,1 um:zero minimum:500 name:COP0_SLIP_CYCLES : Coprocessor 0 slip cycles +event:0x1a counters:0,1 um:zero minimum:500 name:SLIP_CYCLES_PENDING_NON_BLKING_LOAD : Slip cycles due to pending non-blocking loads +event:0x1c counters:0,1 um:zero minimum:500 name:WRITE_BUFFER_FULL_STALL_CYCLES : Write buffer full stall cycles +event:0x1d counters:0,1 um:zero minimum:500 name:CACHE_INSTRUCTION_STALL_CYCLES : Cache instruction stall cycles +event:0x1e counters:0,1 um:zero minimum:500 name:MULTIPLIER_STALL_CYCLES : Multiplier stall cycles +event:0x1f counters:0,1 um:zero minimum:500 name:STALL_CYCLES_PENDING_NON_BLKING_LOAD : Stall cycles due to pending non-blocking loads - stall start of exception diff --git a/events/mips/rm7000/unit_masks b/events/mips/rm7000/unit_masks new file mode 100644 index 0000000..cb11b7c --- /dev/null +++ b/events/mips/rm7000/unit_masks @@ -0,0 +1,5 @@ +# +# MIPS RM7000 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/mips/rm9000/events b/events/mips/rm9000/events new file mode 100644 index 0000000..71d8491 --- /dev/null +++ b/events/mips/rm9000/events @@ -0,0 +1,32 @@ +# +# RM9000 events +# +event:0x00 counters:0,1 um:zero minimum:500 name:CYCLES : Processor clock cycles +event:0x01 counters:0,1 um:zero minimum:500 name:INSTRUCTIONS_ISSUED : Instructions issued +event:0x02 counters:0,1 um:zero minimum:500 name:FP_INSTRUCTIONS_ISSUED : Floating-point instructions issued +event:0x03 counters:0,1 um:zero minimum:500 name:INT_INSTRUCTIONS_ISSUED : Integer instructions issued +event:0x04 counters:0,1 um:zero minimum:500 name:LOAD_INSTRUCTIONS_ISSUED : Load instructions issued +event:0x05 counters:0,1 um:zero minimum:500 name:STORE_INSTRUCTIONS_ISSUED : Store instructions issued +event:0x06 counters:0,1 um:zero minimum:500 name:INSTRUCTIONS_DUAL_ISSUED : Dual-issued instruction pairs +event:0x07 counters:0,1 um:zero minimum:500 name:BRANCH_MISSPREDICTS : Branch mispredictions +event:0x09 counters:0,1 um:zero minimum:500 name:STALL_CYCLES : Stall cycles +event:0x0a counters:0,1 um:zero minimum:500 name:L2_CACHE_MISSES : L2 cache misses +event:0x0b counters:0,1 um:zero minimum:500 name:ICACHE_MISSES : Icache misses +event:0x0c counters:0,1 um:zero minimum:500 name:DCACHE_MISSES : Dcache misses +event:0x0d counters:0,1 um:zero minimum:500 name:DTLB_MISSES : Data TLB misses +event:0x0e counters:0,1 um:zero minimum:500 name:ITLB_MISSES : Instruction TLB misses +event:0x0f counters:0,1 um:zero minimum:500 name:JTLB_INSTRUCTION_MISSES : Joint TLB instruction misses +event:0x10 counters:0,1 um:zero minimum:500 name:JTLB_DATA_MISSES : Joint TLB data misses +event:0x11 counters:0,1 um:zero minimum:500 name:BRANCHES_TAKEN : Branches taken +event:0x12 counters:0,1 um:zero minimum:500 name:BRANCHES_ISSUED : Branch instructions issued +event:0x13 counters:0,1 um:zero minimum:500 name:L2_WRITEBACKS : L2 cache writebacks +event:0x14 counters:0,1 um:zero minimum:500 name:DCACHE_WRITEBACKS : Dcache writebacks +event:0x15 counters:0,1 um:zero minimum:500 name:DCACHE_MISS_STALL_CYCLES : Dcache-miss stall cycles +event:0x16 counters:0,1 um:zero minimum:500 name:CACHE_REMISSES : Cache remisses +event:0x17 counters:0,1 um:zero minimum:500 name:FP_POSSIBLE_EXCEPTION_CYCLES : Floating-point possible exception cycles +event:0x18 counters:0,1 um:zero minimum:500 name:MULTIPLIER_BUSY_SLIP_CYCLES : Slip cycles due to busy multiplier +event:0x19 counters:0,1 um:zero minimum:500 name:COP0_SLIP_CYCLES : Co-processor 0 slip cycles +event:0x1a counters:0,1 um:zero minimum:500 name:NONBLOCKING_LOAD_SLIP_CYCLES : Slip cycles due to pending non-blocking loads +event:0x1b counters:0,1 um:zero minimum:500 name:WRITE_BUFFER_FULL_STALL_CYCLES : Stall cycles due to a full write buffer +event:0x1c counters:0,1 um:zero minimum:500 name:CACHE_INSN_STALL_CYCLES : Stall cycles due to cache instructions +event:0x1e counters:0,1 um:zero minimum:500 name:NONBLOCKING_LOAD_PENDING_EXCEPTION_STALL_CYCLES : Stall cycles due to pending non-blocking loads - stall start of exception diff --git a/events/mips/rm9000/unit_masks b/events/mips/rm9000/unit_masks new file mode 100644 index 0000000..63ba9da --- /dev/null +++ b/events/mips/rm9000/unit_masks @@ -0,0 +1,5 @@ +# +# MIPS RM9000 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/mips/sb1/events b/events/mips/sb1/events new file mode 100644 index 0000000..51ee013 --- /dev/null +++ b/events/mips/sb1/events @@ -0,0 +1,73 @@ +# +# Sibyte SB1 events +# + +event:16 counters:0,1,2,3 um:zero minimum:500 name:CYCLES :Elapsed cycles + +# Execution Counts and Instruction Slotting +event:40 counters:1,2,3 um:zero minimum:500 name:ISSUE_L0 :Issue to L0 +event:41 counters:1,2,3 um:zero minimum:500 name:ISSUE_L1 :Issue to L0 +event:42 counters:1,2,3 um:zero minimum:500 name:ISSUE_E0 :Issue to E0 +event:43 counters:1,2,3 um:zero minimum:500 name:ISSUE_E1 :Issue to E1 + +# Explaining Sub-Peak Performance: Pipeline Traps +event:47 counters:1,2,3 um:zero minimum:500 name:BRANCH_MISSPREDICTS :Branch mispredicts +event:29 counters:0,1,2,3 um:zero minimum:500 name:MBOX_REPLAY :MBOX replay +event:28 counters:0,1,2,3 um:zero minimum:500 name:DCFIFO :DCFIFO +event:30 counters:0,1,2,3 um:zero minimum:500 name:DATA_DEPENDENCY_REPLAY :Data dependency replay +event:27 counters:0,1,2,3 um:zero minimum:500 name:DCACHE_FILL_REPLAY :Dcache fill replay +event:31 counters:0,1,2,3 um:zero minimum:500 name:ANY_REPLAY :Any replay except mispredict + + +# Explaining Sub-Peak Performance: static and dynamic stalls +event:32 counters:1,2,3 um:zero minimum:500 name:MAX_ISSUE :Max issue +event:33 counters:1,2,3 um:zero minimum:500 name:NO_VALID_INSN :No valid instr to issue +event:34 counters:1,2,3 um:zero minimum:500 name:CONSUMER_WAITING_FOR_LOAD :load consumer waiting for dfill +event:35 counters:1,2,3 um:zero minimum:500 name:NOT_DATA_READY :Not data ready +event:36 counters:1,2,3 um:zero minimum:500 name:RESOURCE_CONSTRAINT :Resource (L0/1 E0/1) constraint +event:37 counters:1,2,3 um:zero minimum:500 name:ISSUE_CONFLICT_DUE_IMISS :issue conflict due to imiss using LS0 +event:38 counters:1,2,3 um:zero minimum:500 name:ISSUE_CONFLICT_DUE_DFILL :issue conflict due to dfill using LS0/1 + +# Grouping Co-issued Instructions +event:39 counters:1,2,3 um:zero minimum:500 name:INSN_STAGE4 :One or more instructions survives stage 4 + +# Branch information +event:44 counters:1,2,3 um:zero minimum:500 name:BRANCH_STAGE4 :Branch survived stage 4 +event:45 counters:1,2,3 um:zero minimum:500 name:BRANCH_REALLY_TAKEN :Conditional branch was really taken +event:46 counters:1,2,3 um:zero minimum:500 name:BRANCH_PREDICTED_TAKEN :Predicted taken conditional branch + +# Cache access +event:1 counters:1,2,3 um:zero minimum:500 name:RQ_LENGTH :Read queue length +event:2 counters:1,2,3 um:zero minimum:500 name:UNCACHED_RQ_LENGTH :Number of valid uncached entries in read queue +event:3 counters:1,2,3 um:zero minimum:500 name:DCACHE_READ_MISS :Dcache read results in a miss + +event:10 counters:1,2,3 um:zero minimum:500 name:DCACHE_FILLED_SHD_NONC_EXC :Dcache is filled (shared, nonc, exclusive) +event:11 counters:1,2,3 um:zero minimum:500 name:DCACHE_FILL_SHARED_LINE :Dcache is filled with shared line +event:12 counters:1,2,3 um:zero minimum:500 name:DCACHE_READ_MISS :Dcache read results in a miss +event:15 counters:1,2,3 um:zero minimum:500 name:WRITEBACK_RETURNS :Number of instruction returns +event:13 counters:1,2,3 um:zero minimum:500 name:VICTIM_WRITEBACK :A writeback occurs due to replacement +event:7 counters:1,2,3 um:zero minimum:500 name:UPGRADE_SHARED_TO_EXCLUSIVE :A line is upgraded from shared to exclusive +event:6 counters:1,2,3 um:zero minimum:500 name:LD_ST_HITS_PREFETCH_IN_QUEUE :Load/store hits prefetch in read queue +event:5 counters:1,2,3 um:zero minimum:500 name:PREFETCH_HITS_CACHE_OR_READ_Q :Prefetch hits in cache or read queue +event:4 counters:1,2,3 um:zero minimum:500 name:READ_HITS_READ_Q :Read hits in read queue + +# BIU + +event:17 counters:1,2,3 um:zero minimum:500 name:BIU_STALLS_ON_ZB_ADDR_BUS :BIU stalls on ZB addr bus +event:18 counters:1,2,3 um:zero minimum:500 name:BIU_STALLS_ON_ZB_DATA_BUS :BIU stalls on ZB data bus +event:19 counters:1,2,3 um:zero minimum:500 name:READ_RQ_SENT_TO_ABUS :Requests sent to ZB Abus +event:20 counters:1,2,3 um:zero minimum:500 name:READ_RQ_NOPS_SENT_TO_ABUS :Read requests and NOPs sent to ZB Abus +event:21 counters:1,2,3 um:zero minimum:500 name:READ_RQ_SENT_TO_ABUS :Read requests sent to ZB Abus +event:14 counters:1,2,3 um:zero minimum:500 name:MBOX_RQ_WHEN_BIU_BUSY :MBOX requests to BIU when BIU busy + +# Multiprocessor +event:26 counters:1,2,3 um:zero minimum:500 name:STORE_COND_FAILED :Failed store conditional +event:22 counters:1,2,3 um:zero minimum:500 name:SNOOP_RQ_HITS :Snoop request hits anywhere +event:23 counters:1,2,3 um:zero minimum:500 name:SNOOP_ADDR_Q_FULL :Snoop address queue is full +event:24 counters:1,2,3 um:zero minimum:500 name:R_RESP_OTHER_CORE :Read response comes from the other core +event:25 counters:1,2,3 um:zero minimum:500 name:R_RESP_OTHER_CORE_D_MOD :Read response comes from the other core with D_MOD set + +# Instruction Counts +event:8 counters:1,2,3 um:zero minimum:500 name:LOAD_SURVIVED_STAGE4 :Load survived stage 4 +event:9 counters:1,2,3 um:zero minimum:500 name:STORE_SURVIVED_STAGE4 :Store survived stage 4 +event:0 counters:1,2,3 um:zero minimum:500 name:INSN_SURVIVED_STAGE7 :Instruction survived stage 7 diff --git a/events/mips/sb1/unit_masks b/events/mips/sb1/unit_masks new file mode 100644 index 0000000..7fd41fb --- /dev/null +++ b/events/mips/sb1/unit_masks @@ -0,0 +1,5 @@ +# +# Sibyte SB1 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/mips/vr5432/events b/events/mips/vr5432/events new file mode 100644 index 0000000..328585d --- /dev/null +++ b/events/mips/vr5432/events @@ -0,0 +1,14 @@ +# +# VR5432 events +# +event:0 counters:0,1 um:zero minimum:500 name:CYCLES : Processor cycles (PClock) +event:1 counters:0,1 um:zero minimum:500 name:INSTRUCTIONS_EXECUTED : (Instructions executed)/2 and truncated +event:2 counters:0,1 um:zero minimum:500 name:LOAD_PREF_CACHE_INSTRUCTIONS : Load, prefetch/CacheOps execution (no sync) +event:3 counters:0,1 um:zero minimum:500 name:STORES : Store execution +event:4 counters:0,1 um:zero minimum:500 name:BRANCHES : Branch execution (no jumps or jump registers) +event:5 counters:0,1 um:zero minimum:500 name:FP_INSTRUCTIONS : (FP instruction execution) / 2 and truncated excluding cp1 loads and stores +event:6 counters:0,1 um:zero minimum:500 name:DOUBLEWORDS_FLUSHED : Doublewords flushed to main memory (no uncached stores) +event:7 counters:0,1 um:zero minimum:500 name:JTLB_REFILLS : JTLB refills +event:8 counters:0,1 um:zero minimum:500 name:DCACHE_MISSES : Data cache misses (no I-cache misses) +event:9 counters:0,1 um:zero minimum:500 name:ICACHE_MISSES : Instruction cache misses (no D-cache misses) +event:10 counters:0,1 um:zero minimum:500 name:BRANCHES_MISPREDICTED : Branches mispredicted diff --git a/events/mips/vr5432/unit_masks b/events/mips/vr5432/unit_masks new file mode 100644 index 0000000..2239d12 --- /dev/null +++ b/events/mips/vr5432/unit_masks @@ -0,0 +1,5 @@ +# +# MIPS VR5432 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/mips/vr5500/events b/events/mips/vr5500/events new file mode 100644 index 0000000..688f604 --- /dev/null +++ b/events/mips/vr5500/events @@ -0,0 +1,16 @@ +# +# VR5500, VR5532 and VR7701 events +# +# Very similar to what the VR5432 provides. +# +event:0 counters:0,1 um:zero minimum:500 name:CYCLES : Processor clock cycles +event:1 counters:0,1 um:zero minimum:500 name:INSTRUCTIONS_EXECUTED : Instructions executed +event:2 counters:0,1 um:zero minimum:500 name:LOAD_PREF_CACHE_INSTRUCTIONS : Execution of load/prefetch/cache instruction +event:3 counters:0,1 um:zero minimum:500 name:STORES : Execution of store instruction +event:4 counters:0,1 um:zero minimum:500 name:BRANCHES : Execution of branch instruction +event:5 counters:0,1 um:zero minimum:500 name:FP_INSTRUCTIONS : Execution of floating-point instruction +event:6 counters:0,1 um:zero minimum:500 name:DOUBLEWORDS_FLUSHED : Doubleword flush to main memory +event:7 counters:0,1 um:zero minimum:500 name:JTLB_REFILLS : TLB refill +event:8 counters:0,1 um:zero minimum:500 name:DCACHE_MISSES : Data cache miss +event:9 counters:0,1 um:zero minimum:500 name:ICACHE_MISSES : Instruction cache miss +event:10 counters:0,1 um:zero minimum:500 name:BRANCHES_MISPREDICTED : Branch prediction miss diff --git a/events/mips/vr5500/unit_masks b/events/mips/vr5500/unit_masks new file mode 100644 index 0000000..ef69a7a --- /dev/null +++ b/events/mips/vr5500/unit_masks @@ -0,0 +1,5 @@ +# +# MIPS VR5500 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/ppc/e500/events b/events/ppc/e500/events new file mode 100644 index 0000000..21d3d7c --- /dev/null +++ b/events/ppc/e500/events @@ -0,0 +1,83 @@ +# e500 Events +# +event:0x1 counters:0,1,2,3 um:zero minimum:3000 name:CPU_CLK : Cycles +event:0x2 counters:0,1,2,3 um:zero minimum:3000 name:COMPLETED_INSNS : Completed Instructions (0, 1, or 2 per cycle) +event:0x3 counters:0,1,2,3 um:zero minimum:500 name:COMPLETED_OPS : Completed Micro-ops (counts 2 for load/store w/update) +event:0x4 counters:0,1,2,3 um:zero minimum:500 name:INSTRUCTION_FETCHES : Instruction fetches +event:0x5 counters:0,1,2,3 um:zero minimum:500 name:DECODED_OPS : Micro-ops decoded +event:0x8 counters:0,1,2,3 um:zero minimum:500 name:COMPLETED_BRANCHES : Branch Instructions completed +event:0x9 counters:0,1,2,3 um:zero minimum:500 name:COMPLETED_LOAD_OPS : Load micro-ops completed +event:0xa counters:0,1,2,3 um:zero minimum:500 name:COMPLETED_STORE_OPS : Store micro-ops completed +event:0xb counters:0,1,2,3 um:zero minimum:500 name:COMPLETION_REDIRECTS : Number of completion buffer redirects +event:0xc counters:0,1,2,3 um:zero minimum:500 name:BRANCHES_FINISHED : Branches finished +event:0xd counters:0,1,2,3 um:zero minimum:500 name:TAKEN_BRANCHES_FINISHED : Taken branches finished +event:0xe counters:0,1,2,3 um:zero minimum:500 name:BIFFED_BRANCHES_FINISHED : Biffed branches finished +event:0xf counters:0,1,2,3 um:zero minimum:500 name:BRANCHES_MISPREDICTED : Branch instructions mispredicted due to direction, target, or IAB prediction +event:0x10 counters:0,1,2,3 um:zero minimum:500 name:BRANCHES_MISPREDICTED_DIRECTION : Branches mispredicted due to direction prediction +event:0x11 counters:0,1,2,3 um:zero minimum:500 name:BTB_HITS : Branches that hit in the BTB, or missed but are not taken +event:0x12 counters:0,1,2,3 um:zero minimum:500 name:DECODE_STALLED : Cycles the instruction buffer was not empty, but 0 instructions decoded +event:0x13 counters:0,1,2,3 um:zero minimum:500 name:ISSUE_STALLED : Cycles the issue buffer is not empty but 0 instructions issued +event:0x14 counters:0,1,2,3 um:zero minimum:500 name:BRANCH_ISSUE_STALLED : Cycles the branch buffer is not empty but 0 instructions issued +event:0x15 counters:0,1,2,3 um:zero minimum:500 name:SRS0_SCHEDULE_STALLED : Cycles SRS0 is not empty but 0 instructions scheduled +event:0x16 counters:0,1,2,3 um:zero minimum:500 name:SRS1_SCHEDULE_STALLED : Cycles SRS1 is not empty but 0 instructions scheduled +event:0x17 counters:0,1,2,3 um:zero minimum:500 name:VRS_SCHEDULE_STALLED : Cycles VRS is not empty but 0 instructions scheduled +event:0x18 counters:0,1,2,3 um:zero minimum:500 name:LRS_SCHEDULE_STALLED : Cycles LRS is not empty but 0 instructions scheduled +event:0x19 counters:0,1,2,3 um:zero minimum:500 name:BRS_SCHEDULE_STALLED : Cycles BRS is not empty but 0 instructions scheduled Load/Store, Data Cache, and dLFB Events +event:0x1a counters:0,1,2,3 um:zero minimum:500 name:TOTAL_TRANSLATED : Total Ldst microops translated. +event:0x1b counters:0,1,2,3 um:zero minimum:500 name:LOADS_TRANSLATED : Number of cacheable L* or EVL* microops translated. (This includes microops from load-multiple, load-update, and load-context instructions.) +event:0x1c counters:0,1,2,3 um:zero minimum:500 name:STORES_TRANSLATED : Number of cacheable ST* or EVST* microops translated. (This includes microops from store-multiple, store-update, and save-context instructions.) +event:0x1d counters:0,1,2,3 um:zero minimum:500 name:TOUCHES_TRANSLATED : Number of cacheable DCBT and DCBTST instructions translated (L1 only) (DoesnÕt count touches that are converted to nops i.e. exceptions, noncacheable, hid0[nopti] bit is set.) +event:0x1e counters:0,1,2,3 um:zero minimum:500 name:CACHEOPS_TRANSLATED : Number of dcba, dcbf, dcbst, and dcbz instructions translated (e500 traps on dcbi) +event:0x1f counters:0,1,2,3 um:zero minimum:500 name:CACHEINHIBITED_ACCESSES_TRANSLATED : Number of cache inhibited accesses translated +event:0x20 counters:0,1,2,3 um:zero minimum:500 name:GUARDED_LOADS_TRANSLATED : Number of guarded loads translated +event:0x21 counters:0,1,2,3 um:zero minimum:500 name:WRITETHROUGH_STORES_TRANSLATED : Number of write-through stores translated +event:0x22 counters:0,1,2,3 um:zero minimum:500 name:MISALIGNED_ACCESSES_TRANSLATED : Number of misaligned load or store accesses translated. +event:0x23 counters:0,1,2,3 um:zero minimum:500 name:TOTAL_ALLOCATED_DLFB : Total allocated to dLFB +event:0x24 counters:0,1,2,3 um:zero minimum:500 name:LOADS_TRANSLATED_ALLOCATED_DLFB : Loads translated and allocated to dLFB (Applies to same class of instructions as loads translated.) +event:0x25 counters:0,1,2,3 um:zero minimum:500 name:STORES_COMPLETED_ALLOCATED_DLFB : Stores completed and allocated to dLFB (Applies to same class of instructions as stores translated.) +event:0x26 counters:0,1,2,3 um:zero minimum:500 name:TOUCHES_TRANSLATED_ALLOCATED_DLFB : Touches translated and allocated to dLFB (Applies to same class of instructions as touches translated.) +event:0x27 counters:0,1,2,3 um:zero minimum:500 name:STORES_COMPLETED : Number of cacheable ST* or EVST* microops completed. (Applies to the same class of instructions as stores translated.) +event:0x28 counters:0,1,2,3 um:zero minimum:500 name:DL1_LOCKS : Number of cache lines locked in the dL1. (Counts a lock even if an overlock condition is encountered.) +event:0x29 counters:0,1,2,3 um:zero minimum:500 name:DL1_RELOADS : This is historically used to determine dcache miss rate (along with loads/stores completed). This counts dL1 reloads for any reason. +event:0x2a counters:0,1,2,3 um:zero minimum:500 name:DL1_CASTOUTS : dL1 castouts. Does not count castouts due to DCBF. +event:0x2b counters:0,1,2,3 um:zero minimum:500 name:DETECTED_REPLAYS : Times detected replay condition - Load miss with dLFB full. +event:0x2c counters:0,1,2,3 um:zero minimum:500 name:LOAD_MISS_QUEUE_FULL_REPLAYS : Load miss with load queue full. +event:0x2d counters:0,1,2,3 um:zero minimum:500 name:LOAD_GUARDED_MISS_NOT_LAST_REPLAYS : Load guarded miss when the load is not yet at the bottom of the completion buffer. +event:0x2e counters:0,1,2,3 um:zero minimum:500 name:STORE_TRANSLATED_QUEUE_FULL_REPLAYS : Translate a store when the StQ is full. +event:0x2f counters:0,1,2,3 um:zero minimum:500 name:ADDRESS_COLLISION_REPLAYS : Address collision. +event:0x30 counters:0,1,2,3 um:zero minimum:500 name:DMMU_MISS_REPLAYS : DMMU_MISS_REPLAYS : DMMU miss. +event:0x31 counters:0,1,2,3 um:zero minimum:500 name:DMMU_BUSY_REPLAYS : DMMU_BUSY_REPLAYS : DMMU busy. +event:0x32 counters:0,1,2,3 um:zero minimum:500 name:SECOND_PART_MISALIGNED_AFTER_MISS_REPLAYS : Second part of misaligned access when first part missed in cache. +event:0x33 counters:0,1,2,3 um:zero minimum:500 name:LOAD_MISS_DLFB_FULL_CYCLES : Cycles stalled on replay condition - Load miss with dLFB full. +event:0x34 counters:0,1,2,3 um:zero minimum:500 name:LOAD_MISS_QUEUE_FULL_CYCLES : Cycles stalled on replay condition - Load miss with load queue full. +event:0x35 counters:0,1,2,3 um:zero minimum:500 name:LOAD_GUARDED_MISS_NOT_LAST_CYCLES : Cycles stalled on replay condition - Load guarded miss when the load is not yet at the bottom of the completion buffer. +event:0x36 counters:0,1,2,3 um:zero minimum:500 name:STORE_TRANSLATED_QUEUE_FULL_CYCLES : Cycles stalled on replay condition - Translate a store when the StQ is full. +event:0x37 counters:0,1,2,3 um:zero minimum:500 name:ADDRESS_COLLISION_CYCLES : Cycles stalled on replay condition - Address collision. +event:0x38 counters:0,1,2,3 um:zero minimum:500 name:DMMU_MISS_CYCLES : Cycles stalled on replay condition - DMMU miss. +event:0x39 counters:0,1,2,3 um:zero minimum:500 name:DMMU_BUSY_CYCLES : Cycles stalled on replay condition - DMMU busy. +event:0x3a counters:0,1,2,3 um:zero minimum:500 name:SECOND_PART_MISALIGNED_AFTER_MISS_CYCLES : Cycles stalled on replay condition - Second part of misaligned access when first part missed in cache. +event:0x3b counters:0,1,2,3 um:zero minimum:500 name:IL1_LOCKS : Number of cache lines locked in the iL1. (Counts a lock even if an overlock condition is encountered.) +event:0x3c counters:0,1,2,3 um:zero minimum:500 name:IL1_FETCH_RELOADS : This is historically used to determine icache miss rate (along with instructions completed) Reloads due to demand fetch. +event:0x3d counters:0,1,2,3 um:zero minimum:500 name:FETCHES : Counts the number of fetches that write at least one instruction to the instruction buffer. (With instruction fetched, can used to compute instructions-per-fetch) +event:0x3e counters:0,1,2,3 um:zero minimum:500 name:IMMU_TLB4K_RELOADS : iMMU TLB4K reloads +event:0x3f counters:0,1,2,3 um:zero minimum:500 name:IMMU_VSP_RELOADS : iMMU VSP reloads +event:0x40 counters:0,1,2,3 um:zero minimum:500 name:DMMU_TLB4K_RELOADS : dMMU TLB4K reloads +event:0x41 counters:0,1,2,3 um:zero minimum:500 name:DMMU_VSP_RELOADS : dMMU VSP reloads +event:0x42 counters:0,1,2,3 um:zero minimum:500 name:L2MMU_MISSES : Counts iTLB/dTLB error interrupt +event:0x43 counters:0,1,2,3 um:zero minimum:500 name:BIU_MASTER_REQUESTS : Number of master transactions. (Number of master TSs.) +event:0x44 counters:0,1,2,3 um:zero minimum:500 name:BIU_MASTER_I_REQUESTS : Number of master I-Side transactions. (Number of master I-Side TSs.) +event:0x45 counters:0,1,2,3 um:zero minimum:500 name:BIU_MASTER_D_REQUESTS : Number of master D-Side transactions. (Number of master D-Side TSs.) +event:0x46 counters:0,1,2,3 um:zero minimum:500 name:BIU_MASTER_D_CASTOUT_REQUESTS : Number of master D-Side non-program-demand castout transactions. This counts replacement pushes and snoop pushes. This does not count DCBF castouts. (Number of master D-side non-program-demand castout TSs.) +event:0x47 counters:0,1,2,3 um:zero minimum:500 name:BIU_MASTER_RETRIES : Number of transactions which were initiated by this processor which were retried on the BIU interface. (Number of master ARTRYs.) +event:0x48 counters:0,1,2,3 um:zero minimum:500 name:SNOOP_REQUESTS : Number of externally generated snoop requests. (Counts snoop TSs.) +event:0x49 counters:0,1,2,3 um:zero minimum:500 name:SNOOP_HITS : Number of snoop hits on all D-side resources regardless of the cache state (modified, exclusive, or shared) +event:0x4a counters:0,1,2,3 um:zero minimum:500 name:SNOOP_PUSHES : Number of snoop pushes from all D-side resources. (Counts snoop ARTRY/WOPs.) +event:0x4b counters:0,1,2,3 um:zero minimum:500 name:SNOOP_RETRIES : Number of snoop requests retried. (Counts snoop ARTRYs.) +event:0x52 counters:0,1,2,3 um:zero minimum:500 name:PMC0_OVERFLOW : Counts the number of times PMC0[32] transitioned from 1 to 0. +event:0x53 counters:0,1,2,3 um:zero minimum:500 name:PMC1_OVERFLOW : Counts the number of times PMC1[32] transitioned from 1 to 0. +event:0x54 counters:0,1,2,3 um:zero minimum:500 name:PMC2_OVERFLOW : Counts the number of times PMC2[32] transitioned from 1 to 0. +event:0x55 counters:0,1,2,3 um:zero minimum:500 name:PMC3_OVERFLOW : Counts the number of times PMC3[32] transitioned from 1 to 0. +event:0x56 counters:0,1,2,3 um:zero minimum:500 name:INTERRUPTS : Number of interrupts taken +event:0x57 counters:0,1,2,3 um:zero minimum:500 name:EXTERNAL_INTERRUPTS : Number of external input interrupts taken +event:0x58 counters:0,1,2,3 um:zero minimum:500 name:CRITICAL_INTERRUPTS : Number of critical input interrupts taken +event:0x59 counters:0,1,2,3 um:zero minimum:500 name:SC_TRAP_INTERRUPTS : Number of system call and trap interrupts diff --git a/events/ppc/e500/unit_masks b/events/ppc/e500/unit_masks new file mode 100644 index 0000000..395c653 --- /dev/null +++ b/events/ppc/e500/unit_masks @@ -0,0 +1,4 @@ +# e500 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/ppc64/970/event_mappings b/events/ppc64/970/event_mappings new file mode 100644 index 0000000..cf9a383 --- /dev/null +++ b/events/ppc64/970/event_mappings @@ -0,0 +1,212 @@ +event:0x1 mmcr0:0x0400C51E mmcr1:0x000000000A46F18C mmcra:0x00002000 + +#Group 0 pm_slice0 +event:0x10 mmcr0:0x0400C51E mmcr1:0x000000000A46F18C mmcra:0x00002000 +event:0x11 mmcr0:0x0400C51E mmcr1:0x000000000A46F18C mmcra:0x00002000 +event:0x13 mmcr0:0x0400C51E mmcr1:0x000000000A46F18C mmcra:0x00002000 + +#Group 2 pm_basic +event:0x18 mmcr0:0x0400C91E mmcr1:0x4003001005F09000 mmcra:0x00002000 +event:0x19 mmcr0:0x0400C91E mmcr1:0x4003001005F09000 mmcra:0x00002000 +event:0x1a mmcr0:0x0400C91E mmcr1:0x4003001005F09000 mmcra:0x00002000 +event:0x1b mmcr0:0x0400C91E mmcr1:0x4003001005F09000 mmcra:0x00002000 +event:0x1c mmcr0:0x0400C91E mmcr1:0x4003001005F09000 mmcra:0x00002000 +event:0x1d mmcr0:0x0400C91E mmcr1:0x4003001005F09000 mmcra:0x00002000 +event:0x1e mmcr0:0x0400C91E mmcr1:0x4003001005F09000 mmcra:0x00002000 + +#Group 3 pm_lsu +event:0x20 mmcr0:0x0400C000 mmcr1:0x000F00007A400000 mmcra:0x00002000 +event:0x21 mmcr0:0x0400C000 mmcr1:0x000F00007A400000 mmcra:0x00002000 +event:0x22 mmcr0:0x0400C000 mmcr1:0x000F00007A400000 mmcra:0x00002000 +event:0x23 mmcr0:0x0400C000 mmcr1:0x000F00007A400000 mmcra:0x00002000 +event:0x24 mmcr0:0x0400C000 mmcr1:0x000F00007A400000 mmcra:0x00002000 +event:0x25 mmcr0:0x0400C000 mmcr1:0x000F00007A400000 mmcra:0x00002000 +event:0x26 mmcr0:0x0400C000 mmcr1:0x000F00007A400000 mmcra:0x00002000 +event:0x27 mmcr0:0x0400C000 mmcr1:0x000F00007A400000 mmcra:0x00002000 + +#Group 4 pm_fpul +event:0x08 mmcr0:0x0400C000 mmcr1:0x00000000001E0480 mmcra:0x00002000 +event:0x09 mmcr0:0x0400C000 mmcr1:0x00000000001E0480 mmcra:0x00002000 +event:0x0a mmcr0:0x0400C000 mmcr1:0x00000000001E0480 mmcra:0x00002000 +event:0x0b mmcr0:0x0400C000 mmcr1:0x00000000001E0480 mmcra:0x00002000 +event:0x0c mmcr0:0x0400C000 mmcr1:0x00000000001E0480 mmcra:0x00002000 +event:0x0d mmcr0:0x0400C000 mmcr1:0x00000000001E0480 mmcra:0x00002000 +event:0x0e mmcr0:0x0400C000 mmcr1:0x00000000001E0480 mmcra:0x00002000 +event:0xof mmcr0:0x0400C000 mmcr1:0x00000000001E0480 mmcra:0x00002000 + +#Group 15 LSU Load Events +event:0x28 mmcr0:0x0400D028 mmcr1:0x000F0000851E9958 mmcra:0x00002000 +event:0x29 mmcr0:0x0400D028 mmcr1:0x000F0000851E9958 mmcra:0x00002000 +event:0x2a mmcr0:0x0400D028 mmcr1:0x000F0000851E9958 mmcra:0x00002000 +event:0x2b mmcr0:0x0400D028 mmcr1:0x000F0000851E9958 mmcra:0x00002000 +event:0x2c mmcr0:0x0400D028 mmcr1:0x000F0000851E9958 mmcra:0x00002000 +event:0x2d mmcr0:0x0400D028 mmcr1:0x000F0000851E9958 mmcra:0x00002000 +event:0x2e mmcr0:0x0400D028 mmcr1:0x000F0000851E9958 mmcra:0x00002000 +event:0x2f mmcr0:0x0400D028 mmcr1:0x000F0000851E9958 mmcra:0x00002000 + +#Group 16 Store Events +event:0x30 mmcr0:0x0400D12A mmcr1:0x000F00008D5E99DC mmcra:0x00002000 +event:0x31 mmcr0:0x0400D12A mmcr1:0x000F00008D5E99DC mmcra:0x00002000 +event:0x32 mmcr0:0x0400D12A mmcr1:0x000F00008D5E99DC mmcra:0x00002000 +event:0x33 mmcr0:0x0400D12A mmcr1:0x000F00008D5E99DC mmcra:0x00002000 +event:0x34 mmcr0:0x0400D12A mmcr1:0x000F00008D5E99DC mmcra:0x00002000 +event:0x35 mmcr0:0x0400D12A mmcr1:0x000F00008D5E99DC mmcra:0x00002000 +event:0x36 mmcr0:0x0400D12A mmcr1:0x000F00008D5E99DC mmcra:0x00002000 +event:0x37 mmcr0:0x0400D12A mmcr1:0x000F00008D5E99DC mmcra:0x00002000 + +#Group 17 Store Events 2 +event:0x38 mmcr0:0x0400D838 mmcr1:0x0003C0D08D76F4BC mmcra:0x00002000 +event:0x39 mmcr0:0x0400D838 mmcr1:0x0003C0D08D76F4BC mmcra:0x00002000 +event:0x3a mmcr0:0x0400D838 mmcr1:0x0003C0D08D76F4BC mmcra:0x00002000 +event:0x3b mmcr0:0x0400D838 mmcr1:0x0003C0D08D76F4BC mmcra:0x00002000 +event:0x3c mmcr0:0x0400D838 mmcr1:0x0003C0D08D76F4BC mmcra:0x00002000 +event:0x3d mmcr0:0x0400D838 mmcr1:0x0003C0D08D76F4BC mmcra:0x00002000 +event:0x3e mmcr0:0x0400D838 mmcr1:0x0003C0D08D76F4BC mmcra:0x00002000 +event:0x3f mmcr0:0x0400D838 mmcr1:0x0003C0D08D76F4BC mmcra:0x00002000 + +#Group 18 Information on the Load Store Unit +event:0x40 mmcr0:0x0400D22C mmcr1:0x000830047BD2FE3C mmcra:0x00002000 +event:0x41 mmcr0:0x0400D22C mmcr1:0x000830047BD2FE3C mmcra:0x00002000 +event:0x42 mmcr0:0x0400D22C mmcr1:0x000830047BD2FE3C mmcra:0x00002000 +event:0x43 mmcr0:0x0400D22C mmcr1:0x000830047BD2FE3C mmcra:0x00002000 +event:0x44 mmcr0:0x0400D22C mmcr1:0x000830047BD2FE3C mmcra:0x00002000 +event:0x45 mmcr0:0x0400D22C mmcr1:0x000830047BD2FE3C mmcra:0x00002000 +event:0x46 mmcr0:0x0400D22C mmcr1:0x000830047BD2FE3C mmcra:0x00002000 +event:0x47 mmcr0:0x0400D22C mmcr1:0x000830047BD2FE3C mmcra:0x00002000 + +#Group 21 PE Benchmarker group for L1 and TLB +event:0x48 mmcr0:0x0400D420 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x49 mmcr0:0x0400D420 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x4a mmcr0:0x0400D420 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x4b mmcr0:0x0400D420 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x4c mmcr0:0x0400D420 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x4d mmcr0:0x0400D420 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x4e mmcr0:0x0400D420 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x4f mmcr0:0x0400D420 mmcr1:0x000B000004DE9000 mmcra:0x00002000 + +#Group 22 Hpmcount group for L1 and TLB behavior +event:0x50 mmcr0:0x0400D404 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x51 mmcr0:0x0400D404 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x52 mmcr0:0x0400D404 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x53 mmcr0:0x0400D404 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x54 mmcr0:0x0400D404 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x55 mmcr0:0x0400D404 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x56 mmcr0:0x0400D404 mmcr1:0x000B000004DE9000 mmcra:0x00002000 +event:0x57 mmcr0:0x0400D404 mmcr1:0x000B000004DE9000 mmcra:0x00002000 + +#Group 24 L1 miss and branch misspredict +event:0x58 mmcr0:0x0400C91E mmcr1:0x8003C01D0636FCE8 mmcra:0x00002000 +event:0x59 mmcr0:0x0400C91E mmcr1:0x8003C01D0636FCE8 mmcra:0x00002000 +event:0x5a mmcr0:0x0400C91E mmcr1:0x8003C01D0636FCE8 mmcra:0x00002000 +event:0x5b mmcr0:0x0400C91E mmcr1:0x8003C01D0636FCE8 mmcra:0x00002000 +event:0x5c mmcr0:0x0400C91E mmcr1:0x8003C01D0636FCE8 mmcra:0x00002000 +event:0x5d mmcr0:0x0400C91E mmcr1:0x8003C01D0636FCE8 mmcra:0x00002000 +event:0x5e mmcr0:0x0400C91E mmcr1:0x8003C01D0636FCE8 mmcra:0x00002000 +event:0x5f mmcr0:0x0400C91E mmcr1:0x8003C01D0636FCE8 mmcra:0x00002000 + +#Group 26 SLB and branch mis-predict analysis +event:0x80 mmcr0:0x0400C52A mmcr1:0x8008000BC662F4E8 mmcra:0x00002000 +event:0x81 mmcr0:0x0400C52A mmcr1:0x8008000BC662F4E8 mmcra:0x00002000 +event:0x82 mmcr0:0x0400C52A mmcr1:0x8008000BC662F4E8 mmcra:0x00002000 +event:0x83 mmcr0:0x0400C52A mmcr1:0x8008000BC662F4E8 mmcra:0x00002000 +event:0x84 mmcr0:0x0400C52A mmcr1:0x8008000BC662F4E8 mmcra:0x00002000 +event:0x85 mmcr0:0x0400C52A mmcr1:0x8008000BC662F4E8 mmcra:0x00002000 +event:0x86 mmcr0:0x0400C52A mmcr1:0x8008000BC662F4E8 mmcra:0x00002000 +event:0x87 mmcr0:0x0400C52A mmcr1:0x8008000BC662F4E8 mmcra:0x00002000 + +#Group 27 Data source and LMQ +event:0x88 mmcr0:0x0400C712 mmcr1:0x0000300E3BCE7F74 mmcra:0x00002000 +event:0x89 mmcr0:0x0400C712 mmcr1:0x0000300E3BCE7F74 mmcra:0x00002000 +event:0x8a mmcr0:0x0400C712 mmcr1:0x0000300E3BCE7F74 mmcra:0x00002000 +event:0x8b mmcr0:0x0400C712 mmcr1:0x0000300E3BCE7F74 mmcra:0x00002000 +event:0x8c mmcr0:0x0400C712 mmcr1:0x0000300E3BCE7F74 mmcra:0x00002000 +event:0x8d mmcr0:0x0400C712 mmcr1:0x0000300E3BCE7F74 mmcra:0x00002000 +event:0x8e mmcr0:0x0400C712 mmcr1:0x0000300E3BCE7F74 mmcra:0x00002000 +event:0x8f mmcr0:0x0400C712 mmcr1:0x0000300E3BCE7F74 mmcra:0x00002000 + +#Group 28 TLB and LRQ plus data prefetch +event:0x90 mmcr0:0x0400D420 mmcr1:0x0008E03C4BFDACEC mmcra:0x00002000 +event:0x91 mmcr0:0x0400D420 mmcr1:0x0008E03C4BFDACEC mmcra:0x00002000 +event:0x92 mmcr0:0x0400D420 mmcr1:0x0008E03C4BFDACEC mmcra:0x00002000 +event:0x93 mmcr0:0x0400D420 mmcr1:0x0008E03C4BFDACEC mmcra:0x00002000 +event:0x94 mmcr0:0x0400D420 mmcr1:0x0008E03C4BFDACEC mmcra:0x00002000 +event:0x95 mmcr0:0x0400D420 mmcr1:0x0008E03C4BFDACEC mmcra:0x00002000 +event:0x96 mmcr0:0x0400D420 mmcr1:0x0008E03C4BFDACEC mmcra:0x00002000 +event:0x97 mmcr0:0x0400D420 mmcr1:0x0008E03C4BFDACEC mmcra:0x00002000 + +#Group 29 Instruction source and tablewalk +event:0x98 mmcr0:0x0400C60C mmcr1:0x800B00C0226EF1DC mmcra:0x00002000 +event:0x99 mmcr0:0x0400C60C mmcr1:0x800B00C0226EF1DC mmcra:0x00002000 +event:0x9a mmcr0:0x0400C60C mmcr1:0x800B00C0226EF1DC mmcra:0x00002000 +event:0x9b mmcr0:0x0400C60C mmcr1:0x800B00C0226EF1DC mmcra:0x00002000 +event:0x9c mmcr0:0x0400C60C mmcr1:0x800B00C0226EF1DC mmcra:0x00002000 +event:0x9d mmcr0:0x0400C60C mmcr1:0x800B00C0226EF1DC mmcra:0x00002000 +event:0x9e mmcr0:0x0400C60C mmcr1:0x800B00C0226EF1DC mmcra:0x00002000 +event:0x9f mmcr0:0x0400C60C mmcr1:0x800B00C0226EF1DC mmcra:0x00002000 + +#Group 30 Sync and SRQ +event:0xa0 mmcr0:0x0400DD32 mmcr1:0x0003E0C107529780 mmcra:0x00002000 +event:0xa1 mmcr0:0x0400DD32 mmcr1:0x0003E0C107529780 mmcra:0x00002000 +event:0xa2 mmcr0:0x0400DD32 mmcr1:0x0003E0C107529780 mmcra:0x00002000 +event:0xa3 mmcr0:0x0400DD32 mmcr1:0x0003E0C107529780 mmcra:0x00002000 +event:0xa4 mmcr0:0x0400DD32 mmcr1:0x0003E0C107529780 mmcra:0x00002000 +event:0xa5 mmcr0:0x0400DD32 mmcr1:0x0003E0C107529780 mmcra:0x00002000 +event:0xa6 mmcr0:0x0400DD32 mmcr1:0x0003E0C107529780 mmcra:0x00002000 + +#Group 31 IERAT +event:0xa8 mmcr0:0x0400CD3E mmcr1:0x800000C04BD2F4BC mmcra:0x00002000 +event:0xa9 mmcr0:0x0400CD3E mmcr1:0x800000C04BD2F4BC mmcra:0x00002000 +event:0xaa mmcr0:0x0400CD3E mmcr1:0x800000C04BD2F4BC mmcra:0x00002000 +event:0xab mmcr0:0x0400CD3E mmcr1:0x800000C04BD2F4BC mmcra:0x00002000 + +#Group 32 DERAT +event:0xb0 mmcr0:0x0400C436 mmcr1:0x100B7052E274003C mmcra:0x00002000 +event:0xb1 mmcr0:0x0400C436 mmcr1:0x100B7052E274003C mmcra:0x00002000 +event:0xb2 mmcr0:0x0400C436 mmcr1:0x100B7052E274003C mmcra:0x00002000 +event:0xb3 mmcr0:0x0400C436 mmcr1:0x100B7052E274003C mmcra:0x00002000 +event:0xb4 mmcr0:0x0400C436 mmcr1:0x100B7052E274003C mmcra:0x00002000 +event:0xb5 mmcr0:0x0400C436 mmcr1:0x100B7052E274003C mmcra:0x00002000 +event:0xb6 mmcr0:0x0400C436 mmcr1:0x100B7052E274003C mmcra:0x00002000 +event:0xb7 mmcr0:0x0400C436 mmcr1:0x100B7052E274003C mmcra:0x00002000 + +#Group 33 Info on marked instructions +event:0x60 mmcr0:0x0400C006 mmcr1:0x00008080790852A4 mmcra:0x00002001 +event:0x61 mmcr0:0x0400C006 mmcr1:0x00008080790852A4 mmcra:0x00002001 +event:0x62 mmcr0:0x0400C006 mmcr1:0x00008080790852A4 mmcra:0x00002001 +event:0x63 mmcr0:0x0400C006 mmcr1:0x00008080790852A4 mmcra:0x00002001 +event:0x64 mmcr0:0x0400C006 mmcr1:0x00008080790852A4 mmcra:0x00002001 +event:0x65 mmcr0:0x0400C006 mmcr1:0x00008080790852A4 mmcra:0x00002001 +event:0x66 mmcr0:0x0400C006 mmcr1:0x00008080790852A4 mmcra:0x00002001 +event:0x67 mmcr0:0x0400C006 mmcr1:0x00008080790852A4 mmcra:0x00002001 + +#Group 34 Marked Stores Processing Flow +event:0x68 mmcr0:0x0400C31E mmcr1:0x00203004190A3F24 mmcra:0x00002001 +event:0x69 mmcr0:0x0400C31E mmcr1:0x00203004190A3F24 mmcra:0x00002001 +event:0x6a mmcr0:0x0400C31E mmcr1:0x00203004190A3F24 mmcra:0x00002001 +event:0x6b mmcr0:0x0400C31E mmcr1:0x00203004190A3F24 mmcra:0x00002001 +event:0x6c mmcr0:0x0400C31E mmcr1:0x00203004190A3F24 mmcra:0x00002001 +event:0x6d mmcr0:0x0400C31E mmcr1:0x00203004190A3F24 mmcra:0x00002001 +event:0x6e mmcr0:0x0400C31E mmcr1:0x00203004190A3F24 mmcra:0x00002001 +event:0x6f mmcr0:0x0400C31E mmcr1:0x00203004190A3F24 mmcra:0x00002001 + +#Group 35 Load Store Unit Marked Events +event:0x70 mmcr0:0x0400DB34 mmcr1:0x000280C08D5E9850 mmcra:0x00002001 +event:0x71 mmcr0:0x0400DB34 mmcr1:0x000280C08D5E9850 mmcra:0x00002001 +event:0x72 mmcr0:0x0400DB34 mmcr1:0x000280C08D5E9850 mmcra:0x00002001 +event:0x73 mmcr0:0x0400DB34 mmcr1:0x000280C08D5E9850 mmcra:0x00002001 +event:0x74 mmcr0:0x0400DB34 mmcr1:0x000280C08D5E9850 mmcra:0x00002001 +event:0x75 mmcr0:0x0400DB34 mmcr1:0x000280C08D5E9850 mmcra:0x00002001 +event:0x76 mmcr0:0x0400DB34 mmcr1:0x000280C08D5E9850 mmcra:0x00002001 +event:0x77 mmcr0:0x0400DB34 mmcr1:0x000280C08D5E9850 mmcra:0x00002001 + + +#Group 36 Load Store Unit Marked Events 2 +event:0x78 mmcr0:0x0400D838 mmcr1:0x000280C0959E99DC mmcra:0x00002001 +event:0x79 mmcr0:0x0400D838 mmcr1:0x000280C0959E99DC mmcra:0x00002001 +event:0x7a mmcr0:0x0400D838 mmcr1:0x000280C0959E99DC mmcra:0x00002001 +event:0x7b mmcr0:0x0400D838 mmcr1:0x000280C0959E99DC mmcra:0x00002001 +event:0x7c mmcr0:0x0400D838 mmcr1:0x000280C0959E99DC mmcra:0x00002001 +event:0x7d mmcr0:0x0400D838 mmcr1:0x000280C0959E99DC mmcra:0x00002001 +event:0x7e mmcr0:0x0400D838 mmcr1:0x000280C0959E99DC mmcra:0x00002001 +event:0x7f mmcr0:0x0400D838 mmcr1:0x000280C0959E99DC mmcra:0x00002001 + diff --git a/events/ppc64/970/events b/events/ppc64/970/events new file mode 100644 index 0000000..03563b5 --- /dev/null +++ b/events/ppc64/970/events @@ -0,0 +1,226 @@ +# ppc64 POWERPC970 events +# +# Within each group the event names must be unique. Each event in a group is +# assigned to a unique counter. The groups are from the groups defined in the +# PowerPC970 manual. +# +# Only events within the same group can be selected simultaneously +# Each event is given a unique event number. The event number is used by the +# Oprofile code to resolve event names for the postprocessing. This is done +# to preserve compatibility with the rest of the Oprofile code. The event +# number format group_num followed by the counter number for the event within +# the group. The event number must be between 0 and 100 hex. + +#Group Default +event:0x1 counters:1 um:zero minimum:10000 name:CYCLES : Processor Cycles + +#Group 0 pm_slice0 +event:0x10 counters:0 um:zero minimum:10000 name:PM_RUN_CYC_GRP1 : (Group 1 pm_slice0) Processor Cycles gated by the run latch +event:0x11 counters:1 um:zero minimum:10000 name:PM_CYC_GRP1 : (Group 1 pm_slice0) Processor Cycles +event:0x13 counters:3 um:zero minimum:10000 name:PM_INST_CMPL_GRP1 : (Group 1 pm_slice0) Number of eligible instructions that completed + +#Group 2 pm_basic +event:0x18 counters:0 um:zero minimum:10000 name:PM_INST_CMPL_GRP2 : (Group 2 pm_basic) Instructions completed +event:0x19 counters:1 um:zero minimum:10000 name:PM_CYC_GRP2 : (Group 2 pm_basic) Processor cycles +event:0x1a counters:2 um:zero minimum:1000 name:PM_LD_MISS_1_GRP2 : (Group 2 pm_basic) Total DL1 load references that miss the DL1 +event:0x1b counters:3 um:zero minimum:1000 name:PM_DC_INV_L2_GRP2 : (Group 2 pm_basic) A Dcache invalidated was received from the L2 because a line in L2 was castout +event:0x1c counters:4 um:zero minimum:5000 name:PM_INST_DISP_GRP2 : (Group 2 pm_basic) The ISU sends the number of instructions dispatched +event:0x1d counters:6 um:zero minimum:5000 name:PM_ST_REF_L1_GRP2 : (Group 2 pm_basic) Total DL1 store references +event:0x1e counters:7 um:zero minimum:5000 name:PM_LD_REF_L1_GRP2 : (Group 2 pm_basic) Total DL1 load references + +#Group 3 pm_lsu +event:0x20 counters:0 um:zero minimum:1000 name:PM_LSU_FLUSH_ULD_GRP3 : (Group 3 pm_lsu) A load was flushed because it was unaligned (crossed a 64byte boundary, or 32 byte if it missed the L1) +event:0x21 counters:1 um:zero minimum:1000 name:PM_LSU_FLUSH_UST_GRP3 : (Group 3 pm_lsu) A store was flushed because it was unaligned +event:0x22 counters:2 um:zero minimum:10000 name:PM_CYC_GRP3 : (Group 3 pm_lsu) Processor cycles +event:0x23 counters:3 um:zero minimum:10000 name:PM_INST_CMPL_GRP3 : (Group 3 pm_lsu) Number of Eligible Instructions that completed +event:0x24 counters:4 um:zero minimum:1000 name:PM_LSU_FLUSH_SRQ_GRP3 : (Group 3 pm_lsu) Store flushed because younger load hits and older store already in SRQ or in the same group +event:0x25 counters:5 um:zero minimum:1000 name:PM_LSU_FLUSH_LRQ_GRP3 : (Group 3 pm_lsu) Load flushed because younger load executed before older store executed where data overlapped; OR two loads executed out of order with byte overlap and a snoop in between. +event:0x26 counters:6 um:zero minimum:5000 name:PM_ST_REF_L1_GRP3 : (Group 3 pm_lsu) Total DL1 store references +event:0x27 counters:7 um:zero minimum:5000 name:PM_LD_REF_L1_GRP3 : (Group 3 pm_lsu) Total DL1 load references + +#Group 4 pm_fpul +event:0x08 counters:0 um:zero minimum:1000 name:PM_FPU_FDIV_GRP4 : (GRP4 pm_fpul) Active for one cycle at end of microcode executed when FPU is executing divide instruction; e.g. fdiv, fdivs. +event:0x09 counters:1 um:zero minimum:1000 name:PM_FPU_FMA_GRP4 : (GRP4 pm_fpul) Active for one cycle when FPU is executing multiply-add kind of instruction; e.g. fmadd*, fnmsub*, where XYZ* means XYZ, XYZs. +event:0x0a counters:2 um:zero minimum:1000 name:PM_FPU_FEST_GRP4 : (GRP4 pm_fpul) Active for one cycle when executing one of the estimate instructions; e.g. fres*. +event:0x0b counters:3 um:zero minimum:1000 name:PM_FPU_FIN_GRP4 : (GRP4 pm_fpul) FPU finished, produced a result. This only indicates finish, not completion. +event:0x0c counters:4 um:zero minimum:10000 name:PM_CYC_GRP4 : (GRP4 pm_fpul) Processor cycles +event:0x0d counters:5 um:zero minimum:1000 name:PM_FPU_FSQRT_GRP4 : (GRP4 pm_fpul) Active for one cycle at end of microcode executed when FPU is executing a square root instruction; e.g. fsqrt*. +event:0x0e counters:6 um:zero minimum:10000 name:PM_INST_CMPL_GRP4 : (GRP4 pm_fpul) Number of Eligible Instructions that completed. +event:0x0f counters:7 um:zero minimum:1000 name:PM_FPU_FMOV_FEST_GRP4 : (GRP4 pm_fpul) Active for one cycle when executing a move kind of instruction or one of the estimate instructions; e.g. fmr* or fres*. + +#Group 15 LSU Load Events +event:0x28 counters:0 um:zero minimum:1000 name:PM_LSU0_FLUSH_ULD_GRP15 : (GRP15 LSU load events) A load was flushed from unit 0 because it was unaligned. +event:0x29 counters:1 um:zero minimum:1000 name:PM_LSU1_FLUSH_ULD_GRP15 : (GRP15 LSU load events) A load was flushed from unit 1 because it was unaligned. +event:0x2a counters:2 um:zero minimum:1000 name:PM_LD_REF_L1_LSU0_GRP15 : (GRP15 LSU load events) LSU0 L1 Dcache load reference execucted on uint 0 +event:0x2b counters:3 um:zero minimum:1000 name:PM_LD_REF_L1_LSU1_GRP15 : (GRP15 LSU load events) LSU1 L1 Dcache load reference execucted on uint 0 +event:0x2c counters:4 um:zero minimum:10000 name:PM_CYC_GRP15 : (GRP15 LSU load events) Processor cycles +event:0x2d counters:5 um:zero minimum:10000 name:PM_INST_CMPL_GRP15 : (GRP15 LSU load events) Number of elegible instructions that completed +event:0x2e counters:6 um:zero minimum:1000 name:PM_LD_MISS_L1_LSU0_GRP15 : (GRP15 LSU load events) A load executing on unit 0 missed the D cache +event:0x2f counters:7 um:zero minimum:1000 name:PM_LD_MISS_L1_LSU1_GRP15 : (GRP15 LSU load events) A load executing on unit 1 missed the D cache + +#Group 16 LSU Store Events +event:0x30 counters:0 um:zero minimum:1000 name:PM_LSU0_FLUSH_UST_GRP16 : (GRP16 LSU store events) A store was flushed from unit 0 because it was unaligned (crossed 4K boundary) +event:0x31 counters:1 um:zero minimum:1000 name:PM_LSU1_FLUSH_UST_GRP16 : (GRP16 LSU store events) A store was flushed from unit 1 because it was unaligned (crossed 4K boundary) +event:0x32 counters:2 um:zero minimum:1000 name:PM_ST_REF_L1_LSU0_GRP16 : (GRP16 LSU store events) An L1 D cache store executed on unit 0 +event:0x33 counters:3 um:zero minimum:1000 name:PM_ST_REF_L1_LSU1_GRP16 : (GRP16 LSU store events) An L1 D cache store executed on unit 1 +event:0x34 counters:4 um:zero minimum:10000 name:PM_CYC_GRP16 : (GRP16 LSU store events) Processor cycles +event:0x35 counters:5 um:zero minimum:10000 name:PM_INST_CMPL_GRP16 : (GRP16 LSU store events) Instructions completed +event:0x36 counters:6 um:zero minimum:1000 name:PM_ST_MISS_L1_GRP16 : (GRP16 LSU store events) L1 Dcache store missed the D cache +event:0x37 counters:7 um:zero minimum:1000 name:PM_DC_INV_L2_GRP16 : (GRP16 LSU store events) An L1 Dcache entry invalidated from the L2 because L2 line was cast out + +#Group 17 LSU Store Events 2 +event:0x38 counters:0 um:zero minimum:1000 name:PM_LSU0_SRQ_STFWD_GRP17 : (GRP17 LSU store events 2) Data from a store instruction was forwarded to a load on unit 0 +event:0x39 counters:1 um:zero minimum:1000 name:PM_LSU1_SRQ_STFWD_GRP17 : (GRP17 LSU store events 2) Data from a store instruction was forwarded to a load on unit 1 +event:0x3a counters:2 um:zero minimum:1000 name:PM_ST_REF_L1_LSU0_GRP17 : (GRP17 LSU store events 2) L1 Dcache store executed on unit 0 +event:0x3b counters:3 um:zero minimum:1000 name:PM_ST_REF_L1_LSU1_GRP17 : (GRP17 LSU store events 2) L1 Dcache store executed on unit 1 +event:0x3c counters:4 um:zero minimum:1000 name:PM_ST_MISS_L1_GRP17 : (GRP17 LSU store events 2) L1 Dcache store missed the D cache +event:0x3d counters:5 um:zero minimum:10000 name:PM_CYC_GRP17 : (GRP17 LSU store events 2) Processor Cycles +event:0x3e counters:6 um:zero minimum:10000 name:PM_INST_CMPL_GRP17 : (GRP17 LSU store events 2) Instructions completed +event:0x3f counters:7 um:zero minimum:10000 name:PM_CYC_GRP17 : (GRP17 LSU store events 2) Processor Cycles + +#Group 18 Information on the Load Store Unit +event:0x40 counters:0 um:zero minimum:1000 name:PM_LSU0_DERAT_MISS_GRP18 : (GRP18 Info on load store unit) Data request from LSU unit 0 missed ERAT causing ERAT reload +event:0x41 counters:1 um:zero minimum:1000 name:PM_LSU1_DERAT_MISS_GRP18 : (GRP18 Info on load store unit) Data request from LSU unit 1 missed ERAT causing ERAT reload +event:0x42 counters:2 um:zero minimum:10000 name:PM_CYC_GRP18 : (GRP18 Info on load store unit) Processor Cycles +event:0x43 counters:3 um:zero minimum:10000 name:PM_CYC_GRP18 : (GRP18 Info on load store unit) Processor Cycles +event:0x44 counters:4 um:zero minimum:10000 name:PM_INST_CMPL_GRP18 : (GRP18 Info on load store unit) Instructions completed +event:0x45 counters:5 um:zero minimum:10000 name:PM_CYC_GRP18 : (GRP18 Info on load store unit) Processor Cycles +event:0x46 counters:6 um:zero minimum:1000 name:PM_L1_DCACHE_RELOAD_VALID_GRP18 : (GRP18 Info on load store unit) L1 reload data source valid +event:0x47 counters:7 um:zero minimum:10000 name:PM_CYC_GRP18 : (GRP18 Info on load store unit) Processor Cycles + +#Group 21 PE Benchmarker group for L1 and TLB +event:0x48 counters:0 um:zero minimum:1000 name:PM_DTLB_MISS_GRP21 : (GRP21 PE Benchmarker group for L1 and TLB) TLB miss for Data request occurred. Request may be retried until inst is in next complete group causing multiple TLB misses for the same inst. +event:0x49 counters:1 um:zero minimum:1000 name:PM_ITLB_MISS_GRP21 : (GRP21 PE Benchmarker group for L1 and TLB) A TLB miss for an instruction Fetch has occurred +event:0x4a counters:2 um:zero minimum:1000 name:PM_LD_MISS_L1_GRP21 : (GRP21 PE Benchmarker group for L1 and TLB) L1 reference that misses the L1 Dcache +event:0x4b counters:3 um:zero minimum:1000 name:PM_ST_MISS_L1_GRP21 : (GRP21 PE Benchmarker group for L1 and TLB) L1 D cache store that misses the cache +event:0x4c counters:4 um:zero minimum:10000 name:PM_CYC_GRP21 : (GRP21 PE Benchmarker group for L1 and TLB) Processor cycles +event:0x4d counters:5 um:zero minimum:10000 name:PM_INST_CMPL_GRP21 : (GRP21 PE Benchmarker group for L1 and TLB) Instructions completed +event:0x4e counters:6 um:zero minimum:1000 name:PM_ST_REF_L1_GRP21 : (GRP21 PE Benchmarker group for L1 and TLB) L1 D cache store references +event:0x4f counters:7 um:zero minimum:1000 name:PM_LD_REF_L1_GRP21 : (GRP21 PE Benchmarker group for L1 and TLB) L1 D cache load references + +#Group 22 Hpmcount group for L1 and TLB behavior +event:0x50 counters:0 um:zero minimum:1000 name:PM_DTLB_MISS_GRP22 : (GRP22 Hpmcount group for L1 and TLB behavior) A TLB miss for data, request may be retried until the instruction is in the next complete group. This may cause multiple TLB misses for the same instruction. +event:0x51 counters:1 um:zero minimum:1000 name:PM_LSU_LMQ_SRQ_EMPTY_CYC_GRP22 : (GRP22 Hpmcount group for L1 and TLB behavior) Cycles LMQ and SRQ empty +event:0x52 counters:2 um:zero minimum:1000 name:PM_LD_MISS_L1_GRP22 : (GRP22 Hpmcount group for L1 and TLB behavior) L1 D cache load miss +event:0x53 counters:3 um:zero minimum:1000 name:PM_ST_MISS_L1_GRP22 : (GRP22 Hpmcount group for L1 and TLB behavior) L1 D cache store miss +event:0x54 counters:4 um:zero minimum:10000 name:PM_CYC_GRP22 : (GRP22 Hpmcount group for L1 and TLB behavior) processor cycles +event:0x55 counters:5 um:zero minimum:10000 name:PM_INST_CMPL_GRP22 : (GRP22 Hpmcount group for L1 and TLB behavior) instructions completed +event:0x56 counters:6 um:zero minimum:1000 name:PM_ST_REF_L1_GRP22 : (GRP22 Hpmcount group for L1 and TLB behavior) L1 D cache store references +event:0x57 counters:7 um:zero minimum:1000 name:PM_LD_REF_L1_GRP22 : (GRP22 Hpmcount group for L1 and TLB behavior) L1 D cache load references + +#Group 24 L1 miss and branch mispredict +event:0x58 counters:0 um:zero minimum:10000 name:PM_INST_CMPL_GRP24 : (GRP24 L1 miss and branch mispredict) Instructions completed +event:0x59 counters:1 um:zero minimum:10000 name:PM_CYC_GRP24 : (GRP24 L1 miss and branch mispredict) Processor Cycles +event:0x5a counters:2 um:zero minimum:1000 name:PM_LD_MISS_L1_GRP24 : (GRP24 L1 miss and branch mispredict) L1 D cache load misses +event:0x5b counters:3 um:zero minimum:1000 name:PM_BR_ISSUED_GRP24 : (GRP24 L1 miss and branch mispredict) Branches issued +event:0x5c counters:4 um:zero minimum:1000 name:PM_ST_MISS_L1_GRP24 : (GRP24 L1 miss and branch mispredict) L1 D cache store misses +event:0x5d counters:5 um:zero minimum:10000 name:PM_CYC_GRP24 : (GRP24 L1 miss and branch mispredict) Processor Cycles +event:0x5e counters:6 um:zero minimum:1000 name:PM_BR_MPRED_CR_GRP24 : (GRP24 L1 miss and branch mispredict) Branch misprediction due to CR bit setting +event:0x5f counters:7 um:zero minimum:1000 name:PM_BR_MPRED_TA_GRP24 : (GRP24 L1 miss and branch mispredict) Branch mispreditions due to target address + +#Group 26 SLB and branch mispredict analysis +event:0x80 counters:0 um:zero minimum:10000 name:PM_RUN_CYC_GRP26 : (GRP26 SLB and branch mispredict analysis) Processor Cycles gated by the run latch +event:0x81 counters:1 um:zero minimum:1000 name:PM_DSLB_MISS_GRP26 : (GRP26 SLB and branch mispredict analysis) SLB miss for a data request. SLB misses trap to the operating system to resolve. +event:0x82 counters:2 um:zero minimum:1000 name:PM_BR_ISSUED_GRP26 : (GRP26 SLB and branch mispredict analysis) Asserted when ISU issues a branch instruction. +event:0x83 counters:3 um:zero minimum:1000 name:PM_BR_MPRED_CR_GRP26 : (GRP26 SLB and branch mispredict analysis) Asserted when the branch execution unit detects a branch mispredict because the CR value is opposite of the predicted value. +event:0x84 counters:4 um:zero minimum:1000 name:PM_ISLB_MISS_GRP26 : (GRP26 SLB and branch mispredict analysis) SLB miss for an instruction fetch as occurred +event:0x85 counters:5 um:zero minimum:10000 name:PM_CYC_GRP26 : (GRP26 SLB and branch mispredict analysis) Processor cycles +event:0x86 counters:6 um:zero minimum:10000 name:PM_INST_CMPL_GRP26 : (GRP26 SLB and branch mispredict analysis) Instructions completed +event:0x87 counters:7 um:zero minimum:1000 name:PM_BR_MPRED_TA_GRP26 : (GRP26 SLB and branch mispredict analysis) Asserted when the branch execution unit detects an incorrect target address prediction. + +#Group 27 Data source and LMQ +event:0x88 counters:0 um:zero minimum:1000 name:PM_DATA_FROM_L2_GRP27 : (GRP27 Data source and LMQ) DL1 was reloaded from the local L2 due to a demand load +event:0x89 counters:1 um:zero minimum:10000 name:PM_INST_CMPL_GRP27 : (GRP27 Data source and LMQ) Instructions completed +event:0x8a counters:2 um:zero minimum:1000 name:PM_DATA_FROM_MEM_GRP27 : (GRP27 Data source and LMQ) Data loaded from memory +event:0x8b counters:3 um:zero minimum:10000 name:PM_CYC_GRP27 : (GRP27 Data source and LMQ) Processor cycles +event:0x8c counters:4 um:zero minimum:1000 name:PM_DATA_FROM_L25_SHR_GRP27 : (GRP27 Data source and LMQ) DL1 reloaded with shared (T or SL) data from L2 of a chip on this MCM due to demand load +event:0x8d counters:5 um:zero minimum:1000 name:PM_DATA_FROM_L25_MOD_GRP27 : (GRP27 Data source and LMQ) DL1 reloaded with modified (M) data from L2 of a chip on this MCM due to a demand load +event:0x8e counters:6 um:zero minimum:1000 name:PM_LSU_LMQ_S0_ALLOC_GRP27 : (GRP27 Data source and LMQ) The first entry in the LMQ was allocated +event:0x8f counters:7 um:zero minimum:1000 name:PM_LSU_LMQ_S0_VALID_GRP27 : (GRP27 Data source and LMQ) Asserted every cycle when first entry in LMQ is valid. LMQ had eight entries allocated FIFO. + +#Group 28 TLB and LRQ plus data prefetch +event:0x90 counters:0 um:zero minimum:1000 name:PM_DTLB_MISS_GRP28 : (GRP28 TLB and LRQ plus data prefetch) TLB miss for data request. Request may be retried, resulting in multiple TLB misses for same instruction. +event:0x91 counters:1 um:zero minimum:1000 name:PM_ITLB_MISS_GRP28 : (GRP28 TLB and LRQ plus data prefetch) TLB miss for an Instruction Fetch has occurred +event:0x92 counters:2 um:zero minimum:10000 name:PM_INST_CMPL_GRP28 : (GRP28 TLB and LRQ plus data prefetch) Instructions completed +event:0x93 counters:3 um:zero minimum:10000 name:PM_CYC_GRP28 : (GRP28 TLB and LRQ plus data prefetch) Processor cycles +event:0x94 counters:4 um:zero minimum:1000 name:PM_LSU_LRQ_S0_ALLOC_GRP28 : (GRP28 TLB and LRQ plus data prefetch) LRQ slot zero was allocated +event:0x95 counters:5 um:zero minimum:1000 name:PM_LSU_LRQ_S0_VALID_GRP28 : (GRP28 TLB and LRQ plus data prefetch) Asserted every cycle that Load Request Queue slot zero is valid. SRQ is 32 entries long and is allocated round-robin. +event:0x96 counters:6 um:zero minimum:1000 name:PM_L1_PREF_GRP28 : (GRP28 TLB and LRQ plus data prefetch) A request to prefetch data into the L1 was made +event:0x97 counters:7 um:zero minimum:1000 name:PM_L2_PREF_GRP28 : (GRP28 TLB and LRQ plus data prefetch) A request to prefetch data into L2 was made + +#Group 29 Instruction source and tablewalk +event:0x98 counters:0 um:zero minimum:1000 name:PM_INST_FROM_L2_GRP29 : (GRP29 Instruction source and tablewalk) Instruction fetch group was fetched from L2. Fetch Groups can contain up to 8 instructions. +event:0x99 counters:1 um:zero minimum:1000 name:PM_INST_FROM_MEM_GRP29 : (GRP29 Instruction source and tablewalk) Instruction fetched from memory +event:0x9a counters:2 um:zero minimum:10000 name:PM_HV_CYC_GRP29 : (GRP29 Instruction source and tablewalk) Cycles when the processor is executing in Hypervisor (MSR[HV] = 1 and MSR[PR]=0) +event:0x9b counters:3 um:zero minimum:10000 name:PM_INST_CMPL_GRP29 : (GRP29 Instruction source and tablewalk) Instructions completed +event:0x9c counters:4 um:zero minimum:1000 name:PM_DATA_TABLEWALK_CYC_GRP29 : (GRP29 Instruction source and tablewalk) Asserted every cycle when a tablewalk is active, during which, any request attempting to access the TLB will be rejected and retried. +event:0x9d counters:5 um:zero minimum:10000 name:PM_CYC_GRP29 : (GRP29 Instruction source and tablewalk) Processor cycles +event:0x9e counters:6 um:zero minimum:1000 name:PM_GRP_CMPL_GRP29 : (GRP29 Instruction source and tablewalk) A group completed. Microcoded instructions that span multiple groups will generate this event once per group. +event:0x9f counters:7 um:zero minimum:1000 name:PM_DC_INV_L2_GRP29 : (GRP29 Instruction source and tablewalk) A dcache invalidated was received from the L2 because a line in L2 was castout. + +#Group 30 Sync and SRQ +event:0xa0 counters:0 um:zero minimum:1000 name:PM_LSU_SRQ_S0_ALLOC_GRP30 : (GRP30 Sync and SRQ) SRQ Slot zero was allocated +event:0xa1 counters:1 um:zero minimum:1000 name:PM_LSU_SRQ_S0_VALID_GRP30 : (GRP30 Sync and SRQ) Asserted every cycle that the Store Request Queue slot zero is valid. SRQ is 32 entries long and is allocated round-robin. +event:0xa2 counters:2 um:zero minimum:1000 name:PM_LD_MISS_L1_GRP30 : (GRP30 Sync and SRQ) Total DL1 load references that miss the DL1 +event:0xa3 counters:3 um:zero minimum:1000 name:PM_LSU_SRQ_SYNC_CYC_GRP30 : (GRP30 Sync and SRQ) Asserted every cycle when a sync is in the SRQ. +event:0xa4 counters:4 um:zero minimum:10000 name:PM_INST_CMPL_GRP30 : (GRP30 Sync and SRQ) Instructions completed +event:0xa5 counters:6 um:zero minimum:10000 name:PM_CYC_GRP30 : (GRP30 Sync and SRQ) Processor cycles +event:0xa6 counters:7 um:zero minimum:1000 name:PM_LD_REF_L1_GRP30 : (GRP30 Sync and SRQ) Total DL1 Load references + +#Group 31 IERAT +event:0xa8 counters:0 um:zero minimum:1000 name:PM_INST_FROM_L1_GRP31 : (GRP31 IERAT) Instruction fetch group was fetched from L1. Fetch Groups can contain up to 8 instructions. +event:0xa9 counters:1 um:zero minimum:1000 name:PM_IERAT_XLATE_WR_GRP31 : (GRP31 IERAT) Asserted each time the I-ERAT is written, indicating that an ERAT miss has been serviced. +event:0xaa counters:2 um:zero minimum:10000 name:PM_INST_CMPL_GRP31 : (GRP31 IERAT) Instructions completed +event:0xab counters:3 um:zero minimum:10000 name:PM_CYC_GRP31 : (GRP31 IERAT) Processor cycles + +#Group 32 DERAT +event:0xb0 counters:0 um:zero minimum:1000 name:PM_GCT_EMPTY_CYC_GRP32 : (GRP32 DERAT) The Global Completion Table is completely empty +event:0xb1 counters:1 um:zero minimum:1000 name:PM_GRP_DISP_VALID_GRP32 : (GRP32 DERAT) Dispatch has been attempted for a valid group. +event:0xb2 counters:2 um:zero minimum:1000 name:PM_L1_DCACHE_RELOAD_VALID_GRP32 : (GRP32 DERAT) The data source information is valid +event:0xb3 counters:3 um:zero minimum:10000 name:PM_INST_CMPL_GRP32 : (GRP32 DERAT) Instructions completed +event:0xb4 counters:4 um:zero minimum:1000 name:PM_INST_DISP_GRP32 : (GRP32 DERAT) The ISU sends the number of instructions dispatched. +event:0xb5 counters:5 um:zero minimum:1000 name:PM_LSU_DERAT_MISS_GRP32 : (GRP32 DERAT) Total D-ERAT Misses (Unit 0 + Unit 1). Requests are retried and may result in multiple erat misses for the same instruction. +event:0xb6 counters:6 um:zero minimum:1000 name:PM_ST_REF_L1_GRP32 : (GRP32 DERAT) Total DL1 Store references +event:0xb7 counters:7 um:zero minimum:10000 name:PM_CYC_GRP32 : (GRP32 DERAT) Processor cycles + +#Group 33 Info on marked instructions +event:0x60 counters:0 um:zero minimum:1000 name:PM_MRK_LD_MISS_L1_GRP33 : (GRP33 Info on marked instructions) Marked L1 D cache load misses +event:0x61 counters:1 um:zero minimum:1000 name:PM_THRESHOLD_TIMEO_GRP33 : (GRP33 Info on marked instructions) Threshold timer expired +event:0x62 counters:2 um:zero minimum:10000 name:PM_CYC_GRP33 : (GRP33 Info on marked instructions) Processor cycles +event:0x63 counters:3 um:zero minimum:1000 name:PM_MRK_GRP_CMPL_GRP33 : (GRP33 Info on marked instructions) Marked group completed +event:0x64 counters:4 um:zero minimum:1000 name:PM_GRP_MRK_GRP33 : (GRP33 Info on marked instructions) A marked group was sampled in IDU +event:0x65 counters:5 um:zero minimum:1000 name:PM_MRK_GRP_ISSUED_GRP33 : (GRP33 Info on marked instructions) A marked group was issued +event:0x66 counters:6 um:zero minimum:1000 name:PM_MRK_GRP_INST_FIN_GRP33 : (GRP33 Info on marked instructions) A marked instruction finished +event:0x67 counters:7 um:zero minimum:10000 name:PM_INST_CMPL_GRP33 : (GRP33 Info on marked instructions) Instructions completed + +#Group 34 Marked Stores Processing Flow +event:0x68 counters:0 um:zero minimum:1000 name:PM_MRK_ST_CMPL_GRP34 : (GRP34 Marked Stores Processing Flow) Marked store instruction completed (data home) +event:0x69 counters:1 um:zero minimum:10000 name:PM_CYC_GRP34 : (GRP34 Marked Stores Processing Flow) Processor cycles +event:0x6a counters:2 um:zero minimum:1000 name:PM_MRK_ST_CMPL_INT_GRP34 : (GRP34 Marked Stores Processing Flow) Marked store completed with intervention +event:0x6b counters:3 um:zero minimum:1000 name:PM_MRK_GRP_CMPL_GRP34 : (GRP34 Marked Stores Processing Flow) Marked group completed +event:0x6c counters:4 um:zero minimum:1000 name:PM_MRK_GRP_TIME0_GRP34 : (GRP34 Marked Stores Processing Flow) Marked group completion timeout +event:0x6d counters:5 um:zero minimum:1000 name:PM_MRK_ST_GPS_GRP34 : (GRP34 Marked Stores Processing Flow) Marked store sent to GPS +event:0x6e counters:6 um:zero minimum:1000 name:PM_MRK_LSU_SRQ_INST_VALID_GRP34 : (GRP34 Marked Stores Processing Flow) Marked instruction valid in SRQ +event:0x6f counters:7 um:zero minimum:10000 name:PM_INST_CMPL_GRP34 : (GRP34 Marked Stores Processing Flow) Instructions completed + +#Group 35 Load Store Unit Marked Events +event:0x70 counters:0 um:zero minimum:1000 name:PM_MRK_ST_MISS_L1_GRP35 : (GRP35 Load Store Unit Marked Events) Marked L1 D cacahe store misses +event:0x71 counters:1 um:zero minimum:1000 name:PM_MRK_IMR_RELOAD_GRP35 : (GRP35 Load Store Unit Marked Events) A DL1 reload occured due to a marked load +event:0x72 counters:2 um:zero minimum:1000 name:PM_MRK_LSU0_FLUSH_UST_GRP35 : (GRP35 Load Store Unit Marked Events) A marked store was flushed from unit 0 because it was unaligned +event:0x73 counters:3 um:zero minimum:1000 name:PM_MRK_LSU1_FLUSH_UST_GRP35 : (GRP35 Load Store Unit Marked Events) A marked store was flushed from unit 1 because it was unaligned +event:0x74 counters:4 um:zero minimum:10000 name:PM_CYC_GRP35 : (GRP35 Load Store Unit Marked Events) processor cycles +event:0x75 counters:5 um:zero minimum:10000 name:PM_INST_CMPL_GRP35 : (GRP35 Load Store Unit Marked Events) Instructions completed +event:0x76 counters:6 um:zero minimum:1000 name:PM_MRK_LSU0_FLUSH_ULD_GRP35 : (GRP35 Load Store Unit Marked Events) Marked load was flushed from unit 0 because it was unaligned (crossed a 64byte boundery or 32 byte if it missed the L1 +event:0x77 counters:7 um:zero minimum:1000 name:PM_MRK_LSU1_FLUSH_ULD_GRP35 : (GRP35 Load Store Unit Marked Events) Marked load was flushed from unit 1 because it was unaligned (crossed a 64byte boundery or 32 byte if it missed the L1 + +#Group 36 Load Store Unit Marked Events 2 +event:0x78 counters:0 um:zero minimum:1000 name:PM_MRK_LD_MISS_L1_LSU0_GRP36 : (GRP36 Load Store Unit Marked Events2) Marked load executing on unit 0 missed the dcache +event:0x79 counters:1 um:zero minimum:1000 name:PM_MRK_LD_MISS_L1_LSU1_GRP36 : (GRP36 Load Store Unit Marked Events2) Marked load executing on unit 1 missed the dcache +event:0x7a counters:2 um:zero minimum:1000 name:PM_MRK_LSU0_FLUSH_LRQ_GRP36 : (GRP36 Load Store Unit Marked Events2) Marked load was flushed by unit 0 because a younger load executed before an older store executed and they had overlapping data OR two loads executed out of order and they have byte overlap and there was a snoop in between to an overlapped byte +event:0x7b counters:3 um:zero minimum:1000 name:PM_MRK_LSU1_FLUSH_LRQ_GRP36 : (GRP36 Load Store Unit Marked Events2) Marked load was flushed by unit 1 because a younger load executed before an older store executed and they had overlapping data OR two loads executed out of order and they have byte overlap and there was a snoop in between to an overlapped byte +event:0x7c counters:4 um:zero minimum:10000 name:PM_CYC_GRP36 : (GRP36 Load Store Unit Marked Events2) Processor cycles +event:0x7d counters:5 um:zero minimum:10000 name:PM_INST_CMPL_GRP36 : (GRP36 Load Store Unit Marked Events2) Instructions completed +event:0x7e counters:6 um:zero minimum:1000 name:PM_MRK_LSU0_FLUSH_SRQ_GRP36 : (GRP36 Load Store Unit Marked Events2) A marked store was flushed because younger load hits and older store that is already in the SRQ or in the same group +event:0x7f counters:7 um:zero minimum:1000 name:PM_MRK_LSU1_FLUSH_SRQ_GRP36 : (GRP36 Load Store Unit Marked Events2) A marked store was flushed because younger load hits and older store that is already in the SRQ or in the same group + + diff --git a/events/ppc64/970/unit_masks b/events/ppc64/970/unit_masks new file mode 100644 index 0000000..3aabdca --- /dev/null +++ b/events/ppc64/970/unit_masks @@ -0,0 +1,4 @@ +# ppc64 970 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/ppc64/power4/event_mappings b/events/ppc64/power4/event_mappings new file mode 100644 index 0000000..24ef0b6 --- /dev/null +++ b/events/ppc64/power4/event_mappings @@ -0,0 +1,76 @@ +#Group Default +event:0x1 mmcr0:0x00000D0E mmcr1:0x000000004A5675AC mmcra:0x00022001 + +#Group 1 pm_slice0 +event:0x10 mmcr0:0x00000D0E mmcr1:0x000000004A5675AC mmcra:0x00022001 +event:0x11 mmcr0:0x00000D0E mmcr1:0x000000004A5675AC mmcra:0x00022001 +event:0x13 mmcr0:0x00000D0E mmcr1:0x000000004A5675AC mmcra:0x00022001 + +#Group 2 pm_basic +event:0x20 mmcr0:0x0000090E mmcr1:0x1003400045F29420 mmcra:0x00002001 +event:0x21 mmcr0:0x0000090E mmcr1:0x1003400045F29420 mmcra:0x00002001 +event:0x22 mmcr0:0x0000090E mmcr1:0x1003400045F29420 mmcra:0x00002001 +event:0x23 mmcr0:0x0000090E mmcr1:0x1003400045F29420 mmcra:0x00002001 +event:0x24 mmcr0:0x0000090E mmcr1:0x1003400045F29420 mmcra:0x00002001 +event:0x25 mmcr0:0x0000090E mmcr1:0x1003400045F29420 mmcra:0x00002001 +event:0x26 mmcr0:0x0000090E mmcr1:0x1003400045F29420 mmcra:0x00002001 + +#Group 3 pm_lsource +event:0x30 mmcr0:0x00000E1C mmcr1:0x0010C000739CE738 mmcra:0x00002001 +event:0x31 mmcr0:0x00000E1C mmcr1:0x0010C000739CE738 mmcra:0x00002001 +event:0x32 mmcr0:0x00000E1C mmcr1:0x0010C000739CE738 mmcra:0x00002001 +event:0x33 mmcr0:0x00000E1C mmcr1:0x0010C000739CE738 mmcra:0x00002001 +event:0x34 mmcr0:0x00000E1C mmcr1:0x0010C000739CE738 mmcra:0x00002001 +event:0x35 mmcr0:0x00000E1C mmcr1:0x0010C000739CE738 mmcra:0x00002001 +event:0x36 mmcr0:0x00000E1C mmcr1:0x0010C000739CE738 mmcra:0x00002001 +event:0x37 mmcr0:0x00000E1C mmcr1:0x0010C000739CE738 mmcra:0x00002001 + +#Group 4 pm_lsource2 +event:0x40 mmcr0:0x00000938 mmcr1:0x0010C0003B9CE738 mmcra:0x00002001 +event:0x41 mmcr0:0x00000938 mmcr1:0x0010C0003B9CE738 mmcra:0x00002001 +event:0x42 mmcr0:0x00000938 mmcr1:0x0010C0003B9CE738 mmcra:0x00002001 +event:0x43 mmcr0:0x00000938 mmcr1:0x0010C0003B9CE738 mmcra:0x00002001 +event:0x44 mmcr0:0x00000938 mmcr1:0x0010C0003B9CE738 mmcra:0x00002001 +event:0x45 mmcr0:0x00000938 mmcr1:0x0010C0003B9CE738 mmcra:0x00002001 +event:0x46 mmcr0:0x00000938 mmcr1:0x0010C0003B9CE738 mmcra:0x00002001 +event:0x47 mmcr0:0x00000938 mmcr1:0x0010C0003B9CE738 mmcra:0x00002001 + +#Group 5 pm_lsource3 +event:0x50 mmcr0:0x00000E1C mmcr1:0x0010C00073B87724 mmcra:0x00002001 +event:0x51 mmcr0:0x00000E1C mmcr1:0x0010C00073B87724 mmcra:0x00002001 +event:0x52 mmcr0:0x00000E1C mmcr1:0x0010C00073B87724 mmcra:0x00002001 +event:0x53 mmcr0:0x00000E1C mmcr1:0x0010C00073B87724 mmcra:0x00002001 +event:0x54 mmcr0:0x00000E1C mmcr1:0x0010C00073B87724 mmcra:0x00002001 +event:0x55 mmcr0:0x00000E1C mmcr1:0x0010C00073B87724 mmcra:0x00002001 +event:0x56 mmcr0:0x00000E1C mmcr1:0x0010C00073B87724 mmcra:0x00002001 +event:0x57 mmcr0:0x00000E1C mmcr1:0x0010C00073B87724 mmcra:0x00002001 + +#Group 6 pm_isource +event:0x60 mmcr0:0x00000F1E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x61 mmcr0:0x00000F1E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x62 mmcr0:0x00000F1E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x63 mmcr0:0x00000F1E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x64 mmcr0:0x00000F1E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x65 mmcr0:0x00000F1E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x66 mmcr0:0x00000F1E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x67 mmcr0:0x00000F1E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 + +#Group 7 pm_isource2 +event:0x70 mmcr0:0x0000090E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x71 mmcr0:0x0000090E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x72 mmcr0:0x0000090E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x73 mmcr0:0x0000090E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x74 mmcr0:0x0000090E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x75 mmcr0:0x0000090E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x76 mmcr0:0x0000090E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 +event:0x77 mmcr0:0x0000090E mmcr1:0x800000007BDEF7BC mmcra:0x00002201 + +#Group 8 pm_isource3 +event:0x80 mmcr0:0x00000F1E mmcr1:0x800000007BDEF3A4 mmcra:0x00002201 +event:0x81 mmcr0:0x00000F1E mmcr1:0x800000007BDEF3A4 mmcra:0x00002201 +event:0x82 mmcr0:0x00000F1E mmcr1:0x800000007BDEF3A4 mmcra:0x00002201 +event:0x83 mmcr0:0x00000F1E mmcr1:0x800000007BDEF3A4 mmcra:0x00002201 +event:0x84 mmcr0:0x00000F1E mmcr1:0x800000007BDEF3A4 mmcra:0x00002201 +event:0x85 mmcr0:0x00000F1E mmcr1:0x800000007BDEF3A4 mmcra:0x00002201 +event:0x86 mmcr0:0x00000F1E mmcr1:0x800000007BDEF3A4 mmcra:0x00002201 +event:0x87 mmcr0:0x00000F1E mmcr1:0x800000007BDEF3A4 mmcra:0x00002201 diff --git a/events/ppc64/power4/events b/events/ppc64/power4/events new file mode 100644 index 0000000..60d01bf --- /dev/null +++ b/events/ppc64/power4/events @@ -0,0 +1,89 @@ +# ppc64 POWER4 events +# +# Within each group the event names must be unique. Each event in a group is +# assigned to a unique counter. The groups are from the groups defined in the +# power 4 manual. +# +# Only events within the same group can be selected simultaneously +# Each event is given a unique event number. The event number is used by the +# Oprofile code to resolve event names for the postprocessing. This is done +# to preserve compatibility with the rest of the Oprofile code. The event +# number format group_num followed by the counter number for the event within +# the group. The event number must be between 0 and 255. + +#Group Default +event:0x1 counters:1 um:zero minimum:10000 name:CYCLES : Processor Cycles + +#Group 1 pm_slice0 +event:0x10 counters:0 um:zero minimum:10000 name:PM_RUN_CYC_GRP1 : (Group 1 pm_slice0) Processor Cycles gated by the run latch +event:0x11 counters:1 um:zero minimum:10000 name:PM_CYC_GRP1 : (Group 1 pm_slice0) Processor Cycles +event:0x13 counters:3 um:zero minimum:10000 name:PM_INST_CMPL_GRP1 : (Group 1 pm_slice0) Number of eligible instructions that completed + +#Group 2 pm_basic +event:0x20 counters:0 um:zero minimum:10000 name:PM_INST_CMPL_GRP2 : (Group 2 pm_basic) Instrucitons completed +event:0x21 counters:1 um:zero minimum:10000 name:PM_CYC_GRP2 : (Group 2 pm_basic) Processor cycles +event:0x22 counters:2 um:zero minimum:5000 name:PM_LD_MISS_1_GRP2 : (Group 2 pm_basic) Total DL1 load references that miss the DL1 +event:0x23 counters:3 um:zero minimum:5000 name:PM_DC_INV_L2_GRP2 : (Group 2 pm_basic) A Dcache invalidated was received from the L2 because a line in L2 was castout +event:0x24 counters:4 um:zero minimum:5000 name:PM_INST_DISP_GRP2 : (Group 2 pm_basic) The ISU sends the number of instructions dispatched +event:0x25 counters:6 um:zero minimum:5000 name:PM_ST_REF_L1_GRP2 : (Group 2 pm_basic) Total DL1 store references +event:0x26 counters:7 um:zero minimum:5000 name:PM_LD_REF_L1_GRP2 : (Group 2 pm_basic) Total DL1 load references + +#Group 3 pm_lsource +event:0x30 counters:0 um:zero minimum:1000 name:PM_DATA_FROM_L3_GRP3 : (Group 3 pm_lsource) Data loaded from L3 due to a demand load +event:0x31 counters:1 um:zero minimum:1000 name:PM_DATA_FROM_MEM_GRP3 : (Group 3 pm_lsource) Data loaded from MEM due to a demand load +event:0x32 counters:2 um:zero minimum:1000 name:PM_DATA_FROM_L3.5_GRP3 : (Group 3 pm_lsource) Data loaded from L3 of another MCM due to a demand load +event:0x33 counters:3 um:zero minimum:1000 name:PM_DATA_FROM_L2_GRP3 : (Group 3 pm_lsource) Data loaded from L2 due to a demand load +event:0x34 counters:4 um:zero minimum:1000 name:PM_DATA_FROM_L25_SHR_GRP3 : (Group 3 pm_lsource) Data reloaded with shared (T) data from the L2 of a chip on this MCM due to a demand load +event:0x35 counters:5 um:zero minimum:1000 name:PM_DATA_FROM_L275_SHR_GRP3 : (Group 3 pm_lsource) Data reloaded with shared (T) data from the another MCM due to a demand load +event:0x36 counters:6 um:zero minimum:1000 name:PM_DATA_FROM_L275_MOD_GRP3 : (Group 3 pm_lsource) Data reloaded with modified (M) data from the another MCM due to a demand load +event:0x37 counters:7 um:zero minimum:1000 name:PM_DATA_FROM_L25_MOD_GRP3 : (Group 3 pm_lsource) Data reloaded with modified (M) data from the L2 of a chip on this MCM due to a demand load + +#Group 4 pm_lsource2 +event:0x40 counters:0 um:zero minimum:10000 name:PM_INST_CMPL_GRP4 : (Group 4 pm_lsource2) Number of Eligible Instructions that completed +event:0x41 counters:1 um:zero minimum:1000 name:PM_L2_DCACHE_RELOAD_VALID_GRP4 : (Group 4 pm_lsource2) The data source information is valid +event:0x42 counters:2 um:zero minimum:10000 name:PM_CYC_GRP4 : (Group 4 pm_lsource2) Processor Cycles +event:0x43 counters:3 um:zero minimum:1000 name:PM_DATA_FROM_L2_GRP4 : (Group 4 pm_lsource2) DL1 was reloaded from the local L2 due to a demand load +event:0x44 counters:4 um:zero minimum:1000 name:PM_DATA_FROM_L25_SH_GRP4 : (Group 4 pm_lsource2) Data reloaded with shared (T) data from the L2 of a chip on this MCM due to a demand load +event:0x45 counters:5 um:zero minimum:1000 name:PM_DATA_FROM_L275_SHR_GRP4 : (Group 4 pm_lsource2) Data reloaded with shared (T) data from the another MCM due to a demand load +event:0x46 counters:6 um:zero minimum:1000 name:PM_DATA_FROM_L275_MOD_GRP4 : (Group 4 pm_lsource2) Data reloaded with modified (M) data from the another MCM due to a demand load +event:0x47 counters:7 um:zero minimum:1000 name:PM_DATA_FROM_L25_MOD_GRP4 : (Group 4 pm_lsource2) Data reloaded with modified (M) data from the L2 of a chip on this MCM due to a demand load + +#Group 5 pm_lsource3 +event:0x50 counters:0 um:zero minimum:1000 name:PM_DATA_FROM_L3_GRP5 : (Group 5 pm_lsource3) Data loaded from L3 +event:0x51 counters:1 um:zero minimum:1000 name:PM_DATA_FROM_MEM_GRP5 : (Group 5 pm_lsource3) Data loaded from memory +event:0x52 counters:2 um:zero minimum:1000 name:PM_DATA_FROM_L35_GRP5 : (Group 5 pm_lsource3) Data loaded from L3 of another MCM +event:0x53 counters:3 um:zero minimum:1000 name:PM_DATA_FROM_L2_GRP5 : (Group 5 pm_lsource3) Data loaded from L2 +event:0x54 counters:4 um:zero minimum:1000 name:PM_L1_DCACHE_RELOAD_GRP5 : (Group 5 pm_lsource3) L1 reloaded data source valid +event:0x55 counters:5 um:zero minimum:10000 name:PM_CYC_GRP5 : (Group 5 pm_lsource3) Processor Cycles +event:0x56 counters:6 um:zero minimum:1000 name:PM_DATA_FROM_L275_MOD_GRP5 : (Group 5 pm_lsource3) Data loaded from L2 of another MCM +event:0x57 counters:7 um:zero minimum:10000 name:PM_INST_CMPL_GRP5 : (Group 5 pm_lsource3) Instructions completed + +#Group 6 pm_isource +event:0x60 counters:0 um:zero minimum:1000 name:PM_INST_FROM_MEM_GRP6 : (Group 6 pm_isource) Instruction fetched from memory +event:0x61 counters:1 um:zero minimum:1000 name:PM_INST_FROM_L25_L275_GRP6 : (Group 6 pm_isource) Instruction fetched from L2 of another chip +event:0x62 counters:2 um:zero minimum:1000 name:PM_INST_FROM_L2_GRP6 : (Group 6 pm_isource) Instructions fetched from L2 +event:0x63 counters:3 um:zero minimum:1000 name:PM_INST_FROM_L35_GRP6 : (Group 6 pm_isource) Instructions fetched from L3 of another module +event:0x64 counters:4 um:zero minimum:1000 name:PM_INST_FROM_L3_GRP6 : (Group 6 pm_isource) Instructions fetched from L3 +event:0x65 counters:5 um:zero minimum:1000 name:PM_INST_FROM_L1_GRP6 : (Group 6 pm_isource) Instructions fetched from L1 +event:0x66 counters:6 um:zero minimum:1000 name:PM_INST_FROM_PREF_GRP6 : (Group 6 pm_isource) Instructions fetched from prefetch +event:0x67 counters:7 um:zero minimum:1000 name:PM_0INST_FETCH_GRP6 : (Group 6 pm_isource) No instructions fetched + +#Group 7 pm_isource2 +event:0x70 counters:0 um:zero minimum:10000 name:PM_INST_CMPL_GRP7 : (Group 7 pm_isource) Instructions completed +event:0x71 counters:1 um:zero minimum:10000 name:PM_CYC_GRP7 : (Group 7 pm_isource) Processor cycles +event:0x72 counters:2 um:zero minimum:1000 name:PM_INST_FROM_L2_GRP7 : (Group 7 pm_isource) Instructions fetched from L2 +event:0x73 counters:3 um:zero minimum:1000 name:PM_INST_FROM_L35_GRP7 : (Group 7 pm_isource) Instructions fetched from L3 of another module +event:0x74 counters:4 um:zero minimum:1000 name:PM_INST_FROM_L3_GRP7 : (Group 7 pm_isource) Instructions fetched from L3 +event:0x75 counters:5 um:zero minimum:1000 name:PM_INST_FROM_L1_GRP7 : (Group 7 pm_isource) Instructions fetched from L1 +event:0x76 counters:6 um:zero minimum:1000 name:PM_INST_FROM_PREF_GRP7 : (Group 7 pm_isource) Instructions fetched from prefetch +event:0x77 counters:7 um:zero minimum:1000 name:PM_0INST_FETCH_GRP7 : (Group 7 pm_isource) No instructions fetched + +#Group 8 pm_isource3 +event:0x80 counters:0 um:zero minimum:1000 name:PM_INST_FROM_MEM_GRP8 : (Group 8 pm_isource) Instruction fetched from memory +event:0x81 counters:1 um:zero minimum:1000 name:PM_INST_FROM_L25_L275_GRP8 : (Group 8 pm_isource) Instruction fetched from L2 of another chip +event:0x82 counters:2 um:zero minimum:1000 name:PM_INST_FROM_L2_GRP8 : (Group 8 pm_isource) Instructions fetched from L2 +event:0x83 counters:3 um:zero minimum:1000 name:PM_INST_FROM_L35_GRP8 : (Group 8 pm_isource) Instructions fetched from L3 of another module +event:0x84 counters:4 um:zero minimum:1000 name:PM_INST_FROM_L3_GRP8 : (Group 8 pm_isource) Instructions fetched from L3 +event:0x85 counters:5 um:zero minimum:1000 name:PM_INST_FROM_L1_GRP8 : (Group 8 pm_isource) Instructions fetched from L1 +event:0x86 counters:6 um:zero minimum:10000 name:PM_CYC_GRP8 : (Group 8 pm_isource) Processor cycles +event:0x87 counters:7 um:zero minimum:10000 name:PM_INST_CMPL_GRP8 : (Group 8 pm_isource) Instructions completed diff --git a/events/ppc64/power4/unit_masks b/events/ppc64/power4/unit_masks new file mode 100644 index 0000000..7643f05 --- /dev/null +++ b/events/ppc64/power4/unit_masks @@ -0,0 +1,5 @@ +# ppc64 POWER4 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask + diff --git a/events/ppc64/power5/event_mappings b/events/ppc64/power5/event_mappings new file mode 100644 index 0000000..39856d2 --- /dev/null +++ b/events/ppc64/power5/event_mappings @@ -0,0 +1,130 @@ +#Group Default +event:0x001 mmcr0:0x0400C000 mmcr1:0x4000000002341E36 mmcra:0x00000001 + +#Group 9 LSU SRQ and LMQ events +event:0x010 mmcr0:0x0400C000 mmcr1:0x010F000A102ACA2A mmcra:0x00000000 +event:0x011 mmcr0:0x0400C000 mmcr1:0x010F000A102ACA2A mmcra:0x00000000 +event:0x012 mmcr0:0x0400C000 mmcr1:0x010F000A102ACA2A mmcra:0x00000000 +event:0x013 mmcr0:0x0400C000 mmcr1:0x010F000A102ACA2A mmcra:0x00000000 +event:0x014 mmcr0:0x0400C000 mmcr1:0x010F000A102ACA2A mmcra:0x00000000 +event:0x015 mmcr0:0x0400C000 mmcr1:0x010F000A102ACA2A mmcra:0x00000000 + +#Group 13 Misc prefetch and reject events +event:0x01a mmcr0:0x0400C000 mmcr1:0x063E000EC0C8CC86 mmcra:0x00000000 +event:0x01b mmcr0:0x0400C000 mmcr1:0x063E000EC0C8CC86 mmcra:0x00000000 +event:0x01c mmcr0:0x0400C000 mmcr1:0x063E000EC0C8CC86 mmcra:0x00000000 +event:0x01d mmcr0:0x0400C000 mmcr1:0x063E000EC0C8CC86 mmcra:0x00000000 +event:0x01e mmcr0:0x0400C000 mmcr1:0x063E000EC0C8CC86 mmcra:0x00000000 +event:0x01f mmcr0:0x0400C000 mmcr1:0x063E000EC0C8CC86 mmcra:0x00000000 + +#Group 14 LSU reject events +event:0x020 mmcr0:0x0400C000 mmcr1:0xC22C000E2010C610 mmcra:0x00000001 +event:0x021 mmcr0:0x0400C000 mmcr1:0xC22C000E2010C610 mmcra:0x00000001 +event:0x022 mmcr0:0x0400C000 mmcr1:0xC22C000E2010C610 mmcra:0x00000001 +event:0x023 mmcr0:0x0400C000 mmcr1:0xC22C000E2010C610 mmcra:0x00000001 +event:0x024 mmcr0:0x0400C000 mmcr1:0xC22C000E2010C610 mmcra:0x00000001 +event:0x025 mmcr0:0x0400C000 mmcr1:0xC22C000E2010C610 mmcra:0x00000001 + +#Group 43 L1 load and TLB misses +event:0x02b mmcr0:0x0400C000 mmcr1:0x00B000008E881020 mmcra:0x00000000 +event:0x02c mmcr0:0x0400C000 mmcr1:0x00B000008E881020 mmcra:0x00000000 +event:0x02d mmcr0:0x0400C000 mmcr1:0x00B000008E881020 mmcra:0x00000000 +event:0x02e mmcr0:0x0400C000 mmcr1:0x00B000008E881020 mmcra:0x00000000 +event:0x02f mmcr0:0x0400C000 mmcr1:0x00B000008E881020 mmcra:0x00000000 + +#Group 44 L1 store and DERAT misses +event:0x030 mmcr0:0x0400C000 mmcr1:0x00B300000E202086 mmcra:0x00000000 +event:0x031 mmcr0:0x0400C000 mmcr1:0x00B300000E202086 mmcra:0x00000000 +event:0x033 mmcr0:0x0400C000 mmcr1:0x00B300000E202086 mmcra:0x00000000 +event:0x034 mmcr0:0x0400C000 mmcr1:0x00B300000E202086 mmcra:0x00000000 +event:0x035 mmcr0:0x0400C000 mmcr1:0x00B300000E202086 mmcra:0x00000000 + +#Group 45 L1 load and SLB misses +event:0x03a mmcr0:0x0400C000 mmcr1:0x00B000008A82848C mmcra:0x00000000 +event:0x03b mmcr0:0x0400C000 mmcr1:0x00B000008A82848C mmcra:0x00000000 +event:0x03c mmcr0:0x0400C000 mmcr1:0x00B000008A82848C mmcra:0x00000000 +event:0x03d mmcr0:0x0400C000 mmcr1:0x00B000008A82848C mmcra:0x00000000 +event:0x03e mmcr0:0x0400C000 mmcr1:0x00B000008A82848C mmcra:0x00000000 +event:0x03f mmcr0:0x0400C000 mmcr1:0x00B000008A82848C mmcra:0x00000000 + +#Group 46 L1 load references and 4k Data TLB references and misses +event:0x040 mmcr0:0x0400C000 mmcr1:0x0BF0000084808088 mmcra:0x00000000 +event:0x041 mmcr0:0x0400C000 mmcr1:0x0BF0000084808088 mmcra:0x00000000 +event:0x042 mmcr0:0x0400C000 mmcr1:0x0BF0000084808088 mmcra:0x00000000 +event:0x043 mmcr0:0x0400C000 mmcr1:0x0BF0000084808088 mmcra:0x00000000 +event:0x044 mmcr0:0x0400C000 mmcr1:0x0BF0000084808088 mmcra:0x00000000 +event:0x045 mmcr0:0x0400C000 mmcr1:0x0BF0000084808088 mmcra:0x00000000 + +#Group 47 L1 store references and 16M Data TLB references and misses +event:0x04a mmcr0:0x0400C000 mmcr1:0x0BF000008C88828A mmcra:0x00000000 +event:0x04b mmcr0:0x0400C000 mmcr1:0x0BF000008C88828A mmcra:0x00000000 +event:0x04c mmcr0:0x0400C000 mmcr1:0x0BF000008C88828A mmcra:0x00000000 +event:0x04d mmcr0:0x0400C000 mmcr1:0x0BF000008C88828A mmcra:0x00000000 +event:0x04e mmcr0:0x0400C000 mmcr1:0x0BF000008C88828A mmcra:0x00000000 +event:0x04f mmcr0:0x0400C000 mmcr1:0x0BF000008C88828A mmcra:0x00000000 + +#Group 48 L3 cache and memory data access +event:0x050 mmcr0:0x0400C000 mmcr1:0x400300001C0E8E02 mmcra:0x00000000 +event:0x051 mmcr0:0x0400C000 mmcr1:0x400300001C0E8E02 mmcra:0x00000000 +event:0x052 mmcr0:0x0400C000 mmcr1:0x400300001C0E8E02 mmcra:0x00000000 +event:0x053 mmcr0:0x0400C000 mmcr1:0x400300001C0E8E02 mmcra:0x00000000 +event:0x054 mmcr0:0x0400C000 mmcr1:0x400300001C0E8E02 mmcra:0x00000000 +event:0x055 mmcr0:0x0400C000 mmcr1:0x400300001C0E8E02 mmcra:0x00000000 + +#Group 49 L3 cacahe and memory data access +event:0x05a mmcr0:0x0400C000 mmcr1:0x000300031C0E360E mmcra:0x00000000 +event:0x05b mmcr0:0x0400C000 mmcr1:0x000300031C0E360E mmcra:0x00000000 +event:0x05c mmcr0:0x0400C000 mmcr1:0x000300031C0E360E mmcra:0x00000000 +event:0x05d mmcr0:0x0400C000 mmcr1:0x000300031C0E360E mmcra:0x00000000 +event:0x05e mmcr0:0x0400C000 mmcr1:0x000300031C0E360E mmcra:0x00000000 +event:0x05f mmcr0:0x0400C000 mmcr1:0x000300031C0E360E mmcra:0x00000000 + +#Group 50 L2 cache data access +event:0x060 mmcr0:0x0400C000 mmcr1:0x000300032E2E2E2E mmcra:0x00000000 +event:0x061 mmcr0:0x0400C000 mmcr1:0x000300032E2E2E2E mmcra:0x00000000 +event:0x062 mmcr0:0x0400C000 mmcr1:0x000300032E2E2E2E mmcra:0x00000000 +event:0x063 mmcr0:0x0400C000 mmcr1:0x000300032E2E2E2E mmcra:0x00000000 +event:0x064 mmcr0:0x0400C000 mmcr1:0x000300032E2E2E2E mmcra:0x00000000 +event:0x065 mmcr0:0x0400C000 mmcr1:0x000300032E2E2E2E mmcra:0x00000000 + +#Group 51 L3 cache data access +event:0x06a mmcr0:0x0400C000 mmcr1:0x000300033C3C3C3C mmcra:0x00000000 +event:0x06b mmcr0:0x0400C000 mmcr1:0x000300033C3C3C3C mmcra:0x00000000 +event:0x06c mmcr0:0x0400C000 mmcr1:0x000300033C3C3C3C mmcra:0x00000000 +event:0x06d mmcr0:0x0400C000 mmcr1:0x000300033C3C3C3C mmcra:0x00000000 +event:0x06e mmcr0:0x0400C000 mmcr1:0x000300033C3C3C3C mmcra:0x00000000 +event:0x06f mmcr0:0x0400C000 mmcr1:0x000300033C3C3C3C mmcra:0x00000000 + +#Group 52 Instruction source information +event:0x070 mmcr0:0x0400C000 mmcr1:0x8000000C1A1A1A0C mmcra:0x00000000 +event:0x071 mmcr0:0x0400C000 mmcr1:0x8000000C1A1A1A0C mmcra:0x00000000 +event:0x072 mmcr0:0x0400C000 mmcr1:0x8000000C1A1A1A0C mmcra:0x00000000 +event:0x073 mmcr0:0x0400C000 mmcr1:0x8000000C1A1A1A0C mmcra:0x00000000 +event:0x074 mmcr0:0x0400C000 mmcr1:0x8000000C1A1A1A0C mmcra:0x00000000 +event:0x075 mmcr0:0x0400C000 mmcr1:0x8000000C1A1A1A0C mmcra:0x00000000 + +#Group 54 L2 instruction source information +event:0x07a mmcr0:0x0400C000 mmcr1:0x8000000C2C2C2C2C mmcra:0x00000000 +event:0x07b mmcr0:0x0400C000 mmcr1:0x8000000C2C2C2C2C mmcra:0x00000000 +event:0x07c mmcr0:0x0400C000 mmcr1:0x8000000C2C2C2C2C mmcra:0x00000000 +event:0x07d mmcr0:0x0400C000 mmcr1:0x8000000C2C2C2C2C mmcra:0x00000000 +event:0x07e mmcr0:0x0400C000 mmcr1:0x8000000C2C2C2C2C mmcra:0x00000000 +event:0x07f mmcr0:0x0400C000 mmcr1:0x8000000C2C2C2C2C mmcra:0x00000000 + +#Group 55 L3 instruction source information +event:0x080 mmcr0:0x0400C000 mmcr1:0x8000000C3A3A3A3A mmcra:0x00000000 +event:0x081 mmcr0:0x0400C000 mmcr1:0x8000000C3A3A3A3A mmcra:0x00000000 +event:0x082 mmcr0:0x0400C000 mmcr1:0x8000000C3A3A3A3A mmcra:0x00000000 +event:0x083 mmcr0:0x0400C000 mmcr1:0x8000000C3A3A3A3A mmcra:0x00000000 +event:0x084 mmcr0:0x0400C000 mmcr1:0x8000000C3A3A3A3A mmcra:0x00000000 +event:0x085 mmcr0:0x0400C000 mmcr1:0x8000000C3A3A3A3A mmcra:0x00000000 + +#Group 123 Marked TLB and SLB misses +event:0x08d mmcr0:0x0400C000 mmcr1:0x0CF00000828A8C8E mmcra:0x00000001 +event:0x08e mmcr0:0x0400C000 mmcr1:0x0CF00000828A8C8E mmcra:0x00000001 +event:0x08f mmcr0:0x0400C000 mmcr1:0x0CF00000828A8C8E mmcra:0x00000001 + +#Group 126 Mark unaligned load and store flushes +event:0x093 mmcr0:0x0400C000 mmcr1:0x0028000406C62020 mmcra:0x00000001 +event:0x094 mmcr0:0x0400C000 mmcr1:0x0028000406C62020 mmcra:0x00000001 +event:0x095 mmcr0:0x0400C000 mmcr1:0x0028000406C62020 mmcra:0x00000001 diff --git a/events/ppc64/power5/events b/events/ppc64/power5/events new file mode 100644 index 0000000..b08c028 --- /dev/null +++ b/events/ppc64/power5/events @@ -0,0 +1,145 @@ +# ppc64 POWER5 events +# +# Within each group the event names must be unique. Each event in a group is +# assigned to a unique counter. The groups are from the groups defined in the +# power5.evs and power5.gps files. +# +# Only events within the same group can be selected simultaneously +# Each event is given a unique event number. The event number is used by the +# Oprofile code to resolve event names for the postprocessing. This is done to +# preserve compatibility with the rest of the Oprofile code. The event +# number format group_num followed by the counter number for the event within +# the group. +# +# The maximum event number is 0x100. Oprofile numbers the counters 0-5. + +#Group Default +event:0x001 counters:2 um:zero minimum:10000 name:CYCLES : Processor cycles + +#Group 9 LSU SRQ and LMQ events +event:0x010 counters:0 um:zero minimum:1000 name:PM_DTLB_MISS_GP9 : A TLB miss for a data request occurred +event:0x011 counters:1 um:zero minimum:1000 name:PM_DC_PREF_L2_CLONE_L3_GP9 : L2 prefetch cloned with L3 +event:0x012 counters:2 um:zero minimum:1000 name:PM_LSU_LMQ_LHR_MERGE_GP9 : Dcache miss occured for the same real cache line as earlier req, merged into LMQ +event:0x013 counters:3 um:zero minimum:1000 name:PM_LSU_SRQ_EMPTY_CYC_GP9 : Cycles Store Req Queue empty +event:0x014 counters:4 um:zero minimum:10000 name:PM_INST_CMPL_GP9 : Number of PPC inst completed +event:0x015 counters:5 um:zero minimum:10000 name:PM_RUN_CYC_GP9 : Proc cycles gated by the run latch + +#Group 13 Misc prefetch and reject events +event:0x01a counters:0 um:zero minimum:1000 name:PM_LSU0_REJECT_SRQ_LHS_G13 : LSU0 reject due to load hit store +event:0x01b counters:1 um:zero minimum:1000 name:PM_DATA_FROM_L25_MOD_G13 : DL1 reloaded with modified data from L2 within this MCM +event:0x01c counters:2 um:zero minimum:1000 name:PM_DC_PREF_L2_CLONE_L3_G13 : L2 prefetch cloned with L3 +event:0x01d counters:3 um:zero minimum:1000 name:PM_L2_PREF_G13 : L2 cacahe prefetchs +event:0x01e counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G13 : Number of PPC instructions completed +event:0x01f counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G13 : Processor cycles gated by run latch + +#Group 14 LSU reject events +event:0x020 counters:0 um:zero minimum:1000 name:PM_DATA_FROM_L35_MOD_G14 : Data loaded from l3.5 modified +event:0x021 counters:1 um:zero minimum:1000 name:PM_EE_OFF_EXT_INT_G14 : Cycles MSR (EE) bit off and external interupt pending +event:0x022 counters:2 um:zero minimum:1000 name:PM_FLUSH_IMBAL_G14 : Flush caused by thread GCT imbalance +event:0x023 counters:3 um:zero minimum:1000 name:PM_MRK_LSU_FLUSH_SRQ_G14 : Marked SRQ flushes +event:0x024 counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G14 : Instructions completed +event:0x025 counters:5 um:zero minimum:10000 name:PM_RUN_CYCLES_G14 : Processor cycles gated by run latch + +#Group 43 L1 load and TLB misses +event:0x02b counters:1 um:zero minimum:1000 name:PM_DTLB_MISS_G43 : Data TLB miss occurred +event:0x02c counters:2 um:zero minimum:1000 name:PM_LD_MISS_L1_G43 : L1 D cache load miss +event:0x02d counters:3 um:zero minimum:1000 name:PM_LD_REF_L1_G43 : L1 D cache load references +event:0x02e counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G43 : PPC instructions completed +event:0x02f counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G43 : Processor cycles gated by run latch + +#Group 44 L1 store and DERAT misses +event:0x030 counters:0 um:zero minimum:1000 name:PM_DATA_FROM_L2_G44 : Data loaded from L2 +event:0x031 counters:1 um:zero minimum:1000 name:PM_DATA_FROM_L35_G44 : Data loaded from L3.5 modified +event:0x033 counters:3 um:zero minimum:1000 name:PM_ST_MISS_L1_G44 : L1 D cache store misses +event:0x034 counters:4 um:zero minimum:10000 name:PM_PM_INST_CMPL_G44 : PPC instructions completed +event:0x035 counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G44 : Processor cycles gated by the run latch + +#group 45 L1 load and SLB misses +event:0x03a counters:0 um:zero minimum:1000 name:PM_DSLB_MISS_G45 : Data SLB misses +event:0x03b counters:1 um:zero minimum:1000 name:PM_ISLB_MISS_G45 : Instruction SLB misses +event:0x03c counters:2 um:zero minimum:1000 name:PM_LD_MISS_L1_LSU0_G45 : LSU0 L1 D cache load misses +event:0x03d counters:3 um:zero minimum:1000 name:PM_LD_MISS_L1_LSU1_G45 : LSU1 L1 D cache load misses +event:0x03e counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G45 : PPC instructions completed +event:0x03f counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G45 : Processor cycles gated by the run latch + +#Group 46 L1 load references and 4k Data TLB references and misses +event:0x040 counters:0 um:zero minimum:1000 name:PM_DTLB_REF_4K_G46 : Data TLB reference for 4K page +event:0x041 counters:1 um:zero minimum:1000 name:PM_DTLB_MISS_4K_G46 : Data TLB miss for 4K page +event:0x042 counters:2 um:zero minimum:1000 name:PM_LD_REF_L1_LSU0_G46 : LSU0 L1 D cache load references +event:0x043 counters:3 um:zero minimum:1000 name:PM_LD_REF_L1_LSU1_G46 : LSU1 L1 D cache load references +event:0x044 counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G46 : PPC instructions completed +event:0x045 counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G46 : Processor cycles gated by the run latch + +#Group 47 L1 store references and 16M Data TLB references and misses +event:0x04a counters:0 um:zero minimum:1000 name:PM_DTLB_REF_G47 : Data TLB reference for 16M page +event:0x04b counters:1 um:zero minimum:1000 name:PM_DTLB_MISS_G47 : Data TLB miss for 16M page +event:0x04c counters:2 um:zero minimum:1000 name:PM_FPU0_FRSP_FCONV_G47 : FPU0 executed FRSP or FCONV instructions +event:0x04d counters:3 um:zero minimum:1000 name:PM_ST_REF_L1_LSU1_G47 : LSU1 L1 Dcache store references +event:0x04e counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G47 : PPC instructions completed +event:0x04f counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G47 : Processor cycles gated by the run latch + +#Group 48 L3 cache and memory data access +event:0x050 counters:0 um:zero minimum:1000 name:PM_DATA_FROM_L3_G48 : Data loaded from L3 +event:0x051 counters:1 um:zero minimum:1000 name:PM_DATA_FROM_LMEM_G48 : Data loaded from local memory +event:0x052 counters:2 um:zero minimum:1000 name:PM_FLUSH_G48 : Flushes +event:0x053 counters:3 um:zero minimum:1000 name:PM_EINST_CMPL_G48 : Eligible instructions that completed +event:0x054 counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G48 : PPC instructiions completed +event:0x055 counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G48 : Processor cycles gated by the run latch + +#Group 49 L3 cacahe and memory data access +event:0x05a counters:0 um:zero minimum:1000 name:PM_DATA_FROM_L3_G49 : Data loaded from L3 +event:0x05b counters:1 um:zero minimum:1000 name:PM_DATA_FROM_LMEM_G49 : Data loaded from Memory +event:0x05c counters:2 um:zero minimum:1000 name:PM_EINST_CMPL_G49 : Eligible instructions completed +event:0x05d counters:3 um:zero minimum:1000 name:PM_DATA_FROM_RMEM_G49 : Data loaded from remote memory +event:0x05e counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G49 : PPC instructions compled +event:0x05f counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G49 : Processor cycles gated by run latch + +#Group 50 L2 cache data access +event:0x060 counters:0 um:zero minimum:1000 name:PM_DATA_FROM_L25_SHR_G50 : Data loaded from L2.5 shared +event:0x061 counters:1 um:zero minimum:1000 name:PM_DATA_FROM_L25_MOD_G50 : Data loaded from L2.5 modified +event:0x062 counters:2 um:zero minimum:1000 name:PM_DATA_FROM_L275_SHR_G50 : Data loaded from L2.75 shared +event:0x063 counters:3 um:zero minimum:1000 name:PM_DATA_FROM_L275_MOD_G50 : Data loaded from L2.75 modified +event:0x064 counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G50 : PPC instructions completed +event:0x065 counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G50 : Processor cycles gated by run latch + +#Group 51 L3 cache data access +event:0x06a counters:0 um:zero minimum:1000 name:PM_DATA_FROM_L35_SHR_G51 : Data loaded from L3.5 shared +event:0x06b counters:1 um:zero minimum:1000 name:PM_DATA_FROM_L35_MOD_G51 : Data loaded from L3.5 modified +event:0x06c counters:2 um:zero minimum:1000 name:PM_DATA_FROM_L375_SHR_G51 : Data loaded from L3.75 shared +event:0x06d counters:3 um:zero minimum:1000 name:PM_DATA_FROM_L375_MOD_G51 : Data loaded from L3.75 modified +event:0x06e counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G51 : PPC instructions completed +event:0x06f counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G51 : Processor cycles gated by run latch + +#Group 52 Instruction source information +event:0x070 counters:0 um:zero minimum:1000 name:PM_INST_FROM_L3_G52 : Instruction fetrched from L3 +event:0x071 counters:1 um:zero minimum:1000 name:PM_INST_FROM_L1_G52 : Instruction fetched from L1 +event:0x072 counters:2 um:zero minimum:1000 name:PM_INST_FROM_PREF_G52 : Instructions fetched from prefetch +event:0x073 counters:3 um:zero minimum:1000 name:PM_INST_FROM_RMEM_G52 : Instruction fetched from remote memory +event:0x074 counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G52 : PPC instructions completed +event:0x075 counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G52 : Processor Cycles gated by the run latch + +#Group 54 L2 instruction source information +event:0x07a counters:0 um:zero minimum:1000 name:PM_INST_FROM_L25_SHR_G54 : Instruction fetched from L2.5 shared +event:0x07b counters:1 um:zero minimum:1000 name:PM_INST_FROM_L25_MOD_G54 : Instruction fetched from L2.5 modified +event:0x07c counters:2 um:zero minimum:1000 name:PM_INST_FROM_L275_SHR_G54 : Instruction fetched from L2.75 shared +event:0x07d counters:3 um:zero minimum:1000 name:PM_INST_FROM_L275_MOD_G54 : Instruction fetched from L2.75 modified +event:0x07e counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G54 : PPC instructions completed +event:0x07f counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G54 : Processor cycles gated by the run latch + +#Group 55 L3 instruction source information +event:0x080 counters:0 um:zero minimum:1000 name:PM_INST_FROM_L35_SHR_G55 : Instruction fetched from L3.5 shared +event:0x081 counters:1 um:zero minimum:1000 name:PM_INST_FROM_L35_MOD_G55 : Instruction fetched from L3.5 modified +event:0x082 counters:2 um:zero minimum:1000 name:PM_INST_FROM_L375_SHR_G55 : Instruction fetched from L3.75 shared +event:0x083 counters:3 um:zero minimum:1000 name:PM_INST_FROM_L375_MOD_G55 : Instruction fetched from L3.75 modified +event:0x084 counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G55 : PPC instructions completed +event:0x085 counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G55 : Processor cycles gated by the run latch + +#Group 123 Marked TLB and SLB Misses +event:0x08d counters:3 um:zero minimum:1000 name:PM_MRK_DSLB_MISS_G123 : Marked Data SLB misses +event:0x08e counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G123 : Instructions completed +event:0x08f counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G123 : Processor cycles gated by run latch + +#Group 126 Mark unaligned load and store flushes +event:0x093 counters:3 um:zero minimum:1000 name:PM_MRK_LSU_FLUSH_ULD_G126 : A marked load was flushed because it was unaligned (crossed a 64byte boundary or 32 byte if it missed the L1) +event:0x094 counters:4 um:zero minimum:10000 name:PM_INST_CMPL_G126 : Instructions completed +event:0x095 counters:5 um:zero minimum:10000 name:PM_RUN_CYC_G126 : Processor cycles gated by run latch diff --git a/events/ppc64/power5/unit_masks b/events/ppc64/power5/unit_masks new file mode 100644 index 0000000..b2e5f30 --- /dev/null +++ b/events/ppc64/power5/unit_masks @@ -0,0 +1,4 @@ +# ppc64 POWER5 possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/rtc/events b/events/rtc/events new file mode 100644 index 0000000..cce44b0 --- /dev/null +++ b/events/rtc/events @@ -0,0 +1,3 @@ +# RTC events +# +name:RTC_INTERRUPTS event:0xff counters:0 um:zero minimum:2 : RTC interrupts/sec (rounded up to power of two) diff --git a/events/rtc/unit_masks b/events/rtc/unit_masks new file mode 100644 index 0000000..6984b62 --- /dev/null +++ b/events/rtc/unit_masks @@ -0,0 +1,4 @@ +# RTC possible unit masks +# +name:zero type:mandatory default:0x0 + 0x0 No unit mask diff --git a/events/x86-64/hammer/events b/events/x86-64/hammer/events new file mode 100644 index 0000000..386dad1 --- /dev/null +++ b/events/x86-64/hammer/events @@ -0,0 +1,81 @@ +# Hammer events +# +event:0x76 counters:0,1,2,3 um:zero minimum:3000 name:CPU_CLK_UNHALTED : Cycles outside of halt state +event:0xc0 counters:0,1,2,3 um:zero minimum:3000 name:RETIRED_INSNS : Retired instructions (includes exceptions, interrupts, re-syncs) +event:0xc1 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_OPS : Retired ops +event:0x80 counters:0,1,2,3 um:zero minimum:500 name:ICACHE_FETCHES : Instruction cache fetches +event:0x81 counters:0,1,2,3 um:zero minimum:500 name:ICACHE_MISSES : Instruction cache misses +event:0x40 counters:0,1,2,3 um:zero minimum:500 name:DATA_CACHE_ACCESSES : Data cache accesses +event:0x41 counters:0,1,2,3 um:zero minimum:500 name:DATA_CACHE_MISSES : Data cache misses +event:0x42 counters:0,1,2,3 um:moesi minimum:500 name:DATA_CACHE_REFILLS_FROM_L2 : Data cache refills from L2 +event:0x43 counters:0,1,2,3 um:moesi minimum:500 name:DATA_CACHE_REFILLS_FROM_SYSTEM : Data cache refills from system +event:0x44 counters:0,1,2,3 um:moesi minimum:500 name:DATA_CACHE_WRITEBACKS : Data cache write backs +event:0xc2 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_BRANCHES : Retired branches (conditional, unconditional, exceptions, interrupts) +event:0xc3 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_BRANCHES_MISPREDICTED : Retired branches mispredicted +event:0xc4 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_TAKEN_BRANCHES : Retired taken branches +event:0xc5 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_TAKEN_BRANCHES_MISPREDICTED : Retired taken branches mispredicted +event:0x45 counters:0,1,2,3 um:zero minimum:500 name:L1_DTLB_MISSES_L2_DTLB_HITS : L1 DTLB misses and L2 DTLB hits +event:0x46 counters:0,1,2,3 um:zero minimum:500 name:L1_AND_L2_DTLB_MISSES : L1 and L2 DTLB misses +event:0x47 counters:0,1,2,3 um:zero minimum:500 name:MISALIGNED_DATA_REFS : Misaligned data references +event:0x84 counters:0,1,2,3 um:zero minimum:500 name:L1_ITLB_MISSES_L2_ITLB_HITS : L1 ITLB misses (and L2 ITLB hits) +event:0x85 counters:0,1,2,3 um:zero minimum:500 name:L1_AND_L2_ITLB_MISSES : L1 and L2 ITLB misses +event:0xc6 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_FAR_CONTROL_TRANSFERS : Retired far control transfers +event:0xc7 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_RESYNC_BRANCHES : Retired re-sync branches (only non-control transfer branches) +event:0xcd counters:0,1,2,3 um:zero minimum:500 name:INTERRUPTS_MASKED : Interrupts masked cycles (IF=0) +event:0xce counters:0,1,2,3 um:zero minimum:500 name:INTERRUPTS_MASKED_PENDING : Interrupts masked while pending cycles (INTR while IF=0) +event:0xcf counters:0,1,2,3 um:zero minimum:10 name:HARDWARE_INTERRUPTS : Number of taken hardware interrupts +event:0x00 counters:0,1,2,3 um:fpu_ops minimum:500 name:DISPATCHED_FPU_OPS : Dispatched FPU ops +event:0x01 counters:0,1,2,3 um:zero minimum:500 name:NO_FPU_OPS : Cycles with no FPU ops retired +event:0x02 counters:0,1,2,3 um:zero minimum:500 name:FAST_FPU_OPS : Dispatched FPU ops that use the fast flag interface +event:0x20 counters:0,1,2,3 um:segregload minimum:500 name:SEG_REG_LOAD : Segment register load +event:0x21 counters:0,1,2,3 um:zero minimum:500 name:SELF_MODIFY_RESYNC : Micro-architectural re-sync caused by self modifying code +event:0x22 counters:0,1,2,3 um:zero minimum:500 name:SNOOP_RESYNC : Micro-architectural re-sync caused by snoop +event:0x23 counters:0,1,2,3 um:zero minimum:500 name:LS_BUFFER_FULL : LS Buffer 2 Full +event:0x24 counters:0,1,2,3 um:zero minimum:500 name:LOCKED_OP : Locked operation +event:0x25 counters:0,1,2,3 um:zero minimum:500 name:OP_LATE_CANCEL : Micro-architectural late cancel of an operation +event:0x26 counters:0,1,2,3 um:zero minimum:500 name:CFLUSH_RETIRED : Retired CFLUSH instructions +event:0x27 counters:0,1,2,3 um:zero minimum:500 name:CPUID_RETIRED : Retired CPUID instructions +event:0x48 counters:0,1,2,3 um:zero minimum:500 name:ACCESS_CANCEL_LATE : Micro-architectural late cancel of an access +event:0x49 counters:0,1,2,3 um:zero minimum:500 name:ACCESS_CANCEL_EARLY : Micro-architectural early cancel of an access +event:0x4A counters:0,1,2,3 um:ecc minimum:500 name:ECC_BIT_ERR : One bit ECC error recorded by scrubber +event:0x4B counters:0,1,2,3 um:prefetch minimum:500 name:DISPATCHED_PRE_INSTRS : Dispatched prefetch instructions +event:0x7D counters:0,1,2,3 um:l2_internal minimum:500 name:BU_INT_L2_REQ : Internal L2 request +event:0x7E counters:0,1,2,3 um:l2_req_miss minimum:500 name:BU_FILL_REQ : Fill request that missed in L2 +event:0x7F counters:0,1,2,3 um:l2_fill minimum:500 name:BU_FILL_L2 : Fill into L2 +event:0x82 counters:0,1,2,3 um:zero minimum:500 name:IC_REFILL_FROM_L2 : Refill from L2 +event:0x83 counters:0,1,2,3 um:zero minimum:500 name:IC_REFILL_FROM_SYS : Refill from system +event:0x86 counters:0,1,2,3 um:zero minimum:500 name:IC_RESYNC_BY_SNOOP : Micro-architectural re-sync caused by snoop +event:0x88 counters:0,1,2,3 um:zero minimum:500 name:IC_STACK_HIT : Return stack hit +event:0x87 counters:0,1,2,3 um:zero minimum:500 name:IC_FETCH_STALL : Instruction fetch stall +event:0x89 counters:0,1,2,3 um:zero minimum:500 name:IC_STACK_OVERFLOW : Return stack overflow +event:0xC8 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_NEAR_RETURNS : Retired near returns +event:0xc9 counters:0,1,2,3 um:zero minimum:500 name:RETIRED_RETURNS_MISPREDICT : Retired near returns mispredicted +event:0xca counters:0,1,2,3 um:zero minimum:500 name:RETIRED_BRANCH_MISCOMPARE : Returned taken branches mispredicted due to address miscompare +event:0xcb counters:0,1,2,3 um:fpu_instr minimum:500 name:RETIRED_FPU_INSTRS : Retired FPU instructions +event:0xcc counters:0,1,2,3 um:fpu_fastpath minimum:500 name:RETIRED_FASTPATH_INSTRS : Retired FastPath double-op instructions +event:0xd0 counters:0,1,2,3 um:zero minimum:500 name:DECODER_EMPTY : Nothing to dispatch (decoder empty) +event:0xd1 counters:0,1,2,3 um:zero minimum:500 name:DISPATCH_STALLS : Dispatch stalls +event:0xd2 counters:0,1,2,3 um:zero minimum:500 name:DISPATCH_STALL_FROM_BRANCH_ABORT : Dispatch stall from branch abort to retire +event:0xd3 counters:0,1,2,3 um:zero minimum:500 name:DISPATCH_STALL_SERIALIZATION : Dispatch stall for serialization +event:0xd4 counters:0,1,2,3 um:zero minimum:500 name:DISPATCH_STALL_SEG_LOAD : Dispatch stall for segment load +event:0xd5 counters:0,1,2,3 um:zero minimum:500 name:DISPATCH_STALL_REORDER_BUFFER : Dispatch stall when reorder buffer is full +event:0xd6 counters:0,1,2,3 um:zero minimum:500 name:DISPATCH_STALL_RESERVE_STATIONS : Dispatch stall when reservation stations are full +event:0xd7 counters:0,1,2,3 um:zero minimum:500 name:DISPATCH_STALL_FPU : Dispatch stall when FPU is full +event:0xd8 counters:0,1,2,3 um:zero minimum:500 name:DISPATCH_STALL_LS : Dispatch stall when LS is full +event:0xd9 counters:0,1,2,3 um:zero minimum:500 name:DISPATCH_STALL_QUIET_WAIT : Dispatch stall when waiting for all to be quiet +event:0xda counters:0,1,2,3 um:zero minimum:500 name:DISPATCH_STALL_PENDING : Dispatch stall when far control transfer or re-sync branch is pending +event:0xdb counters:0,1,2,3 um:fpu_exceptions minimum:1 name:FPU_EXCEPTIONS : FPU exceptions +event:0xdc counters:0,1,2,3 um:zero minimum:1 name:DR0_BREAKPOINTS : Number of breakpoints for DR0 +event:0xdd counters:0,1,2,3 um:zero minimum:1 name:DR1_BREAKPOINTS : Number of breakpoints for DR1 +event:0xde counters:0,1,2,3 um:zero minimum:1 name:DR2_BREAKPOINTS : Number of breakpoints for DR2 +event:0xdf counters:0,1,2,3 um:zero minimum:1 name:DR3_BREAKPOINTS : Number of breakpoints for DR3 +event:0xe0 counters:0,1,2,3 um:page_access minimum:500 name:MEM_PAGE_ACCESS : Memory controller page access +event:0xe1 counters:0,1,2,3 um:zero minimum:500 name:MEM_PAGE_TBL_OVERFLOW : Memory controller page table overflow +event:0xe2 counters:0,1,2,3 um:zero minimum:500 name:DRAM_SLOTS_MISSED : Memory controller DRAM command slots missed (in MemClks) +event:0xe3 counters:0,1,2,3 um:turnaround minimum:500 name:MEM_TURNAROUND : Memory controller turnaround +event:0xe4 counters:0,1,2,3 um:saturation minimum:500 name:MEM_BYPASS_SAT : Memory controller bypass saturation +event:0xeb counters:0,1,2,3 um:sizecmds minimum:500 name:SIZED_COMMANDS : Sized Commands +event:0xec counters:0,1,2,3 um:probe minimum:500 name:PROBE_RESULT : Probe Result +event:0xf6 counters:0,1,2,3 um:ht minimum:500 name:HYPERTRANSPORT_BUS0_WIDTH : HyperTransport(tm) bus 0 bandwidth +event:0xf7 counters:0,1,2,3 um:ht minimum:500 name:HYPERTRANSPORT_BUS1_WIDTH : HyperTransport(tm) bus 1 bandwidth +event:0xf8 counters:0,1,2,3 um:ht minimum:500 name:HYPERTRANSPORT_BUS2_WIDTH : HyperTransport(tm) bus 2 bandwidth diff --git a/events/x86-64/hammer/unit_masks b/events/x86-64/hammer/unit_masks new file mode 100644 index 0000000..85175a8 --- /dev/null +++ b/events/x86-64/hammer/unit_masks @@ -0,0 +1,97 @@ +# Athlon possible unit masks +# +# See "Bios and Kernel Developer's Guide for the AMD Athlon 64 and AMD Opteron +# Processors" (publication #26094) +# + +name:zero type:mandatory default:0x0 + 0x0 No unit mask +name:moesi type:bitmask default:0x1f + 0x10 (M)odified cache state + 0x08 (O)wner cache state + 0x04 (E)xclusive cache state + 0x02 (S)hared cache state + 0x01 (I)nvalid cache state + 0x1f All cache states +name:fpu_ops type:bitmask default:0x3f + 0x01 Add pipe ops excluding junk ops + 0x02 Multiply pipe ops excluding junk ops + 0x04 Store pipe ops excluding junk ops + 0x08 Add pipe junk ops +# FIXME: correct ? + 0x10 Multiple pipe junk ops + 0x20 Store pipe junk ops +name:segregload type:bitmask default:0x7f + 0x01 ES register + 0x02 CS register + 0x04 SS register + 0x08 DS register + 0x10 FS register + 0x20 GS register + 0x40 HS register +name:ecc type:bitmask default:0x03 + 0x01 Scrubber error + 0x02 Piggyback scrubber errors +name:prefetch type:bitmask default:0x07 + 0x01 Load + 0x02 Store + 0x04 NTA +name:fpu_instr type:bitmask default:0x0f + 0x01 x87 instructions + 0x02 Combined MMX & 3DNow instructions + 0x04 Combined packed SSE & SSE2 instructions + 0x08 Combined packed scalar SSE & SSE2 instructions +name:fpu_fastpath type:bitmask default:0x07 + 0x01 With low op in position 0 + 0x02 With low op in position 1 + 0x04 With low op in position 2 +name:fpu_exceptions type:bitmask default:0x0f + 0x01 x87 reclass microfaults + 0x02 SSE retype microfaults + 0x04 SSE reclass microfaults + 0x08 SSE and x87 microtraps +name:page_access type:bitmask default:0x07 + 0x01 Page hit + 0x02 Page miss + 0x04 Page conflict +name:turnaround type:bitmask default:0x07 + 0x01 DIMM turnaround + 0x02 Read to write turnaround + 0x04 Write to read turnaround +name:saturation type:bitmask default:0x0f + 0x01 Memory controller high priority bypass + 0x02 Memory controller low priority bypass + 0x04 DRAM controller interface bypass + 0x08 DRAM controller queue bypass +name:sizecmds type:bitmask default:0x7f +# FIXME: can we get some non-gobbledegook ? + 0x01 NonPostWrSzByte + 0x02 NonPostWrSzDWord + 0x04 PostWrSzByte + 0x08 PostWrSzDWord + 0x10 RdSzByte + 0x20 RdSzDword + 0x40 RdModWr +name:probe type:bitmask default:0x0f + 0x01 Probe miss + 0x02 Probe hit + 0x04 Probe hit dirty without memory cancel + 0x08 Probe hit dirty with memory cancel +name:ht type:bitmask default:0x7 + 0x01 Command sent + 0x02 Data sent + 0x04 Buffer release sent + 0x08 NOP sent +name:l2_internal type:bitmask default:0x1f + 0x01 IC fill + 0x02 DC fill + 0x04 TLB reload + 0x08 Tag snoop request + 0x10 Canceled request +name:l2_req_miss type:bitmask default:0x07 + 0x01 IC fill + 0x02 DC fill + 0x04 TLB reload +name:l2_fill type:bitmask default:0x03 + 0x01 Dirty L2 victim + 0x02 Victim from L1 diff --git a/gui/Makefile.am b/gui/Makefile.am new file mode 100644 index 0000000..ba5e27c --- /dev/null +++ b/gui/Makefile.am @@ -0,0 +1,43 @@ +SUBDIRS = ui + +dist_sources = \ + oprof_start.cpp \ + oprof_start_config.cpp \ + oprof_start_util.cpp \ + oprof_start_main.cpp \ + oprof_start.h \ + oprof_start_config.h \ + oprof_start_util.h + +EXTRA_DIST = $(dist_sources) + +if have_qt + +AM_CPPFLAGS = \ + @QT_INCLUDES@ \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libutil++ \ + -I ${top_srcdir}/libutil + +AM_CXXFLAGS = @OP_CXXFLAGS@ + +bin_PROGRAMS = oprof_start + +oprof_start_SOURCES = $(dist_sources) +nodist_oprof_start_SOURCES = oprof_start.moc.cpp +oprof_start_LDADD = \ + ../libutil++/libutil++.a \ + ../libop/libop.a \ + ../libutil/libutil.a \ + ui/liboprof_start.a \ + @QT_LDFLAGS@ \ + @QT_LIB@ \ + @X_LIBS@ + +oprof_start.moc.cpp: ${top_srcdir}/gui/oprof_start.h + $(MOC) -o $@ ${top_srcdir}/gui/oprof_start.h + +clean-local: + rm -f oprof_start.moc.cpp + +endif diff --git a/gui/Makefile.in b/gui/Makefile.in new file mode 100644 index 0000000..b023d6c --- /dev/null +++ b/gui/Makefile.in @@ -0,0 +1,618 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(oprof_start_SOURCES) $(nodist_oprof_start_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +@have_qt_TRUE@bin_PROGRAMS = oprof_start$(EXEEXT) +subdir = gui +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am__oprof_start_SOURCES_DIST = oprof_start.cpp oprof_start_config.cpp \ + oprof_start_util.cpp oprof_start_main.cpp oprof_start.h \ + oprof_start_config.h oprof_start_util.h +am__objects_1 = oprof_start.$(OBJEXT) oprof_start_config.$(OBJEXT) \ + oprof_start_util.$(OBJEXT) oprof_start_main.$(OBJEXT) +@have_qt_TRUE@am_oprof_start_OBJECTS = $(am__objects_1) +@have_qt_TRUE@nodist_oprof_start_OBJECTS = oprof_start.moc.$(OBJEXT) +oprof_start_OBJECTS = $(am_oprof_start_OBJECTS) \ + $(nodist_oprof_start_OBJECTS) +@have_qt_TRUE@oprof_start_DEPENDENCIES = ../libutil++/libutil++.a \ +@have_qt_TRUE@ ../libop/libop.a ../libutil/libutil.a \ +@have_qt_TRUE@ ui/liboprof_start.a +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(oprof_start_SOURCES) $(nodist_oprof_start_SOURCES) +DIST_SOURCES = $(am__oprof_start_SOURCES_DIST) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +SUBDIRS = ui +dist_sources = \ + oprof_start.cpp \ + oprof_start_config.cpp \ + oprof_start_util.cpp \ + oprof_start_main.cpp \ + oprof_start.h \ + oprof_start_config.h \ + oprof_start_util.h + +EXTRA_DIST = $(dist_sources) +@have_qt_TRUE@AM_CPPFLAGS = \ +@have_qt_TRUE@ @QT_INCLUDES@ \ +@have_qt_TRUE@ -I ${top_srcdir}/libop \ +@have_qt_TRUE@ -I ${top_srcdir}/libutil++ \ +@have_qt_TRUE@ -I ${top_srcdir}/libutil + +@have_qt_TRUE@AM_CXXFLAGS = @OP_CXXFLAGS@ +@have_qt_TRUE@oprof_start_SOURCES = $(dist_sources) +@have_qt_TRUE@nodist_oprof_start_SOURCES = oprof_start.moc.cpp +@have_qt_TRUE@oprof_start_LDADD = \ +@have_qt_TRUE@ ../libutil++/libutil++.a \ +@have_qt_TRUE@ ../libop/libop.a \ +@have_qt_TRUE@ ../libutil/libutil.a \ +@have_qt_TRUE@ ui/liboprof_start.a \ +@have_qt_TRUE@ @QT_LDFLAGS@ \ +@have_qt_TRUE@ @QT_LIB@ \ +@have_qt_TRUE@ @X_LIBS@ + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gui/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign gui/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +oprof_start$(EXEEXT): $(oprof_start_OBJECTS) $(oprof_start_DEPENDENCIES) + @rm -f oprof_start$(EXEEXT) + $(CXXLINK) $(oprof_start_LDFLAGS) $(oprof_start_OBJECTS) $(oprof_start_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oprof_start.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oprof_start.moc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oprof_start_config.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oprof_start_main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oprof_start_util.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(PROGRAMS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +@have_qt_FALSE@clean-local: +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-local mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: install-binPROGRAMS + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-binPROGRAMS clean-generic clean-local \ + clean-recursive ctags ctags-recursive distclean \ + distclean-compile distclean-generic distclean-recursive \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-binPROGRAMS uninstall-info-am + + +@have_qt_TRUE@oprof_start.moc.cpp: ${top_srcdir}/gui/oprof_start.h +@have_qt_TRUE@ $(MOC) -o $@ ${top_srcdir}/gui/oprof_start.h + +@have_qt_TRUE@clean-local: +@have_qt_TRUE@ rm -f oprof_start.moc.cpp +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/gui/oprof_start.cpp b/gui/oprof_start.cpp new file mode 100644 index 0000000..7126314 --- /dev/null +++ b/gui/oprof_start.cpp @@ -0,0 +1,994 @@ +/** + * @file oprof_start.cpp + * The GUI start main class + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "oprof_start.h" +#include "op_config.h" +#include "op_config_24.h" +#include "string_manip.h" +#include "op_cpufreq.h" +#include "op_alloc_counter.h" +#include "oprof_start_util.h" + +#include "op_hw_config.h" + +using namespace std; + +static char const * green_xpm[] = { +"16 16 2 1", +" c None", +". c #00FF00", +" ....... ", +" ........... ", +" ............. ", +" ............. ", +"............... ", +"............... ", +"............... ", +"............... ", +"............... ", +"............... ", +"............... ", +" ............. ", +" ............. ", +" ........... ", +" ....... ", +" " }; + +static char const * red_xpm[] = { +"16 16 2 1", +" c None", +". c #FF0000", +" ....... ", +" ........... ", +" ............. ", +" ............. ", +"............... ", +"............... ", +"............... ", +"............... ", +"............... ", +"............... ", +"............... ", +" ............. ", +" ............. ", +" ........... ", +" ....... ", +" " }; + +static QPixmap * green_pixmap; +static QPixmap * red_pixmap; + + +op_event_descr::op_event_descr() + : + counter_mask(0), + val(0), + unit(0), + min_count(0) +{ +} + + +oprof_start::oprof_start() + : + oprof_start_base(0, 0, false, 0), + event_count_validator(new QIntValidator(event_count_edit)), + current_event(0), + cpu_speed(op_cpu_frequency()), + total_nr_interrupts(0) +{ + green_pixmap = new QPixmap(green_xpm); + red_pixmap = new QPixmap(red_xpm); + vector args; + args.push_back("--init"); + + if (do_exec_command(OP_BINDIR "/opcontrol", args)) + exit(EXIT_FAILURE); + + cpu_type = op_get_cpu_type(); + op_nr_counters = op_get_nr_counters(cpu_type); + + if (cpu_type == CPU_TIMER_INT) { + setup_config_tab->removePage(counter_setup_page); + } else { + fill_events(); + } + + op_interface interface = op_get_interface(); + if (interface == OP_INTERFACE_NO_GOOD) { + QMessageBox::warning(this, 0, "Couldn't determine kernel" + " interface version"); + exit(EXIT_FAILURE); + } + bool is_26 = interface == OP_INTERFACE_26; + + if (is_26) { + note_table_size_edit->hide(); + note_table_size_label->hide(); + // FIXME: can adapt to 2.6 ... + buffer_size_edit->hide(); + buffer_size_label->hide(); + } + + // setup the configuration page. + kernel_filename_edit->setText(config.kernel_filename.c_str()); + + no_vmlinux->setChecked(config.no_kernel); + + buffer_size_edit->setText(QString().setNum(config.buffer_size)); + note_table_size_edit->setText(QString().setNum(config.note_table_size)); + verbose->setChecked(config.verbose); + separate_lib_cb->setChecked(config.separate_lib); + separate_kernel_cb->setChecked(config.separate_kernel); + separate_cpu_cb->setChecked(config.separate_cpu); + separate_thread_cb->setChecked(config.separate_thread); + + // the unit mask check boxes + hide_masks(); + + event_count_edit->setValidator(event_count_validator); + QIntValidator * iv; + iv = new QIntValidator(OP_MIN_BUF_SIZE, OP_MAX_BUF_SIZE, buffer_size_edit); + buffer_size_edit->setValidator(iv); + iv = new QIntValidator(OP_MIN_NOTE_TABLE_SIZE, OP_MAX_NOTE_TABLE_SIZE, note_table_size_edit); + note_table_size_edit->setValidator(iv); + + // daemon status timer + startTimer(5000); + timerEvent(0); + + resize(minimumSizeHint()); + + // force the pixmap re-draw + event_selected(); +} + + +void oprof_start::fill_events() +{ + // we need to build the event descr stuff before loading the + // configuration because we use locate_event to get an event descr + // from its name. + struct list_head * pos; + struct list_head * events = op_events(cpu_type); + + list_for_each(pos, events) { + struct op_event * event = list_entry(pos, struct op_event, event_next); + + op_event_descr descr; + + descr.counter_mask = event->counter_mask; + descr.val = event->val; + if (event->unit->num) { + descr.unit = event->unit; + } else { + descr.unit = 0; + } + + descr.name = event->name; + descr.help_str = event->desc; + descr.min_count = event->min_count; + + for (uint ctr = 0; ctr < op_nr_counters; ++ctr) { + uint count; + + if (!(descr.counter_mask & (1 << ctr))) + continue; + + if (cpu_type == CPU_RTC) { + count = 1024; + } else { + /* setting to cpu Hz / 2000 gives a safe value for + * all events, and a good one for most. + */ + if (cpu_speed) + count = int(cpu_speed * 500); + else + count = descr.min_count * 100; + } + + event_cfgs[descr.name].count = count; + event_cfgs[descr.name].umask = 0; + if (descr.unit) + event_cfgs[descr.name].umask = descr.unit->default_mask; + event_cfgs[descr.name].os_ring_count = 1; + event_cfgs[descr.name].user_ring_count = 1; + } + + v_events.push_back(descr); + } + + events_list->header()->hide(); + events_list->setSorting(-1); + + fill_events_listbox(); + + read_set_events(); + + // FIXME: why this ? + if (cpu_type == CPU_RTC) + events_list->setCurrentItem(events_list->firstChild()); + + load_config_file(); +} + + +namespace { + +/// find the first item with the given text in column 0 or return NULL +QListViewItem * findItem(QListView * view, char const * name) +{ + // Qt 2.3.1 does not have QListView::findItem() + QListViewItem * item = view->firstChild(); + + while (item && strcmp(item->text(0).latin1(), name)) { + item = item->nextSibling(); + } + + return item; +} + +}; + + +void oprof_start::setup_default_event() +{ + struct op_default_event_descr descr; + op_default_event(cpu_type, &descr); + + event_cfgs[descr.name].umask = descr.um; + event_cfgs[descr.name].count = descr.count; + event_cfgs[descr.name].user_ring_count = 1; + event_cfgs[descr.name].os_ring_count = 1; + + QListViewItem * item = findItem(events_list, descr.name); + if (item) + item->setSelected(true); +} + + +void oprof_start::read_set_events() +{ + string name = get_user_filename(".oprofile/daemonrc"); + + ifstream in(name.c_str()); + + if (!in) { + setup_default_event(); + return; + } + + string str; + + bool one_enabled = false; + + while (getline(in, str)) { + string const val = split(str, '='); + string const name = str; + + if (!is_prefix(name, "CHOSEN_EVENTS[")) + continue; + + one_enabled = true; + + // CHOSEN_EVENTS[0]=CPU_CLK_UNHALTED:10000:0:1:1 + vector parts = separate_token(val, ':'); + + if (parts.size() != 5 && parts.size() != 2) { + cerr << "invalid configuration file\n"; + // FIXME + exit(EXIT_FAILURE); + } + + string ev_name = parts[0]; + event_cfgs[ev_name].count = + op_lexical_cast(parts[1]); + + // CPU_CLK_UNHALTED:10000 is also valid + if (parts.size() == 5) { + event_cfgs[ev_name].umask = + op_lexical_cast(parts[2]); + event_cfgs[ev_name].user_ring_count = + op_lexical_cast(parts[3]); + event_cfgs[ev_name].os_ring_count = + op_lexical_cast(parts[4]); + } else { + event_cfgs[ev_name].umask = 0; + event_cfgs[ev_name].user_ring_count = 1; + event_cfgs[ev_name].os_ring_count = 1; + } + + QListViewItem * item = findItem(events_list, ev_name.c_str()); + if (item) + item->setSelected(true); + } + + // use default event if none set + if (!one_enabled) + setup_default_event(); +} + + +void oprof_start::load_config_file() +{ + string name = get_user_filename(".oprofile/daemonrc"); + + ifstream in(name.c_str()); + if (!in) { + if (!check_and_create_config_dir()) + return; + + ofstream out(name.c_str()); + if (!out) { + QMessageBox::warning(this, 0, "Unable to open configuration " + "file ~/.oprofile/daemonrc"); + } + return; + } + + in >> config; +} + + +// user request a "normal" exit so save the config file. +void oprof_start::accept() +{ + // record the previous settings + record_selected_event_config(); + + save_config(); + + QDialog::accept(); +} + + +void oprof_start::closeEvent(QCloseEvent *) +{ + accept(); +} + + +void oprof_start::timerEvent(QTimerEvent *) +{ + static time_t last = time(0); + + daemon_status dstat; + + flush_profiler_data_btn->setEnabled(dstat.running); + stop_profiler_btn->setEnabled(dstat.running); + start_profiler_btn->setEnabled(!dstat.running); + + if (!dstat.running) { + daemon_label->setText("Profiler is not running."); + return; + } + + ostringstream ss; + ss << "Profiler running:"; + + time_t curr = time(0); + total_nr_interrupts += dstat.nr_interrupts; + + if (curr - last) + ss << " (" << dstat.nr_interrupts / (curr - last) << " interrupts / second, total " << total_nr_interrupts << ")"; + + daemon_label->setText(ss.str().c_str()); + + last = curr; +} + + +void oprof_start::fill_events_listbox() +{ + setUpdatesEnabled(false); + + for (vector::reverse_iterator cit = v_events.rbegin(); + cit != v_events.rend(); ++cit) { + new QListViewItem(events_list, cit->name.c_str()); + } + + setUpdatesEnabled(true); + update(); +} + + +void oprof_start::display_event(op_event_descr const & descr) +{ + setUpdatesEnabled(false); + + setup_unit_masks(descr); + os_ring_count_cb->setEnabled(true); + user_ring_count_cb->setEnabled(true); + event_count_edit->setEnabled(true); + + event_setting & cfg = event_cfgs[descr.name]; + + os_ring_count_cb->setChecked(cfg.os_ring_count); + user_ring_count_cb->setChecked(cfg.user_ring_count); + QString count_text; + count_text.setNum(cfg.count); + event_count_edit->setText(count_text); + event_count_validator->setRange(descr.min_count, max_perf_count()); + + setUpdatesEnabled(true); + update(); +} + + +bool oprof_start::is_selectable_event(QListViewItem * item) +{ + if (item->isSelected()) + return true; + + selected_events.insert(item); + + bool ret = false; + if (alloc_selected_events()) + ret = true; + + selected_events.erase(item); + + return ret; +} + + +void oprof_start::draw_event_list() +{ + QListViewItem * cur; + for (cur = events_list->firstChild(); cur; cur = cur->nextSibling()) { + if (is_selectable_event(cur)) + cur->setPixmap(0, *green_pixmap); + else + cur->setPixmap(0, *red_pixmap); + } +} + + +bool oprof_start::alloc_selected_events() const +{ + vector events; + + set::const_iterator it; + for (it = selected_events.begin(); it != selected_events.end(); ++it) { + events.push_back(find_event_by_name((*it)->text(0).latin1())); + } + + size_t * map = + map_event_to_counter(&events[0], events.size(), cpu_type); + + if (!map) + return false; + + free(map); + return true; +} + +void oprof_start::event_selected() +{ + // The deal is simple: QT lack of a way to know what item was the last + // (de)selected item so we record a set of selected items and diff + // it in the appropriate way with the previous list of selected items. + + set current_selection; + QListViewItem * cur; + for (cur = events_list->firstChild(); cur; cur = cur->nextSibling()) { + if (cur->isSelected()) { + current_selection.insert(cur); + } + } + + // First remove the deselected item. + vector new_deselected; + set_difference(selected_events.begin(), selected_events.end(), + current_selection.begin(), current_selection.end(), + back_inserter(new_deselected)); + vector::const_iterator it; + for (it = new_deselected.begin(); it != new_deselected.end(); ++it) { + selected_events.erase(*it); + } + + // Now try to add the newly selected item if enough HW resource exists + vector new_selected; + set_difference(current_selection.begin(), current_selection.end(), + selected_events.begin(), selected_events.end(), + back_inserter(new_selected)); + for (it = new_selected.begin(); it != new_selected.end(); ++it) { + selected_events.insert(*it); + if (!alloc_selected_events()) { + (*it)->setSelected(false); + selected_events.erase(*it); + } else { + current_event = *it; + } + } + + draw_event_list(); + + if (current_event) + display_event(locate_event(current_event->text(0).latin1())); +} + + +void oprof_start::event_over(QListViewItem * item) +{ + op_event_descr const & descr = locate_event(item->text(0).latin1()); + + string help_str = descr.help_str.c_str(); + if (!is_selectable_event(item)) { + help_str += " conflicts with:"; + + set::const_iterator it; + for (it = selected_events.begin(); + it != selected_events.end(); ) { + QListViewItem * temp = *it; + selected_events.erase(it++); + if (is_selectable_event(item)) { + help_str += " "; + help_str += temp->text(0).latin1(); + } + selected_events.insert(temp); + } + } + + event_help_label->setText(help_str.c_str()); +} + + +/// select the kernel image filename +void oprof_start::choose_kernel_filename() +{ + string name = kernel_filename_edit->text().latin1(); + string result = do_open_file_or_dir(name, false); + + if (!result.empty()) + kernel_filename_edit->setText(result.c_str()); +} + + +// this record the current selected event setting in the event_cfg[] stuff. +// FIXME: need validation? +void oprof_start::record_selected_event_config() +{ + if (!current_event) + return; + + string name(current_event->text(0).latin1()); + + event_setting & cfg = event_cfgs[name]; + op_event_descr const & curr = locate_event(name); + + cfg.count = event_count_edit->text().toUInt(); + cfg.os_ring_count = os_ring_count_cb->isChecked(); + cfg.user_ring_count = user_ring_count_cb->isChecked(); + cfg.umask = get_unit_mask(curr); +} + + +// validate and save the configuration (The qt validator installed +// are not sufficient to do the validation) +bool oprof_start::record_config() +{ + config.kernel_filename = kernel_filename_edit->text().latin1(); + config.no_kernel = no_vmlinux->isChecked(); + + QString const t = buffer_size_edit->text(); + uint temp = t.toUInt(); + if (temp < OP_MIN_BUF_SIZE || temp > OP_MAX_BUF_SIZE) { + ostringstream error; + + error << "buffer size out of range: " << temp + << " valid range is [" << OP_MIN_BUF_SIZE << ", " + << OP_MAX_BUF_SIZE << "]"; + + QMessageBox::warning(this, 0, error.str().c_str()); + + return false; + } + config.buffer_size = temp; + + temp = note_table_size_edit->text().toUInt(); + if (temp < OP_MIN_NOTE_TABLE_SIZE || temp > OP_MAX_NOTE_TABLE_SIZE) { + ostringstream error; + + error << "note table size out of range: " << temp + << " valid range is [" << OP_MIN_NOTE_TABLE_SIZE << ", " + << OP_MAX_NOTE_TABLE_SIZE << "]"; + + QMessageBox::warning(this, 0, error.str().c_str()); + + return false; + } + config.note_table_size = temp; + + config.verbose = verbose->isChecked(); + config.separate_lib = separate_lib_cb->isChecked(); + config.separate_kernel = separate_kernel_cb->isChecked(); + config.separate_cpu = separate_cpu_cb->isChecked(); + config.separate_thread = separate_thread_cb->isChecked(); + + return true; +} + + +void oprof_start::get_unit_mask_part(op_event_descr const & descr, uint num, + bool selected, uint & mask) +{ + if (!selected) + return; + if (num >= descr.unit->num) + return; + + if (descr.unit->unit_type_mask == utm_bitmask) + mask |= descr.unit->um[num].value; + else + mask = descr.unit->um[num].value; +} + + +// return the unit mask selected through the unit mask check box +uint oprof_start::get_unit_mask(op_event_descr const & descr) +{ + uint mask = 0; + + if (!descr.unit) + return 0; + + // mandatory mask is transparent for user. + if (descr.unit->unit_type_mask == utm_mandatory) { + mask = descr.unit->default_mask; + return mask; + } + + get_unit_mask_part(descr, 0, check0->isChecked(), mask); + get_unit_mask_part(descr, 1, check1->isChecked(), mask); + get_unit_mask_part(descr, 2, check2->isChecked(), mask); + get_unit_mask_part(descr, 3, check3->isChecked(), mask); + get_unit_mask_part(descr, 4, check4->isChecked(), mask); + get_unit_mask_part(descr, 5, check5->isChecked(), mask); + get_unit_mask_part(descr, 6, check6->isChecked(), mask); + get_unit_mask_part(descr, 7, check7->isChecked(), mask); + get_unit_mask_part(descr, 8, check8->isChecked(), mask); + get_unit_mask_part(descr, 9, check9->isChecked(), mask); + get_unit_mask_part(descr, 10, check10->isChecked(), mask); + get_unit_mask_part(descr, 11, check11->isChecked(), mask); + get_unit_mask_part(descr, 12, check12->isChecked(), mask); + get_unit_mask_part(descr, 13, check13->isChecked(), mask); + get_unit_mask_part(descr, 14, check14->isChecked(), mask); + get_unit_mask_part(descr, 15, check15->isChecked(), mask); + return mask; +} + + +void oprof_start::hide_masks() +{ + check0->hide(); + check1->hide(); + check2->hide(); + check3->hide(); + check4->hide(); + check5->hide(); + check6->hide(); + check7->hide(); + check8->hide(); + check9->hide(); + check10->hide(); + check11->hide(); + check12->hide(); + check13->hide(); + check14->hide(); + check15->hide(); +} + + +void oprof_start::setup_unit_masks(op_event_descr const & descr) +{ + op_unit_mask const * um = descr.unit; + + hide_masks(); + + if (!um || um->unit_type_mask == utm_mandatory) + return; + + event_setting & cfg = event_cfgs[descr.name]; + + unit_mask_group->setExclusive(um->unit_type_mask == utm_exclusive); + + for (size_t i = 0; i < um->num ; ++i) { + QCheckBox * check = 0; + switch (i) { + case 0: check = check0; break; + case 1: check = check1; break; + case 2: check = check2; break; + case 3: check = check3; break; + case 4: check = check4; break; + case 5: check = check5; break; + case 6: check = check6; break; + case 7: check = check7; break; + case 8: check = check8; break; + case 9: check = check9; break; + case 10: check = check10; break; + case 11: check = check11; break; + case 12: check = check12; break; + case 13: check = check13; break; + case 14: check = check14; break; + case 15: check = check15; break; + } + check->setText(um->um[i].desc); + if (um->unit_type_mask == utm_exclusive) { + check->setChecked(cfg.umask == um->um[i].value); + } else { + // The last descriptor contains a mask that enable all + // value so we must enable the last check box only if + // all bits are on. + if (i == um->num - 1) { + check->setChecked(cfg.umask == um->um[i].value); + } else { + check->setChecked(cfg.umask & um->um[i].value); + } + } + check->show(); + } + unit_mask_group->setMinimumSize(unit_mask_group->sizeHint()); + setup_config_tab->setMinimumSize(setup_config_tab->sizeHint()); +} + + +uint oprof_start::max_perf_count() const +{ + return cpu_type == CPU_RTC ? OP_MAX_RTC_COUNT : OP_MAX_PERF_COUNT; +} + + +void oprof_start::on_flush_profiler_data() +{ + vector args; + args.push_back("--dump"); + + if (daemon_status().running) + do_exec_command(OP_BINDIR "/opcontrol", args); + else + QMessageBox::warning(this, 0, "The profiler is not started."); +} + + +// user is happy of its setting. +void oprof_start::on_start_profiler() +{ + // save the current settings + record_selected_event_config(); + + bool one_enable = false; + + QListViewItem * cur; + for (cur = events_list->firstChild(); cur; cur = cur->nextSibling()) { + if (!cur->isSelected()) + continue; + + // the missing reference is intended: gcc 2.91.66 can compile + // "op_event_descr const & descr = ..." w/o a warning + op_event_descr const descr = + locate_event(cur->text(0).latin1()); + + event_setting & cfg = event_cfgs[cur->text(0).latin1()]; + + one_enable = true; + + if (!cfg.os_ring_count && !cfg.user_ring_count) { + QMessageBox::warning(this, 0, "You must select to " + "profile at least one of user binaries/kernel"); + return; + } + + if (cfg.count < descr.min_count || + cfg.count > max_perf_count()) { + ostringstream out; + + out << "event " << descr.name << " count of range: " + << cfg.count << " must be in [ " + << descr.min_count << ", " + << max_perf_count() + << "]"; + + QMessageBox::warning(this, 0, out.str().c_str()); + return; + } + + if (descr.unit && + descr.unit->unit_type_mask == utm_bitmask && + cfg.umask == 0) { + ostringstream out; + + out << "event " << descr.name << " invalid unit mask: " + << cfg.umask << endl; + + QMessageBox::warning(this, 0, out.str().c_str()); + return; + } + } + + if (one_enable == false && cpu_type != CPU_TIMER_INT) { + QMessageBox::warning(this, 0, "No counters enabled.\n"); + return; + } + + if (daemon_status().running) { + // gcc 2.91 work around + int user_choice = 0; + user_choice = + QMessageBox::warning(this, 0, + "Profiler already started:\n\n" + "stop and restart it?", + "&Restart", "&Cancel", 0, 0, 1); + + if (user_choice == 1) + return; + + // this flush profiler data also. + on_stop_profiler(); + } + + vector args; + + // save_config validate and setup the config + if (save_config()) { + // now actually start + args.push_back("--start"); + if (config.verbose) + args.push_back("--verbose"); + do_exec_command(OP_BINDIR "/opcontrol", args); + } + + total_nr_interrupts = 0; + timerEvent(0); +} + + +bool oprof_start::save_config() +{ + if (!record_config()) + return false; + + vector args; + + // saving config is done by running opcontrol --setup with appropriate + // setted parameters so we use the same config file as command line + // tools + + args.push_back("--setup"); + + bool one_enabled = false; + + vector tmpargs; + tmpargs.push_back("--setup"); + + QListViewItem * cur; + for (cur = events_list->firstChild(); cur; cur = cur->nextSibling()) { + if (!cur->isSelected()) + continue; + + event_setting & cfg = event_cfgs[cur->text(0).latin1()]; + + op_event_descr const & descr = + locate_event(cur->text(0).latin1()); + + one_enabled = true; + + string arg = "--event=" + descr.name; + arg += ":" + op_lexical_cast(cfg.count); + arg += ":" + op_lexical_cast(cfg.umask); + arg += ":" + op_lexical_cast(cfg.os_ring_count); + arg += ":" + op_lexical_cast(cfg.user_ring_count); + + tmpargs.push_back(arg); + } + + // only set counters if at least one is enabled + if (one_enabled) + args = tmpargs; + + if (config.no_kernel) { + args.push_back("--no-vmlinux"); + } else { + args.push_back("--vmlinux=" + config.kernel_filename); + } + + if (op_get_interface() == OP_INTERFACE_24) { + args.push_back("--buffer-size=" + + op_lexical_cast(config.buffer_size)); + args.push_back("--note-table-size=" + + op_lexical_cast(config.note_table_size)); + } + + string sep = "--separate="; + + if (config.separate_lib) + sep += "library,"; + if (config.separate_kernel) + sep += "kernel,"; + if (config.separate_cpu) + sep += "cpu,"; + if (config.separate_thread) + sep += "thread,"; + + if (sep == "--separate=") + sep += "none"; + args.push_back(sep); + + // 2.95 work-around, it didn't like return !do_exec_command() + bool ret = !do_exec_command(OP_BINDIR "/opcontrol", args); + return ret; +} + + +// flush and stop the profiler if it was started. +void oprof_start::on_stop_profiler() +{ + vector args; + args.push_back("--shutdown"); + + if (daemon_status().running) + do_exec_command(OP_BINDIR "/opcontrol", args); + else + QMessageBox::warning(this, 0, "The profiler is already stopped."); + + timerEvent(0); +} + + +void oprof_start::on_separate_kernel_cb_changed(int state) +{ + if (state == 2) + separate_lib_cb->setChecked(true); +} + + +/// function object for matching against name +class event_name_eq { + string name_; +public: + explicit event_name_eq(string const & s) : name_(s) {} + bool operator()(op_event_descr const & d) const { + return d.name == name_; + } +}; + + +// helper to retrieve an event descr through its name. +op_event_descr const & oprof_start::locate_event(string const & name) const +{ + return *(find_if(v_events.begin(), v_events.end(), event_name_eq(name))); +} diff --git a/gui/oprof_start.h b/gui/oprof_start.h new file mode 100644 index 0000000..7f6212b --- /dev/null +++ b/gui/oprof_start.h @@ -0,0 +1,162 @@ +/** + * @file oprof_start.h + * The GUI start main class + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef OPROF_START_H +#define OPROF_START_H + +#include +#include +#include + +#include "ui/oprof_start.base.h" +#include "oprof_start_config.h" + +#include "op_events.h" + +class QIntValidator; +class QListViewItem; +class QTimerEvent; + +/// a struct describing a particular event type +struct op_event_descr { + op_event_descr(); + + /// bit mask of allowed counters + uint counter_mask; + /// hardware event number + u8 val; + /// unit mask values if applicable + op_unit_mask const * unit; + /// name of event + std::string name; + /// description of event + std::string help_str; + /// minimum counter value + uint min_count; +}; + +class oprof_start : public oprof_start_base +{ + Q_OBJECT + +public: + oprof_start(); + +protected slots: + /// select the kernel image filename + void choose_kernel_filename(); + /// flush profiler + void on_flush_profiler_data(); + /// start profiler + void on_start_profiler(); + /// stop profiler + void on_stop_profiler(); + /// events selection change + void event_selected(); + /// the mouse is over an event + void event_over(QListViewItem *); + /// state of separate_kernel_cb changed + void on_separate_kernel_cb_changed(int); + + /// close the dialog + void accept(); + + /// WM hide event + void closeEvent(QCloseEvent * e); + + /// timer event + void timerEvent(QTimerEvent * e); + +private: + /// the counter combo has been activated + void fill_events_listbox(); + + /// fill the event details and gui setup + void fill_events(); + + /// find an event description by name + op_event_descr const & locate_event(std::string const & name) const; + + /// update config on user change + void record_selected_event_config(); + /// update config and validate + bool record_config(); + + /// calculate unit mask for given event and unit mask part + void get_unit_mask_part(op_event_descr const & descr, uint num, bool selected, uint & mask); + /// calculate unit mask for given event + uint get_unit_mask(op_event_descr const & descr); + /// set the unit mask widgets for given event + void setup_unit_masks(op_event_descr const & descr); + + /// return the maximum perf counter value for the current cpu type + uint max_perf_count() const; + + /// show an event's settings + void display_event(op_event_descr const & descrp); + + /// hide unit mask widgets + void hide_masks(void); + + /// read the events set in daemonrc + void read_set_events(); + /// use the default event + void setup_default_event(); + /// load the extra config file + void load_config_file(); + /// save the config + bool save_config(); + + /// redraw the event list by changing icon status + void draw_event_list(); + + /// return true if item is selectable or already selected + bool is_selectable_event(QListViewItem * item); + + /// try to alloc counters for the selected_events + bool alloc_selected_events() const; + + /// validator for event count + QIntValidator* event_count_validator; + + /// all available events for this hardware + std::vector v_events; + + /// current event configs for each counter + typedef std::map event_setting_map; + event_setting_map event_cfgs; + + /// The currently selected events. We must track this because + /// with multiple selection listbox QT doesn't allow to know + /// what is the last selected item. events_selected() update it + std::set selected_events; + QListViewItem * current_event; + + /// current config + config_setting config; + + /// the expansion of "~" directory + std::string user_dir; + + /// CPU type + op_cpu cpu_type; + + /// CPU speed in MHz + double cpu_speed; + + /// total number of available HW counters + uint op_nr_counters; + + /// Total number of samples for this run + unsigned long total_nr_interrupts; +}; + +#endif // OPROF_START_H diff --git a/gui/oprof_start_config.cpp b/gui/oprof_start_config.cpp new file mode 100644 index 0000000..162b130 --- /dev/null +++ b/gui/oprof_start_config.cpp @@ -0,0 +1,103 @@ +/** + * @file oprof_start_config.cpp + * GUI startup config management + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include +#include +#include +#include + +#include "string_manip.h" +#include "oprof_start_config.h" +#include "op_config.h" +#include "op_config_24.h" + +using namespace std; + +event_setting::event_setting() + : + count(0), + umask(0), + os_ring_count(0), + user_ring_count(0) +{ +} + + +config_setting::config_setting() + : + buffer_size(OP_DEFAULT_BUF_SIZE), + note_table_size(OP_DEFAULT_NOTE_SIZE), + no_kernel(false), + verbose(false), + separate_lib(false), + separate_kernel(false), + separate_cpu(false), + separate_thread(false) +{ + struct utsname info; + + /* Guess path to vmlinux based on kernel currently running. */ + if (uname(&info)) { + perror("oprof_start: Unable to determine OS release."); + } else { + string const version(info.release); + string const vmlinux_path("/lib/modules/" + version + + "/build/vmlinux"); + kernel_filename = vmlinux_path; + } +} + + +void config_setting::load(istream & in) +{ + buffer_size = OP_DEFAULT_BUF_SIZE; + note_table_size = OP_DEFAULT_NOTE_SIZE; + + string str; + + while (getline(in, str)) { + string val = split(str, '='); + if (str == "BUF_SIZE") { + buffer_size = op_lexical_cast(val); + if (buffer_size < OP_DEFAULT_BUF_SIZE) + buffer_size = OP_DEFAULT_BUF_SIZE; + } else if (str == "NOTE_SIZE") { + note_table_size = op_lexical_cast(val); + if (note_table_size < OP_DEFAULT_NOTE_SIZE) + note_table_size = OP_DEFAULT_NOTE_SIZE; + } else if (str == "VMLINUX") { + if (val == "none") { + kernel_filename = ""; + no_kernel = true; + } else if (!val.empty()) { + no_kernel = false; + kernel_filename = val; + } + } else if (str == "SEPARATE_LIB") { + separate_lib = op_lexical_cast(val); + } else if (str == "SEPARATE_KERNEL") { + separate_kernel = op_lexical_cast(val); + } else if (str == "SEPARATE_CPU") { + separate_cpu = op_lexical_cast(val); + } else if (str == "SEPARATE_THREAD") { + separate_thread = op_lexical_cast(val); + } + } +} + + +istream & operator>>(istream & in, config_setting & object) +{ + object.load(in); + return in; +} diff --git a/gui/oprof_start_config.h b/gui/oprof_start_config.h new file mode 100644 index 0000000..3e82875 --- /dev/null +++ b/gui/oprof_start_config.h @@ -0,0 +1,53 @@ +/** + * @file oprof_start_config.h + * GUI startup config management + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPROF_START_CONFIG_H +#define OPROF_START_CONFIG_H + +#include +#include +#include + +/// Store the setup of one event +struct event_setting { + + event_setting(); + + uint count; + uint umask; + bool os_ring_count; + bool user_ring_count; +}; + +/** + * Store the general configuration of the profiler. + * There is no save(), instead opcontrol --setup must be + * called. This uses opcontrol's daemonrc file. + */ +struct config_setting { + config_setting(); + + void load(std::istream & in); + + uint buffer_size; + uint note_table_size; + std::string kernel_filename; + bool no_kernel; + bool verbose; + bool separate_lib; + bool separate_kernel; + bool separate_cpu; + bool separate_thread; +}; + +std::istream & operator>>(std::istream & in, config_setting & object); + +#endif // ! OPROF_START_CONFIG_H diff --git a/gui/oprof_start_main.cpp b/gui/oprof_start_main.cpp new file mode 100644 index 0000000..44da5de --- /dev/null +++ b/gui/oprof_start_main.cpp @@ -0,0 +1,27 @@ +/** + * @file oprof_start_main.cpp + * main routine for GUI start + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include + +#include "oprof_start.h" + +int main(int argc, char* argv[]) +{ + QApplication a(argc, argv); + + oprof_start* dlg = new oprof_start(); + + a.setMainWidget(dlg); + + dlg->show(); + + return a.exec(); +} diff --git a/gui/oprof_start_util.cpp b/gui/oprof_start_util.cpp new file mode 100644 index 0000000..ded9cae --- /dev/null +++ b/gui/oprof_start_util.cpp @@ -0,0 +1,341 @@ +/** + * @file oprof_start_util.cpp + * Miscellaneous helpers for the GUI start + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "op_file.h" +#include "file_manip.h" +#include "child_reader.h" +#include "op_libiberty.h" + +#include "oprof_start.h" +#include "oprof_start_util.h" + +using namespace std; + +namespace { + +// return the ~ expansion suffixed with a '/' +string const get_user_dir() +{ + static string user_dir; + + if (user_dir.empty()) { + char * dir = getenv("HOME"); + if (!dir) { + cerr << "Can't determine home directory !\n" << endl; + exit(EXIT_FAILURE); + } + + user_dir = dir; + + if (user_dir.length() && user_dir[user_dir.length() -1] != '/') + user_dir += '/'; + } + + return user_dir; +} + +string daemon_pid; + +} // namespace anon + +daemon_status::daemon_status() + : running(false) +{ + int HZ; + if (!daemon_pid.empty()) { + string const exec = + op_realpath(string("/proc/") + daemon_pid + "/exe"); + if (exec.empty()) + daemon_pid.erase(); + else + running = true; + } + + if (daemon_pid.empty()) { + DIR * dir; + struct dirent * dirent; + + if (!(dir = opendir("/proc"))) { + perror("oprofiled: /proc directory could not be opened. "); + exit(EXIT_FAILURE); + } + + while ((dirent = readdir(dir))) { + string const exec = + op_realpath(string("/proc/") + + dirent->d_name + "/exe"); + string const name = op_basename(exec); + if (name != "oprofiled") + continue; + + daemon_pid = dirent->d_name; + running = true; + } + + closedir(dir); + } + + HZ = sysconf(_SC_CLK_TCK); + if (HZ == -1) { + perror("oprofiled: Unable to determine clock ticks per second. "); + exit(EXIT_FAILURE); + } + + if (daemon_pid.empty()) + return; + + nr_interrupts = 0; + + switch (op_get_interface()) { + case OP_INTERFACE_24: + { + ifstream ifs3("/proc/sys/dev/oprofile/nr_interrupts"); + if (ifs3) + ifs3 >> nr_interrupts; + } + break; + case OP_INTERFACE_26: + { + static unsigned int old_sum_interrupts; + unsigned int sum_interrupts = 0; + glob_t file_names; + + file_names.gl_offs = 0; + glob("/dev/oprofile/stats/cpu*/sample_received", + GLOB_DOOFFS, NULL, &file_names); + + for (size_t i = 0; i < file_names.gl_pathc; ++i) { + ifstream ifs3(file_names.gl_pathv[i]); + if (ifs3) { + unsigned int file_interrupts; + ifs3 >> file_interrupts; + sum_interrupts += file_interrupts; + } + } + nr_interrupts = sum_interrupts - old_sum_interrupts; + old_sum_interrupts = sum_interrupts; + globfree(&file_names); + } + break; + default: + break; + } +} + + +/** + * get_user_filename - get absolute filename of file in user $HOME + * @param filename the relative filename + * + * Get the absolute path of a file in a user's home directory. + */ +string const get_user_filename(string const & filename) +{ + return get_user_dir() + "/" + filename; +} + + +/** + * check_and_create_config_dir - make sure config dir is accessible + * + * Returns %true if the dir is accessible. + */ +bool check_and_create_config_dir() +{ + string dir = get_user_filename(".oprofile"); + + char * name = xstrdup(dir.c_str()); + + if (create_dir(name)) { + ostringstream out; + out << "unable to create " << dir << " directory "; + out << "cause: " << strerror(errno); + QMessageBox::warning(0, 0, out.str().c_str()); + + free(name); + + return false; + } + + free(name); + return true; +} + + +/** + * format - re-format a string + * @param orig string to format + * @param maxlen width of line + * + * Re-formats a string to fit into a certain width, + * breaking lines at spaces between words. + * + * Returns the formatted string + */ +string const format(string const & orig, uint const maxlen) +{ + string text(orig); + + istringstream ss(text); + vector lines; + + string oline; + string line; + + while (getline(ss, oline)) { + if (line.size() + oline.size() < maxlen) { + lines.push_back(line + oline); + line.erase(); + } else { + lines.push_back(line); + line.erase(); + string s; + string word; + istringstream oss(oline); + while (oss >> word) { + if (line.size() + word.size() > maxlen) { + lines.push_back(line); + line.erase(); + } + line += word + " "; + } + } + } + + if (line.size()) + lines.push_back(line); + + string ret; + + for(vector::const_iterator it = lines.begin(); it != lines.end(); ++it) + ret += *it + "\n"; + + return ret; +} + + +/** + * do_exec_command - execute a command + * @param cmd command name + * @param args arguments to command + * + * Execute a command synchronously. An error message is shown + * if the command returns a non-zero status, which is also returned. + * + * The arguments are verified and will refuse to execute if they contain + * shell metacharacters. + */ +int do_exec_command(string const & cmd, vector const & args) +{ + ostringstream err; + bool ok = true; + + // verify arguments + for (vector::const_iterator cit = args.begin(); + cit != args.end(); ++cit) { + if (verify_argument(*cit)) + continue; + + QMessageBox::warning(0, 0, + string( + "Could not execute: Argument \"" + *cit + + "\" contains shell metacharacters.\n").c_str()); + return EINVAL; + } + + child_reader reader(cmd, args); + if (reader.error()) + ok = false; + + if (ok) + reader.get_data(cout, err); + + int ret = reader.terminate_process(); + if (ret) { + string error = reader.error_str() + "\n"; + error += "Failed: \n" + err.str() + "\n"; + string cmdline = cmd; + for (vector::const_iterator cit = args.begin(); + cit != args.end(); ++cit) { + cmdline += " " + *cit + " "; + } + error += "\n\nCommand was :\n\n" + cmdline + "\n"; + + QMessageBox::warning(0, 0, format(error, 50).c_str()); + } + + return ret; +} + + +/** + * do_open_file_or_dir - open file/directory + * @param base_dir directory to start at + * @param dir_only directory or filename to select + * + * Select a file or directory. The selection is returned; + * an empty string if the selection was cancelled. + */ +string const do_open_file_or_dir(string const & base_dir, bool dir_only) +{ + QString result; + + if (dir_only) { + result = QFileDialog::getExistingDirectory(base_dir.c_str(), 0, + "open_file_or_dir", "Get directory name", true); + } else { + result = QFileDialog::getOpenFileName(base_dir.c_str(), 0, 0, + "open_file_or_dir", "Get filename"); + } + + if (result.isNull()) + return string(); + else + return result.latin1(); +} + +/** + * verify_argument - check string for potentially dangerous characters + * + * This function returns false if the string contains dangerous shell + * metacharacters. + * + * WWW Security FAQ dangerous chars: + * + * & ; ` ' \ " | * ? ~ < > ^ ( ) [ ] { } $ \n \r + * + * David Wheeler: ! # + * + * We allow '-' because we disallow whitespace. We allow ':' and '=' + */ +bool verify_argument(string const & str) +{ + if (str.find_first_not_of( + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz0123456789_:=-+%,./") + != string::npos) + return false; + return true; +} diff --git a/gui/oprof_start_util.h b/gui/oprof_start_util.h new file mode 100644 index 0000000..52fafad --- /dev/null +++ b/gui/oprof_start_util.h @@ -0,0 +1,39 @@ +/** + * @file oprof_start_util.h + * Miscellaneous helpers for the GUI start + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef OPROF_START_UTIL_H +#define OPROF_START_UTIL_H + +#include +#include +#include + +/// Store various daemon status data +struct daemon_status { + /// fill various data member according to the current daemon status + daemon_status(); + bool running; ///< true if daemon is running + unsigned int nr_interrupts; ///< nr_interrupts from profiling start +}; + +inline double ratio(double x1, double x2) +{ + return fabs(((x1 - x2) / x2)) * 100; +} + +std::string const get_user_filename(std::string const & filename); +bool check_and_create_config_dir(); +std::string const format(std::string const & orig, uint const maxlen); +int do_exec_command(std::string const & cmd, std::vector const & args = std::vector()); +std::string const do_open_file_or_dir(std::string const & base_dir, bool dir_only); +bool verify_argument(std::string const & str); + +#endif // OPROF_START_UTIL_H diff --git a/gui/ui/Makefile.am b/gui/ui/Makefile.am new file mode 100644 index 0000000..387ef4e --- /dev/null +++ b/gui/ui/Makefile.am @@ -0,0 +1,24 @@ +EXTRA_DIST = oprof_start.base.ui + +if have_qt + +AM_CPPFLAGS = @QT_INCLUDES@ + +AM_CXXFLAGS = @OP_CXXFLAGS@ + +noinst_LIBRARIES = liboprof_start.a +nodist_liboprof_start_a_SOURCES = oprof_start.base.cpp oprof_start.base.moc.cpp + +oprof_start.base.h: oprof_start.base.ui + $(UIC) -o $@ $< + +oprof_start.base.cpp: oprof_start.base.h oprof_start.base.ui + $(UIC) -o $@ -impl $^ + +oprof_start.base.moc.cpp: oprof_start.base.h + $(MOC) -o $@ $< + +clean-local: + rm -f oprof_start.base.h oprof_start.base.cpp oprof_start.base.moc.cpp + +endif diff --git a/gui/ui/Makefile.in b/gui/ui/Makefile.in new file mode 100644 index 0000000..a1587a4 --- /dev/null +++ b/gui/ui/Makefile.in @@ -0,0 +1,453 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(nodist_liboprof_start_a_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = gui/ui +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +liboprof_start_a_AR = $(AR) $(ARFLAGS) +liboprof_start_a_LIBADD = +@have_qt_TRUE@nodist_liboprof_start_a_OBJECTS = \ +@have_qt_TRUE@ oprof_start.base.$(OBJEXT) \ +@have_qt_TRUE@ oprof_start.base.moc.$(OBJEXT) +liboprof_start_a_OBJECTS = $(nodist_liboprof_start_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(nodist_liboprof_start_a_SOURCES) +DIST_SOURCES = +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +EXTRA_DIST = oprof_start.base.ui +@have_qt_TRUE@AM_CPPFLAGS = @QT_INCLUDES@ +@have_qt_TRUE@AM_CXXFLAGS = @OP_CXXFLAGS@ +@have_qt_TRUE@noinst_LIBRARIES = liboprof_start.a +@have_qt_TRUE@nodist_liboprof_start_a_SOURCES = oprof_start.base.cpp oprof_start.base.moc.cpp +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign gui/ui/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign gui/ui/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +liboprof_start.a: $(liboprof_start_a_OBJECTS) $(liboprof_start_a_DEPENDENCIES) + -rm -f liboprof_start.a + $(liboprof_start_a_AR) liboprof_start.a $(liboprof_start_a_OBJECTS) $(liboprof_start_a_LIBADD) + $(RANLIB) liboprof_start.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oprof_start.base.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oprof_start.base.moc.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +@have_qt_FALSE@clean-local: +clean: clean-am + +clean-am: clean-generic clean-local clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-local clean-noinstLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + + +@have_qt_TRUE@oprof_start.base.h: oprof_start.base.ui +@have_qt_TRUE@ $(UIC) -o $@ $< + +@have_qt_TRUE@oprof_start.base.cpp: oprof_start.base.h oprof_start.base.ui +@have_qt_TRUE@ $(UIC) -o $@ -impl $^ + +@have_qt_TRUE@oprof_start.base.moc.cpp: oprof_start.base.h +@have_qt_TRUE@ $(MOC) -o $@ $< + +@have_qt_TRUE@clean-local: +@have_qt_TRUE@ rm -f oprof_start.base.h oprof_start.base.cpp oprof_start.base.moc.cpp +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/gui/ui/oprof_start.base.ui b/gui/ui/oprof_start.base.ui new file mode 100644 index 0000000..c54c215 --- /dev/null +++ b/gui/ui/oprof_start.base.ui @@ -0,0 +1,1078 @@ + +oprof_start_base + + QDialog + + name + oprof_start_base + + + geometry + + 0 + 0 + 569 + 735 + + + + caption + Start profiler + + + sizeGripEnabled + true + + + + margin + 11 + + + spacing + 6 + + + QTabWidget + + name + setup_config_tab + + + QWidget + + name + counter_setup_page + + + title + &Setup + + + + margin + 11 + + + spacing + 6 + + + QGroupBox + + name + counter_group + + + title + Events + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout10 + + + + margin + 0 + + + spacing + 6 + + + QListView + + + text + Removedincode + + + clickable + false + + + resizeable + true + + + + name + events_list + + + minimumSize + + 250 + 0 + + + + selectionMode + Multi + + + toolTip + Available events + + + + QLayoutWidget + + name + Layout9 + + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + os_ring_count_cb + + + text + Profile &kernel + + + toolTip + Profile kernel code + + + + QCheckBox + + name + user_ring_count_cb + + + text + Profile &user binaries + + + toolTip + Profile user libraries and applications + + + + QLayoutWidget + + name + Layout16 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel1_2 + + + text + C&ount + + + buddy + event_count_edit + + + + QLineEdit + + name + event_count_edit + + + sizePolicy + + 1 + 0 + + + + toolTip + Set the count value + + + + + name + Spacer13_2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QButtonGroup + + name + unit_mask_group + + + sizePolicy + + 1 + 5 + + + + title + Unit mask + + + toolTip + Unit mask settings for this event + + + + margin + 11 + + + spacing + 6 + + + QCheckBox + + name + check0 + + + text + check0 + + + + QCheckBox + + name + check1 + + + text + check1 + + + + QCheckBox + + name + check2 + + + text + check2 + + + + QCheckBox + + name + check3 + + + text + check3 + + + + QCheckBox + + name + check4 + + + text + check4 + + + + QCheckBox + + name + check5 + + + text + check5 + + + + QCheckBox + + name + check6 + + + text + check6 + + + + QCheckBox + + name + check7 + + + text + check7 + + + + + name + Spacer14 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QCheckBox + + name + check11 + + + text + check11 + + + + QCheckBox + + name + check13 + + + text + check13 + + + + QCheckBox + + name + check15 + + + text + check15 + + + + QCheckBox + + name + check10 + + + text + check10 + + + + QCheckBox + + name + check14 + + + text + check14 + + + + QCheckBox + + name + check9 + + + text + check9 + + + + QCheckBox + + name + check8 + + + text + check8 + + + + QCheckBox + + name + check12 + + + text + check12 + + + + + + + + + + QLabel + + name + event_help_label + + + enabled + true + + + sizePolicy + + 1 + 1 + + + + frameShape + WinPanel + + + frameShadow + Sunken + + + text + + + + + + + + + QWidget + + name + configuration_page + + + title + &Configuration + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout11 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel1 + + + text + &Kernel image file + + + buddy + kernel_filename_edit + + + + QLineEdit + + name + kernel_filename_edit + + + toolTip + The vmlinux file of the running kernel + + + + QToolButton + + name + kernel_filename_tb + + + text + ... + + + + QCheckBox + + name + no_vmlinux + + + text + No kernel image + + + toolTip + No kernel image available. Disables kernel profiling. + + + + + + QLayoutWidget + + name + Layout16 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer11 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout15 + + + + margin + 0 + + + spacing + 6 + + + QLineEdit + + name + buffer_size_edit + + + toolTip + The size of the profiler's buffers + + + + QLineEdit + + name + note_table_size_edit + + + + QLabel + + name + note_table_size_label + + + text + Note Size + + + buddy + note_table_size_edit + + + + QLabel + + name + buffer_size_label + + + text + &Buffer size + + + buddy + buffer_size_edit + + + + + + + + QLayoutWidget + + name + Layout11 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout10 + + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + verbose + + + text + &Verbose + + + toolTip + Very verbose output in log file + + + + QCheckBox + + name + separate_lib_cb + + + text + Per-application profiles + + + toolTip + Separate samples for each shared library. This increases the time and space overhead of OProfile. + + + + QCheckBox + + name + separate_kernel_cb + + + text + Per-application profiles, including kernel + + + toolTip + Separate samples for each shared library and kernel samples. This increases the time and space overhead of OProfile. + + + + QCheckBox + + name + separate_cpu_cb + + + text + Per-CPU profiles + + + toolTip + Separate samples for each shared library and kernel samples. This increases the time and space overhead of OProfile. + + + + QCheckBox + + name + separate_thread_cb + + + text + Per-thread/task profiles + + + toolTip + Separate samples for each shared library and kernel samples. This increases the time and space overhead of OProfile. + + + + + + + name + Spacer12 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer9 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + QLabel + + name + daemon_label + + + frameShape + Panel + + + frameShadow + Sunken + + + text + + + + toolTip + Current daemon status + + + + QLayoutWidget + + name + Layout11 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + start_profiler_btn + + + text + Start &profiler + + + + QPushButton + + name + flush_profiler_data_btn + + + text + &Flush profiler data + + + + QPushButton + + name + stop_profiler_btn + + + text + Stop profiler + + + + + name + Spacer5 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + quit_and_save_btn + + + text + Save and &quit + + + autoDefault + true + + + + + + + + + start_profiler_btn + clicked() + oprof_start_base + on_start_profiler() + + + stop_profiler_btn + clicked() + oprof_start_base + on_stop_profiler() + + + flush_profiler_data_btn + clicked() + oprof_start_base + on_flush_profiler_data() + + + quit_and_save_btn + clicked() + oprof_start_base + accept() + + + kernel_filename_tb + clicked() + oprof_start_base + choose_kernel_filename() + + + no_vmlinux + toggled(bool) + kernel_filename_tb + setDisabled(bool) + + + no_vmlinux + toggled(bool) + kernel_filename_edit + setDisabled(bool) + + + no_vmlinux + toggled(bool) + TextLabel1 + setDisabled(bool) + + + events_list + selectionChanged() + oprof_start_base + event_selected() + + + events_list + onItem(QListViewItem*) + oprof_start_base + event_over(QListViewItem *) + + + separate_kernel_cb + stateChanged(int) + oprof_start_base + on_separate_kernel_cb_changed(int) + + choose_kernel_filename() + event_over(QListViewItem *) + event_selected() + on_flush_profiler_data() + on_separate_kernel_cb_changed(int) + on_start_profiler() + on_stop_profiler() + + + setup_config_tab + events_list + os_ring_count_cb + user_ring_count_cb + event_count_edit + check0 + check1 + check2 + check3 + check4 + check5 + check6 + check7 + check8 + check9 + check10 + check11 + check12 + check13 + check14 + check15 + start_profiler_btn + flush_profiler_data_btn + stop_profiler_btn + quit_and_save_btn + kernel_filename_edit + no_vmlinux + buffer_size_edit + note_table_size_edit + verbose + separate_kernel_cb + separate_lib_cb + + diff --git a/include/sstream b/include/sstream new file mode 100644 index 0000000..45393b1 --- /dev/null +++ b/include/sstream @@ -0,0 +1,343 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 2000 Free Software Foundation + +This file is part of the GNU IO Library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this library; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +/* Written by Magnus Fromreide (magfr@lysator.liu.se). */ +/* seekoff and ideas for overflow is largely borrowed from libstdc++-v3 */ + +#ifndef __SSTREAM__ +#define __SSTREAM__ + +#include +#include +#include + +namespace std +{ + class stringbuf : public streambuf + { + public: + typedef char char_type; + typedef int int_type; + typedef streampos pos_type; + typedef streamoff off_type; + + explicit + stringbuf(int which=ios::in|ios::out) + : streambuf(), mode(static_cast(which)), + stream(NULL), stream_len(0) + { + stringbuf_init(); + } + + explicit + stringbuf(const string &str, int which=ios::in|ios::out) + : streambuf(), mode(static_cast(which)), + stream(NULL), stream_len(0) + { + if (mode & (ios::in|ios::out)) + { + stream_len = str.size(); + stream = new char_type[stream_len]; + str.copy(stream, stream_len); + } + stringbuf_init(); + } + + virtual + ~stringbuf() + { + delete[] stream; + } + + string + str() const + { + if (pbase() != 0) + return string(stream, pptr()-pbase()); + else + return string(); + } + + void + str(const string& str) + { + delete[] stream; + stream_len = str.size(); + stream = new char_type[stream_len]; + str.copy(stream, stream_len); + stringbuf_init(); + } + + protected: + // The buffer is already in gptr, so if it ends then it is out of data. + virtual int + underflow() + { + return EOF; + } + + virtual int + overflow(int c = EOF) + { + int res; + if (mode & ios::out) + { + if (c != EOF) + { + streamsize old_stream_len = stream_len; + stream_len += 1; + char_type* new_stream = new char_type[stream_len]; + memcpy(new_stream, stream, old_stream_len); + delete[] stream; + stream = new_stream; + stringbuf_sync(gptr()-eback(), pptr()-pbase()); + sputc(c); + res = c; + } + else + res = EOF; + } + else + res = 0; + return res; + } + + virtual streambuf* + setbuf(char_type* s, streamsize n) + { + if (n != 0) + { + delete[] stream; + stream = new char_type[n]; + memcpy(stream, s, n); + stream_len = n; + stringbuf_sync(0, 0); + } + return this; + } + + virtual pos_type + seekoff(off_type off, ios::seek_dir way, int which = ios::in | ios::out) + { + pos_type ret = pos_type(off_type(-1)); + bool testin = which & ios::in && mode & ios::in; + bool testout = which & ios::out && mode & ios::out; + bool testboth = testin && testout && way != ios::cur; + + if (stream_len && ((testin != testout) || testboth)) + { + char_type* beg = stream; + char_type* curi = NULL; + char_type* curo = NULL; + char_type* endi = NULL; + char_type* endo = NULL; + + if (testin) + { + curi = gptr(); + endi = egptr(); + } + if (testout) + { + curo = pptr(); + endo = epptr(); + } + + off_type newoffi = 0; + off_type newoffo = 0; + if (way == ios::beg) + { + newoffi = beg - curi; + newoffo = beg - curo; + } + else if (way == ios::end) + { + newoffi = endi - curi; + newoffo = endo - curo; + } + + if (testin && newoffi + off + curi - beg >= 0 && + endi - beg >= newoffi + off + curi - beg) + { + gbump(newoffi + off); + ret = pos_type(newoffi + off + curi); + } + if (testout && newoffo + off + curo - beg >= 0 && + endo - beg >= newoffo + off + curo - beg) + { + pbump(newoffo + off); + ret = pos_type(newoffo + off + curo); + } + } + return ret; + } + + virtual pos_type + seekpos(pos_type sp, int which = ios::in | ios::out) + { + pos_type ret = seekoff(sp, ios::beg, which); + return ret; + } + + private: + void + stringbuf_sync(streamsize i, streamsize o) + { + if (mode & ios::in) + setg(stream, stream + i, stream + stream_len); + if (mode & ios::out) + { + setp(stream, stream + stream_len); + pbump(o); + } + } + void + stringbuf_init() + { + if (mode & ios::ate) + stringbuf_sync(0, stream_len); + else + stringbuf_sync(0, 0); + } + + private: + ios::open_mode mode; + char_type* stream; + streamsize stream_len; + }; + + class istringstream : public istream { + public: + typedef char char_type; + typedef int int_type; + typedef streampos pos_type; + typedef streamoff off_type; + + explicit + istringstream(int which=ios::in) + : istream(&sb), sb(which | ios::in) + { } + + explicit + istringstream(const string& str, int which=ios::in) + : istream(&sb), sb(str, which | ios::in) + { } + + stringbuf* + rdbuf() const + { + return const_cast(&sb); + } + + string + str() const + { + return rdbuf()->str(); + } + void + str(const string& s) + { + rdbuf()->str(s); + } + private: + stringbuf sb; + }; + + class ostringstream : public ostream { + public: + typedef char char_type; + typedef int int_type; + typedef streampos pos_type; + typedef streamoff off_type; + + explicit + ostringstream(int which=ios::out) + : ostream(&sb), sb(which | ios::out) + { } + + explicit + ostringstream(const string& str, int which=ios::out) + : ostream(&sb), sb(str, which | ios::out) + { } + + stringbuf* + rdbuf() const + { + return const_cast(&sb); + } + + string + str() const + { + return rdbuf()->str(); + } + + void str(const string& s) + { + rdbuf()->str(s); + } + private: + stringbuf sb; + }; + + class stringstream : public iostream { + public: + typedef char char_type; + typedef int int_type; + typedef streampos pos_type; + typedef streamoff off_type; + + explicit + stringstream(int which=ios::out|ios::in) + : iostream(&sb), sb(which) + { } + + explicit + stringstream(const string& str, int which=ios::out|ios::in) + : iostream(&sb), sb(str, which) + { } + + stringbuf* + rdbuf() const + { + return const_cast(&sb); + } + + string + str() const + { + return rdbuf()->str(); + } + + void + str(const string& s) + { + rdbuf()->str(s); + } + private: + stringbuf sb; + }; +}; + +#endif /* not __STRSTREAM__ */ diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..1a83534 --- /dev/null +++ b/install-sh @@ -0,0 +1,323 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2005-02-02.21 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +chmodcmd="$chmodprog 0755" +chowncmd= +chgrpcmd= +stripcmd= +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src= +dst= +dir_arg= +dstarg= +no_target_directory= + +usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: +-c (ignored) +-d create directories instead of installing files. +-g GROUP $chgrpprog installed files to GROUP. +-m MODE $chmodprog installed files to MODE. +-o USER $chownprog installed files to USER. +-s $stripprog installed files. +-t DIRECTORY install into DIRECTORY. +-T report an error if DSTFILE is a directory. +--help display this help and exit. +--version display version info and exit. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG +" + +while test -n "$1"; do + case $1 in + -c) shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + --help) echo "$usage"; exit $?;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -s) stripcmd=$stripprog + shift + continue;; + + -t) dstarg=$2 + shift + shift + continue;; + + -T) no_target_directory=true + shift + continue;; + + --version) echo "$0 $scriptversion"; exit $?;; + + *) # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + test -n "$dir_arg$dstarg" && break + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done + break;; + esac +done + +if test -z "$1"; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src ;; + esac + + if test -n "$dir_arg"; then + dst=$src + src= + + if test -d "$dst"; then + mkdircmd=: + chmodcmd= + else + mkdircmd=$mkdirprog + fi + else + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dstarg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dstarg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst ;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dstarg: Is a directory" >&2 + exit 1 + fi + dst=$dst/`basename "$src"` + fi + fi + + # This sed command emulates the dirname command. + dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` + + # Make sure that the destination directory exists. + + # Skip lots of stat calls in the usual case. + if test ! -d "$dstdir"; then + defaultIFS=' + ' + IFS="${IFS-$defaultIFS}" + + oIFS=$IFS + # Some sh's can't handle IFS=/ for some reason. + IFS='%' + set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` + shift + IFS=$oIFS + + pathcomp= + + while test $# -ne 0 ; do + pathcomp=$pathcomp$1 + shift + if test ! -d "$pathcomp"; then + $mkdirprog "$pathcomp" + # mkdir can fail with a `File exist' error in case several + # install-sh are creating the directory concurrently. This + # is OK. + test -d "$pathcomp" || exit + fi + pathcomp=$pathcomp/ + done + fi + + if test -n "$dir_arg"; then + $doit $mkdircmd "$dst" \ + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } + + else + dstfile=`basename "$dst"` + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + trap '(exit $?); exit' 1 2 13 15 + + # Copy the file name to the temp name. + $doit $cpprog "$src" "$dsttmp" && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && + + # Now rename the file to the real destination. + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ + || { + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit 1 + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + } + } + fi || { (exit 1); exit 1; } +done + +# The final little trick to "correctly" pass the exit status to the exit trap. +{ + (exit 0); exit 0 +} + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/libabi/Makefile.am b/libabi/Makefile.am new file mode 100644 index 0000000..a1a277c --- /dev/null +++ b/libabi/Makefile.am @@ -0,0 +1,37 @@ +SUBDIRS=. tests + +dist_sources = \ + abi.cpp \ + op_abi.cpp \ + abi.h \ + op_abi.h \ + opimport.cpp + +EXTRA_DIST = $(dist_sources) + +LIBS=@POPT_LIBS@ @LIBERTY_LIBS@ + +if enable_abi + +AM_CPPFLAGS = \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libdb \ + -I ${top_srcdir}/libopt++ + +AM_CXXFLAGS = @OP_CXXFLAGS@ + +noinst_LIBRARIES = libabi.a +libabi_a_SOURCES = abi.cpp op_abi.cpp + +bin_PROGRAMS = opimport + +opimport_SOURCES = opimport.cpp +opimport_LDADD = \ + libabi.a \ + ../libdb/libodb.a \ + ../libopt++/libopt++.a \ + ../libutil++/libutil++.a \ + ../libutil/libutil.a + +endif diff --git a/libabi/Makefile.in b/libabi/Makefile.in new file mode 100644 index 0000000..773e941 --- /dev/null +++ b/libabi/Makefile.in @@ -0,0 +1,614 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +SOURCES = $(libabi_a_SOURCES) $(opimport_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +@enable_abi_TRUE@bin_PROGRAMS = opimport$(EXEEXT) +subdir = libabi +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libabi_a_AR = $(AR) $(ARFLAGS) +libabi_a_LIBADD = +am__libabi_a_SOURCES_DIST = abi.cpp op_abi.cpp +@enable_abi_TRUE@am_libabi_a_OBJECTS = abi.$(OBJEXT) op_abi.$(OBJEXT) +libabi_a_OBJECTS = $(am_libabi_a_OBJECTS) +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am__opimport_SOURCES_DIST = opimport.cpp +@enable_abi_TRUE@am_opimport_OBJECTS = opimport.$(OBJEXT) +opimport_OBJECTS = $(am_opimport_OBJECTS) +@enable_abi_TRUE@opimport_DEPENDENCIES = libabi.a ../libdb/libodb.a \ +@enable_abi_TRUE@ ../libopt++/libopt++.a \ +@enable_abi_TRUE@ ../libutil++/libutil++.a ../libutil/libutil.a +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(libabi_a_SOURCES) $(opimport_SOURCES) +DIST_SOURCES = $(am__libabi_a_SOURCES_DIST) \ + $(am__opimport_SOURCES_DIST) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @POPT_LIBS@ @LIBERTY_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +SUBDIRS = . tests +dist_sources = \ + abi.cpp \ + op_abi.cpp \ + abi.h \ + op_abi.h \ + opimport.cpp + +EXTRA_DIST = $(dist_sources) +@enable_abi_TRUE@AM_CPPFLAGS = \ +@enable_abi_TRUE@ -I ${top_srcdir}/libop \ +@enable_abi_TRUE@ -I ${top_srcdir}/libutil \ +@enable_abi_TRUE@ -I ${top_srcdir}/libdb \ +@enable_abi_TRUE@ -I ${top_srcdir}/libopt++ + +@enable_abi_TRUE@AM_CXXFLAGS = @OP_CXXFLAGS@ +@enable_abi_TRUE@noinst_LIBRARIES = libabi.a +@enable_abi_TRUE@libabi_a_SOURCES = abi.cpp op_abi.cpp +@enable_abi_TRUE@opimport_SOURCES = opimport.cpp +@enable_abi_TRUE@opimport_LDADD = \ +@enable_abi_TRUE@ libabi.a \ +@enable_abi_TRUE@ ../libdb/libodb.a \ +@enable_abi_TRUE@ ../libopt++/libopt++.a \ +@enable_abi_TRUE@ ../libutil++/libutil++.a \ +@enable_abi_TRUE@ ../libutil/libutil.a + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libabi/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libabi/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libabi.a: $(libabi_a_OBJECTS) $(libabi_a_DEPENDENCIES) + -rm -f libabi.a + $(libabi_a_AR) libabi.a $(libabi_a_OBJECTS) $(libabi_a_LIBADD) + $(RANLIB) libabi.a +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +opimport$(EXEEXT): $(opimport_OBJECTS) $(opimport_DEPENDENCIES) + @rm -f opimport$(EXEEXT) + $(CXXLINK) $(opimport_LDFLAGS) $(opimport_OBJECTS) $(opimport_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_abi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opimport.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LIBRARIES) $(PROGRAMS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: install-binPROGRAMS + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ + clean-recursive ctags ctags-recursive distclean \ + distclean-compile distclean-generic distclean-recursive \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-binPROGRAMS uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libabi/abi.cpp b/libabi/abi.cpp new file mode 100644 index 0000000..2a24b45 --- /dev/null +++ b/libabi/abi.cpp @@ -0,0 +1,142 @@ +/** + * @file abi.cpp + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Graydon Hoare + * @author John Levon + */ + +#include "abi.h" +#include "odb.h" +#include "op_sample_file.h" + +#include +#include + +using namespace std; + +typedef map abi_map; +typedef map::const_iterator abi_iter; + +#define byte_addr(x) (reinterpret_cast(&(x))) +#define field_offset(s, f) (byte_addr(s.f) - byte_addr(s)) + +abi_exception::abi_exception(string const d) : desc(d) {} + + +abi::abi() +{ + odb_node_t node; + odb_descr_t descr; + struct opd_header header; + + slots["sizeof_double"] = sizeof(double); + slots["sizeof_time_t"] = sizeof(time_t); + slots["sizeof_u8"] = sizeof(u8); + slots["sizeof_u32"] = sizeof(u32); + slots["sizeof_int"] = sizeof(int); + slots["sizeof_unsigned_int"] = sizeof(unsigned int); + slots["sizeof_odb_key_t"] = sizeof(odb_key_t); + slots["sizeof_odb_index_t"] = sizeof(odb_index_t); + slots["sizeof_odb_value_t"] = sizeof(odb_value_t); + slots["sizeof_odb_node_nr_t"] = sizeof(odb_node_nr_t); + slots["sizeof_odb_descr_t"] = sizeof(odb_descr_t); + slots["sizeof_odb_node_t"] = sizeof(odb_node_t); + slots["sizeof_struct_opd_header"] = sizeof(struct opd_header); + + slots["offsetof_node_key"] = field_offset(node, key); + slots["offsetof_node_value"] = field_offset(node, value); + slots["offsetof_node_next"] = field_offset(node, next); + + slots["offsetof_descr_size"] = field_offset(descr, size); + slots["offsetof_descr_current_size"] = field_offset(descr, current_size); + + slots["offsetof_header_magic"] = field_offset(header, magic); + slots["offsetof_header_version"] = field_offset(header, version); + slots["offsetof_header_cpu_type"] = field_offset(header, cpu_type); + slots["offsetof_header_ctr_event"] = field_offset(header, ctr_event); + slots["offsetof_header_ctr_um"] = field_offset(header, ctr_um); + slots["offsetof_header_ctr_count"] = field_offset(header, ctr_count); + slots["offsetof_header_is_kernel"] = field_offset(header, is_kernel); + slots["offsetof_header_cpu_speed"] = field_offset(header, cpu_speed); + slots["offsetof_header_mtime"] = field_offset(header, mtime); + slots["offsetof_header_cg_to_is_kernel"] = field_offset(header, + cg_to_is_kernel); + slots["offsetof_header_anon_start"] = field_offset(header, anon_start); + slots["offsetof_header_cg_to_anon_start"] = field_offset(header, + cg_to_anon_start); + + // determine endianness + + unsigned int probe = 0xff; + size_t sz = sizeof(unsigned int); + unsigned char * probe_byte = reinterpret_cast(&probe); + + assert(probe_byte[0] == 0xff || probe_byte[sz - 1] == 0xff); + + if (probe_byte[0] == 0xff) + slots["little_endian"] = 1; + else + slots["little_endian"] = 0; +} + + +abi::abi(abi const & other) +{ + slots.clear(); + slots.insert(other.slots.begin(), other.slots.end()); +} + + +int abi::need(string const key) const throw (abi_exception) +{ + if (slots.find(key) != slots.end()) + return slots.find(key)->second; + else + throw abi_exception(string("missing ABI key: ") + key); +} + + +bool abi::operator==(abi const & other) const +{ + abi_iter i = slots.begin(); + abi_iter e = slots.end(); + abi_map const & theirs = other.slots; + + for (; i != e; ++i) { + if (theirs.find(i->first) == theirs.end() || + theirs.find(i->first)->second != i->second) + return false; + } + + return true; +} + + +ostream & operator<<(ostream & o, abi const & abi) +{ + abi_iter i = abi.slots.begin(); + abi_iter e = abi.slots.end(); + + for (; i != e; ++i) { + o << i->first << " " << i->second << endl; + } + + return o; +} + + +istream & operator>>(istream & i, abi & abi) +{ + string key; + int val; + abi.slots.clear(); + + while(i >> key >> val) { + abi.slots[key] = val; + } + + return i; +} diff --git a/libabi/abi.h b/libabi/abi.h new file mode 100644 index 0000000..ce439e0 --- /dev/null +++ b/libabi/abi.h @@ -0,0 +1,43 @@ +/** + * @file abi.h + * + * Contains internal ABI management class + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Graydon Hoare + */ + +#ifndef OPROF_ABI_H +#define OPROF_ABI_H + +#include +#include +#include + +struct abi_exception : std::exception { + std::string const desc; + + explicit abi_exception(std::string const d); + + ~abi_exception() throw() {} +}; + + +class abi { +public: + abi(); + abi(abi const & other); + + int need(std::string const key) const throw (abi_exception); + + bool operator==(abi const & other) const; + friend std::ostream & operator<<(std::ostream & o, abi const & abi); + friend std::istream & operator>>(std::istream & i, abi & abi); + +private: + std::map slots; +}; + +#endif // OPROF_ABI_H diff --git a/libabi/op_abi.cpp b/libabi/op_abi.cpp new file mode 100644 index 0000000..6460d01 --- /dev/null +++ b/libabi/op_abi.cpp @@ -0,0 +1,30 @@ +/** + * @file op_abi.cpp + * This file contains a simple C interface to the ABI-describing functionality, + * the majority of which is implemented in C++. this is the file which is + * intended for use in files outside the /libabi directory. + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Graydon Hoare + */ + +#include "op_abi.h" +#include "abi.h" + +#include + +using namespace std; + +int op_write_abi_to_file(char const * abi_file) +{ + ofstream file(abi_file); + if (!file) + return 0; + + abi curr; + file << curr; + + return 1; +} diff --git a/libabi/op_abi.h b/libabi/op_abi.h new file mode 100644 index 0000000..94ddd20 --- /dev/null +++ b/libabi/op_abi.h @@ -0,0 +1,30 @@ +/** + * @file op_abi.h + * This file contains a simple C interface to the ABI-describing functionality, + * the majority of which is implemented in C++. this is the file which is + * intended for use in files outside the /libabi directory. + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Graydon Hoare + */ + +#ifndef OP_ABI_H +#define OP_ABI_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Write current abi to file. + * return 1 on success, 0 on failure + */ +int op_write_abi_to_file(char const * abi_file); + +#ifdef __cplusplus +} +#endif + +#endif // OP_ABI_H diff --git a/libabi/opimport.cpp b/libabi/opimport.cpp new file mode 100644 index 0000000..614b690 --- /dev/null +++ b/libabi/opimport.cpp @@ -0,0 +1,221 @@ +/** + * @file opimport.cpp + * Import sample files from other ABI + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Graydon Hoare + */ + +#include "abi.h" +#include "odb.h" +#include "popt_options.h" +#include "op_sample_file.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace std; + +namespace { + string output_filename; + string abi_filename; + bool verbose; + bool force; +}; + + +popt::option options_array[] = { + popt::option(verbose, "verbose", 'V', "verbose output"), + popt::option(output_filename, "output", 'o', "output to file", "filename"), + popt::option(abi_filename, "abi", 'a', "abi description", "filename"), + popt::option(force, "force", 'f', "force conversion, even if identical") +}; + + +struct extractor { + + abi const & theabi; + + unsigned char const * begin; + unsigned char const * end; + bool little_endian; + + explicit + extractor(abi const & a, unsigned char const * src, size_t len) + : theabi(a), begin(src), end(src + len) { + little_endian = theabi.need(string("little_endian")) == 1; + if (verbose) { + cerr << "source byte order is: " + << string(little_endian ? "little" : "big") + << " endian" << endl; + } + } + + template + void extract(T & targ, void const * src_, + char const * sz, char const * off); +}; + + +template +void extractor::extract(T & targ, void const * src_, + char const * sz, char const * off) +{ + unsigned char const * src = static_cast(src_) + + theabi.need(off); + size_t nbytes = theabi.need(sz); + + if (nbytes == 0) + return; + + assert(nbytes <= sizeof(T)); + assert(src >= begin); + assert(src + nbytes <= end); + + if (verbose) + cerr << hex << "get " << sz << " = " << nbytes + << " bytes @ " << off << " = " << (src - begin) + << " : "; + + targ = 0; + if (little_endian) + while(nbytes--) + targ = (targ << 8) | src[nbytes]; + else + for(size_t i = 0; i < nbytes; ++i) + targ = (targ << 8) | src[i]; + + if (verbose) + cerr << " = " << targ << endl; +} + + +void import_from_abi(abi const & abi, void const * srcv, + size_t len, odb_t * dest) throw (abi_exception) +{ + struct opd_header * head = + static_cast(odb_get_data(dest)); + unsigned char const * src = static_cast(srcv); + unsigned char const * const begin = src; + extractor ext(abi, src, len); + + memcpy(head->magic, src + abi.need("offsetof_header_magic"), 4); + + // begin extracting opd header + ext.extract(head->version, src, "sizeof_u32", "offsetof_header_version"); + ext.extract(head->cpu_type, src, "sizeof_u32", "offsetof_header_cpu_type"); + ext.extract(head->ctr_event, src, "sizeof_u32", "offsetof_header_ctr_event"); + ext.extract(head->ctr_um, src, "sizeof_u32", "offsetof_header_ctr_um"); + ext.extract(head->ctr_count, src, "sizeof_u32", "offsetof_header_ctr_count"); + ext.extract(head->is_kernel, src, "sizeof_u32", "offsetof_header_is_kernel"); + // "double" extraction is unlikely to work + head->cpu_speed = 0.0; + ext.extract(head->mtime, src, "sizeof_time_t", "offsetof_header_mtime"); + ext.extract(head->cg_to_is_kernel, src, "sizeof_u32", + "offsetof_header_cg_to_is_kernel"); + ext.extract(head->anon_start, src, "sizeof_u32", + "offsetof_header_anon_start"); + ext.extract(head->cg_to_anon_start, src, "sizeof_u32", + "offsetof_header_cg_to_anon_start"); + src += abi.need("sizeof_struct_opd_header"); + // done extracting opd header + + // begin extracting necessary parts of descr + odb_node_nr_t node_nr; + ext.extract(node_nr, src, "sizeof_odb_node_nr_t", "offsetof_descr_current_size"); + src += abi.need("sizeof_odb_descr_t"); + // done extracting descr + + // skip node zero, it is reserved and contains nothing usefull + src += abi.need("sizeof_odb_node_t"); + + // begin extracting nodes + unsigned int step = abi.need("sizeof_odb_node_t"); + if (verbose) + cerr << "extracting " << node_nr << " nodes of " << step << " bytes each " << endl; + + assert(src + (node_nr * step) <= begin + len); + + for (odb_node_nr_t i = 1 ; i < node_nr ; ++i, src += step) { + odb_key_t key; + odb_value_t val; + ext.extract(key, src, "sizeof_odb_key_t", "offsetof_node_key"); + ext.extract(val, src, "sizeof_odb_value_t", "offsetof_node_value"); + int rc = odb_insert(dest, key, val); + if (rc != EXIT_SUCCESS) { + cerr << strerror(rc) << endl; + exit(EXIT_FAILURE); + } + } + // done extracting nodes +} + + +int main(int argc, char const ** argv) +{ + + vector inputs; + popt::parse_options(argc, argv, inputs); + + if (inputs.size() != 1) { + cerr << "error: must specify exactly 1 input file" << endl; + exit(1); + } + + abi current_abi, input_abi; + + { + ifstream abi_file(abi_filename.c_str()); + if (!abi_file) { + cerr << "error: cannot open abi file " + << abi_filename << endl; + exit(1); + } + abi_file >> input_abi; + } + + if (!force && current_abi == input_abi) { + cerr << "input abi is identical to native. " + << "no conversion necessary." << endl; + exit(1); + } + + int in_fd; + struct stat statb; + void * in; + odb_t dest; + int rc; + + assert((in_fd = open(inputs[0].c_str(), O_RDONLY)) > 0); + assert(fstat(in_fd, &statb) == 0); + assert((in = mmap(0, statb.st_size, PROT_READ, + MAP_PRIVATE, in_fd, 0)) != (void *)-1); + + rc = odb_open(&dest, output_filename.c_str(), ODB_RDWR, + sizeof(struct opd_header)); + if (rc) { + cerr << "odb_open() fail:\n" + << strerror(rc) << endl; + exit(EXIT_FAILURE); + } + + try { + import_from_abi(input_abi, in, statb.st_size, &dest); + } catch (abi_exception & e) { + cerr << "caught abi exception: " << e.desc << endl; + } + + odb_close(&dest); + + assert(munmap(in, statb.st_size) == 0); +} diff --git a/libabi/tests/Makefile.am b/libabi/tests/Makefile.am new file mode 100644 index 0000000..b171b17 --- /dev/null +++ b/libabi/tests/Makefile.am @@ -0,0 +1,30 @@ + +dist_sources = abi_test.cpp + +EXTRA_DIST = $(dist_sources) + +LIBS=@POPT_LIBS@ @LIBERTY_LIBS@ + +if enable_abi + +AM_CPPFLAGS = \ + -I ${top_srcdir}/libabi \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libdb \ + -I ${top_srcdir}/libopt++ \ + -I ${top_srcdir}/libutil + +AM_CXXFLAGS = @OP_CXXFLAGS@ + +check_PROGRAMS = abi_test + +abi_test_SOURCES = abi_test.cpp +abi_test_LDADD = \ + ../libabi.a \ + ../../libop/libop.a \ + ../../libdb/libodb.a \ + ../../libopt++/libopt++.a \ + ../../libutil++/libutil++.a \ + ../../libutil/libutil.a + +endif diff --git a/libabi/tests/Makefile.in b/libabi/tests/Makefile.in new file mode 100644 index 0000000..b53a7ef --- /dev/null +++ b/libabi/tests/Makefile.in @@ -0,0 +1,451 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +SOURCES = $(abi_test_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +@enable_abi_TRUE@check_PROGRAMS = abi_test$(EXEEXT) +subdir = libabi/tests +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__abi_test_SOURCES_DIST = abi_test.cpp +@enable_abi_TRUE@am_abi_test_OBJECTS = abi_test.$(OBJEXT) +abi_test_OBJECTS = $(am_abi_test_OBJECTS) +@enable_abi_TRUE@abi_test_DEPENDENCIES = ../libabi.a \ +@enable_abi_TRUE@ ../../libop/libop.a ../../libdb/libodb.a \ +@enable_abi_TRUE@ ../../libopt++/libopt++.a \ +@enable_abi_TRUE@ ../../libutil++/libutil++.a \ +@enable_abi_TRUE@ ../../libutil/libutil.a +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(abi_test_SOURCES) +DIST_SOURCES = $(am__abi_test_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @POPT_LIBS@ @LIBERTY_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +dist_sources = abi_test.cpp +EXTRA_DIST = $(dist_sources) +@enable_abi_TRUE@AM_CPPFLAGS = \ +@enable_abi_TRUE@ -I ${top_srcdir}/libabi \ +@enable_abi_TRUE@ -I ${top_srcdir}/libop \ +@enable_abi_TRUE@ -I ${top_srcdir}/libdb \ +@enable_abi_TRUE@ -I ${top_srcdir}/libopt++ \ +@enable_abi_TRUE@ -I ${top_srcdir}/libutil + +@enable_abi_TRUE@AM_CXXFLAGS = @OP_CXXFLAGS@ +@enable_abi_TRUE@abi_test_SOURCES = abi_test.cpp +@enable_abi_TRUE@abi_test_LDADD = \ +@enable_abi_TRUE@ ../libabi.a \ +@enable_abi_TRUE@ ../../libop/libop.a \ +@enable_abi_TRUE@ ../../libdb/libodb.a \ +@enable_abi_TRUE@ ../../libopt++/libopt++.a \ +@enable_abi_TRUE@ ../../libutil++/libutil++.a \ +@enable_abi_TRUE@ ../../libutil/libutil.a + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libabi/tests/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libabi/tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +abi_test$(EXEEXT): $(abi_test_OBJECTS) $(abi_test_DEPENDENCIES) + @rm -f abi_test$(EXEEXT) + $(CXXLINK) $(abi_test_LDFLAGS) $(abi_test_OBJECTS) $(abi_test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abi_test.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean \ + clean-checkPROGRAMS clean-generic ctags distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libabi/tests/abi_test.cpp b/libabi/tests/abi_test.cpp new file mode 100644 index 0000000..108e5e4 --- /dev/null +++ b/libabi/tests/abi_test.cpp @@ -0,0 +1,94 @@ +/** + * @file abi_test.cpp + * Import sample files from other ABI + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Graydon Hoare + */ + +#include "abi.h" +#include "odb.h" +#include "popt_options.h" +#include "op_sample_file.h" +#include "op_cpu_type.h" +#include "op_config.h" + +#include +#include + +using namespace std; + +namespace { + string db_filename; + string abi_filename; +} + + +popt::option options_array[] = { + popt::option(db_filename, "db", 'd', "output db to file", "filename"), + popt::option(abi_filename, "abi", 'a', "output abi to file", "filename") +}; + + +int main(int argc, char const ** argv) +{ + vector rest; + popt::parse_options(argc, argv, rest); + + if (abi_filename.empty() && db_filename.empty()) { + cerr << "error: no file specified to work on" << endl; + exit(1); + } + + + if (!abi_filename.empty()) { + ofstream file(abi_filename.c_str()); + if (!file) { + cerr << "error: cannot open " << abi_filename + << " for writing" << endl; + exit(1); + } + file << abi(); + } + + if (!db_filename.empty()) { + odb_t dest; + int rc = odb_open(&dest, db_filename.c_str(), ODB_RDWR, + sizeof(struct opd_header)); + + if (rc) { + cerr << "odb_open() fail:\n" + << strerror(rc) << endl; + exit(EXIT_FAILURE); + } + + struct opd_header * header; + header = static_cast(odb_get_data(&dest)); + memset(header, '\0', sizeof(struct opd_header)); + header->version = OPD_VERSION; + memcpy(header->magic, OPD_MAGIC, sizeof(header->magic)); + header->is_kernel = 1; + /* ICACHE_FETCHES */ + header->ctr_event = 0x80; + header->ctr_um = 0x0; + header->cpu_type = CPU_ATHLON; + header->ctr_count = 0xdeadbeef; + header->cpu_speed = 0; + header->mtime = 1034790063; + header->cg_to_is_kernel = 1; + header->anon_start = 0; + header->cg_to_anon_start = 0; + + for (int i = 0; i < 3793; ++i) { + int rc = odb_insert(&dest, ((i * i) ^ (i + i)), + ((i * i) ^ i)); + if (rc != EXIT_SUCCESS) { + cerr << strerror(rc) << endl; + exit(EXIT_FAILURE); + } + } + odb_close(&dest); + } +} diff --git a/libdb/Makefile.am b/libdb/Makefile.am new file mode 100644 index 0000000..61658f9 --- /dev/null +++ b/libdb/Makefile.am @@ -0,0 +1,18 @@ +SUBDIRS=. tests + +AM_CPPFLAGS = \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libutil + +AM_CFLAGS = @OP_CFLAGS@ + +noinst_LIBRARIES = libodb.a + +libodb_a_SOURCES = \ + db_manage.c \ + db_insert.c \ + db_travel.c \ + db_debug.c \ + db_stat.c \ + odb.h + diff --git a/libdb/Makefile.in b/libdb/Makefile.in new file mode 100644 index 0000000..bb54977 --- /dev/null +++ b/libdb/Makefile.in @@ -0,0 +1,561 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(libodb_a_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = libdb +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libodb_a_AR = $(AR) $(ARFLAGS) +libodb_a_LIBADD = +am_libodb_a_OBJECTS = db_manage.$(OBJEXT) db_insert.$(OBJEXT) \ + db_travel.$(OBJEXT) db_debug.$(OBJEXT) db_stat.$(OBJEXT) +libodb_a_OBJECTS = $(am_libodb_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libodb_a_SOURCES) +DIST_SOURCES = $(libodb_a_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +SUBDIRS = . tests +AM_CPPFLAGS = \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libutil + +AM_CFLAGS = @OP_CFLAGS@ +noinst_LIBRARIES = libodb.a +libodb_a_SOURCES = \ + db_manage.c \ + db_insert.c \ + db_travel.c \ + db_debug.c \ + db_stat.c \ + odb.h + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libdb/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libdb/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libodb.a: $(libodb_a_OBJECTS) $(libodb_a_DEPENDENCIES) + -rm -f libodb.a + $(libodb_a_AR) libodb.a $(libodb_a_OBJECTS) $(libodb_a_LIBADD) + $(RANLIB) libodb.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/db_debug.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/db_insert.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/db_manage.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/db_stat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/db_travel.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LIBRARIES) +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-generic clean-noinstLIBRARIES clean-recursive \ + ctags ctags-recursive distclean distclean-compile \ + distclean-generic distclean-recursive distclean-tags distdir \ + dvi dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libdb/db_debug.c b/libdb/db_debug.c new file mode 100644 index 0000000..8e88dcc --- /dev/null +++ b/libdb/db_debug.c @@ -0,0 +1,134 @@ +/** + * @file db_debug.c + * Debug routines for libdb + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#include +#include +#include + +#include "odb.h" + +static int check_circular_list(odb_data_t const * data) +{ + odb_node_nr_t pos; + int do_abort = 0; + unsigned char * bitmap = malloc(data->descr->current_size); + memset(bitmap, '\0', data->descr->current_size); + + for (pos = 0 ; pos < data->descr->size * BUCKET_FACTOR ; ++pos) { + + odb_index_t index = data->hash_base[pos]; + if (index && !do_abort) { + while (index) { + if (bitmap[index]) { + do_abort = 1; + } + bitmap[index] = 1; + index = data->node_base[index].next; + } + } + + if (do_abort) { + printf("circular list detected size: %d\n", + data->descr->current_size); + + memset(bitmap, '\0', data->descr->current_size); + + index = data->hash_base[pos]; + while (index) { + printf("%d ", index); + if (bitmap[index]) { + exit(1); + } + bitmap[index] = 1; + index = data->node_base[index].next; + } + } + + /* purely an optimization: intead of memset the map reset only + * the needed part: not my use to optimize test but here the + * test was so slow it was useless */ + index = data->hash_base[pos]; + while (index) { + bitmap[index] = 1; + index = data->node_base[index].next; + } + } + + free(bitmap); + + return do_abort; +} + +static int check_redundant_key(odb_data_t const * data, odb_key_t max) +{ + odb_node_nr_t pos; + + unsigned char * bitmap = malloc(max + 1); + memset(bitmap, '\0', max + 1); + + for (pos = 1 ; pos < data->descr->current_size ; ++pos) { + if (bitmap[data->node_base[pos].key]) { + printf("redundant key found %lld\n", + (unsigned long long)data->node_base[pos].key); + return 1; + } + bitmap[data->node_base[pos].key] = 1; + } + free(bitmap); + + return 0; +} + +int odb_check_hash(odb_t const * odb) +{ + odb_node_nr_t pos; + odb_node_nr_t nr_node = 0; + odb_node_nr_t nr_node_out_of_bound = 0; + int ret = 0; + odb_key_t max = 0; + odb_data_t * data = odb->data; + + for (pos = 0 ; pos < data->descr->size * BUCKET_FACTOR ; ++pos) { + odb_index_t index = data->hash_base[pos]; + while (index) { + if (index >= data->descr->current_size) { + nr_node_out_of_bound++; + break; + } + ++nr_node; + + if (data->node_base[index].key > max) + max = data->node_base[index].key; + + index = data->node_base[index].next; + } + } + + if (nr_node != data->descr->current_size - 1) { + printf("hash table walk found %d node expect %d node\n", + nr_node, data->descr->current_size - 1); + ret = 1; + } + + if (nr_node_out_of_bound) { + printf("out of bound node index: %d\n", nr_node_out_of_bound); + ret = 1; + } + + if (ret == 0) { + ret = check_circular_list(data); + } + + if (ret == 0) { + ret = check_redundant_key(data, max); + } + + return ret; +} diff --git a/libdb/db_insert.c b/libdb/db_insert.c new file mode 100644 index 0000000..2c99640 --- /dev/null +++ b/libdb/db_insert.c @@ -0,0 +1,66 @@ +/** + * @file db_insert.c + * Inserting a key-value pair into a DB + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include + +#include "odb.h" + +int odb_insert(odb_t * odb, odb_key_t key, odb_value_t value) +{ + odb_index_t index; + odb_index_t new_node; + odb_node_t * node; + odb_data_t * data; + + data = odb->data; + index = data->hash_base[odb_do_hash(data, key)]; + while (index) { + if (index <= 0 || index >= data->descr->current_size) { + return EINVAL; + } + node = &data->node_base[index]; + if (node->key == key) { + if (node->value + value >= node->value) { + node->value += value; + } else { + /* post profile tools must handle overflow */ + node->value = ~(odb_value_t)0; + } + return 0; + } + + index = node->next; + } + + /* no locking is necessary: iteration interface retrieve data through + * the node_base array, odb_hash_add_node() increase current_size but + * odb_travel just ignore node with a zero key so on setting the key + * atomically update the node */ + new_node = odb_hash_add_node(odb); + if (new_node == ODB_NODE_NR_INVALID) { + return EINVAL; + } + + node = &data->node_base[new_node]; + node->value = value; + node->key = key; + + /* we need to recalculate hash code, hash table has perhaps grown */ + index = odb_do_hash(data, key); + node->next = data->hash_base[index]; + data->hash_base[index] = new_node; + + return 0; +} diff --git a/libdb/db_manage.c b/libdb/db_manage.c new file mode 100644 index 0000000..afe31f5 --- /dev/null +++ b/libdb/db_manage.c @@ -0,0 +1,312 @@ +/** + * @file db_manage.c + * Management of a DB file + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "odb.h" +#include "op_string.h" +#include "op_libiberty.h" + + +static __inline odb_descr_t * odb_to_descr(odb_data_t * data) +{ + return (odb_descr_t *)(((char*)data->base_memory) + data->sizeof_header); +} + + +static __inline odb_node_t * odb_to_node_base(odb_data_t * data) +{ + return (odb_node_t *)(((char *)data->base_memory) + data->offset_node); +} + + +static __inline odb_index_t * odb_to_hash_base(odb_data_t * data) +{ + return (odb_index_t *)(((char *)data->base_memory) + + data->offset_node + + (data->descr->size * sizeof(odb_node_t))); +} + + +/** + * return the number of bytes used by hash table, node table and header. + */ +static unsigned int tables_size(odb_data_t const * data, odb_node_nr_t node_nr) +{ + size_t size; + + size = node_nr * (sizeof(odb_index_t) * BUCKET_FACTOR); + size += node_nr * sizeof(odb_node_t); + size += data->offset_node; + + return size; +} + + +odb_index_t odb_hash_add_node(odb_t * odb) +{ + odb_data_t * data = odb->data; + + if (data->descr->current_size >= data->descr->size) { + unsigned int old_file_size; + unsigned int new_file_size; + unsigned int pos; + void * new_map; + + old_file_size = tables_size(data, data->descr->size); + new_file_size = tables_size(data, data->descr->size * 2); + + if (ftruncate(data->fd, new_file_size)) + return ODB_NODE_NR_INVALID; + + new_map = mremap(data->base_memory, + old_file_size, new_file_size, MREMAP_MAYMOVE); + + if (new_map == MAP_FAILED) + return ODB_NODE_NR_INVALID; + + data->base_memory = new_map; + data->descr = odb_to_descr(data); + data->descr->size *= 2; + data->node_base = odb_to_node_base(data); + data->hash_base = odb_to_hash_base(data); + data->hash_mask = (data->descr->size * BUCKET_FACTOR) - 1; + + /* rebuild the hash table, node zero is never used. This works + * because layout of file is node table then hash table, + * sizeof(node) > sizeof(bucket) and when we grow table we + * double size ==> old hash table and new hash table can't + * overlap so on the new hash table is entirely in the new + * memory area (the grown part) and we know the new hash + * hash table is zeroed. That's why we don't need to zero init + * the new table */ + /* OK: the above is not exact + * if BUCKET_FACTOR < sizeof(bd_node_t) / sizeof(bd_node_nr_t) + * all things are fine and we don't need to init the hash + * table because in this case the new hash table is completely + * inside the new growed part. Avoiding to touch this memory is + * useful. + */ +#if 0 + for (pos = 0 ; pos < data->descr->size*BUCKET_FACTOR ; ++pos) { + data->hash_base[pos] = 0; + } +#endif + + for (pos = 1; pos < data->descr->current_size; ++pos) { + odb_node_t * node = &data->node_base[pos]; + size_t index = odb_do_hash(data, node->key); + node->next = data->hash_base[index]; + data->hash_base[index] = pos; + } + } + + return (odb_index_t)data->descr->current_size++; +} + + +void odb_init(odb_t * odb) +{ + odb->data = NULL; +} + + +/* the default number of page, calculated to fit in 4096 bytes */ +#define DEFAULT_NODE_NR(offset_node) 128 +#define FILES_HASH_SIZE 512 + +static struct list_head files_hash[FILES_HASH_SIZE]; + + +static void init_hash() +{ + size_t i; + for (i = 0; i < FILES_HASH_SIZE; ++i) + list_init(&files_hash[i]); +} + + +static odb_data_t * +find_samples_data(size_t hash, char const * filename) +{ + struct list_head * pos; + + /* FIXME: maybe an initial init routine ? */ + if (files_hash[0].next == NULL) { + init_hash(); + return NULL; + } + + list_for_each(pos, &files_hash[hash]) { + odb_data_t * entry = list_entry(pos, odb_data_t, list); + if (strcmp(entry->filename, filename) == 0) + return entry; + } + + return NULL; +} + + +int odb_open(odb_t * odb, char const * filename, enum odb_rw rw, + size_t sizeof_header) +{ + struct stat stat_buf; + odb_node_nr_t nr_node; + odb_data_t * data; + size_t hash; + int err = 0; + + int flags = (rw == ODB_RDWR) ? (O_CREAT | O_RDWR) : O_RDONLY; + int mmflags = (rw == ODB_RDWR) ? (PROT_READ | PROT_WRITE) : PROT_READ; + + hash = op_hash_string(filename) % FILES_HASH_SIZE; + data = find_samples_data(hash, filename); + if (data) { + odb->data = data; + data->ref_count++; + return 0; + } + + data = xmalloc(sizeof(odb_data_t)); + memset(data, '\0', sizeof(odb_data_t)); + list_init(&data->list); + data->offset_node = sizeof_header + sizeof(odb_descr_t); + data->sizeof_header = sizeof_header; + data->ref_count = 1; + data->filename = xstrdup(filename); + + data->fd = open(filename, flags, 0644); + if (data->fd < 0) { + err = errno; + goto out; + } + + if (fstat(data->fd, &stat_buf)) { + err = errno; + goto fail; + } + + if (stat_buf.st_size == 0) { + size_t file_size; + + if (rw == ODB_RDONLY) { + err = EIO; + goto fail; + } + + nr_node = DEFAULT_NODE_NR(data->offset_node); + + file_size = tables_size(data, nr_node); + if (ftruncate(data->fd, file_size)) { + err = errno; + goto fail; + } + } else { + /* Calculate nr node allowing a sanity check later */ + nr_node = (stat_buf.st_size - data->offset_node) / + ((sizeof(odb_index_t) * BUCKET_FACTOR) + sizeof(odb_node_t)); + } + + data->base_memory = mmap(0, tables_size(data, nr_node), mmflags, + MAP_SHARED, data->fd, 0); + + if (data->base_memory == MAP_FAILED) { + err = errno; + goto fail; + } + + data->descr = odb_to_descr(data); + + if (stat_buf.st_size == 0) { + data->descr->size = nr_node; + /* page zero is not used */ + data->descr->current_size = 1; + } else { + /* file already exist, sanity check nr node */ + if (nr_node != data->descr->size) { + err = EINVAL; + goto fail_unmap; + } + } + + data->hash_base = odb_to_hash_base(data); + data->node_base = odb_to_node_base(data); + data->hash_mask = (data->descr->size * BUCKET_FACTOR) - 1; + + list_add(&data->list, &files_hash[hash]); + odb->data = data; +out: + return err; +fail_unmap: + munmap(data->base_memory, tables_size(data, nr_node)); +fail: + close(data->fd); + free(data->filename); + free(data); + odb->data = NULL; + goto out; +} + + +void odb_close(odb_t * odb) +{ + odb_data_t * data = odb->data; + + if (data) { + data->ref_count--; + if (data->ref_count == 0) { + size_t size = tables_size(data, data->descr->size); + list_del(&data->list); + munmap(data->base_memory, size); + if (data->fd >= 0) + close(data->fd); + free(data->filename); + free(data); + odb->data = NULL; + } + } +} + + +int odb_open_count(odb_t const * odb) +{ + if (!odb->data) + return 0; + return odb->data->ref_count; +} + + +void * odb_get_data(odb_t * odb) +{ + return odb->data->base_memory; +} + + +void odb_sync(odb_t const * odb) +{ + odb_data_t * data = odb->data; + size_t size; + + if (!data) + return; + + size = tables_size(data, data->descr->size); + msync(data->base_memory, size, MS_ASYNC); +} diff --git a/libdb/db_stat.c b/libdb/db_stat.c new file mode 100644 index 0000000..ab3ed18 --- /dev/null +++ b/libdb/db_stat.c @@ -0,0 +1,87 @@ +/** + * @file db_stat.c + * Statistics routines for libdb + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#include +#include + +#include "odb.h" + +/// hold various statistics data for a db file +struct odb_hash_stat_t { + odb_node_nr_t node_nr; /**< allocated node number */ + odb_node_nr_t used_node_nr; /**< in use node number */ + odb_value_t total_count; /**< cumulated samples count */ + odb_index_t hash_table_size; /**< hash table entry number */ + odb_node_nr_t max_list_length; /**< worst case */ + double average_list_length; /**< average case */ + /* do we need variance ? */ +}; + +odb_hash_stat_t * odb_hash_stat(odb_t const * odb) +{ + size_t max_length = 0; + double total_length = 0.0; + size_t nr_non_empty_list = 0; + size_t pos; + odb_data_t * data = odb->data; + + odb_hash_stat_t * result = calloc(1, sizeof(odb_hash_stat_t)); + if (!result) { + fprintf(stderr, "not enough memory\n"); + exit(EXIT_FAILURE); + } + + result->node_nr = data->descr->size; + result->used_node_nr = data->descr->current_size; + result->hash_table_size = data->descr->size * BUCKET_FACTOR; + + /* FIXME: I'm dubious if this do right statistics for hash table + * efficiency check */ + + for (pos = 0 ; pos < result->hash_table_size ; ++pos) { + size_t cur_length = 0; + size_t index = data->hash_base[pos]; + while (index) { + result->total_count += data->node_base[index].value; + index = data->node_base[index].next; + ++cur_length; + } + + if (cur_length > max_length) + max_length = cur_length; + + if (cur_length) { + total_length += cur_length; + ++nr_non_empty_list; + } + } + + result->max_list_length = max_length; + result->average_list_length = total_length / nr_non_empty_list; + + return result; +} + + +void odb_hash_display_stat(odb_hash_stat_t const * stat) +{ + printf("total node number: %d\n", stat->node_nr); + printf("total used node: %d\n", stat->used_node_nr); + printf("total count: %d\n", stat->total_count); + printf("hash table size: %d\n", stat->hash_table_size); + printf("greater list length: %d\n", stat->max_list_length); + printf("average non empty list length: %2.4f\n", stat->average_list_length); +} + + +void odb_hash_free_stat(odb_hash_stat_t * stat) +{ + free(stat); +} diff --git a/libdb/db_travel.c b/libdb/db_travel.c new file mode 100644 index 0000000..3ed467b --- /dev/null +++ b/libdb/db_travel.c @@ -0,0 +1,18 @@ +/** + * @file db_travel.c + * Inspection of a DB + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#include "odb.h" + +odb_node_t * odb_get_iterator(odb_t const * odb, odb_node_nr_t * nr) +{ + /* node zero is unused */ + *nr = odb->data->descr->current_size - 1; + return odb->data->node_base + 1; +} diff --git a/libdb/odb.h b/libdb/odb.h new file mode 100644 index 0000000..c88baea --- /dev/null +++ b/libdb/odb.h @@ -0,0 +1,203 @@ +/** + * @file odb.h + * This file contains various definitions and interface for management + * of in-memory, through mmaped file, growable hash table, that stores + * sample files. + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#ifndef ODB_HASH_H +#define ODB_HASH_H + +#include +#include + +#include "op_list.h" + +/** the type of key. 64-bit because CG needs 32-bit pair {from,to} */ +typedef uint64_t odb_key_t; +/** the type of an information in the database */ +typedef unsigned int odb_value_t; +/** the type of index (node number), list are implemented through index */ +typedef unsigned int odb_index_t; +/** the type store node number */ +typedef odb_index_t odb_node_nr_t; +/** store the hash mask, hash table size are always power of two */ +typedef odb_index_t odb_hash_mask_t; + +/* there is (bucket factor * nr node) entry in hash table, this can seem + * excessive but hash coding eip don't give a good distributions and our + * goal is to get a O(1) amortized insert time. bucket factor must be a + * power of two. FIXME: see big comment in odb_hash_add_node, you must + * re-enable zeroing hash table if BUCKET_FACTOR > 2 (roughly exact, you + * want to read the comment in odb_hash_add_node() if you tune this define) + */ +#define BUCKET_FACTOR 1 + +/** a db hash node */ +typedef struct { + odb_key_t key; /**< eip */ + odb_value_t value; /**< samples count */ + odb_index_t next; /**< next entry for this bucket */ +} odb_node_t; + +/** the minimal information which must be stored in the file to reload + * properly the data base, following this header is the node array then + * the hash table (when growing we avoid to copy node array) + */ +typedef struct { + odb_node_nr_t size; /**< in node nr (power of two) */ + odb_node_nr_t current_size; /**< nr used node + 1, node 0 unused */ + int padding[6]; /**< for padding and future use */ +} odb_descr_t; + +/** a "database". this is an in memory only description. + * + * We allow to manage a database inside a mapped file with an "header" of + * unknown size so odb_open get a parameter to specify the size of this header. + * A typical use is: + * + * struct header { int etc; ... }; + * odb_open(&hash, filename, ODB_RW, sizeof(header)); + * so on this library have no dependency on the header type. + * + * the internal memory layout from base_memory is: + * the unknown header (sizeof_header) + * odb_descr_t + * the node array: (descr->size * sizeof(odb_node_t) entries + * the hash table: array of odb_index_t indexing the node array + * (descr->size * BUCKET_FACTOR) entries + */ +typedef struct odb_data { + odb_node_t * node_base; /**< base memory area of the page */ + odb_index_t * hash_base; /**< base memory of hash table */ + odb_descr_t * descr; /**< the current state of database */ + odb_hash_mask_t hash_mask; /**< == descr->size - 1 */ + unsigned int sizeof_header; /**< from base_memory to odb header */ + unsigned int offset_node; /**< from base_memory to node array */ + void * base_memory; /**< base memory of the maped memory */ + int fd; /**< mmaped memory file descriptor */ + char * filename; /**< full path name of sample file */ + int ref_count; /**< reference count */ + struct list_head list; /**< hash bucket list */ +} odb_data_t; + +typedef struct { + odb_data_t * data; +} odb_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* db_manage.c */ + +/** how to open the DB file */ +enum odb_rw { + ODB_RDONLY = 0, /**< open for read only */ + ODB_RDWR = 1 /**< open for read and/or write */ +}; + +/** + * odb_init - initialize a DB file + * @param odb the DB file to init + */ +void odb_init(odb_t * odb); + +/** + * odb_open - open a DB file + * @param odb the data base object to setup + * @param filename the filename where go the maped memory + * @param rw \enum ODB_RW if opening for writing, else \enum ODB_RDONLY + * @param sizeof_header size of the file header if any + * + * The sizeof_header parameter allows the data file to have a header + * at the start of the file which is skipped. + * odb_open() always preallocate a few number of pages. + * returns 0 on success, errno on failure + */ +int odb_open(odb_t * odb, char const * filename, + enum odb_rw rw, size_t sizeof_header); + +/** Close the given ODB file */ +void odb_close(odb_t * odb); + +/** return the number of times this sample file is open */ +int odb_open_count(odb_t const * odb); + +/** return the start of the mapped data */ +void * odb_get_data(odb_t * odb); + +/** issue a msync on the used size of the mmaped file */ +void odb_sync(odb_t const * odb); + +/** add a page returning its index. Take care all page pointer can be + * invalidated by this call ! + * returns the index of the created node on success or + * ODB_NODE_NR_INVALID on failure, in this case this function do nothing + * and errno is set by the first libc call failure allowing to retry after + * cleanup some program resource. + */ +odb_node_nr_t odb_hash_add_node(odb_t * odb); + +/** "immpossible" node number to indicate an error from odb_hash_add_node() */ +#define ODB_NODE_NR_INVALID ((odb_node_nr_t)-1) + +/* db_debug.c */ +/** check that the hash is well built */ +int odb_check_hash(odb_t const * odb); + +/* db_stat.c */ +typedef struct odb_hash_stat_t odb_hash_stat_t; +odb_hash_stat_t * odb_hash_stat(odb_t const * odb); +void odb_hash_display_stat(odb_hash_stat_t const * stats); +void odb_hash_free_stat(odb_hash_stat_t * stats); + +/* db_insert.c */ +/** insert info at key, if key already exist the info is added to the + * existing samples + * returns EXIT_SUCCESS on success, EXIT_FAILURE on failure + */ +int odb_insert(odb_t * odb, odb_key_t key, odb_value_t value); + +/* db_travel.c */ +/** + * return a base pointer to the node array and number of node in this array + * caller then will iterate through: + * + * odb_node_nr_t node_nr, pos; + * odb_node_t * node = odb_get_iterator(odb, &node_nr); + * for ( pos = 0 ; pos < node_nr ; ++pos) { + * if (node[pos].key) { + * // do something + * } + * } + * + * note than caller *must* filter nil key. + */ +odb_node_t * odb_get_iterator(odb_t const * odb, odb_node_nr_t * nr); + +static __inline unsigned int +odb_do_hash(odb_data_t const * data, odb_key_t value) +{ + /* FIXME: better hash for eip value, needs to instrument code + * and do a lot of tests ... */ + /* trying to combine high order bits his a no-op: inside a binary image + * high order bits don't vary a lot, hash table start with 7 bits mask + * so this hash coding use bits 0-7, 8-15. Hash table is stored in + * files avoiding to rebuilding them at profiling re-start so + * on changing do_hash() change the file format! + */ + uint32_t temp = (value >> 32) ^ value; + return ((temp << 0) ^ (temp >> 8)) & data->hash_mask; +} + +#ifdef __cplusplus +} +#endif + +#endif /* !ODB_H */ diff --git a/libdb/tests/Makefile.am b/libdb/tests/Makefile.am new file mode 100644 index 0000000..6932088 --- /dev/null +++ b/libdb/tests/Makefile.am @@ -0,0 +1,15 @@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libdb + +AM_CFLAGS = @OP_CFLAGS@ + +LIBS = @LIBERTY_LIBS@ + +check_PROGRAMS = db_test + +db_test_SOURCES = db_test.c +db_test_LDADD = ../libodb.a ../../libutil/libutil.a + +TESTS = ${check_PROGRAMS} diff --git a/libdb/tests/Makefile.in b/libdb/tests/Makefile.in new file mode 100644 index 0000000..96aaeb2 --- /dev/null +++ b/libdb/tests/Makefile.in @@ -0,0 +1,509 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +SOURCES = $(db_test_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +check_PROGRAMS = db_test$(EXEEXT) +subdir = libdb/tests +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am_db_test_OBJECTS = db_test.$(OBJEXT) +db_test_OBJECTS = $(am_db_test_OBJECTS) +db_test_DEPENDENCIES = ../libodb.a ../../libutil/libutil.a +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(db_test_SOURCES) +DIST_SOURCES = $(db_test_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBERTY_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libdb + +AM_CFLAGS = @OP_CFLAGS@ +db_test_SOURCES = db_test.c +db_test_LDADD = ../libodb.a ../../libutil/libutil.a +TESTS = ${check_PROGRAMS} +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libdb/tests/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libdb/tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +db_test$(EXEEXT): $(db_test_OBJECTS) $(db_test_DEPENDENCIES) + @rm -f db_test$(EXEEXT) + $(LINK) $(db_test_LDFLAGS) $(db_test_OBJECTS) $(db_test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/db_test.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic ctags distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libdb/tests/db_test.c b/libdb/tests/db_test.c new file mode 100644 index 0000000..817ff16 --- /dev/null +++ b/libdb/tests/db_test.c @@ -0,0 +1,184 @@ +/** + * @file db_test.c + * Tests for DB hash + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "op_sample_file.h" +#include "odb.h" + +#define TEST_FILENAME "test-hash-db.dat" + +static int nr_error; + +static int verbose = 0; + +#define verbprintf(args...) \ + do { \ + if (verbose) \ + printf(args); \ + } while (0) + +static double used_time(void) +{ + struct rusage usage; + + getrusage(RUSAGE_SELF, &usage); + + return usage.ru_utime.tv_sec + usage.ru_stime.tv_sec + + ((usage.ru_utime.tv_usec + usage.ru_stime.tv_usec) / 1000000.0); +} + + +/* create nr item randomly created with nr_unique_item distinct items */ +static void speed_test(int nr_item, int nr_unique_item) +{ + int i; + double begin, end; + odb_t hash; + int rc; + + rc = odb_open(&hash, TEST_FILENAME, ODB_RDWR, sizeof(struct opd_header)); + if (rc) { + fprintf(stderr, "%s", strerror(rc)); + exit(EXIT_FAILURE); + } + begin = used_time(); + for (i = 0 ; i < nr_item ; ++i) { + rc = odb_insert(&hash, (random() % nr_unique_item) + 1, 1); + if (rc != EXIT_SUCCESS) { + fprintf(stderr, "%s", strerror(rc)); + exit(EXIT_FAILURE); + } + } + end = used_time(); + odb_close(&hash); + + remove(TEST_FILENAME); + + verbprintf("nr item: %d, unique item: %d, elapsed: %f\n", + nr_item, nr_unique_item, end - begin); +} + + +static void do_speed_test(void) +{ + int i, j; + + for (i = 1000 ; i <= 100000 ; i *= 10) { + for (j = 100 ; j <= i / 10 ; j *= 10) { + speed_test(i, j); + } + } +} + + +static int test(int nr_item, int nr_unique_item) +{ + int i; + odb_t hash; + int ret; + int rc; + + rc = odb_open(&hash, TEST_FILENAME, ODB_RDWR, sizeof(struct opd_header)); + if (rc) { + fprintf(stderr, "%s", strerror(rc)); + exit(EXIT_FAILURE); + } + + + for (i = 0 ; i < nr_item ; ++i) { + odb_key_t key = (random() % nr_unique_item) + 1; + rc = odb_insert(&hash, key, 1); + if (rc != EXIT_SUCCESS) { + fprintf(stderr, "%s", strerror(rc)); + exit(EXIT_FAILURE); + } + } + + ret = odb_check_hash(&hash); + + odb_close(&hash); + + remove(TEST_FILENAME); + + return ret; +} + + +static void do_test(void) +{ + int i, j; + + for (i = 1000; i <= 100000; i *= 10) { + for (j = 100 ; j <= i / 10 ; j *= 10) { + if (test(i, j)) { + fprintf(stderr, "%s:%d failure for %d %d\n", + __FILE__, __LINE__, i, j); + nr_error++; + } else { + verbprintf("test() ok %d %d\n", i, j); + } + } + } +} + + +static void sanity_check(char const * filename) +{ + odb_t hash; + int rc; + + rc = odb_open(&hash, filename, ODB_RDONLY, sizeof(struct opd_header)); + if (rc) { + fprintf(stderr, "%s", strerror(rc)); + exit(EXIT_FAILURE); + } + + if (odb_check_hash(&hash)) { + fprintf(stderr, "checking file %s FAIL\n", filename); + ++nr_error; + } else if (verbose) { + odb_hash_stat_t * stats; + stats = odb_hash_stat(&hash); + odb_hash_display_stat(stats); + odb_hash_free_stat(stats); + } + + odb_close(&hash); +} + +int main(int argc, char * argv[1]) +{ + /* if a filename is given take it as: "check this db" */ + if (argc > 1) { + int i; + verbose = 1; + for (i = 1 ; i < argc ; ++i) + sanity_check(argv[i]); + return 0; + } + + remove(TEST_FILENAME); + + do_test(); + + do_speed_test(); + + if (nr_error) + printf("%d error occured\n", nr_error); + + return nr_error ? EXIT_FAILURE : EXIT_SUCCESS; +} diff --git a/libop/Makefile.am b/libop/Makefile.am new file mode 100644 index 0000000..1caebb8 --- /dev/null +++ b/libop/Makefile.am @@ -0,0 +1,23 @@ +SUBDIRS = . tests + +AM_CPPFLAGS=-I${top_srcdir}/libutil +AM_CFLAGS = @OP_CFLAGS@ + +noinst_LIBRARIES = libop.a +libop_a_SOURCES = \ + op_events.c \ + op_events.h \ + op_parse_event.c \ + op_parse_event.h \ + op_cpu_type.c \ + op_cpu_type.h \ + op_mangle.c \ + op_mangle.h \ + op_get_interface.c \ + op_interface.h \ + op_alloc_counter.c \ + op_alloc_counter.h \ + op_hw_config.h \ + op_config.h \ + op_config_24.h \ + op_sample_file.h diff --git a/libop/Makefile.in b/libop/Makefile.in new file mode 100644 index 0000000..07e2240 --- /dev/null +++ b/libop/Makefile.in @@ -0,0 +1,570 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(libop_a_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = libop +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libop_a_AR = $(AR) $(ARFLAGS) +libop_a_LIBADD = +am_libop_a_OBJECTS = op_events.$(OBJEXT) op_parse_event.$(OBJEXT) \ + op_cpu_type.$(OBJEXT) op_mangle.$(OBJEXT) \ + op_get_interface.$(OBJEXT) op_alloc_counter.$(OBJEXT) +libop_a_OBJECTS = $(am_libop_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libop_a_SOURCES) +DIST_SOURCES = $(libop_a_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +SUBDIRS = . tests +AM_CPPFLAGS = -I${top_srcdir}/libutil +AM_CFLAGS = @OP_CFLAGS@ +noinst_LIBRARIES = libop.a +libop_a_SOURCES = \ + op_events.c \ + op_events.h \ + op_parse_event.c \ + op_parse_event.h \ + op_cpu_type.c \ + op_cpu_type.h \ + op_mangle.c \ + op_mangle.h \ + op_get_interface.c \ + op_interface.h \ + op_alloc_counter.c \ + op_alloc_counter.h \ + op_hw_config.h \ + op_config.h \ + op_config_24.h \ + op_sample_file.h + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libop/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libop/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libop.a: $(libop_a_OBJECTS) $(libop_a_DEPENDENCIES) + -rm -f libop.a + $(libop_a_AR) libop.a $(libop_a_OBJECTS) $(libop_a_LIBADD) + $(RANLIB) libop.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_alloc_counter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_cpu_type.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_events.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_get_interface.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_mangle.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_parse_event.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LIBRARIES) +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-generic clean-noinstLIBRARIES clean-recursive \ + ctags ctags-recursive distclean distclean-compile \ + distclean-generic distclean-recursive distclean-tags distdir \ + dvi dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libop/op_alloc_counter.c b/libop/op_alloc_counter.c new file mode 100644 index 0000000..8d20134 --- /dev/null +++ b/libop/op_alloc_counter.c @@ -0,0 +1,169 @@ +/** + * @file op_alloc_counter.c + * hardware counter allocation + * + * You can have silliness here. + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include "op_events.h" +#include "op_libiberty.h" + + +typedef struct counter_arc_head { + /** the head of allowed counter for this event */ + struct list_head next; +} counter_arc_head; + + +typedef struct counter_arc { + /** counter nr */ + int counter; + /** the next counter allowed for this event */ + struct list_head next; +} counter_arc; + + +/** + * @param pev an array of event + * @param nr_events number of entry in pev + * + * build an array of counter list allowed for each events + * counter_arc_head[i] is the list of allowed counter for pev[i] events + * The returned pointer is an array of nr_events entry + */ +static counter_arc_head * +build_counter_arc(struct op_event const * pev[], int nr_events) +{ + counter_arc_head * ctr_arc; + int i; + + ctr_arc = xmalloc(nr_events * sizeof(*ctr_arc)); + + for (i = 0; i < nr_events; ++i) { + int j; + u32 mask = pev[i]->counter_mask; + + list_init(&ctr_arc[i].next); + for (j = 0; mask; ++j) { + if (mask & (1 << j)) { + counter_arc * arc = + xmalloc(sizeof(counter_arc)); + arc->counter = j; + /* we are looping by increasing counter number, + * allocation use a left to right tree walking + * so we add at end to ensure counter will + * be allocated by increasing number: it's not + * required but a bit less surprising when + * debugging code + */ + list_add_tail(&arc->next, &ctr_arc[i].next); + mask &= ~(1 << j); + } + } + } + + return ctr_arc; +} + + +/** + * @param ctr_arc the array to deallocate + * @param nr_events number of entry in array + * + * deallocate all previously allocated resource by build_counter_arc() + */ +static void delete_counter_arc(counter_arc_head * ctr_arc, int nr_events) +{ + int i; + for (i = 0; i < nr_events; ++i) { + struct list_head * pos, * pos2; + list_for_each_safe(pos, pos2, &ctr_arc[i].next) { + counter_arc * arc = list_entry(pos, counter_arc, next); + list_del(&arc->next); + free(arc); + } + } + free(ctr_arc); +} + + +/** + * @param ctr_arc tree description, ctr_arc[i] is the i-th level of tree. + * @param max_depth number of entry in array ctr_arc == depth of tree + * @param depth current level we are exploring + * @param allocated_mask current counter already allocated mask + * @param counter_map array of counter number mapping, returned results go + * here + * + * return non zero on succees, in this case counter_map is set to the counter + * mapping number. + * + * Solution is searched through a simple backtracking exploring recursively all + * possible solution until one is found, prunning is done in O(1) by tracking + * a bitmask of already allocated counter. Walking through node is done in + * preorder left to right. + * + * Possible improvment if neccessary: partition counters in class of counter, + * two counter belong to the same class if they allow exactly the same set of + * event. Now using a variant of the backtrack algo can works on class of + * counter rather on counter (this is not an improvment if each counter goes + * in it's own class) + */ +static int +allocate_counter(counter_arc_head const * ctr_arc, int max_depth, int depth, + u32 allocated_mask, size_t * counter_map) +{ + struct list_head * pos; + + if (depth == max_depth) + return 1; + + list_for_each(pos, &ctr_arc[depth].next) { + counter_arc const * arc = list_entry(pos, counter_arc, next); + + if (allocated_mask & (1 << arc->counter)) + return 0; + + counter_map[depth] = arc->counter; + + if (allocate_counter(ctr_arc, max_depth, depth + 1, + allocated_mask | (1 << arc->counter), + counter_map)) + return 1; + } + + return 0; +} + + +size_t * map_event_to_counter(struct op_event const * pev[], int nr_events, + op_cpu cpu_type) +{ + counter_arc_head * ctr_arc; + size_t * counter_map; + int nr_counters; + + nr_counters = op_get_nr_counters(cpu_type); + if (nr_counters < nr_events) + return 0; + + ctr_arc = build_counter_arc(pev, nr_events); + + counter_map = xmalloc(nr_counters * sizeof(size_t)); + + if (!allocate_counter(ctr_arc, nr_events, 0, 0, counter_map)) { + free(counter_map); + counter_map = 0; + } + + delete_counter_arc(ctr_arc, nr_events); + return counter_map; +} diff --git a/libop/op_alloc_counter.h b/libop/op_alloc_counter.h new file mode 100644 index 0000000..40b4ebf --- /dev/null +++ b/libop/op_alloc_counter.h @@ -0,0 +1,43 @@ +/** + * @file op_alloc_counter.h + * hardware counter allocation + * + * You can have silliness here. + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_ALLOC_COUNTER_H +#define OP_ALLOC_COUNTER_H + +#include + +#include "op_cpu_type.h" + +struct op_event; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @param pev array of selected event we want to bind to counter + * @param nr_events size of pev array + * @param cpu_type cpu type + * + * Try to calculate a binding between passed event in pev and counter number. + * The binding is returned in a size_t * where returned ptr[i] is the counter + * number bound to pev[i] + */ +size_t * map_event_to_counter(struct op_event const * pev[], int nr_events, + op_cpu cpu_type); + +#ifdef __cplusplus +} +#endif + +#endif /* !OP_ALLOC_COUNTER_H */ diff --git a/libop/op_config.h b/libop/op_config.h new file mode 100644 index 0000000..6b4cfbc --- /dev/null +++ b/libop/op_config.h @@ -0,0 +1,33 @@ +/** + * @file op_config.h + * + * Parameters a user may want to change. See + * also op_config_24.h + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_CONFIG_H +#define OP_CONFIG_H + +/* various paths, duplicated in opcontrol */ +#define OP_BASE_DIR "/var/lib/oprofile/" +#define OP_SAMPLES_DIR OP_BASE_DIR "samples/" +#define OP_SAMPLES_CURRENT_DIR OP_SAMPLES_DIR "current/" +#define OP_LOCK_FILE OP_BASE_DIR "lock" +#define OP_LOG_FILE OP_BASE_DIR "oprofiled.log" +#define OP_DUMP_STATUS OP_BASE_DIR "complete_dump" + +/* Global directory that stores debug files */ +#ifndef DEBUGDIR +#define DEBUGDIR "/usr/lib/debug" +#endif + +#define OPD_MAGIC "DAE\n" +#define OPD_VERSION 0x10 + +#endif /* OP_CONFIG_H */ diff --git a/libop/op_config_24.h b/libop/op_config_24.h new file mode 100644 index 0000000..8767244 --- /dev/null +++ b/libop/op_config_24.h @@ -0,0 +1,73 @@ +/** + * @file op_config_24.h + * + * Parameters a user may want to change + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_CONFIG_24_H +#define OP_CONFIG_24_H + +#define OP_MOUNT "/proc/sys/dev/oprofile/" + +#define OP_DEVICE OP_BASE_DIR "opdev" +#define OP_NOTE_DEVICE OP_BASE_DIR "opnotedev" +#define OP_HASH_DEVICE OP_BASE_DIR "ophashmapdev" + +/*@{\name module default/min/max settings */ + +/** 65536 * sizeof(op_sample) */ +#define OP_DEFAULT_BUF_SIZE 65536 +/** we don't try to wake-up daemon until it remains more than this free entry + * in eviction buffer */ +#define OP_PRE_WATERMARK(buffer_size) \ + (((buffer_size) / 8) < OP_MIN_PRE_WATERMARK \ + ? OP_MIN_PRE_WATERMARK \ + : (buffer_size) / 8) +/* minimal buffer water mark before we try to wakeup daemon */ +#define OP_MIN_PRE_WATERMARK 8192 +/** maximum number of entry in samples eviction buffer */ +#define OP_MAX_BUF_SIZE 1048576 +/** minimum number of entry in samples eviction buffer */ +#define OP_MIN_BUF_SIZE (32768 + OP_PRE_WATERMARK(32768)) + +/** 16384 * sizeof(op_note) = 273680 bytes default */ +#define OP_DEFAULT_NOTE_SIZE 16384 +/** we don't try to wake-up daemon until it remains more than this free entry + * in note buffer */ +#define OP_PRE_NOTE_WATERMARK(note_size) \ + (((note_size) / 32) < OP_MIN_NOTE_PRE_WATERMARK \ + ? OP_MIN_NOTE_PRE_WATERMARK \ + : (note_size) / 32) +/* minimal note buffer water mark before we try to wakeup daemon */ +#define OP_MIN_NOTE_PRE_WATERMARK 512 +/** maximum number of entry in note buffer */ +#define OP_MAX_NOTE_TABLE_SIZE 1048576 +/** minimum number of entry in note buffer */ +#define OP_MIN_NOTE_TABLE_SIZE (1024 + OP_PRE_NOTE_WATERMARK(1024)) + +/** maximum sampling rate when using RTC */ +#define OP_MAX_RTC_COUNT 4096 +/** minimum sampling rate when using RTC */ +#define OP_MIN_RTC_COUNT 2 + +/*@}*/ + +/** nr entries in hash map. This is the maximum number of name components + * allowed. Must be a prime number */ +#define OP_HASH_MAP_NR 4093 + +/** size of string pool in bytes */ +#define POOL_SIZE 65536 + +#ifndef NR_CPUS +/** maximum number of cpus present in the box */ +#define NR_CPUS 32 +#endif + +#endif /* OP_CONFIG_24_H */ diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c new file mode 100644 index 0000000..a2574a0 --- /dev/null +++ b/libop/op_cpu_type.c @@ -0,0 +1,139 @@ +/** + * @file op_cpu_type.c + * CPU type determination + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include + +#include "op_cpu_type.h" + +struct cpu_descr { + char const * pretty; + char const * name; + op_cpu cpu; + unsigned int nr_counters; +}; + +static struct cpu_descr const cpu_descrs[MAX_CPU_TYPE] = { + { "Pentium Pro", "i386/ppro", CPU_PPRO, 2 }, + { "PII", "i386/pii", CPU_PII, 2 }, + { "PIII", "i386/piii", CPU_PIII, 2 }, + { "Athlon", "i386/athlon", CPU_ATHLON, 4 }, + { "CPU with timer interrupt", "timer", CPU_TIMER_INT, 1 }, + { "CPU with RTC device", "rtc", CPU_RTC, 1 }, + { "P4 / Xeon", "i386/p4", CPU_P4, 8 }, + { "IA64", "ia64/ia64", CPU_IA64, 4 }, + { "Itanium", "ia64/itanium", CPU_IA64_1, 4 }, + { "Itanium 2", "ia64/itanium2", CPU_IA64_2, 4 }, + { "AMD64 processors", "x86-64/hammer", CPU_HAMMER, 4 }, + { "P4 / Xeon with 2 hyper-threads", "i386/p4-ht", CPU_P4_HT2, 4 }, + { "Alpha EV4", "alpha/ev4", CPU_AXP_EV4, 2 }, + { "Alpha EV5", "alpha/ev5", CPU_AXP_EV5, 3 }, + { "Alpha PCA56", "alpha/pca56", CPU_AXP_PCA56, 3 }, + { "Alpha EV6", "alpha/ev6", CPU_AXP_EV6, 2 }, + { "Alpha EV67", "alpha/ev67", CPU_AXP_EV67, 20 }, + { "Pentium M (P6 core)", "i386/p6_mobile", CPU_P6_MOBILE, 2 }, + { "ARM/XScale PMU1", "arm/xscale1", CPU_ARM_XSCALE1, 3 }, + { "ARM/XScale PMU2", "arm/xscale2", CPU_ARM_XSCALE2, 5 }, + { "ppc64 POWER4", "ppc64/power4", CPU_PPC64_POWER4, 8 }, + { "ppc64 POWER5", "ppc64/power5", CPU_PPC64_POWER5, 6 }, + { "ppc64 970", "ppc64/970", CPU_PPC64_970, 8 }, + { "MIPS 24K", "mips/24K", CPU_MIPS_24K, 2}, + { "MIPS R10000", "mips/r10000", CPU_MIPS_R10000, 2 }, + { "MIPS R12000", "mips/r12000", CPU_MIPS_R12000, 4 }, + { "QED RM7000", "mips/rm7000", CPU_MIPS_RM7000, 1 }, + { "PMC-Sierra RM9000", "mips/rm9000", CPU_MIPS_RM9000, 2 }, + { "Sibyte SB1", "mips/sb1", CPU_MIPS_SB1, 4 }, + { "NEC VR5432", "mips/vr5432", CPU_MIPS_VR5432, 2 }, + { "NEC VR5500", "mips/vr5500", CPU_MIPS_VR5500, 2 }, + { "e500", "ppc/e500", CPU_PPC_E500, 4 }, +}; + +static size_t const nr_cpu_descrs = sizeof(cpu_descrs) / sizeof(struct cpu_descr); + +op_cpu op_get_cpu_type(void) +{ + int cpu_type = CPU_NO_GOOD; + char str[100]; + FILE * fp; + + fp = fopen("/proc/sys/dev/oprofile/cpu_type", "r"); + if (!fp) { + /* Try 2.6's oprofilefs one instead. */ + fp = fopen("/dev/oprofile/cpu_type", "r"); + if (!fp) { + fprintf(stderr, "Unable to open cpu_type file for reading\n"); + fprintf(stderr, "Make sure you have done opcontrol --init\n"); + return cpu_type; + } + } + + if (!fgets(str, 99, fp)) { + fprintf(stderr, "Could not read cpu type.\n"); + return CPU_NO_GOOD; + } + + cpu_type = op_get_cpu_number(str); + + fclose(fp); + + return cpu_type; +} + + +op_cpu op_get_cpu_number(char const * cpu_string) +{ + int cpu_type = CPU_NO_GOOD; + size_t i; + + for (i = 0; i < nr_cpu_descrs; ++i) { + if (!strcmp(cpu_descrs[i].name, cpu_string)) { + cpu_type = cpu_descrs[i].cpu; + break; + } + } + + /* Attempt to convert into a number */ + if (cpu_type == CPU_NO_GOOD) + sscanf(cpu_string, "%d\n", &cpu_type); + + if (cpu_type <= CPU_NO_GOOD || cpu_type >= MAX_CPU_TYPE) + cpu_type = CPU_NO_GOOD; + + return cpu_type; +} + + +char const * op_get_cpu_type_str(op_cpu cpu_type) +{ + if (cpu_type <= CPU_NO_GOOD || cpu_type >= MAX_CPU_TYPE) + return "invalid cpu type"; + + return cpu_descrs[cpu_type].pretty; +} + + +char const * op_get_cpu_name(op_cpu cpu_type) +{ + if (cpu_type <= CPU_NO_GOOD || cpu_type >= MAX_CPU_TYPE) + return "invalid cpu type"; + + return cpu_descrs[cpu_type].name; +} + + +int op_get_nr_counters(op_cpu cpu_type) +{ + if (cpu_type <= CPU_NO_GOOD || cpu_type >= MAX_CPU_TYPE) + return 0; + + return cpu_descrs[cpu_type].nr_counters; +} diff --git a/libop/op_cpu_type.h b/libop/op_cpu_type.h new file mode 100644 index 0000000..9def1d7 --- /dev/null +++ b/libop/op_cpu_type.h @@ -0,0 +1,118 @@ +/** + * @file op_cpu_type.h + * CPU type determination + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_CPU_TYPE_H +#define OP_CPU_TYPE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** supported cpu type */ +typedef enum { + CPU_NO_GOOD = -1, /**< unsupported CPU type */ + CPU_PPRO, /**< Pentium Pro */ + CPU_PII, /**< Pentium II series */ + CPU_PIII, /**< Pentium III series */ + CPU_ATHLON, /**< AMD P6 series */ + CPU_TIMER_INT, /**< CPU using the timer interrupt */ + CPU_RTC, /**< other CPU to use the RTC */ + CPU_P4, /**< Pentium 4 / Xeon series */ + CPU_IA64, /**< Generic IA64 */ + CPU_IA64_1, /**< IA64 Merced */ + CPU_IA64_2, /**< IA64 McKinley */ + CPU_HAMMER, /**< AMD Hammer family */ + CPU_P4_HT2, /**< Pentium 4 / Xeon series with 2 hyper-threads */ + CPU_AXP_EV4, /**< Alpha EV4 family */ + CPU_AXP_EV5, /**< Alpha EV5 family */ + CPU_AXP_PCA56, /**< Alpha PCA56 family */ + CPU_AXP_EV6, /**< Alpha EV6 family */ + CPU_AXP_EV67, /**< Alpha EV67 family */ + CPU_P6_MOBILE, /**< Pentium M series */ + CPU_ARM_XSCALE1, /**< ARM XScale 1 */ + CPU_ARM_XSCALE2, /**< ARM XScale 2 */ + CPU_PPC64_POWER4, /**< ppc64 POWER4 family */ + CPU_PPC64_POWER5, /**< ppc64 POWER5 family */ + CPU_PPC64_970, /**< ppc64 970 family */ + CPU_MIPS_24K, /**< MIPS 24K */ + CPU_MIPS_R10000, /**< MIPS R10000 */ + CPU_MIPS_R12000, /**< MIPS R12000 */ + CPU_MIPS_RM7000, /**< QED RM7000 */ + CPU_MIPS_RM9000, /**< PMC-Sierra RM9000 */ + CPU_MIPS_SB1, /**< Broadcom SB1 */ + CPU_MIPS_VR5432, /**< NEC VR5432 */ + CPU_MIPS_VR5500, /**< MIPS VR5500, VR5532 and VR7701 */ + CPU_PPC_E500, /**< e500 */ + MAX_CPU_TYPE +} op_cpu; + +/** + * get the CPU type from the kernel + * + * returns CPU_NO_GOOD if the CPU could not be identified. + * This function can not work if the module is not loaded + */ +op_cpu op_get_cpu_type(void); + +/** + * get the cpu number based on string + * @param cpu_string with either the cpu type identifier or cpu type number + * + * The function returns CPU_NO_GOOD if no matching string was found. + */ +op_cpu op_get_cpu_number(char const * cpu_string); + +/** + * get the cpu string. + * @param cpu_type the cpu type identifier + * + * The function always return a valid char const * the core cpu denomination + * or "invalid cpu type" if cpu_type is not valid. + */ +char const * op_get_cpu_type_str(op_cpu cpu_type); + +/** + * op_get_cpu_name - get the cpu name + * @param cpu_type the cpu identifier name + * + * The function always return a valid char const * + * Return the OProfile CPU name, e.g. "i386/pii" + */ +char const * op_get_cpu_name(op_cpu cpu_type); + +/** + * compute the number of counters available + * @param cpu_type numeric processor type + * + * returns 0 if the CPU could not be identified + */ +int op_get_nr_counters(op_cpu cpu_type); + +typedef enum { + OP_INTERFACE_NO_GOOD = -1, + OP_INTERFACE_24, + OP_INTERFACE_26 +} op_interface; + +/** + * get the INTERFACE used to communicate between daemon and the kernel + * + * returns OP_INTERFACE_NO_GOOD if the INTERFACE could not be identified. + * This function will identify the interface as OP_INTERFACE_NO_GOOD if + * the module is not loaded. + */ +op_interface op_get_interface(void); + +#ifdef __cplusplus +} +#endif + +#endif /* OP_CPU_TYPE_H */ diff --git a/libop/op_events.c b/libop/op_events.c new file mode 100644 index 0000000..47bae76 --- /dev/null +++ b/libop/op_events.c @@ -0,0 +1,827 @@ +/** + * @file op_events.c + * Details of PMC profiling events + * + * You can have silliness here. + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "op_events.h" +#include "op_libiberty.h" +#include "op_fileio.h" +#include "op_string.h" +#include "op_cpufreq.h" + +#include +#include +#include + +static LIST_HEAD(events_list); +static LIST_HEAD(um_list); + +static char const * filename; +static unsigned int line_nr; + +static void parse_error(char const * context) +{ + fprintf(stderr, "oprofile: parse error in %s, line %u\n", + filename, line_nr); + fprintf(stderr, "%s\n", context); + exit(EXIT_FAILURE); +} + + +static int parse_int(char const * str) +{ + int value; + if (sscanf(str, "%d", &value) != 1) { + parse_error("expected decimal value"); + } + + return value; +} + + +static int parse_hex(char const * str) +{ + int value; + if (sscanf(str, "%x", &value) != 1) { + parse_error("expected hexadecimal value"); + } + + return value; +} + + +static u64 parse_long_hex(char const * str) +{ + u64 value; + if (sscanf(str, "%Lx", &value) != 1) { + parse_error("expected long hexadecimal value"); + } + fflush(stderr); + return value; +} + + +/* name:MESI type:bitmask default:0x0f */ +static void parse_um(struct op_unit_mask * um, char const * line) +{ + int seen_name = 0; + int seen_type = 0; + int seen_default = 0; + char const * valueend = line + 1; + char const * tagend = line + 1; + char const * start = line; + + while (*valueend) { + valueend = skip_nonws(valueend); + + while (*tagend != ':' && *tagend) + ++tagend; + + if (valueend == tagend) + break; + + if (!*tagend) + parse_error("parse_um() expected :value"); + + ++tagend; + + if (strisprefix(start, "name")) { + if (seen_name) + parse_error("duplicate name: tag"); + seen_name = 1; + um->name = op_xstrndup(tagend, valueend - tagend); + } else if (strisprefix(start, "type")) { + if (seen_type) + parse_error("duplicate type: tag"); + seen_type = 1; + if (strisprefix(tagend, "mandatory")) { + um->unit_type_mask = utm_mandatory; + } else if (strisprefix(tagend, "bitmask")) { + um->unit_type_mask = utm_bitmask; + } else if (strisprefix(tagend, "exclusive")) { + um->unit_type_mask = utm_exclusive; + } else { + parse_error("invalid unit mask type"); + } + } else if (strisprefix(start, "default")) { + if (seen_default) + parse_error("duplicate default: tag"); + seen_default = 1; + um->default_mask = parse_hex(tagend); + } else { + parse_error("invalid unit mask tag"); + } + + valueend = skip_ws(valueend); + tagend = valueend; + start = valueend; + } +} + + +/* \t0x08 (M)odified cache state */ +static void parse_um_entry(struct op_described_um * entry, char const * line) +{ + char const * c = line; + + c = skip_ws(c); + entry->value = parse_hex(c); + c = skip_nonws(c); + + if (!*c) + parse_error("invalid unit mask entry"); + + c = skip_ws(c); + + if (!*c) + parse_error("invalid unit mask entry"); + + entry->desc = xstrdup(c); +} + + +static struct op_unit_mask * new_unit_mask(void) +{ + struct op_unit_mask * um = xmalloc(sizeof(struct op_unit_mask)); + memset(um, '\0', sizeof(struct op_unit_mask)); + list_add_tail(&um->um_next, &um_list); + + return um; +} + + +/* + * name:zero type:mandatory default:0x0 + * \t0x0 No unit mask + */ +static void read_unit_masks(char const * file) +{ + struct op_unit_mask * um = NULL; + char * line; + FILE * fp = fopen(file, "r"); + + if (!fp) { + fprintf(stderr, + "oprofile: could not open unit mask description file %s\n", file); + exit(EXIT_FAILURE); + } + + filename = file; + line_nr = 1; + + line = op_get_line(fp); + + while (line) { + if (empty_line(line) || comment_line(line)) + goto next; + + if (line[0] != '\t') { + um = new_unit_mask(); + parse_um(um, line); + } else { + if (!um) { + parse_error("no unit mask name line"); + } + if (um->num >= MAX_UNIT_MASK) { + parse_error("oprofile: maximum unit mask entries exceeded"); + } + parse_um_entry(&um->um[um->num], line); + ++(um->num); + } + +next: + free(line); + line = op_get_line(fp); + ++line_nr; + } + + fclose(fp); +} + + +static u32 parse_counter_mask(char const * str) +{ + u32 mask = 0; + char const * numstart = str; + + while (*numstart) { + mask |= 1 << parse_int(numstart); + + while (*numstart && *numstart != ',') + ++numstart; + /* skip , unless we reach eos */ + if (*numstart) + ++numstart; + + numstart = skip_ws(numstart); + } + + return mask; +} + + +static struct op_unit_mask * find_um(char const * value) +{ + struct list_head * pos; + + list_for_each(pos, &um_list) { + struct op_unit_mask * um = list_entry(pos, struct op_unit_mask, um_next); + if (strcmp(value, um->name) == 0) + return um; + } + + fprintf(stderr, "oprofile: could not find unit mask %s\n", value); + exit(EXIT_FAILURE); +} + + +/* parse either a "tag:value" or a ": trailing description string" */ +static int next_token(char const ** cp, char ** name, char ** value) +{ + size_t tag_len; + size_t val_len; + char const * c = *cp; + char const * end; + char const * colon; + + c = skip_ws(c); + end = colon = c; + end = skip_nonws(end); + + colon = strchr(colon, ':'); + + if (!colon) { + if (*c) { + parse_error("next_token(): garbage at end of line"); + } + return 0; + } + + if (colon >= end) + parse_error("next_token() expected ':'"); + + tag_len = colon - c; + val_len = end - (colon + 1); + + if (!tag_len) { + /* : trailing description */ + end = skip_ws(end); + *name = xstrdup("desc"); + *value = xstrdup(end); + end += strlen(end); + } else { + /* tag:value */ + *name = op_xstrndup(c, tag_len); + *value = op_xstrndup(colon + 1, val_len); + end = skip_ws(end); + } + + *cp = end; + return 1; +} + + +static struct op_event * new_event(void) +{ + struct op_event * event = xmalloc(sizeof(struct op_event)); + memset(event, '\0', sizeof(struct op_event)); + list_add_tail(&event->event_next, &events_list); + + return event; +} + + +/* event:0x00 counters:0 um:zero minimum:4096 name:ISSUES : Total issues */ +static void read_events(char const * file) +{ + struct op_event * event = NULL; + char * line; + char * name; + char * value; + char const * c; + int seen_event, seen_counters, seen_um, seen_minimum, seen_name; + FILE * fp = fopen(file, "r"); + + if (!fp) { + fprintf(stderr, "oprofile: could not open event description file %s\n", file); + exit(EXIT_FAILURE); + } + + filename = file; + line_nr = 1; + + line = op_get_line(fp); + + while (line) { + if (empty_line(line) || comment_line(line)) + goto next; + + seen_name = 0; + seen_event = 0; + seen_counters = 0; + seen_um = 0; + seen_minimum = 0; + event = new_event(); + + c = line; + while (next_token(&c, &name, &value)) { + if (strcmp(name, "name") == 0) { + if (seen_name) + parse_error("duplicate name: tag"); + seen_name = 1; + event->name = value; + } else if (strcmp(name, "event") == 0) { + if (seen_event) + parse_error("duplicate event: tag"); + seen_event = 1; + event->val = parse_hex(value); + free(value); + } else if (strcmp(name, "counters") == 0) { + if (seen_counters) + parse_error("duplicate counters: tag"); + seen_counters = 1; + event->counter_mask = parse_counter_mask(value); + free(value); + } else if (strcmp(name, "um") == 0) { + if (seen_um) + parse_error("duplicate um: tag"); + seen_um = 1; + event->unit = find_um(value); + event->unit->used = 1; + free(value); + } else if (strcmp(name, "minimum") == 0) { + if (seen_minimum) + parse_error("duplicate minimum: tag"); + seen_minimum = 1; + event->min_count = parse_int(value); + free(value); + } else if (strcmp(name, "desc") == 0) { + event->desc = value; + } else { + parse_error("unknown tag"); + } + + free(name); + } +next: + free(line); + line = op_get_line(fp); + ++line_nr; + } + + fclose(fp); +} + + +/* usefull for make check */ +static void check_unit_mask(struct op_unit_mask const * um, + char const * cpu_name) +{ + u16 i; + + if (!um->used) { + fprintf(stderr, "um %s is not used\n", um->name); + exit(EXIT_FAILURE); + } + + if (um->unit_type_mask == utm_mandatory && um->num != 1) { + fprintf(stderr, "mandatory um %s doesn't contain exactly one " + "entry (%s)\n", um->name, cpu_name); + exit(EXIT_FAILURE); + } else if (um->unit_type_mask == utm_bitmask) { + u16 default_mask = um->default_mask; + for (i = 0; i < um->num; ++i) { + default_mask &= ~um->um[i].value; + } + if (default_mask) { + fprintf(stderr, "um %s default mask is not valid " + "(%s)\n", um->name, cpu_name); + exit(EXIT_FAILURE); + } + } else { + for (i = 0; i < um->num; ++i) { + if (um->default_mask == um->um[i].value) + break; + } + + if (i == um->num) { + fprintf(stderr, "exclusive um %s default value is not " + "valid (%s)\n", um->name, cpu_name); + exit(EXIT_FAILURE); + } + } +} + + +static void load_events(op_cpu cpu_type) +{ + char const * cpu_name = op_get_cpu_name(cpu_type); + char * event_dir; + char * event_file; + char * um_file; + char * dir; + struct list_head * pos; + + if (!list_empty(&events_list)) + return; + + dir = getenv("OPROFILE_EVENTS_DIR"); + if (dir == NULL) + dir = OP_DATADIR; + + event_dir = xmalloc(strlen(dir) + strlen("/") + strlen(cpu_name) + + strlen("/") + 1); + strcpy(event_dir, dir); + strcat(event_dir, "/"); + + strcat(event_dir, cpu_name); + strcat(event_dir, "/"); + + event_file = xmalloc(strlen(event_dir) + strlen("events") + 1); + strcpy(event_file, event_dir); + strcat(event_file, "events"); + + um_file = xmalloc(strlen(event_dir) + strlen("unit_masks") + 1); + strcpy(um_file, event_dir); + strcat(um_file, "unit_masks"); + + read_unit_masks(um_file); + read_events(event_file); + + /* sanity check: all unit mask must be used */ + list_for_each(pos, &um_list) { + struct op_unit_mask * um = list_entry(pos, struct op_unit_mask, um_next); + + check_unit_mask(um, cpu_name); + } + + free(um_file); + free(event_file); + free(event_dir); +} + + +struct list_head * op_events(op_cpu cpu_type) +{ + load_events(cpu_type); + return &events_list; +} + + +static void delete_unit_mask(struct op_unit_mask * unit) +{ + u32 cur; + for (cur = 0 ; cur < unit->num ; ++cur) { + if (unit->um[cur].desc) + free(unit->um[cur].desc); + } + + if (unit->name) + free(unit->name); + + list_del(&unit->um_next); + free(unit); +} + + +static void delete_event(struct op_event * event) +{ + if (event->name) + free(event->name); + if (event->desc) + free(event->desc); + + list_del(&event->event_next); + free(event); +} + + +void op_free_events(void) +{ + struct list_head * pos, * pos2; + list_for_each_safe(pos, pos2, &events_list) { + struct op_event * event = list_entry(pos, struct op_event, event_next); + delete_event(event); + } + + list_for_each_safe(pos, pos2, &um_list) { + struct op_unit_mask * unit = list_entry(pos, struct op_unit_mask, um_next); + delete_unit_mask(unit); + } +} + + +static struct op_event * find_event(u8 nr) +{ + struct list_head * pos; + + list_for_each(pos, &events_list) { + struct op_event * event = list_entry(pos, struct op_event, event_next); + if (event->val == nr) + return event; + } + + return NULL; +} + + +static FILE * open_event_mapping_file(char const * cpu_name) +{ + char * ev_map_file; + char * dir; + dir = getenv("OPROFILE_EVENTS_DIR"); + if (dir == NULL) + dir = OP_DATADIR; + + ev_map_file = xmalloc(strlen(dir) + strlen("/") + strlen(cpu_name) + + strlen("/") + + strlen("event_mappings") + 1); + strcpy(ev_map_file, dir); + strcat(ev_map_file, "/"); + + strcat(ev_map_file, cpu_name); + strcat(ev_map_file, "/"); + strcat(ev_map_file, "event_mappings"); + filename = ev_map_file; + return (fopen(ev_map_file, "r")); +} + + +/** + * This function is PPC64-specific. + */ +static char const * get_mapping(u8 nr, FILE * fp) +{ + char * line; + char * name; + char * value; + char const * c; + char * map = NULL; + int seen_event = 0, seen_mmcr0 = 0, seen_mmcr1 = 0, seen_mmcra = 0; + u32 mmcr0 = 0; + u64 mmcr1 = 0; + u32 mmcra = 0; + int event_found = 0; + + line_nr = 1; + line = op_get_line(fp); + while (line && !event_found) { + if (empty_line(line) || comment_line(line)) + goto next; + + seen_event = 0; + seen_mmcr0 = 0; + seen_mmcr1 = 0; + seen_mmcra = 0; + mmcr0 = 0; + mmcr1 = 0; + mmcra = 0; + + c = line; + while (next_token(&c, &name, &value)) { + if (strcmp(name, "event") == 0) { + u8 evt; + if (seen_event) + parse_error("duplicate event tag"); + seen_event = 1; + evt = parse_hex(value); + if (evt == nr) { + event_found = 1; + } + free(value); + } else if (strcmp(name, "mmcr0") == 0) { + if (seen_mmcr0) + parse_error("duplicate mmcr0 tag"); + seen_mmcr0 = 1; + mmcr0 = parse_hex(value); + free(value); + } else if (strcmp(name, "mmcr1") == 0) { + if (seen_mmcr1) + parse_error("duplicate mmcr1: tag"); + seen_mmcr1 = 1; + mmcr1 = parse_long_hex(value); + free(value); + } else if (strcmp(name, "mmcra") == 0) { + if (seen_mmcra) + parse_error("duplicate mmcra: tag"); + seen_mmcra = 1; + mmcra = parse_hex(value); + free(value); + } else { + parse_error("unknown tag"); + } + + free(name); + } +next: + free(line); + line = op_get_line(fp); + ++line_nr; + } + if (event_found) { + if (!seen_mmcr0 || !seen_mmcr1 || !seen_mmcra) { + fprintf(stderr, "Error: Missing information in line %d of event mapping file %s\n", line_nr, filename); + exit(EXIT_FAILURE); + } + map = xmalloc(70); + snprintf(map, 70, "mmcr0:%u mmcr1:%Lu mmcra:%u", + mmcr0, mmcr1, mmcra); + } + + return map; +} + + +char const * find_mapping_for_event(u8 nr, op_cpu cpu_type) +{ + char const * cpu_name = op_get_cpu_name(cpu_type); + FILE * fp = open_event_mapping_file(cpu_name); + char const * map = NULL; + switch (cpu_type) { + case CPU_PPC64_970: + case CPU_PPC64_POWER4: + case CPU_PPC64_POWER5: + if (!fp) { + fprintf(stderr, "oprofile: could not open event mapping file %s\n", filename); + exit(EXIT_FAILURE); + } else { + map = get_mapping(nr, fp); + } + break; + default: + break; + } + + if (fp) + fclose(fp); + + return map; +} + + +struct op_event * find_event_by_name(char const * name) +{ + struct list_head * pos; + + list_for_each(pos, &events_list) { + struct op_event * event = list_entry(pos, struct op_event, event_next); + if (strcmp(event->name, name) == 0) + return event; + } + + return NULL; +} + + +struct op_event * op_find_event(op_cpu cpu_type, u8 nr) +{ + struct op_event * event; + + load_events(cpu_type); + + event = find_event(nr); + + return event; +} + + +int op_check_events(int ctr, u8 nr, u16 um, op_cpu cpu_type) +{ + int ret = OP_OK_EVENT; + struct op_event * event; + size_t i; + u32 ctr_mask = 1 << ctr; + + load_events(cpu_type); + + event = find_event(nr); + + if (!event) { + ret |= OP_INVALID_EVENT; + return ret; + } + + if ((event->counter_mask & ctr_mask) == 0) + ret |= OP_INVALID_COUNTER; + + if (event->unit->unit_type_mask == utm_bitmask) { + for (i = 0; i < event->unit->num; ++i) + um &= ~(event->unit->um[i].value); + + if (um) + ret |= OP_INVALID_UM; + + } else { + for (i = 0; i < event->unit->num; ++i) { + if (event->unit->um[i].value == um) + break; + } + + if (i == event->unit->num) + ret |= OP_INVALID_UM; + } + + return ret; +} + + +void op_default_event(op_cpu cpu_type, struct op_default_event_descr * descr) +{ + descr->name = ""; + descr->um = 0x0; + /* A fixed value of CPU cycles; this should ensure good + * granulity even on faster CPUs, though it will generate more + * interrupts. + */ + descr->count = 100000; + + switch (cpu_type) { + case CPU_PPRO: + case CPU_PII: + case CPU_PIII: + case CPU_P6_MOBILE: + case CPU_ATHLON: + case CPU_HAMMER: + descr->name = "CPU_CLK_UNHALTED"; + break; + + case CPU_RTC: + descr->name = "RTC_INTERRUPTS"; + descr->count = 1024; + break; + + case CPU_P4: + case CPU_P4_HT2: + descr->name = "GLOBAL_POWER_EVENTS"; + descr->um = 0x1; + break; + + case CPU_IA64: + case CPU_IA64_1: + case CPU_IA64_2: + descr->count = 1000000; + descr->name = "CPU_CYCLES"; + break; + + case CPU_AXP_EV4: + case CPU_AXP_EV5: + case CPU_AXP_PCA56: + case CPU_AXP_EV6: + case CPU_AXP_EV67: + descr->name = "CYCLES"; + break; + + // we could possibly use the CCNT + case CPU_ARM_XSCALE1: + case CPU_ARM_XSCALE2: + descr->name = "CPU_CYCLES"; + break; + + case CPU_PPC64_970: + case CPU_PPC64_POWER4: + case CPU_PPC64_POWER5: + descr->name = "CYCLES"; + break; + + case CPU_MIPS_24K: + descr->name = "INSTRUCTIONS"; + break; + + case CPU_MIPS_R10000: + case CPU_MIPS_R12000: + descr->name = "INSTRUCTIONS_GRADUATED"; + break; + + case CPU_MIPS_RM7000: + case CPU_MIPS_RM9000: + descr->name = "INSTRUCTIONS_ISSUED"; + break; + + case CPU_MIPS_SB1: + descr->name = "INSN_SURVIVED_STAGE7"; + break; + + case CPU_MIPS_VR5432: + case CPU_MIPS_VR5500: + descr->name = "INSTRUCTIONS_EXECUTED"; + break; + + case CPU_PPC_E500: + descr->name = "CPU_CLK"; + break; + + // don't use default, if someone add a cpu he wants a compiler + // warning if he forgets to handle it here. + case CPU_TIMER_INT: + case CPU_NO_GOOD: + case MAX_CPU_TYPE: + break; + } +} diff --git a/libop/op_events.h b/libop/op_events.h new file mode 100644 index 0000000..1796fb9 --- /dev/null +++ b/libop/op_events.h @@ -0,0 +1,125 @@ +/** + * @file op_events.h + * Details of PMC profiling events + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_EVENTS_H +#define OP_EVENTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "op_cpu_type.h" +#include "op_types.h" +#include "op_list.h" + +/** Describe an unit mask type. Events can optionally use a filter called + * the unit mask. the mask type can be a bitmask or a discrete value */ +enum unit_mask_type { + utm_mandatory, /**< useless but required by the hardware */ + utm_exclusive, /**< only one of the values is allowed */ + utm_bitmask /**< bitmask */ +}; + +/** up to sixteen allowed unit masks */ +#define MAX_UNIT_MASK 16 + + +/** Describe an unit mask. */ +struct op_unit_mask { + char * name; /**< name of unit mask type */ + u32 num; /**< number of possible unit masks */ + enum unit_mask_type unit_type_mask; + u16 default_mask; /**< only the gui use it */ + struct op_described_um { + u16 value; + char * desc; + } um[MAX_UNIT_MASK]; + struct list_head um_next; /**< next um in list */ + int used; /**< used by events file parser */ +}; + + +/** Describe an event. */ +struct op_event { + u32 counter_mask; /**< bitmask of allowed counter */ + u8 val; /**< event number */ + /** which unit mask if any allowed */ + struct op_unit_mask * unit; + char * name; /**< the event name */ + char * desc; /**< the event description */ + int min_count; /**< minimum counter value allowed */ + struct list_head event_next; /**< next event in list */ +}; + +/** Return the known events list. Idempotent */ +struct list_head * op_events(op_cpu cpu_type); + +/** Find a given event, returns NULL on error */ +struct op_event * op_find_event(op_cpu cpu_type, u8 nr); + +/** Find a given event by name */ +struct op_event * find_event_by_name(char const * name); + +/** + * Find a mapping for a given event ID for architectures requiring additional information + * from what is held in the events file. + */ +char const * find_mapping_for_event(u8 val, op_cpu cpu_type); + + +/** op_check_events() return code */ +enum op_event_check { + OP_OK_EVENT = 0, /**< event is valid and allowed */ + OP_INVALID_EVENT = 1, /**< event number is invalid */ + OP_INVALID_UM = 2, /**< unit mask is invalid */ + OP_INVALID_COUNTER = 4 /**< event is not allowed for the given counter */ +}; + +/** + * sanity check event values + * @param ctr counter number + * @param event value for counter + * @param um unit mask for counter + * @param cpu_type processor type + * + * Check that the counter event and unit mask values are allowed. + * + * The function returns bitmask of failure cause 0 otherwise + * + * \sa op_cpu, OP_EVENTS_OK + */ +int op_check_events(int ctr, u8 event, u16 um, op_cpu cpu_type); + +/** + * free memory used by any call to above function. Need to be called only once + */ +void op_free_events(void); + +struct op_default_event_descr { + char * name; + unsigned long count; + unsigned long um; +}; + +/** + * op_default_event - return the details of the default event + * @param cpu_type cpu type + * @param descr filled event description + * + * Fills in the event description if applicable + */ +void op_default_event(op_cpu cpu_type, struct op_default_event_descr * descr); + +#ifdef __cplusplus +} +#endif + +#endif /* OP_EVENTS_H */ diff --git a/libop/op_get_interface.c b/libop/op_get_interface.c new file mode 100644 index 0000000..bdf72a5 --- /dev/null +++ b/libop/op_get_interface.c @@ -0,0 +1,32 @@ +/** + * @file op_get_interface.c + * Determine which oprofile kernel interface used + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Will Cohen + */ + +#include +#include +#include + +#include "op_cpu_type.h" +#include "op_file.h" + +op_interface op_get_interface(void) +{ + static op_interface current_interface = OP_INTERFACE_NO_GOOD; + + if (current_interface != OP_INTERFACE_NO_GOOD) + return current_interface; + + if (op_file_readable("/proc/sys/dev/oprofile/cpu_type")) { + current_interface = OP_INTERFACE_24; + } else if (op_file_readable("/dev/oprofile/cpu_type")) { + current_interface = OP_INTERFACE_26; + } + + return current_interface; +} diff --git a/libop/op_hw_config.h b/libop/op_hw_config.h new file mode 100644 index 0000000..169b36b --- /dev/null +++ b/libop/op_hw_config.h @@ -0,0 +1,30 @@ +/** + * @file op_hw_config.h + * Configuration parameters that are dependent on CPU/architecture + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_HW_CONFIG_H +#define OP_HW_CONFIG_H + +/** maximum number of counters, up to 4 for Athlon (18 for P4). The primary + * use of this variable is for static/local array dimension. Never use it in + * loop or in array index access/index checking unless you know what you + * made. */ +#ifdef __alpha__ +#define OP_MAX_COUNTERS 20 +#else +#define OP_MAX_COUNTERS 8 +#endif + +/** maximum number of events between interrupts. Counters are 40 bits, but + * for convenience we only use 32 bits. The top bit is used for overflow + * detection, so user can set up to (2^31)-1 */ +#define OP_MAX_PERF_COUNT 2147483647UL + +#endif /* OP_HW_CONFIG_H */ diff --git a/libop/op_interface.h b/libop/op_interface.h new file mode 100644 index 0000000..fa2ecbd --- /dev/null +++ b/libop/op_interface.h @@ -0,0 +1,87 @@ +/** + * @file op_interface.h + * + * Module / user space interface for 2.4 + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_INTERFACE_H +#define OP_INTERFACE_H + +#include "op_config.h" +#include "op_types.h" + +/*@{\name notifications types encoded in op_note::type */ +/** fork(),vfork(),clone() */ +#define OP_FORK 1 +/** mapping */ +#define OP_MAP 2 +/** execve() */ +#define OP_EXEC 4 +/** init_module() */ +#define OP_DROP_MODULES 8 +/** exit() */ +#define OP_EXIT 16 +/*@}*/ + +/** Data type to transfer samples counts from the module to the daemon */ +struct op_sample { + unsigned long eip; /**< eip value where occur interrupt */ + u32 counter; /**< counter nr */ + u32 pid; /**< 32 bits can hold any pid */ + u32 tgid; /**< always equal to pid for kernel < 2.4.0 */ +}; + +/** the current kernel-side profiler state */ +enum oprof_state { + STOPPED = 0, + STOPPING = 1, + RUNNING = 2 +}; + +/** + * The head structure of a kernel sample buffer. + */ +struct op_buffer_head { + int cpu_nr; /**< the CPU number of this buffer */ + size_t count; /**< number of samples in this buffer */ + enum oprof_state state; /**< current profiler state */ + struct op_sample buffer[0]; /**< the sample buffer */ +} __attribute__((__packed__)); + +/** + * Data type used by the module to notify daemon of fork/exit/mapping etc. + * Meanings of fields depend on the type of notification encoded in the type + * field. + * \sa OP_FORK, OP_EXEC, OP_MAP, OP_DROP_MODULES and OP_EXIT + */ +struct op_note { + unsigned long addr; + unsigned long len; + unsigned long offset; + unsigned int hash; + unsigned int pid; + unsigned int tgid; + unsigned short type; +}; + +/** + * A path component. Directory name are stored as a stack of path components. + * Note than the name index acts also as an unique identifier + */ +struct op_hash_index { + /** index inside the string pool */ + u32 name; + /** parent component, zero if this component is the root */ + u32 parent; +} __attribute__((__packed__)); + +/** size of hash map in bytes */ +#define OP_HASH_MAP_SIZE (OP_HASH_MAP_NR * sizeof(struct op_hash_index) + POOL_SIZE) + +#endif /* OP_INTERFACE_H */ diff --git a/libop/op_mangle.c b/libop/op_mangle.c new file mode 100644 index 0000000..a78d87f --- /dev/null +++ b/libop/op_mangle.c @@ -0,0 +1,97 @@ +/** + * @file op_mangle.c + * Mangling of sample file names + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "op_mangle.h" + +#include +#include + +#include "op_libiberty.h" + +#include "op_sample_file.h" +#include "op_config.h" + +static void append_image(char * dest, int flags, int anon, char const * name) +{ + if ((flags & MANGLE_KERNEL) && !strchr(name, '/')) { + strcat(dest, "{kern}/"); + } else if (anon) { + strcat(dest, "{anon}/"); + } else { + strcat(dest, "{root}/"); + } + + strcat(dest, name); + strcat(dest, "/"); +} + +char * op_mangle_filename(struct mangle_values const * values) +{ + char * mangled; + size_t len; + int anon = values->flags & MANGLE_ANON; + int cg_anon = values->flags & MANGLE_CG_ANON; + /* if dep_name != image_name we need to invert them (and so revert them + * unconditionally because if they are equal it doesn't hurt to invert + * them), see P:3, FIXME: this is a bit weirds, we prolly need to + * reword pp_interface */ + char const * image_name = values->dep_name; + char const * dep_name = values->image_name; + char const * cg_image_name = values->cg_image_name; + + len = strlen(OP_SAMPLES_CURRENT_DIR) + strlen(dep_name) + 1 + + strlen(values->event_name) + 1 + strlen(image_name) + 1; + + if (values->flags & MANGLE_CALLGRAPH) + len += strlen(cg_image_name) + 1; + + /* provision for tgid, tid, unit_mask, cpu and some {root}, {dep}, + * {kern}, {anon} and {cg} marker */ + /* FIXME: too ugly */ + len += 256; + + mangled = xmalloc(len); + + strcpy(mangled, OP_SAMPLES_CURRENT_DIR); + append_image(mangled, values->flags, 0, image_name); + + strcat(mangled, "{dep}" "/"); + append_image(mangled, values->flags, anon, dep_name); + + if (values->flags & MANGLE_CALLGRAPH) { + strcat(mangled, "{cg}" "/"); + append_image(mangled, values->flags, cg_anon, cg_image_name); + } + + strcat(mangled, values->event_name); + sprintf(mangled + strlen(mangled), ".%d.%d.", + values->count, values->unit_mask); + + if (values->flags & MANGLE_TGID) { + sprintf(mangled + strlen(mangled), "%d.", values->tgid); + } else { + sprintf(mangled + strlen(mangled), "%s.", "all"); + } + + if (values->flags & MANGLE_TID) { + sprintf(mangled + strlen(mangled), "%d.", values->tid); + } else { + sprintf(mangled + strlen(mangled), "%s.", "all"); + } + + if (values->flags & MANGLE_CPU) { + sprintf(mangled + strlen(mangled), "%d", values->cpu); + } else { + sprintf(mangled + strlen(mangled), "%s", "all"); + } + + return mangled; +} diff --git a/libop/op_mangle.h b/libop/op_mangle.h new file mode 100644 index 0000000..5d02d94 --- /dev/null +++ b/libop/op_mangle.h @@ -0,0 +1,65 @@ +/** + * @file op_mangle.h + * Mangling of sample file names + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_MANGLE_H +#define OP_MANGLE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum mangle_flags { + MANGLE_NONE = 0, + MANGLE_CPU = (1 << 0), + MANGLE_TGID = (1 << 1), + MANGLE_TID = (1 << 2), + MANGLE_KERNEL = (1 << 3), + MANGLE_CALLGRAPH = (1 << 4), + MANGLE_ANON = (1 << 5), + MANGLE_CG_ANON = (1 << 6), +}; + +/** + * Temporary structure for passing parameters to + * op_mangle_filename. + */ +struct mangle_values { + int flags; + + char const * image_name; + char const * dep_name; + char const * cg_image_name; + char const * event_name; + int count; + unsigned int unit_mask; + pid_t tgid; + pid_t tid; + int cpu; +}; + +/** + * op_mangle_filename - mangle a sample filename + * @param values parameters to use as mangling input + * + * See also PP:3 for the encoding scheme + * + * Returns a char* pointer to the mangled string. Caller + * is responsible for freeing this string. + */ +char * op_mangle_filename(struct mangle_values const * values); + +#ifdef __cplusplus +} +#endif + +#endif /* OP_MANGLE_H */ diff --git a/libop/op_parse_event.c b/libop/op_parse_event.c new file mode 100644 index 0000000..920d617 --- /dev/null +++ b/libop/op_parse_event.c @@ -0,0 +1,120 @@ +/** + * @file op_parse_event.c + * event parsing + * + * You can have silliness here. + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include + +#include "op_parse_event.h" +#include "op_string.h" + +static char * next_part(char const ** str) +{ + char const * c; + char * ret; + + if ((*str)[0] == '\0') + return NULL; + + if ((*str)[0] == ':') + ++(*str); + + c = *str; + + while (*c != '\0' && *c != ':') + ++c; + + if (c == *str) + return NULL; + + ret = op_xstrndup(*str, c - *str); + *str += c - *str; + return ret; +} + + +static int parse_ulong(char const * str) +{ + unsigned long value; + char * end; + value = strtoul(str, &end, 0); + if (end && *end) { + fprintf(stderr, "Invalid event part %s\n", str); + exit(EXIT_FAILURE); + } + + return value; +} + + +size_t parse_events(struct parsed_event * parsed_events, size_t max_events, + char const * const * events) +{ + size_t i = 0; + + while (events[i]) { + char const * cp = events[i]; + char * part = next_part(&cp); + + if (i >= max_events) { + fprintf(stderr, "Too many events specified: CPU " + "only has %lu counters.\n", + (unsigned long) max_events); + exit(EXIT_FAILURE); + } + + if (!part) { + fprintf(stderr, "Invalid event %s\n", cp); + exit(EXIT_FAILURE); + } + + parsed_events[i].name = part; + + part = next_part(&cp); + + if (!part) { + fprintf(stderr, "Invalid count for event %s\n", events[i]); + exit(EXIT_FAILURE); + } + + parsed_events[i].count = parse_ulong(part); + free(part); + + parsed_events[i].unit_mask = 0; + part = next_part(&cp); + + if (part) { + parsed_events[i].unit_mask = parse_ulong(part); + free(part); + } + + parsed_events[i].kernel = 1; + part = next_part(&cp); + + if (part) { + parsed_events[i].kernel = parse_ulong(part); + free(part); + } + + parsed_events[i].user = 1; + part = next_part(&cp); + + if (part) { + parsed_events[i].user = parse_ulong(part); + free(part); + } + + ++i; + } + + return i; +} diff --git a/libop/op_parse_event.h b/libop/op_parse_event.h new file mode 100644 index 0000000..247a355 --- /dev/null +++ b/libop/op_parse_event.h @@ -0,0 +1,42 @@ +/** + * @file op_parse_event.h + * event parsing + * + * You can have silliness here. + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_PARSE_EVENT_H +#define OP_PARSE_EVENT_H + +#include + +struct parsed_event { + char * name; + int count; + int unit_mask; + int kernel; + int user; +}; + +/** + * @param parsed_events array of events to fill in + * @param max_events size of parsed_events + * @param events null terminated array of events string on the form + * event_name:count[:unit_mask:kernel:user] + * + * parse events given by the nil terminated array events and fill in + * parsed_events with results. Events validity are not checked except. + * A fatal error occur if number of events is greater than max_events. + * + * Return the number of events parsed. + */ +size_t parse_events(struct parsed_event * parsed_events, size_t max_events, + char const * const * events); + +#endif /* !OP_PARSE_EVENT_H */ diff --git a/libop/op_sample_file.h b/libop/op_sample_file.h new file mode 100644 index 0000000..c3121c8 --- /dev/null +++ b/libop/op_sample_file.h @@ -0,0 +1,38 @@ +/** + * @file op_sample_file.h + * Sample file format + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_SAMPLE_FILE_H +#define OP_SAMPLE_FILE_H + +#include "op_types.h" + +#include + +/* header of the sample files */ +struct opd_header { + u8 magic[4]; + u32 version; + u32 cpu_type; + u32 ctr_event; + u32 ctr_um; + u32 ctr_count; + // for cg file the from_cg_is_kernel + u32 is_kernel; + double cpu_speed; + time_t mtime; + u32 cg_to_is_kernel; + u64 anon_start; + u64 cg_to_anon_start; + /* binary compatibility reserve */ + u32 reserved1[1]; +}; + +#endif /* OP_SAMPLE_FILE_H */ diff --git a/libop/tests/Makefile.am b/libop/tests/Makefile.am new file mode 100644 index 0000000..cf5e8fc --- /dev/null +++ b/libop/tests/Makefile.am @@ -0,0 +1,33 @@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libop + +AM_CFLAGS = @OP_CFLAGS@ -DOPROFILE_SRCDIR=\"@top_srcdir@\" + +COMMON_LIBS = ../libop.a ../../libutil/libutil.a + +LIBS = @LIBERTY_LIBS@ + +check_PROGRAMS = \ + cpu_type_tests \ + parse_event_tests \ + load_events_files_tests \ + alloc_counter_tests \ + mangle_tests + +cpu_type_tests_SOURCES = cpu_type_tests.c +cpu_type_tests_LDADD = ${COMMON_LIBS} + +parse_event_tests_SOURCES = parse_event_tests.c +parse_event_tests_LDADD = ${COMMON_LIBS} + +alloc_counter_tests_SOURCES = alloc_counter_tests.c +alloc_counter_tests_LDADD = ${COMMON_LIBS} + +load_events_files_tests_SOURCES = load_events_files_tests.c +load_events_files_tests_LDADD = ${COMMON_LIBS} + +mangle_tests_SOURCES = mangle_tests.c +mangle_tests_LDADD = ${COMMON_LIBS} + +TESTS = ${check_PROGRAMS} diff --git a/libop/tests/Makefile.in b/libop/tests/Makefile.in new file mode 100644 index 0000000..4992cec --- /dev/null +++ b/libop/tests/Makefile.in @@ -0,0 +1,554 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +SOURCES = $(alloc_counter_tests_SOURCES) $(cpu_type_tests_SOURCES) $(load_events_files_tests_SOURCES) $(mangle_tests_SOURCES) $(parse_event_tests_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +check_PROGRAMS = cpu_type_tests$(EXEEXT) parse_event_tests$(EXEEXT) \ + load_events_files_tests$(EXEEXT) alloc_counter_tests$(EXEEXT) \ + mangle_tests$(EXEEXT) +subdir = libop/tests +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am_alloc_counter_tests_OBJECTS = alloc_counter_tests.$(OBJEXT) +alloc_counter_tests_OBJECTS = $(am_alloc_counter_tests_OBJECTS) +am__DEPENDENCIES_1 = ../libop.a ../../libutil/libutil.a +alloc_counter_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_cpu_type_tests_OBJECTS = cpu_type_tests.$(OBJEXT) +cpu_type_tests_OBJECTS = $(am_cpu_type_tests_OBJECTS) +cpu_type_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_load_events_files_tests_OBJECTS = \ + load_events_files_tests.$(OBJEXT) +load_events_files_tests_OBJECTS = \ + $(am_load_events_files_tests_OBJECTS) +load_events_files_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_mangle_tests_OBJECTS = mangle_tests.$(OBJEXT) +mangle_tests_OBJECTS = $(am_mangle_tests_OBJECTS) +mangle_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_parse_event_tests_OBJECTS = parse_event_tests.$(OBJEXT) +parse_event_tests_OBJECTS = $(am_parse_event_tests_OBJECTS) +parse_event_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(alloc_counter_tests_SOURCES) $(cpu_type_tests_SOURCES) \ + $(load_events_files_tests_SOURCES) $(mangle_tests_SOURCES) \ + $(parse_event_tests_SOURCES) +DIST_SOURCES = $(alloc_counter_tests_SOURCES) \ + $(cpu_type_tests_SOURCES) $(load_events_files_tests_SOURCES) \ + $(mangle_tests_SOURCES) $(parse_event_tests_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBERTY_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libop + +AM_CFLAGS = @OP_CFLAGS@ -DOPROFILE_SRCDIR=\"@top_srcdir@\" +COMMON_LIBS = ../libop.a ../../libutil/libutil.a +cpu_type_tests_SOURCES = cpu_type_tests.c +cpu_type_tests_LDADD = ${COMMON_LIBS} +parse_event_tests_SOURCES = parse_event_tests.c +parse_event_tests_LDADD = ${COMMON_LIBS} +alloc_counter_tests_SOURCES = alloc_counter_tests.c +alloc_counter_tests_LDADD = ${COMMON_LIBS} +load_events_files_tests_SOURCES = load_events_files_tests.c +load_events_files_tests_LDADD = ${COMMON_LIBS} +mangle_tests_SOURCES = mangle_tests.c +mangle_tests_LDADD = ${COMMON_LIBS} +TESTS = ${check_PROGRAMS} +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libop/tests/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libop/tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +alloc_counter_tests$(EXEEXT): $(alloc_counter_tests_OBJECTS) $(alloc_counter_tests_DEPENDENCIES) + @rm -f alloc_counter_tests$(EXEEXT) + $(LINK) $(alloc_counter_tests_LDFLAGS) $(alloc_counter_tests_OBJECTS) $(alloc_counter_tests_LDADD) $(LIBS) +cpu_type_tests$(EXEEXT): $(cpu_type_tests_OBJECTS) $(cpu_type_tests_DEPENDENCIES) + @rm -f cpu_type_tests$(EXEEXT) + $(LINK) $(cpu_type_tests_LDFLAGS) $(cpu_type_tests_OBJECTS) $(cpu_type_tests_LDADD) $(LIBS) +load_events_files_tests$(EXEEXT): $(load_events_files_tests_OBJECTS) $(load_events_files_tests_DEPENDENCIES) + @rm -f load_events_files_tests$(EXEEXT) + $(LINK) $(load_events_files_tests_LDFLAGS) $(load_events_files_tests_OBJECTS) $(load_events_files_tests_LDADD) $(LIBS) +mangle_tests$(EXEEXT): $(mangle_tests_OBJECTS) $(mangle_tests_DEPENDENCIES) + @rm -f mangle_tests$(EXEEXT) + $(LINK) $(mangle_tests_LDFLAGS) $(mangle_tests_OBJECTS) $(mangle_tests_LDADD) $(LIBS) +parse_event_tests$(EXEEXT): $(parse_event_tests_OBJECTS) $(parse_event_tests_DEPENDENCIES) + @rm -f parse_event_tests$(EXEEXT) + $(LINK) $(parse_event_tests_LDFLAGS) $(parse_event_tests_OBJECTS) $(parse_event_tests_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloc_counter_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu_type_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/load_events_files_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mangle_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_event_tests.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic ctags distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libop/tests/alloc_counter_tests.c b/libop/tests/alloc_counter_tests.c new file mode 100644 index 0000000..8a82974 --- /dev/null +++ b/libop/tests/alloc_counter_tests.c @@ -0,0 +1,207 @@ +/** + * @file alloc_counter_tests.c + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include + +#include "op_parse_event.h" +#include "op_alloc_counter.h" +#include "op_events.h" +#include "op_hw_config.h" +#include "op_cpu_type.h" +#include "op_events.h" + +/* FIXME: alpha description events need 20 but when running test on x86 + * OP_MAX_COUNTERS is 8, so we can't use it */ +#define MAX_EVENTS 20 + + +/* some test are setup to fail in a known way */ +enum failure_type { + no_failure, + fail_to_find_event, + fail_to_alloc_counter +}; + +struct allocated_counter { + op_cpu cpu_type; + char const * const * events; + size_t alloc_map[MAX_EVENTS]; + /* expected failure for this test */ + enum failure_type failure; +}; + + +/* not more than MAX_EVENTS string for all these arrays */ +static char const * const events_alpha_ev4_1[] = { + "ISSUES:4096:0:1:1", + NULL +}; + +static char const * const events_alpha_ev4_2[] = { + "UNKNOWN_EVENT:4096:0:1:1", + NULL +}; + +static char const * const events_ppro_1[] = { + "CPU_CLK_UNHALTED:4096:0:1:1", + NULL +}; + +static char const * const events_ppro_2[] = { + "CPU_CLK_UNHALTED:4096:0:1:1", + "DATA_MEM_REFS:4096:0:1:1", + NULL +}; + +static char const * const events_ppro_3[] = { + /* fail_to_alloc_counter: 2 event to counter 0 */ + "COMP_FLOP_RET:4096:0:1:1", + "FLOPS:4096:0:1:1", + NULL +}; + +static char const * const events_ppro_4[] = { + "FLOPS:4096:0:1:1", + "FP_ASSIST:4096:0:1:1", + NULL +}; + +static char const * const events_ppro_5[] = { + "FP_ASSIST:4096:0:1:1", + "FLOPS:4096:0:1:1", + NULL +}; + +static char const * const events_p4_1[] = { + "BRANCH_RETIRED:4096:0:1:1", + "MISPRED_BRANCH_RETIRED:4096:0:1:1", + "BPU_FETCH_REQUEST:4096:0:1:1", + "ITLB_REFERENCE:4096:0:1:1", + "MEMORY_CANCEL:4096:0:1:1", + "MEMORY_COMPLETE:4096:0:1:1", + "TC_MS_XFER:4096:0:1:1", + "UOP_QUEUE_WRITES:4096:0:1:1", + NULL +}; + +static char const * const events_p4_2[] = { + /* fail_to_alloc_counter: 3 event to counter 3, 7 */ + "BRANCH_RETIRED:4096:0:1:1", + "MISPRED_BRANCH_RETIRED:4096:0:1:1", + "INSTR_RETIRED:4096:0:1:1", + "BPU_FETCH_REQUEST:4096:0:1:1", + "ITLB_REFERENCE:4096:0:1:1", + "MEMORY_CANCEL:4096:0:1:1", + "MEMORY_COMPLETE:4096:0:1:1", + "TC_MS_XFER:4096:0:1:1", + NULL +}; + +static struct allocated_counter const tests[] = { + { CPU_AXP_EV4, events_alpha_ev4_1, { 0 }, no_failure }, + { CPU_AXP_EV4, events_alpha_ev4_2, { -1 }, fail_to_find_event }, + { CPU_PPRO, events_ppro_1, { 0 }, no_failure }, + { CPU_PPRO, events_ppro_2, { 1, 0 }, no_failure }, + { CPU_PPRO, events_ppro_3, { 1, 0 }, fail_to_alloc_counter }, + { CPU_PPRO, events_ppro_4, { 0, 1 }, no_failure }, + { CPU_PPRO, events_ppro_5, { 1, 0 }, no_failure }, + { CPU_P4, events_p4_1, { 7, 3, 4, 0, 6, 2, 5, 1 }, no_failure }, + { CPU_P4, events_p4_2, { -1 }, fail_to_alloc_counter }, + { CPU_NO_GOOD, 0, { 0 }, 0 } +}; + + +static void show_events(char const * const * events) +{ + for ( ; *events; ++events) + printf("%s\n", *events); +} + + +static void show_counter_map(size_t const * counter_map, size_t nr_events) +{ + size_t i; + for (i = 0; i < nr_events; ++i) + printf("%lu ", (unsigned long)counter_map[i]); + printf("\n"); +} + + +static void do_test(struct allocated_counter const * it) +{ + size_t i; + size_t * counter_map; + size_t nr_events; + struct parsed_event parsed[MAX_EVENTS]; + struct op_event const * event[MAX_EVENTS]; + + op_events(it->cpu_type); + + nr_events = parse_events(parsed, MAX_EVENTS, it->events); + + for (i = 0; i < nr_events; ++i) { + event[i] = find_event_by_name(parsed[i].name); + if (!event[i]) { + if (it->failure == fail_to_find_event) + goto free_events; + printf("Can't find events %s for cpu %s\n", + parsed[i].name, + op_get_cpu_type_str(it->cpu_type)); + exit(EXIT_FAILURE); + } + } + + counter_map = map_event_to_counter(event, nr_events, it->cpu_type); + if (!counter_map) { + if (it->failure == fail_to_alloc_counter) + goto free_events; + printf("Can't map this set of events to counter:\n"); + show_events(it->events); + exit(EXIT_FAILURE); + } + + for (i = 0; i < nr_events; ++i) { + if (counter_map[i] != it->alloc_map[i]) { + printf("Incorrect allocation map for these events:\n"); + show_events(it->events); + printf("(expect, found):\n"); + show_counter_map(it->alloc_map, nr_events); + show_counter_map(counter_map, nr_events); + exit(EXIT_FAILURE); + } + } + + if (it->failure != no_failure) { + /* test should fail but success! */ + printf("test should fail with a failure type %d but succeed " + "for events:\n", it->failure); + for (i = 0; i < nr_events; ++i) + printf("%s\n", it->events[i]); + exit(EXIT_FAILURE); + } + + free(counter_map); +free_events: + op_free_events(); +} + + +int main(void) +{ + struct allocated_counter const * it; + + setenv("OPROFILE_EVENTS_DIR", OPROFILE_SRCDIR "/events", 1); + + for (it = tests; it->cpu_type != CPU_NO_GOOD; ++it) { + do_test(it); + } + return 0; +} diff --git a/libop/tests/cpu_type_tests.c b/libop/tests/cpu_type_tests.c new file mode 100644 index 0000000..2b0f6ba --- /dev/null +++ b/libop/tests/cpu_type_tests.c @@ -0,0 +1,79 @@ +/** + * @file cpu_type_tests.c + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include +#include + +#include "op_cpu_type.h" + +static struct cpu_type { + char const * name; + op_cpu type; +} cpu_str[] = { + { "i386/ppro", CPU_PPRO }, + { "i386/pii", CPU_PII }, + { "i386/piii", CPU_PIII }, + { "i386/athlon", CPU_ATHLON }, + { "timer", CPU_TIMER_INT }, + { "rtc", CPU_RTC }, + { "i386/p4", CPU_P4 }, + { "ia64/ia64", CPU_IA64 }, + { "ia64/itanium", CPU_IA64_1 }, + { "ia64/itanium2", CPU_IA64_2 }, + { "x86-64/hammer", CPU_HAMMER }, + { "i386/p4-ht", CPU_P4_HT2 }, + { "alpha/ev4", CPU_AXP_EV4 }, + { "alpha/ev5", CPU_AXP_EV5 }, + { "alpha/pca56", CPU_AXP_PCA56 }, + { "alpha/ev6", CPU_AXP_EV6 }, + { "alpha/ev67", CPU_AXP_EV67 }, + { "foo", CPU_NO_GOOD }, + { "-3", CPU_NO_GOOD }, + { "2927", CPU_NO_GOOD }, + { "", CPU_NO_GOOD }, + { NULL, CPU_NO_GOOD } +}; + + +static void test(struct cpu_type const * cpu) +{ + char const * name; + op_cpu type; + + name = op_get_cpu_name(cpu->type); + if (cpu->type != CPU_NO_GOOD && strcmp(cpu->name, name)) { + printf("for %d expect %s found %s\n", cpu->type, cpu->name, + name); + exit(EXIT_FAILURE); + } + if (cpu->type == CPU_NO_GOOD && strcmp("invalid cpu type", name)) { + printf("for %d expect %s found %s\n", cpu->type, + "invalid cpu type", name); + exit(EXIT_FAILURE); + } + + type = op_get_cpu_number(cpu->name); + if (type != cpu->type) { + printf("for %s expect %d found %d\n", cpu->name, cpu->type, + type); + exit(EXIT_FAILURE); + } +} + + +int main(void) +{ + struct cpu_type * cpu; + for (cpu = cpu_str; cpu->name; ++cpu) + test(cpu); + return 0; +} diff --git a/libop/tests/load_events_files_tests.c b/libop/tests/load_events_files_tests.c new file mode 100644 index 0000000..de548e5 --- /dev/null +++ b/libop/tests/load_events_files_tests.c @@ -0,0 +1,31 @@ +/** + * @file load_events_files_tests.c + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include + +#include "op_events.h" +#include "op_cpu_type.h" + +int main(void) +{ + op_cpu cpu_type; + + setenv("OPROFILE_EVENTS_DIR", OPROFILE_SRCDIR "/events", 1); + + for (cpu_type = CPU_NO_GOOD + 1; cpu_type < MAX_CPU_TYPE; ++cpu_type) { + if (cpu_type != CPU_TIMER_INT) { + op_events(cpu_type); + op_free_events(); + } + } + + return 0; +} diff --git a/libop/tests/mangle_tests.c b/libop/tests/mangle_tests.c new file mode 100644 index 0000000..30607bf --- /dev/null +++ b/libop/tests/mangle_tests.c @@ -0,0 +1,67 @@ +/** + * @file mangle_tests.c + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include + +#include "op_libiberty.h" +#include "op_mangle.h" +#include "op_config.h" + +struct test_input { + struct mangle_values values; + char const * result; +}; + +static struct test_input const tests[] = { + { { MANGLE_NONE, "foo", "bar", NULL, "EVENT", 0, 0, 0, 0, 0 }, + "{root}/bar/{dep}/{root}/foo/EVENT.0.0.all.all.all" }, + { { MANGLE_CPU, "foo", "bar", NULL, "EVENT", 0, 0, 0, 0, 2 }, + "{root}/bar/{dep}/{root}/foo/EVENT.0.0.all.all.2" }, + { { MANGLE_TID, "foo", "bar", NULL, "EVENT", 0, 0, 0, 33, 0 }, + "{root}/bar/{dep}/{root}/foo/EVENT.0.0.all.33.all" }, + { { MANGLE_TGID, "foo", "bar", NULL, "EVENT", 0, 0, 34, 0, 0 }, + "{root}/bar/{dep}/{root}/foo/EVENT.0.0.34.all.all" }, + { { MANGLE_KERNEL, "foo", "bar", NULL, "EVENT", 0, 0, 0, 0, 0 }, + "{kern}/bar/{dep}/{kern}/foo/EVENT.0.0.all.all.all" }, + { { MANGLE_CALLGRAPH, "foo-from", "bar-from", "foo-to", "EVENT", 0, 0, 0, 0, 0 }, + "{root}/bar-from/{dep}/{root}/foo-from/{cg}/{root}/foo-to/EVENT.0.0.all.all.all" }, + { { MANGLE_CPU|MANGLE_TID|MANGLE_TID|MANGLE_TGID|MANGLE_KERNEL, "foo", "bar", NULL, "EVENT", 1234, 8192, 34, 35, 2 }, + "{kern}/bar/{dep}/{kern}/foo/EVENT.1234.8192.34.35.2" }, + { { MANGLE_CPU|MANGLE_TID|MANGLE_TID|MANGLE_TGID|MANGLE_KERNEL, "foo1/foo2", "bar1/bar2", NULL, "EVENT", 1234, 8192, 34, 35, 2 }, + "{root}/bar1/bar2/{dep}/{root}/foo1/foo2/EVENT.1234.8192.34.35.2" }, + { { MANGLE_CALLGRAPH|MANGLE_CPU|MANGLE_TID|MANGLE_TID|MANGLE_TGID|MANGLE_KERNEL, "bar1/bar2", "bar1/bar2", "bar1/bar2-to", "EVENT", 1234, 8192, 34, 35, 2 }, + "{root}/bar1/bar2/{dep}/{root}/bar1/bar2/{cg}/{root}/bar1/bar2-to/EVENT.1234.8192.34.35.2" }, + + { { 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 }, NULL } +}; + + +int main(void) +{ + struct test_input const * test; + for (test = tests; test->result; ++test) { + char * result = op_mangle_filename(&test->values); + char * expect = xmalloc(strlen(test->result) + + strlen(OP_SAMPLES_CURRENT_DIR) + 1); + strcpy(expect, OP_SAMPLES_CURRENT_DIR); + strcat(expect, test->result); + if (strcmp(result, expect)) { + fprintf(stderr, "test %d:\nfound: %s\nexpect: %s\n", + (int)(test - tests), result, expect); + exit(EXIT_FAILURE); + } + free(expect); + free(result); + } + + return EXIT_SUCCESS; +} diff --git a/libop/tests/parse_event_tests.c b/libop/tests/parse_event_tests.c new file mode 100644 index 0000000..b1c3394 --- /dev/null +++ b/libop/tests/parse_event_tests.c @@ -0,0 +1,60 @@ +/** + * @file parse_event_tests.c + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include + +#include "op_parse_event.h" + +struct events_test { + /* second pointer is the null terminating array marker */ + char const * const tests[2]; + struct parsed_event expected; +}; + +static struct events_test const events[] = +{ + { { "FOO:3000:0:0:0", 0 }, { "FOO", 3000, 0, 0, 0 } }, + { { "BAR:3000", 0 }, { "BAR", 3000, 0, 1, 1 } }, + { { "FOOBAR:3000:1:1:1", 0 }, { "FOOBAR", 3000, 1, 1, 1 } }, + { { NULL, NULL }, { 0, 0, 0, 0, 0 } } +}; + +static void do_test(struct events_test const * ev) +{ + struct parsed_event parsed; + + parse_events(&parsed, 1, ev->tests); + + if (strcmp(ev->expected.name, parsed.name) || + ev->expected.count != parsed.count || + ev->expected.unit_mask != parsed.unit_mask || + ev->expected.kernel != parsed.kernel || + ev->expected.user != parsed.user) { + printf("for %s expect { %s, %d, %d, %d, %d } found " + "{ %s, %d, %d, %d, %d }\n", + ev->tests[0], ev->expected.name, ev->expected.count, + ev->expected.unit_mask, ev->expected.kernel, + ev->expected.user, parsed.name, parsed.count, + parsed.unit_mask, parsed.kernel, parsed.user); + exit(EXIT_FAILURE); + } +} + +int main(void) +{ + struct events_test const * ev; + for (ev = events; ev->tests[0]; ++ev) { + do_test(ev); + } + + return 0; +} diff --git a/libopt++/Makefile.am b/libopt++/Makefile.am new file mode 100644 index 0000000..f175ce7 --- /dev/null +++ b/libopt++/Makefile.am @@ -0,0 +1,5 @@ +AM_CPPFLAGS=-I ${top_srcdir}/libutil++ -I ${top_srcdir}/libutil +AM_CXXFLAGS = @OP_CXXFLAGS@ + +noinst_LIBRARIES = libopt++.a +libopt___a_SOURCES = popt_options.cpp popt_options.h diff --git a/libopt++/Makefile.in b/libopt++/Makefile.in new file mode 100644 index 0000000..d0f7a8d --- /dev/null +++ b/libopt++/Makefile.in @@ -0,0 +1,439 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(libopt___a_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = libopt++ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libopt___a_AR = $(AR) $(ARFLAGS) +libopt___a_LIBADD = +am_libopt___a_OBJECTS = popt_options.$(OBJEXT) +libopt___a_OBJECTS = $(am_libopt___a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libopt___a_SOURCES) +DIST_SOURCES = $(libopt___a_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +AM_CPPFLAGS = -I ${top_srcdir}/libutil++ -I ${top_srcdir}/libutil +AM_CXXFLAGS = @OP_CXXFLAGS@ +noinst_LIBRARIES = libopt++.a +libopt___a_SOURCES = popt_options.cpp popt_options.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libopt++/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libopt++/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libopt++.a: $(libopt___a_OBJECTS) $(libopt___a_DEPENDENCIES) + -rm -f libopt++.a + $(libopt___a_AR) libopt++.a $(libopt___a_OBJECTS) $(libopt___a_LIBADD) + $(RANLIB) libopt++.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/popt_options.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libopt++/popt_options.cpp b/libopt++/popt_options.cpp new file mode 100644 index 0000000..a960e2e --- /dev/null +++ b/libopt++/popt_options.cpp @@ -0,0 +1,321 @@ +/** + * @file popt_options.cpp + * option parsing + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include + +#include "op_popt.h" +#include "op_version.h" + +#include "popt_options.h" +#include "string_manip.h" + +using namespace std; + +namespace popt { + +/** + * option_base - base class for implementation of a command line option + * + * Every command line option added before calling parse_options() + * is of this type. + */ +class option_base { +public: + /** + * option_base - construct an option with the given options. + * @param option_name name part of long form e.g. --option + * @param short_name short form name e.g. -o + * @param help_str short description of the option + * @param arg_help_str short description of the argument (if any) + * @param data a pointer to the data to fill in + * @param popt_flags the popt library data type + */ + option_base(char const * option_name, char short_name, + char const * help_str, char const * arg_help_str, + void * data, int popt_flags); + + virtual ~option_base() {} + + /** + * post_process - perform any necessary post-processing + */ + virtual void post_process() {} + +protected: + char const * option_name; +}; + + +/** the popt array singleton options */ +static vector popt_options; +static vector options_list; + +static int showvers; + +static struct poptOption appended_options[] = { + { "version", 'v', POPT_ARG_NONE, &showvers, 0, "show version", NULL, }, + POPT_AUTOHELP + POPT_TABLEEND + }; + + +/* options parameter can't be a local variable because caller can use the + * returned poptContext which contains pointer inside the options array */ +static poptContext do_parse_options(int argc, char const ** argv, + vector & options, + vector & additional_params) +{ + options = popt_options; + + int const nr_appended_options = + sizeof(appended_options) / sizeof(appended_options[0]); + + options.insert(options.end(), appended_options, + appended_options + nr_appended_options); + + poptContext con = op_poptGetContext(NULL, argc, argv, &options[0], 0); + + if (showvers) { + show_version(argv[0]); + } + + char const * file; + while ((file = poptGetArg(con)) != 0) { + additional_params.push_back(file); + } + + for (size_t i = 0 ; i < options_list.size() ; ++i) { + options_list[i]->post_process(); + } + + return con; +} + + +void parse_options(int argc, char const ** argv, + vector & additional_params) +{ + vector options; + + poptContext con = + do_parse_options(argc, argv, options, additional_params); + + poptFreeContext(con); +} + + +template class option_imp; + + +/** + * option - a binary option + * + * Use this option type for constructing specified / not-specified + * options e.g. --frob + */ +template <> class option_imp : public option_base { +public: + option_imp(bool & value, char const * option_name, char short_name, + char const * help_str); + + ~option_imp() {} + + void post_process(); + +private: + bool & value; + int popt_value; +}; + + +/** + * option - a integer option + * + * Use this for options taking an integer e.g. --frob 6 + */ +template <> class option_imp : public option_base { +public: + option_imp(int & value, char const * option_name, char short_name, + char const * help_str, char const * arg_help_str); + + ~option_imp() {} +}; + + +/** + * option - a string option + * + * Use this for options taking a string e.g. --frob parsley + */ +template <> class option_imp : public option_base { +public: + option_imp(string & value, char const * option_name, + char short_name, char const * help_str, + char const * arg_help_str); + + void post_process(); + + ~option_imp() {} + +private: + // we need an intermediate char array to pass to popt libs + char * popt_value; + string & value; +}; + + +/** + * option< vector > - a string vector option + * + * Use this for options taking a number of string arguments, + * separated by the given separator. + */ +template <> class option_imp< vector > : public option_base { +public: + option_imp(vector & value, + char const * option_name, char short_name, + char const * help_str, char const * arg_help_str, + char separator = ','); + + void post_process(); + + ~option_imp() {} + +private: + vector & value; + // we need an intermediate char array to pass to popt libs + char * popt_value; + char const separator; +}; + + +option::~option() +{ + delete the_option; +} + + +/// non templatized ctor for boolean option +option::option(bool & value, char const * name, char short_name, char const * help) + : the_option(new option_imp(value, name, short_name, help)) +{ +} + + +/// specialization of option ctor for integer option +template <> +option::option(int & value, char const * name, char short_name, + char const * help, char const * arg_help) + : the_option(new option_imp + (value, name, short_name, help, arg_help)) +{ +} + + +/// specialization of option ctor for string option +template <> +option::option(string & value, char const * name, char short_name, + char const * help, char const * arg_help) + : the_option(new option_imp + (value, name, short_name, help, arg_help)) +{ +} + + +/// specialization of option ctor for vector option +template <> +option::option(vector & value, char const * name, char short_name, + char const * help, char const * arg_help) + : the_option(new option_imp< vector > + (value, name, short_name, help, arg_help)) +{ +} + + +option_base::option_base(char const * name, char short_name, + char const * help, char const * arg_help, + void * data, int popt_flags) + : option_name(name) +{ + poptOption const opt = { name, short_name, popt_flags, + data, 0, help, arg_help }; + + popt_options.push_back(opt); + + options_list.push_back(this); +} + + +option_imp::option_imp(bool & val, char const * name, char short_name, + char const * help) + : option_base(name, short_name, help, 0, &popt_value, POPT_ARG_NONE), + value(val), popt_value(0) +{ +} + + +void option_imp::post_process() +{ + if (popt_value) { + if (is_prefix(option_name, "no-")) + value = !popt_value; + else + value = popt_value; + } +} + + +option_imp::option_imp(int & value, char const * name, char short_name, + char const * help, char const * arg_help) + : option_base(name, short_name, help, arg_help, &value, POPT_ARG_INT) +{ +} + + +option_imp::option_imp(string & val, char const * name, char short_name, + char const * help, char const * arg_help) + : option_base(name, short_name, help, arg_help, + &popt_value, POPT_ARG_STRING), + popt_value(0), value(val) +{ +} + + +void option_imp::post_process() +{ + if (popt_value) { + value = popt_value; + popt_value = 0; + } +} + + +option_imp< vector >::option_imp(vector & val, + char const * name, char short_name, + char const * help, + char const * arg_help, char sepchar) + : option_base(name, short_name, help, arg_help, + &popt_value, POPT_ARG_STRING), + value(val), popt_value(0), separator(sepchar) +{ +} + + +void option_imp< vector >::post_process() +{ + if (popt_value) { + value = separate_token(popt_value, separator); + + popt_value = 0; + } +} + +} // namespace popt diff --git a/libopt++/popt_options.h b/libopt++/popt_options.h new file mode 100644 index 0000000..7f72aa6 --- /dev/null +++ b/libopt++/popt_options.h @@ -0,0 +1,123 @@ +/** + * @file popt_options.h + * option parsing + * + * This provides a simple facility for adding command-line + * options, and parsing them. + * + * You can add a number of options and then call parse_options() + * to process them, for example : + * + * \code + * bool allow_frob; + * string frob; + * static popt::option allow_frob_opt(allow_frob, "allow-frob", 'a', "allow frobs"); + * static popt::option frob_opt(frob, "frob", 'f', "what to frob", "name"); + * + * ... + * popt::parse_options(argc, argv, add_params); + * \endcode + * + * Note than if you try to implement an option for an unsupported type like : + * \code + * static unsigned int i; + * static popt::option i_opt(i, ....); + * \endcode + * you don't get a compile time error but a link time error. + * + * The call to parse_options() will fill in allow_frob and frob, if they + * are passed to the program (myfrobber --allow-frob --frob foo), and place + * any left over command line arguments in the add_params vector. Note + * that the template parameter denotes the type of the option argument. + * + * When the template parameter type is bool, option starting with "no-" prefix + * are implicitely considered as negated before writing the associated bool so + * this will work as expected: + * \code + * bool demangle; + * popt::option(demangle, "demangle", 'd', "demangle C++ symbols"), + * popt::option(demangle, "no-demangle", '\0', "don't demangle C++ symbols"), + * \endcode + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef POPT_OPTIONS_H +#define POPT_OPTIONS_H + +#include +#include + +namespace popt { + +/** + * parse_options - parse command line options + * @param argc like the parameter of main() + * @param argv like the parameter of main() + * @param additional_params additional options are stored here + * + * Parse the given command line with the previous + * options created. Multiple additional arguments + * that are not recognised will be added to the additional_params + * vector. + */ +void parse_options(int argc, char const ** argv, + std::vector & additional_params); + +class option_base; + +/** + * option - base class for a command line option + * + * Every command line option added before calling parse_options() + * is of this type. + */ +class option { +public: + /** + * Templatized constructor for an option. This adds the option + * to the option list on construction. This is specialized for + * each recognised option value type below. + */ + template option(T &, char const * option_name, + char short_name, char const * help_str, + char const * arg_help_str); + + /** + * boolean operations don't get the same set of parameters as other + * option, as there is no argument to give help for. + * Due to a bug in gcc 2.95 we can't use a default parameter + * in the templatized ctor above because 2.95 is unable to match + * the right ctor. So on we add a non-templatized ctor with an exact + * match for boolean option. + */ + option(bool &, char const * option_name, + char short_name, char const * help_str); + + ~option(); + +private: + option_base * the_option; +}; + + +/** + * The supported option type, boolean option are matched by a non templatized + * ctor above. + */ +template <> option::option(int &, char const * option_name, char short_name, + char const * help_str, char const * arg_help_str); +template <> option::option(std::string &, char const * option_name, + char short_name, char const * help_str, + char const * arg_help_str); +template <> option::option(std::vector &, + char const * option_name, char short_name, + char const * help_str, char const * arg_help_str); + +} // namespace popt + +#endif // POPT_OPTIONS_H diff --git a/libpp/Makefile.am b/libpp/Makefile.am new file mode 100644 index 0000000..07a7fdd --- /dev/null +++ b/libpp/Makefile.am @@ -0,0 +1,52 @@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libdb \ + -I ${top_srcdir}/libopt++ \ + -I ${top_srcdir}/libutil++ \ + -I ${top_srcdir}/libop++ \ + -I ${top_srcdir}/libregex + +AM_CXXFLAGS = @OP_CXXFLAGS@ + +noinst_LIBRARIES = libpp.a +libpp_a_SOURCES = \ + arrange_profiles.cpp \ + arrange_profiles.h \ + callgraph_container.h \ + callgraph_container.cpp \ + diff_container.cpp \ + diff_container.h \ + filename_spec.cpp \ + filename_spec.h \ + format_flags.h \ + format_output.cpp \ + format_output.h \ + image_errors.h \ + image_errors.cpp \ + locate_images.cpp \ + locate_images.h \ + name_storage.cpp \ + name_storage.h \ + op_header.cpp \ + op_header.h \ + symbol.cpp \ + symbol.h \ + parse_filename.cpp \ + parse_filename.h \ + populate.h \ + populate.cpp \ + profile.cpp \ + profile.h \ + profile_container.cpp \ + profile_container.h \ + profile_spec.cpp \ + profile_spec.h \ + sample_container.cpp \ + sample_container.h \ + symbol_container.cpp \ + symbol_container.h \ + symbol_functors.cpp \ + symbol_functors.h \ + symbol_sort.cpp \ + symbol_sort.h diff --git a/libpp/Makefile.in b/libpp/Makefile.in new file mode 100644 index 0000000..ffbb3cf --- /dev/null +++ b/libpp/Makefile.in @@ -0,0 +1,513 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(libpp_a_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = libpp +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libpp_a_AR = $(AR) $(ARFLAGS) +libpp_a_LIBADD = +am_libpp_a_OBJECTS = arrange_profiles.$(OBJEXT) \ + callgraph_container.$(OBJEXT) diff_container.$(OBJEXT) \ + filename_spec.$(OBJEXT) format_output.$(OBJEXT) \ + image_errors.$(OBJEXT) locate_images.$(OBJEXT) \ + name_storage.$(OBJEXT) op_header.$(OBJEXT) symbol.$(OBJEXT) \ + parse_filename.$(OBJEXT) populate.$(OBJEXT) profile.$(OBJEXT) \ + profile_container.$(OBJEXT) profile_spec.$(OBJEXT) \ + sample_container.$(OBJEXT) symbol_container.$(OBJEXT) \ + symbol_functors.$(OBJEXT) symbol_sort.$(OBJEXT) +libpp_a_OBJECTS = $(am_libpp_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libpp_a_SOURCES) +DIST_SOURCES = $(libpp_a_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libdb \ + -I ${top_srcdir}/libopt++ \ + -I ${top_srcdir}/libutil++ \ + -I ${top_srcdir}/libop++ \ + -I ${top_srcdir}/libregex + +AM_CXXFLAGS = @OP_CXXFLAGS@ +noinst_LIBRARIES = libpp.a +libpp_a_SOURCES = \ + arrange_profiles.cpp \ + arrange_profiles.h \ + callgraph_container.h \ + callgraph_container.cpp \ + diff_container.cpp \ + diff_container.h \ + filename_spec.cpp \ + filename_spec.h \ + format_flags.h \ + format_output.cpp \ + format_output.h \ + image_errors.h \ + image_errors.cpp \ + locate_images.cpp \ + locate_images.h \ + name_storage.cpp \ + name_storage.h \ + op_header.cpp \ + op_header.h \ + symbol.cpp \ + symbol.h \ + parse_filename.cpp \ + parse_filename.h \ + populate.h \ + populate.cpp \ + profile.cpp \ + profile.h \ + profile_container.cpp \ + profile_container.h \ + profile_spec.cpp \ + profile_spec.h \ + sample_container.cpp \ + sample_container.h \ + symbol_container.cpp \ + symbol_container.h \ + symbol_functors.cpp \ + symbol_functors.h \ + symbol_sort.cpp \ + symbol_sort.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libpp/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libpp/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libpp.a: $(libpp_a_OBJECTS) $(libpp_a_DEPENDENCIES) + -rm -f libpp.a + $(libpp_a_AR) libpp.a $(libpp_a_OBJECTS) $(libpp_a_LIBADD) + $(RANLIB) libpp.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arrange_profiles.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/callgraph_container.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diff_container.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filename_spec.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format_output.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/image_errors.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/locate_images.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/name_storage.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_header.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_filename.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/populate.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/profile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/profile_container.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/profile_spec.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sample_container.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symbol_container.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symbol_functors.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symbol_sort.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libpp/arrange_profiles.cpp b/libpp/arrange_profiles.cpp new file mode 100644 index 0000000..4b21eb6 --- /dev/null +++ b/libpp/arrange_profiles.cpp @@ -0,0 +1,776 @@ +/** + * @file arrange_profiles.cpp + * Classify and process a list of candidate sample files + * into merged sets and classes. + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#include +#include +#include +#include +#include +#include + +#include "string_manip.h" +#include "op_header.h" +#include "op_exception.h" + +#include "arrange_profiles.h" +#include "parse_filename.h" +#include "locate_images.h" + +using namespace std; + +namespace { + +int numeric_compare(string const & lhs, string const & rhs) +{ + if (lhs == "all" && rhs == "all") + return 0; + // we choose an order arbitrarily + if (lhs == "all") + return 1; + if (rhs == "all") + return -1; + unsigned int lhsval = op_lexical_cast(lhs); + unsigned int rhsval = op_lexical_cast(rhs); + if (lhsval == rhsval) + return 0; + if (lhsval < rhsval) + return -1; + return 1; +} + +} // anonymous namespace + + +// global to fix some C++ obscure corner case. +bool operator<(profile_class const & lhs, + profile_class const & rhs) +{ + profile_template const & lt = lhs.ptemplate; + profile_template const & rt = rhs.ptemplate; + + int comp = numeric_compare(lt.cpu, rt.cpu); + if (comp) + return comp < 0; + + comp = numeric_compare(lt.tgid, rt.tgid); + if (comp) + return comp < 0; + + comp = numeric_compare(lt.tid, rt.tid); + if (comp) + return comp < 0; + + comp = numeric_compare(lt.unitmask, rt.unitmask); + if (comp) + return comp < 0; + + if (lt.event == rt.event) + return lt.count < rt.count; + return lt.event < rt.event; +} + +namespace { + +struct axis_t { + string name; + string suggestion; +} axes[AXIS_MAX] = { + { "event", "specify event:, count: or unitmask: (see also --merge=unitmask)" }, + { "tgid", "specify tgid: or --merge tgid" }, + { "tid", "specify tid: or --merge tid" }, + { "cpu", "specify cpu: or --merge cpu" }, +}; + + +bool profile_classes::matches(profile_classes const & classes) +{ + if (v.size() != classes.v.size()) + return false; + + axis_types const axis2 = classes.axis; + + switch (axis) { + case AXIS_EVENT: + break; + case AXIS_TGID: + case AXIS_TID: + return axis2 == AXIS_TID || axis2 == AXIS_TGID; + case AXIS_CPU: + return axis2 == AXIS_CPU; + case AXIS_MAX: + return false; + } + + // check that the events match (same event, count) + + vector::const_iterator it1 = v.begin(); + vector::const_iterator end1 = v.end(); + vector::const_iterator it2 = classes.v.begin(); + + while (it1 != end1) { + if (it1->ptemplate.event != it2->ptemplate.event) + return false; + if (it1->ptemplate.count != it2->ptemplate.count) + return false; + // differing unit mask is considered comparable + ++it1; + ++it2; + } + + return true; +} + + +/// We have more than one axis of classification, tell the user. +void report_error(profile_classes const & classes, axis_types newaxis) +{ + string str = "Already displaying results for parameter "; + str += axes[classes.axis].name; + str += " with values:\n"; + vector::const_iterator it = classes.v.begin(); + vector::const_iterator const end = classes.v.end(); + + // We show error for the first conflicting axis but on this + // axis we can get only a few different it->name, we display only + // these different name. + set name_seen; + size_t i = 5; + for (; it != end && i; ++it) { + if (name_seen.find(it->name) == name_seen.end()) { + name_seen.insert(it->name); + str += it->name + ","; + --i; + } + } + + if (!i) { + str += " and "; + str += op_lexical_cast(classes.v.size() - 5); + str += " more,"; + } + + str += "\nwhich conflicts with parameter "; + str += axes[newaxis].name += ".\n"; + str += "Suggestion: "; + str += axes[classes.axis].suggestion; + throw op_fatal_error(str); +} + + +/** + * check that two different axes are OK - this is only + * allowed if they are TGID,TID and for each class, + * tid == tgid + */ +bool allow_axes(profile_classes const & classes, axis_types newaxis) +{ + // No previous axis - OK + if (classes.axis == AXIS_MAX) + return true; + + if (classes.axis != AXIS_TID && classes.axis != AXIS_TGID) + return false; + + if (newaxis != AXIS_TID && newaxis != AXIS_TGID) + return false; + + vector::const_iterator it = classes.v.begin(); + vector::const_iterator const end = classes.v.end(); + + for (; it != end; ++it) { + if (it->ptemplate.tgid != it->ptemplate.tid) + return false; + } + + return true; +} + + +/// find the first sample file header in the class +opd_header const get_first_header(profile_class const & pclass) +{ + profile_set const & profile = *(pclass.profiles.begin()); + + string file; + + // could be only one main app, with no samples for the main image + if (profile.files.empty()) { + profile_dep_set const & dep = *(profile.deps.begin()); + list const & files = dep.files; + profile_sample_files const & sample_files = *(files.begin()); + if (!sample_files.sample_filename.empty()) + file = sample_files.sample_filename; + else + file = *sample_files.cg_files.begin(); + } else { + profile_sample_files const & sample_files + = *(profile.files.begin()); + if (!sample_files.sample_filename.empty()) + file = sample_files.sample_filename; + else + file = *sample_files.cg_files.begin(); + } + + return read_header(file); +} + +/// merge sample file header in the profile_sample_files +void merge_header(profile_sample_files const & files, opd_header & header) +{ + if (!files.sample_filename.empty()) { + opd_header const temp = read_header(files.sample_filename); + header.ctr_um |= temp.ctr_um; + } + + list::const_iterator it = files.cg_files.begin(); + list::const_iterator const end = files.cg_files.end(); + for ( ; it != end; ++it) { + opd_header const temp = read_header(*it); + header.ctr_um |= temp.ctr_um; + } +} + +/// merge sample file header in the class +opd_header const get_header(profile_class const & pclass, + merge_option const & merge_by) +{ + opd_header header = get_first_header(pclass); + + if (!merge_by.unitmask) + return header; + + profile_set const & profile = *(pclass.profiles.begin()); + + typedef list::const_iterator citerator; + + citerator it = profile.files.begin(); + citerator const end = profile.files.end(); + for ( ; it != end; ++it) { + merge_header(*it, header); + } + + list::const_iterator dep_it = profile.deps.begin(); + list::const_iterator dep_end = profile.deps.end(); + for ( ; dep_it != dep_end; ++dep_it) { + citerator it = dep_it->files.begin(); + citerator const end = dep_it->files.end(); + for ( ; it != end; ++it) { + merge_header(*it, header); + } + } + + return header; +} + + +/// Give human-readable names to each class. +void name_classes(profile_classes & classes, merge_option const & merge_by) +{ + opd_header header = get_header(classes.v[0], merge_by); + + classes.event = describe_header(header); + classes.cpuinfo = describe_cpu(header); + + // If we're splitting on event anyway, clear out the + // global event name + if (classes.axis == AXIS_EVENT) + classes.event.erase(); + + vector::iterator it = classes.v.begin(); + vector::iterator const end = classes.v.end(); + + for (; it != end; ++it) { + it->name = axes[classes.axis].name + ":"; + switch (classes.axis) { + case AXIS_EVENT: + it->name = it->ptemplate.event + + ":" + it->ptemplate.count; + header = get_header(*it, merge_by); + it->longname = describe_header(header); + break; + case AXIS_TGID: + it->name += it->ptemplate.tgid; + it->longname = "Processes with a thread group ID of "; + it->longname += it->ptemplate.tgid; + break; + case AXIS_TID: + it->name += it->ptemplate.tid; + it->longname = "Processes with a thread ID of "; + it->longname += it->ptemplate.tid; + break; + case AXIS_CPU: + it->name += it->ptemplate.cpu; + it->longname = "Samples on CPU " + it->ptemplate.cpu; + break; + case AXIS_MAX:; + } + } +} + + +/** + * Name and verify classes. + */ +void identify_classes(profile_classes & classes, + merge_option const & merge_by) +{ + profile_template & ptemplate = classes.v[0].ptemplate; + bool changed[AXIS_MAX] = { false, }; + + vector::iterator it = classes.v.begin(); + ++it; + vector::iterator end = classes.v.end(); + + // only one class, name it after the event + if (it == end) { + changed[AXIS_EVENT] = true; + } + + for (; it != end; ++it) { + if (it->ptemplate.event != ptemplate.event + || it->ptemplate.count != ptemplate.count + // unit mask are mergeable + || (!merge_by.unitmask + && it->ptemplate.unitmask != ptemplate.unitmask)) + changed[AXIS_EVENT] = true; + + // we need the merge checks here because each + // template is filled in from the first non + // matching profile, so just because they differ + // doesn't mean it's the axis we care about + if (!merge_by.tgid && it->ptemplate.tgid != ptemplate.tgid) + changed[AXIS_TGID] = true; + + if (!merge_by.tid && it->ptemplate.tid != ptemplate.tid) + changed[AXIS_TID] = true; + + if (!merge_by.cpu && it->ptemplate.cpu != ptemplate.cpu) + changed[AXIS_CPU] = true; + } + + classes.axis = AXIS_MAX; + + for (size_t i = 0; i < AXIS_MAX; ++i) { + if (!changed[i]) + continue; + + if (!allow_axes(classes, axis_types(i))) + report_error(classes, axis_types(i)); + classes.axis = axis_types(i); + /* do this early for report_error */ + name_classes(classes, merge_by); + } + + if (classes.axis == AXIS_MAX) { + cerr << "Internal error - no equivalence class axis" << endl; + abort(); + } +} + + +/// construct a class template from a profile +profile_template const +template_from_profile(parsed_filename const & parsed, + merge_option const & merge_by) +{ + profile_template ptemplate; + + ptemplate.event = parsed.event; + ptemplate.count = parsed.count; + + if (!merge_by.unitmask) + ptemplate.unitmask = parsed.unitmask; + if (!merge_by.tgid) + ptemplate.tgid = parsed.tgid; + if (!merge_by.tid) + ptemplate.tid = parsed.tid; + if (!merge_by.cpu) + ptemplate.cpu = parsed.cpu; + return ptemplate; +} + + +/** + * Find a matching class the sample file could go in, or generate + * a new class if needed. + * This is the heart of the merging and classification process. + * The returned value is non-const reference but the ptemplate member + * must be considered as const + */ +profile_class & find_class(set & classes, + parsed_filename const & parsed, + merge_option const & merge_by) +{ + profile_class cls; + cls.ptemplate = template_from_profile(parsed, merge_by); + + pair::iterator, bool> ret = classes.insert(cls); + + return const_cast(*ret.first); +} + +/** + * Sanity check : we can't overwrite sample_filename, if we abort here it means + * we fail to detect that parsed sample filename for two distinct samples + * filename must go in two distinct profile_sample_files. This assumption is + * false for callgraph samples files so this function is only called for non cg + * files. + */ +void sanitize_profile_sample_files(profile_sample_files const & sample_files, + parsed_filename const & parsed) +{ + // We can't allow to overwrite sample_filename. + if (!sample_files.sample_filename.empty()) { + ostringstream out; + out << "sanitize_profile_sample_files(): sample file " + << "parsed twice ?\nsample_filename:\n" + << sample_files.sample_filename << endl + << parsed << endl; + throw op_fatal_error(out.str()); + } +} + + +/** + * Add a sample filename (either cg or non cg files) to this profile. + */ +void +add_to_profile_sample_files(profile_sample_files & sample_files, + parsed_filename const & parsed) +{ + if (parsed.cg_image.empty()) { + // We can't allow to overwrite sample_filename. + sanitize_profile_sample_files(sample_files, parsed); + + sample_files.sample_filename = parsed.filename; + } else { + sample_files.cg_files.push_back(parsed.filename); + } +} + + +/** + * we need to fix cg filename: a callgraph filename can occur before the binary + * non callgraph samples filename occur so we must search. + */ +profile_sample_files & +find_profile_sample_files(list & files, + parsed_filename const & parsed) +{ + list::iterator it; + list::iterator const end = files.end(); + for (it = files.begin(); it != end; ++it) { + if (!it->sample_filename.empty()) { + parsed_filename psample_filename = + parse_filename(it->sample_filename); + if (psample_filename.lib_image == parsed.lib_image && + psample_filename.image == parsed.image && + psample_filename.profile_spec_equal(parsed)) + return *it; + } + + list::const_iterator cit; + list::const_iterator const cend = it->cg_files.end(); + for (cit = it->cg_files.begin(); cit != cend; ++cit) { + parsed_filename pcg_filename = parse_filename(*cit); + if (pcg_filename.lib_image == parsed.lib_image && + pcg_filename.image == parsed.image && + pcg_filename.profile_spec_equal(parsed)) + return *it; + } + } + + // not found, create a new one + files.push_back(profile_sample_files()); + return files.back(); +} + + +/** + * Add a profile to particular profile set. If the new profile is + * a dependent image, it gets added to the dep list, or just placed + * on the normal list of profiles otherwise. + */ +void +add_to_profile_set(profile_set & set, parsed_filename const & parsed, bool merge_by_lib) +{ + if (parsed.image == parsed.lib_image && !merge_by_lib) { + profile_sample_files & sample_files = + find_profile_sample_files(set.files, parsed); + add_to_profile_sample_files(sample_files, parsed); + return; + } + + list::iterator it = set.deps.begin(); + list::iterator const end = set.deps.end(); + + for (; it != end; ++it) { + if (it->lib_image == parsed.lib_image && !merge_by_lib) { + profile_sample_files & sample_files = + find_profile_sample_files(it->files, parsed); + add_to_profile_sample_files(sample_files, parsed); + return; + } + } + + profile_dep_set depset; + depset.lib_image = parsed.lib_image; + profile_sample_files & sample_files = + find_profile_sample_files(depset.files, parsed); + add_to_profile_sample_files(sample_files, parsed); + set.deps.push_back(depset); +} + + +/** + * Add a profile to a particular equivalence class. The previous matching + * will have ensured the profile "fits", so now it's just a matter of + * finding which sample file list it needs to go on. + */ +void add_profile(profile_class & pclass, parsed_filename const & parsed, bool merge_by_lib) +{ + list::iterator it = pclass.profiles.begin(); + list::iterator const end = pclass.profiles.end(); + + for (; it != end; ++it) { + if (it->image == parsed.image) { + add_to_profile_set(*it, parsed, merge_by_lib); + return; + } + } + + profile_set set; + set.image = parsed.image; + add_to_profile_set(set, parsed, merge_by_lib); + pclass.profiles.push_back(set); +} + +} // anon namespace + + +profile_classes const +arrange_profiles(list const & files, merge_option const & merge_by) +{ + set temp_classes; + + list::const_iterator it = files.begin(); + list::const_iterator const end = files.end(); + + for (; it != end; ++it) { + parsed_filename parsed = parse_filename(*it); + + if (parsed.lib_image.empty()) + parsed.lib_image = parsed.image; + + // This simplifies the add of the profile later, + // if we're lib-merging, then the app_image cannot + // matter. After this, any non-dependent has + // image == lib_image + if (merge_by.lib) + parsed.image = parsed.lib_image; + + profile_class & pclass = + find_class(temp_classes, parsed, merge_by); + add_profile(pclass, parsed, merge_by.lib); + } + + profile_classes classes; + copy(temp_classes.begin(), temp_classes.end(), + back_inserter(classes.v)); + + if (classes.v.empty()) + return classes; + + // sort by template for nicely ordered columns + stable_sort(classes.v.begin(), classes.v.end()); + + // name and check + identify_classes(classes, merge_by); + + return classes; +} + + +ostream & operator<<(ostream & out, profile_sample_files const & sample_files) +{ + out << "sample_filename: " << sample_files.sample_filename << endl; + out << "callgraph filenames:\n"; + copy(sample_files.cg_files.begin(), sample_files.cg_files.end(), + ostream_iterator(out, "\n")); + return out; +} + +ostream & operator<<(ostream & out, profile_dep_set const & pdep_set) +{ + out << "lib_image: " << pdep_set.lib_image << endl; + + list::const_iterator it; + list::const_iterator const end = + pdep_set.files.end(); + size_t i = 0; + for (it = pdep_set.files.begin(); it != end; ++it) + out << "profile_sample_files #" << i++ << ":\n" << *it; + + return out; +} + +ostream & operator<<(ostream & out, profile_set const & pset) +{ + out << "image: " << pset.image << endl; + + list::const_iterator it; + list::const_iterator const end = + pset.files.end(); + size_t i = 0; + for (it = pset.files.begin(); it != end; ++it) + out << "profile_sample_files #" << i++ << ":\n" << *it; + + list::const_iterator cit; + list::const_iterator const cend = pset.deps.end(); + i = 0; + for (cit = pset.deps.begin(); cit != cend; ++cit) + out << "profile_dep_set #" << i++ << ":\n" << *cit; + + return out; +} + +ostream & operator<<(ostream & out, profile_template const & ptemplate) +{ + out << "event: " << ptemplate.event << endl + << "count: " << ptemplate.count << endl + << "unitmask: " << ptemplate.unitmask << endl + << "tgid: " << ptemplate.tgid << endl + << "tid: " << ptemplate.tid << endl + << "cpu: " << ptemplate.cpu << endl; + return out; +} + +ostream & operator<<(ostream & out, profile_class const & pclass) +{ + out << "name: " << pclass.name << endl + << "longname: " << pclass.longname << endl + << "ptemplate:\n" << pclass.ptemplate; + + size_t i = 0; + list::const_iterator it; + list::const_iterator const end = pclass.profiles.end(); + for (it = pclass.profiles.begin(); it != end; ++it) + out << "profiles_set #" << i++ << ":\n" << *it; + + return out; +} + +ostream & operator<<(ostream & out, profile_classes const & pclasses) +{ + out << "event: " << pclasses.event << endl + << "cpuinfo: " << pclasses.cpuinfo << endl; + + for (size_t i = 0; i < pclasses.v.size(); ++i) + out << "class #" << i << ":\n" << pclasses.v[i]; + + return out; +} + + +namespace { + +/// add the files to group of image sets +void add_to_group(image_group_set & group, string const & app_image, + list const & files) +{ + image_set set; + set.app_image = app_image; + set.files = files; + group.push_back(set); +} + + +typedef map app_map_t; + + +inverted_profile & +get_iprofile(app_map_t & app_map, string const & image, size_t nr_classes) +{ + app_map_t::iterator ait = app_map.find(image); + if (ait != app_map.end()) + return ait->second; + + inverted_profile ip; + ip.image = image; + ip.groups.resize(nr_classes); + app_map[image] = ip; + return app_map[image]; +} + + +/// Pull out all the images, removing any we can't access. +void +verify_and_fill(string archive_path, app_map_t & app_map, + list & plist, extra_images const & extra) +{ + app_map_t::iterator it = app_map.begin(); + app_map_t::iterator const end = app_map.end(); + + for (; it != end; ++it) { + plist.push_back(it->second); + inverted_profile & ip = plist.back(); + ip.image = find_image_path(archive_path, ip.image, extra, + ip.error); + } +} + +} // anon namespace + + +list const +invert_profiles(string archive_path, profile_classes const & classes, + extra_images const & extra) +{ + app_map_t app_map; + + size_t nr_classes = classes.v.size(); + + for (size_t i = 0; i < nr_classes; ++i) { + list::const_iterator pit + = classes.v[i].profiles.begin(); + list::const_iterator pend + = classes.v[i].profiles.end(); + + for (; pit != pend; ++pit) { + // files can be empty if samples for a lib image + // but none for the main image. Deal with it here + // rather than later. + if (pit->files.size()) { + inverted_profile & ip = get_iprofile(app_map, + pit->image, nr_classes); + add_to_group(ip.groups[i], pit->image, pit->files); + } + + list::const_iterator dit + = pit->deps.begin(); + list::const_iterator const dend + = pit->deps.end(); + + for (; dit != dend; ++dit) { + inverted_profile & ip = get_iprofile(app_map, + dit->lib_image, nr_classes); + add_to_group(ip.groups[i], pit->image, + dit->files); + } + } + } + + list inverted_list; + + verify_and_fill(archive_path, app_map, inverted_list, extra); + + return inverted_list; +} diff --git a/libpp/arrange_profiles.h b/libpp/arrange_profiles.h new file mode 100644 index 0000000..3f71305 --- /dev/null +++ b/libpp/arrange_profiles.h @@ -0,0 +1,245 @@ +/** + * @file arrange_profiles.h + * Classify and process a list of candidate sample files + * into merged sets and classes. + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#ifndef ARRANGE_PROFILES_H +#define ARRANGE_PROFILES_H + +#include +#include +#include +#include + +#include "image_errors.h" + +/** + * store merging options options used to classify profiles + */ +struct merge_option { + bool cpu; + bool lib; + bool tid; + bool tgid; + bool unitmask; +}; + + +/** + * This describes which parameters are set for each + * equivalence class. + */ +struct profile_template { + std::string event; + std::string count; + std::string unitmask; + std::string tgid; + std::string tid; + std::string cpu; +}; + + +/** + * A samples filename + its associated callgraph sample filename. + */ +struct profile_sample_files { + /** + * This member can be empty since it is possible to get callgraph + * w/o any samples to the binary. e.g an application which defer all + * works to shared library but if arrange_profiles receive a sample + * file list filtered from cg file sample_filename can't be empty + */ + std::string sample_filename; + /** + * List of callgraph sample filename. If the {dep} part of + * cg_filename != {cg} part it's a cross binary samples file. + */ + std::list cg_files; +}; + + +/** + * A number of profiles files that are all dependent on + * the same main (application) profile, for the same + * dependent image. + */ +struct profile_dep_set { + /// which dependent image is this set for + std::string lib_image; + + /// the actual sample files optionnaly including callgraph sample files + std::list files; +}; + +/** + * A number of profile files all for the same binary with the same + * profile specification (after merging). Includes the set of dependent + * profile files, if any. + * + * For example, we could have image == "/bin/bash", where files + * contains all profiles against /bin/bash, and deps contains + * the sample file list for /lib/libc.so, /lib/ld.so etc. + */ +struct profile_set { + std::string image; + + /// the actual sample files for the main image and the asociated + /// callgraph files + std::list files; + + /// all profile files dependent on the main image + std::list deps; +}; + + +/** + * A class collection of profiles. This is an equivalence class and + * will correspond to columnar output of opreport. + */ +struct profile_class { + std::list profiles; + + /// human-readable column name + std::string name; + + /// human-readable long name + std::string longname; + + /// merging matches against this + profile_template ptemplate; +}; + + +/** + * The "axis" says what we've used to split the sample + * files into the classes. Only one is allowed. + */ +enum axis_types { + AXIS_EVENT, + AXIS_TGID, + AXIS_TID, + AXIS_CPU, + AXIS_MAX +}; + + +struct profile_classes { + /** + * This is only set if we're not classifying on event/count + * anyway - if we're classifying on event/count, then we'll + * already output the details of each class's event/count. + * + * It's only used when classifying by CPU, tgid etc. so the + * user can still see what perfctr event was used. + */ + std::string event; + + /// CPU info + std::string cpuinfo; + + /// the actual classes + std::vector v; + + /// the axis of the classes + axis_types axis; + + /// is this class set comparable with another? + bool matches(profile_classes const & classes); +}; + + +std::ostream & operator<<(std::ostream &, profile_sample_files const &); +std::ostream & operator<<(std::ostream &, profile_dep_set const &); +std::ostream & operator<<(std::ostream &, profile_set const &); +std::ostream & operator<<(std::ostream &, profile_template const &); +std::ostream & operator<<(std::ostream &, profile_class const &); +std::ostream & operator<<(std::ostream &, profile_classes const &); + + +/** + * Take a list of sample filenames, and process them into a set of + * classes containing profile_sets. Merging is done at this stage + * as well as attaching dependent profiles to the main image. + * + * The classes correspond to the columns you'll get in opreport: + * this can be a number of events, or different CPUs, etc. + */ +profile_classes const +arrange_profiles(std::list const & files, + merge_option const & merge_by); + + +/** + * A set of sample files where the image binary to open + * are all the same. + */ +struct image_set { + /// this is main app image, *not* necessarily + /// the one we need to open + std::string app_image; + + /// the sample files + std::list files; +}; + +typedef std::list image_group_set; + +/** + * All sample files where the binary image to open is + * the same. + * + * This is the "inverse" to some degree of profile_set. + * For example, here we might have image = "/lib/libc.so", + * with groups being the profile classifications + * tgid:404, tgid:301, etc. + * + * Within each group there's a number of image_sets. + * All the sample files listed within the image_sets + * are still for /lib/libc.so, but they may have + * different app_image values, e.g. /bin/bash. + * We need to keep track of the app_image values to + * make opreport give the right info in the "app" + * column. + */ +struct inverted_profile { + inverted_profile() : error(image_ok) {} + /// the image to open + std::string image; + + /// an error found in reading the image + mutable image_error error; + + /// all sample files with data for the above image + std::vector groups; +}; + + +class extra_images; + +/** + * Invert the profile set. For opreport -l, opannotate etc., + * processing the profile_classes directly is slow, because + * we end up opening BFDs multiple times (for each class, + * dependent images etc.). This function returns an inverted + * set of sample files, where the primary sort is on the binary + * image to open. + * + * Thus each element in the returned list is for exactly one + * binary file that we're going to bfd_openr(). Attached to that + * is the actual sample files we need to process for that binary + * file. In order to get the output right, these have to be + * marked with the profile class they're from (hence the groups + * vector), and the app image that owned the sample file, if + * applicable (hence image_set). + */ +std::list const +invert_profiles(std::string archive_path, profile_classes const & classes, + extra_images const & extra); + +#endif /* !ARRANGE_PROFILES_H */ diff --git a/libpp/callgraph_container.cpp b/libpp/callgraph_container.cpp new file mode 100644 index 0000000..b9b1a49 --- /dev/null +++ b/libpp/callgraph_container.cpp @@ -0,0 +1,604 @@ +/** + * @file callgraph_container.cpp + * Container associating symbols and caller/caller symbols + * + * @remark Copyright 2004 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "callgraph_container.h" +#include "cverb.h" +#include "parse_filename.h" +#include "profile_container.h" +#include "arrange_profiles.h" +#include "populate.h" +#include "string_filter.h" +#include "op_bfd.h" +#include "op_sample_file.h" +#include "locate_images.h" + +using namespace std; + +namespace { + +bool operator==(cg_symbol const & lhs, cg_symbol const & rhs) +{ + less_symbol cmp_symb; + return !cmp_symb(lhs, rhs) && !cmp_symb(rhs, lhs); +} + + +// we store {caller,callee} inside a single u64 +odb_key_t caller_to_key(u32 value) +{ + return odb_key_t(value) << 32; +} + + +u32 key_to_callee(odb_key_t key) +{ + return key & 0xffffffff; +} + + +bool compare_by_callee_vma(pair const & lhs, + pair const & rhs) +{ + return (key_to_callee(lhs.first)) < (key_to_callee(rhs.first)); +} + + +/* + * We need 2 comparators for callgraph to get the desired output: + * + * caller_with_few_samples + * caller_with_many_samples + * function_with_many_samples + * callee_with_many_samples + * callee_with_few_samples + */ + +bool +compare_arc_count(symbol_entry const & lhs, symbol_entry const & rhs) +{ + return lhs.sample.counts[0] < rhs.sample.counts[0]; +} + + +bool +compare_arc_count_reverse(symbol_entry const & lhs, symbol_entry const & rhs) +{ + return rhs.sample.counts[0] < lhs.sample.counts[0]; +} + + +// find the nearest bfd symbol for the given file offset and check it's +// in range +op_bfd_symbol const * +get_symbol_by_filepos(op_bfd const & bfd, u32 bfd_offset, + vma_t offset, symbol_index_t & i) +{ + offset += bfd_offset; + op_bfd_symbol tmpsym(offset, 0, string()); + + // sorted by filepos so this will find the nearest + vector::const_iterator it = + upper_bound(bfd.syms.begin(), bfd.syms.end(), tmpsym); + + if (it != bfd.syms.begin()) + --it; + + if (it == bfd.syms.end()) { + cerr << "get_symbol_by_filepos: no symbols at all?" << endl; + abort(); + } + + // if the offset is past the end of the symbol, we didn't find one + u32 const end_offset = it->size() + it->filepos(); + + if (offset >= end_offset) { + // let's be verbose for now + cerr << "warning: dropping hyperspace sample at offset " + << hex << offset << " >= " << end_offset + << " for binary " << bfd.get_filename() << dec << endl; + return NULL; + } + + i = distance(bfd.syms.begin(), it); + return &(*it); +} + + +/// temporary caller and callee data held during processing +class call_data { +public: + call_data(profile_container const & p, profile_t const & pr, + op_bfd const & bfd, u32 boff, image_name_id iid, + image_name_id aid, bool debug_info) + : pc(p), profile(pr), b(bfd), boffset(boff), image(iid), + app(aid), debug(debug_info) {} + + /// point to a caller symbol + void caller_sym(symbol_index_t i) { + sym = symbol_entry(); + + unsigned long start; + unsigned long end; + b.get_symbol_range(i, start, end); + + samples.clear(); + + // see profile_t::samples_range() for why we need this check + if (start > boffset) { + profile_t::iterator_pair p_it = profile.samples_range( + caller_to_key(start - boffset), + caller_to_key(end - boffset)); + + // Our odb_key_t contain (from_eip << 32 | to_eip), + // the range of keys we selected above contains one + // caller but different callees, and due to the + // ordering callee offsets are not consecutive: so + // we must sort them first. + + for (; p_it.first != p_it.second; ++p_it.first) { + samples.push_back(make_pair(p_it.first.vma(), + p_it.first.count())); + } + + sort(samples.begin(), samples.end(), + compare_by_callee_vma); + } + + sym.size = end - start; + sym.name = symbol_names.create(b.syms[i].name()); + sym.sample.vma = b.sym_offset(i, start) + b.syms[i].vma(); + + finish_sym(i, start); + + if (cverb << vdebug) { + cverb << vdebug << hex << "Caller sym: " + << b.syms[i].name() << " filepos " << start + << "-" << end << dec << endl; + } + } + + /// point to a callee symbol + bool callee_sym(u32 off) { + sym = symbol_entry(); + + symbol_index_t i; + op_bfd_symbol const * bfdsym = + get_symbol_by_filepos(b, boffset, off, i); + + if (!bfdsym) + return false; + + callee_end = bfdsym->size() + bfdsym->filepos() - boffset; + + sym.size = bfdsym->size(); + sym.name = symbol_names.create(bfdsym->name()); + sym.sample.vma = bfdsym->vma(); + + finish_sym(i, bfdsym->filepos()); + + if (cverb << vdebug) { + cverb << vdebug << hex << "Callee sym: " + << bfdsym->name() << " filepos " + << bfdsym->filepos() << "-" + << (bfdsym->filepos() + bfdsym->size()) + << dec << endl; + } + return true; + } + + void verbose_bfd(string const & prefix) const { + cverb << vdebug << prefix << " " << b.get_filename() + << " offset " << boffset << " app " + << image_names.name(app) << endl; + } + + typedef vector > samples_t; + + typedef samples_t::const_iterator const_iterator; + + samples_t samples; + symbol_entry sym; + u32 callee_end; + +private: + /// fill in the rest of the sym + void finish_sym(symbol_index_t i, unsigned long start) { + sym.image_name = image; + sym.app_name = app; + symbol_entry const * self = pc.find(sym); + if (self) + sym.sample.counts = self->sample.counts; + + if (debug) { + string filename; + file_location & loc = sym.sample.file_loc; + if (b.get_linenr(i, start, filename, loc.linenr)) + loc.filename = debug_names.create(filename); + } + } + + profile_container const & pc; + profile_t const & profile; + op_bfd const & b; + u32 boffset; + image_name_id image; + image_name_id app; + bool debug; +}; + + +/// accumulate all samples for a given caller/callee pair +u32 +accumulate_callee(call_data::const_iterator & it, call_data::const_iterator end, + u32 callee_end) +{ + u32 count = 0; + call_data::const_iterator const start = it; + + while (it != end) { + u32 offset = key_to_callee(it->first); + + if (cverb << (vdebug & vlevel1)) { + cverb << (vdebug & vlevel1) << hex << "offset: " + << offset << dec << endl; + } + + // stop if we pass the end of the callee + if (offset >= callee_end) + break; + + count += it->second; + ++it; + } + + // If we haven't advanced at all, then we'll get + // an infinite loop, so we must abort. + if (it == start) { + cerr << "failure to advance iterator\n"; + abort(); + } + + return count; +} + + +} // anonymous namespace + + +void arc_recorder:: +add(symbol_entry const & caller, symbol_entry const * callee, + count_array_t const & arc_count) +{ + cg_data & data = sym_map[caller]; + + // If we have a callee, add it to the caller's list, then + // add the caller to the callee's list. + if (callee) { + data.callees[*callee] += arc_count; + + cg_data & callee_data = sym_map[*callee]; + + callee_data.callers[caller] += arc_count; + } +} + + +void arc_recorder::process_children(cg_symbol & sym, double threshold) +{ + // generate the synthetic self entry for the symbol + symbol_entry self = sym; + + self.name = symbol_names.create(symbol_names.demangle(self.name) + + " [self]"); + + sym.total_callee_count += self.sample.counts; + sym.callees.push_back(self); + + sort(sym.callers.begin(), sym.callers.end(), compare_arc_count); + sort(sym.callees.begin(), sym.callees.end(), compare_arc_count_reverse); + + // FIXME: this relies on sort always being sample count + + cg_symbol::children::iterator cit = sym.callers.begin(); + cg_symbol::children::iterator cend = sym.callers.end(); + + while (cit != cend && op_ratio(cit->sample.counts[0], + sym.total_caller_count[0]) < threshold) + ++cit; + + if (cit != cend) + sym.callers.erase(sym.callers.begin(), cit); + + cit = sym.callees.begin(); + cend = sym.callees.end(); + + while (cit != cend && op_ratio(cit->sample.counts[0], + sym.total_callee_count[0]) >= threshold) + ++cit; + + if (cit != cend) + sym.callees.erase(cit, sym.callees.end()); +} + + +void arc_recorder:: +process(count_array_t total, double threshold, + string_filter const & sym_filter) +{ + map_t::const_iterator it; + map_t::const_iterator end = sym_map.end(); + + for (it = sym_map.begin(); it != end; ++it) { + cg_symbol sym((*it).first); + cg_data const & data = (*it).second; + + // threshold out the main symbol if needed + if (op_ratio(sym.sample.counts[0], total[0]) < threshold) + continue; + + // FIXME: slow? + if (!sym_filter.match(symbol_names.demangle(sym.name))) + continue; + + cg_data::children::const_iterator cit; + cg_data::children::const_iterator cend = data.callers.end(); + + for (cit = data.callers.begin(); cit != cend; ++cit) { + symbol_entry csym = cit->first; + csym.sample.counts = cit->second; + sym.callers.push_back(csym); + sym.total_caller_count += cit->second; + } + + cend = data.callees.end(); + + for (cit = data.callees.begin(); cit != cend; ++cit) { + symbol_entry csym = cit->first; + csym.sample.counts = cit->second; + sym.callees.push_back(csym); + sym.total_callee_count += cit->second; + } + + process_children(sym, threshold); + + cg_syms.push_back(sym); + } +} + + +cg_collection arc_recorder::get_symbols() const +{ + return cg_syms; +} + + +void callgraph_container::populate(string const & archive_path, + list const & iprofiles, + extra_images const & extra, bool debug_info, double threshold, + bool merge_lib, string_filter const & sym_filter) +{ + // non callgraph samples container, we record sample at symbol level + // not at vma level. + profile_container pc(debug_info, false); + + list::const_iterator it; + list::const_iterator const end = iprofiles.end(); + for (it = iprofiles.begin(); it != end; ++it) { + // populate_caller_image take care about empty sample filename + populate_for_image(archive_path, pc, *it, sym_filter, 0); + } + + add_symbols(pc); + + total_count = pc.samples_count(); + + for (it = iprofiles.begin(); it != end; ++it) { + for (size_t i = 0; i < it->groups.size(); ++i) { + populate(archive_path, it->groups[i], it->image, extra, + i, pc, debug_info, merge_lib); + } + } + + recorder.process(total_count, threshold / 100.0, sym_filter); +} + + +void callgraph_container::populate(string const & archive_path, + list const & lset, + string const & app_image, extra_images const & extra, size_t pclass, + profile_container const & pc, bool debug_info, bool merge_lib) +{ + list::const_iterator lit; + list::const_iterator const lend = lset.end(); + for (lit = lset.begin(); lit != lend; ++lit) { + list::const_iterator pit; + list::const_iterator pend + = lit->files.end(); + for (pit = lit->files.begin(); pit != pend; ++pit) { + populate(archive_path, pit->cg_files, app_image, + extra, pclass, pc, debug_info, merge_lib); + } + } +} + + +void callgraph_container::populate(string const & archive_path, + list const & cg_files, + string const & app_image, extra_images const & extra, size_t pclass, + profile_container const & pc, bool debug_info, bool merge_lib) +{ + list::const_iterator it; + list::const_iterator const end = cg_files.end(); + for (it = cg_files.begin(); it != end; ++it) { + cverb << vdebug << "samples file : " << *it << endl; + + parsed_filename caller_file = parse_filename(*it); + string const app_name = caller_file.image; + + image_error error; + string caller_binary = + find_image_path(archive_path, caller_file.lib_image, + extra, error); + + if (error != image_ok) + report_image_error(archive_path + caller_file.lib_image, + error, false); + + bool caller_bfd_ok = true; + op_bfd caller_bfd(archive_path, caller_binary, + string_filter(), caller_bfd_ok); + if (!caller_bfd_ok) + report_image_error(caller_binary, + image_format_failure, false); + + parsed_filename callee_file = parse_filename(*it); + + string callee_binary = + find_image_path(archive_path, callee_file.cg_image, + extra, error); + if (error != image_ok) + report_image_error(callee_file.cg_image, error, false); + + bool callee_bfd_ok = true; + op_bfd callee_bfd(archive_path, callee_binary, + string_filter(), callee_bfd_ok); + if (!callee_bfd_ok) + report_image_error(callee_binary, + image_format_failure, false); + + profile_t profile; + // We can't use start_offset support in profile_t, give + // it a zero offset and we will fix that in add() + profile.add_sample_file(*it); + add(profile, caller_bfd, caller_bfd_ok, callee_bfd, + merge_lib ? app_image : app_name, pc, + debug_info, pclass); + } +} + + +void callgraph_container:: +add(profile_t const & profile, op_bfd const & caller_bfd, bool caller_bfd_ok, + op_bfd const & callee_bfd, string const & app_name, + profile_container const & pc, bool debug_info, size_t pclass) +{ + string const image_name = caller_bfd.get_filename(); + + opd_header const & header = profile.get_header(); + + // We can't use kernel sample file w/o the binary else we will + // use it with a zero offset, the code below will abort because + // we will get incorrect callee sub-range and out of range + // callee vma. FIXME + if (header.is_kernel && !caller_bfd_ok) + return; + + // We must handle start_offset, this offset can be different for the + // caller and the callee: kernel sample traversing the syscall barrier. + u32 caller_offset = 0; + + if (header.is_kernel || header.anon_start) { + caller_offset = caller_bfd.get_start_offset(header.anon_start); + } + + u32 callee_offset = 0; + + if (header.cg_to_is_kernel || header.cg_to_anon_start) { + callee_offset = + callee_bfd.get_start_offset(header.cg_to_anon_start); + } + + image_name_id image_id = image_names.create(image_name); + image_name_id callee_image_id = image_names.create(callee_bfd.get_filename()); + image_name_id app_id = image_names.create(app_name); + + call_data caller(pc, profile, caller_bfd, caller_offset, image_id, + app_id, debug_info); + call_data callee(pc, profile, callee_bfd, callee_offset, + callee_image_id, app_id, debug_info); + + if (cverb << vdebug) { + caller.verbose_bfd("Caller:"); + callee.verbose_bfd("Callee:"); + } + + // For each symbol in the caller bfd, process all arcs to + // callee bfd symbols + + for (symbol_index_t i = 0; i < caller_bfd.syms.size(); ++i) { + + caller.caller_sym(i); + + call_data::const_iterator dit = caller.samples.begin(); + call_data::const_iterator dend = caller.samples.end(); + while (dit != dend) { + // if we can't find the callee, skip an arc + if (!callee.callee_sym(key_to_callee(dit->first))) { + ++dit; + continue; + } + + count_array_t arc_count; + arc_count[pclass] = + accumulate_callee(dit, dend, callee.callee_end); + + recorder.add(caller.sym, &callee.sym, arc_count); + } + } +} + + +void callgraph_container::add_symbols(profile_container const & pc) +{ + symbol_container::symbols_t::iterator it; + symbol_container::symbols_t::iterator const end = pc.end_symbol(); + + for (it = pc.begin_symbol(); it != end; ++it) + recorder.add(*it, 0, count_array_t()); +} + + +column_flags callgraph_container::output_hint() const +{ + column_flags output_hints = cf_none; + + // FIXME: costly: must we access directly recorder map ? + cg_collection syms = recorder.get_symbols(); + + cg_collection::const_iterator it; + cg_collection::const_iterator const end = syms.end(); + for (it = syms.begin(); it != end; ++it) + output_hints = it->output_hint(output_hints); + + return output_hints; +} + + +count_array_t callgraph_container::samples_count() const +{ + return total_count; +} + + +cg_collection callgraph_container::get_symbols() const +{ + return recorder.get_symbols(); +} diff --git a/libpp/callgraph_container.h b/libpp/callgraph_container.h new file mode 100644 index 0000000..7b8ee6e --- /dev/null +++ b/libpp/callgraph_container.h @@ -0,0 +1,172 @@ +/** + * @file callgraph_container.h + * Container associating symbols and caller/caller symbols + * + * @remark Copyright 2004 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef CALLGRAPH_CONTAINER_H +#define CALLGRAPH_CONTAINER_H + +#include +#include +#include + +#include "symbol.h" +#include "symbol_functors.h" +#include "string_filter.h" + +class profile_container; +class inverted_profile; +class profile_t; +class extra_images; +class image_set; +class op_bfd; + + +/** + * During building a callgraph_container we store all caller/callee + * relationship in this container. + * + * An "arc" is simply a description of a call from one function to + * another. + */ +class arc_recorder { +public: + ~arc_recorder() {} + + /** + * Add a symbol arc. + * @param caller The calling symbol + * @param callee The called symbol + * @param arc_count profile data for the arcs + * + * If the callee is NULL, only the caller is added to the main + * list. This is used to initially populate the recorder with + * the symbols. + */ + void add(symbol_entry const & caller, symbol_entry const * callee, + count_array_t const & arc_count); + + /// return all the cg symbols + cg_collection get_symbols() const; + + /** + * After population, build the final output, and do + * thresholding. + */ + void process(count_array_t total, double threshold, + string_filter const & filter); + +private: + /** + * Internal structure used during collation. We use a map to + * allow quick lookup of children (we'll do this several times + * if we have more than one profile class). Each child maps from + * the symbol to the relevant arc data. + */ + struct cg_data { + cg_data() {} + + typedef std::map children; + + /// callers of this symbol + children callers; + /// callees of this symbol + children callees; + }; + + /** + * Sort and threshold callers and callees. + */ + void process_children(cg_symbol & sym, double threshold); + + typedef std::map map_t; + + /// all the symbols (used during processing) + map_t sym_map; + + /// final output data + cg_collection cg_syms; +}; + + +/** + * Store all callgraph information for the given profiles + */ +class callgraph_container { +public: + /** + * Populate the container, must be called once only. + * @param archive_path oparchive prefix path + * @param iprofiles sample file list including callgraph files. + * @param extra extra image list to fixup binary name. + * @param debug_info true if we must record linenr information + * @param threshold ignore sample percent below this threshold + * @param merge_lib merge library samples + * @param sym_filter symbol filter + * + * Currently all errors core dump. + * FIXME: consider if this should be a ctor + */ + void populate(std::string const & archive_path, + std::list const & iprofiles, + extra_images const & extra, bool debug_info, + double threshold, bool merge_lib, + string_filter const & sym_filter); + + /// return hint on how data must be displayed. + column_flags output_hint() const; + + /// return the total number of samples. + count_array_t samples_count() const; + + // return all the cg symbols + cg_collection get_symbols() const; + +private: + /** + * Record caller/callee for one cg file + * @param profile one callgraph file stored in a profile_t + * @param caller_bfd the caller bfd + * @param bfd_caller_ok true if we succefully open the binary + * @param callee_bfd the callee bfd + * @param app_name the owning application + * @param pc the profile_container holding all non cg samples. + * @param debug_info record linenr debug information + * @param pclass profile class nr + */ + void add(profile_t const & profile, op_bfd const & caller_bfd, + bool bfd_caller_ok, op_bfd const & callee_bfd, + std::string const & app_name, + profile_container const & pc, bool debug_info, + size_t pclass); + + void populate(std::string const & archive_path, + std::list const & lset, + std::string const & app_image, + extra_images const & extra, size_t pclass, + profile_container const & pc, bool debug_info, + bool merge_lib); + void populate(std::string const & archive_path, + std::list const & cg_files, + std::string const & app_image, + extra_images const & extra, size_t pclass, + profile_container const & pc, bool debug_info, + bool merge_lib); + + /// record all main symbols + void add_symbols(profile_container const & pc); + + /// Cached value of samples count. + count_array_t total_count; + + /// A structured representation of the callgraph. + arc_recorder recorder; +}; + +#endif /* !CALLGRAPH_CONTAINER_H */ diff --git a/libpp/diff_container.cpp b/libpp/diff_container.cpp new file mode 100644 index 0000000..7762916 --- /dev/null +++ b/libpp/diff_container.cpp @@ -0,0 +1,159 @@ +/** + * @file diff_container.cpp + * Container for diffed symbols + * + * @remark Copyright 2005 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +/* older glibc has C99 INFINITY in _GNU_SOURCE */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include "diff_container.h" + +#include + +using namespace std; + + +namespace { + + +/// a comparator suitable for diffing symbols +bool rough_less(symbol_entry const & lhs, symbol_entry const & rhs) +{ + if (lhs.image_name != rhs.image_name) + return lhs.image_name < rhs.image_name; + + if (lhs.app_name != rhs.app_name) + return lhs.app_name < rhs.app_name; + + if (lhs.name != rhs.name) + return lhs.name < rhs.name; + + return false; +} + + +/// possibly add a diff sym +void +add_sym(diff_collection & syms, diff_symbol const & sym, + profile_container::symbol_choice & choice) +{ + if (choice.match_image + && (image_names.name(sym.image_name) != choice.image_name)) + return; + + if (fabs(sym.diffs[0]) < choice.threshold) + return; + + choice.hints = sym.output_hint(choice.hints); + syms.push_back(sym); +} + + +/// add a symbol not present in the new profile +void +symbol_old(diff_collection & syms, symbol_entry const & sym, + profile_container::symbol_choice & choice) +{ + diff_symbol symbol(sym); + symbol.diffs.fill(sym.sample.counts.size(), -INFINITY); + add_sym(syms, symbol, choice); +} + + +/// add a symbol not present in the old profile +void +symbol_new(diff_collection & syms, symbol_entry const & sym, + profile_container::symbol_choice & choice) +{ + diff_symbol symbol(sym); + symbol.diffs.fill(sym.sample.counts.size(), INFINITY); + add_sym(syms, symbol, choice); +} + + +/// add a diffed symbol +void symbol_diff(diff_collection & syms, + symbol_entry const & sym1, count_array_t const & total1, + symbol_entry const & sym2, count_array_t const & total2, + profile_container::symbol_choice & choice) +{ + diff_symbol symbol(sym2); + + size_t size = sym2.sample.counts.size(); + for (size_t i = 0; i != size; ++i) { + double percent1; + double percent2; + percent1 = op_ratio(sym1.sample.counts[i], total1[i]); + percent2 = op_ratio(sym2.sample.counts[i], total2[i]); + symbol.diffs[i] = op_ratio(percent2 - percent1, percent1); + symbol.diffs[i] *= 100.0; + } + + add_sym(syms, symbol, choice); +} + + +}; // namespace anon + + +diff_container::diff_container(profile_container const & c1, + profile_container const & c2) + : pc1(c1), pc2(c2), + total1(pc1.samples_count()), total2(pc2.samples_count()) +{ +} + + +diff_collection const +diff_container::get_symbols(profile_container::symbol_choice & choice) const +{ + diff_collection syms; + + /* + * Do a pairwise comparison of the two symbol sets. We're + * relying here on the symbol container being sorted such + * that rough_less() is suitable for iterating through the + * two lists (see less_symbol). + */ + + symbol_container::symbols_t::iterator it1 = pc1.begin_symbol(); + symbol_container::symbols_t::iterator end1 = pc1.end_symbol(); + symbol_container::symbols_t::iterator it2 = pc2.begin_symbol(); + symbol_container::symbols_t::iterator end2 = pc2.end_symbol(); + + while (it1 != end1 && it2 != end2) { + if (rough_less(*it1, *it2)) { + symbol_old(syms, *it1, choice); + ++it1; + } else if (rough_less(*it2, *it1)) { + symbol_new(syms, *it2, choice); + ++it2; + } else { + symbol_diff(syms, *it1, total1, *it2, total2, choice); + ++it1; + ++it2; + } + } + + for (; it1 != end1; ++it1) + symbol_old(syms, *it1, choice); + + for (; it2 != end2; ++it2) + symbol_new(syms, *it2, choice); + + return syms; +} + + +count_array_t const diff_container::samples_count() const +{ + return total2; +} diff --git a/libpp/diff_container.h b/libpp/diff_container.h new file mode 100644 index 0000000..14b431d --- /dev/null +++ b/libpp/diff_container.h @@ -0,0 +1,50 @@ +/** + * @file diff_container.h + * Container for diffed symbols + * + * @remark Copyright 2005 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef DIFF_CONTAINER_H +#define DIFF_CONTAINER_H + +#include "profile_container.h" + + +/** + * Store two profiles for diffing. + */ +class diff_container : noncopyable { +public: + /// populate the collection of diffed symbols + diff_container(profile_container const & pc1, + profile_container const & pc2); + + ~diff_container() {} + + /// return a collection of diffed symbols + diff_collection const + get_symbols(profile_container::symbol_choice & choice) const; + + /// total count for 'new' profile + count_array_t const samples_count() const; + +private: + /// first profile + profile_container const & pc1; + + /// second profile + profile_container const & pc2; + + /// samples count for pc1 + count_array_t total1; + + /// samples count for pc2 + count_array_t total2; +}; + +#endif /* !DIFF_CONTAINER_H */ diff --git a/libpp/filename_spec.cpp b/libpp/filename_spec.cpp new file mode 100644 index 0000000..9ce7cb4 --- /dev/null +++ b/libpp/filename_spec.cpp @@ -0,0 +1,79 @@ +/** + * @file filename_spec.cpp + * Container holding a sample filename split into its components + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#include + +#include "filename_spec.h" +#include "parse_filename.h" +#include "generic_spec.h" + + +using namespace std; + + +filename_spec::filename_spec(string const & filename) +{ + set_sample_filename(filename); +} + + +filename_spec::filename_spec() + : image("*"), lib_image("*") +{ +} + + +bool filename_spec::match(filename_spec const & rhs, + string const & binary) const +{ + if (!tid.match(rhs.tid) || !cpu.match(rhs.cpu) || + !tgid.match(rhs.tgid) || count != rhs.count || + unitmask != rhs.unitmask || event != rhs.event) { + return false; + } + + if (binary.empty()) { + return image == rhs.image && lib_image == rhs.lib_image; + } + + // PP:3.3 if binary is not empty we must match either the + // lib_name if present or the image name + if (!rhs.lib_image.empty()) { + // FIXME: use fnmatch ? + return rhs.lib_image == binary; + } + + // FIXME: use fnmatch ? + return rhs.image == binary; +} + + +void filename_spec::set_sample_filename(string const & filename) +{ + parsed_filename parsed = parse_filename(filename); + + image = parsed.image; + lib_image = parsed.lib_image; + cg_image = parsed.cg_image; + event = parsed.event; + count = op_lexical_cast(parsed.count); + unitmask = op_lexical_cast(parsed.unitmask); + tgid.set(parsed.tgid); + tid.set(parsed.tid); + cpu.set(parsed.cpu); +} + + +bool filename_spec::is_dependent() const +{ + if (cg_image.empty()) + return image != lib_image; + return cg_image != image || cg_image != lib_image; +} diff --git a/libpp/filename_spec.h b/libpp/filename_spec.h new file mode 100644 index 0000000..abd7f8a --- /dev/null +++ b/libpp/filename_spec.h @@ -0,0 +1,79 @@ +/** + * @file filename_spec.h + * Container holding a sample filename split into its components + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#ifndef FILENAME_SPEC_H +#define FILENAME_SPEC_H + +#include +#include + +#include "generic_spec.h" + +class profile_spec; + +/** + * A class to split and store components of a sample filename. + * These derived values are then used to match against a + * profile_spec as given by the user. + */ +class filename_spec +{ + friend class profile_spec; + +public: + /** + * @param filename the samples filename + * + * build a filename_spec from a samples filename + */ + filename_spec(std::string const & filename); + + filename_spec(); + + /** + * @param filename a sample filename + * + * setup filename spec according to the samples filename. PP:3.19 to + * 3.25 + */ + void set_sample_filename(std::string const & filename); + + /** + * @param rhs right hand side of the match operator + * @param binary if binary is non-empty, and matches + * the binary or lib name, use it rather than the + * one in rhs. + * + * return true if *this match rhs, matching if: + * - image_name are identical + * - lib_name are identical + * - event_spec match + * + * This operation is not commutative. First part of PP:3.24 + */ + bool match(filename_spec const & rhs, + std::string const & binary) const; + + bool is_dependent() const; + +private: + std::string image; + std::string lib_image; + std::string cg_image; + std::string event; + int count; + unsigned int unitmask; + generic_spec tgid; + generic_spec tid; + generic_spec cpu; +}; + + +#endif /* !FILENAME_SPEC_H */ diff --git a/libpp/format_flags.h b/libpp/format_flags.h new file mode 100644 index 0000000..6268ae1 --- /dev/null +++ b/libpp/format_flags.h @@ -0,0 +1,69 @@ +/** + * @file format_flags.h + * output options + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef FORMAT_FLAGS_H +#define FORMAT_FLAGS_H + +/** + * flags passed to the ctor of an output_symbol object. + * + * \sa format_output::formatter + */ +enum format_flags { + ff_none = 0, + /// a formatted memory address + ff_vma = 1 << 0, + /// output debug filename and line nr. + ff_linenr_info = 1 << 1, + /// output the image name for this line + ff_image_name = 1 << 3, + /// output owning application name + ff_app_name = 1 << 4, + /// output the (demangled) symbol name + ff_symb_name = 1 << 5, + + /** @name subset of flags used by opreport_formatter */ + //@{ + /// number of samples + ff_nr_samples = 1 << 6, + /// number of samples accumulated + ff_nr_samples_cumulated = 1 << 7, + /// relative percentage of samples + ff_percent = 1 << 8, + /// relative percentage of samples accumulated + ff_percent_cumulated = 1 << 9, + /** + * Output percentage for details, not relative + * to symbol but relative to the total nr of samples + */ + ff_percent_details = 1 << 10, + /** + * Output percentage for details, not relative + * to symbol but relative to the total nr of samples, + * accumulated + */ + ff_percent_cumulated_details = 1 << 11, + /// output diff value + ff_diff = 1 << 12, + //@} +}; + + +/** + * General hints about formatting of the columnar output. + */ +enum column_flags { + cf_none = 0, + cf_64bit_vma = 1 << 0, + cf_image_name = 1 << 1 +}; + +#endif // FORMAT_FLAGS_H diff --git a/libpp/format_output.cpp b/libpp/format_output.cpp new file mode 100644 index 0000000..700c0d6 --- /dev/null +++ b/libpp/format_output.cpp @@ -0,0 +1,544 @@ +/** + * @file format_output.cpp + * outputting format for symbol lists + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +/* older glibc has C99 INFINITY in _GNU_SOURCE */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include +#include +#include +#include + +#include "string_manip.h" + +#include "format_output.h" +#include "profile_container.h" +#include "callgraph_container.h" +#include "diff_container.h" + +using namespace std; + + +namespace { + +string const & get_image_name(image_name_id id, bool lf) +{ + return lf ? image_names.name(id) : image_names.basename(id); +} + +string const get_linenr_info(file_location const floc, bool lf) +{ + ostringstream out; + + string const & filename = lf + ? debug_names.name(floc.filename) + : debug_names.basename(floc.filename); + + if (!filename.empty()) { + out << filename << ":" << floc.linenr; + } else { + out << "(no location information)"; + } + + return out.str(); +} + +string get_vma(bfd_vma vma, bool vma_64) +{ + ostringstream out; + int width = vma_64 ? 16 : 8; + + out << hex << setw(width) << setfill('0') << vma; + + return out.str(); +} + +string get_percent(size_t dividend, size_t divisor) +{ + double ratio = op_ratio(dividend, divisor); + + return ::format_percent(ratio * 100, percent_int_width, + percent_fract_width); +} + +} // anonymous namespace + + +namespace format_output { + + +formatter::formatter() + : + nr_classes(1), + flags(ff_none), + vma_64(false), + long_filenames(false), + need_header(true) +{ + format_map[ff_vma] = field_description(9, "vma", &formatter::format_vma); + format_map[ff_nr_samples] = field_description(9, "samples", &formatter::format_nr_samples); + format_map[ff_nr_samples_cumulated] = field_description(14, "cum. samples", &formatter::format_nr_cumulated_samples); + format_map[ff_percent] = field_description(9, "%", &formatter::format_percent); + format_map[ff_percent_cumulated] = field_description(11, "cum. %", &formatter::format_cumulated_percent); + format_map[ff_linenr_info] = field_description(28, "linenr info", &formatter::format_linenr_info); + format_map[ff_image_name] = field_description(25, "image name", &formatter::format_image_name); + format_map[ff_app_name] = field_description(25, "app name", &formatter::format_app_name); + format_map[ff_symb_name] = field_description(30, "symbol name", &formatter::format_symb_name); + format_map[ff_percent_details] = field_description(9, "%", &formatter::format_percent_details); + format_map[ff_percent_cumulated_details] = field_description(10, "cum. %", &formatter::format_cumulated_percent_details); + format_map[ff_diff] = field_description(10, "diff %", &formatter::format_diff); +} + + +formatter::~formatter() +{ +} + + +void formatter::set_nr_classes(size_t nr) +{ + nr_classes = nr; +} + + +void formatter::add_format(format_flags flag) +{ + flags = static_cast(flags | flag); +} + + +void formatter::show_header(bool on_off) +{ + need_header = on_off; +} + + +void formatter::vma_format_64bit(bool on_off) +{ + vma_64 = on_off; +} + + +void formatter::show_long_filenames(bool on_off) +{ + long_filenames = on_off; +} + + +void formatter::show_global_percent(bool on_off) +{ + global_percent = on_off; +} + + +void formatter::output_header(ostream & out) +{ + if (!need_header) + return; + + size_t padding = 0; + + // first output the vma field + if (flags & ff_vma) + padding = output_header_field(out, ff_vma, padding); + + // the field repeated for each profile class + for (size_t pclass = 0 ; pclass < nr_classes; ++pclass) { + if (flags & ff_nr_samples) + padding = output_header_field(out, + ff_nr_samples, padding); + + if (flags & ff_nr_samples_cumulated) + padding = output_header_field(out, + ff_nr_samples_cumulated, padding); + + if (flags & ff_percent) + padding = output_header_field(out, + ff_percent, padding); + + if (flags & ff_percent_cumulated) + padding = output_header_field(out, + ff_percent_cumulated, padding); + + if (flags & ff_diff) + padding = output_header_field(out, + ff_diff, padding); + + if (flags & ff_percent_details) + padding = output_header_field(out, + ff_percent_details, padding); + + if (flags & ff_percent_cumulated_details) + padding = output_header_field(out, + ff_percent_cumulated_details, padding); + } + + // now the remaining field + if (flags & ff_linenr_info) + padding = output_header_field(out, ff_linenr_info, padding); + + if (flags & ff_image_name) + padding = output_header_field(out, ff_image_name, padding); + + if (flags & ff_app_name) + padding = output_header_field(out, ff_app_name, padding); + + if (flags & ff_symb_name) + padding = output_header_field(out, ff_symb_name, padding); + + out << "\n"; +} + + +/// describe each possible field of colummned output. +// FIXME: use % of the screen width here. sum of % equal to 100, then calculate +// ratio between 100 and the selected % to grow non fixed field use also +// lib[n?]curses to get the console width (look info source) (so on add a fixed +// field flags) +size_t formatter:: +output_field(ostream & out, field_datum const & datum, + format_flags fl, size_t padding, bool hide_immutable) +{ + if (!hide_immutable) { + out << string(padding, ' '); + + field_description const & field(format_map[fl]); + string str = (this->*field.formatter)(datum); + out << str; + + // at least one separator char + padding = 1; + if (str.length() < field.width) + padding = field.width - str.length(); + } else { + field_description const & field(format_map[fl]); + padding += field.width; + } + + return padding; +} + + +size_t formatter:: +output_header_field(ostream & out, format_flags fl, size_t padding) +{ + out << string(padding, ' '); + + field_description const & field(format_map[fl]); + out << field.header_name; + + // at least one separator char + padding = 1; + if (field.header_name.length() < field.width) + padding = field.width - field.header_name.length(); + + return padding; +} + + +string formatter::format_vma(field_datum const & f) +{ + return get_vma(f.sample.vma, vma_64); +} + + +string formatter::format_symb_name(field_datum const & f) +{ + return symbol_names.demangle(f.symbol.name); +} + + +string formatter::format_image_name(field_datum const & f) +{ + return get_image_name(f.symbol.image_name, long_filenames); +} + + +string formatter::format_app_name(field_datum const & f) +{ + return get_image_name(f.symbol.app_name, long_filenames); +} + + +string formatter::format_linenr_info(field_datum const & f) +{ + return get_linenr_info(f.sample.file_loc, long_filenames); +} + + +string formatter::format_nr_samples(field_datum const & f) +{ + ostringstream out; + out << f.sample.counts[f.pclass]; + return out.str(); +} + + +string formatter::format_nr_cumulated_samples(field_datum const & f) +{ + if (f.diff == -INFINITY) + return "---"; + ostringstream out; + f.counts.cumulated_samples[f.pclass] += f.sample.counts[f.pclass]; + out << f.counts.cumulated_samples[f.pclass]; + return out.str(); +} + + +string formatter::format_percent(field_datum const & f) +{ + if (f.diff == -INFINITY) + return "---"; + return get_percent(f.sample.counts[f.pclass], f.counts.total[f.pclass]); +} + + +string formatter::format_cumulated_percent(field_datum const & f) +{ + if (f.diff == -INFINITY) + return "---"; + f.counts.cumulated_percent[f.pclass] += f.sample.counts[f.pclass]; + + return get_percent(f.counts.cumulated_percent[f.pclass], + f.counts.total[f.pclass]); +} + + +string formatter::format_percent_details(field_datum const & f) +{ + return get_percent(f.sample.counts[f.pclass], + f.counts.total[f.pclass]); +} + + +string formatter::format_cumulated_percent_details(field_datum const & f) +{ + f.counts.cumulated_percent_details[f.pclass] += f.sample.counts[f.pclass]; + + return get_percent(f.counts.cumulated_percent_details[f.pclass], + f.counts.total[f.pclass]); +} + + +string formatter::format_diff(field_datum const & f) +{ + if (f.diff == INFINITY) { + ostringstream out; + out << "+++"; + return out.str(); + } else if (f.diff == -INFINITY) { + ostringstream out; + out << "---"; + return out.str(); + } + + return ::format_percent(f.diff, percent_int_width, + percent_fract_width, true); +} + + +void formatter:: +do_output(ostream & out, symbol_entry const & symb, sample_entry const & sample, + counts_t & c, diff_array_t const & diffs, bool hide_immutable) +{ + size_t padding = 0; + + // first output the vma field + field_datum datum(symb, sample, 0, c); + if (flags & ff_vma) + padding = output_field(out, datum, ff_vma, padding, false); + + // repeated fields for each profile class + for (size_t pclass = 0 ; pclass < nr_classes; ++pclass) { + field_datum datum(symb, sample, pclass, c, diffs[pclass]); + + if (flags & ff_nr_samples) + padding = output_field(out, datum, + ff_nr_samples, padding, false); + + if (flags & ff_nr_samples_cumulated) + padding = output_field(out, datum, + ff_nr_samples_cumulated, padding, false); + + if (flags & ff_percent) + padding = output_field(out, datum, + ff_percent, padding, false); + + if (flags & ff_percent_cumulated) + padding = output_field(out, datum, + ff_percent_cumulated, padding, false); + + if (flags & ff_diff) + padding = output_field(out, datum, + ff_diff, padding, false); + + if (flags & ff_percent_details) + padding = output_field(out, datum, + ff_percent_details, padding, false); + + if (flags & ff_percent_cumulated_details) + padding = output_field(out, datum, + ff_percent_cumulated_details, padding, false); + } + + // now the remaining field + if (flags & ff_linenr_info) + padding = output_field(out, datum, ff_linenr_info, + padding, false); + + if (flags & ff_image_name) + padding = output_field(out, datum, ff_image_name, + padding, hide_immutable); + + if (flags & ff_app_name) + padding = output_field(out, datum, ff_app_name, + padding, hide_immutable); + + if (flags & ff_symb_name) + padding = output_field(out, datum, ff_symb_name, + padding, hide_immutable); + + out << "\n"; +} + + +opreport_formatter::opreport_formatter(profile_container const & p) + : + profile(p), + need_details(false) +{ + counts.total = profile.samples_count(); +} + + +void opreport_formatter::show_details(bool on_off) +{ + need_details = on_off; +} + + +void opreport_formatter::output(ostream & out, symbol_entry const * symb) +{ + do_output(out, *symb, symb->sample, counts); + + if (need_details) + output_details(out, symb); +} + + +void opreport_formatter:: +output(ostream & out, symbol_collection const & syms) +{ + output_header(out); + + symbol_collection::const_iterator it = syms.begin(); + symbol_collection::const_iterator end = syms.end(); + for (; it != end; ++it) + output(out, *it); +} + + +void opreport_formatter:: +output_details(ostream & out, symbol_entry const * symb) +{ + counts_t c = counts; + + if (!global_percent) + c.total = symb->sample.counts; + + // cumulated percent are relative to current symbol. + c.cumulated_samples = count_array_t(); + c.cumulated_percent = count_array_t(); + + sample_container::samples_iterator it = profile.begin(symb); + sample_container::samples_iterator end = profile.end(symb); + for (; it != end; ++it) { + out << " "; + do_output(out, *symb, it->second, c, diff_array_t(), true); + } +} + + +cg_formatter::cg_formatter(callgraph_container const & profile) +{ + counts.total = profile.samples_count(); +} + + +void cg_formatter::output(ostream & out, cg_collection const & syms) +{ + // amount of spacing prefixing child and parent lines + string const child_parent_prefix(" "); + + output_header(out); + + out << string(79, '-') << endl; + + cg_collection::const_iterator it; + cg_collection::const_iterator end = syms.end(); + + for (it = syms.begin(); it < end; ++it) { + cg_symbol const & sym = *it; + + cg_symbol::children::const_iterator cit; + cg_symbol::children::const_iterator cend = sym.callers.end(); + + counts_t c; + if (global_percent) + c.total = counts.total; + else + c.total = sym.total_caller_count; + + for (cit = sym.callers.begin(); cit != cend; ++cit) { + out << child_parent_prefix; + do_output(out, *cit, cit->sample, c); + } + + do_output(out, sym, sym.sample, counts); + + c = counts_t(); + if (global_percent) + c.total = counts.total; + else + c.total = sym.total_callee_count; + + cend = sym.callees.end(); + + for (cit = sym.callees.begin(); cit != cend; ++cit) { + out << child_parent_prefix; + do_output(out, *cit, cit->sample, c); + } + + out << string(79, '-') << endl; + } +} + + +diff_formatter::diff_formatter(diff_container const & profile) +{ + counts.total = profile.samples_count(); +} + + +void diff_formatter::output(ostream & out, diff_collection const & syms) +{ + output_header(out); + + diff_collection::const_iterator it = syms.begin(); + diff_collection::const_iterator end = syms.end(); + for (; it != end; ++it) + do_output(out, *it, it->sample, counts, it->diffs); +} + + +} // namespace format_output diff --git a/libpp/format_output.h b/libpp/format_output.h new file mode 100644 index 0000000..88404d7 --- /dev/null +++ b/libpp/format_output.h @@ -0,0 +1,222 @@ +/** + * @file format_output.h + * outputting format for symbol lists + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef FORMAT_OUTPUT_H +#define FORMAT_OUTPUT_H + +#include "config.h" + +#include +#include +#include + +#include "format_flags.h" +#include "symbol.h" + +class symbol_entry; +class sample_entry; +class callgraph_container; +class profile_container; +class diff_container; + +namespace format_output { + +/// base class for formatter, handle common options to formatter +class formatter { +public: + formatter(); + virtual ~formatter(); + + /// add a given column + void add_format(format_flags flag); + + /// set the need_header boolean to false + void show_header(bool); + /// format for 64 bit wide VMAs + void vma_format_64bit(bool); + /// show long (full path) filenames + void show_long_filenames(bool); + /// use global count rather symbol count for details percent + void show_global_percent(bool); + + /** + * Set the number of collected profile classes. Each class + * will output sample count and percentage in extra columns. + * + * This class assumes that the profile information has been + * populated with the right number of classes. + */ + void set_nr_classes(size_t nr_classes); + + /// output table header, implemented by calling the virtual function + /// output_header_field() + void output_header(std::ostream & out); + +protected: + struct counts_t { + /// total sample count + count_array_t total; + /// samples so far + count_array_t cumulated_samples; + /// percentage so far + count_array_t cumulated_percent; + /// detailed percentage so far + count_array_t cumulated_percent_details; + }; + + /// data passed for output + struct field_datum { + field_datum(symbol_entry const & sym, + sample_entry const & s, + size_t pc, counts_t & c, double d = 0.0) + : symbol(sym), sample(s), pclass(pc), + counts(c), diff(d) {} + symbol_entry const & symbol; + sample_entry const & sample; + size_t pclass; + mutable counts_t & counts; + double diff; + }; + + /// format callback type + typedef std::string (formatter::*fct_format)(field_datum const &); + + /** @name format functions. + * The set of formatting functions, used internally by output(). + */ + //@{ + std::string format_vma(field_datum const &); + std::string format_symb_name(field_datum const &); + std::string format_image_name(field_datum const &); + std::string format_app_name(field_datum const &); + std::string format_linenr_info(field_datum const &); + std::string format_nr_samples(field_datum const &); + std::string format_nr_cumulated_samples(field_datum const &); + std::string format_percent(field_datum const &); + std::string format_cumulated_percent(field_datum const &); + std::string format_percent_details(field_datum const &); + std::string format_cumulated_percent_details(field_datum const &); + std::string format_diff(field_datum const &); + //@} + + /// decribe one field of the colummned output. + struct field_description { + field_description() {} + field_description(std::size_t w, std::string h, fct_format f) + : width(w), header_name(h), formatter(f) {} + + std::size_t width; + std::string header_name; + fct_format formatter; + }; + + typedef std::map format_map_t; + + /// actually do output + void do_output(std::ostream & out, symbol_entry const & symbol, + sample_entry const & sample, counts_t & c, + diff_array_t const & = diff_array_t(), + bool hide_immutable_field = false); + + /// returns the nr of char needed to pad this field + size_t output_header_field(std::ostream & out, format_flags fl, + size_t padding); + + /// returns the nr of char needed to pad this field + size_t output_field(std::ostream & out, field_datum const & datum, + format_flags fl, size_t padding, + bool hide_immutable); + + /// stores functors for doing actual formatting + format_map_t format_map; + + /// number of profile classes + size_t nr_classes; + + /// total counts + counts_t counts; + + /// formatting flags set + format_flags flags; + /// true if we need to format as 64 bits quantities + bool vma_64; + /// false if we use basename(filename) in output rather filename + bool long_filenames; + /// true if we need to show header before the first output + bool need_header; + /// bool if details percentage are relative to total count rather to + /// symbol count + bool global_percent; +}; + + +/// class to output in a columned format symbols and associated samples +class opreport_formatter : public formatter { +public: + /// build a ready to use formatter + opreport_formatter(profile_container const & profile); + + /** output a vector of symbols to out according to the output format + * specifier previously set by call(s) to add_format() */ + void output(std::ostream & out, symbol_collection const & syms); + + /// set the output_details boolean + void show_details(bool); + +private: + + /** output one symbol symb to out according to the output format + * specifier previously set by call(s) to add_format() */ + void output(std::ostream & out, symbol_entry const * symb); + + /// output details for the symbol + void output_details(std::ostream & out, symbol_entry const * symb); + + /// container we work from + profile_container const & profile; + + /// true if we need to show details for each symbols + bool need_details; +}; + + +/// class to output in a columned format caller/callee and associated samples +class cg_formatter : public formatter { +public: + /// build a ready to use formatter + cg_formatter(callgraph_container const & profile); + + /** output callgraph information according to the previously format + * specifier set by call(s) to add_format() */ + void output(std::ostream & out, cg_collection const & syms); +}; + +/// class to output a columned format symbols plus diff values +class diff_formatter : public formatter { +public: + /// build a ready to use formatter + diff_formatter(diff_container const & profile); + + /** + * Output a vector of symbols to out according to the output + * format specifier previously set by call(s) to add_format() + */ + void output(std::ostream & out, diff_collection const & syms); + +private: + /// output a single symbol + void output(std::ostream & out, diff_symbol const & sym); + +}; + +} // namespace format_output + +#endif /* !FORMAT_OUTPUT_H */ diff --git a/libpp/image_errors.cpp b/libpp/image_errors.cpp new file mode 100644 index 0000000..0960be6 --- /dev/null +++ b/libpp/image_errors.cpp @@ -0,0 +1,81 @@ +/** + * @file image_errors.cpp + * Report errors in images + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#include "image_errors.h" + +#include "arrange_profiles.h" +#include "string_manip.h" + +#include +#include + +using namespace std; + +namespace { + +set reported_images_error; + +} + +void report_image_error(string const & image, image_error error, bool fatal) +{ + if (error == image_ok) + return; + + if (reported_images_error.find(image) == reported_images_error.end()) { + reported_images_error.insert(image); + + // FIXME: hacky + if (error == image_not_found && is_prefix(image, "anon ")) + return; + + cerr << (fatal ? "error: " : "warning: "); + cerr << image << ' '; + + switch (error) { + case image_not_found: + cerr << "could not be found.\n"; + break; + + case image_unreadable: + cerr << "could not be read.\n"; + break; + + case image_multiple_match: + cerr << "matches more than one file: " + "detailed profile will not be provided.\n"; + break; + + case image_format_failure: + cerr << "is not in a usable binary format.\n"; + break; + + case image_ok: + break; + } + } +} + + +void report_image_error(inverted_profile const & profile, bool fatal) +{ + report_image_error(profile.image, profile.error, fatal); +} + + +void report_image_errors(list const & plist) +{ + list::const_iterator it = plist.begin(); + list::const_iterator const end = plist.end(); + + for (; it != end; ++it) { + report_image_error(*it, false); + } +} diff --git a/libpp/image_errors.h b/libpp/image_errors.h new file mode 100644 index 0000000..ec26d90 --- /dev/null +++ b/libpp/image_errors.h @@ -0,0 +1,39 @@ +/** + * @file image_errors.h + * Report errors in images + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#ifndef IMAGE_ERRORS_H +#define IMAGE_ERRORS_H + +#include +#include + +class inverted_profile; + +/// possible reasons why we can't read a binary image +enum image_error { + image_ok = 0, + image_not_found, + image_unreadable, + image_format_failure, + image_multiple_match +}; + +/// output why the image passed can't be read to stderr, we warranty only one +/// error report by image name. +void +report_image_error(std::string const & image, image_error error, bool fatal); + +/// output why the image passed can't be read to stderr +void report_image_error(inverted_profile const & profile, bool fatal); + +/// output why any bad images can't be read to stderr +void report_image_errors(std::list const & plist); + +#endif /* IMAGE_ERRORS_H */ diff --git a/libpp/locate_images.cpp b/libpp/locate_images.cpp new file mode 100644 index 0000000..26b14b3 --- /dev/null +++ b/libpp/locate_images.cpp @@ -0,0 +1,135 @@ +/** + * @file locate_images.cpp + * Command-line helper + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include "file_manip.h" +#include "locate_images.h" + +#include +#include +#include +#include + +using namespace std; + + +void extra_images::populate(vector const & paths) +{ + vector::const_iterator cit = paths.begin(); + vector::const_iterator end = paths.end(); + for (; cit != end; ++cit) { + string const path = op_realpath(*cit); + list file_list; + create_file_list(file_list, path, "*", true); + list::const_iterator lit = file_list.begin(); + list::const_iterator lend = file_list.end(); + for (; lit != lend; ++lit) { + value_type v(op_basename(*lit), op_dirname(*lit)); + images.insert(v); + } + } +} + + +vector const extra_images::find(string const & name) const +{ + extra_images::matcher match(name); + return find(match); +} + + +vector const +extra_images::find(extra_images::matcher const & match) const +{ + vector matches; + + const_iterator cit = images.begin(); + const_iterator end = images.end(); + + for (; cit != end; ++cit) { + if (match(cit->first)) + matches.push_back(cit->second + '/' + cit->first); + } + + return matches; +} + + +namespace { + +/** + * Function object for matching a module filename, which + * has its own special mangling rules in 2.6 kernels. + */ +struct module_matcher : public extra_images::matcher { +public: + explicit module_matcher(string const & s) + : extra_images::matcher(s) {} + + virtual bool operator()(string const & candidate) const { + if (candidate.length() != value.length()) + return false; + + for (string::size_type i = 0 ; i < value.length() ; ++i) { + if (value[i] == candidate[i]) + continue; + if (value[i] == '_' && + (candidate[i] == ',' || candidate[i] == '-')) + continue; + return false; + } + + return true; + } +}; + +} // anon namespace + + +string const find_image_path(string const & archive_path, + string const & image_name, + extra_images const & extra_images, + image_error & error) +{ + error = image_ok; + + string const image = op_realpath(archive_path + image_name); + + // simplest case + if (op_file_readable(image)) { + error = image_ok; + return image_name; + } + + if (errno == EACCES) { + error = image_unreadable; + return image_name; + } + + string const base = op_basename(image); + + vector result = extra_images.find(base); + + // not found, try a module search + if (result.empty()) + result = extra_images.find(module_matcher(base + ".ko")); + + if (result.empty()) { + error = image_not_found; + return image_name; + } + + if (result.size() > 1) { + error = image_multiple_match; + return image_name; + } + + return result[0]; +} diff --git a/libpp/locate_images.h b/libpp/locate_images.h new file mode 100644 index 0000000..c003f9e --- /dev/null +++ b/libpp/locate_images.h @@ -0,0 +1,78 @@ +/** + * @file locate_images.h + * Location of binary images + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef LOCATE_IMAGES_H +#define LOCATE_IMAGES_H + +#include +#include +#include + +#include "image_errors.h" + +/** + * A class containing mappings from an image basename, + * such as 'floppy.ko', to locations in the paths passed + * in to populate(). + * + * The name may exist multiple times; all locations are recorded + * in this container. + */ +class extra_images { +public: + /// add all filenames found in the given paths, recursively + void populate(std::vector const & paths); + + /// base class for matcher functors object + struct matcher { + std::string const & value; + public: + explicit matcher(std::string const & v) : value(v) {} + virtual ~matcher() {} + /// default functor allowing trivial match + virtual bool operator()(std::string const & str) const { + return str == value; + } + }; + + /** + * return a vector of all directories that match the functor + */ + std::vector const find(matcher const & match) const; + + /// return a vector of all directories that match the given name + std::vector const find(std::string const & name) const; + +private: + typedef std::multimap images_t; + typedef images_t::value_type value_type; + typedef images_t::const_iterator const_iterator; + + /// map from image basename to owning directory + images_t images; +}; + +/** + * @param archive_path archive prefix path + * @param extra_images container where all extra candidate filenames are stored + * @param image_name binary image name + * @param error errors are flagged in this passed enum ref + * + * Locate a (number of) matching absolute paths to the given image name. + * If we fail to find the file we fill in error and return the original string. + */ +std::string const +find_image_path(std::string const & archive_path, + std::string const & image_name, + extra_images const & extra_images, + image_error & error); + +#endif /* LOCATE_IMAGES_H */ diff --git a/libpp/name_storage.cpp b/libpp/name_storage.cpp new file mode 100644 index 0000000..99e0e90 --- /dev/null +++ b/libpp/name_storage.cpp @@ -0,0 +1,65 @@ +/** + * @file name_storage.cpp + * Storage of global names (filenames and symbols) + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include + +#include "name_storage.h" +#include "demangle_symbol.h" +#include "file_manip.h" +#include "string_manip.h" + +using namespace std; + +image_name_storage image_names; +debug_name_storage debug_names; +symbol_name_storage symbol_names; + + +string const & image_name_storage::basename(image_name_id id) const +{ + stored_name const & n = get(id); + if (n.name_processed.empty()) { + n.name_processed = op_basename(n.name); + } + return n.name_processed; +} + + +string const & debug_name_storage::basename(debug_name_id id) const +{ + stored_name const & n = get(id); + if (n.name_processed.empty()) { + n.name_processed = op_basename(n.name); + } + return n.name_processed; +} + + +string const & symbol_name_storage::demangle(symbol_name_id id) const +{ + stored_name const & n = get(id); + if (!n.name_processed.empty() || n.name.empty()) + return n.name_processed; + + if (n.name[0] != '?') { + n.name_processed = demangle_symbol(n.name); + return n.name_processed; + } + + if (n.name.length() < 2 || n.name[1] != '?') { + n.name_processed = "(no symbols)"; + return n.name_processed; + } + + n.name_processed = "anonymous symbol from section "; + n.name_processed += ltrim(n.name, "?"); + return n.name_processed; +} diff --git a/libpp/name_storage.h b/libpp/name_storage.h new file mode 100644 index 0000000..0e278cb --- /dev/null +++ b/libpp/name_storage.h @@ -0,0 +1,102 @@ +/** + * @file name_storage.h + * Type-safe unique storage of global names (filenames and symbols) + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef NAME_STORAGE_H +#define NAME_STORAGE_H + +#include + +#include "unique_storage.h" + +/// store original name and processed name +struct stored_name { + stored_name(std::string const & n = std::string()) + : name(n) {} + + bool operator<(stored_name const & rhs) const { + return name < rhs.name; + } + + std::string name; + mutable std::string name_processed; +}; + + +/// partial specialization for unique storage of names +template struct name_storage : unique_storage { + + typedef typename unique_storage::id_value id_value; + + std::string const & name(id_value const & id) const { + return unique_storage::get(id).name; + }; +}; + + +class debug_name_tag; +/// a debug filename +typedef name_storage::id_value debug_name_id; + +/// class storing a set of shared debug name (source filename) +struct debug_name_storage : name_storage { + /// return the basename for the given ID + std::string const & basename(debug_name_id id) const; +}; + + +class image_name_tag; +/// an image name +typedef name_storage::id_value image_name_id; + +/// class storing a set of shared image name +struct image_name_storage : name_storage { + /// return the basename name for the given ID + std::string const & basename(image_name_id) const; +}; + + +class symbol_name_tag; +/// a (demangled) symbol +typedef name_storage::id_value symbol_name_id; + +/// class storing a set of shared symbol name +struct symbol_name_storage : name_storage { + /// return the demangled name for the given ID + std::string const & demangle(symbol_name_id id) const; +}; + + +/// for images +extern image_name_storage image_names; + +/// for debug filenames i.e. source filename +extern debug_name_storage debug_names; + +/// for symbols +extern symbol_name_storage symbol_names; + + +/** + * debug name specialisation for comparison. + * + * We compare by name rather by id since what user will see are + * filename and when the criteria "samples count" give identical + * result it's better to obtain result sorted by the user visible + * property filename rather than by an obscure, invisible from user + * point of view, file identifier property + */ +template<> inline bool +debug_name_id::operator<(debug_name_id const & rhs) const +{ + return debug_names.name(*this) < debug_names.name(rhs); +} + +#endif /* !NAME_STORAGE_H */ diff --git a/libpp/op_header.cpp b/libpp/op_header.cpp new file mode 100644 index 0000000..f0bacac --- /dev/null +++ b/libpp/op_header.cpp @@ -0,0 +1,184 @@ +/** + * @file op_header.cpp + * various free function acting on a sample file header + * + * @remark Copyright 2004 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include +#include +#include + +#include "op_exception.h" +#include "odb.h" +#include "op_cpu_type.h" +#include "op_file.h" +#include "op_header.h" +#include "op_events.h" +#include "string_manip.h" + +using namespace std; + +void op_check_header(opd_header const & h1, opd_header const & h2, + string const & filename) +{ + if (h1.mtime != h2.mtime) { + ostringstream os; + os << "header timestamps are different (" + << h1.mtime << ", " << h2.mtime << ") for " + << filename << "\n"; + throw op_fatal_error(os.str()); + } + + if (h1.is_kernel != h2.is_kernel) { + ostringstream os; + os << "header is_kernel flags are different for " + << filename << "\n"; + throw op_fatal_error(os.str()); + } + + if (h1.anon_start != h2.anon_start) { + ostringstream os; + os << "header anon_start flags are different for " + << filename << "\n"; + throw op_fatal_error(os.str()); + } + + // Note that we don't check CPU speed since that can vary + // freely on the same machine +} + + +namespace { + +set warned_files; + +} + + +void check_mtime(string const & file, opd_header const & header) +{ + time_t const newmtime = op_get_mtime(file.c_str()); + + if (newmtime == header.mtime) + return; + + if (warned_files.find(file) != warned_files.end()) + return; + + warned_files.insert(file); + + // Files we couldn't get mtime of have zero mtime + if (!header.mtime) { + cerr << "warning: could not check that the binary file " + << file << " has not been modified since " + "the profile was taken. Results may be inaccurate.\n"; + } else { + static bool warned_already = false; + + cerr << "warning: the last modified time of the binary file " + "does not match that of the sample file for " << file + << "\n"; + + if (!warned_already) { + cerr << "Either this is the wrong binary or the binary " + "has been modified since the sample file was created.\n"; + warned_already = true; + } + } +} + + +opd_header const read_header(string const & sample_filename) +{ + odb_t samples_db; + + int rc = odb_open(&samples_db, sample_filename.c_str(), ODB_RDONLY, + sizeof(struct opd_header)); + + if (rc) + throw op_fatal_error(sample_filename + ": " + strerror(rc)); + + opd_header head = *static_cast(samples_db.data->base_memory); + + odb_close(&samples_db); + + return head; +} + + +namespace { + +string const op_print_event(op_cpu cpu_type, u8 type, u16 um, u32 count) +{ + string str; + + if (cpu_type == CPU_TIMER_INT) { + str += "Profiling through timer interrupt"; + return str; + } + + struct op_event * event = op_find_event(cpu_type, type); + + if (!event) { + cerr << "Could not locate event " << int(type) << endl; + return str; + } + + char const * um_desc = 0; + + for (size_t i = 0; i < event->unit->num; ++i) { + if (event->unit->um[i].value == um) + um_desc = event->unit->um[i].desc; + } + + str += string("Counted ") + event->name; + str += string(" events (") + event->desc + ")"; + + if (cpu_type != CPU_RTC) { + str += " with a unit mask of 0x"; + + ostringstream ss; + ss << hex << setw(2) << setfill('0') << unsigned(um); + str += ss.str(); + + str += " ("; + str += um_desc ? um_desc : "multiple flags"; + str += ")"; + } + + str += " count " + op_lexical_cast(count); + return str; +} + +} + + +string const describe_header(opd_header const & header) +{ + op_cpu cpu = static_cast(header.cpu_type); + + return op_print_event(cpu, header.ctr_event, + header.ctr_um, header.ctr_count); +} + + +string const describe_cpu(opd_header const & header) +{ + op_cpu cpu = static_cast(header.cpu_type); + + string str; + str += string("CPU: ") + op_get_cpu_type_str(cpu); + str += ", speed "; + + ostringstream ss; + ss << header.cpu_speed; + str += ss.str() + " MHz (estimated)"; + return str; +} diff --git a/libpp/op_header.h b/libpp/op_header.h new file mode 100644 index 0000000..0e109bc --- /dev/null +++ b/libpp/op_header.h @@ -0,0 +1,54 @@ +/** + * @file op_header.h + * various free function acting on a sample file header + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_HEADER_H +#define OP_HEADER_H + +#include +#include + +#include "op_sample_file.h" + +/** + * @param h1 sample file header + * @param h2 sample file header + * @param filename sample filename + * + * check that the h1 and h2 are coherent (same size, same mtime etc.) + * all error are fatal + */ +void op_check_header(opd_header const & h1, opd_header const & h2, + std::string const & filename); + +/** + * check mtime of samples file header against file + * all error are fatal + */ +void check_mtime(std::string const & file, opd_header const & header); + +/** + * @param sample_filename the sample to open + * + * Return the header of this sample file. Only the magic number is checked + * the version number is not checked. All error are fatal + */ +opd_header const read_header(std::string const & sample_filename); + +/** + * output a readable form of header, this don't include the cpu type + * and speed + */ +std::string const describe_header(opd_header const & header); + +/// output a readable form of cpu type and speed +std::string const describe_cpu(opd_header const & header); + +#endif // OP_HEADER_H diff --git a/libpp/parse_filename.cpp b/libpp/parse_filename.cpp new file mode 100644 index 0000000..1593b94 --- /dev/null +++ b/libpp/parse_filename.cpp @@ -0,0 +1,211 @@ +/** + * @file parse_filename.cpp + * Split a sample filename into its constituent parts + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#include +#include +#include +#include + +#include "parse_filename.h" +#include "file_manip.h" +#include "string_manip.h" + +using namespace std; + +namespace { + +// PP:3.19 event_name.count.unitmask.tgid.tid.cpu +parsed_filename parse_event_spec(string const & event_spec) +{ + typedef vector parts_type; + typedef parts_type::size_type size_type; + + size_type const nr_parts = 6; + + parts_type parts = separate_token(event_spec, '.'); + + if (parts.size() != nr_parts) { + throw invalid_argument("parse_event_spec(): bad event specification: " + event_spec); + } + + for (size_type i = 0; i < nr_parts ; ++i) { + if (parts[i].empty()) { + throw invalid_argument("parse_event_spec(): bad event specification: " + event_spec); + } + } + + parsed_filename result; + + size_type i = 0; + result.event = parts[i++]; + result.count = parts[i++]; + result.unitmask = parts[i++]; + result.tgid = parts[i++]; + result.tid = parts[i++]; + result.cpu = parts[i++]; + + return result; +} + + +/** + * @param component path component + * + * remove from path_component all directory left to {root}, {kern} or {anon} + */ +void remove_base_dir(vector & path) +{ + vector::iterator it; + for (it = path.begin(); it != path.end(); ++it) { + if (*it == "{root}" || *it == "{kern}" || *it == "{anon}") + break; + } + + path.erase(path.begin(), it); +} + + +/// Handle an anon region. Pretty print the details. +string const parse_anon(string const & str) +{ + vector parts = separate_token(str, '.'); + if (parts.size() != 3) + throw invalid_argument("parse_anon() invalid name: " + str); + + string ret = "anon (tgid:"; + ret += parts[0] + " range:" + parts[1] + "-" + parts[2] + ")"; + return ret; +} + + +} // anonymous namespace + + +/* + * valid filename are variations on: + * + * {kern}/name/event_spec + * {root}/path/to/bin/{dep}/{root}/path/to/bin/event_spec + * {root}/path/to/bin/{dep}/{anon}/pid.start.end/event_spec + * {root}/path/to/bin/{dep}/{kern}/name/event_spec + * {root}/path/to/bin/{dep}/{root}/path/to/bin/{cg}/{root}/path/to/bin/event_spec + + * + * where /name/ denote a unique path component + */ +parsed_filename parse_filename(string const & filename) +{ + string::size_type pos = filename.find_last_of('/'); + if (pos == string::npos) { + throw invalid_argument("parse_filename() invalid filename: " + + filename); + } + string event_spec = filename.substr(pos + 1); + string filename_spec = filename.substr(0, pos); + + parsed_filename result = parse_event_spec(event_spec); + + result.filename = filename; + + vector path = separate_token(filename_spec, '/'); + + remove_base_dir(path); + + // pp_interface PP:3.19 to PP:3.23 path must start either with {root} + // or {kern} and we must found at least 2 component, remove_base_dir() + // return an empty path if {root} or {kern} are not found + if (path.size() < 2) { + throw invalid_argument("parse_filename() invalid filename: " + + filename); + } + + size_t i; + for (i = 1 ; i < path.size() ; ++i) { + if (path[i] == "{dep}") + break; + + result.image += "/" + path[i]; + } + + if (i == path.size()) { + throw invalid_argument("parse_filename() invalid filename: " + + filename); + } + + // skip "{dep}" + ++i; + + // PP:3.19 {dep}/ must be followed by {kern}/, {root}/ or {anon}/ + if (path[i] != "{kern}" && path[i] != "{root}" && path[i] != "{anon}") { + throw invalid_argument("parse_filename() invalid filename: " + + filename); + } + + bool anon = path[i] == "{anon}"; + + // skip "{root}", "{kern}" or "{anon}" + ++i; + + for (; i < path.size(); ++i) { + if (path[i] == "{cg}") + break; + + if (anon) { + result.lib_image = parse_anon(path[i++]); + break; + } + result.lib_image += "/" + path[i]; + } + + if (i == path.size()) + return result; + + // skip "{cg}" + ++i; + if (i == path.size() || + (path[i] != "{kern}" && path[i] != "{root}" && path[i] != "{anon}")) { + throw invalid_argument("parse_filename() invalid filename: " + + filename); + } + + // skip "{root}", "{kern}" or "{anon}" + anon = path[i] == "{anon}"; + ++i; + + if (anon) { + result.cg_image = parse_anon(path[i++]); + } else { + for (; i < path.size(); ++i) + result.cg_image += "/" + path[i]; + } + + return result; +} + +bool parsed_filename::profile_spec_equal(parsed_filename const & parsed) +{ + return event == parsed.event && + count == parsed.count && + unitmask == parsed.unitmask && + tgid == parsed.tgid && + tid == parsed.tid && + cpu == parsed.tid; +} + +ostream & operator<<(ostream & out, parsed_filename const & data) +{ + out << data.filename << endl; + out << data.image << " " << data.lib_image << " " + << data.event << " " << data.count << " " + << data.unitmask << " " << data.tgid << " " + << data.tid << " " << data.cpu << endl; + + return out; +} diff --git a/libpp/parse_filename.h b/libpp/parse_filename.h new file mode 100644 index 0000000..79c06aa --- /dev/null +++ b/libpp/parse_filename.h @@ -0,0 +1,60 @@ +/** + * @file parse_filename.h + * Split a sample filename into its constituent parts + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#ifndef PARSE_FILENAME_H +#define PARSE_FILENAME_H + +#include + +/** + * a convenience class to store result of parse_filename() + */ +struct parsed_filename +{ + std::string image; + std::string lib_image; + /// destination image for call graph file, empty if this sample + /// file is not a callgraph file. + std::string cg_image; + std::string event; + std::string count; + std::string unitmask; + std::string tgid; + std::string tid; + std::string cpu; + + /// return true if the profile specification are identical. + bool profile_spec_equal(parsed_filename const & parsed); + + /** + * the original sample filename from which the + * above components are built + */ + std::string filename; +}; + + +/// debugging helper +std::ostream & operator<<(std::ostream &, parsed_filename const &); + + +/** + * parse a sample filename + * @param filename in: a sample filename + * + * filename is split into constituent parts, the lib_image is optional + * and can be empty on successfull call. All other error are fatal. + * Filenames are encoded as according to PP:3.19 to PP:3.25 + * + * all errors throw an std::invalid_argument exception + */ +parsed_filename parse_filename(std::string const & filename); + +#endif /* !PARSE_FILENAME_H */ diff --git a/libpp/populate.cpp b/libpp/populate.cpp new file mode 100644 index 0000000..450673a --- /dev/null +++ b/libpp/populate.cpp @@ -0,0 +1,97 @@ +/** + * @file populate.cpp + * Fill up a profile_container from inverted profiles + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "profile.h" +#include "profile_container.h" +#include "arrange_profiles.h" +#include "op_bfd.h" +#include "op_header.h" +#include "populate.h" + +#include "image_errors.h" + +#include + +using namespace std; + +namespace { + +/// load merged files for one set of sample files +bool +populate_from_files(profile_t & profile, op_bfd const & abfd, + list const & files) +{ + list::const_iterator it = files.begin(); + list::const_iterator const end = files.end(); + + bool found = false; + // we can't handle cg files here obviously + for (; it != end; ++it) { + // A bit ugly but we must accept silently empty sample filename + // since we can create a profile_sample_files for cg file only + // (i.e no sample to the binary) + if (!it->sample_filename.empty()) { + profile.add_sample_file(it->sample_filename); + profile.set_offset(abfd); + found = true; + } + } + + return found; +} + +} // anon namespace + + +void +populate_for_image(string const & archive_path, profile_container & samples, + inverted_profile const & ip, string_filter const & symbol_filter, + bool * has_debug_info) +{ + bool ok = ip.error == image_ok; + + op_bfd abfd(archive_path, ip.image, symbol_filter, ok); + if (!ok && ip.error == image_ok) + ip.error = image_format_failure; + + if (ip.error == image_format_failure) + report_image_error(ip, false); + + opd_header header; + + bool found = false; + for (size_t i = 0; i < ip.groups.size(); ++i) { + list::const_iterator it + = ip.groups[i].begin(); + list::const_iterator const end + = ip.groups[i].end(); + + // we can only share a profile_t amongst each + // image_set's files - this is because it->app_image + // changes, and the .add() would mis-attribute + // to the wrong app_image otherwise + for (; it != end; ++it) { + profile_t profile; + if (populate_from_files(profile, abfd, it->files)) { + header = profile.get_header(); + samples.add(profile, abfd, it->app_image, i); + found = true; + } + } + } + + // we shouldn't check/warn if an archive is used + if (archive_path.empty() && found == true && ip.error == image_ok) + check_mtime(abfd.get_filename(), header); + + if (has_debug_info) + *has_debug_info = abfd.has_debug_info(); +} diff --git a/libpp/populate.h b/libpp/populate.h new file mode 100644 index 0000000..082136f --- /dev/null +++ b/libpp/populate.h @@ -0,0 +1,26 @@ +/** + * @file populate.h + * Fill up a profile_container from inverted profiles + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef POPULATE_H +#define POPULATE_H + +class profile_container; +class inverted_profile; +class string_filter; + + +/// Load all sample file information for exactly one binary image. +void +populate_for_image(std::string const & archive_path, + profile_container & samples, inverted_profile const & ip, + string_filter const & symbol_filter, bool * has_debug_info); + +#endif /* POPULATE_H */ diff --git a/libpp/profile.cpp b/libpp/profile.cpp new file mode 100644 index 0000000..a0007dd --- /dev/null +++ b/libpp/profile.cpp @@ -0,0 +1,165 @@ +/** + * @file profile.cpp + * Encapsulation for samples files over all profile classes + * belonging to the same binary image + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include + +#include +#include +#include + +#include + +#include "op_exception.h" +#include "op_header.h" +#include "op_config.h" +#include "op_sample_file.h" +#include "profile.h" +#include "op_bfd.h" +#include "cverb.h" + +using namespace std; + +profile_t::profile_t() + : start_offset(0) +{ +} + + +// static member +unsigned int profile_t::sample_count(string const & filename) +{ + odb_t samples_db; + + open_sample_file(filename, samples_db); + + unsigned int count = 0; + + odb_node_nr_t node_nr, pos; + odb_node_t * node = odb_get_iterator(&samples_db, &node_nr); + for (pos = 0; pos < node_nr; ++pos) { + if (node[pos].key) + count += node[pos].value; + } + + odb_close(&samples_db); + + return count; +} + +//static member +void profile_t::open_sample_file(string const & filename, odb_t & db) +{ + int rc = odb_open(&db, filename.c_str(), ODB_RDONLY, + sizeof(struct opd_header)); + + if (rc) + throw op_fatal_error(filename + ": " + strerror(rc)); + + opd_header const & head = + *static_cast(odb_get_data(&db)); + + if (head.version != OPD_VERSION) { + ostringstream os; + os << "oprofpp: samples files version mismatch, are you " + << "running a daemon and post-profile tools with version " + << "mismatch ?\n"; + throw op_fatal_error(os.str()); + } +} + +void profile_t::add_sample_file(string const & filename) +{ + odb_t samples_db; + + open_sample_file(filename, samples_db); + + opd_header const & head = + *static_cast(odb_get_data(&samples_db)); + + // if we already read a sample file header pointer is non null + if (file_header.get()) + op_check_header(head, *file_header, filename); + + file_header.reset(new opd_header(head)); + + odb_node_nr_t node_nr, pos; + odb_node_t * node = odb_get_iterator(&samples_db, &node_nr); + + for (pos = 0; pos < node_nr; ++pos) { + if (node[pos].key) { + ordered_samples_t::iterator it = + ordered_samples.find(node[pos].key); + if (it != ordered_samples.end()) { + it->second += node[pos].value; + } else { + ordered_samples_t::value_type + val(node[pos].key, node[pos].value); + ordered_samples.insert(val); + } + } + } + + odb_close(&samples_db); +} + + +void profile_t::set_offset(op_bfd const & abfd) +{ + opd_header const & header = get_header(); + if (header.anon_start || header.is_kernel) + start_offset = abfd.get_start_offset(header.anon_start); + cverb << (vdebug) << "start_offset is now " << start_offset << endl; +} + + +profile_t::iterator_pair +profile_t::samples_range(odb_key_t start, odb_key_t end) const +{ + // Check the start position isn't before start_offset: + // this avoids wrapping/underflowing start/end. + // This can happen on e.g. ARM kernels, where .init is + // mapped before .text - we just have to skip any such + // .init symbols. + if (start < start_offset) { + return make_pair(const_iterator(ordered_samples.end(), 0), + const_iterator(ordered_samples.end(), 0)); + } + + start -= start_offset; + end -= start_offset; + + // sanity check if start > end caller will enter into an infinite loop + if (start > end) { + throw op_fatal_error("profile_t::samples_range(): start > end" + " something wrong with kernel or module layout ?\n" + "please report problem to " + "oprofile-list@lists.sourceforge.net"); + } + + ordered_samples_t::const_iterator first = + ordered_samples.lower_bound(start); + ordered_samples_t::const_iterator last = + ordered_samples.lower_bound(end); + + return make_pair(const_iterator(first, start_offset), + const_iterator(last, start_offset)); +} + + +profile_t::iterator_pair profile_t::samples_range() const +{ + ordered_samples_t::const_iterator first = ordered_samples.begin(); + ordered_samples_t::const_iterator last = ordered_samples.end(); + + return make_pair(const_iterator(first, start_offset), + const_iterator(last, start_offset)); +} diff --git a/libpp/profile.h b/libpp/profile.h new file mode 100644 index 0000000..237e354 --- /dev/null +++ b/libpp/profile.h @@ -0,0 +1,176 @@ +/** + * @file profile.h + * Encapsulation for samples files over all profile classes + * belonging to the same binary image + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef PROFILE_H +#define PROFILE_H + +#include +#include +#include + +#include "odb.h" +#include "op_types.h" +#include "utility.h" + +class opd_header; +class op_bfd; + +/** + * Class containing a single sample file contents. + * i.e. set of count values for VMA offsets for + * a particular binary. + */ +class profile_t : noncopyable { +public: + /** + * profile_t - construct an empty profile_t object + */ + profile_t(); + + /// return true if no sample file has been loaded + bool empty() const { return !file_header.get(); } + + /// return the header of the last opened samples file + opd_header const & get_header() const { + return *file_header; + } + + /** + * count samples count w/o recording them + * @param filename sample filename + * + * convenience interface for raw access to sample count w/o recording + * them. It's placed here so all access to samples files go through + * profile_t static or non static member. + */ + static unsigned int sample_count(std::string const & filename); + + /** + * cumulate sample file to our container of samples + * @param filename sample file name + * + * store samples for one sample file, sample file header is sanitized. + * + * all error are fatal + */ + void add_sample_file(std::string const & filename); + + /// Set an appropriate start offset, see comments below. + void set_offset(op_bfd const & abfd); + + class const_iterator; + typedef std::pair iterator_pair; + + /** + * @param start start offset + * @param end end offset + * + * return an iterator pair to [start, end) range + */ + iterator_pair + samples_range(odb_key_t start, odb_key_t end) const; + + /// return a pair of iterator for all samples + iterator_pair samples_range() const; + +private: + /// helper for sample_count() and add_sample_file(). All error launch + /// an exception. + static void + open_sample_file(std::string const & filename, odb_t &); + + /// copy of the samples file header + scoped_ptr file_header; + + /// storage type for samples sorted by eip + typedef std::map ordered_samples_t; + + /** + * Samples are stored in hash table, iterating over hash table don't + * provide any ordering, the above count() interface rely on samples + * ordered by eip. This map is only a temporary storage where samples + * are ordered by eip. + */ + ordered_samples_t ordered_samples; + + /** + * For certain profiles, such as kernel/modules, and anon + * regions with a matching binary, this value is non-zero, + * and represents the file offset of the relevant section. + * + * For kernel profiles, this is done because we use the information + * provided in /proc/ksyms, which only gives the mapped position of + * .text, and the symbol _text from vmlinux. This value is used to fix + * up the sample offsets for kernel code as a result of this difference + * + * In user-space samples, the sample offset is from the start of the + * mapped file, as seen in /proc/pid/maps. This is fine for + * mappings of permanent files, but with anon mappings, we need + * to adjust the key values to be a file offset against the + * *binary* (if there is one). This can obviously be different. + * So we pass our anon mapping start VMA to op_bfd, which looks + * for a section with that VMA, then returns the section's + * filepos. So all is good. + * + * Finally, note that for cg we can't use this inside the + * profile_t, as we're storing two offsets in the key value. So + * we do it later in that case. + * + * Phew. + */ + u32 start_offset; +}; + + +// It will be easier to derive profile_t::const_iterator from +// std::iterator but this doesn't +// work for gcc <= 2.95 so we provide the neccessary typedef in the hard way. +// See ISO C++ 17.4.3.1 § 1 and 14.7.3 § 9. +namespace std { + template <> + struct iterator_traits { + typedef ptrdiff_t difference_type; + typedef unsigned int value_type; + typedef unsigned int * pointer; + typedef unsigned int & reference; + typedef input_iterator_tag iterator_category; + }; +} + + +class profile_t::const_iterator +{ + typedef ordered_samples_t::const_iterator iterator_t; +public: + const_iterator() : start_offset(0) {} + const_iterator(iterator_t it_, u32 start_offset_) + : it(it_), start_offset(start_offset_) {} + + unsigned int operator*() const { return it->second; } + const_iterator & operator++() { ++it; return *this; } + + odb_key_t vma() const { return it->first + start_offset; } + unsigned int count() const { return **this; } + + bool operator!=(const_iterator const & rhs) const { + return it != rhs.it; + } + bool operator==(const_iterator const & rhs) const { + return it == rhs.it; + } + +private: + iterator_t it; + u32 start_offset; +}; + +#endif /* !PROFILE_H */ diff --git a/libpp/profile_container.cpp b/libpp/profile_container.cpp new file mode 100644 index 0000000..b0422d1 --- /dev/null +++ b/libpp/profile_container.cpp @@ -0,0 +1,318 @@ +/** + * @file profile_container.cpp + * profile file container + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include +#include +#include +#include +#include +#include + +#include "symbol.h" +#include "op_header.h" +#include "profile.h" +#include "symbol_functors.h" +#include "profile_container.h" +#include "sample_container.h" +#include "symbol_container.h" + +using namespace std; + +namespace { + +struct filename_by_samples { + filename_by_samples(debug_name_id id, double percent_) + : filename(id), percent(percent_) + {} + + bool operator<(filename_by_samples const & lhs) const { + if (percent != lhs.percent) + return percent < lhs.percent; + return filename < lhs.filename; + } + + debug_name_id filename; + // ratio of samples which belongs to this filename. + double percent; +}; + +} // anon namespace + + +profile_container::profile_container(bool debug_info_, bool need_details_) + : + symbols(new symbol_container), + samples(new sample_container), + debug_info(debug_info_), + need_details(need_details_) +{ +} + + +profile_container::~profile_container() +{ +} + + +// Post condition: +// the symbols/samples are sorted by increasing vma. +// the range of sample_entry inside each symbol entry are valid +// the samples_by_file_loc member var is correctly setup. +void profile_container::add(profile_t const & profile, + op_bfd const & abfd, string const & app_name, + size_t pclass) +{ + string const image_name = abfd.get_filename(); + + for (symbol_index_t i = 0; i < abfd.syms.size(); ++i) { + + unsigned long start, end; + symbol_entry symb_entry; + + abfd.get_symbol_range(i, start, end); + + profile_t::iterator_pair p_it = + profile.samples_range(start, end); + + u32 count = accumulate(p_it.first, p_it.second, 0); + + // skip entries with no samples + if (count == 0) + continue; + + symb_entry.sample.counts[pclass] = count; + total_count[pclass] += count; + + symb_entry.size = end - start; + + symb_entry.name = symbol_names.create(abfd.syms[i].name()); + + symb_entry.sample.file_loc.linenr = 0; + if (debug_info) { + string filename; + if (abfd.get_linenr(i, start, filename, + symb_entry.sample.file_loc.linenr)) { + symb_entry.sample.file_loc.filename = + debug_names.create(filename); + } + } + + symb_entry.image_name = image_names.create(image_name); + symb_entry.app_name = image_names.create(app_name); + + bfd_vma base_vma = abfd.syms[i].vma(); + + symb_entry.sample.vma = abfd.sym_offset(i, start) + base_vma; + + symbol_entry const * symbol = symbols->insert(symb_entry); + + if (need_details) { + add_samples(abfd, i, p_it, symbol, pclass); + } + } +} + + +void +profile_container::add_samples(op_bfd const & abfd, symbol_index_t sym_index, + profile_t::iterator_pair const & p_it, + symbol_entry const * symbol, size_t pclass) +{ + bfd_vma base_vma = abfd.syms[sym_index].vma(); + + profile_t::const_iterator it; + for (it = p_it.first; it != p_it.second ; ++it) { + sample_entry sample; + + sample.counts[pclass] = it.count(); + + sample.file_loc.linenr = 0; + if (debug_info) { + string filename; + if (abfd.get_linenr(sym_index, it.vma(), filename, + sample.file_loc.linenr)) { + sample.file_loc.filename = + debug_names.create(filename); + } + } + + sample.vma = abfd.sym_offset(sym_index, it.vma()) + base_vma; + + samples->insert(symbol, sample); + } +} + + +symbol_collection const +profile_container::select_symbols(symbol_choice & choice) const +{ + symbol_collection result; + + double const threshold = choice.threshold / 100.0; + + symbol_container::symbols_t::iterator it = symbols->begin(); + symbol_container::symbols_t::iterator const end = symbols->end(); + + for (; it != end; ++it) { + if (choice.match_image + && (image_names.name(it->image_name) != choice.image_name)) + continue; + + double const percent = + op_ratio(it->sample.counts[0], total_count[0]); + + if (percent >= threshold) { + result.push_back(&*it); + + choice.hints = it->output_hint(choice.hints); + } + } + + return result; +} + + +vector const +profile_container::select_filename(double threshold) const +{ + set filename_set; + + threshold /= 100.0; + + // Trying to iterate on symbols to create the set of filenames which + // contain sample does not work: a symbol can contain samples and this + // symbol is in a source file that contain zero sample because only + // inline function in this source file contains samples. + sample_container::samples_iterator sit = samples->begin(); + sample_container::samples_iterator const send = samples->end(); + + for (; sit != send; ++sit) { + debug_name_id name_id = sit->second.file_loc.filename; + if (name_id.set()) { + filename_set.insert(name_id); + } + } + + // Give a sort order on filename for the selected pclass. + vector file_by_samples; + + set::const_iterator it = filename_set.begin(); + set::const_iterator const end = filename_set.end(); + for (; it != end; ++it) { + // FIXME: is samples_count() the right interface now ? + count_array_t counts = samples_count(*it); + + double const ratio = op_ratio(counts[0], total_count[0]); + filename_by_samples const f(*it, ratio); + + file_by_samples.push_back(f); + } + + // now sort the file_by_samples entry. + sort(file_by_samples.begin(), file_by_samples.end()); + + // 2.91.66 doesn't like const_reverse_iterator in this context + vector::reverse_iterator cit + = file_by_samples.rbegin(); + vector::reverse_iterator const cend + = file_by_samples.rend(); + + vector result; + for (; cit != cend; ++cit) { + if (cit->percent >= threshold) + result.push_back(cit->filename); + } + + return result; +} + + +count_array_t profile_container::samples_count() const +{ + return total_count; +} + + +// Rest here are delegated to our private implementation. + +symbol_entry const * +profile_container::find_symbol(string const & image_name, bfd_vma vma) const +{ + return symbols->find_by_vma(image_name, vma); +} + + +symbol_entry const * +profile_container::find_symbol(debug_name_id filename, size_t linenr) const +{ + return symbols->find(filename, linenr); +} + + +sample_entry const * +profile_container::find_sample(symbol_entry const * symbol, bfd_vma vma) const +{ + return samples->find_by_vma(symbol, vma); +} + + +count_array_t profile_container::samples_count(debug_name_id filename_id) const +{ + return samples->accumulate_samples(filename_id); +} + + +count_array_t profile_container::samples_count(debug_name_id filename, + size_t linenr) const +{ + return samples->accumulate_samples(filename, linenr); +} + + +sample_container::samples_iterator +profile_container::begin(symbol_entry const * symbol) const +{ + return samples->begin(symbol); +} + + +sample_container::samples_iterator +profile_container::end(symbol_entry const * symbol) const +{ + return samples->end(symbol); +} + + +sample_container::samples_iterator profile_container::begin() const +{ + return samples->begin(); +} + + +sample_container::samples_iterator profile_container::end() const +{ + return samples->end(); +} + +symbol_entry const * profile_container::find(symbol_entry const & symbol) const +{ + return symbols->find(symbol); +} + +symbol_container::symbols_t::iterator profile_container::begin_symbol() const +{ + return symbols->begin(); +} + +symbol_container::symbols_t::iterator profile_container::end_symbol() const +{ + return symbols->end(); +} diff --git a/libpp/profile_container.h b/libpp/profile_container.h new file mode 100644 index 0000000..153ecfc --- /dev/null +++ b/libpp/profile_container.h @@ -0,0 +1,175 @@ +/** + * @file profile_container.h + * Container associating symbols and samples + * + * @remark Copyright 2002, 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef PROFILE_CONTAINER_H +#define PROFILE_CONTAINER_H + +#include +#include + +#include "profile.h" +#include "utility.h" +#include "op_bfd.h" +#include "sample_container.h" +#include "symbol_container.h" +#include "format_flags.h" + +class string_filter; +class symbol_entry; +class sample_entry; + +/** + * Store multiple samples files belonging to the same profiling session. + * This is the main container capable of holding the profiles for arbitrary + * binary images and arbitrary profile classes. + */ +class profile_container : noncopyable { +public: + /** + * Build an object to store information on samples. All parameters + * acts as hint for what you will request after recording samples and + * so allow optimizations during recording the information. + * + * @param debug_info If true line numbers and source files are recorded. + * + * @param need_details If true if we need to record all samples or to + * to record them at symbol level. + */ + profile_container(bool debug_info, bool need_details); + + ~profile_container(); + + /** + * add() - record symbols/samples in the underlying container + * + * @param profile the samples files container + * @param abfd the associated bfd object + * @param app_name the owning application name of sample + * @param pclass the profile class to add results for + * + * add() is an helper for delayed ctor. Take care you can't safely + * make any call to add after any other member function call. + * Obviously you can add only samples files which are coherent (same + * sampling rate, same events etc.) + */ + void add(profile_t const & profile, op_bfd const & abfd, + std::string const & app_name, size_t pclass); + + /// Find a symbol from its image_name, vma, return zero if no symbol + /// for this image at this vma + symbol_entry const * find_symbol(std::string const & image_name, + bfd_vma vma) const; + + /// Find a symbol from its filename, linenr, return zero if no symbol + /// at this location + symbol_entry const * find_symbol(debug_name_id filename, + size_t linenr) const; + + /// Find a sample by its symbol, vma, return zero if there is no sample + /// at this vma + sample_entry const * find_sample(symbol_entry const * symbol, + bfd_vma vma) const; + + /// Find a symbol. Return NULL if not found. + symbol_entry const * find(symbol_entry const & symbol) const; + + /// used for select_symbols() + struct symbol_choice { + symbol_choice() + : hints(cf_none), threshold(0.0), match_image(false) {} + + /// hints filled in + column_flags hints; + /// percentage threshold + double threshold; + /// match the image name only + bool match_image; + /// owning image name + std::string image_name; + }; + + /** + * select_symbols - create a set of symbols sorted by sample count + * @param choice parameters to use/fill in when selecting + */ + symbol_collection const select_symbols(symbol_choice & choice) const; + + /// Like select_symbols for filename without allowing sort by vma. + std::vector const select_filename(double threshold) const; + + /// return the total number of samples + count_array_t samples_count() const; + + /// Get the samples count which belongs to filename. Return 0 if + /// no samples found. + count_array_t samples_count(debug_name_id filename_id) const; + /// Get the samples count which belongs to filename, linenr. Return + /// 0 if no samples found. + count_array_t samples_count(debug_name_id filename, + size_t linenr) const; + + /// return an iterator to the first symbol + symbol_container::symbols_t::iterator begin_symbol() const; + /// return an iterator to the last symbol + symbol_container::symbols_t::iterator end_symbol() const; + + /// return iterator to the first samples + sample_container::samples_iterator begin() const; + /// return iterator to the last samples + sample_container::samples_iterator end() const; + + /// return iterator to the first samples for this symbol + sample_container::samples_iterator begin(symbol_entry const *) const; + /// return iterator to the last samples for this symbol + sample_container::samples_iterator end(symbol_entry const *) const; + +private: + /// helper for add() + void add_samples(op_bfd const & abfd, symbol_index_t sym_index, + profile_t::iterator_pair const &, + symbol_entry const * symbol, size_t pclass); + + /** + * create an unique artificial symbol for an offset range. The range + * is only a hint of the maximum size of the created symbol. We + * give to the symbol an unique name as ?image_file_name#order and + * a range up to the nearest of syms or for the whole range if no + * syms exist after the start offset. the end parameter is updated + * to reflect the symbol range. + * + * The rationale here is to try to create symbols for alignment between + * function as little as possible and to create meaningfull symbols + * for special case such image w/o symbol. + */ + std::string create_artificial_symbol(op_bfd const & abfd, u32 start, + u32 & end, size_t & order); + + /// The symbols collected by pp tools sorted by increased vma, provide + /// also a sort order on samples count for each profile class + scoped_ptr symbols; + /// The samples count collected by pp tools sorted by increased vma, + /// provide also a sort order on (filename, linenr) + scoped_ptr samples; + /// build() must count samples count for each profile class so cache it + /// here since user of profile_container often need it later. + count_array_t total_count; + + /** + * Optimization hints for what information we are going to need, + * see the explanation in profile_container() + */ + //@{ + bool debug_info; + bool need_details; + //@} +}; + +#endif /* !PROFILE_CONTAINER_H */ diff --git a/libpp/profile_spec.cpp b/libpp/profile_spec.cpp new file mode 100644 index 0000000..f244e7c --- /dev/null +++ b/libpp/profile_spec.cpp @@ -0,0 +1,447 @@ +/** + * @file profile_spec.cpp + * Contains a PP profile specification + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#include +#include +#include +#include +#include + +#include "file_manip.h" +#include "op_config.h" +#include "profile_spec.h" +#include "string_manip.h" +#include "glob_filter.h" +#include "locate_images.h" +#include "op_exception.h" + +using namespace std; + +namespace { + +// PP:3.7, full path, or relative path. If we can't find it, +// we should maintain the original to maintain the wordexp etc. +string const fixup_image_spec(string const & str, extra_images const & extra) +{ + string dummy_archive_path; + // FIXME: what todo if an error in find_image_path() ? + image_error error; + return find_image_path(dummy_archive_path, str, extra, error); +} + + +void fixup_image_spec(vector & images, extra_images const & extra) +{ + vector::iterator it = images.begin(); + vector::iterator const end = images.end(); + + for (; it != end; ++it) { + *it = fixup_image_spec(*it, extra); + } +} + +} // anon namespace + + +profile_spec::profile_spec(extra_images const & extra) + : extra(extra) +{ + parse_table["archive"] = &profile_spec::parse_archive_path; + parse_table["session"] = &profile_spec::parse_session; + parse_table["session-exclude"] = + &profile_spec::parse_session_exclude; + parse_table["image"] = &profile_spec::parse_image; + parse_table["image-exclude"] = &profile_spec::parse_image_exclude; + parse_table["lib-image"] = &profile_spec::parse_lib_image; + parse_table["event"] = &profile_spec::parse_event; + parse_table["count"] = &profile_spec::parse_count; + parse_table["unit-mask"] = &profile_spec::parse_unitmask; + parse_table["tid"] = &profile_spec::parse_tid; + parse_table["tgid"] = &profile_spec::parse_tgid; + parse_table["cpu"] = &profile_spec::parse_cpu; +} + + +void profile_spec::parse(string const & tag_value) +{ + string value; + action_t action = get_handler(tag_value, value); + if (!action) { + throw invalid_argument("profile_spec::parse(): not " + "a valid tag \"" + tag_value + "\""); + } + + (this->*action)(value); +} + + +bool profile_spec::is_valid_tag(string const & tag_value) +{ + string value; + return get_handler(tag_value, value); +} + + +void profile_spec::set_image_or_lib_name(string const & str) +{ + /* FIXME: what does spec say about this being allowed to be + * a comma list or not ? */ + image_or_lib_image.push_back(fixup_image_spec(str, extra)); +} + + +void profile_spec::parse_archive_path(string const & str) +{ + archive_path = op_realpath(str); +} + + +string profile_spec::get_archive_path() const +{ + return archive_path; +} + + +void profile_spec::parse_session(string const & str) +{ + session = separate_token(str, ','); +} + + +void profile_spec::parse_session_exclude(string const & str) +{ + session_exclude = separate_token(str, ','); +} + + +void profile_spec::parse_image(string const & str) +{ + image = separate_token(str, ','); + fixup_image_spec(image, extra); +} + + +void profile_spec::parse_image_exclude(string const & str) +{ + image_exclude = separate_token(str, ','); +} + + +void profile_spec::parse_lib_image(string const & str) +{ + lib_image = separate_token(str, ','); + fixup_image_spec(image, extra); +} + + +void profile_spec::parse_event(string const & str) +{ + event.set(str); +} + + +void profile_spec::parse_count(string const & str) +{ + count.set(str); +} + + +void profile_spec::parse_unitmask(string const & str) +{ + unitmask.set(str); +} + + +void profile_spec::parse_tid(string const & str) +{ + tid.set(str); +} + + +void profile_spec::parse_tgid(string const & str) +{ + tgid.set(str); +} + + +void profile_spec::parse_cpu(string const & str) +{ + cpu.set(str); +} + + +profile_spec::action_t +profile_spec::get_handler(string const & tag_value, string & value) +{ + string::size_type pos = tag_value.find_first_of(':'); + if (pos == string::npos) { + return 0; + } + + string tag(tag_value.substr(0, pos)); + value = tag_value.substr(pos + 1); + + parse_table_t::const_iterator it = parse_table.find(tag); + if (it == parse_table.end()) { + return 0; + } + + return it->second; +} + + +namespace { + +/// return true if the value from the profile spec may match the comma +/// list +template +bool comma_match(comma_list const & cl, generic_spec const & value) +{ + // if the profile spec is "all" we match the sample file + if (!cl.is_set()) + return true; + + // an "all" sample file should never match specified profile + // spec values + if (!value.is_set()) + return false; + + // now match each profile spec value against the sample file + return cl.match(value.value()); +} + +} + + +bool profile_spec::match(filename_spec const & spec) const +{ + bool matched_by_image_or_lib_image = false; + + // PP:3.19 + if (!image_or_lib_image.empty()) { + // Need the path search for the benefit of modules + // which have "/oprofile" or similar + string simage = fixup_image_spec(spec.image, extra); + string slib_image = fixup_image_spec(spec.lib_image, extra); + glob_filter filter(image_or_lib_image, image_exclude); + if (filter.match(simage) || filter.match(slib_image)) { + matched_by_image_or_lib_image = true; + } + } + + if (!matched_by_image_or_lib_image) { + // PP:3.7 3.8 + if (!image.empty()) { + glob_filter filter(image, image_exclude); + if (!filter.match(spec.image)) { + return false; + } + } else if (!image_or_lib_image.empty()) { + // image.empty() means match all except if user + // specified image_or_lib_image + return false; + } + + // PP:3.9 3.10 + if (!lib_image.empty()) { + glob_filter filter(lib_image, image_exclude); + if (!filter.match(spec.lib_image)) { + return false; + } + } else if (image.empty() && !image_or_lib_image.empty()) { + // lib_image empty means match all except if user + // specified image_or_lib_image *or* we already + // matched this spec through image + return false; + } + } + + if (!matched_by_image_or_lib_image) { + // if we don't match by image_or_lib_image we must try to + // exclude from spec, exclusion from image_or_lib_image has + // been handled above + vector empty; + glob_filter filter(empty, image_exclude); + if (!filter.match(spec.image)) { + return false; + } + if (!spec.lib_image.empty() && !filter.match(spec.lib_image)) { + return false; + } + } + + if (!event.match(spec.event)) + return false; + + if (!count.match(spec.count)) + return false; + + if (!unitmask.match(spec.unitmask)) + return false; + + if (!comma_match(cpu, spec.cpu)) + return false; + + if (!comma_match(tid, spec.tid)) + return false; + + if (!comma_match(tgid, spec.tgid)) + return false; + + return true; +} + + +profile_spec profile_spec::create(list const & args, + extra_images const & extra) +{ + profile_spec spec(extra); + set tag_seen; + + list::const_iterator it = args.begin(); + list::const_iterator end = args.end(); + + for (; it != end; ++it) { + if (spec.is_valid_tag(*it)) { + if (tag_seen.find(*it) != tag_seen.end()) { + throw op_runtime_error("tag specified " + "more than once: " + *it); + } + tag_seen.insert(*it); + spec.parse(*it); + } else { + string const file = op_realpath(*it); + spec.set_image_or_lib_name(file); + } + } + + // PP:3.5 no session given means use the current session. + if (spec.session.empty()) { + spec.session.push_back("current"); + } + + return spec; +} + +namespace { + +vector filter_session(vector const & session, + vector const & session_exclude) +{ + vector result(session); + + if (result.empty()) { + result.push_back("current"); + } + + for (size_t i = 0 ; i < session_exclude.size() ; ++i) { + // FIXME: would we use fnmatch on each item, are we allowed + // to --session=current* ? + vector::iterator it = + find(result.begin(), result.end(), session_exclude[i]); + + if (it != result.end()) { + result.erase(it); + } + } + + return result; +} + + +bool valid_candidate(string const & base_dir, string const & filename, + profile_spec const & spec, bool exclude_dependent, + bool exclude_cg) +{ + if (exclude_cg && filename.find("{cg}") != string::npos) + return false; + + // strip out non sample files + string const & sub = filename.substr(base_dir.size(), string::npos); + if (!is_prefix(sub, "/{root}/") && !is_prefix(sub, "/{kern}/")) + return false; + + filename_spec file_spec(filename); + if (spec.match(file_spec)) { + if (exclude_dependent && file_spec.is_dependent()) + return false; + return true; + } + + return false; +} + +} // anonymous namespace + + +list profile_spec::generate_file_list(bool exclude_dependent, + bool exclude_cg) const +{ + // FIXME: isn't remove_duplicates faster than doing this, then copy() ? + set unique_files; + + vector sessions = filter_session(session, session_exclude); + + if (sessions.empty()) { + ostringstream os; + os << "No session given\n" + << "included session was:\n"; + copy(session.begin(), session.end(), + ostream_iterator(os, "\n")); + os << "excluded session was:\n"; + copy(session_exclude.begin(), session_exclude.end(), + ostream_iterator(os, "\n")); + throw invalid_argument(os.str()); + } + + bool found_file = false; + + vector::const_iterator cit = sessions.begin(); + vector::const_iterator end = sessions.end(); + + for (; cit != end; ++cit) { + if (cit->empty()) + continue; + + string base_dir; + if ((*cit)[0] != '.' && (*cit)[0] != '/') + base_dir = archive_path + OP_SAMPLES_DIR; + base_dir += *cit; + + base_dir = op_realpath(base_dir); + + list files; + create_file_list(files, base_dir, "*", true); + + if (!files.empty()) + found_file = true; + + list::const_iterator it = files.begin(); + list::const_iterator fend = files.end(); + for (; it != fend; ++it) { + if (valid_candidate(base_dir, *it, *this, + exclude_dependent, exclude_cg)) { + unique_files.insert(*it); + } + } + } + + if (!found_file) { + ostringstream os; + os << "No sample file found: try running opcontrol --dump\n" + << "or specify a session containing sample files\n"; + throw op_fatal_error(os.str()); + } + + list result; + copy(unique_files.begin(), unique_files.end(), back_inserter(result)); + + return result; +} diff --git a/libpp/profile_spec.h b/libpp/profile_spec.h new file mode 100644 index 0000000..1e02abb --- /dev/null +++ b/libpp/profile_spec.h @@ -0,0 +1,142 @@ +/** + * @file profile_spec.h + * Contains a PP profile specification + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#ifndef PROFILE_SPEC_H +#define PROFILE_SPEC_H + +#include +#include +#include + +#include "filename_spec.h" +#include "comma_list.h" + +class extra_images; + +/** + * Holds a parsed profile spec composed of tag:value pairs, as given in + * pp_interface documentation. + * + * @internal implemented through a map of string, pointer to function member + * indexed by tag_name. + */ +class profile_spec +{ +public: + /** + * @param args a vector of non options strings + * @param extra extra image paths to search + * + * Factory returning a profile_spec instance storing all valid + * tag:value contained in args vector doing also alias + * substitution, non-valid tag:value options are considered + * as image:value + */ + static profile_spec create(std::list const & args, + extra_images const & extra); + + /** + * @param exclude_dependent whether to exclude dependent sub-images + * @param exclude_cg whether to exclude call graph file + * + * Use the spec to generate the list of candidate sample files. + */ + std::list + generate_file_list(bool exclude_dependent, bool exclude_cg) const; + + /** + * @param file_spec the filename specification to check + * + * return true if filename match the spec. PP:3.24 internal loop + */ + bool match(filename_spec const & file_spec) const; + + /** + * return archive name + * returns an empty string if not using an archive. + */ + std::string get_archive_path() const; + +private: + profile_spec(extra_images const & extra); + + /** + * @param tag_value a "tag:value" to interpret, all error throw an + * invalid_argument exception. + */ + void parse(std::string const & tag_value); + + /** + * @param image an image or a libray name given on command line + * + * Used for e.g. "opreport /bin/mybinary". We don't know yet + * if this is an application or a dependent image. + */ + void set_image_or_lib_name(std::string const & image); + + /** + * @param str a "tag:value" + * + * return true if tag is a valid tag + */ + bool is_valid_tag(std::string const & str); + + /** + * implement tag parsing: PP:3.3 to 3.16 + */ + void parse_archive_path(std::string const &); + void parse_session(std::string const &); + void parse_session_exclude(std::string const &); + void parse_image(std::string const &); + void parse_image_exclude(std::string const &); + void parse_lib_image(std::string const &); + void parse_event(std::string const &); + void parse_count(std::string const &); + void parse_unitmask(std::string const &); + void parse_tid(std::string const &); + void parse_tgid(std::string const &); + void parse_cpu(std::string const &); + + typedef void (profile_spec::*action_t)(std::string const &); + typedef std::map parse_table_t; + parse_table_t parse_table; + + /** + * @param tag_value input "tag:value" string + * @param value if success return the value part of tag_value + * helper for set/is_valid_tag public interface + * + * return null if tag is not valid, else return the pointer to member + * function to apply and the value in value parameter + */ + action_t get_handler(std::string const & tag_value, + std::string & value); + + std::string archive_path; + std::string binary; + std::vector session; + std::vector session_exclude; + std::vector image; + std::vector image_exclude; + std::vector lib_image; + comma_list event; + comma_list count; + comma_list unitmask; + comma_list tid; + comma_list tgid; + comma_list cpu; + // specified by user on command like opreport image1 image2 ... + std::vector image_or_lib_image; + + /// extra search path for images + extra_images const & extra; +}; + +#endif /* !PROFILE_SPEC_H */ diff --git a/libpp/sample_container.cpp b/libpp/sample_container.cpp new file mode 100644 index 0000000..7a9f4af --- /dev/null +++ b/libpp/sample_container.cpp @@ -0,0 +1,140 @@ +/** + * @file sample_container.cpp + * Internal container for samples + * + * @remark Copyright 2002, 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include +#include +#include +#include + +#include "sample_container.h" + +using namespace std; + +namespace { + +// FIXME: efficiency ? +count_array_t add_counts(count_array_t const & counts, + sample_entry const * s) +{ + count_array_t temp(counts); + temp += s->counts; + return temp; +} + +} // namespace anon + + +sample_container::samples_iterator sample_container::begin() const +{ + return samples.begin(); +} + + +sample_container::samples_iterator sample_container::end() const +{ + return samples.end(); +} + + +sample_container::samples_iterator +sample_container::begin(symbol_entry const * symbol) const +{ + samples_storage::key_type key(symbol, 0); + + return samples.lower_bound(key); +} + + +sample_container::samples_iterator +sample_container::end(symbol_entry const * symbol) const +{ + samples_storage::key_type key(symbol, ~bfd_vma(0)); + + return samples.upper_bound(key); +} + + +void sample_container::insert(symbol_entry const * symbol, + sample_entry const & sample) +{ + samples_storage::key_type key(symbol, sample.vma); + + samples_storage::iterator it = samples.find(key); + if (it != samples.end()) { + it->second.counts += sample.counts; + } else { + samples[key] = sample; + } +} + + +count_array_t +sample_container::accumulate_samples(debug_name_id filename_id) const +{ + build_by_loc(); + + sample_entry lower, upper; + + lower.file_loc.filename = upper.file_loc.filename = filename_id; + lower.file_loc.linenr = 0; + upper.file_loc.linenr = INT_MAX; + + typedef samples_by_loc_t::const_iterator iterator; + + iterator it1 = samples_by_loc.lower_bound(&lower); + iterator it2 = samples_by_loc.upper_bound(&upper); + + return accumulate(it1, it2, count_array_t(), add_counts); +} + + +sample_entry const * +sample_container::find_by_vma(symbol_entry const * symbol, bfd_vma vma) const +{ + sample_index_t key(symbol, vma); + samples_iterator it = samples.find(key); + if (it != samples.end()) + return &it->second; + + return 0; +} + + +count_array_t +sample_container::accumulate_samples(debug_name_id filename, + size_t linenr) const +{ + build_by_loc(); + + sample_entry sample; + + sample.file_loc.filename = filename; + sample.file_loc.linenr = linenr; + + typedef pair it_pair; + + it_pair itp = samples_by_loc.equal_range(&sample); + + return accumulate(itp.first, itp.second, count_array_t(), add_counts); +} + + +void sample_container::build_by_loc() const +{ + if (!samples_by_loc.empty()) + return; + + samples_iterator cit = samples.begin(); + samples_iterator end = samples.end(); + for (; cit != end; ++cit) + samples_by_loc.insert(&cit->second); +} diff --git a/libpp/sample_container.h b/libpp/sample_container.h new file mode 100644 index 0000000..74c9ab0 --- /dev/null +++ b/libpp/sample_container.h @@ -0,0 +1,77 @@ +/** + * @file sample_container.h + * Internal implementation of sample container + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef SAMPLE_CONTAINER_H +#define SAMPLE_CONTAINER_H + +#include +#include +#include + +#include "symbol.h" +#include "symbol_functors.h" + +/** + * Arbitrary container of sample entries. Can return + * number of samples for a file or line number and + * return the particular sample information for a VMA. + */ +class sample_container { + typedef std::pair sample_index_t; +public: + typedef std::map samples_storage; + typedef samples_storage::const_iterator samples_iterator; + + /// return iterator to the first samples for this symbol + samples_iterator begin(symbol_entry const *) const; + /// return iterator to the last samples for this symbol + samples_iterator end(symbol_entry const *) const; + + /// return iterator to the first samples + samples_iterator begin() const; + /// return iterator to the last samples + samples_iterator end() const; + + /// insert a sample entry by creating a new entry or by cumulating + /// samples into an existing one. Can only be done before any lookups + void insert(symbol_entry const * symbol, sample_entry const &); + + /// return nr of samples in the given filename + count_array_t accumulate_samples(debug_name_id filename_id) const; + + /// return nr of samples at the given line nr in the given file + count_array_t accumulate_samples(debug_name_id, size_t linenr) const; + + /// return the sample entry for the given image_name and vma if any + sample_entry const * find_by_vma(symbol_entry const * symbol, + bfd_vma vma) const; + +private: + /// build the symbol by file-location cache + void build_by_loc() const; + + /// main sample entry container + samples_storage samples; + + typedef std::multiset + samples_by_loc_t; + + // must be declared after the samples_storage to ensure a + // correct life-time. + + /** + * Sample entries by file location. Lazily built when necessary, + * so mutable. + */ + mutable samples_by_loc_t samples_by_loc; +}; + +#endif /* SAMPLE_CONTAINER_H */ diff --git a/libpp/symbol.cpp b/libpp/symbol.cpp new file mode 100644 index 0000000..dd94412 --- /dev/null +++ b/libpp/symbol.cpp @@ -0,0 +1,29 @@ +/** + * @file symbol.cpp + * Symbol containers + * + * @remark Copyright 2002, 2004 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + + +#include "symbol.h" +#include + +using std::cerr; +using std::endl; + +column_flags symbol_entry::output_hint(column_flags fl) const +{ + if (app_name != image_name) + fl = column_flags(fl | cf_image_name); + + // FIXME: see comment in symbol.h: why we don't use sample.vma + size ? + if (sample.vma & ~0xffffffffLLU) + fl = column_flags(fl | cf_64bit_vma); + + return fl; +} diff --git a/libpp/symbol.h b/libpp/symbol.h new file mode 100644 index 0000000..7072d9c --- /dev/null +++ b/libpp/symbol.h @@ -0,0 +1,133 @@ +/** + * @file symbol.h + * Symbol containers + * + * @remark Copyright 2002, 2004 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef SYMBOL_H +#define SYMBOL_H + +#include "name_storage.h" +#include "growable_vector.h" +#include "format_flags.h" +#include "op_types.h" + +#include + +#include + + +/// for storing sample counts +typedef growable_vector count_array_t; + + +/// A simple container for a fileno:linenr location. +struct file_location { + file_location() : linenr(0) {} + /// empty if not valid. + debug_name_id filename; + /// 0 means invalid or code is generated internally by the compiler + unsigned int linenr; + + bool operator<(file_location const & rhs) const { + // Note we sort on filename id not on string + return filename < rhs.filename || + (filename == rhs.filename && linenr < rhs.linenr); + } +}; + + +/// associate vma address with a file location and a samples count +struct sample_entry { + sample_entry() : vma(0) {} + /// From where file location comes the samples + file_location file_loc; + /// From where virtual memory address comes the samples + bfd_vma vma; + /// the samples count + count_array_t counts; +}; + + +/// associate a symbol with a file location, samples count and vma address +struct symbol_entry { + symbol_entry() : size(0) {} + /// which image this symbol belongs to + image_name_id image_name; + /// owning application name: identical to image name if profiling + /// session did not separate samples for shared libs or if image_name + /// is not a shared lib + image_name_id app_name; + /// file location, vma and cumulated samples count for this symbol + sample_entry sample; + /// name of symbol + symbol_name_id name; + /// symbol size as calculated by op_bfd, start of symbol is sample.vma + size_t size; + + /** + * @param fl input hint + * + * combine fl with the calculated hint. It's theoretically possible + * that we get a symbol where its samples pass the border line, but + * the start is below it, but the the hint is only used for formatting + */ + column_flags output_hint(column_flags fl) const; +}; + + +/// a collection of sorted symbols +typedef std::vector symbol_collection; + + +/** + * The public data for call-graph symbols. Each caller/callee has + * the sample counts replaced with the relevant arc counts, whilst + * the cg_symbol retains its self count. + */ +struct cg_symbol : public symbol_entry { + cg_symbol(symbol_entry const & sym) : symbol_entry(sym) {} + + typedef std::vector children; + + /// all callers of this symbol + children callers; + /// total count of callers + count_array_t total_caller_count; + + /// all symbols called by this symbol + children callees; + /// total count of callees + count_array_t total_callee_count; +}; + + +/// a collection of sorted callgraph symbols +typedef std::vector cg_collection; + + +/// for storing diff %ages +typedef growable_vector diff_array_t; + + +/** + * Data for a diffed symbol. + */ +struct diff_symbol : public symbol_entry { + diff_symbol(symbol_entry const & sym) : symbol_entry(sym) {} + + /// diff %age values for each profile class + diff_array_t diffs; +}; + + +/// a collection of diffed symbols +typedef std::vector diff_collection; + + +#endif /* !SYMBOL_H */ diff --git a/libpp/symbol_container.cpp b/libpp/symbol_container.cpp new file mode 100644 index 0000000..b7a6d3e --- /dev/null +++ b/libpp/symbol_container.cpp @@ -0,0 +1,100 @@ +/** + * @file symbol_container.cpp + * Internal container for symbols + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include +#include +#include +#include + +#include "symbol_container.h" + +using namespace std; + +symbol_container::size_type symbol_container::size() const +{ + return symbols.size(); +} + + +symbol_entry const * symbol_container::insert(symbol_entry const & symb) +{ + pair p = symbols.insert(symb); + if (!p.second) { + // safe: count is not used by sorting criteria + symbol_entry * symbol = const_cast(&*p.first); + symbol->sample.counts += symb.sample.counts; + } + + return &*p.first; +} + + +symbol_entry const * +symbol_container::find(debug_name_id filename, size_t linenr) const +{ + build_by_loc(); + + symbol_entry symbol; + symbol.sample.file_loc.filename = filename; + symbol.sample.file_loc.linenr = linenr; + + symbols_by_loc_t::const_iterator it = symbols_by_loc.find(&symbol); + + if (it != symbols_by_loc.end()) + return *it; + + return 0; +} + + +void symbol_container::build_by_loc() const +{ + if (!symbols_by_loc.empty()) + return; + + symbols_t::const_iterator cit = symbols.begin(); + symbols_t::const_iterator end = symbols.end(); + for (; cit != end; ++cit) + symbols_by_loc.insert(&*cit); +} + + +symbol_entry const * symbol_container::find_by_vma(string const & image_name, + bfd_vma vma) const +{ + // FIXME: this is too inefficient probably + symbols_t::const_iterator it; + for (it = symbols.begin(); it != symbols.end(); ++it) { + if (it->sample.vma == vma && + image_names.name(it->image_name) == image_name) + return &*it; + } + + return 0; +} + + +symbol_container::symbols_t::iterator symbol_container::begin() +{ + return symbols.begin(); +} + + +symbol_container::symbols_t::iterator symbol_container::end() +{ + return symbols.end(); +} + +symbol_entry const * symbol_container::find(symbol_entry const & symbol) const +{ + symbols_t::const_iterator it = symbols.find(symbol); + return it == symbols.end() ? 0 : &*it; +} diff --git a/libpp/symbol_container.h b/libpp/symbol_container.h new file mode 100644 index 0000000..73ca581 --- /dev/null +++ b/libpp/symbol_container.h @@ -0,0 +1,92 @@ +/** + * @file symbol_container.h + * Internal container for symbols + * + * @remark Copyright 2002, 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef SYMBOL_CONTAINER_H +#define SYMBOL_CONTAINER_H + +#include +#include + +#include "symbol.h" +#include "symbol_functors.h" + +/** + * An arbitrary container of symbols. Supports lookup + * by name, by VMA, and by file location. + * + * Lookup by name or by VMA is O(n). Lookup by file location + * is O(log(n)). + */ +class symbol_container { +public: + /// container type + typedef std::set symbols_t; + + typedef symbols_t::size_type size_type; + + /// return the number of symbols stored + size_type size() const; + + /** + * Insert a new symbol. If the symbol already exists in the container, + * then the sample counts are accumulated. + * Returns the newly created symbol or the existing one. This pointer + * remains valid during the whole life time of a symbol_container + * object and is warranted unique according to less_symbol comparator. + * Can only be done before any file-location based lookups, since the + * two lookup methods are not synchronised. + */ + symbol_entry const * insert(symbol_entry const &); + + /// find the symbol at the given filename and line number, if any + symbol_entry const * find(debug_name_id filename, + size_t linenr) const; + + /// find the symbol with the given image_name vma if any + symbol_entry const * find_by_vma(std::string const & image_name, + bfd_vma vma) const; + + /// Search a symbol. Return NULL if not found. + symbol_entry const * find(symbol_entry const & symbol) const; + + /// return start of symbols + symbols_t::iterator begin(); + + /// return end of symbols + symbols_t::iterator end(); + +private: + /// build the symbol by file-location cache + void build_by_loc() const; + + /** + * The main container of symbols. Multiple symbols with the same + * name are allowed. + */ + symbols_t symbols; + + /** + * Differently-named symbol at same file location are allowed e.g. + * template instantiation. + */ + typedef std::multiset + symbols_by_loc_t; + + // must be declared after the set to ensure a correct life-time. + + /** + * Symbols sorted by location order. Lazily built on request, + * so mutable. + */ + mutable symbols_by_loc_t symbols_by_loc; +}; + +#endif /* SYMBOL_CONTAINER_H */ diff --git a/libpp/symbol_functors.cpp b/libpp/symbol_functors.cpp new file mode 100644 index 0000000..a4107c3 --- /dev/null +++ b/libpp/symbol_functors.cpp @@ -0,0 +1,30 @@ +/** + * @file symbol_functors.cpp + * Functors for symbol/sample comparison + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include "symbol_functors.h" + +bool less_symbol::operator()(symbol_entry const & lhs, + symbol_entry const & rhs) const +{ + if (lhs.image_name != rhs.image_name) + return lhs.image_name < rhs.image_name; + + if (lhs.app_name != rhs.app_name) + return lhs.app_name < rhs.app_name; + + if (lhs.name != rhs.name) + return lhs.name < rhs.name; + + if (lhs.sample.vma != rhs.sample.vma) + return lhs.sample.vma < rhs.sample.vma; + + return lhs.size < rhs.size; +} diff --git a/libpp/symbol_functors.h b/libpp/symbol_functors.h new file mode 100644 index 0000000..53a7253 --- /dev/null +++ b/libpp/symbol_functors.h @@ -0,0 +1,38 @@ +/** + * @file symbol_functors.h + * Functors for symbol/sample comparison + * + * @remark Copyright 2002, 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef SYMBOL_FUNCTORS_H +#define SYMBOL_FUNCTORS_H + +#include "symbol.h" + +/// compare based on file location +struct less_by_file_loc { + bool operator()(sample_entry const * lhs, + sample_entry const * rhs) const { + return lhs->file_loc < rhs->file_loc; + } + + bool operator()(symbol_entry const * lhs, + symbol_entry const * rhs) const { + return lhs->sample.file_loc < rhs->sample.file_loc; + } +}; + + +/// compare based on symbol contents +struct less_symbol { + // implementation compare by id rather than by string + bool operator()(symbol_entry const & lhs, + symbol_entry const & rhs) const; +}; + +#endif /* SYMBOL_FUNCTORS_H */ diff --git a/libpp/symbol_sort.cpp b/libpp/symbol_sort.cpp new file mode 100644 index 0000000..4b18e59 --- /dev/null +++ b/libpp/symbol_sort.cpp @@ -0,0 +1,207 @@ +/** + * @file symbol_sort.cpp + * Sorting symbols + * + * @remark Copyright 2002, 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include "symbol_sort.h" +#include "symbol_functors.h" + +#include "name_storage.h" +#include "op_exception.h" + +#include +#include + +using namespace std; + +namespace { + +bool long_filenames; + +int image_compare(image_name_id l, image_name_id r) +{ + if (long_filenames) + return image_names.name(l).compare(image_names.name(r)); + return image_names.basename(l).compare(image_names.basename(r)); +} + + +int debug_compare(debug_name_id l, debug_name_id r) +{ + if (long_filenames) + return debug_names.name(l).compare(debug_names.name(r)); + return debug_names.basename(l).compare(debug_names.basename(r)); +} + + +int compare_by(sort_options::sort_order order, + symbol_entry const & lhs, symbol_entry const & rhs) +{ + switch (order) { + case sort_options::sample: + if (lhs.sample.counts[0] < rhs.sample.counts[0]) + return 1; + if (lhs.sample.counts[0] > rhs.sample.counts[0]) + return -1; + return 0; + + case sort_options::symbol: + return symbol_names.demangle(lhs.name).compare( + symbol_names.demangle(rhs.name)); + + case sort_options::image: + return image_compare(lhs.image_name, rhs.image_name); + + case sort_options::app_name: + return image_compare(lhs.app_name, rhs.app_name); + + case sort_options::vma: + if (lhs.sample.vma < rhs.sample.vma) + return -1; + if (lhs.sample.vma > rhs.sample.vma) + return 1; + return 0; + + case sort_options::debug: { + file_location const & f1 = lhs.sample.file_loc; + file_location const & f2 = rhs.sample.file_loc; + int ret = debug_compare(f1.filename, f2.filename); + if (ret == 0) + ret = f1.linenr - f2.linenr; + return ret; + } + + default: { + // static_cast<> to shut up g++ 2.91.66 which warn + // about ambiguity between <<(int) and <<(long int) + ostringstream os; + os << "compare_by(): unknown sort option: " + << static_cast(order) << endl; + throw op_fatal_error(os.str()); + } + } + + return 0; +} + + +struct symbol_compare { + symbol_compare(vector const & order, + bool reverse) + : compare_order(order), reverse_sort(reverse) {} + + bool operator()(symbol_entry const * lhs, + symbol_entry const * rhs) const { + return operator()(*lhs, *rhs); + } + + bool operator()(symbol_entry const & lhs, + symbol_entry const & rhs) const; + +protected: + vector const & compare_order; + bool reverse_sort; +}; + + +bool symbol_compare::operator()(symbol_entry const & lhs, + symbol_entry const & rhs) const +{ + for (size_t i = 0; i < compare_order.size(); ++i) { + int ret = compare_by(compare_order[i], lhs, rhs); + + if (reverse_sort) + ret = -ret; + if (ret != 0) + return ret < 0; + } + return false; +} + + +} // anonymous namespace + + +void sort_options:: +sort(symbol_collection & syms, bool reverse_sort, bool lf) const +{ + long_filenames = lf; + + vector sort_option(options); + for (sort_order cur = first; cur != last; cur = sort_order(cur + 1)) { + if (find(sort_option.begin(), sort_option.end(), cur) == + sort_option.end()) + sort_option.push_back(cur); + } + + stable_sort(syms.begin(), syms.end(), + symbol_compare(sort_option, reverse_sort)); +} + + +void sort_options:: +sort(cg_collection & syms, bool reverse_sort, bool lf) const +{ + long_filenames = lf; + + vector sort_option(options); + for (sort_order cur = first; cur != last; cur = sort_order(cur + 1)) { + if (find(sort_option.begin(), sort_option.end(), cur) == + sort_option.end()) + sort_option.push_back(cur); + } + + stable_sort(syms.begin(), syms.end(), + symbol_compare(sort_option, reverse_sort)); +} + + +void sort_options:: +sort(diff_collection & syms, bool reverse_sort, bool lf) const +{ + long_filenames = lf; + + vector sort_option(options); + for (sort_order cur = first; cur != last; cur = sort_order(cur + 1)) { + if (find(sort_option.begin(), sort_option.end(), cur) == + sort_option.end()) + sort_option.push_back(cur); + } + + stable_sort(syms.begin(), syms.end(), + symbol_compare(sort_option, reverse_sort)); +} + + +void sort_options::add_sort_option(string const & name) +{ + if (name == "vma") { + options.push_back(vma); + } else if (name == "sample") { + options.push_back(sample); + } else if (name == "symbol") { + options.push_back(symbol); + } else if (name == "debug") { + options.push_back(debug); + } else if (name == "image") { + options.push_back(image); + } else if (name == "app-name") { + options.push_back(app_name); + } else { + ostringstream os; + os << "unknown sort option: " << name << endl; + throw op_fatal_error(os.str()); + } +} + + +void sort_options::add_sort_option(sort_options::sort_order order) +{ + options.push_back(order); +} diff --git a/libpp/symbol_sort.h b/libpp/symbol_sort.h new file mode 100644 index 0000000..da93d04 --- /dev/null +++ b/libpp/symbol_sort.h @@ -0,0 +1,59 @@ +/** + * @file symbol_sort.h + * Sorting symbols + * + * @remark Copyright 2002, 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef SYMBOL_SORT_H +#define SYMBOL_SORT_H + +#include "symbol.h" + +#include +#include + +struct sort_options { + enum sort_order { + // order give sort order if caller doesn't specify one + first, + sample = first, + image, + app_name, + symbol, + debug, + vma, + last + }; + + sort_options() {} + + void add_sort_option(std::string const & name); + void add_sort_option(sort_order order); + + /** + * Sort the given container by the given criteria. + */ + void sort(symbol_collection & syms, bool reverse_sort, + bool long_filenames) const; + + /** + * Sort the given container by the given criteria. + */ + void sort(cg_collection & syms, bool reverse_sort, + bool long_filenames) const; + + /** + * Sort the given container by the given criteria. + */ + void sort(diff_collection & syms, bool reverse_sort, + bool long_filenames) const; + + std::vector options; +}; + +#endif // SYMBOL_SORT_H diff --git a/libregex/Makefile.am b/libregex/Makefile.am new file mode 100644 index 0000000..abe114b --- /dev/null +++ b/libregex/Makefile.am @@ -0,0 +1,15 @@ +SUBDIRS = . tests + +AM_CPPFLAGS = -I ${top_srcdir}/libutil++ +AM_CXXFLAGS = @OP_CXXFLAGS@ + +noinst_LIBRARIES = libop_regex.a + +libop_regex_a_SOURCES = \ + op_regex.cpp \ + op_regex.h \ + demangle_symbol.h \ + demangle_symbol.cpp + +datadir = $(prefix)/share/oprofile +nodist_data_DATA = stl.pat diff --git a/libregex/Makefile.in b/libregex/Makefile.in new file mode 100644 index 0000000..fa709b3 --- /dev/null +++ b/libregex/Makefile.in @@ -0,0 +1,594 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +SOURCES = $(libop_regex_a_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = libregex +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/stl.pat.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = stl.pat +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libop_regex_a_AR = $(AR) $(ARFLAGS) +libop_regex_a_LIBADD = +am_libop_regex_a_OBJECTS = op_regex.$(OBJEXT) \ + demangle_symbol.$(OBJEXT) +libop_regex_a_OBJECTS = $(am_libop_regex_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libop_regex_a_SOURCES) +DIST_SOURCES = $(libop_regex_a_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(datadir)" +nodist_dataDATA_INSTALL = $(INSTALL_DATA) +DATA = $(nodist_data_DATA) +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = $(prefix)/share/oprofile +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +SUBDIRS = . tests +AM_CPPFLAGS = -I ${top_srcdir}/libutil++ +AM_CXXFLAGS = @OP_CXXFLAGS@ +noinst_LIBRARIES = libop_regex.a +libop_regex_a_SOURCES = \ + op_regex.cpp \ + op_regex.h \ + demangle_symbol.h \ + demangle_symbol.cpp + +nodist_data_DATA = stl.pat +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libregex/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libregex/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +stl.pat: $(top_builddir)/config.status $(srcdir)/stl.pat.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libop_regex.a: $(libop_regex_a_OBJECTS) $(libop_regex_a_DEPENDENCIES) + -rm -f libop_regex.a + $(libop_regex_a_AR) libop_regex.a $(libop_regex_a_OBJECTS) $(libop_regex_a_LIBADD) + $(RANLIB) libop_regex.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demangle_symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_regex.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: +install-nodist_dataDATA: $(nodist_data_DATA) + @$(NORMAL_INSTALL) + test -z "$(datadir)" || $(mkdir_p) "$(DESTDIR)$(datadir)" + @list='$(nodist_data_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(nodist_dataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(datadir)/$$f'"; \ + $(nodist_dataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(datadir)/$$f"; \ + done + +uninstall-nodist_dataDATA: + @$(NORMAL_UNINSTALL) + @list='$(nodist_data_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(datadir)/$$f'"; \ + rm -f "$(DESTDIR)$(datadir)/$$f"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LIBRARIES) $(DATA) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(datadir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-nodist_dataDATA + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am uninstall-nodist_dataDATA + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-generic clean-noinstLIBRARIES clean-recursive \ + ctags ctags-recursive distclean distclean-compile \ + distclean-generic distclean-recursive distclean-tags distdir \ + dvi dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man \ + install-nodist_dataDATA install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-info-am \ + uninstall-nodist_dataDATA + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libregex/demangle_symbol.cpp b/libregex/demangle_symbol.cpp new file mode 100644 index 0000000..0d1ab73 --- /dev/null +++ b/libregex/demangle_symbol.cpp @@ -0,0 +1,61 @@ +/** + * @file demangle_symbol.cpp + * Demangle a C++ symbol + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#include "config.h" + +#include "demangle_symbol.h" +#include "op_regex.h" + +// from libiberty +/*@{\name demangle option parameter */ +#ifndef DMGL_PARAMS +# define DMGL_PARAMS (1 << 0) /**< Include function args */ +#endif +#ifndef DMGL_ANSI +# define DMGL_ANSI (1 << 1) /**< Include const, volatile, etc */ +#endif +/*@}*/ +extern "C" char * cplus_demangle(char const * mangled, int options); + +using namespace std; + +namespace options { + extern demangle_type demangle; +} + +string const demangle_symbol(string const & name) +{ + if (options::demangle == dmt_none) + return name; + + // Do not try to strip leading underscore, this leads to many + // C++ demangling failures. + char * unmangled = cplus_demangle(name.c_str(), DMGL_PARAMS | DMGL_ANSI); + + if (!unmangled) + return name; + + string result(unmangled); + free(unmangled); + + if (options::demangle == dmt_smart) { + static bool init = false; + static regular_expression_replace regex; + if (init == false) { + setup_regex(regex, OP_DATADIR "/stl.pat"); + init = true; + } + // we don't protect against exception here, pattern must be + // right and user can easily work-around by using -d + regex.execute(result); + } + + return result; +} diff --git a/libregex/demangle_symbol.h b/libregex/demangle_symbol.h new file mode 100644 index 0000000..e2cefa3 --- /dev/null +++ b/libregex/demangle_symbol.h @@ -0,0 +1,40 @@ +/** + * @file demangle_symbol.h + * Demangle a C++ symbol + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#ifndef DEMANGLE_SYMBOL_H +#define DEMANGLE_SYMBOL_H + +#include + +/// demangle type: specify what demangling we use +enum demangle_type { + /// no demangling. + dmt_none, + /// use cplus_demangle() + dmt_normal, + /// normal plus a pass through the regular expression to simplify + /// the mangled name + dmt_smart +}; + +/** + * demangle_symbol - demangle a symbol + * @param name the mangled symbol name + * @return the demangled name + * + * Demangle the symbol name, if the global + * variable demangle is true. + * + * The demangled name lists the parameters and type + * qualifiers such as "const". + */ +std::string const demangle_symbol(std::string const & name); + +#endif // DEMANGLE_SYMBOL_H diff --git a/libregex/op_regex.cpp b/libregex/op_regex.cpp new file mode 100644 index 0000000..379eea5 --- /dev/null +++ b/libregex/op_regex.cpp @@ -0,0 +1,313 @@ +/** + * @file op_regex.cpp + * This file contains implementation for a lightweight wrapper around + * libc regex, providing regular expression match and replace facility. + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * @remark Idea comes from TextFilt project + * + * @author Philippe Elie + */ + +#include + +#include +#include + +#include "string_manip.h" + +#include "op_regex.h" + +using namespace std; + +namespace { + +string op_regerror(int err, regex_t const & regexp) +{ + size_t needed_size = regerror(err, ®exp, 0, 0); + char * buffer = new char[needed_size]; + regerror(err, ®exp, buffer, needed_size); + + return buffer; +} + + +void op_regcomp(regex_t & regexp, string const & pattern) +{ + int err = regcomp(®exp, pattern.c_str(), REG_EXTENDED); + if (err) { + throw bad_regex("regcomp error: " + op_regerror(err, regexp) + + " for pattern : " + pattern); + } +} + + +bool op_regexec(regex_t const & regex, string const & str, regmatch_t * match, + size_t nmatch) +{ + return regexec(®ex, str.c_str(), nmatch, match, 0) != REG_NOMATCH; +} + + +void op_regfree(regex_t & regexp) +{ + regfree(®exp); +} + + +// return the index number associated with a char seen in a "\x". +// Allowed range are for x is [0-9a-z] return size_t(-1) if x is not in +// these ranges. +size_t subexpr_index(char ch) +{ + if (isdigit(ch)) + return ch - '0'; + if (ch >= 'a' && ch <= 'z') + return ch - 'a' + 10; + return size_t(-1); +} + +} // anonymous namespace + + +bad_regex::bad_regex(string const & pattern) + : op_exception(pattern) +{ +} + + +regular_expression_replace::regular_expression_replace(size_t limit_, + size_t limit_defs) + : + limit(limit_), + limit_defs_expansion(limit_defs) +{ +} + + +regular_expression_replace::~regular_expression_replace() +{ + for (size_t i = 0 ; i < regex_replace.size() ; ++i) + op_regfree(regex_replace[i].regexp); +} + + +void regular_expression_replace::add_definition(string const & name, + string const & definition) +{ + defs[name] = expand_string(definition); +} + + +void regular_expression_replace::add_pattern(string const & pattern, + string const & replace) +{ + string expanded_pattern = expand_string(pattern); + + regex_t regexp; + op_regcomp(regexp, expanded_pattern); + replace_t regex = { regexp, replace }; + regex_replace.push_back(regex); +} + + +string regular_expression_replace::expand_string(string const & input) +{ + string last, expanded(input); + size_t i = 0; + for (i = 0 ; i < limit_defs_expansion ; ++i) { + last = expanded; + expanded = substitute_definition(last); + if (expanded == last) + break; + } + + if (i == limit_defs_expansion) + throw bad_regex("too many substitution for: + input"); + + return last; +} + + +string regular_expression_replace::substitute_definition(string const & pattern) +{ + string result; + bool previous_is_escape = false; + + for (size_t i = 0 ; i < pattern.length() ; ++i) { + if (pattern[i] == '$' && !previous_is_escape) { + size_t pos = pattern.find('{', i); + if (pos != i + 1) { + throw bad_regex("invalid $ in pattern: " + pattern); + } + size_t end = pattern.find('}', i); + if (end == string::npos) { + throw bad_regex("no matching '}' in pattern: " + pattern); + } + string def_name = pattern.substr(pos+1, (end-pos) - 1); + if (defs.find(def_name) == defs.end()) { + throw bad_regex("definition not found and used in pattern: (" + def_name + ") " + pattern); + } + result += defs[def_name]; + i = end; + } else { + if (pattern[i] == '\\' && !previous_is_escape) { + previous_is_escape = true; + } else { + previous_is_escape = false; + } + result += pattern[i]; + } + } + + return result; +} + + +// FIXME limit output string size ? (cause we can have exponential growing +// of output string through a rule "a" = "aa") +bool regular_expression_replace::execute(string & str) const +{ + bool changed = true; + for (size_t nr_iter = 0; changed && nr_iter < limit ; ++nr_iter) { + changed = false; + for (size_t i = 0 ; i < regex_replace.size() ; ++i) { + if (do_execute(str, regex_replace[i])) { + changed = true; + } + } + } + + // this don't return if the input string has been changed but if + // we reach the limit number of iteration. + return changed == false; +} + + +bool regular_expression_replace::do_execute(string & str, + replace_t const & regexp) const +{ + bool changed = false; + + regmatch_t match[max_match]; + for (size_t iter = 0; + op_regexec(regexp.regexp, str, match, max_match) && iter < limit; + iter++) { + changed = true; + do_replace(str, regexp.replace, match); + } + + return changed; +} + + +regmatch_t const & +regular_expression_replace::get_match(regmatch_t const * match, char idx) const +{ + size_t sub_expr = subexpr_index(idx); + if (sub_expr == size_t(-1)) + throw bad_regex("expect group index: " + idx); + if (sub_expr >= max_match) + throw bad_regex("illegal group index :" + idx); + return match[sub_expr]; +} + +void regular_expression_replace::do_replace +(string & str, string const & replace, regmatch_t const * match) const +{ + string inserted; + for (size_t i = 0 ; i < replace.length() ; ++i) { + if (replace[i] == '\\') { + if (i == replace.length() - 1) { + throw bad_regex("illegal \\ trailer: " + + replace); + } + ++i; + if (replace[i] == '\\') { + inserted += '\\'; + } else { + regmatch_t const & matched = get_match(match, + replace[i]); + if (matched.rm_so == -1 && + matched.rm_eo == -1) { + // empty match: nothing todo + } else if (matched.rm_so == -1 || + matched.rm_eo == -1) { + throw bad_regex("illegal match: " + + replace); + } else { + inserted += str.substr(matched.rm_so, + matched.rm_eo - matched.rm_so); + } + } + } else { + inserted += replace[i]; + } + } + + size_t first = match[0].rm_so; + size_t count = match[0].rm_eo - match[0].rm_so; + + str.replace(first, count, inserted); +} + + +void setup_regex(regular_expression_replace & regex, + string const & filename) +{ + ifstream in(filename.c_str()); + if (!in) { + throw op_runtime_error("Can't open file " + filename + + " for reading", errno); + } + + regular_expression_replace var_name_rule; + var_name_rule.add_pattern("^\\$([_a-zA-Z][_a-zA-Z0-9]*)[ ]*=.*", "\\1"); + regular_expression_replace var_value_rule; + var_value_rule.add_pattern(".*=[ ]*\"(.*)\"", "\\1"); + + regular_expression_replace left_rule; + left_rule.add_pattern("[ ]*\"(.*)\"[ ]*=.*", "\\1"); + regular_expression_replace right_rule; + right_rule.add_pattern(".*=[ ]*\"(.*)\"", "\\1"); + + string line; + while (getline(in, line)) { + line = trim(line); + if (line.empty() || line[0] == '#') + continue; + + string temp = line; + var_name_rule.execute(temp); + if (temp == line) { + string left = line; + left_rule.execute(left); + if (left == line) { + throw bad_regex("invalid input file: " + + '"' + line + '"'); + } + + string right = line; + right_rule.execute(right); + if (right == line) { + throw bad_regex("invalid input file: " + + '"' + line + '"'); + } + + regex.add_pattern(left, right); + } else { + // temp != line ==> var_name_rule succeed to substitute + // into temp the var_name present in line + string var_name = temp; + string var_value = line; + var_value_rule.execute(var_value); + if (var_value == line) { + throw bad_regex("invalid input file: " + + '"' + line + '"'); + } + + regex.add_definition(var_name, var_value); + } + } +} diff --git a/libregex/op_regex.h b/libregex/op_regex.h new file mode 100644 index 0000000..423b980 --- /dev/null +++ b/libregex/op_regex.h @@ -0,0 +1,130 @@ +/** + * @file op_regex.h + * This file contains various definitions and interface for a + * lightweight wrapper around libc regex, providing match + * and replace facility. + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * @remark Idea comes from TextFilt project + * + * @author Philippe Elie + */ + +#ifndef OP_REGEX_H +#define OP_REGEX_H + +// required by posix before including regex.h +#include +#include + +#include +#include +#include + +#include "op_exception.h" + +/** + * ill formed regular expression or expression throw such exception + */ +struct bad_regex : op_exception { + bad_regex(std::string const & pattern); +}; + +/** + * lightweight encapsulation of regex lib search and replace + * + * See stl.pat for further details and examples of used syntax. + */ +class regular_expression_replace { +public: + /** + * @param limit limit on number of search and replace done + * @param limit_defs_expansion limit on number of expansion done + * during replacement of regular definition name by their expansion + * + * build an object holding regular defintion and regular expression + * & replace, preparing it for substitution ala sed + */ + regular_expression_replace(size_t limit = 100, + size_t limit_defs_expansion = 100); + ~regular_expression_replace(); + + /** + * @param name a regular definition name + * @param replace the string to subsitute in other regular definition + * or regular exepression when this regular defintion name is + * encoutered. + */ + void add_definition(std::string const & name, + std::string const & replace); + /** + * @param pattern a regular expression pattern, POSIX extended notation + * @param replace the replace string to use when this regular + * expression is matched + * + * You can imbed regular definition in pattern but not in replace. + */ + void add_pattern(std::string const & pattern, + std::string const & replace); + + /** + * @param str the input/output string where we search pattern and + * replace them. + * + * Execute loop at max limit time on the set of regular expression + * + * Return true if too many match occur and replacing has been stopped + * due to reach limit_defs_expansion. You can test if some pattern has + * been matched by saving the input string and comparing it to the new + * value. There is no way to detect s/a/a because the output string + * will be identical to the input string. + */ + bool execute(std::string & str) const; +private: + struct replace_t { + // when this regexp is matched + regex_t regexp; + // replace the matched part with this string + std::string replace; + }; + + // helper to execute + bool do_execute(std::string & str, replace_t const & regexp) const; + void do_replace(std::string & str, std::string const & replace, + regmatch_t const * match) const; + + // helper to add_definition() and add_pattern() + std::string expand_string(std::string const & input); + + // helper to add_pattern + std::string substitute_definition(std::string const & pattern); + + // return the match of throw if idx is invalid + regmatch_t const & get_match(regmatch_t const * match, char idx) const; + + // don't increase too, it have direct impact on performance. This limit + // the number of grouping expression allowed in a regular expression + // Note than you can use grouping match operator > 9 only in the + // replace rule not in match regular expression since POSIX don't allow + // more than \9 in matching sequence. + static const size_t max_match = 16; + + size_t limit; + size_t limit_defs_expansion; + std::vector regex_replace; + /// dictionary of regular definition + typedef std::map defs_dict; + defs_dict defs; +}; + +/** + * @param regex the regular_expression_replace to fill + * @param filename the filename from where the deifnition and pattern are read + * + * add to regex pattern and regular definition read from the given file + */ +void setup_regex(regular_expression_replace& regex, + std::string const & filename); + +#endif /* !OP_REGEX_H */ diff --git a/libregex/stl.pat.in b/libregex/stl.pat.in new file mode 100644 index 0000000..64aeaf9 --- /dev/null +++ b/libregex/stl.pat.in @@ -0,0 +1,160 @@ +# format : +# $name = "regular_definition" +# "pattern" = "substitued_pattern" +# pattern can contain reference to regular definition with ${name} +# this occurence are substitued in pattern by their definition + +# regular_definition containing other regular_definition refer always to a +# previously defined regular definition so they can look like recursive but are +# not. op_regex.cpp do sucessive apply of pattern whilst change occur (with a +# hard limit on number of subsitutions) so you can apply successive change to +# translate first to an intermediate simplified form then continue substitution +# in another pattern (see iosfwd section). The number of grouping regexp is +# limited, see static const size_t max_match; in op_regex.h. Note than mangled +# name produce can be illegal as I choose to output like vector> rather +# than vector > + +# man regex is a friend, is it your ? + +$integer = "\<[0-9]+" +$identifier = "\<[_a-zA-Z][_a-zA-Z0-9]*" +$typename = "${identifier}(::${identifier})*" +$typename = "${typename}(<${typename}(, ${typename})*>)*" +# adding more substitution allow more nested templated type but we run out of +# \digit which is a wall. Indeed if you add more () grouping you need to +# rename all relevant \digit in pattern which use this regular definition +# $typename = "${typename}(<${typename}(, ${typename})*>)*" +# finally add standard C type not recognized by above patterns, the way to add +# pointer is ugly but we can't add any grouping to not overrun 9 max group +# in left pattern rules side.. +$typename = "(${typename}[ ]*\**|unsigned short[ ]**\**|unsigned int[ ]*\**|unsigned long[ ]*\**|unsigned char[ ]*\**|signed char[ ]*\**|long long[ ]*\**|unsigned long long[ ]*\**|long double[ ]*\**)" + +# FIXME: really discussable but simplify output and the next pattern. +"\" = ">" +# for these two we can't match begin of word. +"\{anonymous\}::" = "" +"\(anonymous namespace\)::" = "" + +# specific to gcc 2.95 +"\, __default_alloc_template>" = "string" +# two pass, first shrink allocator<> then less<> allowing map with user defined +# comparator +"\<(multi)?map<${typename}, ${typename}, ${typename}, allocator<\8>>" = "\1map<\2, \8, \e>" +"\<(multi)?map<${typename}, ${typename}, less<\2>>" = "\1map<\2, \8>" + +"\" = "bitset<\1>" +"\<([io]stream_iterator)" = "\1" + +# common to all supported gcc version. +"\, 0>" = "deque<\1>" +"\<(stack|queue)<${typename}, deque<\2>>" = "\1<\2>" +"\<(vector|list|deque)<${typename}, allocator<\2>>" = "\1<\2>" +# strictly speaking 3rd parameters is less +"\, less<\1>>" = "priority_queue<\1>" +# two pass, first shrink allocator<> then less<> allowing map with user defined +# comparator +"\<(multi)?set<${typename}, ${typename}, allocator<\2>>" = "\1set<\2, \8>" +"\<(multi)?set<${typename}, less<\2>>" = "\1set<\2>" + +# get ride of _Rb_tree iterator typedef, these are also mapped by map/set but +# we can't distinguish a set>::iterator and a +# map::iterator as they decay to an identical typedef so we don't try +# to be clever here. +"\<_Rb_tree_iterator<${typename}, \1 const[ ]*&, \1 const[ ]*\*>" = "_Rb_tree<\1>::const_iterator" +"\<_Rb_tree_iterator<${typename}, \1[ ]*&, \1[ ]*\*>" = "_Rb_tree<\1>::iterator" +# important special case for map/multimap iterator +"\<_Rb_tree_iterator<(pair<${typename} const, ${typename}>), \1 const[ ]*&, \1 const[ ]*\*>" = "_Rb_tree<\1>::const_iterator" +"\<_Rb_tree_iterator<(pair<${typename} const, ${typename}>), \1[ ]*&, \1[ ]*\*>" = "_Rb_tree<\1>::iterator" +# 2.95/3.2 set/multiset implementation +"\<_Rb_tree<${typename}, \1, _Identity<\1>, ${typename}, allocator<\1>>" = "_Rb_tree<\1, \1, _Identity<\1>, \7>" +"_Rb_tree<${typename}, \1, _Identity<\1>, less<\1>>" = "_Rb_tree<\1, \1, _Identity<\1>>" +# 2.95 map/multimap implementation +"\<_Rb_tree<${typename}, pair<\1 const, (${typename}( const)?)>, _Select1st>, less<\1>, allocator<\7>>" = "_Rb_tree<\1, pair<\1 const, \7>, _Select1st>, less<\1>>" +# 3.2 map/multimap implementation +"\<_Rb_tree<${typename}, pair<\1 const, ${typename}>, _Select1st>, less<\1>, allocator>>" = "_Rb_tree<\1, pair<\1 const, \7>, _Select1st>, less<\1>>" +# now we can shrink default comparator. +"\<_Rb_tree<${typename}, pair<\1 const, (${typename}( const)?)>, _Select1st>, less<\1>>" = "_Rb_tree<\1, pair<\1 const, \7>, _Select1st>>" +# get rid of _Select1st and _Identity +# FIXME: the presence od _Identity<> and _Select1st<> allowed to quickly +# differentiate a set or a map, the rule now to differentiate them is: +# second parameter to _Rb_tree* is a pair<> ==> map else set<>. Either we need +# to document this or remove _Identity and _Select1st pattern +"\<_Identity<${typename}>" = "\1" +"\<_Select1st>" = "\1 const" + +"\<_List_base<${typename}, allocator<\1>>" = "_List_base<\1>" + +# 2.95 templatized operator<< and >> exist only for std::string +"\, __default_alloc_template>\(ostream &, string const &\)" = "ostream & operator<<(ostream &, string const &)" +"\>|getline), __default_alloc_template>\(istream &, string &\)" = "istream & \1(istream &, string &)" + +# 3.0 templatized operator<< and >> exist only for std::string +"\, allocator>\(ostream&, string const&\)" = "ostream & operator<<(ostream &, string const &)" +"\>|getline) , allocator>\(istream&, string&\)" = "istream & \1(istream &, string &)" + +# 2.95/3.2 algorithm +"\<(${typename}( const)?) \* find<\1 \*, ${typename}>\(\1 \*, \1 \*, \9 const &, ${typename}\)" = "\1 * find(\1 *, \1 *, \9 const &, \f)" + +"\<(${typename}( const)?) \* find_if<\1 \*, ${typename}>\(\1 \*, \1 \*, \9, random_access_iterator_tag)" = "\1 * find_if(\1 *, \1 *, \9, random_access_iterator_tag)" + +# gcc 3.2, not tested on 3.0, 3.1 but probably work. +# FIXME: there is a potential problem here with map +# the pair become pair<\2, \8> not pair<\2 const, \8>, who use the above, +# is it legal ? +# two pass, first shrink allocator<> then less<> allowing map with user defined +# comparator +"\<(multi)?map<${typename}, ${typename}, ${typename}, allocator>>" = "\1map<\2, \8, \e>" +# this one exist already for 2.95 the first transformation giving a common +# form for 2.95/3.2 +# "\<(multi)?map<${typename}, ${typename}, less<\2>>" = "\1map<\2, \8>" + +"\" = "bitset<\1>" + +# iterator +"\" = "iterator<\1_iterator_tag, \2>" +"\<([io]stream_iterator)<${typename}, char, char_traits, @PTRDIFF_T_TYPE@>" = "\1<\2>" + +# __gnu_cxx::__normal_iterator are used in two context: basic_string<> and +# vector we decay them to string::iterator, vector::iterator +"\<__gnu_cxx::__normal_iterator" = "string::const_iterator" +"\<__gnu_cxx::__normal_iterator" = "string::iterator" +"\<__gnu_cxx::__normal_iterator" = "wstring::const_iterator" +"\<__gnu_cxx::__normal_iterator" = "wstring::iterator" +"\<__gnu_cxx::__normal_iterator<${typename} const\*, vector<\1>>" = "vector<\1>::const_iterator" +"\<__gnu_cxx::__normal_iterator<${typename}\*, vector<\1>>" = "vector<\1>::iterator" + +# 2.95 use only _List_iterator, 3.2 use also _List_iterator_base but since +# list::iterator is a typedef to _List_iterator we don't need to deal with +# _List_iterator_base +"\<_List_iterator<${typename}, \1[ ]*&, \1[ ]*\*>" = "list<\1>::iterator" +"\<_List_iterator<${typename}, \1 const[ ]*&, \1 const[ ]*\*>" = "list<\1>::const_iterator" + +# iosfwd, std::string and std::wstring +# first translate from "basic_xxx>" to "basic_xxx" +"\<([io]streambuf_iterator|basic_(ios|streambuf|([io]|io)stream|filebuf|[io]?fstream))<${typename}, char_traits<\4>>" = "\1<\4>" +# as above translate from "basic_xxx, ...>" to "basic_xxx" +"\, allocator<\3>>" = "basic_\1<\3>" +# now we can translate the two above for char, wchar_t to standardese typedef +$iosfwd_name = "\" = "\1" +"\<${iosfwd_name}" = "w\1" + +# streampos and wstreampos decay to the same type, they are undistingushable +# in mangled name so substitute for the most probable, not a big deal +"\" = "streampos" + +# locale +# strictly speaking this accept num_put<..., istream_iterator<...> > or +# num_get<..., ostream_iterator<...> > but this can't compile so no big deal +"\<(money|time|num)_(put|get)<${typename}, (i|o)streambuf_iterator<\3>>" = "\1_\2<\3>" +"\" = "moneypunct\1<\2>" + +# 3.2 algorithm +"\<(vector<${typename}>::(const_)?iterator) find<\1, ${typename}>\(\1, \1, \9 const&, ${typename}\)" = "\1 find(\1, \1, \9 const&, \f)" + +"\<((string|wstring)::(const_)?iterator) find<\1, ${typename}>\(\1, \1, \4 const&, ${typename}\)" = "\1 find(\1, \1, \4 const&, \a)" + +"\<(vector<${typename}>::(const_)?iterator) find_if<\1, ${typename}>\(\1, \1, \9, random_access_iterator_tag\)" = "\1 find_if(\1, \1, \9, random_access_iterator_tag)" + +"\<((string|wstring)::(const_)?iterator) find_if<\1, ${typename}>\(\1, \1, \4, random_access_iterator_tag\)" = "\1 find_if(\1, \1, \4, random_access_iterator_tag)" diff --git a/libregex/tests/Makefile.am b/libregex/tests/Makefile.am new file mode 100644 index 0000000..1f4c970 --- /dev/null +++ b/libregex/tests/Makefile.am @@ -0,0 +1,16 @@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil++ \ + -I ${top_srcdir}/libregex + +AM_CXXFLAGS = @OP_CXXFLAGS@ + +check_PROGRAMS = regex_test + +regex_test_SOURCES = regex_test.cpp +regex_test_LDADD = \ + ../libop_regex.a \ + ../../libutil++/libutil++.a + +EXTRA_DIST = mangled-name.in + +TESTS = ${check_PROGRAMS} diff --git a/libregex/tests/Makefile.in b/libregex/tests/Makefile.in new file mode 100644 index 0000000..134bbaf --- /dev/null +++ b/libregex/tests/Makefile.in @@ -0,0 +1,516 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +SOURCES = $(regex_test_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +check_PROGRAMS = regex_test$(EXEEXT) +subdir = libregex/tests +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/mangled-name.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = mangled-name +am_regex_test_OBJECTS = regex_test.$(OBJEXT) +regex_test_OBJECTS = $(am_regex_test_OBJECTS) +regex_test_DEPENDENCIES = ../libop_regex.a ../../libutil++/libutil++.a +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(regex_test_SOURCES) +DIST_SOURCES = $(regex_test_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil++ \ + -I ${top_srcdir}/libregex + +AM_CXXFLAGS = @OP_CXXFLAGS@ +regex_test_SOURCES = regex_test.cpp +regex_test_LDADD = \ + ../libop_regex.a \ + ../../libutil++/libutil++.a + +EXTRA_DIST = mangled-name.in +TESTS = ${check_PROGRAMS} +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libregex/tests/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libregex/tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +mangled-name: $(top_builddir)/config.status $(srcdir)/mangled-name.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +regex_test$(EXEEXT): $(regex_test_OBJECTS) $(regex_test_DEPENDENCIES) + @rm -f regex_test$(EXEEXT) + $(CXXLINK) $(regex_test_LDFLAGS) $(regex_test_OBJECTS) $(regex_test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex_test.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic ctags distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libregex/tests/mangled-name.in b/libregex/tests/mangled-name.in new file mode 100644 index 0000000..cee4bc8 --- /dev/null +++ b/libregex/tests/mangled-name.in @@ -0,0 +1,453 @@ +# test for stl beautifier, do op_regex_test < mangled-name.txt +# line go by couple mangled name then expected name after run, line +# starting by # and blank line are ignored. The test must output nothing if +# successfull + +# before removing tests think it take time to write them. This is intended +# to be a coverage test of all pattern in stl.pat. + +# g++ 2.95 stl mangled name + +basic_string, __default_alloc_template > +string + +prefix_basic_string, __default_alloc_template > +prefix_basic_string, __default_alloc_template> + +vector, __default_alloc_template >, allocator, __default_alloc_template > > > +vector + +map, allocator > +map + +map, __default_alloc_template >, image_name, less, __default_alloc_template > >, allocator > +map + +multimap, allocator > +multimap + +prefix_multimap, allocator > +prefix_multimap, allocator> + +map > +map + +bitset<33, unsigned long> +bitset<33> + +istream_iterator +istream_iterator + +ostream_iterator +ostream_iterator + +# shared between all supported gcc version +deque, 0> +deque + +std::deque, 0> +deque + +prefix_deque, 0> +prefix_deque, 0> + +list > +list + +list > +list + +_List_iterator +list::const_iterator + +_List_iterator +list::iterator + +prefix_list > +prefix_list> + +std::list > +list + +queue, 0> > +queue + +prefix_queue, 0> > +prefix_queue> + +std::queue, 0> > +queue + +# get ride of _Rb_tree typedef, these are also mapped by map/set but we can't +# distinguish a set>::iterator and a map::iterator +# as they decay to an identical typedef so we don't try to be clever here. +_Rb_tree_iterator +_Rb_tree::const_iterator + +_Rb_tree_iterator +_Rb_tree::iterator + +# this run through special case pattern +_Rb_tree_iterator, pair const &, pair const *> +_Rb_tree>::const_iterator + +_Rb_tree_iterator, pair &, pair *> +_Rb_tree>::iterator + +_Rb_tree, less, allocator > +_Rb_tree + +_Rb_tree, _Select1st>, less, allocator> +_Rb_tree, string const> + +_Select1st > +int const + +_Select1st > +int const + +_Select1st> +string const + +_Identity +int + +# this test fail since pair<> is not recognized as a type +# _Select1st const, sample_entry>> +# pair const + +# 2.95 map/multimap +_Rb_tree, _Select1st >, less, allocator > +_Rb_tree, int const> +# 3.2 map/multimap +_Rb_tree, _Select1st >, less, allocator > > +_Rb_tree, int const> + +_List_base> +_List_base + +# strictly speaking 3rd parameters is less +priority_queue >, less > +priority_queue + +prefix_priority_queue >, less > +prefix_priority_queue, less> + +std::priority_queue >, std::less > +priority_queue + +vector > +vector + +vector > +vector + +vector > +vector + +stack, 0> > +stack + +prefix_stack, 0> > +prefix_stack> + +std::stack, 0> > +stack + +# test complex typename, we don't support more than one level of nesting +vector >, allocator > > > +vector> + +std::vector >, std::allocator > > > +vector> + +set, allocator > +set + +set, __default_alloc_template >, less, __default_alloc_template > >, allocator, __default_alloc_template > > > +set + +set > +set + +prefix_set, allocator > +prefix_set, allocator> + +prefix_set, allocator > +prefix_set, allocator> + +multiset, allocator > +multiset + +# test than pointer and reference to pointer are handled +vector > +vector + +vector > +vector + +# algorithm, will work for 3.2 too. +int * find(int *, int *, int const &, random_access_iterator_tag) +int * find(int *, int *, int const &, random_access_iterator_tag) +char const * find_if(char const *, char const *, compare, random_access_iterator_tag) +char const * find_if(char const *, char const *, compare, random_access_iterator_tag) + +# gcc 3.2 +std::basic_string, std::allocator > +string + +std::basic_string, std::allocator > +wstring + +# __normal_iterator are treated a part +__gnu_cxx::__normal_iterator +string::const_iterator +__gnu_cxx::__normal_iterator +string::iterator +__gnu_cxx::__normal_iterator +wstring::iterator +__gnu_cxx::__normal_iterator +wstring::const_iterator +std::reverse_iterator<__gnu_cxx::__normal_iterator> +reverse_iterator + +__gnu_cxx::__normal_iterator> +vector::const_iterator +__gnu_cxx::__normal_iterator> +vector::iterator +std::reverse_iterator<__gnu_cxx::__normal_iterator> +reverse_iterator::const_iterator + +std::map, std::allocator > > +map + +std::multimap, std::allocator > > +multimap + +std::map > > +map + +# parameter is size_t on x86 it's an unsigned +bitset<(@SIZE_T_TYPE@)33> +bitset<33> + +# 3, 4, 5th params are ptrdiff_t it's an int on x86 +std::iterator +iterator + +std::iterator +iterator + +std::iterator +iterator + +std::iterator +iterator + +std::iterator +iterator + +# 4th parms is ptrdiff_t +std::istream_iterator, @PTRDIFF_T_TYPE@> +istream_iterator + +std::ostream_iterator, @PTRDIFF_T_TYPE@> +ostream_iterator + +# simple enough, it's just +std::basic_ios > +basic_ios + +std::basic_streambuf > +basic_streambuf + +std::basic_istream > +basic_istream + +std::basic_ostream > +basic_ostream + +std::basic_iostream > +basic_iostream + +std::basic_filebuf > +basic_filebuf + +std::basic_ifstream > +basic_ifstream + +std::basic_ofstream > +basic_ofstream + +std::basic_fstream > +basic_fstream + +std::istreambuf_iterator > +istreambuf_iterator + +std::ostreambuf_iterator > +ostreambuf_iterator + +std::basic_stringbuf, std::allocator > +basic_stringbuf + +std::basic_istringstream, std::allocator > +basic_istringstream + +std::basic_ostringstream, std::allocator > +basic_ostringstream + +std::basic_stringstream, std::allocator > +basic_stringstream + +# all the above intantiated with char and wchar_t fallback to standardised +# typedef except istreambuf_iterator and ostreambuf_iterator + +std::basic_ios > +ios +std::basic_ios > +wios + +std::basic_streambuf > +streambuf +std::basic_streambuf > +wstreambuf + +std::basic_istream > +istream +std::basic_istream > +wistream + +std::basic_ostream > +ostream +std::basic_ostream > +wostream + +std::basic_iostream > +iostream +std::basic_iostream > +wiostream + +std::basic_filebuf > +filebuf +std::basic_filebuf > +wfilebuf + +std::basic_ifstream > +ifstream +std::basic_ifstream > +wifstream + +std::basic_ofstream > +ofstream +std::basic_ofstream > +wofstream + +std::basic_fstream > +fstream +std::basic_fstream > +wfstream + +std::basic_stringbuf, std::allocator > +stringbuf +std::basic_stringbuf, std::allocator > +wstringbuf + +std::basic_istringstream, std::allocator > +istringstream +std::basic_istringstream, std::allocator > +wistringstream + +std::basic_ostringstream, std::allocator > +ostringstream +std::basic_ostringstream, std::allocator > +wostringstream + +std::basic_stringstream, std::allocator > +stringstream +std::basic_stringstream, std::allocator > +wstringstream + +# these two are also in iosfw, namely +# typedef fpos::state_type> streampos; +# typedef fpos::state_type> wstreampos; +# but twice decay to fpos<__mbstate>, we choosed to translate to streampos +std::fpos<__mbstate_t> +streampos + +# locale +std::num_put > +num_put +std::num_put > +num_put +std::num_get > +num_get +std::num_get > +num_get + +std::time_put > +time_put +std::time_put > +time_put +std::time_get > +time_get +std::time_get > +time_get + +std::money_put > +money_put +std::money_put > +money_put +std::money_get > +money_get +std::money_get > +money_get + +std::moneypunct +moneypunct +std::moneypunct +moneypunct +std::moneypunct_byname +moneypunct_byname +std::moneypunct_byname +moneypunct_byname + +# algorithm +vector::iterator find::iterator, string>(vector::iterator, vector::iterator, string const&, random_access_iterator_tag) +vector::iterator find(vector::iterator, vector::iterator, string const&, random_access_iterator_tag) + +string::iterator find(string::iterator, string::iterator, int const&, random_access_iterator_tag) +string::iterator find(string::iterator, string::iterator, int const&, random_access_iterator_tag) + +vector::iterator find::iterator, int>(vector::iterator, vector::iterator, int const&, random_access_iterator_tag) +vector::iterator find(vector::iterator, vector::iterator, int const&, random_access_iterator_tag) + +char const * find(char const *, char const *, int const &, random_access_iterator_tag) +char const * find(char const *, char const *, int const &, random_access_iterator_tag) + +string::const_iterator find(string::const_iterator, string::const_iterator, int const&, random_access_iterator_tag) +string::const_iterator find(string::const_iterator, string::const_iterator, int const&, random_access_iterator_tag) + +string::const_iterator find_if(string::const_iterator, string::const_iterator, compare, random_access_iterator_tag) +string::const_iterator find_if(string::const_iterator, string::const_iterator, compare, random_access_iterator_tag) + +vector::iterator find_if::iterator, compare>(vector::iterator, vector::iterator, compare, random_access_iterator_tag) +vector::iterator find_if(vector::iterator, vector::iterator, compare, random_access_iterator_tag) + +ostream & operator<<, __default_alloc_template>(ostream &, string const &) +ostream & operator<<(ostream &, string const &) + +istream & operator>>, __default_alloc_template>(istream &, string &) +istream & operator>>(istream &, string &) + +istream & getline, __default_alloc_template>(istream &, string &) +istream & getline(istream &, string &) + +ostream& operator<< , allocator>(ostream&, string const&) +ostream & operator<<(ostream &, string const &) + +istream& operator>> , allocator>(istream&, string&) +istream & operator>>(istream &, string &) + +std::basic_ostream >::operator<<(long) +ostream::operator<<(long) diff --git a/libregex/tests/regex_test.cpp b/libregex/tests/regex_test.cpp new file mode 100644 index 0000000..66261a5 --- /dev/null +++ b/libregex/tests/regex_test.cpp @@ -0,0 +1,93 @@ +/** + * @file regex_test.cpp + * + * A simple test for libregex. Run it through: + * $ regex_test + * or + * $ regex_test filename(s) + * when no argument is provided "mangled-name" is used, + * see it for the input file format + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#include "string_manip.h" + +#include "op_regex.h" + +#include +#include + +using namespace std; + +static int nr_error = 0; + +static void do_test(istream& fin) +{ + regular_expression_replace rep; + + setup_regex(rep, "../stl.pat"); + + string test, expect, last; + bool first = true; + while (getline(fin, last)) { + last = trim(last); + if (last.length() == 0 || last[0] == '#') + continue; + + if (first) { + test = last; + first = false; + } else { + expect = last; + first = true; + string str(test); + rep.execute(str); + if (str != expect) { + cerr << "mistmatch: test, expect, returned\n" + << '"' << test << '"' << endl + << '"' << expect << '"' << endl + << '"' << str << '"' << endl; + ++nr_error; + } + } + } + + if (!first) { + cerr << "input file ill formed\n"; + } +} + +int main(int argc, char * argv[]) +{ + try { + if (argc > 1) { + for (int i = 1; i < argc; ++i) { + ifstream fin(argv[i]); + do_test(fin); + } + } else { + ifstream fin("mangled-name"); + if (!fin) { + cerr << "Unable to open input test " + << "\"mangled_name\"\n" << endl; + exit(EXIT_FAILURE); + } + do_test(fin); + } + } + catch (bad_regex const & e) { + cerr << "bad_regex " << e.what() << endl; + return EXIT_FAILURE; + } + catch (exception const & e) { + cerr << "exception: " << e.what() << endl; + return EXIT_FAILURE; + } + + return nr_error ? EXIT_FAILURE : EXIT_SUCCESS; +} + diff --git a/libutil++/Makefile.am b/libutil++/Makefile.am new file mode 100644 index 0000000..5c894a4 --- /dev/null +++ b/libutil++/Makefile.am @@ -0,0 +1,37 @@ +SUBDIRS = . tests + +AM_CPPFLAGS= \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libop +AM_CXXFLAGS = @OP_CXXFLAGS@ + +noinst_LIBRARIES = libutil++.a +libutil___a_SOURCES = \ + op_bfd.cpp \ + op_bfd.h \ + bfd_support.cpp \ + bfd_support.h \ + string_filter.cpp \ + string_filter.h \ + glob_filter.cpp \ + glob_filter.h \ + growable_vector.h \ + path_filter.cpp \ + path_filter.h \ + file_manip.cpp \ + file_manip.h \ + stream_util.cpp \ + stream_util.h \ + string_manip.cpp \ + string_manip.h \ + cverb.cpp \ + cverb.h \ + generic_spec.h \ + op_exception.cpp \ + op_exception.h \ + child_reader.cpp \ + child_reader.h \ + unique_storage.h \ + utility.h \ + cached_value.h \ + comma_list.h diff --git a/libutil++/Makefile.in b/libutil++/Makefile.in new file mode 100644 index 0000000..53f9405 --- /dev/null +++ b/libutil++/Makefile.in @@ -0,0 +1,597 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(libutil___a_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = libutil++ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libutil___a_AR = $(AR) $(ARFLAGS) +libutil___a_LIBADD = +am_libutil___a_OBJECTS = op_bfd.$(OBJEXT) bfd_support.$(OBJEXT) \ + string_filter.$(OBJEXT) glob_filter.$(OBJEXT) \ + path_filter.$(OBJEXT) file_manip.$(OBJEXT) \ + stream_util.$(OBJEXT) string_manip.$(OBJEXT) cverb.$(OBJEXT) \ + op_exception.$(OBJEXT) child_reader.$(OBJEXT) +libutil___a_OBJECTS = $(am_libutil___a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libutil___a_SOURCES) +DIST_SOURCES = $(libutil___a_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +SUBDIRS = . tests +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libop + +AM_CXXFLAGS = @OP_CXXFLAGS@ +noinst_LIBRARIES = libutil++.a +libutil___a_SOURCES = \ + op_bfd.cpp \ + op_bfd.h \ + bfd_support.cpp \ + bfd_support.h \ + string_filter.cpp \ + string_filter.h \ + glob_filter.cpp \ + glob_filter.h \ + growable_vector.h \ + path_filter.cpp \ + path_filter.h \ + file_manip.cpp \ + file_manip.h \ + stream_util.cpp \ + stream_util.h \ + string_manip.cpp \ + string_manip.h \ + cverb.cpp \ + cverb.h \ + generic_spec.h \ + op_exception.cpp \ + op_exception.h \ + child_reader.cpp \ + child_reader.h \ + unique_storage.h \ + utility.h \ + cached_value.h \ + comma_list.h + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libutil++/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libutil++/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libutil++.a: $(libutil___a_OBJECTS) $(libutil___a_DEPENDENCIES) + -rm -f libutil++.a + $(libutil___a_AR) libutil++.a $(libutil___a_OBJECTS) $(libutil___a_LIBADD) + $(RANLIB) libutil++.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bfd_support.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/child_reader.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cverb.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_manip.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glob_filter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_bfd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_exception.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/path_filter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_util.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string_filter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string_manip.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LIBRARIES) +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-generic clean-noinstLIBRARIES clean-recursive \ + ctags ctags-recursive distclean distclean-compile \ + distclean-generic distclean-recursive distclean-tags distdir \ + dvi dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libutil++/bfd_support.cpp b/libutil++/bfd_support.cpp new file mode 100644 index 0000000..af83b1d --- /dev/null +++ b/libutil++/bfd_support.cpp @@ -0,0 +1,556 @@ +/** + * @file bfd_support.cpp + * BFD muck we have to deal with. + * + * @remark Copyright 2005 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#include "bfd_support.h" + +#include "op_bfd.h" +#include "op_fileio.h" +#include "string_manip.h" +#include "cverb.h" + +#include +#include +#include +#include + +using namespace std; + +extern verbose vbfd; + +namespace { + + +void check_format(string const & file, bfd ** ibfd) +{ + if (!bfd_check_format_matches(*ibfd, bfd_object, NULL)) { + cverb << vbfd << "BFD format failure for " << file << endl; + bfd_close(*ibfd); + *ibfd = NULL; + } +} + + +bool separate_debug_file_exists(string const & name, unsigned long const crc) +{ + unsigned long file_crc = 0; + // The size of 2 * 1024 elements for the buffer is arbitrary. + char buffer[2 * 1024]; + + ifstream file(name.c_str()); + if (!file) + return false; + + cverb << vbfd << "found " << name; + while (file) { + file.read(buffer, sizeof(buffer)); + file_crc = calc_crc32(file_crc, + reinterpret_cast(&buffer[0]), + file.gcount()); + } + cverb << vbfd << " with crc32 = " << hex << file_crc << endl; + return crc == file_crc; +} + + +bool get_debug_link_info(bfd * ibfd, string & filename, unsigned long & crc32) +{ + asection * sect; + + cverb << vbfd << "fetching .gnu_debuglink section" << endl; + sect = bfd_get_section_by_name(ibfd, ".gnu_debuglink"); + + if (sect == NULL) + return false; + + bfd_size_type debuglink_size = bfd_section_size(ibfd, sect); + char contents[debuglink_size]; + cverb << vbfd + << ".gnu_debuglink section has size " << debuglink_size << endl; + + bfd_get_section_contents(ibfd, sect, + reinterpret_cast(contents), + static_cast(0), debuglink_size); + + /* CRC value is stored after the filename, aligned up to 4 bytes. */ + size_t filename_len = strlen(contents); + size_t crc_offset = filename_len + 1; + crc_offset = (crc_offset + 3) & ~3; + + crc32 = bfd_get_32(ibfd, + reinterpret_cast(contents + crc_offset)); + filename = string(contents, filename_len); + cverb << vbfd << ".gnu_debuglink filename is " << filename << endl; + return true; +} + + +/** + * With Objective C, we'll get strings like: + * + * _i_GSUnicodeString__rangeOfCharacterSetFromSet_options_range + * + * for the symbol name, and: + * -[GSUnicodeString rangeOfCharacterFromSet:options:range:] + * + * for the function name, so we have to do some looser matching + * than for other languages (unfortunately, it's not possible + * to demangle Objective C symbols). + */ +bool objc_match(string const & sym, string const & method) +{ + if (method.length() < 3) + return false; + + string mangled; + + if (is_prefix(method, "-[")) { + mangled += "_i_"; + } else if (is_prefix(method, "+[")) { + mangled += "_c_"; + } else { + return false; + } + + string::const_iterator it = method.begin() + 2; + string::const_iterator const end = method.end(); + + bool found_paren = false; + + for (; it != end; ++it) { + switch (*it) { + case ' ': + mangled += '_'; + if (!found_paren) + mangled += '_'; + break; + case ':': + mangled += '_'; + break; + case ')': + case ']': + break; + case '(': + found_paren = true; + mangled += '_'; + break; + default: + mangled += *it; + } + } + + return sym == mangled; +} + + +/* + * With a binary image where some objects are missing debug + * info, we can end up attributing to a completely different + * function (#484660): bfd_nearest_line() will happily move from one + * symbol to the nearest one it can find with debug information. + * To mitigate this problem, we check that the symbol name + * matches the returned function name. + * + * However, this check fails in some cases it shouldn't: + * Objective C, and C++ static inline functions (as discussed in + * GCC bugzilla #11774). So, we have a looser check that + * accepts merely a substring, plus some magic for Objective C. + * + * If even the loose check fails, then we give up. + */ +bool is_correct_function(string const & function, string const & name) +{ + if (name == function) + return true; + + if (objc_match(name, function)) + return true; + + // warn the user if we had to use the loose check + if (name.find(function) != string::npos) { + static bool warned = false; + if (!warned) { + cerr << "warning: some functions compiled without " + << "debug information may have incorrect source " + << "line attributions" << endl; + warned = true; + } + cverb << vbfd << "is_correct_function(" << function << ", " + << name << ") fuzzy match." << endl; + return true; + } + + return false; +} + + +/* + * binutils 2.12 and below have a small bug where functions without a + * debug entry at the prologue start do not give a useful line number + * from bfd_find_nearest_line(). This can happen with certain gcc + * versions such as 2.95. + * + * We work around this problem by scanning forward for a vma with valid + * linenr info, if we can't get a valid line number. Problem uncovered + * by Norbert Kaufmann. The work-around decreases, on the tincas + * application, the number of failure to retrieve linenr info from 835 + * to 173. Most of the remaining are c++ inline functions mainly from + * the STL library. Fix #529622 + */ +void fixup_linenr(bfd * abfd, asection * section, asymbol ** syms, + string const & name, bfd_vma pc, + char const ** filename, unsigned int * line) +{ + char const * cfilename; + char const * function; + unsigned int linenr; + + // FIXME: looking at debug info for all gcc version shows than + // the same problems can -perhaps- occur for epilog code: find a + // samples files with samples in epilog and try opreport -l -g + // on it, check it also with opannotate. + + // first restrict the search on a sensible range of vma, 16 is + // an intuitive value based on epilog code look + size_t max_search = 16; + size_t section_size = bfd_section_size(abfd, section); + if (pc + max_search > section_size) + max_search = section_size - pc; + + for (size_t i = 1; i < max_search; ++i) { + bool ret = bfd_find_nearest_line(abfd, section, syms, pc + i, + &cfilename, &function, + &linenr); + + if (ret && cfilename && function && linenr != 0 + && is_correct_function(function, name)) { + *filename = cfilename; + *line = linenr; + return; + } + } +} + + +} // namespace anon + + +bfd * open_bfd(string const & file) +{ + /* bfd keeps its own reference to the filename char *, + * so it must have a lifetime longer than the ibfd */ + bfd * ibfd = bfd_openr(file.c_str(), NULL); + if (!ibfd) { + cverb << vbfd << "bfd_openr failed for " << file << endl; + return NULL; + } + + check_format(file, &ibfd); + + return ibfd; +} + + +bfd * fdopen_bfd(string const & file, int fd) +{ + /* bfd keeps its own reference to the filename char *, + * so it must have a lifetime longer than the ibfd */ + bfd * ibfd = bfd_fdopenr(file.c_str(), NULL, fd); + if (!ibfd) { + cverb << vbfd << "bfd_openr failed for " << file << endl; + return NULL; + } + + check_format(file, &ibfd); + + return ibfd; +} + + +bool find_separate_debug_file(bfd * ibfd, string const & dir_in, + string const & global_in, string & filename) +{ + string dir(dir_in); + string global(global_in); + string basename; + unsigned long crc32; + + if (!get_debug_link_info(ibfd, basename, crc32)) + return false; + + if (dir.size() > 0 && dir.at(dir.size() - 1) != '/') + dir += '/'; + + if (global.size() > 0 && global.at(global.size() - 1) != '/') + global += '/'; + + cverb << vbfd << "looking for debugging file " << basename + << " with crc32 = " << hex << crc32 << endl; + + string first_try(dir + basename); + string second_try(dir + ".debug/" + basename); + + if (dir.size() > 0 && dir[0] == '/') + dir = dir.substr(1); + + string third_try(global + dir + basename); + + if (separate_debug_file_exists(first_try, crc32)) + filename = first_try; + else if (separate_debug_file_exists(second_try, crc32)) + filename = second_try; + else if (separate_debug_file_exists(third_try, crc32)) + filename = third_try; + else + return false; + + return true; +} + + +bool interesting_symbol(asymbol * sym) +{ + // #717720 some binutils are miscompiled by gcc 2.95, one of the + // typical symptom can be catched here. + if (!sym->section) { + ostringstream os; + os << "Your version of binutils seems to have a bug.\n" + << "Read http://oprofile.sf.net/faq/#binutilsbug\n"; + throw op_runtime_error(os.str()); + } + + if (!(sym->section->flags & SEC_CODE)) + return false; + + // returning true for fix up in op_bfd_symbol() + if (!sym->name || sym->name[0] == '\0') + return true; + + // C++ exception stuff + if (sym->name[0] == '.' && sym->name[1] == 'L') + return false; + + /* This case cannot be moved to boring_symbol(), + * because that's only used for duplicate VMAs, + * and sometimes this symbol appears at an address + * different from all other symbols. + */ + if (!strcmp("gcc2_compiled.", sym->name)) + return false; + + return true; +} + + +bool boring_symbol(op_bfd_symbol const & first, op_bfd_symbol const & second) +{ + if (first.name() == "Letext") + return true; + else if (second.name() == "Letext") + return false; + + if (first.name().substr(0, 2) == "??") + return true; + else if (second.name().substr(0, 2) == "??") + return false; + + if (first.hidden() && !second.hidden()) + return true; + else if (!first.hidden() && second.hidden()) + return false; + + if (first.name()[0] == '_' && second.name()[0] != '_') + return true; + else if (first.name()[0] != '_' && second.name()[0] == '_') + return false; + + if (first.weak() && !second.weak()) + return true; + else if (!first.weak() && second.weak()) + return false; + + return false; +} + + +bool bfd_info::has_debug_info() const +{ + if (!valid()) + return false; + + for (asection const * sect = abfd->sections; sect; sect = sect->next) { + if (sect->flags & SEC_DEBUGGING) + return true; + } + + return false; +} + + +bfd_info::~bfd_info() +{ + free(synth_syms); + close(); +} + + +void bfd_info::close() +{ + if (abfd) + bfd_close(abfd); +} + + +#if SYNTHESIZE_SYMBOLS +bool bfd_info::get_synth_symbols() +{ + extern const bfd_target bfd_elf64_powerpc_vec; + extern const bfd_target bfd_elf64_powerpcle_vec; + bool is_elf64_powerpc_target = (abfd->xvec == &bfd_elf64_powerpc_vec) + || (abfd->xvec == &bfd_elf64_powerpcle_vec); + + if (!is_elf64_powerpc_target) + return false; + + void * buf; + uint tmp; + long nr_mini_syms = bfd_read_minisymbols(abfd, 0, &buf, &tmp); + if (nr_mini_syms < 1) + return false; + + asymbol ** mini_syms = (asymbol **)buf; + buf = NULL; + + long nr_synth_syms = bfd_get_synthetic_symtab(abfd, nr_mini_syms, + mini_syms, 0, + NULL, &synth_syms); + + if (nr_synth_syms < 0) { + free(mini_syms); + return false; + } + + cverb << vbfd << "mini_syms: " << dec << nr_mini_syms << hex << endl; + cverb << vbfd << "synth_syms: " << dec << nr_synth_syms << hex << endl; + + nr_syms = nr_mini_syms + nr_synth_syms; + syms.reset(new asymbol *[nr_syms + 1]); + + for (size_t i = 0; i < (size_t)nr_mini_syms; ++i) + syms[i] = mini_syms[i]; + + + for (size_t i = 0; i < (size_t)nr_synth_syms; ++i) + syms[nr_mini_syms + i] = synth_syms + i; + + + free(mini_syms); + + // bfd_canonicalize_symtab does this, so shall we + syms[nr_syms] = NULL; + + return true; +} +#else +bool bfd_info::get_synth_symbols() +{ + return false; +} +#endif /* SYNTHESIZE_SYMBOLS */ + + +void bfd_info::get_symbols() +{ + if (!abfd) + return; + + cverb << vbfd << "bfd_info::get_symbols() for " + << bfd_get_filename(abfd) << endl; + + if (get_synth_symbols()) + return; + + if (bfd_get_file_flags(abfd) & HAS_SYMS) + nr_syms = bfd_get_symtab_upper_bound(abfd); + + cverb << vbfd << "bfd_get_symtab_upper_bound: " << dec + << nr_syms << hex << endl; + + nr_syms /= sizeof(asymbol *); + + if (nr_syms < 1) + return; + + syms.reset(new asymbol *[nr_syms]); + + nr_syms = bfd_canonicalize_symtab(abfd, syms.get()); + + cverb << vbfd << "bfd_canonicalize_symtab: " << dec + << nr_syms << hex << endl; +} + + +linenr_info const +find_nearest_line(bfd_info const & b, op_bfd_symbol const & sym, + unsigned int offset) +{ + char const * function = ""; + char const * cfilename = ""; + unsigned int linenr = 0; + linenr_info info; + bfd * abfd; + asymbol ** syms; + asection * section; + bfd_vma pc; + bool ret; + + if (!b.valid()) + goto fail; + + // take care about artificial symbol + if (!sym.symbol()) + goto fail; + + abfd = b.abfd; + syms = b.syms.get(); + section = sym.symbol()->section; + pc = (sym.value() + offset) - sym.filepos(); + + if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0) + goto fail; + + if (pc >= bfd_section_size(abfd, section)) + goto fail; + + ret = bfd_find_nearest_line(abfd, section, syms, pc, &cfilename, + &function, &linenr); + + if (!ret || !cfilename) + goto fail; + + if (!is_correct_function(function, sym.name())) + goto fail; + + if (linenr == 0) { + fixup_linenr(abfd, section, syms, sym.name(), pc, &cfilename, + &linenr); + } + + info.found = true; + info.filename = cfilename; + info.line = linenr; + return info; + +fail: + info.found = false; + // some stl lacks string::clear() + info.filename.erase(info.filename.begin(), info.filename.end()); + info.line = 0; + return info; +} diff --git a/libutil++/bfd_support.h b/libutil++/bfd_support.h new file mode 100644 index 0000000..3b92655 --- /dev/null +++ b/libutil++/bfd_support.h @@ -0,0 +1,123 @@ +/** + * @file bfd_support.h + * BFD muck we have to deal with. + * + * @remark Copyright 2005 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#ifndef BFD_SUPPORT_H +#define BFD_SUPPORT_H + +#include "utility.h" +#include "op_types.h" + +#include + +#include + +class op_bfd_symbol; + +/// holder for BFD state we must keep +struct bfd_info { + bfd_info() : abfd(0), nr_syms(0), synth_syms(0) {} + + ~bfd_info(); + + /// close the BFD, setting abfd to NULL + void close(); + + /// return true if BFD is readable + bool valid() const { return abfd; } + + /// return true if BFD has debug info + bool has_debug_info() const; + + /// pick out the symbols from the bfd, if we can + void get_symbols(); + + /// the actual BFD + bfd * abfd; + /// normal symbols (includes synthesized symbols) + scoped_array syms; + /// nr. symbols + size_t nr_syms; + +private: + /** + * Acquire the synthetic symbols if we need to. + */ + bool get_synth_symbols(); + + /** + * On PPC64, synth_syms points to an array of synthetic asymbol + * structs returned from bfd_get_synthetic_symtab. The syms + * member points into this array, so we have to keep it around + * until ~bfd_info time. + */ + asymbol * synth_syms; + +}; + + +/* + * find_separate_debug_file - return true if a valid separate debug file found + * @param ibfd binary file + * @param dir_in directory holding the binary file + * @param global_in + * @param filename path to valid debug file + * + * Search order for debug file and use first one found: + * 1) dir_in directory + * 2) dir_in/.debug directory + * 3) global_in/dir_in directory + * + * Newer binutils and Linux distributions (e.g. Fedora) allow the + * creation of debug files that are separate from the binary. The + * debugging information is stripped out of the binary file, placed in + * this separate file, and a link to the new file is placed in the + * binary. The debug files hold the information needed by the debugger + * (and OProfile) to map machine instructions back to source code. + */ +extern bool +find_separate_debug_file(bfd * ibfd, + std::string const & dir_in, + std::string const & global_in, + std::string & filename); + +/// open the given BFD +bfd * open_bfd(std::string const & file); + +/// open the given BFD from the fd +bfd * fdopen_bfd(std::string const & file, int fd); + +/// Return true if the symbol is worth looking at +bool interesting_symbol(asymbol * sym); + +/** + * return true if the first symbol is less interesting than the second symbol + * boring symbol are eliminated when multiple symbol exist at the same vma + */ +bool boring_symbol(op_bfd_symbol const & first, op_bfd_symbol const & second); + +/// debug info for a given pc +struct linenr_info { + /// did we find something? + bool found; + /// filename + std::string filename; + /// line number + unsigned int line; +}; + +/** + * Attempt to locate a filename + line number for the given symbol and + * offset. + */ +linenr_info const +find_nearest_line(bfd_info const & ibfd, op_bfd_symbol const & sym, + unsigned int offset); + +#endif /* !BFD_SUPPORT_H */ diff --git a/libutil++/cached_value.h b/libutil++/cached_value.h new file mode 100644 index 0000000..362e16a --- /dev/null +++ b/libutil++/cached_value.h @@ -0,0 +1,52 @@ +/** + * @file cached_value.h + * Hold a cached value. + * + * @remark Copyright 2005 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#ifndef CACHED_VALUE_H +#define CACHED_VALUE_H + +#include "op_exception.h" + +/** + * Hold a single value, returning a cached value if there is one. + */ +template +class cached_value +{ +public: + cached_value() : set(false) {} + + typedef T value_type; + + /// return the cached value + value_type const get() const { + if (!set) + throw op_fatal_error("cached value not set"); + return value; + } + + /// return true if a value is cached + bool cached() const { return set; } + + /// set the contained value + value_type const reset(value_type const & val) { + value = val; + set = true; + return value; + } + +private: + /// the cached value + value_type value; + /// is the value valid? + bool set; +}; + + +#endif /* !CACHED_VALUE_H */ diff --git a/libutil++/child_reader.cpp b/libutil++/child_reader.cpp new file mode 100644 index 0000000..8e1ea70 --- /dev/null +++ b/libutil++/child_reader.cpp @@ -0,0 +1,273 @@ +/** + * @file child_reader.cpp + * Facility for reading from child processes + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include +#include + +#include +#include +#include + +#include "op_libiberty.h" +#include "child_reader.h" + +using namespace std; + +child_reader::child_reader(string const & cmd, vector const & args) + : + fd1(-1), fd2(-1), + pos1(0), end1(0), + pos2(0), end2(0), + pid(0), + first_error(0), + buf2(0), sz_buf2(0), + buf1(new char[PIPE_BUF]), + process_name(cmd), + is_terminated(true), + terminate_on_exception(false), + forked(false) +{ + exec_command(cmd, args); +} + + +child_reader::~child_reader() +{ + terminate_process(); + delete [] buf1; + if (buf2) { + // allocated through C alloc + free(buf2); + } +} + + +void child_reader::exec_command(string const & cmd, vector const & args) +{ + int pstdout[2]; + int pstderr[2]; + + if (pipe(pstdout) == -1 || pipe(pstderr) == -1) { + first_error = errno; + return; + } + + pid = fork(); + switch (pid) { + case -1: + first_error = errno; + return; + + case 0: { + char const ** argv = new char const *[args.size() + 2]; + size_t i; + argv[0] = cmd.c_str(); + + for (i = 1 ; i <= args.size() ; ++i) + argv[i] = args[i - 1].c_str(); + + argv[i] = 0; + + // child: we can cleanup a few fd + close(pstdout[0]); + dup2(pstdout[1], STDOUT_FILENO); + close(pstdout[1]); + close(pstderr[0]); + dup2(pstderr[1], STDERR_FILENO); + close(pstderr[1]); + + execvp(cmd.c_str(), (char * const *)argv); + + int ret_code = errno; + + // we can communicate with parent by writing to stderr + // and by returning a non zero error code. Setting + // first_error in the child is a non-sense + + // we are in the child process: so this error message + // is redirect to the parent process + cerr << "Couldn't exec \"" << cmd << "\" : " + << strerror(errno) << endl; + exit(ret_code); + } + + default:; + // parent: we do not write on these fd. + close(pstdout[1]); + close(pstderr[1]); + forked = true; + break; + } + + fd1 = pstdout[0]; + fd2 = pstderr[0]; + + is_terminated = false; + + return; +} + + +bool child_reader::block_read() +{ + fd_set read_fs; + + FD_ZERO(&read_fs); + FD_SET(fd1, &read_fs); + FD_SET(fd2, &read_fs); + + if (select(max(fd1, fd2) + 1, &read_fs, 0, 0, 0) >= 0) { + if (FD_ISSET(fd1, &read_fs)) { + ssize_t temp = read(fd1, buf1, PIPE_BUF); + if (temp >= 0) + end1 = temp; + else + end1 = 0; + } + + if (FD_ISSET(fd2, &read_fs)) { + if (end2 >= sz_buf2) { + sz_buf2 = sz_buf2 ? sz_buf2 * 2 : PIPE_BUF; + buf2 = (char *)xrealloc(buf2, sz_buf2); + } + + ssize_t temp = read(fd2, buf2 + end2, sz_buf2 - end2); + if (temp > 0) + end2 += temp; + } + } + + bool ret = !(end1 == 0 && end2 == 0); + + if (end1 == -1) + end1 = 0; + if (end2 == -1) + end2 = 0; + + return ret; +} + + +bool child_reader::getline(string & result) +{ + // some stl lacks string::clear() + result.erase(result.begin(), result.end()); + + bool ok = true; + bool ret = true; + bool can_stop = false; + do { + int temp = end2; + if (pos1 >= end1) { + pos1 = 0; + ret = block_read(); + } + + // for efficiency try to copy as much as we can of data + ssize_t temp_pos = pos1; + while (temp_pos < end1 && ok) { + char ch = buf1[temp_pos++]; + if (ch == '\n') + ok = false; + } + + // !ok ==> endl has been read so do not copy it. + result.append(&buf1[pos1], (temp_pos - pos1) - !ok); + + if (!ok || !end1) + can_stop = true; + + // reading zero byte from stdout don't mean than we exhausted + // all stdout output, we must continue to try until reading + // stdout and stderr return zero byte. + if (ok && temp != end2) + can_stop = false; + + pos1 = temp_pos; + } while (!can_stop); + + // Is this correct ? + return end1 != 0 || result.length() != 0; +} + + +bool child_reader::get_data(ostream & out, ostream & err) +{ + bool ret = true; + while (ret) { + ret = block_read(); + + out.write(buf1, end1); + err.write(buf2, end2); + + end1 = end2 = 0; + } + + return first_error == 0; +} + + +int child_reader::terminate_process() +{ + // can be called explicitely or by dtor, + // we must protect against multiple call + if (!is_terminated) { + int ret; + waitpid(pid, &ret, 0); + + is_terminated = true; + + if (WIFEXITED(ret)) { + first_error = WEXITSTATUS(ret) | WIFSIGNALED(ret); + } else if (WIFSIGNALED(ret)) { + terminate_on_exception = true; + first_error = WTERMSIG(ret); + } else { + // FIXME: this seems impossible, waitpid *must* wait + // and either the process terminate normally or through + // a signal. + first_error = -1; + } + } + + if (fd1 != -1) { + close(fd1); + fd1 = -1; + } + if (fd2 != -1) { + close(fd2); + fd2 = -1; + } + + return first_error; +} + + +string child_reader::error_str() const +{ + ostringstream err; + if (!forked) { + err << string("unable to fork, error: ") + << strerror(first_error); + } else if (is_terminated) { + if (first_error) { + if (terminate_on_exception) { + err << process_name << " terminated by signal " + << first_error; + } else { + err << process_name << " return " + << first_error; + } + } + } + + return err.str(); +} diff --git a/libutil++/child_reader.h b/libutil++/child_reader.h new file mode 100644 index 0000000..f3bf71a --- /dev/null +++ b/libutil++/child_reader.h @@ -0,0 +1,111 @@ +/** + * @file child_reader.h + * Facility for reading from child processes + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef CHILD_READER_H +#define CHILD_READER_H + +#include + +#include +#include + +/** + * a class to read stdout / stderr from a child process. + * + * two interfaces are provided. read line by line: getline() or read all data + * in one : get_data(). In all case get_data() must be called once to flush the + * stderr child output + */ +/* + * FIXME: code review is needed: + * - check the getline()/get_data()/block_read() interface. + * the expected behavior is: + * caller can call getline until nothing is available from the stdout of the + * child. in this case child stderr is acumulated in buf2 and can be read + * through get_data(). get_data() is blocking until the child close stderr / + * stdout (even if the child die by a signal ?). The following corner case must + * work but I'm unsure if the code reflect this behavior: the last line of the + * child stdout have not necessarilly a LF terminator. the child can output any + * size of data in stderr. + */ +class child_reader { +public: + /** fork a process. use error() to get error code. Do not try to + * use other public member interface if error() return non-zero */ + child_reader(std::string const & cmd, + std::vector const & args); + + /** wait for the termination of the child process if this have not + * already occur. In this case return code of the child process is not + * available. */ + ~child_reader(); + + /** fill result from on line of stdout of the child process. + * must be used as: + * child_reader reader(...); + * while (reader.getline(line)) .... */ + bool getline(std::string & result); + + /** fill out / err with the stdout / stderr of the child process. + * You can call this after calling one or more time getline(...). This + * call is blocking until the child die and so on all subsequent + * call will fail */ + bool get_data(std::ostream & out, std::ostream & err); + + /** rather to rely on dtor to wait for the termination of the child you + * can use terminate_process() to get the return code of the child + * process */ + int terminate_process(); + + /** return the status of the first error encoutered + * != 0 : something feel wrong, use error_str() to get an error + * message */ + int error() const { return first_error; } + + /** + * return an error message if appropriate, if the process has + * been successfully exec'ed and is not terminate the error message + * is always empty. Error message is also empty if the child process + * terminate successfully. Else three type of error message exist: + * - "unable to fork" followed by sterror(errno) + * - "process_name return xxx" xxx is return code + * - "process_name terminated by signal xxx" xxx is signal number + */ + std::string error_str() const; + +private: + // ctor helper: create the child process. + void exec_command(std::string const & cmd, + std::vector const & args); + // return false when eof condition is reached on fd1. fd2 can have + // already input in the pipe buffer or in buf2. + bool block_read(); + + int fd1; + int fd2; + ssize_t pos1; + ssize_t end1; + ssize_t pos2; + ssize_t end2; + pid_t pid; + int first_error; + // child stderr is handled especially, we need to retain data even + // if caller read only stdout of the child. + char * buf2; + ssize_t sz_buf2; + char * buf1; + std::string process_name; + bool is_terminated; + bool terminate_on_exception; + bool forked; +}; + +#endif // CHILD_READER_H diff --git a/libutil++/comma_list.h b/libutil++/comma_list.h new file mode 100644 index 0000000..1868ee0 --- /dev/null +++ b/libutil++/comma_list.h @@ -0,0 +1,102 @@ +/** + * @file comma_list.h + * Container holding items from a list of comma separated items + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#ifndef COMMA_LIST_H +#define COMMA_LIST_H + +#include +#include + +#include "string_manip.h" + +/** + * hold a list of item of type T, tracking also if item has been set. + */ +template +class comma_list +{ +public: + comma_list(); + + /** + * @param str list of comma separated item + * + * setup items array according to str parameters. Implement PP:3.17 + * w/o restriction on charset and with the special string all which + * match anything. + */ + void set(std::string const & str); + + /// return true if a specific value is held by this container + bool is_set() const { + return !is_all; + } + + /** + * @param value the value to test + * + * return true if value match one the stored value in items + */ + bool match(T const & value) const; + +private: + typedef T value_type; + typedef std::vector container_type; + typedef typename container_type::const_iterator const_iterator; + bool is_all; + container_type items; +}; + + +template +comma_list::comma_list() + : is_all(true) +{ +} + + +template +void comma_list::set(std::string const & str) +{ + items.clear(); + + is_all = false; + + std::vector result = separate_token(str, ','); + for (size_t i = 0 ; i < result.size() ; ++i) { + if (result[i] == "all") { + is_all = true; + items.clear(); + break; + } + items.push_back(op_lexical_cast(result[i])); + } +} + + +template +bool comma_list::match(T const & value) const +{ + if (is_all) + return true; + + const_iterator cit = items.begin(); + const_iterator const end = items.end(); + + for (; cit != end; ++cit) { + if (value == *cit) + return true; + } + + return false; +} + + +#endif /* !COMMA_LIST_H */ diff --git a/libutil++/cverb.cpp b/libutil++/cverb.cpp new file mode 100644 index 0000000..247794c --- /dev/null +++ b/libutil++/cverb.cpp @@ -0,0 +1,119 @@ +/** + * @file cverb.cpp + * verbose output stream + * + * @remark Copyright 2002, 2004 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include +#include +#include +#include + +#include "cverb.h" + +using namespace std; + +cverb_object cverb; +verbose vlevel1("level1"); +verbose vdebug("debug"); +verbose vstats("stats"); +verbose vsfile("sfile"); + +namespace { + +// The right way is to use: ofstream fout; but cverb(fout.rdbuf()) receive +// a null pointer and stl shipped with 2.91 segfault. +ofstream fout("/dev/null"); +ostream null_stream(fout.rdbuf()); + +// Used to setup the bad bit in our null stream so output will fail earlier +// and overhead will be smaller. +struct setup_stream { + setup_stream(); +}; + +setup_stream::setup_stream() +{ + null_stream.clear(ios::badbit); +} + +setup_stream setup; + +// We use a multimap because user can create multiple verbose object with +// the same name, these are synonymous, setting up one to true will setup +// all with the same name to true. +typedef multimap recorder_t; +// The recorder is lazilly created by verbose object ctor +static recorder_t * object_map; + +} // anonymous namespace + + +verbose::verbose(char const * name) + : + set(false) +{ + // all params is treated a part, there is no need to create a + // verbose all("all"); it's meaningless. "all" verbose named object is + // reserved. + if (strcmp(name, "all") == 0) + return; + if (!object_map) + object_map = new recorder_t; + object_map->insert(recorder_t::value_type(name, this)); +} + + +verbose verbose::operator|(verbose const & rhs) +{ + verbose result(*this); + result.set = result.set || rhs.set; + return result; +} + + +verbose verbose::operator&(verbose const & rhs) +{ + verbose result(*this); + result.set = result.set && rhs.set; + return result; +} + + +bool verbose::setup(string const & name) +{ + if (name == "all") { + null_stream.rdbuf(cout.rdbuf()); + null_stream.clear(); + return true; + } + if (!object_map) + object_map = new recorder_t; + pair p_it = + object_map->equal_range(name); + if (p_it.first == p_it.second) + return false; + for (; p_it.first != p_it.second; ++p_it.first) + p_it.first->second->set = true; + return true; +} + + +bool verbose::setup(vector const & names) +{ + for (size_t i = 0; i < names.size(); ++i) + if (!setup(names[i])) + return false; + return true; +} + + +ostream& operator<<(cverb_object &, verbose const & v) +{ + return v.set ? cout : null_stream; +} diff --git a/libutil++/cverb.h b/libutil++/cverb.h new file mode 100644 index 0000000..6e71dc3 --- /dev/null +++ b/libutil++/cverb.h @@ -0,0 +1,82 @@ +/** + * @file cverb.h + * verbose output stream + * + * @remark Copyright 2002, 2004 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef CVERB_H +#define CVERB_H + +#include +#include +#include + +struct cverb_object { }; + +/** + * verbose object, all output through this stream are made only + * if a verbose object with a true state is injected in the stream. + */ +extern cverb_object cverb; + +/** + * typical use: + * declare some verbose global object: + * verbose debug("debug"); + * verbose stats("stats"); + * verbose level2("level2"); + * + * setup from command line the state of these objects + * + * verbose::setup(command_line_args_to'--verbose='); + * + * cverb << stats << "stats\n"; + * cverb << (stats&level2) << "very verbose stats\n" + * cverb << (stats|debug) << "bar\n"; + * these will give a compile time error + * cverb << stats << "foo" << debug << "bar"; + * cout << stats << "foo"; + * + * In critical code path cverb can be used in the more efficient way: + * if (cverb << vdebug) + * cverb << vdebug << "foo" << "bar"; + * the condition test the fails bit for the returned stream while the later + * build a sentry object for each << (more efficient even with one level of <<) + */ +class verbose { + /// The returned stream is either a null stream or cout. + friend std::ostream & operator<<(cverb_object &, verbose const &); +public: + /** + * create a verbose object named name, the ctor auto-register name + * as a verbose object, the set state can be intialized through + * verbose::setup(name) + */ + verbose(char const * name); + + verbose operator|(verbose const &); + verbose operator&(verbose const &); + + /// Return false if this named verbose object has not be registred. + static bool setup(std::string const &); + /// convenient interface calling the above for string in args + static bool setup(std::vector const & args); +private: + bool set; +}; + +/** + * predefined general purpose verbose object, comment give their names + */ +extern verbose vlevel1; /**< named "level1" */ +extern verbose vdebug; /**< named "debug" */ +extern verbose vstats; /**< named "stats" */ +// all sample filename manipulation. +extern verbose vsfile; /**< named "sfile" */ + +#endif /* !CVERB_H */ diff --git a/libutil++/file_manip.cpp b/libutil++/file_manip.cpp new file mode 100644 index 0000000..0d35acd --- /dev/null +++ b/libutil++/file_manip.cpp @@ -0,0 +1,176 @@ +/** + * @file file_manip.cpp + * Useful file management helpers + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "op_file.h" + +#include "file_manip.h" +#include "string_manip.h" + +using namespace std; + + +bool copy_file(string const & source, string const & destination) +{ + struct stat buf; + int status = stat(source.c_str(), &buf); + + if (status == 0) { + /* FIXME: This code should avoid using system() if possible. */ + string copy_command("cp -a -f " + source + " " + destination); + status = system(copy_command.c_str()); + } + return !status; +} + + +bool is_directory(string const & dirname) +{ + struct stat st; + return !stat(dirname.c_str(), &st) && S_ISDIR(st.st_mode); +} + + +bool is_files_identical(string const & file1, string const & file2) +{ + struct stat st1; + struct stat st2; + + if (stat(file1.c_str(), &st1) == 0 && stat(file2.c_str(), &st2) == 0) { + if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) + return true; + } + + return false; +} + + +string const op_realpath(string const & name) +{ + static char tmp[PATH_MAX]; + if (!realpath(name.c_str(), tmp)) + return name; + return string(tmp); +} + + +bool op_file_readable(string const & file) +{ + return op_file_readable(file.c_str()); +} + +inline static bool is_directory_name(char const * name) +{ + return name[0] == '.' && + (name[1] == '\0' || + (name[1] == '.' && name[2] == '\0')); +} + + +bool create_file_list(list & file_list, string const & base_dir, + string const & filter, bool recursive) +{ + DIR * dir; + struct dirent * ent; + + if (!(dir = opendir(base_dir.c_str()))) + return false; + + while ((ent = readdir(dir)) != 0) { + if (!is_directory_name(ent->d_name) && + fnmatch(filter.c_str(), ent->d_name, 0) != FNM_NOMATCH) { + if (recursive) { + struct stat stat_buffer; + string name = base_dir + '/' + ent->d_name; + if (stat(name.c_str(), &stat_buffer) == 0) { + if (S_ISDIR(stat_buffer.st_mode) && + !S_ISLNK(stat_buffer.st_mode)) { + // recursive retrieve + create_file_list(file_list, + name, filter, + recursive); + } else { + file_list.push_back(name); + } + } + } else { + file_list.push_back(ent->d_name); + } + } + } + + closedir(dir); + + return true; +} + + +/** + * @param path_name the path where we remove trailing '/' + * + * erase all trailing '/' in path_name except if the last '/' is at pos 0 + */ +static string erase_trailing_path_separator(string const & path_name) +{ + string result(path_name); + + while (result.length() > 1) { + if (result[result.length() - 1] != '/') + break; + result.erase(result.length() - 1, 1); + } + + return result; +} + + +string op_dirname(string const & file_name) +{ + string result = erase_trailing_path_separator(file_name); + if (result.find_first_of('/') == string::npos) + return "."; + + // catch result == "/" + if (result.length() == 1) + return result; + + size_t pos = result.find_last_of('/'); + + // "/usr" must return "/" + if (pos == 0) + pos = 1; + + result.erase(pos, result.length() - pos); + + // "////usr" must return "/" + return erase_trailing_path_separator(result); +} + + +string op_basename(string const & path_name) +{ + string result = erase_trailing_path_separator(path_name); + + // catch result == "/" + if (result.length() == 1) + return result; + + return erase_to_last_of(result, '/'); +} diff --git a/libutil++/file_manip.h b/libutil++/file_manip.h new file mode 100644 index 0000000..ce4154f --- /dev/null +++ b/libutil++/file_manip.h @@ -0,0 +1,88 @@ +/** + * @file file_manip.h + * Useful file management helpers + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef FILE_MANIP_H +#define FILE_MANIP_H + +#include +#include + + +/** + * copy_file - copy a file or subtree + * @param source filename to copy from + * @param destination filename to copy into + * + * return true if copying successful + */ +bool copy_file(std::string const & source, std::string const & destination); + +/// return true if dir is an existing directory +bool is_directory(std::string const & dirname); + +/** + * is_file_identical - check for identical files + * @param file1 first filename + * @param file2 second filename + * + * return true if the two filenames belong to the same file + */ +bool is_files_identical(std::string const & file1, std::string const & file2); + +/** + * op_realpath - resolve symlinks etc. + * Resolve a path as much as possible. Accounts for relative + * paths (from cwd), ".." and ".". For success, the target + * file must exist ! + * + * Resolve a symbolic link as far as possible. + * Returns the original string on failure. + */ +std::string const op_realpath(std::string const & name); + +/// return true if the given file is readable +bool op_file_readable(std::string const & file); + +/** + * @param file_list where to store result + * @param base_dir directory from where lookup start + * @param filter a filename filter + * @param recursive if true lookup in sub-directory + * + * create a filelist under base_dir, filtered by filter and optionally + * looking in sub-directory. If we look in sub-directory only sub-directory + * which match filter are traversed. + */ +bool create_file_list(std::list & file_list, + std::string const & base_dir, + std::string const & filter = "*", + bool recursive = false); + +/** + * op_dirname - get the path component of a filename + * @param file_name filename + * + * Returns the path name of a filename with trailing '/' removed. + */ +std::string op_dirname(std::string const & file_name); + +/** + * op_basename - get the basename of a path + * @param path_name path + * + * Returns the basename of a path with trailing '/' removed. + * + * Always use this instead of the C basename() - header order + * can affect behaviour for basename("/") + */ +std::string op_basename(std::string const & path_name); + +#endif /* !FILE_MANIP_H */ diff --git a/libutil++/generic_spec.h b/libutil++/generic_spec.h new file mode 100644 index 0000000..18bff51 --- /dev/null +++ b/libutil++/generic_spec.h @@ -0,0 +1,97 @@ +/** + * @file generic_spec.h + * Container holding an item or a special "match all" item + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef GENERIC_SPEC_H +#define GENERIC_SPEC_H + +#include +#include +#include + +#include "string_manip.h" + + +/** + * used to hold something like { int cpu_nr, bool is_all }; + * to store a sub part of a samples filename see PP:3.21. + */ +template +class generic_spec +{ +public: + /** + * build a default spec which match anything + */ + generic_spec(); + + /// build a spec from a string, valid argument are "all" + /// or a string convertible to T through istringtream(str) >> data + /// conversion is strict, no space are allowed at begin or end of str + void set(std::string const &); + + /// return true if a specific value is held by this container + bool is_set() const { + return !is_all; + } + + /// return the specific value (only if is_set() == true) + T const value() const { + if (!is_all) + return data; + throw std::out_of_range("generic_spec holds no value"); + } + + /// return true if rhs match this spec. Sub part of PP:3.24 + bool match(T const & rhs) const { + return rhs == data; + } + + /// return true if rhs match this spec. Sub part of PP:3.24 + bool match(generic_spec const & rhs) const { + return is_all || rhs.is_all || rhs.data == data; + } + +private: + T data; + bool is_all; +}; + + +template +generic_spec::generic_spec() + : + data(T()), + is_all(true) +{ +} + + +template +void generic_spec::set(std::string const & str) +{ + if (str == "all") { + is_all = true; + return; + } + + is_all = false; + data = op_lexical_cast(str); +} + + +/// We don't use generic_spec, since it's probably an error to try +/// to use generic_spec we specialize but don't define it to get a +/// link error (using generic_spec is problematic because g.set("all") +/// is ambiguous) +template <> +void generic_spec::set(std::string const & str); + +#endif /* !GENERIC_SPEC_H */ diff --git a/libutil++/glob_filter.cpp b/libutil++/glob_filter.cpp new file mode 100644 index 0000000..e44549f --- /dev/null +++ b/libutil++/glob_filter.cpp @@ -0,0 +1,39 @@ +/** + * @file glob_filter.cpp + * Filter strings based on globbed exclude/include list + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include + +#include + +#include "glob_filter.h" +#include "string_manip.h" + +using namespace std; + +bool glob_filter::fnmatcher::operator()(string const & s) +{ + return fnmatch(s.c_str(), str_.c_str(), 0) != FNM_NOMATCH; +} + + +bool glob_filter::match(string const & str) const +{ + vector::const_iterator cit; + cit = find_if(exclude.begin(), exclude.end(), fnmatcher(str)); + if (cit != exclude.end()) + return false; + + cit = find_if(include.begin(), include.end(), fnmatcher(str)); + if (include.empty() || cit != include.end()) + return true; + + return false; +} diff --git a/libutil++/glob_filter.h b/libutil++/glob_filter.h new file mode 100644 index 0000000..6887cbf --- /dev/null +++ b/libutil++/glob_filter.h @@ -0,0 +1,57 @@ +/** + * @file glob_filter.h + * Filter strings based on globbed exclude/include list + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef GLOB_FILTER_H +#define GLOB_FILTER_H + +#include "string_filter.h" + +/** + * glob_filter - filtering of a string based on globbed include/exclude list + * + * This class is an oracle on whether a particular string matches + * the given list of included and excluded strings. + * + * This class gives glob-based matches on each pattern, as with fnmatch(3) + */ +class glob_filter : public string_filter { +public: + /** + * Initialise the filter with the include and exclude list, + * comma-separated. + */ + glob_filter(std::string const & include_patterns, + std::string const & exclude_patterns) + : string_filter(include_patterns, exclude_patterns) {} + + /** + * Initialise the filter with the include and exclude list. + */ + glob_filter(std::vector const & include_patterns, + std::vector const & exclude_patterns) + : string_filter(include_patterns, exclude_patterns) {} + + /// Returns true if the given string matches + virtual bool match(std::string const & str) const; + +protected: + + /// function object for fnmatching + struct fnmatcher { + fnmatcher(std::string const & str) : str_(str) {} + + bool operator()(std::string const & s); + + std::string const & str_; + }; +}; + +#endif /* GLOB_FILTER_H */ diff --git a/libutil++/growable_vector.h b/libutil++/growable_vector.h new file mode 100644 index 0000000..afc73f2 --- /dev/null +++ b/libutil++/growable_vector.h @@ -0,0 +1,105 @@ +/** + * @file growable_vector.h + * Auto-expanding vector type + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef GROWABLE_VECTOR_H +#define GROWABLE_VECTOR_H + +#include +#include +#include + +/** + * A simple growable vector template. + */ +template class growable_vector { +public: + typedef std::vector container_type; + typedef typename container_type::size_type size_type; + + + /** + * Index into the vector for a value. An out of + * bounds index will return a default-constructed value. + */ + T operator[](size_type index) const { + if (index >= container.size()) + return 0; + return container[index]; + } + + + /** + * Index into the vector for a value. If the index is larger than + * the current max index, the array is expanded, default-filling + * any intermediary gaps. + */ + T & operator[](size_type index) { + if (index >= container.size()) + container.resize(index + 1); + return container[index]; + } + + + /** + * vectorized += operator + */ + growable_vector & operator+=(growable_vector const & rhs) { + if (rhs.container.size() > container.size()) + container.resize(rhs.container.size()); + + size_type min_size = min(container.size(), rhs.container.size()); + for (size_type i = 0 ; i < min_size; ++i) + container[i] += rhs.container[i]; + + return *this; + } + + + /** + * vectorized -= operator, overflow shouldn't occur during substraction + * (iow: for each components lhs[i] >= rhs[i] + */ + growable_vector & operator-=(growable_vector const & rhs) { + if (rhs.container.size() > container.size()) + container.resize(rhs.container.size()); + + size_type min_size = min(container.size(), rhs.container.size()); + for (size_type i = 0 ; i < min_size; ++i) + container[i] -= rhs.container[i]; + + return *this; + } + + + /// return current size of vector + size_type size() const { + return container.size(); + } + + + /// fill container with given value + void fill(size_type size, T const & value) { + container.resize(size, value); + } + + + /// return true if all elements have the default constructed value + bool zero() const { + return std::find_if(container.begin(), container.end(), + std::bind2nd(std::not_equal_to(), T())) + == container.end(); + } + +private: + container_type container; +}; + +#endif // GROWABLE_VECTOR_H diff --git a/libutil++/op_bfd.cpp b/libutil++/op_bfd.cpp new file mode 100644 index 0000000..f1bef78 --- /dev/null +++ b/libutil++/op_bfd.cpp @@ -0,0 +1,429 @@ +/** + * @file op_bfd.cpp + * Encapsulation of bfd objects + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include "op_file.h" +#include "op_config.h" +#include "config.h" + +#include +#include + +#include + +#include +#include +#include +#include + +#include "op_bfd.h" +#include "string_filter.h" +#include "stream_util.h" +#include "cverb.h" + +using namespace std; + + +verbose vbfd("bfd"); + + +namespace { + +/// function object for filtering symbols to remove +struct remove_filter { + remove_filter(string_filter const & filter) + : filter_(filter) {} + + bool operator()(op_bfd_symbol const & symbol) { + return !filter_.match(symbol.name()); + } + + string_filter filter_; +}; + + +} // namespace anon + + +op_bfd_symbol::op_bfd_symbol(asymbol const * a) + : bfd_symbol(a), symb_value(a->value), + section_filepos(a->section->filepos), + section_vma(a->section->vma), + symb_size(0), symb_hidden(false), symb_weak(false) +{ + // Some sections have unnamed symbols in them. If + // we just ignore them then we end up sticking + // things like .plt hits inside of _init. So instead + // we name the symbol after the section. + if (a->name && a->name[0] != '\0') { + symb_name = a->name; + symb_weak = a->flags & BSF_WEAK; + symb_hidden = (a->flags & BSF_LOCAL) + && !(a->flags & BSF_GLOBAL); + } else { + symb_name = string("??") + a->section->name; + } +} + + +op_bfd_symbol::op_bfd_symbol(bfd_vma vma, size_t size, string const & name) + : bfd_symbol(0), symb_value(vma), + section_filepos(0), section_vma(0), + symb_size(size), symb_name(name) +{ +} + + +bool op_bfd_symbol::operator<(op_bfd_symbol const & rhs) const +{ + return filepos() < rhs.filepos(); +} + + +op_bfd::op_bfd(string const & archive, string const & fname, + string_filter const & symbol_filter, bool & ok) + : + filename(fname), + archive_path(archive), + file_size(-1) +{ + int fd; + struct stat st; + // after creating all symbol it's convenient for user code to access + // symbols through a vector. We use an intermediate list to avoid a + // O(N²) behavior when we will filter vector element below + symbols_found_t symbols; + asection const * sect; + + string const image_path = archive_path + filename; + + cverb << vbfd << "op_bfd ctor for " << image_path << endl; + + // if there's a problem already, don't try to open it + if (!ok) + goto out_fail; + + fd = open(image_path.c_str(), O_RDONLY); + if (fd == -1) { + cverb << vbfd << "open failed for " << image_path << endl; + ok = false; + goto out_fail; + } + + if (fstat(fd, &st)) { + cverb << vbfd << "stat failed for " << image_path << endl; + ok = false; + goto out_fail; + } + + file_size = st.st_size; + + ibfd.abfd = fdopen_bfd(image_path, fd); + + if (!ibfd.valid()) { + cverb << vbfd << "fdopen_bfd failed for " << image_path << endl; + ok = false; + goto out_fail; + } + + // find .text and use it + for (sect = ibfd.abfd->sections; sect; sect = sect->next) { + if (sect->flags & SEC_CODE) { + if (filepos_map[sect->name] != 0) { + cerr << "Found section \"" << sect->name + << "\" twice for " << get_filename() + << endl; + abort(); + } + + filepos_map[sect->name] = sect->filepos; + } + } + + get_symbols(symbols); + +out: + add_symbols(symbols, symbol_filter); + return; +out_fail: + ibfd.close(); + dbfd.close(); + // make the fake symbol fit within the fake file + file_size = -1; + goto out; +} + + +op_bfd::~op_bfd() +{ +} + + +unsigned long const op_bfd::get_start_offset(bfd_vma vma) const +{ + if (!vma || !ibfd.valid()) { + filepos_map_t::const_iterator it = filepos_map.find(".text"); + if (it != filepos_map.end()) + return it->second; + return 0; + } + + for (asection * sect = ibfd.abfd->sections; sect; sect = sect->next) { + if (sect->vma == vma) + return sect->filepos; + } + + return 0; +} + + +void op_bfd::get_symbols(op_bfd::symbols_found_t & symbols) +{ + ibfd.get_symbols(); + + // On separate debug file systems, the main bfd has no symbols, + // so even for non -g reports, we want to process the dbfd. + // This hurts us pretty badly (the CRC), but we really don't + // have much choice at the moment. + has_debug_info(); + + dbfd.get_symbols(); + + size_t i; + for (i = 0; i < ibfd.nr_syms; ++i) { + if (interesting_symbol(ibfd.syms[i])) + symbols.push_back(op_bfd_symbol(ibfd.syms[i])); + } + + for (i = 0; i < dbfd.nr_syms; ++i) { + if (!interesting_symbol(dbfd.syms[i])) + continue; + + // need to use filepos of original file's section for + // debug file symbols. We probably need to be more + // careful for special symbols which have ->section from + // .rodata like *ABS* + u32 filepos = filepos_map[dbfd.syms[i]->section->name]; + if (filepos != 0) + dbfd.syms[i]->section->filepos = filepos; + symbols.push_back(op_bfd_symbol(dbfd.syms[i])); + } + + symbols.sort(); + + symbols_found_t::iterator it = symbols.begin(); + + // we need to ensure than for a given vma only one symbol exist else + // we read more than one time some samples. Fix #526098 + for (; it != symbols.end();) { + symbols_found_t::iterator temp = it; + ++temp; + if (temp != symbols.end() && (it->vma() == temp->vma())) { + if (boring_symbol(*it, *temp)) { + it = symbols.erase(it); + } else { + symbols.erase(temp); + } + } else { + ++it; + } + } + + // now we can calculate the symbol size, we can't first include/exclude + // symbols because the size of symbol is calculated from the difference + // between the vma of a symbol and the next one. + for (it = symbols.begin() ; it != symbols.end(); ++it) { + op_bfd_symbol const * next = 0; + symbols_found_t::iterator temp = it; + ++temp; + if (temp != symbols.end()) + next = &*temp; + it->size(symbol_size(*it, next)); + } +} + + +void op_bfd::add_symbols(op_bfd::symbols_found_t & symbols, + string_filter const & symbol_filter) +{ + // images with no symbols debug info available get a placeholder symbol + if (symbols.empty()) + symbols.push_back(create_artificial_symbol()); + + cverb << vbfd << "number of symbols before filtering " + << dec << symbols.size() << hex << endl; + + symbols_found_t::iterator it; + it = remove_if(symbols.begin(), symbols.end(), + remove_filter(symbol_filter)); + + copy(symbols.begin(), it, back_inserter(syms)); + + cverb << vbfd << "number of symbols now " + << dec << syms.size() << hex << endl; +} + + +unsigned long op_bfd::sym_offset(symbol_index_t sym_index, u32 num) const +{ + /* take off section offset and symb value */ + return num - syms[sym_index].filepos(); +} + + +bfd_vma op_bfd::offset_to_pc(bfd_vma offset) const +{ + asection const * sect = ibfd.abfd->sections; + + for (; sect; sect = sect->next) { + if (offset >= bfd_vma(sect->filepos) && + (!sect->next || offset < bfd_vma(sect->next->filepos))) { + return sect->vma + (offset - sect->filepos); + } + } + + return 0; +} + + +bool op_bfd::has_debug_info() const +{ + if (debug_info.cached()) + return debug_info.get(); + + if (!ibfd.valid()) + return debug_info.reset(false); + + if (ibfd.has_debug_info()) + return debug_info.reset(true); + + // check to see if there is an .debug file + string const global(archive_path + DEBUGDIR); + string const image_path = archive_path + filename; + string const dirname(image_path.substr(0, image_path.rfind('/'))); + + if (find_separate_debug_file(ibfd.abfd, dirname, global, debug_filename)) { + cverb << vbfd << "now loading: " << debug_filename << endl; + dbfd.abfd = open_bfd(debug_filename); + if (dbfd.has_debug_info()) + return debug_info.reset(true); + } + + // .debug is optional, so will not fail if there's a problem + cverb << vbfd << "failed to process separate debug file " + << debug_filename << endl; + + return debug_info.reset(false); +} + + +bool op_bfd::get_linenr(symbol_index_t sym_idx, unsigned int offset, + string & source_filename, unsigned int & linenr) const +{ + if (!has_debug_info()) + return false; + + // FIXME: to test, I'm unsure if from this point we must use abfd + // or the check if (pc >= bfd_section_size(abfd, section)) must be done + // with ibfd. + bfd_info const & b = dbfd.valid() ? dbfd : ibfd; + + linenr_info const info = find_nearest_line(b, syms[sym_idx], offset); + + if (!info.found) + return false; + + source_filename = info.filename; + linenr = info.line; + return true; +} + + +size_t op_bfd::symbol_size(op_bfd_symbol const & sym, + op_bfd_symbol const * next) const +{ + unsigned long start = sym.filepos(); + unsigned long end = next ? next->filepos() : file_size; + + return end - start; +} + + +void op_bfd::get_symbol_range(symbol_index_t sym_idx, + unsigned long & start, unsigned long & end) const +{ + op_bfd_symbol const & sym = syms[sym_idx]; + + bool const verbose = cverb << (vbfd & vlevel1); + + start = sym.filepos(); + end = start + sym.size(); + + if (!verbose) + return; + + io_state state(cverb << (vbfd & vlevel1)); + + cverb << (vbfd & vlevel1) << "symbol " << sym.name() + << ", value " << hex << sym.value() << endl; + cverb << (vbfd & vlevel1) + << "start " << hex << start << ", end " << end << endl; + + if (sym.symbol()) { + cverb << (vbfd & vlevel1) << "in section " + << sym.symbol()->section->name << ", filepos " + << hex << sym.symbol()->section->filepos << endl; + } +} + + +void op_bfd::get_vma_range(bfd_vma & start, bfd_vma & end) const +{ + if (!syms.empty()) { + // syms are sorted by vma so vma of the first symbol and vma + + // size of the last symbol give the vma range for gprof output + op_bfd_symbol const & last_symb = syms[syms.size() - 1]; + start = syms[0].vma(); + // end is excluded from range so + 1 *if* last_symb.size() != 0 + end = last_symb.vma() + last_symb.size() + (last_symb.size() != 0); + } else { + start = 0; + end = file_size; + } +} + + +op_bfd_symbol const op_bfd::create_artificial_symbol() +{ + // FIXME: prefer a bool artificial; to this ?? + string symname = "?"; + + symname += get_filename(); + + bfd_vma start, end; + get_vma_range(start, end); + return op_bfd_symbol(start, end - start, symname); +} + + +string op_bfd::get_filename() const +{ + return filename; +} + + +size_t op_bfd::bfd_arch_bits_per_address() const +{ + if (ibfd.valid()) + return ::bfd_arch_bits_per_address(ibfd.abfd); + // FIXME: this function should be called only if the underlined ibfd + // is ok, must we throw ? + return sizeof(bfd_vma); +} diff --git a/libutil++/op_bfd.h b/libutil++/op_bfd.h new file mode 100644 index 0000000..701a1aa --- /dev/null +++ b/libutil++/op_bfd.h @@ -0,0 +1,253 @@ +/** + * @file op_bfd.h + * Encapsulation of bfd objects + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef OP_BFD_H +#define OP_BFD_H + +#include "config.h" + +#include +#include +#include +#include + +#include "bfd_support.h" +#include "utility.h" +#include "cached_value.h" +#include "op_types.h" + +class op_bfd; +class string_filter; + +/// all symbol vector indexing uses this type +typedef size_t symbol_index_t; + +/** + * A symbol description from a bfd point of view. This duplicate + * information pointed by an asymbol, we need this duplication in case + * the symbol is an artificial symbol + */ +class op_bfd_symbol { +public: + + /// ctor for real symbols + op_bfd_symbol(asymbol const * a); + + /// ctor for artificial symbols + op_bfd_symbol(bfd_vma vma, size_t size, std::string const & name); + + bfd_vma vma() const { return symb_value + section_vma; } + unsigned long value() const { return symb_value; } + unsigned long filepos() const { return symb_value + section_filepos; } + std::string const & name() const { return symb_name; } + asymbol const * symbol() const { return bfd_symbol; } + size_t size() const { return symb_size; } + void size(size_t s) { symb_size = s; } + bool hidden() const { return symb_hidden; } + bool weak() const { return symb_weak; } + + /// compare two symbols by their filepos() + bool operator<(op_bfd_symbol const & lhs) const; + +private: + /// the original bfd symbol, this can be null if the symbol is an + /// artificial symbol + asymbol const * bfd_symbol; + /// the offset of this symbol relative to the begin of the section's + /// symbol + unsigned long symb_value; + /// the section filepos for this symbol + unsigned long section_filepos; + /// the section vma for this symbol + bfd_vma section_vma; + /// the size of this symbol + size_t symb_size; + /// the name of the symbol + std::string symb_name; + /// normally not externally visible symbol + bool symb_hidden; + /// whether other symbols can override it + bool symb_weak; +}; + +/** + * Encapsulation of a bfd object. Simplifies open/close of bfd, enumerating + * symbols and retrieving informations for symbols or vma. + * + * Use of this class relies on a std::ostream cverb + */ +class op_bfd { +public: + /** + * @param archive_path oparchive prefix path + * @param filename the name of the image file + * @param symbol_filter filter to apply to symbols + * @param ok in-out parameter: on in, if not set, don't + * open the bfd (because it's not there or whatever). On out, + * it's set to false if the bfd couldn't be loaded. + */ + op_bfd(std::string const & archive_path, + std::string const & filename, + string_filter const & symbol_filter, + bool & ok); + + /// close an opened bfd image and free all related resources + ~op_bfd(); + + /** + * @param sym_idx index of the symbol + * @param offset fentry number + * @param filename output parameter to store filename + * @param linenr output parameter to store linenr. + * + * Retrieve the relevant finename:linenr information for the sym_idx + * at offset. If the lookup fails, return false. In some cases this + * function can retrieve the filename and return true but fail to + * retrieve the linenr and so can return zero in linenr + */ + bool get_linenr(symbol_index_t sym_idx, unsigned int offset, + std::string & filename, unsigned int & linenr) const; + + /** + * @param sym_idx symbol index + * @param start reference to start var + * @param end reference to end var + * + * Calculates the range of sample file entries covered by sym. start + * and end will be filled in appropriately. If index is the last entry + * in symbol table, all entries up to the end of the sample file will + * be used. After calculating start and end they are sanitized + * + * All errors are fatal. + */ + void get_symbol_range(symbol_index_t sym_idx, + unsigned long & start, unsigned long & end) const; + + /** + * sym_offset - return offset from a symbol's start + * @param num_symbols symbol number + * @param num number of fentry + * + * Returns the offset of a sample at position num + * in the samples file from the start of symbol sym_idx. + */ + unsigned long sym_offset(symbol_index_t num_symbols, u32 num) const; + + /** + * @param start reference to the start vma + * @param end reference to the end vma + * + * return in start, end the vma range for this binary object. + */ + void get_vma_range(bfd_vma & start, bfd_vma & end) const; + + /** return the relocated PC value for the given file offset */ + bfd_vma offset_to_pc(bfd_vma offset) const; + + /** + * If passed 0, return the file position of the .text section. + * Otherwise, return the filepos of a section with a matching + * vma. + */ + unsigned long const get_start_offset(bfd_vma vma = 0) const; + + /** + * Return the image name of the underlying binary image. For an + * archive, this returns the path *within* the archive, not the + * full path of the file. + */ + std::string get_filename() const; + + /// sorted vector by vma of interesting symbol. + std::vector syms; + + /// return in bits the bfd_vma size for this binary. This is needed + /// because gprof output depend on the bfd_vma for *this* binary + /// and do not depend on sizeof(bfd_vma) + size_t bfd_arch_bits_per_address() const; + + /// return true if binary contain some debug information + bool has_debug_info() const; + +private: + /// temporary container type for getting symbols + typedef std::list symbols_found_t; + + /** + * Parse and sort in ascending order all symbols + * in the file pointed to by abfd that reside in + * a %SEC_CODE section. + * + * The symbols are filtered through + * the interesting_symbol() predicate and sorted + * with op_bfd_symbol::operator<() comparator. + */ + void get_symbols(symbols_found_t & symbols); + + /** + * Helper function for get_symbols. + * Populates bfd_syms and extracts the "interesting_symbol"s. + */ + void get_symbols_from_file(bfd_info & bfd, size_t start, + op_bfd::symbols_found_t & symbols, + bool debug_file); + + /** + * Add the symbols in the binary, applying filtering, + * and handling artificial symbols. + */ + void add_symbols(symbols_found_t & symbols, + string_filter const & symbol_filter); + + /** + * symbol_size - return the size of a symbol + * @param sym symbol to get size + * @param next next symbol in vma order if any + */ + size_t symbol_size(op_bfd_symbol const & sym, + op_bfd_symbol const * next) const; + + /// create an artificial symbol for a symbolless binary + op_bfd_symbol const create_artificial_symbol(); + + /* Generate symbols using bfd functions for + * the image file associated with the ibfd arg. + */ + uint process_symtab(bfd_info * bfd, uint start); + + /// filename we open (not including archive path) + std::string filename; + + /// path to archive + std::string archive_path; + + /// file size in bytes + off_t file_size; + + /// corresponding debug file name + mutable std::string debug_filename; + + /// true if at least one section has (flags & SEC_DEBUGGING) != 0 + mutable cached_value debug_info; + + /// our main bfd object: .bfd may be NULL + bfd_info ibfd; + + // corresponding debug bfd object, if one is found + mutable bfd_info dbfd; + + typedef std::map filepos_map_t; + // mapping of section names to filepos in the original binary + filepos_map_t filepos_map; +}; + + +#endif /* !OP_BFD_H */ diff --git a/libutil++/op_exception.cpp b/libutil++/op_exception.cpp new file mode 100644 index 0000000..235b9bc --- /dev/null +++ b/libutil++/op_exception.cpp @@ -0,0 +1,55 @@ +/** + * @file op_exception.cpp + * exception base class + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include + +#include "op_exception.h" + +using namespace std; + +op_exception::op_exception(string const & msg) + : + message(msg) +{ +} + +op_exception::~op_exception() throw() +{ +} + +char const * op_exception::what() const throw() +{ + return message.c_str(); +} + + +op_fatal_error::op_fatal_error(string const & msg) + : + op_exception(msg) +{ +} + + +op_runtime_error::op_runtime_error(string const & msg) + : + runtime_error(msg) +{ +} + +op_runtime_error::op_runtime_error(string const & msg, int cerrno) + : + runtime_error(msg + "\ncause: " + strerror(cerrno)) +{ +} + +op_runtime_error::~op_runtime_error() throw() +{ +} diff --git a/libutil++/op_exception.h b/libutil++/op_exception.h new file mode 100644 index 0000000..af344ed --- /dev/null +++ b/libutil++/op_exception.h @@ -0,0 +1,60 @@ +/** + * @file op_exception.h + * exception base class + * + * This provide simple base class for exception object. All + * exception are derived from directly or indirectly from + * std::exception. This class are not itended to be catched + * in your code except at top level, derive what you want + * and catch derived class rather. + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef OP_EXCEPTION_H +#define OP_EXCEPTION_H + +#include +#include + + +/** + * exception abstract base class + */ +class op_exception : public std::exception { +public: + explicit op_exception(std::string const& msg); + ~op_exception() throw() = 0; + + char const * what() const throw(); +private: + std::string message; +}; + + +/** + * fatal exception, never catch it except at top level (likely main or + * gui). Intended to replace cerr << "blah"; exit(EXIT_FAILURE); by a + * throw op_fatal_error("blah") when returning error code is not an option + */ +struct op_fatal_error : op_exception +{ + explicit op_fatal_error(std::string const & msg); +}; + +/** + * Encapsulate a runtime error with or w/o a valid errno + */ +struct op_runtime_error : std::runtime_error +{ + explicit op_runtime_error(std::string const & err); + op_runtime_error(std::string const & err, int cerrno); + ~op_runtime_error() throw(); +}; + + +#endif /* !OP_EXCEPTION_H */ diff --git a/libutil++/path_filter.cpp b/libutil++/path_filter.cpp new file mode 100644 index 0000000..94db94e --- /dev/null +++ b/libutil++/path_filter.cpp @@ -0,0 +1,68 @@ +/** + * @file path_filter.cpp + * Filter paths based on globbed exclude/include list + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include + +#include + +#include "path_filter.h" +#include "string_manip.h" +#include "file_manip.h" + +using namespace std; + +bool path_filter::match(string const & str) const +{ + vector::const_iterator cit; + + // first, if any component of the dir is listed in exclude -> no + string comp = op_dirname(str); + while (!comp.empty() && comp != "/") { + cit = find_if(exclude.begin(), exclude.end(), + fnmatcher(op_basename(comp))); + if (cit != exclude.end()) + return false; + + // dirname("foo") == "foo" + if (comp == op_dirname(comp)) + break; + comp = op_dirname(comp); + } + + string const base = op_basename(str); + + // now if the file name is specifically excluded -> no + cit = find_if(exclude.begin(), exclude.end(), fnmatcher(base)); + if (cit != exclude.end()) + return false; + + // now if the file name is specifically included -> yes + cit = find_if(include.begin(), include.end(), fnmatcher(base)); + if (cit != include.end()) + return true; + + // now if any component of the path is included -> yes + // note that the include pattern defaults to '*' + string compi = op_dirname(str); + while (!compi.empty() && compi != "/") { + cit = find_if(include.begin(), include.end(), + fnmatcher(op_basename(compi))); + if (cit != include.end()) + return true; + + // dirname("foo") == "foo" + if (compi == op_dirname(compi)) + break; + compi = op_dirname(compi); + } + + return include.empty(); +} diff --git a/libutil++/path_filter.h b/libutil++/path_filter.h new file mode 100644 index 0000000..21203fb --- /dev/null +++ b/libutil++/path_filter.h @@ -0,0 +1,48 @@ +/** + * @file path_filter.h + * Filter paths based on globbed exclude/include list + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef PATH_FILTER_H +#define PATH_FILTER_H + +#include "glob_filter.h" + +/** + * path_filter - filtering of a string based on globbed include/exclude list + * + * This class is an oracle on whether a particular string matches + * the given list of included and excluded strings. + * + * This class gives glob-based matches on each pattern, as with fnmatch(3), + * where each component of the candidate path is considered separately. + */ +class path_filter : public glob_filter { +public: + /** + * Initialise the filter with the include and exclude list, + * comma-separated. + */ + path_filter(std::string const & include_patterns = std::string(), + std::string const & exclude_patterns = std::string()) + : glob_filter(include_patterns, exclude_patterns) {} + + /** + * Initialise the filter with the include and exclude list. + */ + path_filter(std::vector const & include_patterns, + std::vector const & exclude_patterns) + : glob_filter(include_patterns, exclude_patterns) {} + + + /// Returns true if the given string matches + virtual bool match(std::string const & str) const; +}; + +#endif /* PATH_FILTER_H */ diff --git a/libutil++/stream_util.cpp b/libutil++/stream_util.cpp new file mode 100644 index 0000000..750b0d3 --- /dev/null +++ b/libutil++/stream_util.cpp @@ -0,0 +1,31 @@ +/** + * @file stream_util.cpp + * C++ stream utility + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include "stream_util.h" + +using namespace std; + +io_state::io_state(ios & stream_) + : + stream(stream_), + format(stream.flags()), + precision(stream.precision()), + fill(stream.fill()) +{ +} + + +io_state::~io_state() +{ + stream.flags(format); + stream.precision(precision); + stream.fill(fill); +} diff --git a/libutil++/stream_util.h b/libutil++/stream_util.h new file mode 100644 index 0000000..0ccee9a --- /dev/null +++ b/libutil++/stream_util.h @@ -0,0 +1,39 @@ +/** + * @file stream_util.h + * C++ stream utility + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef STREAM_UTIL_H +#define STREAM_UTIL_H + +#include + +/// class which save a stream state and restore it at dtor time +class io_state { +public: + /** + * save the stream flags, precision and fill char. + * + * width is restored at end of expression, there is no need to save it. + * tie and locale are not saved currently + * + * error state shouldn't be saved. + */ + io_state(std::ios & stream); + /// restore the stream state + ~io_state(); +private: + std::ios & stream; + + std::ios::fmtflags format; + std::streamsize precision; + char fill; +}; + +#endif /* !STREAM_UTIL_H */ diff --git a/libutil++/string_filter.cpp b/libutil++/string_filter.cpp new file mode 100644 index 0000000..2a10cc6 --- /dev/null +++ b/libutil++/string_filter.cpp @@ -0,0 +1,49 @@ +/** + * @file string_filter.cpp + * Filter strings based on exclude/include list + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include + +#include "string_filter.h" +#include "string_manip.h" + +using namespace std; + + +string_filter::string_filter(string const & include_patterns, + string const & exclude_patterns) + : include(separate_token(include_patterns, ',')), + exclude(separate_token(exclude_patterns, ',')) +{ +} + + +string_filter::string_filter(vector const & include_patterns, + vector const & exclude_patterns) + : include(include_patterns), + exclude(exclude_patterns) +{ +} + + +// FIXME: PP reference +bool string_filter::match(string const & str) const +{ + vector::const_iterator cit; + cit = find(exclude.begin(), exclude.end(), str); + if (cit != exclude.end()) + return false; + + cit = find(include.begin(), include.end(), str); + if (include.empty() || cit != include.end()) + return true; + + return false; +} diff --git a/libutil++/string_filter.h b/libutil++/string_filter.h new file mode 100644 index 0000000..c008fe3 --- /dev/null +++ b/libutil++/string_filter.h @@ -0,0 +1,55 @@ +/** + * @file string_filter.h + * Filter strings based on exclude/include list + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef STRING_FILTER_H +#define STRING_FILTER_H + +#include +#include + +/** + * string_filter - filtering of a string based on include/exclude list + * + * This class is an oracle on whether a particular string matches + * the given list of included and excluded strings. + * + * This base class gives a default exact-match semantics. + */ +class string_filter { +public: + string_filter() {} + + /** + * Initialise the filter with the include and exclude list, + * comma-separated. + */ + string_filter(std::string const & include_patterns, + std::string const & exclude_patterns); + + /** + * Initialise the filter with the include and exclude list. + */ + string_filter(std::vector const & include_patterns, + std::vector const & exclude_patterns); + + virtual ~string_filter() {} + + /// Returns true if the given string matches + virtual bool match(std::string const & str) const; + +protected: + /// include patterns + std::vector include; + /// exclude patterns + std::vector exclude; +}; + +#endif /* STRING_FILTER_H */ diff --git a/libutil++/string_manip.cpp b/libutil++/string_manip.cpp new file mode 100644 index 0000000..d9e83b8 --- /dev/null +++ b/libutil++/string_manip.cpp @@ -0,0 +1,149 @@ +/** + * @file string_manip.cpp + * std::string helpers + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#include +#include + +#include +#include + +#include "string_manip.h" + +using namespace std; + + +string erase_to_last_of(string const & str, char ch) +{ + string result = str; + string::size_type pos = result.find_last_of(ch); + if (pos != string::npos) + result.erase(0, pos + 1); + + return result; +} + + +string split(string & s, char c) +{ + string::size_type i = s.find_first_of(c); + if (i == string::npos) + return string(); + + string const tail = s.substr(i + 1); + s = s.substr(0, i); + return tail; +} + + +bool is_prefix(string const & s, string const & prefix) +{ + // gcc 2.95 and below don't have this + // return s.compare(0, prefix.length(), prefix) == 0; + return s.find(prefix) == 0; +} + + +vector separate_token(string const & str, char sep) +{ + vector result; + string next; + + for (size_t pos = 0 ; pos != str.length() ; ++pos) { + char ch = str[pos]; + if (ch == '\\') { + if (pos < str.length() - 1 && str[pos + 1] == sep) { + ++pos; + next += sep; + } else { + next += '\\'; + } + } else if (ch == sep) { + result.push_back(next); + // some stl lacks string::clear() + next.erase(next.begin(), next.end()); + } else { + next += ch; + } + } + + if (!next.empty()) + result.push_back(next); + + return result; +} + + +string ltrim(string const & str, string const & totrim) +{ + string result(str); + + return result.erase(0, result.find_first_not_of(totrim)); +} + + +string rtrim(string const & str, string const & totrim) +{ + string result(str); + + return result.erase(result.find_last_not_of(totrim) + 1); +} + + +string trim(string const & str, string const & totrim) +{ + return rtrim(ltrim(str, totrim), totrim); +} + + +string const +format_percent(double value, size_t int_width, size_t fract_width, bool showpos) +{ + ostringstream os; + + if (value == 0.0) + return string(int_width + fract_width, ' ') + "0"; + + if (showpos) + os.setf(ios::showpos); + + if (fabs(value) > .001) { + // os << fixed << value unsupported by gcc 2.95 + os.setf(ios::fixed, ios::floatfield); + os << setw(int_width + fract_width + 1) + << setprecision(fract_width) << value; + } else { + // os << scientific << value unsupported by gcc 2.95 + os.setf(ios::scientific, ios::floatfield); + os << setw(int_width + fract_width + 1) + // - 3 to count exponent part + << setprecision(fract_width - 3) << value; + } + + string formatted = os.str(); + if (is_prefix(formatted, "100.")) + formatted.erase(formatted.size() - 1); + return formatted; +} + + +template <> +unsigned int op_lexical_cast(string const & str) +{ + char* endptr; + + // 2.91.66 fix + unsigned long ret = 0; + ret = strtoul(str.c_str(), &endptr, 0); + if (*endptr) { + throw invalid_argument("op_lexical_cast(\""+ str +"\")"); + } + return ret; +} diff --git a/libutil++/string_manip.h b/libutil++/string_manip.h new file mode 100644 index 0000000..9fe74ce --- /dev/null +++ b/libutil++/string_manip.h @@ -0,0 +1,108 @@ +/** + * @file string_manip.h + * std::string helpers + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef STRING_MANIP_H +#define STRING_MANIP_H + +#include +#include +#include +#include + +/** + * @param str string + * @param ch the characterto search + * + * erase char from the begin of str to the last + * occurence of ch from and return the string + */ +std::string erase_to_last_of(std::string const & str, char ch); + +/// split string s by first occurence of char c, returning the second part. +/// s is set to the first part. Neither include the split character +std::string split(std::string & s, char c); + +/// return true if "prefix" is a prefix of "s", behavior is undefined +/// if prefix is an empty string +bool is_prefix(std::string const & s, std::string const & prefix); + +/** + * @param str the string to tokenize + * @param sep the separator_char + * + * separate fields in a string in a list of token; field are + * separated by the sep character, sep char can be escaped + * by '\\' to specify a sep char in a token, '\\' not followed + * by a sep is taken as it e.g. "\,\a" --> ",\a" + */ +std::vector separate_token(std::string const & str, char sep); + +/// remove trim chars from start of input string return the new string +std::string ltrim(std::string const & str, std::string const & totrim = "\t "); +/// remove trim chars from end of input string return the new string +std::string rtrim(std::string const & str, std::string const & totrim = "\t "); +/// ltrim(rtrim(str)) +std::string trim(std::string const & str, std::string const & totrim = "\t "); + +/** + * format_percent - smart format of double percentage value + * @param value - the value + * @param int_width - the maximum integer integer width default to 2 + * @param frac_width - the fractionnary width default to 4 + * @param showpos - show + sign for positive values + * + * This formats a percentage into exactly the given width and returns + * it. If the integer part is larger than the given int_width, the + * returned string will be wider. The returned string is never + * shorter than (fract_with + int_width + 1) + * + */ +std::string const +format_percent(double value, size_t int_width, + size_t frac_width, bool showpos = false); + +/// prefered width to format percentage +static unsigned int const percent_int_width = 2; +static unsigned int const percent_fract_width = 4; +static unsigned int const percent_width = percent_int_width + percent_fract_width + 1; + + +/** + * @param src input parameter + * convert From src to a T through an istringstream. + * + * Throws invalid_argument if conversion fail. + * + * Note that this is not as foolproof as boost's lexical_cast + */ +template +To op_lexical_cast(From const & src) +{ + std::ostringstream in; + if (!(in << src)) { + throw std::invalid_argument("op_lexical_cast()"); + } + std::istringstream out(in.str()); + To value; + if (!(out >> value)) { + throw std::invalid_argument("op_lexical_cast(\"" + + in.str() +"\")"); + } + return value; +} + +// specialization accepting hexadecimal and octal number in input. Note that +// op_lexical_cast("0x23"); will fail because it call the +// non specialized template. +template <> +unsigned int op_lexical_cast(std::string const & str); + +#endif /* !STRING_MANIP_H */ diff --git a/libutil++/tests/Makefile.am b/libutil++/tests/Makefile.am new file mode 100644 index 0000000..fcc9a7d --- /dev/null +++ b/libutil++/tests/Makefile.am @@ -0,0 +1,49 @@ + +REALPATH= readlink -f + +SRCDIR := $(shell $(REALPATH) $(topdir)/libutil++/tests/ ) + +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil++ -D SRCDIR="\"$(SRCDIR)/\"" + +COMMON_LIBS = ../libutil++.a ../../libutil/libutil.a + +LIBS = @LIBERTY_LIBS@ + +AM_CXXFLAGS = @OP_CXXFLAGS@ + +check_PROGRAMS = \ + string_manip_tests \ + string_filter_tests \ + comma_list_tests \ + file_manip_tests \ + glob_filter_tests \ + path_filter_tests \ + cached_value_tests \ + utility_tests + +string_manip_tests_SOURCES = string_manip_tests.cpp +string_manip_tests_LDADD = ${COMMON_LIBS} + +string_filter_tests_SOURCES = string_filter_tests.cpp +string_filter_tests_LDADD = ${COMMON_LIBS} + +glob_filter_tests_SOURCES = glob_filter_tests.cpp +glob_filter_tests_LDADD = ${COMMON_LIBS} + +path_filter_tests_SOURCES = path_filter_tests.cpp +path_filter_tests_LDADD = ${COMMON_LIBS} + +comma_list_tests_SOURCES = comma_list_tests.cpp +comma_list_tests_LDADD = ${COMMON_LIBS} + +file_manip_tests_SOURCES = file_manip_tests.cpp +file_manip_tests_LDADD = ${COMMON_LIBS} + +cached_value_tests_SOURCES = cached_value_tests.cpp +cached_value_tests_LDADD = ${COMMON_LIBS} + +utility_tests_SOURCES = utility_tests.cpp +utility_tests_LDADD = ${COMMON_LIBS} + +TESTS = ${check_PROGRAMS} diff --git a/libutil++/tests/Makefile.in b/libutil++/tests/Makefile.in new file mode 100644 index 0000000..f5980df --- /dev/null +++ b/libutil++/tests/Makefile.in @@ -0,0 +1,586 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +SOURCES = $(cached_value_tests_SOURCES) $(comma_list_tests_SOURCES) $(file_manip_tests_SOURCES) $(glob_filter_tests_SOURCES) $(path_filter_tests_SOURCES) $(string_filter_tests_SOURCES) $(string_manip_tests_SOURCES) $(utility_tests_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +check_PROGRAMS = string_manip_tests$(EXEEXT) \ + string_filter_tests$(EXEEXT) comma_list_tests$(EXEEXT) \ + file_manip_tests$(EXEEXT) glob_filter_tests$(EXEEXT) \ + path_filter_tests$(EXEEXT) cached_value_tests$(EXEEXT) \ + utility_tests$(EXEEXT) +subdir = libutil++/tests +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am_cached_value_tests_OBJECTS = cached_value_tests.$(OBJEXT) +cached_value_tests_OBJECTS = $(am_cached_value_tests_OBJECTS) +am__DEPENDENCIES_1 = ../libutil++.a ../../libutil/libutil.a +cached_value_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_comma_list_tests_OBJECTS = comma_list_tests.$(OBJEXT) +comma_list_tests_OBJECTS = $(am_comma_list_tests_OBJECTS) +comma_list_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_file_manip_tests_OBJECTS = file_manip_tests.$(OBJEXT) +file_manip_tests_OBJECTS = $(am_file_manip_tests_OBJECTS) +file_manip_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_glob_filter_tests_OBJECTS = glob_filter_tests.$(OBJEXT) +glob_filter_tests_OBJECTS = $(am_glob_filter_tests_OBJECTS) +glob_filter_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_path_filter_tests_OBJECTS = path_filter_tests.$(OBJEXT) +path_filter_tests_OBJECTS = $(am_path_filter_tests_OBJECTS) +path_filter_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_string_filter_tests_OBJECTS = string_filter_tests.$(OBJEXT) +string_filter_tests_OBJECTS = $(am_string_filter_tests_OBJECTS) +string_filter_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_string_manip_tests_OBJECTS = string_manip_tests.$(OBJEXT) +string_manip_tests_OBJECTS = $(am_string_manip_tests_OBJECTS) +string_manip_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_utility_tests_OBJECTS = utility_tests.$(OBJEXT) +utility_tests_OBJECTS = $(am_utility_tests_OBJECTS) +utility_tests_DEPENDENCIES = $(am__DEPENDENCIES_1) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(cached_value_tests_SOURCES) $(comma_list_tests_SOURCES) \ + $(file_manip_tests_SOURCES) $(glob_filter_tests_SOURCES) \ + $(path_filter_tests_SOURCES) $(string_filter_tests_SOURCES) \ + $(string_manip_tests_SOURCES) $(utility_tests_SOURCES) +DIST_SOURCES = $(cached_value_tests_SOURCES) \ + $(comma_list_tests_SOURCES) $(file_manip_tests_SOURCES) \ + $(glob_filter_tests_SOURCES) $(path_filter_tests_SOURCES) \ + $(string_filter_tests_SOURCES) $(string_manip_tests_SOURCES) \ + $(utility_tests_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBERTY_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +REALPATH = readlink -f +SRCDIR := $(shell $(REALPATH) $(topdir)/libutil++/tests/ ) +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil++ -D SRCDIR="\"$(SRCDIR)/\"" + +COMMON_LIBS = ../libutil++.a ../../libutil/libutil.a +AM_CXXFLAGS = @OP_CXXFLAGS@ +string_manip_tests_SOURCES = string_manip_tests.cpp +string_manip_tests_LDADD = ${COMMON_LIBS} +string_filter_tests_SOURCES = string_filter_tests.cpp +string_filter_tests_LDADD = ${COMMON_LIBS} +glob_filter_tests_SOURCES = glob_filter_tests.cpp +glob_filter_tests_LDADD = ${COMMON_LIBS} +path_filter_tests_SOURCES = path_filter_tests.cpp +path_filter_tests_LDADD = ${COMMON_LIBS} +comma_list_tests_SOURCES = comma_list_tests.cpp +comma_list_tests_LDADD = ${COMMON_LIBS} +file_manip_tests_SOURCES = file_manip_tests.cpp +file_manip_tests_LDADD = ${COMMON_LIBS} +cached_value_tests_SOURCES = cached_value_tests.cpp +cached_value_tests_LDADD = ${COMMON_LIBS} +utility_tests_SOURCES = utility_tests.cpp +utility_tests_LDADD = ${COMMON_LIBS} +TESTS = ${check_PROGRAMS} +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libutil++/tests/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libutil++/tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +cached_value_tests$(EXEEXT): $(cached_value_tests_OBJECTS) $(cached_value_tests_DEPENDENCIES) + @rm -f cached_value_tests$(EXEEXT) + $(CXXLINK) $(cached_value_tests_LDFLAGS) $(cached_value_tests_OBJECTS) $(cached_value_tests_LDADD) $(LIBS) +comma_list_tests$(EXEEXT): $(comma_list_tests_OBJECTS) $(comma_list_tests_DEPENDENCIES) + @rm -f comma_list_tests$(EXEEXT) + $(CXXLINK) $(comma_list_tests_LDFLAGS) $(comma_list_tests_OBJECTS) $(comma_list_tests_LDADD) $(LIBS) +file_manip_tests$(EXEEXT): $(file_manip_tests_OBJECTS) $(file_manip_tests_DEPENDENCIES) + @rm -f file_manip_tests$(EXEEXT) + $(CXXLINK) $(file_manip_tests_LDFLAGS) $(file_manip_tests_OBJECTS) $(file_manip_tests_LDADD) $(LIBS) +glob_filter_tests$(EXEEXT): $(glob_filter_tests_OBJECTS) $(glob_filter_tests_DEPENDENCIES) + @rm -f glob_filter_tests$(EXEEXT) + $(CXXLINK) $(glob_filter_tests_LDFLAGS) $(glob_filter_tests_OBJECTS) $(glob_filter_tests_LDADD) $(LIBS) +path_filter_tests$(EXEEXT): $(path_filter_tests_OBJECTS) $(path_filter_tests_DEPENDENCIES) + @rm -f path_filter_tests$(EXEEXT) + $(CXXLINK) $(path_filter_tests_LDFLAGS) $(path_filter_tests_OBJECTS) $(path_filter_tests_LDADD) $(LIBS) +string_filter_tests$(EXEEXT): $(string_filter_tests_OBJECTS) $(string_filter_tests_DEPENDENCIES) + @rm -f string_filter_tests$(EXEEXT) + $(CXXLINK) $(string_filter_tests_LDFLAGS) $(string_filter_tests_OBJECTS) $(string_filter_tests_LDADD) $(LIBS) +string_manip_tests$(EXEEXT): $(string_manip_tests_OBJECTS) $(string_manip_tests_DEPENDENCIES) + @rm -f string_manip_tests$(EXEEXT) + $(CXXLINK) $(string_manip_tests_LDFLAGS) $(string_manip_tests_OBJECTS) $(string_manip_tests_LDADD) $(LIBS) +utility_tests$(EXEEXT): $(utility_tests_OBJECTS) $(utility_tests_DEPENDENCIES) + @rm -f utility_tests$(EXEEXT) + $(CXXLINK) $(utility_tests_LDFLAGS) $(utility_tests_OBJECTS) $(utility_tests_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cached_value_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/comma_list_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_manip_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glob_filter_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/path_filter_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string_filter_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string_manip_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utility_tests.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic ctags distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libutil++/tests/cached_value_tests.cpp b/libutil++/tests/cached_value_tests.cpp new file mode 100644 index 0000000..b50c5d4 --- /dev/null +++ b/libutil++/tests/cached_value_tests.cpp @@ -0,0 +1,80 @@ +/** + * @file cached_value_tests.cpp + * tests cached_value.h + * + * @remark Copyright 2005 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + */ + +#include +#include +#include + +#include "cached_value.h" + +using namespace std; + +namespace { + + +bool check_throw(cached_value const & boolval) +{ + try { + bool foo = boolval.get(); + foo = false; + } catch (op_fatal_error const & e) { + return true; + } + return false; +} + + +int check_cached(void) +{ + cached_value boolval; + cached_value strval; + + if (!check_throw(boolval)) { + cerr << "get() on no value didn't throw\n"; + return EXIT_FAILURE; + } + + if (boolval.reset(false) != false || boolval.get() != false) { + cerr << "reset() of cached value \"false\" didn't work\n"; + return EXIT_FAILURE; + } + + if (boolval.reset(true) != true || boolval.get() != true) { + cerr << "reset() of cached value \"true\" didn't work\n"; + return EXIT_FAILURE; + } + + if (strval.reset("foo") != "foo" || strval.get() != "foo") { + cerr << "reset() of cached value \"foo\" didn't work\n"; + return EXIT_FAILURE; + } + + if (strval.reset("") != "" || strval.get() != "") { + cerr << "reset() of cached value \"\" didn't work\n"; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} + +}; + +int main() +{ + try { + check_cached(); + } + catch (...) { + cerr << "unknown exception\n"; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/libutil++/tests/comma_list_tests.cpp b/libutil++/tests/comma_list_tests.cpp new file mode 100644 index 0000000..b30feef --- /dev/null +++ b/libutil++/tests/comma_list_tests.cpp @@ -0,0 +1,70 @@ +/** + * @file comma_list_tests.cpp + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include + +#include "comma_list.h" + +using namespace std; + +#define check(clist, val, result) \ + if (clist.match(val) != result) { \ + cerr << "\"" << #val << "\" matched with " #clist \ + << " did not return " #result << endl; \ + exit(EXIT_FAILURE); \ + } + +int main() +{ + comma_list c1; + + check(c1, 1, true); + + c1.set("2"); + + check(c1, 2, true); + check(c1, 3, false); + + c1.set("3"); + + check(c1, 2, false); + check(c1, 3, true); + + c1.set("2,3"); + + check(c1, 2, true); + check(c1, 3, true); + check(c1, 4, false); + + c1.set("all"); + + check(c1, 2, true); + check(c1, 4, true); + check(c1, 5, true); + + comma_list c2; + + c2.set("6,all"); + + check(c2, 4, true); + check(c2, 0, true); + + c2.set("all,6"); + + check(c2, 4, true); + check(c2, 0, true); + + c2.set("10"); + check(c2, 10, true); + check(c2, 11, false); + return EXIT_SUCCESS; +} diff --git a/libutil++/tests/file_manip_tests.cpp b/libutil++/tests/file_manip_tests.cpp new file mode 100644 index 0000000..dfe161b --- /dev/null +++ b/libutil++/tests/file_manip_tests.cpp @@ -0,0 +1,241 @@ +/** + * @file file_manip_tests.cpp + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include + +#include +#include +#include + +#include "file_manip.h" + +using namespace std; + +template +struct input_output { + Input input; + Output output; +}; + + +template +static void check_result(char const * fct_name, Input const & input, + Output const & output, Result const & result) +{ + if (result != output) { + cerr << fct_name << " " + << "for:\n\"" << input << "\"\n" + << "expect:\n\"" << output << "\"\n" + << "found:\n\"" << result << "\"\n"; + exit(EXIT_FAILURE); + } +} + +template +static void check_result(char const * fct_name, Input const & input1, + Input input2, Output const & output, Result const & result) +{ + if (result != output) { + cerr << fct_name << ": \n" + << "for:\n\"" << input1 << "\"\n" + << "\"" << input2 << "\"\n" + << "expect:\n\"" << output << "\"\n" + << "found:\n\"" << result << "\"\n"; + exit(EXIT_FAILURE); + } +} + + +static input_output expect_dirname[] = +{ + { "/", "/" }, + { "//////", "/" }, + { "/usr", "/" }, + { "///usr", "/" }, + // suprising but conform to dirname(1) + { "///usr/dir", "///usr" }, + { "usr/dir", "usr" }, + { "usr", "." }, + { "n", "." }, + { "../..", ".." }, + { "/../..", "/.." }, + { "./..", "." }, + { "./.", "." }, + { "..", "." }, + { ".", "." }, + { "", "." }, + { 0, 0 } +}; + +static void dirname_tests() +{ + input_output const * cur; + for (cur = expect_dirname; cur->input; ++cur) { + string result = op_dirname(cur->input); + check_result("dirname", cur->input, cur->output, result); + } +} + + +static input_output expect_basename[] = +{ + { "/", "/" }, + { "//////", "/" }, + { "/usr", "usr" }, + { "///usr", "usr" }, + { "///usr/dir", "dir" }, + { "///usr//dir", "dir" }, + { "usr/dir", "dir" }, + { "usr", "usr" }, + { "../..", ".." }, + { "/../..", ".." }, + { "./..", ".." }, + { "./.", "." }, + { ".", "." }, + { 0, 0 } +}; + +static void basename_tests() +{ + input_output const * cur; + for (cur = expect_basename; cur->input; ++cur) { + string result = op_basename(cur->input); + check_result("basename", cur->input, cur->output, result); + } +} + + +static input_output expect_is_directory[] = +{ + { ".", true }, + { "/.", true }, + { "./", true }, + { "/", true }, + { "../", true }, + { "../.", true }, + { "non_existing_dir", false }, + { 0, 0 } +}; + +static void is_directory_tests() +{ + input_output const * cur; + for (cur = expect_is_directory; cur->input; ++cur) { + bool result = is_directory(cur->input); + check_result("is_directory", cur->input, cur->output, result); + } +} + + +static input_output, bool> +expect_is_files_identical[] = { +#define MAKE_PAIR(a, b) make_pair(string(a), string(b)) + { MAKE_PAIR(__FILE__, __FILE__), true }, + { MAKE_PAIR(__FILE__, "not_existing"), false }, + { MAKE_PAIR("not_exisiting", __FILE__), false }, + { MAKE_PAIR("not_exisiting", "not_existing"), false }, + { MAKE_PAIR("", ""), false } +#undef MAKE_PAIR +}; + +void is_files_identical_tests(char const * prog_name) +{ + check_result("is_files_identical", prog_name, prog_name, + is_files_identical(prog_name, prog_name), true); + + input_output, bool> const * cur; + for (cur = expect_is_files_identical; !cur->input.first.empty(); ++cur) { + bool result = is_files_identical(cur->input.first, + cur->input.second); + check_result("is_files_identical", cur->input.first, + cur->input.second, cur->output, result); + } +} + + +static input_output expect_op_file_readable[] = +{ + { __FILE__, true }, + { "./" __FILE__, true }, + { ".", false }, + { "/.", false }, + { "./", false }, + { "/", false }, + { "../", false }, + { "../.", false }, + { "non_existing_file", false }, + { 0, 0 } +}; + +static void op_file_readable_tests() +{ + input_output const * cur; + for (cur = expect_op_file_readable; cur->input; ++cur) { + bool result = op_file_readable(cur->input); + check_result("op_file_readable", cur->input, cur->output, result); + } +} + + +static input_output expect_realpath[] = +{ + // realpath() file argument must exists. + { "file_manip_tests.o", "file_manip_tests.o" }, + { "../tests/" "file_manip_tests.o", "file_manip_tests.o" }, + { ".//.//" "file_manip_tests.o", "file_manip_tests.o" }, + // POSIX namespaces ignored by realpath(3) + { "//", "/" }, + { "//usr", "/usr" }, + { "///", "/" }, + { "", "" } +}; + + +// FIXME: useful to test symlinks too +static void realpath_tests() +{ + input_output const * cur; + for (cur = expect_realpath; !cur->input.empty(); ++cur) { + string result = op_realpath(cur->input); + string expect = cur->output; + if (cur->input[0] != '/') + expect = SRCDIR + expect; + check_result("op_realpath", cur->input, + expect, result); + } +} + + +void create_file_list_tests() +{ + list result; + if (!create_file_list(result, ".")) { + cerr << "create_file_list() fail\n"; + exit(EXIT_FAILURE); + } + if (result.empty()) { + cerr << "create_file_list(); empty result\n"; + exit(EXIT_FAILURE); + } +} + + +int main(int, char * argv[]) +{ + dirname_tests(); + basename_tests(); + is_directory_tests(); + is_files_identical_tests(argv[0]); + op_file_readable_tests(); + realpath_tests(); + create_file_list_tests(); + return EXIT_SUCCESS; +} diff --git a/libutil++/tests/glob_filter_tests.cpp b/libutil++/tests/glob_filter_tests.cpp new file mode 100644 index 0000000..e88a3ed --- /dev/null +++ b/libutil++/tests/glob_filter_tests.cpp @@ -0,0 +1,53 @@ +/** + * @file glob_filter_tests.cpp + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include + +#include "glob_filter.h" + +using namespace std; + +#define check(filter, str, result) \ + if (filter.match(str) != result) { \ + cerr << "\"" << str << "\" matched with " #filter \ + << " did not return " #result << endl; \ + exit(EXIT_FAILURE); \ + } + +int main() +{ + glob_filter f1("foo,*bar", "foobar"); + check(f1, "foo/barfoobar", true); + check(f1, "foo/bar", true); + check(f1, "/foo/foobar/foo", false); + check(f1, "fooobar1", false); + check(f1, "foo1", false); + check(f1, "foobar", false); + check(f1, "bar1", false); + + glob_filter f2("foo", ""); + check(f2, "foo", true); + check(f2, "foo1", false); + check(f2, "foo/foo", false); + + glob_filter f3("", "foo"); + check(f3, "foo", false); + check(f3, "foo1", true); + check(f3, "foo/foo", true); + + glob_filter f4("foo", "foo"); + check(f4, "foo", false); + check(f4, "foo1", false); + check(f4, "foo/foo", false); + + return EXIT_SUCCESS; +} diff --git a/libutil++/tests/path_filter_tests.cpp b/libutil++/tests/path_filter_tests.cpp new file mode 100644 index 0000000..e664d0f --- /dev/null +++ b/libutil++/tests/path_filter_tests.cpp @@ -0,0 +1,78 @@ +/** + * @file path_filter_tests.cpp + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include + +#include "path_filter.h" + +using namespace std; + +#define check(filter, str, result) \ + if (filter.match(str) != result) { \ + cerr << "\"" << str << "\" matched with " #filter \ + << " did not return " #result << endl; \ + exit(EXIT_FAILURE); \ + } + +int main() +{ + path_filter f1("foo,*bar", "foobar"); + check(f1, "foo/barfoobar", true); + check(f1, "foo/bar", true); + check(f1, "/foo/foobar/foo", false); + check(f1, "fooobar1", false); + check(f1, "foo1", false); + check(f1, "foobar", false); + check(f1, "bar1", false); + + path_filter f2("foo", ""); + check(f2, "foo", true); + check(f2, "foo1", false); + check(f2, "foo/foo", true); + + path_filter f3("", "foo"); + check(f3, "foo", false); + check(f3, "foo1", true); + check(f3, "foo/foo", false); + + path_filter f4("foo", "foo"); + check(f4, "foo", false); + check(f4, "foo1", false); + check(f4, "foo/foo", false); + + path_filter f5("*foo*", "*bar*"); + check(f5, "foo", true); + check(f5, "bar", false); + check(f5, "foobar", false); + check(f5, "barfoo", false); + check(f5, "foo/bar", false); + + path_filter f6(" foo,bar", "bar "); + check(f6, "foo", false); + check(f6, "foo ", false); + check(f6, " foo", true); + check(f6, "bar", true); + check(f6, "bar ", false); + check(f6, " bar", false); + check(f6, "foo ", false); + check(f6, "foo/ bar", false); + + path_filter f7(".", ""); + check(f7, ".", true); + // a bit surprising but right IMHO, our implementation use successive + // dirname(input) to check vs the included path and + // dirname("foo") == "." so all relative path input match a "." + // included filter + check(f7, "foo", true); + + return EXIT_SUCCESS; +} diff --git a/libutil++/tests/string_filter_tests.cpp b/libutil++/tests/string_filter_tests.cpp new file mode 100644 index 0000000..7d06039 --- /dev/null +++ b/libutil++/tests/string_filter_tests.cpp @@ -0,0 +1,90 @@ +/** + * @file string_filter_tests.cpp + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include + +#include "string_filter.h" + +using namespace std; + +#define check(filter, str, result) \ + if (filter.match(str) != result) { \ + cerr << "\"" << str << "\" matched with " #filter \ + << " did not return " #result << endl; \ + exit(EXIT_FAILURE); \ + } + +int main() +{ + string_filter f1; + check(f1, "", true); + check(f1, "ok", true); + + string_filter f2("ok", ""); + check(f2, "ok", true); + check(f2, "no", false); + + string_filter f3("", "no"); + check(f3, "ok", true); + check(f3, "no", false); + + string_filter f4("ok,ok2,", ""); + check(f4, "ok", true); + check(f4, "ok2", true); + check(f4, "no", false); + + string_filter f5("ok,ok2", "no,no2"); + check(f5, "ok", true); + check(f5, "ok2", true); + check(f5, "no", false); + check(f5, "no2", false); + + vector v1; + vector v2; + + string_filter f6(v1, v2); + check(f6, "", true); + check(f6, "ok", true); + + v1.push_back("ok"); + v1.push_back("ok2"); + + string_filter f7(v1, v2); + check(f7, "ok", true); + check(f7, "ok2", true); + check(f7, "no", false); + + v1.clear(); + + v2.push_back("no"); + v2.push_back("no2"); + + string_filter f8(v1, v2); + check(f8, "ok", true); + check(f8, "no", false); + check(f8, "no", false); + + v1.push_back("ok"); + v1.push_back("ok2"); + + string_filter f9(v1, v2); + check(f9, "ok", true); + check(f9, "no2", false); + + string_filter f10(" foo ", ""); + check(f10, " foo ", true); + check(f10, " foo", false); + check(f10, "foo ", false); + check(f10, "foo", false); + + return EXIT_SUCCESS; +} diff --git a/libutil++/tests/string_manip_tests.cpp b/libutil++/tests/string_manip_tests.cpp new file mode 100644 index 0000000..1cb07df --- /dev/null +++ b/libutil++/tests/string_manip_tests.cpp @@ -0,0 +1,325 @@ +/** + * @file string_manip_tests.cpp + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include +#include +#include +#include + +#include "string_manip.h" + +using namespace std; + +template +struct input_output { + Input input; + Output output; +}; + + +template +static void check_result(char const * fct_name, Input const & input, + Output const & output, Result const & result) +{ + if (result != output) { + cerr << fct_name << ": \n" + << "for:\n\"" << input << "\"\n" + << "expect:\n\"" << output << "\"\n" + << "found:\n\"" << result << "\"\n"; + exit(EXIT_FAILURE); + } +} + + +static input_output expect_erase[] = +{ + { "", "" }, + { ";;;", "" }, + { "ab;;;cd", "cd" }, + { ";;;cd", "cd" }, + { "ab;;;", "" }, + { 0, 0 } +}; + +static void erase_to_last_of_tests() +{ + input_output const * cur; + for (cur = expect_erase; cur->input; ++cur) { + string result = erase_to_last_of(cur->input, ';'); + check_result("erase_to_last_of()", cur->input, cur->output, + result); + } +} + + +static input_output > expect_split[] = +{ +#define MAKE_PAIR(a, b) make_pair(string(a), string(b)) + { "ab;cd", MAKE_PAIR("ab", "cd") }, + { ";cd", MAKE_PAIR("", "cd") }, + { "ab;", MAKE_PAIR("ab", "") }, + { "b;d", MAKE_PAIR("b", "d") }, + { ";d", MAKE_PAIR("", "d") }, + { "a;", MAKE_PAIR("a", "") }, + { ";", MAKE_PAIR("", "") }, + { "", MAKE_PAIR("", "") }, + { 0, MAKE_PAIR("", "") } +#undef MAKE_PAIR +}; + +static void split_tests() +{ + input_output > const * cur; + for (cur = expect_split; cur->input; ++cur) { + string temp = cur->input; + string result = split(temp, ';'); + check_result("split()", cur->input, cur->output.first, temp); + check_result("split()", cur->input, cur->output.second, result); + } +} + +static input_output > expect_is_prefix[] = +{ +#define MAKE_PAIR(a, b) make_pair(string(a), b) + { "abcd", MAKE_PAIR("abc", true) }, + { "abcd", MAKE_PAIR("ac", false) }, + { "babcd", MAKE_PAIR("abc", false) }, + // these invoke undefined behavior from is_prefix, we keep them + // for the record. +// { "babcd", MAKE_PAIR("", false) }, +// { "", MAKE_PAIR("", false) }, + { 0, MAKE_PAIR("", true) } +#undef MAKE_PAIR +}; + +static void is_prefix_tests() +{ + input_output > const * cur; + for (cur = expect_is_prefix; cur->input; ++cur) { + bool result = is_prefix(cur->input, cur->output.first); + if (result != cur->output.second) { + cerr << "is_prefix(" << cur->input << ", " + << cur->output.first << ") " + << "return " << result << endl; + exit(EXIT_FAILURE); + } + } +} + + +static const size_t max_token = 8; +static input_output expect_separate_token[] = +{ + { "aa", { "aa" } }, + { "a\\c", { "a\\c" } }, + { "a\\\\c", { "a\\\\c" } }, + { "a\\\\c\\", { "a\\\\c\\" } }, + { "ab;cd;ef;gh", { "ab", "cd", "ef", "gh" } }, + { "ab\\;cd", { "ab;cd" } }, + { "a;a", { "a", "a" } }, + { ";a", { "", "a" } }, + { ";", { "", "" } }, + { ";;", { "", "", "" } }, + { 0, { 0, } } +}; + + +static void separate_token_tests() +{ + input_output const * cur; + for (cur = expect_separate_token; cur->input; ++cur) { + vector result = separate_token(cur->input, ';'); + if (result.size() > max_token) { + cerr << "separate_token(): too many token\n" + << "input:\n" + << '"' << cur->input << "\"\n" + << "output\n"; + copy(result.begin(), result.end(), + ostream_iterator(cerr, "\n")); + exit(EXIT_FAILURE); + } + for (size_t i = 0; i < result.size(); ++i) { + if (result[i] != cur->output[i]) { + cerr << "separate_token():\n" + << "input:\n" + << cur->input << endl; + cerr << "expect:\n"; + for (size_t i = 0; i < max_token; ++i) { + if (!cur->output[i]) + break; + cerr << cur->output[i] << endl; + } + cerr << "output:\n"; + copy(result.begin(), result.end(), + ostream_iterator(cerr, "\n")); + exit(EXIT_FAILURE); + } + } + } +} + + +static input_output expect_rtrim[] = +{ + { "abc", "abc" }, + { "abc ", "abc" }, + { " abc ", " abc" }, + { " abc \t \t", " abc" }, + { " ", "" }, + { "\t \t", "" }, + { "", "" }, + { 0, 0 } +}; + +static void rtrim_tests() +{ + input_output const * cur; + for (cur = expect_rtrim; cur->input; ++cur) { + string result = rtrim(cur->input); + check_result("rtrim()", cur->input, cur->output, result); + } +} + + +static input_output expect_ltrim[] = +{ + { "abc", "abc" }, + { "abc ", "abc " }, + { " abc ", "abc " }, + { "\t \tabc ", "abc " }, + { " ", "" }, + { "\t \t", "" }, + { "", "" }, + { 0, 0 } +}; + +static void ltrim_tests() +{ + input_output const * cur; + for (cur = expect_ltrim; cur->input; ++cur) { + string result = ltrim(cur->input); + check_result("ltrim()", cur->input, cur->output, result); + } +} + + +static input_output expect_trim[] = +{ + { "abc", "abc" }, + { "abc ", "abc" }, + { " abc ", "abc" }, + { "\t \tabc \t", "abc" }, + { " ", "" }, + { "\t \t", "" }, + { "", "" }, + { 0, 0 } +}; + +static void trim_tests() +{ + input_output const * cur; + for (cur = expect_trim; cur->input; ++cur) { + string result = trim(cur->input); + check_result("trim()", cur->input, cur->output, result); + } +} + + +static input_output expect_format_percent[] = +{ + { 2.2, " 2.2000" }, + { 0, " 0" }, + { 100.00, "100.000" }, + { 99.99999, "100.000" }, + { 0.00000344, "3.4e-06" }, + // FIXME, must be 3.e-124 but output is 3.4e-124 +// { 0.34e-123, "3.e-124" }, + { -1.0, 0 } +}; + +static void format_percent_tests() +{ + input_output const * cur; + for (cur = expect_format_percent; cur->input != -1.0; ++cur) { + string result = format_percent(cur->input, percent_int_width, + percent_fract_width); + check_result("format_percent()", cur->input, cur->output, + result); + } +} + + +static input_output expect_from_str_to_uint[] = +{ + { 123, "123" }, + { 33, "33" }, + { 0, "0" }, + { 0, 0 } +}; + +static void tostr_tests() +{ + input_output const * cur; + for (cur = expect_from_str_to_uint; cur->output; ++cur) { + string result = op_lexical_cast(cur->input); + check_result("op_lexical_cast()", cur->input, + cur->output, result); + } +} + +static void touint_tests() +{ + // reversed input/output of the previous tests + input_output const * cur; + for (cur = expect_from_str_to_uint; cur->output; ++cur) { + unsigned int result = + op_lexical_cast(cur->output); + check_result("op_lexical_cast()", cur->output, cur->input, + result); + } +} + + +static input_output expect_from_str_to_bool[] = +{ + { "0", false }, + { "1", true }, + { 0, 0 } +}; + +static void tobool_tests() +{ + input_output const * cur; + for (cur = expect_from_str_to_bool; cur->input; ++cur) { + bool result = op_lexical_cast(cur->input); + check_result("op_lexical_cast()", cur->input, cur->output, + result); + } +} + +// FIXME: more op_lexical_cast<> tests + +int main() +{ + erase_to_last_of_tests(); + tostr_tests(); + touint_tests(); + tobool_tests(); + split_tests(); + is_prefix_tests(); + separate_token_tests(); + rtrim_tests(); + ltrim_tests(); + trim_tests(); + format_percent_tests(); + return EXIT_SUCCESS; +} diff --git a/libutil++/tests/utility_tests.cpp b/libutil++/tests/utility_tests.cpp new file mode 100644 index 0000000..8de000f --- /dev/null +++ b/libutil++/tests/utility_tests.cpp @@ -0,0 +1,118 @@ +/** + * @file utility_tests.cpp + * tests utility.h and op_exception.h + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include + +#include "utility.h" +#include "op_exception.h" + +using namespace std; + +static int nb_new; +static int nb_new_array; + +void* operator new(size_t size) throw(bad_alloc) +{ + nb_new++; + return malloc(size); +} + +void* operator new[](size_t size) throw(bad_alloc) +{ + nb_new_array++; + return malloc(size); +} + +void operator delete(void * p) throw() +{ + nb_new--; + if (p) + free(p); +} + +void operator delete[](void * p) throw() +{ + nb_new_array--; + if (p) + free(p); +} + + +void check_alloc() +{ + if (nb_new) { + cerr << "new(size_t) leak\n"; + exit(EXIT_FAILURE); + } + + if (nb_new_array) { + cerr << "new[](size_t) leak\n"; + exit(EXIT_FAILURE); + } +} + + +struct A {}; + +template +void throw_tests() +{ + scoped_ptr a(new A); + try { + scoped_ptr a(new A); + throw Throw(""); + } + catch (Catch const &) { + } +} + + +template +void throw_tests(bool) +{ + scoped_array b(new A[10]); + try { + scoped_array a(new A[10]); + throw Throw(""); + } + catch (Catch const &) { + } +} + + +void tests_new() +{ + throw_tests(); + throw_tests(); + throw_tests(); + throw_tests(); + throw_tests(true); + throw_tests(true); + throw_tests(true); + throw_tests(true); +} + + +int main() +{ + try { + tests_new(); + check_alloc(); + } + catch (...) { + cerr << "unknown exception\n"; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/libutil++/unique_storage.h b/libutil++/unique_storage.h new file mode 100644 index 0000000..0f7fd71 --- /dev/null +++ b/libutil++/unique_storage.h @@ -0,0 +1,111 @@ +/** + * @file unique_storage.h + * Unique storage of values + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef UNIQUE_STORAGE_H +#define UNIQUE_STORAGE_H + +#include +#include +#include + +/** + * Store values such that only one copy of the value + * is ever stored. + * + * I is an arbitrary typename that's never + * used. + * + * It is a required parameter in order to enforce + * type-safety for a collection. + * + * The value type "V" must be default-constructible, + * and this is the value returned by a stored id_value + * where .set() is false + */ +template class unique_storage { + +public: + unique_storage() { + // id 0 + values.push_back(V()); + } + + virtual ~unique_storage() {} + + typedef std::vector stored_values; + + /// the actual ID type + struct id_value { + /// id == 0 means "empty" / "undefined" + id_value() : id(0) {} + + /// does this ID map to a non-default value ? + bool set() const { + return id; + } + + bool operator<(id_value const & rhs) const { + return id < rhs.id; + } + + bool operator==(id_value const & rhs) const { + return id == rhs.id; + } + + bool operator!=(id_value const & rhs) const { + return !(id == rhs.id); + } + + private: + friend class unique_storage; + + typedef typename stored_values::size_type size_type; + + explicit id_value(size_type s) : id(s) {} + + /// actual ID value + size_type id; + }; + + + /// ensure this value is available + id_value const create(V const & value) { + typename id_map::value_type val(value, id_value(values.size())); + std::pair + inserted = ids.insert(val); + if (inserted.second) { + values.push_back(value); + } + + return inserted.first->second; + } + + + /// return the stored value for the given ID + V const & get(id_value const & id) const { + // some stl lack at(), so we emulate it + if (id.id < values.size()) + return values[id.id]; + + throw std::out_of_range("unique_storage::get(): out of bounds"); + } + +private: + typedef std::map id_map; + + /// the contained values + stored_values values; + + /// map from ID to value + id_map ids; +}; + +#endif /* !UNIQUE_STORAGE_H */ diff --git a/libutil++/utility.h b/libutil++/utility.h new file mode 100644 index 0000000..83c36ca --- /dev/null +++ b/libutil++/utility.h @@ -0,0 +1,102 @@ +/** + * @file utility.h + * General purpose C++ utility + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef UTILITY_H +#define UTILITY_H + +#include + +/** noncopyable : object of class derived from this class can't be copied + * and isn't copy-constructible */ +class noncopyable { +protected: + noncopyable() {} + ~noncopyable() {} +private: + noncopyable(noncopyable const &); + noncopyable const & operator=(noncopyable const &); +}; + + +template class scoped_ptr { +public: + explicit scoped_ptr(T * p = 0) : p_(p) {} + ~scoped_ptr() { delete p_; } + + void reset(T * p = 0) { + if (p == p_) + return; + delete p_; + p_ = p; + } + + T & operator*() const { return *p_; } + T * operator->() const { return p_; } + T * get() const { return p_; } + + void swap(scoped_ptr & sp) { + T * tmp = sp.p_; + sp.p_ = p_; + p_ = tmp; + } + +private: + scoped_ptr & operator=(scoped_ptr const &); + scoped_ptr(scoped_ptr const &); + T * p_; +}; + +template class scoped_array { +public: + explicit scoped_array(T * p = 0) : p_(p) {} + ~scoped_array() { delete [] p_; } + + void reset(T * p = 0) { + if (p == p_) + return; + delete [] p_; + p_ = p; + } + + T & operator[](std::ptrdiff_t i) const { return p_[i]; } + T * get() const { return p_; } + + void swap(scoped_array & sp) { + T * tmp = sp.p_; + sp.p_ = p_; + p_ = tmp; + } + +private: + scoped_array & operator=(scoped_array const &); + scoped_array(scoped_array const &); + T * p_; +}; + +/** + * @param count + * @param total + * + * return total == 0 ? 1.0 : (count / total); + */ +inline double op_ratio(double count, double total) +{ + return total == 0 ? 0.0 : (count / total); +} + +// Part copyright: +// (C) Copyright boost.org 1999. Permission to copy, use, modify, sell +// and distribute this software is granted provided this copyright +// notice appears in all copies. This software is provided "as is" without +// express or implied warranty, and with no claim as to its suitability for +// any purpose. + +#endif /* !UTILITY_H */ diff --git a/libutil/Makefile.am b/libutil/Makefile.am new file mode 100644 index 0000000..1c0b218 --- /dev/null +++ b/libutil/Makefile.am @@ -0,0 +1,28 @@ +SUBDIRS = . tests + +AM_CFLAGS = @OP_CFLAGS@ + +noinst_LIBRARIES = libutil.a +libutil_a_SOURCES = \ + op_deviceio.c \ + op_lockfile.c \ + op_file.c \ + op_fileio.c \ + op_get_time.c \ + op_libiberty.c \ + op_popt.c \ + op_string.c \ + op_cpufreq.c \ + op_deviceio.h \ + op_fileio.h \ + op_libiberty.h \ + op_lockfile.h \ + op_types.h \ + op_file.h \ + op_get_time.h \ + op_list.h \ + op_popt.h \ + op_string.h \ + op_cpufreq.h \ + op_version.c \ + op_version.h diff --git a/libutil/Makefile.in b/libutil/Makefile.in new file mode 100644 index 0000000..10d30d3 --- /dev/null +++ b/libutil/Makefile.in @@ -0,0 +1,580 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(libutil_a_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = libutil +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libutil_a_AR = $(AR) $(ARFLAGS) +libutil_a_LIBADD = +am_libutil_a_OBJECTS = op_deviceio.$(OBJEXT) op_lockfile.$(OBJEXT) \ + op_file.$(OBJEXT) op_fileio.$(OBJEXT) op_get_time.$(OBJEXT) \ + op_libiberty.$(OBJEXT) op_popt.$(OBJEXT) op_string.$(OBJEXT) \ + op_cpufreq.$(OBJEXT) op_version.$(OBJEXT) +libutil_a_OBJECTS = $(am_libutil_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libutil_a_SOURCES) +DIST_SOURCES = $(libutil_a_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +SUBDIRS = . tests +AM_CFLAGS = @OP_CFLAGS@ +noinst_LIBRARIES = libutil.a +libutil_a_SOURCES = \ + op_deviceio.c \ + op_lockfile.c \ + op_file.c \ + op_fileio.c \ + op_get_time.c \ + op_libiberty.c \ + op_popt.c \ + op_string.c \ + op_cpufreq.c \ + op_deviceio.h \ + op_fileio.h \ + op_libiberty.h \ + op_lockfile.h \ + op_types.h \ + op_file.h \ + op_get_time.h \ + op_list.h \ + op_popt.h \ + op_string.h \ + op_cpufreq.h \ + op_version.c \ + op_version.h + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libutil/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libutil/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libutil.a: $(libutil_a_OBJECTS) $(libutil_a_DEPENDENCIES) + -rm -f libutil.a + $(libutil_a_AR) libutil.a $(libutil_a_OBJECTS) $(libutil_a_LIBADD) + $(RANLIB) libutil.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_cpufreq.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_deviceio.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_file.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_fileio.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_get_time.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_libiberty.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_lockfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_popt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_string.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/op_version.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LIBRARIES) +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-generic clean-noinstLIBRARIES clean-recursive \ + ctags ctags-recursive distclean distclean-compile \ + distclean-generic distclean-recursive distclean-tags distdir \ + dvi dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-recursive pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libutil/op_cpufreq.c b/libutil/op_cpufreq.c new file mode 100644 index 0000000..78a6333 --- /dev/null +++ b/libutil/op_cpufreq.c @@ -0,0 +1,64 @@ +/** + * @file op_cpufreq.c + * get cpu frequency definition + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include + +#include "op_fileio.h" + +double op_cpu_frequency(void) +{ + double fval = 0.0; + unsigned long uval; + char * line = NULL; + + FILE * fp = op_try_open_file("/proc/cpuinfo", "r"); + if (!fp) + return 0.0; + + while (1) { + line = op_get_line(fp); + + if (!line) + break; + + if (line[0] == '\0') { + free(line); + continue; + } + + /* x86/parisc/ia64/x86_64 */ + if (sscanf(line, "cpu MHz : %lf", &fval) == 1) + break; + /* ppc/ppc64 */ + if (sscanf(line, "clock : %lfMHz", &fval) == 1) + break; + /* alpha */ + if (sscanf(line, "cycle frequency [Hz] : %lu", &uval) == 1) { + fval = uval / 1E6; + break; + } + /* sparc64 if CONFIG_SMP only */ + if (sscanf(line, "Cpu0ClkTck : %lx", &uval) == 1) { + fval = uval / 1E6; + break; + } + /* s390 doesn't provide cpu freq, checked up to 2.6-test4 */ + + free(line); + } + + if (line) + free(line); + op_close_file(fp); + + return fval; +} diff --git a/libutil/op_cpufreq.h b/libutil/op_cpufreq.h new file mode 100644 index 0000000..0a71172 --- /dev/null +++ b/libutil/op_cpufreq.h @@ -0,0 +1,30 @@ +/** + * @file op_cpufreq.h + * get cpu frequency declaration + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_CPUFREQ_H +#define OP_CPUFREQ_H + +#if defined(__cplusplus) +extern "C" { +#endif + +/* + * return the estimated cpu frequency in Mhz through + * parsing /proc/cpuinfo, return 0 if this information + * is not avalaible e.g. sparc64 with a non SMP kernel + */ +double op_cpu_frequency(void); + +#if defined(__cplusplus) +} +#endif + +#endif /* !OP_CPUFREQ_H */ diff --git a/libutil/op_deviceio.c b/libutil/op_deviceio.c new file mode 100644 index 0000000..8210304 --- /dev/null +++ b/libutil/op_deviceio.c @@ -0,0 +1,42 @@ +/** + * @file op_deviceio.c + * Reading from a special device + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "op_deviceio.h" + +#include +#include + +#include +#include +#include +#include + +fd_t op_open_device(char const * name) +{ + return open(name, O_RDONLY); +} + + +ssize_t op_read_device(fd_t devfd, void * buf, size_t size) +{ + ssize_t count; + + lseek(devfd, 0, SEEK_SET); + + count = read(devfd, buf, size); + + if (count < 0 && errno != EINTR && errno != EAGAIN) { + perror("oprofiled:op_read_device: "); + exit(EXIT_FAILURE); + } + + return count; +} diff --git a/libutil/op_deviceio.h b/libutil/op_deviceio.h new file mode 100644 index 0000000..f3bd4c2 --- /dev/null +++ b/libutil/op_deviceio.h @@ -0,0 +1,57 @@ +/** + * @file op_deviceio.h + * Reading from a special device + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_DEVICEIO_H +#define OP_DEVICEIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "op_types.h" + +#include + +/** + * op_open_device - open a special char device for reading + * @param name file name of device file + * + * Open the special file name. Returns the file descriptor + * for the file or -1 on error. + */ +fd_t op_open_device(char const * name); + +/** + * op_read_device - read from a special char device + * @param devfd file descriptor of device + * @param buf buffer + * @param size size of buffer + * + * Read size bytes from a device into buffer buf. + * A seek to the start of the device file is done first + * then a read is requested in one go of size bytes. + * + * It is the caller's responsibility to do further op_read_device() + * calls if the number of bytes read is not what is requested + * (where this is applicable). + * + * The number of bytes read is returned, or a negative number + * on failure (in which case errno will be set). If the call is + * interrupted, then errno will be EINTR, and the client should + * arrange for re-starting the read if necessary. + */ +ssize_t op_read_device(fd_t devfd, void * buf, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif /* OP_DEVICEIO_H */ diff --git a/libutil/op_file.c b/libutil/op_file.c new file mode 100644 index 0000000..f2658b4 --- /dev/null +++ b/libutil/op_file.c @@ -0,0 +1,73 @@ +/** + * @file op_file.c + * Useful file management helpers + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include + +#include +#include +#include +#include +#include + +#include "op_file.h" +#include "op_libiberty.h" + +int op_file_readable(char const * file) +{ + struct stat st; + return !stat(file, &st) && S_ISREG(st.st_mode) && !access(file, R_OK); +} + + +time_t op_get_mtime(char const * file) +{ + struct stat st; + + if (stat(file, &st)) + return 0; + + return st.st_mtime; +} + + +int create_dir(char const * dir) +{ + if (mkdir(dir, 0755)) { + /* FIXME: Does not verify existing is a dir */ + if (errno == EEXIST) + return 0; + return errno; + } + + return 0; +} + + +int create_path(char const * path) +{ + int ret = 0; + + char * str = xstrdup(path); + + char * pos = str[0] == '/' ? str + 1 : str; + + for ( ; (pos = strchr(pos, '/')) != NULL; ++pos) { + *pos = '\0'; + ret = create_dir(str); + *pos = '/'; + if (ret) + break; + } + + free(str); + return ret; +} diff --git a/libutil/op_file.h b/libutil/op_file.h new file mode 100644 index 0000000..2774ffe --- /dev/null +++ b/libutil/op_file.h @@ -0,0 +1,64 @@ +/** + * @file op_file.h + * Useful file management helpers + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_FILE_H +#define OP_FILE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + * op_file_readable - is a file readable + * @param file file name + * + * Return true if the given file is readable and regular. + * + * Beware of race conditions ! + */ +int op_file_readable(char const * file); + +/** + * op_get_mtime - get mtime of file + * @param file file name + * + * Returns the mtime of the given file or 0 on failure + */ +time_t op_get_mtime(char const * file); + +/** + * create_dir - create a directory + * @param dir the directory name to create + * + * Returns 0 on success. + */ +int create_dir(char const * dir); + + +/** + * create_path - create a path + * @param path the path to create + * + * create directory for each dir components in path + * the last path component is not considered as a directory + * but as a filename + * + * Returns 0 on success. + */ +int create_path(char const * path); + +#ifdef __cplusplus +} +#endif + +#endif /* OP_FILE_H */ diff --git a/libutil/op_fileio.c b/libutil/op_fileio.c new file mode 100644 index 0000000..9b3e21d --- /dev/null +++ b/libutil/op_fileio.c @@ -0,0 +1,228 @@ +/** + * @file op_fileio.c + * Reading from / writing to files + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include "op_fileio.h" + +#include "op_libiberty.h" + +#include +#include +#include + +static FILE * op_do_open_file(char const * name, char const * mode, int fatal) +{ + FILE * fp; + + fp = fopen(name, mode); + + if (!fp) { + if (fatal) { + fprintf(stderr,"oprofiled:op_do_open_file: %s: %s", + name, strerror(errno)); + exit(EXIT_FAILURE); + } + } + + return fp; +} + + +FILE * op_try_open_file(char const * name, char const * mode) +{ + return op_do_open_file(name, mode, 0); +} + + +FILE * op_open_file(char const * name, char const * mode) +{ + return op_do_open_file(name, mode, 1); +} + + +void op_close_file(FILE * fp) +{ + if (fclose(fp)) + perror("oprofiled:op_close_file: "); +} + + +void op_write_file(FILE * fp, void const * buf, size_t size) +{ + size_t written; + + if (size == 0) + return; + + written = fwrite(buf, size, 1, fp); + + if (written != 1) { + fprintf(stderr, + "oprofiled:op_write_file: wrote less than expected: %lu bytes.\n", + (unsigned long)size); + exit(EXIT_FAILURE); + } +} + + +void op_write_u8(FILE * fp, u8 val) +{ + op_write_file(fp, &val, sizeof(val)); +} + + +void op_write_u32(FILE * fp, u32 val) +{ + op_write_file(fp, &val, sizeof(val)); +} + + +void op_write_u64(FILE * fp, u64 val) +{ + op_write_file(fp, &val, sizeof(val)); +} + + +u32 op_read_int_from_file(char const * filename, int fatal) +{ + FILE * fp; + u32 value; + + fp = fopen(filename, "r"); + if (fp == NULL) { + if (!fatal) + return (u32)-1; + fprintf(stderr, + "op_read_int_from_file: Failed to open %s, reason %s\n", + filename, strerror(errno)); + exit(EXIT_FAILURE); + } + + if (fscanf(fp, "%u", &value) != 1) { + fclose(fp); + if (!fatal) + return (u32)-1; + fprintf(stderr, + "op_read_int_from_file: Failed to convert contents of file %s to integer\n", + filename); + exit(EXIT_FAILURE); + } + + fclose(fp); + + return value; +} + + +char * op_get_line(FILE * fp) +{ + char * buf; + char * cp; + int c; + size_t max = 512; + + buf = xmalloc(max); + cp = buf; + + while (1) { + switch (c = getc(fp)) { + case EOF: + free(buf); + return NULL; + break; + + case '\n': + case '\0': + *cp = '\0'; + return buf; + break; + + default: + *cp = (char)c; + cp++; + if (((size_t)(cp - buf)) == max) { + buf = xrealloc(buf, max + 128); + cp = buf + max; + max += 128; + } + break; + } + } +} + + +/* FIXME the debug info stuff should be handled by binutils */ +unsigned long +calc_crc32(unsigned long crc, unsigned char * buf, size_t len) +{ + static const unsigned long crc32_table[256] = + { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d + }; + unsigned char * end; + + crc = ~crc & 0xffffffff; + for (end = buf + len; buf < end; ++buf) + crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8); + return ~crc & 0xffffffff; +} diff --git a/libutil/op_fileio.h b/libutil/op_fileio.h new file mode 100644 index 0000000..49b126d --- /dev/null +++ b/libutil/op_fileio.h @@ -0,0 +1,140 @@ +/** + * @file op_fileio.h + * Reading from / writing to files + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_FILEIO_H +#define OP_FILEIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "op_types.h" + +#include + +/** + * op_try_open_file - open a file + * @param name file name + * @param mode mode string + * + * Open a file name. + * Returns file handle or %NULL on failure. + */ +FILE * op_try_open_file(char const * name, char const * mode); + +/** + * op_open_file - open a file + * @param name file name + * @param mode mode string + * + * Open a file name. + * Failure to open is fatal. + */ +FILE * op_open_file(char const * name, char const * mode); + +/** + * op_read_int_from_file - parse an ASCII value from a file into an integer + * @param filename name of file to parse integer value from + * @param fatal non-zero if any error must be fatal + * + * Reads an ASCII integer from the given file. If an error occur and fatal is + * zero (u32)-1 is returned else the value read in is returned. + */ +u32 op_read_int_from_file(char const * filename, int fatal); + +/** + * op_close_file - close a file + * @param fp file pointer + * + * Closes a file pointer. A non-fatal + * error message is produced if the + * close fails. + */ +void op_close_file(FILE * fp); + +/** + * op_write_file - write to a file + * @param fp file pointer + * @param buf buffer + * @param size nr. of bytes to write + * + * Write size bytes of buffer buf to a file. + * Failure is fatal. + */ +void op_write_file(FILE * fp, void const * buf, size_t size); + +/** + * op_write_u32 - write four bytes to a file + * @param fp file pointer + * @param val value to write + * + * Write an unsigned four-byte value val to a file. + * Failure is fatal. + * + * No byte-swapping is done. + */ +void op_write_u32(FILE * fp, u32 val); + +/** + * op_write_u64 - write eight bytes to a file + * @param fp file pointer + * @param val value to write + * + * Write an unsigned eight-byte value val to a file. + * Failure is fatal. + * + * No byte-swapping is done. + */ +void op_write_u64(FILE * fp, u64 val); + +/** + * op_write_u8 - write a byte to a file + * @param fp file pointer + * @param val value to write + * + * Write an unsigned byte value val to a file. + * Failure is fatal. + */ +void op_write_u8(FILE * fp, u8 val); + +/** + * op_get_line - read an ASCII line from a file + * @param fp file pointer + * + * Get a line of ASCII text from a file. The file is read + * up to the first '\0' or '\n'. A trailing '\n' is deleted. + * + * Returns the dynamically-allocated string containing + * that line. At the end of a file NULL will be returned. + * be returned. + * + * The string returned must be free()d by the caller. + * + * getline() is not a proper solution to replace this function + */ +char * op_get_line(FILE * fp); + +/** + * calc_crc32 + * @param crc current value + * @param buf pointer to buffer + * @param len + * + * Returns current crc computed from the crc argument and the + * characters in len characters in buf. + */ +unsigned long calc_crc32(unsigned long crc, unsigned char * buf, size_t len); + +#ifdef __cplusplus +} +#endif + +#endif /* OP_FILEIO_H */ diff --git a/libutil/op_get_time.c b/libutil/op_get_time.c new file mode 100644 index 0000000..c094c63 --- /dev/null +++ b/libutil/op_get_time.c @@ -0,0 +1,24 @@ +/** + * @file op_get_time.c + * Get current time as a string + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "op_get_time.h" + +#include + +char * op_get_time(void) +{ + time_t t = time(NULL); + + if (t == -1) + return ""; + + return ctime(&t); +} diff --git a/libutil/op_get_time.h b/libutil/op_get_time.h new file mode 100644 index 0000000..8f96273 --- /dev/null +++ b/libutil/op_get_time.h @@ -0,0 +1,33 @@ +/** + * @file op_get_time.h + * Get current time as a string + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_GET_TIME_H +#define OP_GET_TIME_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * op_get_time - get current date and time + * + * Returns a string representing the current date + * and time, or an empty string on error. + * + * The string is statically allocated and should not be freed. + */ +char * op_get_time(void); + +#ifdef __cplusplus +} +#endif + +#endif /* OP_GET_TIME_H */ diff --git a/libutil/op_libiberty.c b/libutil/op_libiberty.c new file mode 100644 index 0000000..0cf45d3 --- /dev/null +++ b/libutil/op_libiberty.c @@ -0,0 +1,38 @@ +/** + * @file op_libiberty.c + * Wrapper for libiberty - always use this instead of + * libiberty.h + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include + +#include "op_libiberty.h" + +#ifndef HAVE_XCALLOC +/* some system have a valid libiberty without xcalloc */ +void * xcalloc(size_t n_elem, size_t sz) +{ + void * ptr = xmalloc(n_elem * sz); + + memset(ptr, '\0', n_elem * sz); + + return ptr; +} +#endif + +#ifndef HAVE_XMEMDUP +void * xmemdup (void const * input, size_t copy_size, size_t alloc_size) +{ + void * output = xcalloc(1, alloc_size); + + memcpy(output, input, copy_size); + + return output; +} +#endif diff --git a/libutil/op_libiberty.h b/libutil/op_libiberty.h new file mode 100644 index 0000000..5372a10 --- /dev/null +++ b/libutil/op_libiberty.h @@ -0,0 +1,72 @@ +/** + * @file op_libiberty.h + * Wrapper for libiberty - always use this instead of + * libiberty.h + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_LIBIBERTY_H +#define OP_LIBIBERTY_H + +#include + +#include "config.h" + +#ifdef MALLOC_ATTRIBUTE_OK +#define OP_ATTRIB_MALLOC __attribute__((malloc)) +#else +#define OP_ATTRIB_MALLOC +#endif + +#ifdef HAVE_LIBIBERTY_H +#include +#else + +#ifdef __cplusplus +extern "C" { +#endif + +/* some system have a libiberty.a but no libiberty.h so we must provide + * ourself the missing proto */ +#ifndef HAVE_LIBIBERTY_H +/* Set the program name used by xmalloc. */ +void xmalloc_set_program_name(char const *); + +/* Allocate memory without fail. If malloc fails, this will print a + message to stderr (using the name set by xmalloc_set_program_name, + if any) and then call xexit. */ +void * xmalloc(size_t) OP_ATTRIB_MALLOC; + +/* Reallocate memory without fail. This works like xmalloc. Note, + realloc type functions are not suitable for attribute malloc since + they may return the same address across multiple calls. */ +void * xrealloc(void *, size_t); + +/* Allocate memory without fail and set it to zero. This works like xmalloc */ +void * xcalloc(size_t, size_t) OP_ATTRIB_MALLOC; + +/* Copy a string into a memory buffer without fail. */ +char * xstrdup(char const *) OP_ATTRIB_MALLOC; + +/** + * Duplicates a region of memory without fail. First, alloc_size bytes + * are allocated, then copy_size bytes from input are copied into + * it, and the new memory is returned. If fewer bytes are copied than were + * allocated, the remaining memory is zeroed. + */ +void * xmemdup(void const *, size_t, size_t) OP_ATTRIB_MALLOC; + +#endif /* !HAVE_LIBIBERTY_H */ + +#ifdef __cplusplus +} +#endif + +#endif /* !HAVE_LIBIBERTY_H */ + +#endif /* OP_LIBIBERTY_H */ diff --git a/libutil/op_list.h b/libutil/op_list.h new file mode 100644 index 0000000..2e93dda --- /dev/null +++ b/libutil/op_list.h @@ -0,0 +1,177 @@ +/** + * @file op_list.h + * Kernel-style lists + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Linux kernel authors + */ + +#ifndef OP_LIST_H +#define OP_LIST_H + +/* + * Simple doubly linked list implementation. + * + * Some of the internal functions ("__xxx") are useful when + * manipulating whole lists rather than single entries, as + * sometimes we already know the next/prev entries and we can + * generate better code by using them directly rather than + * using the generic single-entry routines. + */ + +struct list_head { + struct list_head * next, * prev; +}; + +/** + * list_init - init a new entry + * @param ptr the list to init + * + * Init a list head to create an empty list from it + */ +static __inline__ void list_init(struct list_head * ptr) +{ + ptr->next = ptr; + ptr->prev = ptr; +} + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static __inline__ void __list_add(struct list_head * new_entry, + struct list_head * prev, + struct list_head * next) +{ + next->prev = new_entry; + new_entry->next = next; + new_entry->prev = prev; + prev->next = new_entry; +} + +/** + * list_add - add a new entry + * @param new new entry to be added + * @param head list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ +static __inline__ void list_add(struct list_head * new_entry, struct list_head * head) +{ + __list_add(new_entry, head, head->next); +} + +/** + * list_add_tail - add a new entry + * @param new new entry to be added + * @param head list head to add it before + * + * Insert a new entry before the specified head. + * This is useful for implementing queues. + */ +static __inline__ void list_add_tail(struct list_head * new_entry, struct list_head * head) +{ + __list_add(new_entry, head->prev, head); +} + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static __inline__ void __list_del(struct list_head * prev, + struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} + +/** + * list_del - deletes entry from list. + * @param entry the element to delete from the list. + * Note: list_empty on entry does not return true after this, the entry is in an undefined state. + */ +static __inline__ void list_del(struct list_head * entry) +{ + __list_del(entry->prev, entry->next); +} + +/** + * list_del_init - deletes entry from list and reinitialize it. + * @param entry the element to delete from the list. + */ +static __inline__ void list_del_init(struct list_head * entry) +{ + __list_del(entry->prev, entry->next); + list_init(entry); +} + +/** + * list_empty - tests whether a list is empty + * @param head the list to test. + */ +static __inline__ int list_empty(struct list_head * head) +{ + return head->next == head; +} + +/** + * list_splice - join two lists + * @param list the new list to add. + * @param head the place to add it in the first list. + */ +static __inline__ void list_splice(struct list_head * list, struct list_head * head) +{ + struct list_head * first = list->next; + + if (first != list) { + struct list_head * last = list->prev; + struct list_head * at = head->next; + + first->prev = head; + head->next = first; + + last->next = at; + at->prev = last; + } +} + +/** + * list_entry - get the struct for this entry + * @param ptr the &struct list_head pointer. + * @param type the type of the struct this is embedded in. + * @param member the name of the list_struct within the struct. + */ +#define list_entry(ptr, type, member) \ + ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + +/** + * list_for_each - iterate over a list + * @param pos the &struct list_head to use as a loop counter. + * @param head the head for your list. + */ +#define list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); pos = pos->next) + +/** + * list_for_each_safe - iterate over a list safe against removal of list entry + * @param pos the &struct list_head to use as a loop counter. + * @param n another &struct list_head to use as temporary storage + * @param head the head for your list. + */ +#define list_for_each_safe(pos, n, head) \ + for (pos = (head)->next, n = pos->next; pos != (head); \ + pos = n, n = pos->next) + +#define LIST_HEAD_INIT(name) { &(name), &(name) } + +#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name) + +#endif /* OP_LIST_H */ diff --git a/libutil/op_lockfile.c b/libutil/op_lockfile.c new file mode 100644 index 0000000..26e3249 --- /dev/null +++ b/libutil/op_lockfile.c @@ -0,0 +1,69 @@ +/** + * @file op_lockfile.c + * PID-based lockfile management + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "op_lockfile.h" +#include "op_file.h" + +#include + +#include +#include +#include +#include + +static pid_t op_read_lock_file(char const * file) +{ + FILE * fp; + pid_t value; + + fp = fopen(file, "r"); + if (fp == NULL) + return 0; + + if (fscanf(fp, "%d", &value) != 1) { + fclose(fp); + return 0; + } + + fclose(fp); + + return value; +} + + +int op_write_lock_file(char const * file) +{ + FILE * fp; + + if (op_file_readable(file)) { + pid_t pid = op_read_lock_file(file); + + /* FIXME: ESRCH vs. EPERM */ + if (kill(pid, 0)) { + int err = unlink(file); + fprintf(stderr, "Removing stale lock file %s\n", + file); + if (err) + return err; + } else { + return EEXIST; + } + } + + fp = fopen(file, "w"); + if (!fp) + return errno; + + fprintf(fp, "%d", getpid()); + fclose(fp); + + return 0; +} diff --git a/libutil/op_lockfile.h b/libutil/op_lockfile.h new file mode 100644 index 0000000..fcc269c --- /dev/null +++ b/libutil/op_lockfile.h @@ -0,0 +1,34 @@ +/** + * @file op_lockfile.h + * PID-based lockfile management + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_LOCKFILE_H +#define OP_LOCKFILE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + * op_write_lock_file - write a lock file + * \return errno on failure, or 0 on success + * + * Write the pid into the given lock file. Stale + * lock files are detected and reset. + */ +int op_write_lock_file(char const * file); + +#ifdef __cplusplus +} +#endif + +#endif /* OP_LOCKFILE_H */ diff --git a/libutil/op_popt.c b/libutil/op_popt.c new file mode 100644 index 0000000..de96364 --- /dev/null +++ b/libutil/op_popt.c @@ -0,0 +1,43 @@ +/** + * @file op_popt.c + * Wrapper for libpopt - always use this rather + * than popt.h + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include "op_libiberty.h" +#include "op_popt.h" + +poptContext op_poptGetContext(char const * name, + int argc, char const ** argv, + struct poptOption const * options, int flags) +{ + poptContext optcon; + int c; + + xmalloc_set_program_name(argv[0]); + +#ifdef CONST_POPT + optcon = poptGetContext(name, argc, argv, options, flags); +#else + optcon = poptGetContext((char *)name, argc, (char **)argv, options, flags); +#endif + + c = poptGetNextOpt(optcon); + + if (c < -1) { + fprintf(stderr, "%s: %s: %s\n", argv[0], + poptBadOption(optcon, POPT_BADOPTION_NOALIAS), + poptStrerror(c)); + poptPrintHelp(optcon, stderr, 0); + exit(EXIT_FAILURE); + } + + return optcon; +} diff --git a/libutil/op_popt.h b/libutil/op_popt.h new file mode 100644 index 0000000..c3dfa6c --- /dev/null +++ b/libutil/op_popt.h @@ -0,0 +1,42 @@ +/** + * @file op_popt.h + * Wrapper for libpopt - always use this rather + * than popt.h + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_POPT_H +#define OP_POPT_H + +#include + +// not in some versions of popt.h +#ifndef POPT_TABLEEND +#define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL } +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * op_poptGetContext - wrapper for popt + * + * Use this instead of poptGetContext to cope with + * different popt versions. This also handle unrecognized + * options. All error are fatal. + */ +poptContext op_poptGetContext(char const * name, + int argc, char const ** argv, + struct poptOption const * options, int flags); + +#ifdef __cplusplus +} +#endif + +#endif /* OP_POPT_H */ diff --git a/libutil/op_string.c b/libutil/op_string.c new file mode 100644 index 0000000..d440299 --- /dev/null +++ b/libutil/op_string.c @@ -0,0 +1,62 @@ +/** + * @file op_string.c + * general purpose C string handling implementation. + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include "op_libiberty.h" + + +char * op_xstrndup(char const * s, size_t len) +{ + return xmemdup(s, len, len + 1); +} + + +size_t op_hash_string(char const * str) +{ + size_t hash = 0; + for (; *str; ++str) + hash ^= (hash << 16) ^ (hash >> 8) ^ *str; + return hash; +} + + +int strisprefix(char const * str, char const * prefix) +{ + return strstr(str, prefix) == str; +} + + +char const * skip_ws(char const * c) +{ + while (*c == ' ' || *c == '\t' || *c == '\n') + ++c; + return c; +} + + +char const * skip_nonws(char const * c) +{ + while (*c && *c != ' ' && *c != '\t' && *c != '\n') + ++c; + return c; +} + + +int empty_line(char const * c) +{ + return !*skip_ws(c); +} + + +int comment_line(char const * c) +{ + return *skip_ws(c) == '#'; +} diff --git a/libutil/op_string.h b/libutil/op_string.h new file mode 100644 index 0000000..993fa6f --- /dev/null +++ b/libutil/op_string.h @@ -0,0 +1,81 @@ +/** + * @file op_string.h + * general purpose C string handling declarations. + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_STRING_H +#define OP_STRING_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @param s: input string + * @param len: len char to copy + * + * Allocate and copy len character from s to a newly allocated buffer then + * append a '\0' terminator. Return the newly allocated string + */ +char * op_xstrndup(char const * s, size_t len); + +/** + * @param s: string to hash + * + * Generate a hash code from a string + */ +size_t op_hash_string(char const * s); + +/** + * @param str: string to test + * @param prefix: prefix string + * + * return non zero if prefix parameters is a prefix of str + */ +int strisprefix(char const * str, char const * prefix); + +/** + * @param c: input string + * + * return a pointer to the first location in c which is not a blank space + * where blank space are in " \t\n" + */ +char const * skip_ws(char const * c); + +/** + * @param c: input string + * + * return a pointer to the first location in c which is a blank space + * where blank space are in " \t\n" + */ +char const * skip_nonws(char const * c); + +/** + * @param c: input string + * + * return non zero if c string contains only blank space + * where blank space are in " \t\n" + */ +int empty_line(char const * c); + +/** + * @param c: input string + * + * return non zero if c string is a comment. Comment are lines with optional + * blank space at left then a '#' character. Blank space are in " \t\n" + */ +int comment_line(char const * c); + +#ifdef __cplusplus +} +#endif + +#endif /* !OP_STRING_H */ diff --git a/libutil/op_types.h b/libutil/op_types.h new file mode 100644 index 0000000..612af20 --- /dev/null +++ b/libutil/op_types.h @@ -0,0 +1,34 @@ +/** + * @file op_types.h + * General-utility types + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_TYPES_H +#define OP_TYPES_H + +#ifndef __KERNEL__ + +#include + +/*@{\name miscellaneous types */ +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +typedef int fd_t; +/*@}*/ + +/** generic type for holding addresses */ +typedef unsigned long long vma_t; + +#else +#include +#endif + +#endif /* OP_TYPES_H */ diff --git a/libutil/op_version.c b/libutil/op_version.c new file mode 100644 index 0000000..99a844e --- /dev/null +++ b/libutil/op_version.c @@ -0,0 +1,24 @@ +/** + * @file op_version.c + * output version string + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include + +#include "op_version.h" +#include "config.h" + +void show_version(char const * app_name) +{ + /* Do not change the version format: it is documented in html doc */ + printf("%s: " PACKAGE " " VERSION " compiled on " + __DATE__ " " __TIME__ "\n", app_name); + exit(EXIT_SUCCESS); +} diff --git a/libutil/op_version.h b/libutil/op_version.h new file mode 100644 index 0000000..43a8365 --- /dev/null +++ b/libutil/op_version.h @@ -0,0 +1,26 @@ +/** + * @file op_version.h + * output version string + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_VERSION_H +#define OP_VERSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** output the version string */ +void show_version(char const * app_name); + +#ifdef __cplusplus +} +#endif + +#endif /* !OP_VERSION_H */ diff --git a/libutil/tests/Makefile.am b/libutil/tests/Makefile.am new file mode 100644 index 0000000..6fa360e --- /dev/null +++ b/libutil/tests/Makefile.am @@ -0,0 +1,15 @@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil + +AM_CFLAGS = @OP_CFLAGS@ + +LIBS = @LIBERTY_LIBS@ + +check_PROGRAMS = file_tests string_tests + +file_tests_SOURCES = file_tests.c +file_tests_LDADD = ../libutil.a +string_tests_SOURCES = string_tests.c +string_tests_LDADD = ../libutil.a + +TESTS = ${check_PROGRAMS} diff --git a/libutil/tests/Makefile.in b/libutil/tests/Makefile.in new file mode 100644 index 0000000..0a6b073 --- /dev/null +++ b/libutil/tests/Makefile.in @@ -0,0 +1,516 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +SOURCES = $(file_tests_SOURCES) $(string_tests_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +check_PROGRAMS = file_tests$(EXEEXT) string_tests$(EXEEXT) +subdir = libutil/tests +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am_file_tests_OBJECTS = file_tests.$(OBJEXT) +file_tests_OBJECTS = $(am_file_tests_OBJECTS) +file_tests_DEPENDENCIES = ../libutil.a +am_string_tests_OBJECTS = string_tests.$(OBJEXT) +string_tests_OBJECTS = $(am_string_tests_OBJECTS) +string_tests_DEPENDENCIES = ../libutil.a +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(file_tests_SOURCES) $(string_tests_SOURCES) +DIST_SOURCES = $(file_tests_SOURCES) $(string_tests_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBERTY_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libutil + +AM_CFLAGS = @OP_CFLAGS@ +file_tests_SOURCES = file_tests.c +file_tests_LDADD = ../libutil.a +string_tests_SOURCES = string_tests.c +string_tests_LDADD = ../libutil.a +TESTS = ${check_PROGRAMS} +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libutil/tests/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign libutil/tests/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +file_tests$(EXEEXT): $(file_tests_OBJECTS) $(file_tests_DEPENDENCIES) + @rm -f file_tests$(EXEEXT) + $(LINK) $(file_tests_LDFLAGS) $(file_tests_OBJECTS) $(file_tests_LDADD) $(LIBS) +string_tests$(EXEEXT): $(string_tests_OBJECTS) $(string_tests_DEPENDENCIES) + @rm -f string_tests$(EXEEXT) + $(LINK) $(string_tests_LDFLAGS) $(string_tests_OBJECTS) $(string_tests_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string_tests.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + echo "SKIP: $$tst"; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + skipped="($$skip tests were not run)"; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + test -z "$$skipped" || echo "$$skipped"; \ + test -z "$$report" || echo "$$report"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic ctags distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libutil/tests/file_tests.c b/libutil/tests/file_tests.c new file mode 100644 index 0000000..52ff5db --- /dev/null +++ b/libutil/tests/file_tests.c @@ -0,0 +1,66 @@ +/** + * @file file_tests.c + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "op_file.h" + +#include +#include +#include +#include +#include + +static char * tests[][2] = { + { "/usr/bin/../bin", "/usr/bin" }, + { "/../usr/bin/", "/usr/bin" }, + { "/../../usr/bin/", "/usr/bin" }, + { "/../../usr/bin/.", "/usr/bin" }, + { "/../../usr/bin/./", "/usr/bin" }, + { "/usr/./bin", "/usr/bin" }, + { "/usr/././bin", "/usr/bin" }, + { "/usr///", "/usr" }, + { "../", "/" }, + { "./", "/usr" }, + { ".", "/usr" }, + { "./../", "/" }, + { "bin/../bin/../", "/usr" }, + { "../../../../../", "/" }, + { "/usr/bin/../../..", "/" }, + { "/usr/bin/../../../", "/" }, + { "././.", "/usr" }, + /* POSIX namespace ignored by realpath(3) */ + { "//", "/" }, + { "//usr", "/usr" }, + { "///", "/" }, + { NULL, NULL }, +}; + +int main(void) +{ + char tmp[PATH_MAX]; + size_t i = 0; + + chdir("/usr"); + + while (tests[i][0]) { + if (!realpath(tests[i][0], tmp)) { + fprintf(stderr, "NULL return for %s\n", tests[i][0]); + exit(EXIT_FAILURE); + } + + if (strcmp(tmp, tests[i][1])) { + fprintf(stderr, "%s does not match %s given %s\n", + tmp, tests[i][1], tests[i][0]); + exit(EXIT_FAILURE); + } + ++i; + } + + return EXIT_SUCCESS; +} diff --git a/libutil/tests/string_tests.c b/libutil/tests/string_tests.c new file mode 100644 index 0000000..b2132cf --- /dev/null +++ b/libutil/tests/string_tests.c @@ -0,0 +1,91 @@ +/** + * @file string_tests.c + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "op_string.h" + +#include +#include +#include + +void error(char const * str) +{ + fprintf(stderr, "%s\n", str); + exit(EXIT_FAILURE); +} + + +int main() +{ + if (!strisprefix("", "")) + error("\"\" is not a prefix of \"\""); + if (!strisprefix("a", "")) + error("\"\" is not a prefix of a"); + if (!strisprefix("a", "a")) + error("a is not a prefix of a"); + if (!strisprefix("aa", "a")) + error("a is not a prefix of aa"); + if (strisprefix("a", "b")) + error("b is a prefix of a"); + + if (strcmp(skip_ws(""), "")) + error("skip_ws of \"\" is not \"\""); + if (strcmp(skip_ws("\na"), "a")) + error("skip_ws of \\na is not a"); + if (strcmp(skip_ws("\n\na"), "a")) + error("skip_ws of \\n\\na is not a"); + if (strcmp(skip_ws("\n a"), "a")) + error("skip_ws of \\n a is not a"); + if (strcmp(skip_ws("\n \ta"), "a")) + error("skip_ws of \\n \\ta is not a"); + if (strcmp(skip_ws("\n \t"), "")) + error("skip_ws of \\n \\t is not \"\""); + if (strcmp(skip_ws(" "), "")) + error("skip_ws of \" \" is not \"\""); + + if (strcmp(skip_nonws(""), "")) + error("skip_nonws of \"\" is not \"\""); + if (strcmp(skip_nonws("a"), "")) + error("skip_nonws of a is not \"\""); + if (strcmp(skip_nonws("\n"), "\n")) + error("skip_nonws of \\n is not \\n"); + if (strcmp(skip_nonws(" "), " ")) + error("skip_nonws of \" \" is not \" \""); + if (strcmp(skip_nonws("\t"), "\t")) + error("skip_nonws of \\t is not \\t"); + if (strcmp(skip_nonws("a\n"), "\n")) + error("skip_nonws of a\\n is not \\n"); + if (strcmp(skip_nonws("ab"), "")) + error("skip_nonws of ab is not \"\""); + + if (!empty_line("")) + error("empty_line is false for \"\""); + if (!empty_line("\n\t ")) + error("empty_line is false for \"\\n\\n \""); + if (!empty_line(" ")) + error("empty_line is false for \" \""); + if (empty_line("\r")) + error("empty_line is true for \\r"); + + if (comment_line("")) + error("comment_line is true for \"\""); + if (comment_line("\n")) + error("comment_line is true for \n"); + if (!comment_line("#")) + error("comment_line is false for #"); + if (!comment_line(" #")) + error("comment_line is false for \" #\""); + /* this is what the spec says */ + if (!comment_line("\n#")) + error("comment_line is false for \\n#"); + if (!comment_line("\t#")) + error("comment_line is false for \\t#"); + + return EXIT_SUCCESS; +} diff --git a/m4/Makefile.am b/m4/Makefile.am new file mode 100644 index 0000000..9ec59bf --- /dev/null +++ b/m4/Makefile.am @@ -0,0 +1,21 @@ + +# You will need to run autogen.sh after adding something here manually + +EXTRA_DIST = \ + binutils.m4 \ + builtinexpect.m4 \ + compileroption.m4 \ + configmodule.m4 \ + copyifchange.m4 \ + docbook.m4 \ + extradirs.m4 \ + findkernel.m4 \ + kerneloption.m4 \ + kernelversion.m4 \ + mallocattribute.m4 \ + poptconst.m4 \ + precompiledheader.m4 \ + qt.m4 \ + resultyn.m4 \ + sstream.m4 \ + typedef.m4 diff --git a/m4/Makefile.in b/m4/Makefile.in new file mode 100644 index 0000000..15ea3a9 --- /dev/null +++ b/m4/Makefile.in @@ -0,0 +1,355 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# You will need to run autogen.sh after adding something here manually +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +subdir = m4 +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +EXTRA_DIST = \ + binutils.m4 \ + builtinexpect.m4 \ + compileroption.m4 \ + configmodule.m4 \ + copyifchange.m4 \ + docbook.m4 \ + extradirs.m4 \ + findkernel.m4 \ + kerneloption.m4 \ + kernelversion.m4 \ + mallocattribute.m4 \ + poptconst.m4 \ + precompiledheader.m4 \ + qt.m4 \ + resultyn.m4 \ + sstream.m4 \ + typedef.m4 + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign m4/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign m4/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/m4/binutils.m4 b/m4/binutils.m4 new file mode 100644 index 0000000..8ea8667 --- /dev/null +++ b/m4/binutils.m4 @@ -0,0 +1,40 @@ +dnl AX_BINUTILS - check for needed binutils stuff +AC_DEFUN([AX_BINUTILS], +[ +dnl some distro have a libiberty.a but does not have a libiberty.h +AC_CHECK_HEADERS(libiberty.h) +AC_CHECK_LIB(iberty, cplus_demangle,, AC_MSG_ERROR([liberty library not found])) +AC_CHECK_FUNCS(xcalloc) +AC_CHECK_FUNCS(xmemdup) +AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl"; DL_LIB="-ldl", DL_LIB="") +AC_CHECK_LIB(intl, main, LIBS="$LIBS -lintl"; INTL_LIB="-lintl", INTL_LIB="") +AC_CHECK_LIB(bfd, bfd_openr,, AC_MSG_ERROR([bfd library not found])) + +# Determine if bfd_get_synthetic_symtab macro is available +OS="`uname`" +if test "$OS" = "Linux"; then + AC_MSG_CHECKING([whether bfd_get_synthetic_symtab() exists in BFD library]) + rm -f test-for-synth + AC_LANG_CONFTEST( + [AC_LANG_PROGRAM([[#include ]], + [[asymbol * synthsyms; bfd * ibfd = 0; + long synth_count = bfd_get_synthetic_symtab(ibfd, 0, 0, 0, 0, &synthsyms); + extern const bfd_target bfd_elf64_powerpc_vec; + extern const bfd_target bfd_elf64_powerpcle_vec; + char * ppc_name = bfd_elf64_powerpc_vec.name; + char * ppcle_name = bfd_elf64_powerpcle_vec.name;]]) + ]) + $CC conftest.$ac_ext $LIBS -o test-for-synth > /dev/null 2>&1 + if test -f test-for-synth; then + echo "yes" + SYNTHESIZE_SYMBOLS='1' + else + echo "no" + SYNTHESIZE_SYMBOLS='0' + fi + AC_DEFINE_UNQUOTED(SYNTHESIZE_SYMBOLS, $SYNTHESIZE_SYMBOLS, [Synthesize special symbols when needed]) + rm -f test-for-synth* + +fi +] +) diff --git a/m4/builtinexpect.m4 b/m4/builtinexpect.m4 new file mode 100644 index 0000000..ba77640 --- /dev/null +++ b/m4/builtinexpect.m4 @@ -0,0 +1,15 @@ +dnl builtin_expect is used in module we can't add that in config.h +AC_DEFUN([AX_BUILTIN_EXPECT], +[ +AC_MSG_CHECKING([whether __builtin_expect is understood]) +SAVE_CFLAGS=$CFLAGS +CFLAGS="-Werror $CFLAGS" +AC_TRY_LINK(,[ +int i; +if (__builtin_expect(i, 0)) { } +], +AC_MSG_RESULT([yes]); EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DEXPECT_OK", +AC_MSG_RESULT([no]);) +CFLAGS=$SAVE_CFLAGS +] +) diff --git a/m4/compileroption.m4 b/m4/compileroption.m4 new file mode 100644 index 0000000..2fec066 --- /dev/null +++ b/m4/compileroption.m4 @@ -0,0 +1,26 @@ +dnl AX_CFLAGS_OPTIONS(var-name, option) +dnl add option to var-name if $CC support it. +AC_DEFUN([AX_CFLAGS_OPTION], [ +AC_MSG_CHECKING([whether ${CC} $2 is understood]) +AC_LANG_SAVE +AC_LANG_C +SAVE_CFLAGS=$CFLAGS +CFLAGS=$2 +AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no])) +CFLAGS=$SAVE_CFLAGS +AC_LANG_RESTORE +]) + + +dnl AX_CXXFLAGS_OPTIONS(var-name, option) +dnl add option to var-name if $CXX support it. +AC_DEFUN([AX_CXXFLAGS_OPTION], [ +AC_MSG_CHECKING([whether ${CXX} $2 is understood]) +AC_LANG_SAVE +AC_LANG_CPLUSPLUS +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS=$2 +AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} $2",AC_MSG_RESULT([no])) +CXXFLAGS=$SAVE_CXXFLAGS +AC_LANG_RESTORE +]) diff --git a/m4/configmodule.m4 b/m4/configmodule.m4 new file mode 100644 index 0000000..79fe34d --- /dev/null +++ b/m4/configmodule.m4 @@ -0,0 +1,80 @@ +dnl Handle the 2.4 module inside module/ +AC_DEFUN([AX_CONFIG_MODULE], +[ +if test ! -f $KINC/linux/autoconf.h; then + AC_MSG_ERROR([no suitably configured kernel include tree found]) +fi + +dnl --- Get Linux kernel version and compile parameters --- + +AC_SUBST(KVERS) +AC_MSG_CHECKING([for kernel version]) +dnl it's like this to handle mandrake's fubar version.h - bug #471448 +eval KVERS=`gcc -I$KINC -E -dM $KINC/linux/version.h | grep -w UTS_RELEASE | awk '{print $[]3}'` +AC_MSG_RESULT([$KVERS]) +case "$KVERS" in +2.2.*|2.4.*) ;; +*) AC_MSG_ERROR([Unsupported kernel version]) +esac + +dnl Check for the minimal kernel version supported +AC_MSG_CHECKING([kernel version]) +AX_KERNEL_VERSION(2, 2, 10, <=, AC_MSG_RESULT([ok]), AC_MSG_ERROR([check html documentation install section])) + +dnl linux/spinlock.h added at some point in past +AC_MSG_CHECKING([for $KINC/linux/spinlock.h]) +if test -f $KINC/linux/spinlock.h; then + EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DHAVE_LINUX_SPINLOCK_HEADER" + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +AC_MSG_CHECKING([for rtc_lock]) +gcc -I$KINC -E $KINC/linux/mc146818rtc.h | grep rtc_lock >/dev/null +if test "$?" -eq 0; then + EXTRA_CFLAGS_MODULE="$EXTRA_CFLAGS_MODULE -DRTC_LOCK" + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +arch="unknown" +AC_MSG_CHECKING(for x86 architecture) +AX_KERNEL_OPTION(CONFIG_X86, x86=1, x86=0) +AX_KERNEL_OPTION(CONFIG_X86_WP_WORKS_OK, x86=1, x86=$x86) +AX_MSG_RESULT_YN($x86) +test "$x86" = 1 && arch="x86" + +if test "$arch" = "unknown"; then + AC_MSG_CHECKING(for ia64 architecture) + AX_KERNEL_OPTION(CONFIG_IA64, ia64=1, ia64=0) + AX_MSG_RESULT_YN($ia64) + test "$ia64" = 1 && arch="ia64" +fi + +test "$arch" = "unknown" && AC_MSG_ERROR(Unsupported architecture) + +dnl check to see if kernel verion appropriate for arch +AC_MSG_CHECKING(arch/kernel version combination) +case "$arch" in +ia64) + AX_KERNEL_VERSION(2, 4, 18, <, AC_MSG_RESULT([ok]), + AC_MSG_ERROR([unsupported arch/kernel])) ;; +*) AC_MSG_RESULT([ok]) +esac + +dnl for now we do not support PREEMPT patch +AC_MSG_CHECKING([for preempt patch]) +AX_KERNEL_OPTION(CONFIG_PREEMPT,preempt=1,preempt=0) +AX_MSG_RESULT_YN([$preempt]) +test "$preempt" = 0 || AC_MSG_ERROR([unsupported kernel configuration : CONFIG_PREEMPT]) + +AC_SUBST(KINC) + +MODINSTALLDIR=/lib/modules/$KVERS + +OPROFILE_MODULE_ARCH=$arch +AC_SUBST(OPROFILE_MODULE_ARCH) +] +) diff --git a/m4/copyifchange.m4 b/m4/copyifchange.m4 new file mode 100644 index 0000000..0464de0 --- /dev/null +++ b/m4/copyifchange.m4 @@ -0,0 +1,13 @@ +dnl AX_COPY_IF_CHANGE(source, dest) +dnl copy source to dest if they don't compare equally or if dest doesn't exist +AC_DEFUN([AX_COPY_IF_CHANGE], [ +if test -r $2; then + if cmp $1 $2 > /dev/null; then + echo $2 is unchanged + else + cp -f $1 $2 + fi +else + cp -f $1 $2 +fi +]) diff --git a/m4/docbook.m4 b/m4/docbook.m4 new file mode 100644 index 0000000..513b0bd --- /dev/null +++ b/m4/docbook.m4 @@ -0,0 +1,53 @@ +dnl AX_CHECK_DOCBOOK +AC_DEFUN([AX_CHECK_DOCBOOK], [ +# It's just rude to go over the net to build +XSLTPROC_FLAGS=--nonet +DOCBOOK_ROOT= +if test ! -f /etc/xml/catalog; then + for i in /usr/share/sgml/docbook/stylesheet/xsl/nwalsh /usr/share/sgml/docbook/xsl-stylesheets/; + do + if test -d "$i"; then + DOCBOOK_ROOT=$i + fi + done + + # Last resort - try net + if test -z "$DOCBOOK_ROOT"; then + XSLTPROC_FLAGS= + fi +else + XML_CATALOG=/etc/xml/catalog + CAT_ENTRY_START='' +fi + +AC_CHECK_PROG(XSLTPROC,xsltproc,xsltproc,) +XSLTPROC_WORKS=no +if test -n "$XSLTPROC"; then + AC_MSG_CHECKING([whether xsltproc works]) + + if test -n "$XML_CATALOG"; then + DB_FILE="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl" + else + DB_FILE="$DOCBOOK_ROOT/docbook.xsl" + fi + + $XSLTPROC $XSLTPROC_FLAGS $DB_FILE >/dev/null 2>&1 << END + + + + +END + if test "$?" = 0; then + XSLTPROC_WORKS=yes + fi + AC_MSG_RESULT($XSLTPROC_WORKS) +fi +AM_CONDITIONAL(have_xsltproc, test "$XSLTPROC_WORKS" = "yes") + +AC_SUBST(XML_CATALOG) +AC_SUBST(XSLTPROC_FLAGS) +AC_SUBST(DOCBOOK_ROOT) +AC_SUBST(CAT_ENTRY_START) +AC_SUBST(CAT_ENTRY_END) +]) diff --git a/m4/extradirs.m4 b/m4/extradirs.m4 new file mode 100644 index 0000000..a12b03d --- /dev/null +++ b/m4/extradirs.m4 @@ -0,0 +1,36 @@ +dnl AX_EXTRA_DIRS - Let user specify extra dirs for include/libs +AC_DEFUN([AX_EXTRA_DIRS], +[ +AC_ARG_WITH(extra-includes, +[ --with-extra-includes=DIR add extra include paths], + use_extra_includes="$withval", + use_extra_includes=NO +) +if test -n "$use_extra_includes" && \ + test "$use_extra_includes" != "NO"; then + ac_save_ifs=$IFS + IFS=':' + for dir in $use_extra_includes; do + extra_includes="$extra_includes -I$dir" + done + IFS=$ac_save_ifs + CPPFLAGS="$CPPFLAGS $extra_includes" +fi + +AC_ARG_WITH(extra-libs, +[ --with-extra-libs=DIR add extra library paths], + use_extra_libs=$withval, + use_extra_libs=NO +) +if test -n "$use_extra_libs" && \ + test "$use_extra_libs" != "NO"; then + ac_save_ifs=$IFS + IFS=':' + for dir in $use_extra_libs; do + extra_libraries="$extra_libraries -L$dir" + done + IFS=$ac_save_ifs + LDFLAGS="$LDFLAGS $extra_libraries" +fi +] +) diff --git a/m4/findkernel.m4 b/m4/findkernel.m4 new file mode 100644 index 0000000..4f66437 --- /dev/null +++ b/m4/findkernel.m4 @@ -0,0 +1,27 @@ +dnl Find the kernel and handle 2.6 settings +AC_DEFUN([AX_FIND_KERNEL], +[ +AC_MSG_CHECKING([for kernel OProfile support]) +AC_ARG_WITH(kernel-support, [ --with-kernel-support Use 2.6 kernel (no kernel source tree required)], +if test "$withval" = "yes"; then + OPROFILE_26=yes +fi +) + +if test "$OPROFILE_26" != "yes"; then + dnl --- Find the Linux kernel, at least the headers --- + + AC_SUBST(KSRC) + KSRC=/lib/modules/`uname -r`/build + AC_ARG_WITH(linux, [ --with-linux=dir Path to Linux source tree], KSRC=$withval) + KINC=$KSRC/include + AC_SUBST(KINC) + + AX_KERNEL_OPTION(CONFIG_OPROFILE, OPROFILE_26=yes, OPROFILE_26=no) + AX_KERNEL_OPTION(CONFIG_OPROFILE_MODULE, OPROFILE_26=yes, OPROFILE_26=$OPROFILE_26) +fi +AC_MSG_RESULT($OPROFILE_26) + +AM_CONDITIONAL(kernel_support, test "$OPROFILE_26" = yes) +] +) diff --git a/m4/kerneloption.m4 b/m4/kerneloption.m4 new file mode 100644 index 0000000..9e5c802 --- /dev/null +++ b/m4/kerneloption.m4 @@ -0,0 +1,13 @@ +dnl AX_KERNEL_OPTION(option, action-if-found, action-if-not-found) +dnl see if autoconf.h defines the option +AC_DEFUN([AX_KERNEL_OPTION], [ +SAVE_CFLAGS=$CFLAGS +CFLAGS="-I$KINC -O2 -D__KERNEL__" +AC_TRY_COMPILE( [#include ], +[ +#ifndef $1 +break_me_hard(\\\); +#endif +],[$2],[$3],) +CFLAGS=$SAVE_CFLAGS +]) diff --git a/m4/kernelversion.m4 b/m4/kernelversion.m4 new file mode 100644 index 0000000..aebe40b --- /dev/null +++ b/m4/kernelversion.m4 @@ -0,0 +1,17 @@ +dnl AX_KERNEL_VERSION(major, minor, level, comparison, action-if-true, action-if-false) +AC_DEFUN([AX_KERNEL_VERSION], [ +SAVE_CFLAGS=$CFLAGS +CFLAGS="-I$KINC -D__KERNEL__ -Werror" +AC_TRY_COMPILE( + [ + #include + #include + ], + [ + #if LINUX_VERSION_CODE $4 KERNEL_VERSION($1, $2, $3) + break_me_hard(\\\); + #endif + ], +[$5],[$6],) +CFLAGS=$SAVE_CFLAGS +]) diff --git a/m4/mallocattribute.m4 b/m4/mallocattribute.m4 new file mode 100644 index 0000000..0bfe3a8 --- /dev/null +++ b/m4/mallocattribute.m4 @@ -0,0 +1,12 @@ +dnl AX_MALLOC_ATTRIBUTE - see if gcc will take __attribute__((malloc)) +AC_DEFUN([AX_MALLOC_ATTRIBUTE], +[ +AC_MSG_CHECKING([whether malloc attribute is understood]) +SAVE_CFLAGS=$CFLAGS +CFLAGS="-Werror $CFLAGS" +AC_TRY_COMPILE(,[ +void monkey() __attribute__((malloc)); +],AC_MSG_RESULT([yes]); AC_DEFINE(MALLOC_ATTRIBUTE_OK, 1, [whether malloc attribute is understood]), AC_MSG_RESULT([no])) +CFLAGS=$SAVE_CFLAGS +] +) diff --git a/m4/poptconst.m4 b/m4/poptconst.m4 new file mode 100644 index 0000000..2888e78 --- /dev/null +++ b/m4/poptconst.m4 @@ -0,0 +1,16 @@ +dnl AX_POPT_CONST - check popt prototype +AC_DEFUN([AX_POPT_CONST], +[ +AC_MSG_CHECKING([popt prototype]) +SAVE_CXXFLAGS=$CXXFLAGS +CXXFLAGS="-Werror $CXXFLAGS" +AC_TRY_COMPILE([#include ], +[ +int c; char **v; +poptGetContext(0, c, v, 0, 0); +], +AC_MSG_RESULT([takes char **]);, +AC_MSG_RESULT([takes const char **]); AC_DEFINE(CONST_POPT, 1, [whether popt prototype takes a const char **])) +CXXFLAGS="$SAVE_CXXFLAGS" +] +) diff --git a/m4/precompiledheader.m4 b/m4/precompiledheader.m4 new file mode 100644 index 0000000..d19aacf --- /dev/null +++ b/m4/precompiledheader.m4 @@ -0,0 +1,15 @@ +dnl AX_CXXFLAGS_OPTIONS(var-name, option) +dnl add option to var-name if $CXX support it. +AC_DEFUN([AX_CHECK_PRECOMPILED_HEADER], [ +AC_MSG_CHECKING([whether ${CXX} support precompiled header]) +AC_LANG_SAVE +AC_LANG_CPLUSPLUS +SAVE_CXXFLAGS=$CXXFLAGS +dnl we consider than if -Winvalid-pch is accepted pch will works ... +CXXFLAGS=-Winvalid-pch +dnl but we don't want -Winvalid-pch else compilation will fail due -Werror and +dnl the fact than some pch will be invalid for the given compilation option +AC_TRY_COMPILE(,[;],AC_MSG_RESULT([yes]); $1="${$1} -include bits/stdc++.h", AC_MSG_RESULT([no])) +CXXFLAGS=$SAVE_CXXFLAGS +AC_LANG_RESTORE +]) diff --git a/m4/qt.m4 b/m4/qt.m4 new file mode 100644 index 0000000..b0e30ef --- /dev/null +++ b/m4/qt.m4 @@ -0,0 +1,217 @@ +dnl find a binary in the path +AC_DEFUN([QT_FIND_PATH], +[ + AC_MSG_CHECKING([for $1]) + AC_CACHE_VAL(qt_cv_path_$1, + [ + qt_cv_path_$1="NONE" + if test -n "$$2"; then + qt_cv_path_$1="$$2"; + else + dirs="$3" + qt_save_IFS=$IFS + IFS=':' + for dir in $PATH; do + dirs="$dirs $dir" + done + IFS=$qt_save_IFS + + for dir in $dirs; do + if test -x "$dir/$1"; then + if test -n "$5"; then + evalstr="$dir/$1 $5 2>&1 " + if eval $evalstr; then + qt_cv_path_$1="$dir/$1" + break + fi + else + qt_cv_path_$1="$dir/$1" + break + fi + fi + done + fi + ]) + + if test -z "$qt_cv_path_$1" || test "$qt_cv_path_$1" = "NONE"; then + AC_MSG_RESULT(not found) + $4 + else + AC_MSG_RESULT($qt_cv_path_$1) + $2=$qt_cv_path_$1 + fi +]) + +dnl Find the uic compiler on the path or in qt_cv_dir +AC_DEFUN([QT_FIND_UIC], +[ + QT_FIND_PATH(uic, ac_uic, $qt_cv_dir/bin) + if test -z "$ac_uic" -a "$FATAL" = 1; then + AC_MSG_ERROR([uic binary not found in \$PATH or $qt_cv_dir/bin !]) + fi +]) + +dnl Find the right moc in path/qt_cv_dir +AC_DEFUN([QT_FIND_MOC], +[ + QT_FIND_PATH(moc2, ac_moc2, $qt_cv_dir/bin) + QT_FIND_PATH(moc, ac_moc1, $qt_cv_dir/bin) + + if test -n "$ac_moc1" -a -n "$ac_moc2"; then + dnl found both. Prefer Qt3's if it exists else moc2 + $ac_moc1 -v 2>&1 | grep "Qt 3" >/dev/null + if test "$?" = 0; then + ac_moc=$ac_moc1; + else + ac_moc=$ac_moc2; + fi + else + if test -n "$ac_moc1"; then + ac_moc=$ac_moc1; + else + ac_moc=$ac_moc2; + fi + fi + + if test -z "$ac_moc" -a "$FATAL" = 1; then + AC_MSG_ERROR([moc binary not found in \$PATH or $qt_cv_dir/bin !]) + fi +]) + +dnl check a particular libname +AC_DEFUN([QT_TRY_LINK], +[ + SAVE_LIBS="$LIBS" + LIBS="$LIBS $1" + AC_TRY_LINK([ + #include + #include + ], + [ + QString s("mangle_failure"); + #if (QT_VERSION < 221) + break_me_(\\\); + #endif + ], + qt_cv_libname=$1, + ) + LIBS="$SAVE_LIBS" +]) + +dnl check we can do a compile +AC_DEFUN([QT_CHECK_COMPILE], +[ + AC_MSG_CHECKING([for Qt library name]) + + AC_CACHE_VAL(qt_cv_libname, + [ + AC_LANG_CPLUSPLUS + SAVE_CXXFLAGS=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS" + + for libname in -lqt-mt -lqt3 -lqt2 -lqt; + do + QT_TRY_LINK($libname) + if test -n "$qt_cv_libname"; then + break; + fi + done + + CXXFLAGS=$SAVE_CXXFLAGS + ]) + + if test -z "$qt_cv_libname"; then + AC_MSG_RESULT([failed]) + if test "$FATAL" = 1 ; then + AC_MSG_ERROR([Cannot compile a simple Qt executable. Check you have the right \$QTDIR !]) + fi + else + AC_MSG_RESULT([$qt_cv_libname]) + fi +]) + +dnl get Qt version we're using +AC_DEFUN([QT_GET_VERSION], +[ + AC_CACHE_CHECK([Qt version],lyx_cv_qtversion, + [ + AC_LANG_CPLUSPLUS + SAVE_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $QT_INCLUDES" + + cat > conftest.$ac_ext < +"%%%"QT_VERSION_STR"%%%" +EOF + lyx_cv_qtversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \ + grep '^"%%%"' 2>/dev/null | \ + sed -e 's/"%%%"//g' -e 's/"//g'` + rm -f conftest.$ac_ext + CPPFLAGS=$SAVE_CPPFLAGS + ]) + + QT_VERSION=$lyx_cv_qtversion + AC_SUBST(QT_VERSION) +]) + +dnl start here +AC_DEFUN([QT_DO_IT_ALL], +[ + dnl Please leave this alone. I use this file in + dnl oprofile. + FATAL=0 + + AC_ARG_WITH(qt-dir, [ --with-qt-dir where the root of Qt is installed ], + [ qt_cv_dir=`eval echo "$withval"/` ]) + + AC_ARG_WITH(qt-includes, [ --with-qt-includes where the Qt includes are. ], + [ qt_cv_includes=`eval echo "$withval"` ]) + + AC_ARG_WITH(qt-libraries, [ --with-qt-libraries where the Qt library is installed.], + [ qt_cv_libraries=`eval echo "$withval"` ]) + + dnl pay attention to $QTDIR unless overridden + if test -z "$qt_cv_dir"; then + qt_cv_dir=$QTDIR + fi + + dnl derive inc/lib if needed + if test -n "$qt_cv_dir"; then + if test -z "$qt_cv_includes"; then + qt_cv_includes=$qt_cv_dir/include + fi + if test -z "$qt_cv_libraries"; then + qt_cv_libraries=$qt_cv_dir/lib + fi + fi + + dnl flags for compilation + QT_INCLUDES= + QT_LDFLAGS= + if test -n "$qt_cv_includes"; then + QT_INCLUDES="-isystem $qt_cv_includes" + fi + if test -n "$qt_cv_libraries"; then + QT_LDFLAGS="-L$qt_cv_libraries" + fi + AC_SUBST(QT_INCLUDES) + AC_SUBST(QT_LDFLAGS) + + QT_FIND_MOC + MOC=$ac_moc + AC_SUBST(MOC) + QT_FIND_UIC + UIC=$ac_uic + AC_SUBST(UIC) + + QT_CHECK_COMPILE + + QT_LIB=$qt_cv_libname; + AC_SUBST(QT_LIB) + + if test -n "$qt_cv_libname"; then + QT_GET_VERSION + fi +]) diff --git a/m4/resultyn.m4 b/m4/resultyn.m4 new file mode 100644 index 0000000..2aac1cc --- /dev/null +++ b/m4/resultyn.m4 @@ -0,0 +1,6 @@ + +dnl AX_MSG_RESULT_YN(a) +dnl results "yes" iff a==1, "no" else +AC_DEFUN([AX_MSG_RESULT_YN], [x=no +test "x$1" = "x1" && x=yes +AC_MSG_RESULT($x)]) diff --git a/m4/sstream.m4 b/m4/sstream.m4 new file mode 100644 index 0000000..4337fb5 --- /dev/null +++ b/m4/sstream.m4 @@ -0,0 +1,9 @@ +dnl AX_CHECK_SSTREAM - check if local sstream is needed to compile OK +AC_DEFUN([AX_CHECK_SSTREAM], +[ +AC_MSG_CHECKING([whether to use included sstream]) +AC_TRY_COMPILE([#include ], [], +AC_MSG_RESULT([no]);, +AC_MSG_RESULT([yes]); OP_CXXFLAGS="$OP_CXXFLAGS -I\${top_srcdir}/include") +] +) diff --git a/m4/typedef.m4 b/m4/typedef.m4 new file mode 100644 index 0000000..b2807d4 --- /dev/null +++ b/m4/typedef.m4 @@ -0,0 +1,46 @@ +dnl AX_CHECK_TYPEDEF(typedef_name, type, action-if-true, action-if-false) +dnl exec action-if-true if typedef_name is a typedef to type else exec +dnl action-if-false +dnl currently work only with type typedef'ed in stddef.h +AC_DEFUN([AX_CHECK_TYPEDEF], [ +dnl AC_LANG_PUSH(C) not in autoconf 2.13 +AC_LANG_SAVE +AC_LANG_C +SAVE_CFLAGS=$CFLAGS +CFLAGS="-Werror $CFLAGS" + +AC_TRY_COMPILE( + [ + #include + ], + [ + typedef void (*fct1)($1); + typedef void (*fct2)($2); + fct1 f1 = 0; + fct2 f2 = 0; + if (f1 == f2) {} + ], +[$3],[$4]) + +CFLAGS=$SAVE_CFLAGS +AC_LANG_RESTORE +]) + + +dnl AX_TYPEDEFED_NAME(typedef_name, candidate_list, var_name) +dnl set var_name to the typedef name of $1 which must be in canditate_list +dnl else produce a fatal error +AC_DEFUN([AX_TYPEDEFED_NAME], [ + AC_MSG_CHECKING([type of $1]) + for f in $2; do + AX_CHECK_TYPEDEF($1, $f, $3="$f", $3="") + if test -n "${$3}"; then + break + fi + done + if test -n "${$3}"; then + AC_MSG_RESULT([${$3}]) + else + AC_MSG_ERROR([not found]) + fi +]) diff --git a/missing b/missing new file mode 100755 index 0000000..09edd88 --- /dev/null +++ b/missing @@ -0,0 +1,357 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2005-02-08.22 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). +case "$1" in + lex|yacc) + # Not GNU programs, they don't have --version. + ;; + + tar) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + touch $file + ;; + + tar) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/module/Makefile.in b/module/Makefile.in new file mode 100644 index 0000000..9630259 --- /dev/null +++ b/module/Makefile.in @@ -0,0 +1,22 @@ +OPROFILE_DIR=@OPROFILE_DIR@ +VERSION=@VERSION@ +KVERS=@KVERS@ +KSRC=@KSRC@ + +EXTRA_CFLAGS=@EXTRA_CFLAGS_MODULE@ -D__NO_VERSION__ \ + -I$(OPROFILE_DIR)/module/@OPROFILE_MODULE_ARCH@ -I$(OPROFILE_DIR) -I$(OPROFILE_DIR)/libutil -I$(OPROFILE_DIR)/libop + +# NB: do not add a file here without adding it to EXTRA_DIST in ../Makefile.am + +O_TARGET := oprofile-module.o + +obj-y := compat.o op_init.o op_util.o op_dname.o oprofile.o @OPROFILE_MODULE_ARCH@/arch.o $(OPROFILE_DIR)/libop/libop.a +obj-m := $(O_TARGET) +O_OBJS := $(obj-y) +M_OBJS := $(O_TARGET) + +TOPDIR := $(KSRC) +CONFIG_SHELL := TOPDIR=$(KSRC) /bin/bash +include $(KSRC)/Rules.make + +# FIXME: deps diff --git a/module/compat.c b/module/compat.c new file mode 100644 index 0000000..a8c17fb --- /dev/null +++ b/module/compat.c @@ -0,0 +1,63 @@ +/** + * @file compat.c + * This file is intended to be up-to-date with the last linux version and + * provide work-arounds for missing features in previous kernel version + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "op_dcache.h" +#include + +#ifdef NEED_2_2_DENTRIES + +/* note - assumes you only test for NULL, and not + * actually care about the return value */ +void * compat_request_region(unsigned long start, unsigned long n, char const * name) +{ + if (check_region(start, n) != 0) + return NULL; + request_region(start, n, name); + return (void *)1; +} + +int wind_dentries_2_2(struct dentry * dentry) +{ + struct dentry * root = current->fs->root; + + if (dentry->d_parent != dentry && list_empty(&dentry->d_hash)) + return 0; + + for (;;) { + struct dentry * parent; + + if (dentry == root) + break; + + dentry = dentry->d_covers; + parent = dentry->d_parent; + + if (dentry == parent) + break; + + push_dname(&dentry->d_name); + + dentry = parent; + } + + return 1; +} + +/* called with note_lock held */ +uint do_path_hash_2_2(struct dentry * dentry) +{ + /* BKL is already taken */ + + return do_hash(dentry, 0, 0, 0); +} + +#endif /* NEED_2_2_DENTRIES */ diff --git a/module/compat.h b/module/compat.h new file mode 100644 index 0000000..14e2722 --- /dev/null +++ b/module/compat.h @@ -0,0 +1,70 @@ +/** + * @file compat.h + * This file is intended to be up-to-date with the last linux version and + * provide work-arounds for missing features in previous kernel version + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + + +#ifndef COMPAT_H +#define COMPAT_H + +#include +#include +#ifdef HAVE_LINUX_SPINLOCK_HEADER +/* FIXME do we need this still ? */ +#include +#endif + +#define V_BEFORE(a,b,c) (LINUX_VERSION_CODE < KERNEL_VERSION(a,b,c)) +#define V_AT_LEAST(a,b,c) (LINUX_VERSION_CODE >= KERNEL_VERSION(a,b,c)) + +#if V_BEFORE(2,4,0) + #include "compat22.h" +#else + #include "compat24.h" +#endif + +#include "op_cache.h" + +/* Things that cannot rely on a particular linux version or are needed between + * major release */ + +#ifndef BUG_ON +#define BUG_ON(p) do { if (p) BUG(); } while (0) +#endif + +#ifndef MODULE_LICENSE +#define MODULE_LICENSE(x) +#endif + +/* Compiler work-around */ + +/* branch prediction */ +#ifndef likely + #ifdef EXPECT_OK + #define likely(a) __builtin_expect((a), 1) + #else + #define likely(a) (a) + #endif +#endif +#ifndef unlikely + #ifdef EXPECT_OK + #define unlikely(a) __builtin_expect((a), 0) + #else + #define unlikely(a) (a) + #endif +#endif + +#ifndef CONFIG_X86_64 +#define VMALLOC_32(sz) vmalloc_32(sz) +#else /* CONFIG_X86_64 */ +#define VMALLOC_32(sz) vmalloc(sz) +#endif /* CONFIG_X86_64 */ + +#endif /* COMPAT_H */ diff --git a/module/compat22.h b/module/compat22.h new file mode 100644 index 0000000..63c4f5f --- /dev/null +++ b/module/compat22.h @@ -0,0 +1,153 @@ +/** + * @file compat22.h + * Compatability functions for 2.2 kernels + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef COMPAT22_H +#define COMPAT22_H + +#include + +#define local_irq_disable() __cli() +#define local_irq_enable() __sti() +#define pte_page_address(a) pte_page(a) + +#define GET_VM_OFFSET(v) ((v)->vm_offset) +#define MODULE_LICENSE(l) +#define NEED_2_2_DENTRIES +#define INC_USE_COUNT_MAYBE MOD_INC_USE_COUNT +#define DEC_USE_COUNT_MAYBE MOD_DEC_USE_COUNT +#define lock_execve lock_kernel +#define unlock_execve unlock_kernel + +/* BKL-protected on 2.2 */ +#define lock_mmap(mm) do {} while (0) +#define unlock_mmap(mm) do {} while (0) + +/* on 2.2 we use pid as tgid, thread seperation is possible but + * each thread is in its own thread group */ +static inline pid_t op_get_tgid(void) +{ + return current->pid; +} + +/* the wake_up path doesn't disable interrupts for wait queue + * manipulation. So let's force it to. + */ +static inline void oprof_wake_up(struct wait_queue **q) +{ + unsigned long flags; + save_flags(flags); + cli(); + wake_up(q); + restore_flags(flags); +} + +extern int wind_dentries_2_2(struct dentry *dentry); +extern uint do_path_hash_2_2(struct dentry *dentry); +#define wind_dentries(d, v, r, m) wind_dentries_2_2(d) +#define hash_path(f) do_path_hash_2_2((f)->f_dentry) + +static inline void lock_out_mmap(void) +{ + lock_kernel(); + down(¤t->mm->mmap_sem); +} + +static inline void unlock_out_mmap(void) +{ + unlock_kernel(); + up(¤t->mm->mmap_sem); +} + +/* different request_region */ +#define request_region_check compat_request_region +void *compat_request_region (unsigned long start, unsigned long n, char const * name); + +#define __exit + +#define virt_to_page(va) MAP_NR(va) + +/* 2.2 has no cpu_number_map on UP */ +#ifdef CONFIG_SMP + #define op_cpu_id() cpu_number_map[smp_processor_id()] +#else + #define op_cpu_id() smp_processor_id() +#endif /* CONFIG_SMP */ + +/* provide a working smp_call_function */ +#if !defined(CONFIG_SMP) + + #undef smp_call_function + static int inline smp_call_function (void (*func) (void *info), void *info, + int retry, int wait) + { + return 0; + } + +#endif /* !CONFIG_SMP */ + +#if V_BEFORE(2,2,18) + + /* 2.2.18 introduced module_init */ + /* Not sure what version aliases were introduced in, but certainly in 2.91.66. */ + #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 91) + #define module_init(x) int init_module(void) __attribute__((alias(#x))); + #define module_exit(x) void cleanup_module(void) __attribute__((alias(#x))); + #else + #define module_init(x) int init_module(void) { return x(); } + #define module_exit(x) void cleanup_module(void) { x(); } + #endif + + /* 2.2.18 introduced vmalloc_32 */ + #define vmalloc_32 vmalloc + + /* 2.2.18 add doubled linked list wait_queue and mutex */ + #define DECLARE_WAIT_QUEUE_HEAD(q) struct wait_queue *q = NULL + #define DECLARE_MUTEX(foo) struct semaphore foo = MUTEX + + /* 2.2.18 add THIS_MODULE */ + #define THIS_MODULE (&__this_module) + + /* 2.2.18 add BUG() FIXME: this is arch dependant would must use + * *(char *)0 = 0 instead ? */ + #define BUG() __asm__ __volatile__("ud2\n"); + +#endif /* V_BEFORE(2,2,18) */ + +/* 2.2.18 introduced the rtc lock */ +#ifdef RTC_LOCK + #define lock_rtc(f) spin_lock_irqsave(&rtc_lock, f) + #define unlock_rtc(f) spin_unlock_irqrestore(&rtc_lock, f) +#else + #define lock_rtc(f) do { save_flags(f); cli(); } while (0) + #define unlock_rtc(f) restore_flags(f) +#endif /* RTC_LOCK */ + +#if V_AT_LEAST(2,2,20) + #define PTRACE_OFF(t) ((t)->ptrace &= ~PT_DTRACE) +#else + #define PTRACE_OFF(t) ((t)->flags &= ~PF_DTRACE) +#endif + +/* 2.2.21 introduced cpuid_edx */ +#if V_BEFORE(2,2,21) +static inline unsigned int cpuid_edx(unsigned int op) +{ + unsigned int eax, edx; + + __asm__("cpuid" + : "=a" (eax), "=d" (edx) + : "0" (op) + : "bx", "cx"); + return edx; +} +#endif + +#endif /* COMPAT22_H */ diff --git a/module/compat24.h b/module/compat24.h new file mode 100644 index 0000000..0f284f1 --- /dev/null +++ b/module/compat24.h @@ -0,0 +1,61 @@ +/** + * @file compat24.h + * Compatability functions for 2.4 kernels + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef COMPAT24_H +#define COMPAT24_H + +#include + +static inline pid_t op_get_tgid(void) +{ + return current->tgid; +} + +#define pte_page_address(a) page_address(pte_page(a)) +#define oprof_wake_up(w) wake_up(w) +#define lock_rtc(f) spin_lock_irqsave(&rtc_lock, f) +#define unlock_rtc(f) spin_unlock_irqrestore(&rtc_lock, f) +#define wind_dentries(d, v, r, m) wind_dentries_2_4(d, v, r, m) +extern uint do_path_hash_2_4(struct dentry * dentry, struct vfsmount * vfsmnt); +#define hash_path(f) do_path_hash_2_4((f)->f_dentry, (f)->f_vfsmnt) +#define request_region_check request_region +#define op_cpu_id() cpu_number_map(smp_processor_id()) +#define GET_VM_OFFSET(v) ((v)->vm_pgoff << PAGE_SHIFT) +#define PTRACE_OFF(t) ((t)->ptrace &= ~PT_DTRACE) +#define lock_execve() do { } while (0) +#define unlock_execve() do { } while (0) +#define lock_out_mmap() do { } while (0) +#define unlock_out_mmap() do { } while (0) +#define HAVE_MMAP2 +#define HAVE_FILE_OPERATIONS_OWNER + +/* ->owner field in 2.4 */ +#define INC_USE_COUNT_MAYBE +#define DEC_USE_COUNT_MAYBE + +/* no global waitqueue spinlock in 2.4 */ +#define wq_is_lockable() (1) + +/* 2.4.3 introduced rw mmap semaphore */ +#if V_AT_LEAST(2,4,3) + #define lock_mmap(mm) down_read(&mm->mmap_sem) + #define unlock_mmap(mm) up_read(&mm->mmap_sem) +#else + #define lock_mmap(mm) down(&mm->mmap_sem) + #define unlock_mmap(mm) up(&mm->mmap_sem) +#endif + +/* 2.4.26 exported the needed stuff for HT support */ +#if V_AT_LEAST(2,4,26) && defined(CONFIG_SMP) +#define HT_SUPPORT +#endif + +#endif /* COMPAT24_H */ diff --git a/module/ia64/IA64entry.h b/module/ia64/IA64entry.h new file mode 100644 index 0000000..7bca90a --- /dev/null +++ b/module/ia64/IA64entry.h @@ -0,0 +1,79 @@ +/** + * @file IA64entry.h + * + * @remark Copy of source code from linux kernel + * @remark linux/arch/ia64/kernel/entry.h + * + */ + +#include + +/* + * Preserved registers that are shared between code in ivt.S and entry.S. Be + * careful not to step on these! + */ + +#define pKern p2 /**< will leave_kernel return to kernel-mode? */ +#define pUser p3 /**< will leave_kernel return to user-mode? */ +#define pSys p4 /**< are we processing a (synchronous) system call? */ +#define pNonSys p5 /**< complement of pSys */ + +#define PT(f) (IA64_PT_REGS_##f##_OFFSET) +#define SW(f) (IA64_SWITCH_STACK_##f##_OFFSET) + +#define PT_REGS_SAVES(off) \ + .unwabi @svr4, 'i'; \ + .fframe IA64_PT_REGS_SIZE+16+(off); \ + .spillsp rp, PT(CR_IIP)+16+(off); \ + .spillsp ar.pfs, PT(CR_IFS)+16+(off); \ + .spillsp ar.unat, PT(AR_UNAT)+16+(off); \ + .spillsp ar.fpsr, PT(AR_FPSR)+16+(off); \ + .spillsp pr, PT(PR)+16+(off); + +#define PT_REGS_UNWIND_INFO(off) \ + .prologue; \ + PT_REGS_SAVES(off); \ + .body + +#define SWITCH_STACK_SAVES(off) \ + .savesp ar.unat,SW(CALLER_UNAT)+16+(off); \ + .savesp ar.fpsr,SW(AR_FPSR)+16+(off); \ + .spillsp f2,SW(F2)+16+(off); .spillsp f3,SW(F3)+16+(off); \ + .spillsp f4,SW(F4)+16+(off); .spillsp f5,SW(F5)+16+(off); \ + .spillsp f16,SW(F16)+16+(off); .spillsp f17,SW(F17)+16+(off); \ + .spillsp f18,SW(F18)+16+(off); .spillsp f19,SW(F19)+16+(off); \ + .spillsp f20,SW(F20)+16+(off); .spillsp f21,SW(F21)+16+(off); \ + .spillsp f22,SW(F22)+16+(off); .spillsp f23,SW(F23)+16+(off); \ + .spillsp f24,SW(F24)+16+(off); .spillsp f25,SW(F25)+16+(off); \ + .spillsp f26,SW(F26)+16+(off); .spillsp f27,SW(F27)+16+(off); \ + .spillsp f28,SW(F28)+16+(off); .spillsp f29,SW(F29)+16+(off); \ + .spillsp f30,SW(F30)+16+(off); .spillsp f31,SW(F31)+16+(off); \ + .spillsp r4,SW(R4)+16+(off); .spillsp r5,SW(R5)+16+(off); \ + .spillsp r6,SW(R6)+16+(off); .spillsp r7,SW(R7)+16+(off); \ + .spillsp b0,SW(B0)+16+(off); .spillsp b1,SW(B1)+16+(off); \ + .spillsp b2,SW(B2)+16+(off); .spillsp b3,SW(B3)+16+(off); \ + .spillsp b4,SW(B4)+16+(off); .spillsp b5,SW(B5)+16+(off); \ + .spillsp ar.pfs,SW(AR_PFS)+16+(off); .spillsp ar.lc,SW(AR_LC)+16+(off); \ + .spillsp @priunat,SW(AR_UNAT)+16+(off); \ + .spillsp ar.rnat,SW(AR_RNAT)+16+(off); \ + .spillsp ar.bspstore,SW(AR_BSPSTORE)+16+(off); \ + .spillsp pr,SW(PR)+16+(off)) + +#define DO_SAVE_SWITCH_STACK \ + movl r28=1f; \ + ;; \ + .fframe IA64_SWITCH_STACK_SIZE; \ + adds sp=-IA64_SWITCH_STACK_SIZE,sp; \ + mov.ret.sptk b7=r28,1f; \ + SWITCH_STACK_SAVES(0); \ + br.cond.sptk.many save_switch_stack; \ +1: + +#define DO_LOAD_SWITCH_STACK \ + movl r28=1f; \ + ;; \ + invala; \ + mov.ret.sptk b7=r28,1f; \ + br.cond.sptk.many load_switch_stack; \ +1: .restore sp; \ + adds sp=IA64_SWITCH_STACK_SIZE,sp diff --git a/module/ia64/IA64minstate.h b/module/ia64/IA64minstate.h new file mode 100644 index 0000000..c0b9fdd --- /dev/null +++ b/module/ia64/IA64minstate.h @@ -0,0 +1,280 @@ +/** + * @file IA64minstate.h + * + * @remark Copy of source code from linux kernel + * @remark linux/arch/ia64/kernel/minstate.h + * + */ + +#include + +#include "IA64entry.h" + +/* + * A couple of convenience macros that make writing and reading + * SAVE_MIN and SAVE_REST easier. + */ +#define rARPR r31 +#define rCRIFS r30 +#define rCRIPSR r29 +#define rCRIIP r28 +#define rARRSC r27 +#define rARPFS r26 +#define rARUNAT r25 +#define rARRNAT r24 +#define rARBSPSTORE r23 +#define rKRBS r22 +#define rB6 r21 +#define rR1 r20 + +/* + * Here start the source dependent macros. + */ + +/* + * For ivt.s we want to access the stack virtually so we dont have + * to disable translation on interrupts. + */ +#define MINSTATE_START_SAVE_MIN_VIRT \ + /* r1 = current (virtual) */ \ + dep r1=-1,r1,61,3; \ + /* set enforced lazy mode, pl 0, little-endian, loadrs=0 */ \ +(pUser) mov ar.rsc=0; \ + ;; \ + /* compute base of RBS */ \ +(pUser) addl rKRBS=IA64_RBS_OFFSET,r1; \ +(pUser) mov rARRNAT=ar.rnat; \ + /* get sp */ \ +(pKern) mov r1=sp; \ + ;; \ + /* compute base of memory stack */ \ +(pUser) addl r1=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r1; \ + /* save ar.bspstore */ \ +(pUser) mov rARBSPSTORE=ar.bspstore; \ + ;; \ + /* if in kernel mode, use sp (r12) */ \ +(pKern) addl r1=-IA64_PT_REGS_SIZE,r1; \ + /* switch to kernel RBS */ \ +(pUser) mov ar.bspstore=rKRBS; \ + ;; \ +(pUser) mov r18=ar.bsp; \ + /* set eager mode, pl 0, little-endian, loadrs=0 */ \ +(pUser) mov ar.rsc=0x3; + +#define MINSTATE_END_SAVE_MIN_VIRT \ + /* make `current' a kernel virtual address */ \ + or r13=r13,r14; \ + /* switch back to bank 1 (must be last in insn group) */ \ + bsw.1; \ + ;; + +/* + * For mca_asm.S we want to access the stack physically since the state + * is saved before we go virtual and dont want to destroy the iip or ipsr. + */ +#define MINSTATE_START_SAVE_MIN_PHYS \ +(pKern) movl sp=ia64_init_stack+IA64_STK_OFFSET-IA64_PT_REGS_SIZE; \ + /* set enforced lazy mode, pl 0, little-endian, loadrs=0 */ \ +(pUser) mov ar.rsc=0; \ + /* compute base of register backing store */ \ +(pUser) addl rKRBS=IA64_RBS_OFFSET,r1; \ + ;; \ +(pUser) mov rARRNAT=ar.rnat; \ + /* compute physical addr of sp */ \ +(pKern) dep r1=0,sp,61,3; \ + /* compute base of memory stack */ \ +(pUser) addl r1=IA64_STK_OFFSET-IA64_PT_REGS_SIZE,r1; \ + /* save ar.bspstore */ \ +(pUser) mov rARBSPSTORE=ar.bspstore; \ + /* compute kernel virtual addr of RBS */ \ +(pUser) dep rKRBS=-1,rKRBS,61,3; \ + ;; \ + /* if in kernel mode, use sp (r12) */ \ +(pKern) addl r1=-IA64_PT_REGS_SIZE,r1; \ + /* switch to kernel RBS */ \ +(pUser) mov ar.bspstore=rKRBS; \ + ;; \ +(pUser) mov r18=ar.bsp; \ + /* set eager mode, pl 0, little-endian, loadrs=0 */ \ +(pUser) mov ar.rsc=0x3; + +#define MINSTATE_END_SAVE_MIN_PHYS \ + /* make sp a kernel virtual address */ \ + or r12=r12,r14; \ + /* make `current' a kernel virtual address */ \ + or r13=r13,r14; \ + ;; + +#ifdef MINSTATE_VIRT +# define MINSTATE_START_SAVE_MIN MINSTATE_START_SAVE_MIN_VIRT +# define MINSTATE_END_SAVE_MIN MINSTATE_END_SAVE_MIN_VIRT +#endif + +#ifdef MINSTATE_PHYS +# define MINSTATE_START_SAVE_MIN MINSTATE_START_SAVE_MIN_PHYS +# define MINSTATE_END_SAVE_MIN MINSTATE_END_SAVE_MIN_PHYS +#endif + +/* + * DO_SAVE_MIN switches to the kernel stacks (if necessary) and saves + * the minimum state necessary that allows us to turn psr.ic back + * on. + * + * Assumed state upon entry: + * psr.ic: off + * psr.dt: off + * r31: contains saved predicates (pr) + * + * Upon exit, the state is as follows: + * psr.ic: off + * r2 = points to &pt_regs.r16 + * r12 = kernel sp (kernel virtual address) + * r13 = points to current task_struct (kernel virtual address) + * p15 = TRUE if psr.i is set in cr.ipsr + * predicate registers (other than p2, p3, and p15), b6, r3, r8, r9, + * r10, r11, r14, r15: preserved + * + * Note that psr.ic is NOT turned on by this macro. This is so that + * we can pass interruption state as arguments to a handler. + */ +#define DO_SAVE_MIN(COVER,SAVE_IFS,EXTRA) \ + mov rARRSC=ar.rsc; \ + mov rARPFS=ar.pfs; \ + mov rR1=r1; \ + mov rARUNAT=ar.unat; \ + mov rCRIPSR=cr.ipsr; \ + /* rB6 = branch reg 6 */ \ + mov rB6=b6; \ + mov rCRIIP=cr.iip; \ + /* r1 = current (physical) */ \ + mov r1=IA64_KR(CURRENT); \ + COVER; \ + ;; \ + invala; \ + /* extract psr.cpl */ \ + extr.u r16=rCRIPSR,32,2; \ + ;; \ + /* are we in kernel mode already? (psr.cpl==0) */ \ + cmp.eq pKern,pUser=r0,r16; \ + /* switch from user to kernel RBS: */ \ + ;; \ + SAVE_IFS; \ + MINSTATE_START_SAVE_MIN \ + ;; \ + /* initialize first base pointer */ \ + mov r16=r1; \ + /* initialize second base pointer */ \ + adds r17=8,r1; \ + ;; \ + st8 [r16]=rCRIPSR,16; /* save cr.ipsr */ \ + st8 [r17]=rCRIIP,16; /* save cr.iip */ \ +(pKern) mov r18=r0; /* make sure r18 isn't NaT */ \ + ;; \ + st8 [r16]=rCRIFS,16; /* save cr.ifs */ \ + st8 [r17]=rARUNAT,16; /* save ar.unat */ \ +(pUser) sub r18=r18,rKRBS; /* r18=RSE.ndirty*8 */ \ + ;; \ + st8 [r16]=rARPFS,16; /* save ar.pfs */ \ + st8 [r17]=rARRSC,16; /* save ar.rsc */ \ + tbit.nz p15,p0=rCRIPSR,IA64_PSR_I_BIT \ + ;; /* avoid RAW on r16 & r17 */ \ +(pKern) adds r16=16,r16; /* skip over ar_rnat field */ \ +(pKern) adds r17=16,r17; /* skip over ar_bspstore field */ \ +(pUser) st8 [r16]=rARRNAT,16; /* save ar.rnat */ \ +(pUser) st8 [r17]=rARBSPSTORE,16; /* save ar.bspstore */ \ + ;; \ + st8 [r16]=rARPR,16; /* save predicates */ \ + st8 [r17]=rB6,16; /* save b6 */ \ + /* compute ar.rsc to be used for "loadrs" */ \ + shl r18=r18,16; \ + ;; \ + st8 [r16]=r18,16; /* save ar.rsc value for "loadrs" */ \ + st8.spill [r17]=rR1,16; /* save original r1 */ \ + ;; \ +.mem.offset 0,0; st8.spill [r16]=r2,16; \ +.mem.offset 8,0; st8.spill [r17]=r3,16; \ + adds r2=IA64_PT_REGS_R16_OFFSET,r1; \ + ;; \ +.mem.offset 0,0; st8.spill [r16]=r12,16; \ +.mem.offset 8,0; st8.spill [r17]=r13,16; \ + /* initialize pSys=0, pNonSys=1 */ \ + cmp.eq pNonSys,pSys=r0,r0 \ + ;; \ +.mem.offset 0,0; st8.spill [r16]=r14,16; \ +.mem.offset 8,0; st8.spill [r17]=r15,16; \ + dep r14=-1,r0,61,3; \ + ;; \ +.mem.offset 0,0; st8.spill [r16]=r8,16; \ +.mem.offset 8,0; st8.spill [r17]=r9,16; \ + /* switch to kernel memory stack (with 16 bytes of scratch) */ \ + adds r12=-16,r1; \ + ;; \ +.mem.offset 0,0; st8.spill [r16]=r10,16; \ +.mem.offset 8,0; st8.spill [r17]=r11,16; \ + mov r13=IA64_KR(CURRENT); /* establish `current' */ \ + ;; \ + EXTRA; \ + movl r1=__gp; /* establish kernel global pointer */ \ + ;; \ + MINSTATE_END_SAVE_MIN + +/* + * SAVE_REST saves the remainder of pt_regs (with psr.ic on). This + * macro guarantees to preserve all predicate registers, r8, r9, r10, + * r11, r14, and r15. + * + * Assumed state upon entry: + * psr.ic: on + * psr.dt: on + * r2: points to &pt_regs.r16 + * r3: points to &pt_regs.r17 + */ +#define SAVE_REST \ +.mem.offset 0,0; st8.spill [r2]=r16,16; \ +.mem.offset 8,0; st8.spill [r3]=r17,16; \ + ;; \ +.mem.offset 0,0; st8.spill [r2]=r18,16; \ +.mem.offset 8,0; st8.spill [r3]=r19,16; \ + ;; \ + mov r16=ar.ccv; /* M-unit */ \ + movl r18=FPSR_DEFAULT /* L-unit */ \ + ;; \ + mov r17=ar.fpsr; /* M-unit */ \ + mov ar.fpsr=r18; /* M-unit */ \ + ;; \ +.mem.offset 0,0; st8.spill [r2]=r20,16; \ +.mem.offset 8,0; st8.spill [r3]=r21,16; \ + mov r18=b0; \ + ;; \ +.mem.offset 0,0; st8.spill [r2]=r22,16; \ +.mem.offset 8,0; st8.spill [r3]=r23,16; \ + mov r19=b7; \ + ;; \ +.mem.offset 0,0; st8.spill [r2]=r24,16; \ +.mem.offset 8,0; st8.spill [r3]=r25,16; \ + ;; \ +.mem.offset 0,0; st8.spill [r2]=r26,16; \ +.mem.offset 8,0; st8.spill [r3]=r27,16; \ + ;; \ +.mem.offset 0,0; st8.spill [r2]=r28,16; \ +.mem.offset 8,0; st8.spill [r3]=r29,16; \ + ;; \ +.mem.offset 0,0; st8.spill [r2]=r30,16; \ +.mem.offset 8,0; st8.spill [r3]=r31,16; \ + ;; \ + st8 [r2]=r16,16; /* ar.ccv */ \ + st8 [r3]=r17,16; /* ar.fpsr */ \ + ;; \ + st8 [r2]=r18,16; /* b0 */ \ + st8 [r3]=r19,16+8; /* b7 */ \ + ;; \ + stf.spill [r2]=f6,32; \ + stf.spill [r3]=f7,32; \ + ;; \ + stf.spill [r2]=f8,32; \ + stf.spill [r3]=f9,32 + +#define SAVE_MIN_WITH_COVER DO_SAVE_MIN(cover, mov rCRIFS=cr.ifs,) +#define SAVE_MIN_WITH_COVER_R19 \ + DO_SAVE_MIN(cover, mov rCRIFS=cr.ifs, mov r15=r19) +#define SAVE_MIN DO_SAVE_MIN( , mov rCRIFS=r0, ) diff --git a/module/ia64/IA64syscallstub.h b/module/ia64/IA64syscallstub.h new file mode 100644 index 0000000..c0f1dbd --- /dev/null +++ b/module/ia64/IA64syscallstub.h @@ -0,0 +1,197 @@ +/** + * @file IA64syscallstub.h + * Assembly language file macros + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Bob Montgomery + */ + +/* $Id: IA64syscallstub.h,v 1.2 2002/11/09 01:11:55 phil_e Exp $ */ + +#define SYSCALLSTUB_POST(name) \ + .sbss; \ + .align 8; \ + .type .post_saverp_##name,@object; \ + .size .post_saverp_##name,8; \ +.post_saverp_##name: \ + .skip 8; \ + .text; \ + .global post_stub_##name; \ + .align 32; \ + .proc post_stub_##name; \ +post_stub_##name: \ +.L1_##name: \ + mov r3=ip; \ + ;; \ + addl r16=.L2_##name - .L1_##name, r3; \ + ;; \ + mov b6=r16; \ + ;; \ + br.ret.sptk.many b6; \ + ;; \ +.L2_##name: \ + mov r3=ip; \ + mov r15=gp; /* save kgp */ \ + mov r17=rp; \ + ;; \ + addl r14=.post_fptr_##name - .L2_##name, r3; \ + ;; \ + ld8 r14=[r14]; \ + ;; \ + adds r14=8,r14; \ + ;; \ + ld8 gp=[r14]; \ + ;; \ + addl r14=@ltoff(old_sys_##name), gp; \ + addl r16=@gprel(.post_saverp_##name), gp; \ + ;; \ + ld8 r14 = [r14]; \ + st8 [r16]=r17; /* save krp */ \ + ;; \ + ld8 r14 = [r14]; \ + mov gp=r15; /* restore kgp */ \ + ;; \ + ld8 r14 = [r14]; \ + ;; \ + mov b6 = r14; \ + ;; \ + br.call.sptk.many b0=b6; \ + ;; \ +.L3_##name: \ + mov r3=ip; \ + mov r15=gp; /* save kgp */ \ + ;; \ + addl r14=.post_fptr_##name - .L3_##name, r3; \ + ;; \ + ld8 r14=[r14]; \ + ;; \ + adds r14=8,r14; \ + ;; \ + ld8 gp=[r14]; \ + br.call.sptk.many b0=post_call_stub_##name; \ + ;; \ + addl r16=@gprel(.post_saverp_##name), gp; \ + ;; \ + ld8 r14=[r16]; \ + ;; \ + mov b0 = r14; \ + mov gp = r15; /* preserved */ \ + br.cond.sptk.many b0; \ + .align 16; \ +.post_fptr_##name: \ + data8 @fptr(post_sys_##name); \ + .endp post_stub_##name; \ + .align 16; \ + .global post_call_stub_##name; \ + .proc post_call_stub_##name; \ +post_call_stub_##name: \ + alloc loc1=ar.pfs,8,6,8,0; \ + mov loc0=rp; \ + mov loc2=r15; /* preserve it */ \ + mov loc3=r8; \ + mov loc4=r10; \ + mov loc5=gp; \ + mov out0 = r8; /* old rv */ \ + mov out1 = in0; \ + mov out2 = in1; \ + mov out3 = in2; \ + mov out4 = in3; \ + mov out5 = in4; \ + mov out6 = in5; \ + mov out7 = in6; \ + ;; \ + br.call.sptk.many rp = post_sys_##name; \ + ;; \ + mov ar.pfs = loc1; \ + mov rp = loc0; \ + mov r15=loc2; \ + mov r8=loc3; \ + mov r10=loc4; \ + mov gp=loc5; \ + br.ret.sptk.few rp; \ + .endp post_call_stub_##name; + +#define SYSCALLSTUB_PRE(name) \ + .text; \ + .global pre_stub_##name; \ + .align 32; \ + .proc pre_stub_##name; \ +pre_stub_##name: \ +.L4_##name: \ + mov r3=ip; \ + ;; \ + addl r17=.L5_##name - .L4_##name, r3; \ + ;; \ + mov b6=r17; \ + ;; \ + br.ret.sptk.many b6; \ + ;; \ +.L5_##name: \ + mov r3=ip; \ + mov r15=gp; /* save kgp */ \ + mov r16=rp; /* save krp */ \ + ;; \ + addl r14=.pre_fptr_##name - .L5_##name, r3; \ + ;; \ + ld8 r14=[r14]; \ + ;; \ + adds r14=8,r14; \ + ;; \ + ld8 gp=[r14]; \ + ;; \ + br.call.sptk.many b0=pre_call_stub_##name; \ + ;; \ + /* kernel gp still in r15 */ \ + /* kernel rp still in r16 */ \ + /* module gp in gp */ \ + ;; \ + addl r14=@ltoff(old_sys_##name), gp; \ + ;; \ + ld8 r14 = [r14]; \ + ;; \ + ld8 r14 = [r14]; \ + mov gp=r15; /* restore kgp */ \ + ;; \ + ld8 r14 = [r14]; \ + mov rp=r16; /* restore krp */ \ + ;; \ + mov b6 = r14; \ + ;; \ + /* use the saved krp */ \ + br.call.sptk.many b6=b6; \ + ;; \ + .align 16; \ +.pre_fptr_##name: \ + data8 @fptr(pre_sys_##name); \ + .endp pre_stub_##name; \ + .align 16; \ + .global pre_call_stub_##name; \ + .proc pre_call_stub_##name; \ +pre_call_stub_##name: \ + alloc loc1=ar.pfs,8,5,8,0; \ + mov loc0=rp; \ + mov loc2=r15; /* preserve it */ \ + mov loc3=r16; /* preserve it */ \ + mov loc4=gp; \ + mov out0 = in0; \ + mov out1 = in1; \ + mov out2 = in2; \ + mov out3 = in3; \ + mov out4 = in4; \ + mov out5 = in5; \ + mov out6 = in6; \ + mov out7 = in7; \ + ;; \ + br.call.sptk.many rp = pre_sys_##name; \ + ;; \ + mov ar.pfs = loc1; \ + mov rp = loc0; \ + mov r15=loc2; \ + mov r16=loc3; \ + mov gp=loc4; \ + br.ret.sptk.few rp; \ + .endp pre_call_stub_##name; + + diff --git a/module/ia64/Makefile.in b/module/ia64/Makefile.in new file mode 100644 index 0000000..b1a932c --- /dev/null +++ b/module/ia64/Makefile.in @@ -0,0 +1,30 @@ +# +# module/ia64/Makefile.in +# +# Will Cohen +# 7/29/2002 + +OPROFILE_DIR=@OPROFILE_DIR@ +VERSION=@VERSION@ +KVERS=@KVERS@ +KSRC=@KSRC@ + +EXTRA_CFLAGS=@EXTRA_CFLAGS_MODULE@ -D__NO_VERSION__ \ + -I$(OPROFILE_DIR)/ -I$(OPROFILE_DIR)/libutil -I$(OPROFILE_DIR)/libop -I$(OPROFILE_DIR)/module + +USE_STANDARD_AS_RULE=1 + +# NB: do not add a file here without adding it to EXTRA_DIST in ../Makefile.am + +O_TARGET := arch.o + +obj-y := cpu_type.o op_pmu.o op_syscalls.o oprofile_stubs.o +obj-m := $(O_TARGET) +O_OBJS := $(obj-y) +M_OBJS := $(O_TARGET) + +TOPDIR := $(KSRC) +CONFIG_SHELL := TOPDIR=$(KSRC) /bin/bash +include $(KSRC)/Rules.make + +# FIXME: dependencies diff --git a/module/ia64/cpu_type.c b/module/ia64/cpu_type.c new file mode 100644 index 0000000..69e1ed4 --- /dev/null +++ b/module/ia64/cpu_type.c @@ -0,0 +1,34 @@ +/** + * @file cpu_type.c + * CPU determination + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + * @author Will Cohen + */ + +#include "oprofile.h" + +EXPORT_NO_SYMBOLS; + +__init op_cpu get_cpu_type(void) +{ + __u8 family = local_cpu_data->family; + + /* FIXME: There should be a bit more checking here. */ + switch (family) { + /* Itanium */ + case 0x07: + return CPU_IA64_1; + break; + /* Itanium 2 */ + case 0x1f: + return CPU_IA64_2; + break; + } + /* Go for the basic generic IA64 */ + return CPU_IA64; +} diff --git a/module/ia64/op_ia64_model.h b/module/ia64/op_ia64_model.h new file mode 100644 index 0000000..79f6c06 --- /dev/null +++ b/module/ia64/op_ia64_model.h @@ -0,0 +1,32 @@ +/** + * @file op_ia64_model.h + * interface to ia64 model-specific MSR operations + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Graydon Hoare + * @author Will Cohen + */ + +#ifndef OP_IA64_MODEL_H +#define OP_IA64_MODEL_H + +#include "oprofile.h" + +struct op_saved_msr { + uint high; + uint low; +}; + +struct op_msr_group { + uint * addrs; + struct op_saved_msr * saved; +}; + +struct op_msrs { + struct op_msr_group counters; + struct op_msr_group controls; +}; + +#endif /* OP_IA64_MODEL_H */ diff --git a/module/ia64/op_pmu.c b/module/ia64/op_pmu.c new file mode 100644 index 0000000..fd6fd0c --- /dev/null +++ b/module/ia64/op_pmu.c @@ -0,0 +1,661 @@ +/** + * @file op_pmu.c + * Setup and handling of IA64 Performance Monitoring Unit (PMU) + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Bob Montgomery + * @author Will Cohen + * @author John Levon + * @author Philippe Elie + */ + + +#include "oprofile.h" +#include "op_util.h" +#include +#include "op_ia64_model.h" + +/* number of counters physically present */ +static uint op_nr_counters = 4; + +/* performance counters are in pairs: pmcN and pmdN. The pmc register acts + * as the event selection; the pmd register is the counter. */ +#define perf_reg(c) ((c)+4) + +#define IA64_1_PMD_MASK_VAL ((1UL << 32) - 1) +#define IA64_2_PMD_MASK_VAL ((1UL << 47) - 1) + +/* The appropriate value is selected in pmu_init() */ +unsigned long pmd_mask = IA64_2_PMD_MASK_VAL; + +#define pmd_overflowed(r,c) ((r) & (1 << perf_reg(c))) +#define set_pmd_neg(v,c) do { \ + ia64_set_pmd(perf_reg(c), -(ulong)(v) & pmd_mask); \ + ia64_srlz_d(); } while (0) +#define set_pmd(v,c) do { \ + ia64_set_pmd(perf_reg(c), (v) & pmd_mask); \ + ia64_srlz_d(); } while (0) +#define set_pmc(v,c) do { ia64_set_pmc(perf_reg(c), (v)); ia64_srlz_d(); } while (0) +#define get_pmd(c) ia64_get_pmd(perf_reg(c)) +#define get_pmc(c) ia64_get_pmc(perf_reg(c)) + +/* ---------------- IRQ handler ------------------ */ + +/* The args match the args for pfm_overflow_handler in perfmon.c. + * The task_struct is currently filled in with the perfmon "owner" of + * the PMU. This might change. I'm not sure it makes sense in perfmon + * either with system-wide profiling. + * pmc0 is a bit mask for overflowed counters (bits 4-7) + * This routine should return 0 to resume interrupts. + */ +inline static void +op_do_pmu_interrupt(u64 pmc0, struct pt_regs *regs) +{ + uint cpu = op_cpu_id(); + int ctr; + + for (ctr = 0 ; ctr < op_nr_counters ; ++ctr) { + if (pmd_overflowed(pmc0, ctr)) { + op_do_profile(cpu, regs->cr_iip, 1, ctr); + set_pmd_neg(oprof_data[cpu].ctr_count[ctr], ctr); + } + } + return; +} + + +static void +op_raw_pmu_interrupt(int irq, void *arg, struct pt_regs *regs) +{ + u64 pmc0; + + pmc0 = ia64_get_pmc(0); + + if ((pmc0 & ~0x1UL) != 0UL) { + op_do_pmu_interrupt(pmc0, regs); + ia64_set_pmc(0, 0); + ia64_srlz_d(); + } +} + + +#define MY_OPROFILE_VECTOR (IA64_PERFMON_VECTOR - 2) + +static void +op_set_pmv(void *dummy) +{ + ia64_set_pmv(MY_OPROFILE_VECTOR); + ia64_srlz_d(); +} + + +static void +op_restore_pmv(void* dummy) +{ + ia64_set_pmv(IA64_PERFMON_VECTOR); + ia64_srlz_d(); +} + + +static int +install_handler(void) +{ + int err = 0; + + /* Try it legally - confusion about vec vs irq */ + err = request_irq(MY_OPROFILE_VECTOR, op_raw_pmu_interrupt, + SA_INTERRUPT | SA_PERCPU_IRQ, "oprofile", NULL); + + if (err) { + printk(KERN_ALERT "oprofile_IA64: request_irq fails, " + "returns %d\n", err); + return err; + } + + if ((smp_call_function(op_set_pmv, NULL, 0, 1))) { + printk(KERN_ALERT "oprofile_IA64: unexpected failure " + "of smp_call_function(op_set_pmv)\n"); + } + + op_set_pmv(NULL); + + return err; +} + + +static int +restore_handler(void) +{ + int err = 0; + + if ((smp_call_function(op_restore_pmv, NULL, 0, 1))) { + printk(KERN_ALERT "oprofile_IA64: unexpected failure " + "of smp_call_function(op_restore_pmv)\n"); + } + + op_restore_pmv(NULL); + + free_irq(MY_OPROFILE_VECTOR, NULL); + return err; +} + + +/* ---------------- PMU setup ------------------ */ + +/* This is kind of artificial. The proc interface might really want to + * accept register values directly. There are other features not exposed + * by this limited interface. Of course that might require all sorts of + * validity checking??? */ +static void +pmc_fill_in(ulong *val, u8 kernel, u8 user, u8 event, u8 um) +{ + /* enable interrupt generation */ + *val |= (1<<5); + + /* setup as a privileged monitor */ + *val |= (1<<6); + + /* McKinley requires pmc4 to have bit 23 set (enable PMU). + * It is supposedly ignored in other pmc registers. + * Try assuming it's ignored in Itanium, too, and just + * set it for everyone. + */ + + *val |= (1<<23); + + /* enable/disable chosen OS and USR counting */ + (user) ? (*val |= (1<<3)) + : (*val &= ~(1<<3)); + + (kernel) ? (*val |= (1<<0)) + : (*val &= ~(1<<0)); + + /* what are we counting ? */ + *val &= ~(0xff << 8); + *val |= ((event & 0xff) << 8); + *val &= ~(0xf << 16); + *val |= ((um & 0xf) << 16); +} + + +static void +pmu_setup(void *dummy) +{ + ulong pmc_val; + int ii; + + /* setup each counter */ + for (ii = 0 ; ii < op_nr_counters ; ++ii) { + if (sysctl.ctr[ii].enabled) { + pmc_val = 0; + + set_pmd_neg(sysctl.ctr[ii].count, ii); + pmc_fill_in(&pmc_val, sysctl.ctr[ii].kernel, + sysctl.ctr[ii].user, sysctl.ctr[ii].event, + sysctl.ctr[ii].unit_mask); + + set_pmc(pmc_val, ii); + } + } +} + + +void +disable_psr(void *dummy) +{ + struct pt_regs *regs; + /* disable profiling for my saved state */ + regs = (struct pt_regs *)((unsigned long) current + IA64_STK_OFFSET); + regs--; + ia64_psr(regs)->pp = 0; + /* shouldn't need to */ + ia64_psr(regs)->up = 0; + + /* disable profiling for my current state */ + __asm__ __volatile__ ("rsm psr.pp;;"::: "memory"); + +#if defined(CONFIG_PERFMON) && defined(CONFIG_SMP) +#if V_AT_LEAST(2, 4, 21) + local_cpu_data->pfm_syst_info |= PFM_CPUINFO_SYST_WIDE; + local_cpu_data->pfm_syst_info &= ~PFM_CPUINFO_DCR_PP; + /* FIXME: what todo with the 3rd flags PFM_CPUINFO_EXCL_IDLE 0x4 */ +#else + /* disable profiling for everyone else */ + local_cpu_data->pfm_syst_wide = 1; + local_cpu_data->pfm_dcr_pp = 0; +#endif +#endif + ia64_set_pmc(0,0); + ia64_srlz_d(); +} + + +static int +pmu_setup_all(void) +{ + + /* This would be a great place to reserve all cpus with + * some sort of call to perfmonctl (something like the + * CREATE_CONTEXT command). The current interface to + * perfmonctl wants to be called from a different task id + * for each CPU to be set up (and doesn't allow calls from + * modules. + */ + + /* disable profiling with the psr.pp bit */ + if ((smp_call_function(disable_psr, NULL, 0, 1))) + return -EFAULT; + + disable_psr(NULL); + + /* now I've reserved the PMUs and they should be quiet */ + + if ((smp_call_function(pmu_setup, NULL, 0, 1))) + return -EFAULT; + + pmu_setup(NULL); + return 0; +} + + +#ifndef CONFIG_SMP +/* from linux/arch/ia64/kernel/perfmon.c */ +/* + * Originaly Written by Ganesh Venkitachalam, IBM Corp. + * Copyright (C) 1999 Ganesh Venkitachalam + * + * Modifications by Stephane Eranian, Hewlett-Packard Co. + * Modifications by David Mosberger-Tang, Hewlett-Packard Co. + * + * Copyright (C) 1999-2002 Hewlett Packard Co + * Stephane Eranian + * David Mosberger-Tang + */ + +/* + * On UP kernels, we do not need to constantly set the psr.pp bit + * when a task is scheduled. The psr.pp bit can only be changed in + * the kernel because of a user request. Given we are on a UP non preeemptive + * kernel we know that no other task is running, so we cna simply update their + * psr.pp from their saved state. There is this no impact on the context switch + * code compared to the SMP case. + */ +static void +op_tasklist_toggle_pp(unsigned int val) +{ + struct task_struct *p; + struct pt_regs *regs; + + read_lock(&tasklist_lock); + + for_each_task(p) { + regs = (struct pt_regs *)((unsigned long) p + IA64_STK_OFFSET); + + /* + * position on pt_regs saved on stack on 1st entry into the kernel + */ + regs--; + + /* + * update psr.pp + */ + ia64_psr(regs)->pp = val; + } + read_unlock(&tasklist_lock); +} +#endif + + +static void +pmu_start(void *info) +{ + struct pt_regs *regs; + + if (info && (*((uint *)info) != op_cpu_id())) + return; + + /* printk(KERN_ALERT "oprofile_IA64: pmu_start on cpu %d\n", + op_cpu_id()); */ + /* The default control register pp value is copied into psr.pp + * on an interrupt. This allows interrupt service routines to + * be monitored. + */ + ia64_set_dcr(ia64_get_dcr() | IA64_DCR_PP); + +#ifdef CONFIG_PERFMON +#ifdef CONFIG_SMP +#if V_AT_LEAST(2, 4, 21) + local_cpu_data->pfm_syst_info |= PFM_CPUINFO_SYST_WIDE; + local_cpu_data->pfm_syst_info |= PFM_CPUINFO_DCR_PP; + /* FIXME: what todo with the 3rd flags PFM_CPUINFO_EXCL_IDLE 0x4 */ +#else + local_cpu_data->pfm_syst_wide = 1; + local_cpu_data->pfm_dcr_pp = 1; +#endif +#else + op_tasklist_toggle_pp(1); +#endif +#endif + /* set it in my saved state */ + regs = (struct pt_regs *)((unsigned long) current + IA64_STK_OFFSET); + regs--; + ia64_psr(regs)->pp = 1; + + /* set it in my current state */ + __asm__ __volatile__ ("ssm psr.pp;;"::: "memory"); + ia64_srlz_d(); +} + + +static void +pmu_stop(void *info) +{ + struct pt_regs *regs; + + if (info && (*((uint *)info) != op_cpu_id())) + return; + + /* stop in my current state */ + __asm__ __volatile__ ("rsm psr.pp;;"::: "memory"); + + /* disable the dcr pp */ + ia64_set_dcr(ia64_get_dcr() & ~IA64_DCR_PP); + +#ifdef CONFIG_PERFMON +#ifdef CONFIG_SMP +#if V_AT_LEAST(2, 4, 21) + local_cpu_data->pfm_syst_info &= ~PFM_CPUINFO_SYST_WIDE; + local_cpu_data->pfm_syst_info &= ~PFM_CPUINFO_DCR_PP; + /* FIXME: what todo with the 3rd flags PFM_CPUINFO_EXCL_IDLE 0x4 */ +#else + local_cpu_data->pfm_syst_wide = 0; + local_cpu_data->pfm_dcr_pp = 0; +#endif +#else + pfm_tasklist_toggle_pp(0); +#endif +#endif + + /* disable in my saved state */ + regs = (struct pt_regs *)((unsigned long) current + IA64_STK_OFFSET); + regs--; + ia64_psr(regs)->pp = 0; +} + + +static void +pmu_select_start(uint cpu) +{ + if (cpu == op_cpu_id()) + pmu_start(NULL); + else + smp_call_function(pmu_start, &cpu, 0, 1); +} + + +static void +pmu_select_stop(uint cpu) +{ + if (cpu == op_cpu_id()) + pmu_stop(NULL); + else + smp_call_function(pmu_stop, &cpu, 0, 1); +} + + +static void +pmu_start_all(void) +{ + int cpu, i; + + for (cpu=0; cpu < smp_num_cpus; cpu++) { + struct _oprof_data * data = &oprof_data[cpu]; + + for (i = 0 ; i < op_nr_counters ; ++i) { + if (sysctl.ctr[i].enabled) { + data->ctr_count[i] = sysctl.ctr[i].count; + } else { + data->ctr_count[i] = 0; + } + } + } + + if (!install_handler()) { + smp_call_function(pmu_start, NULL, 0, 1); + pmu_start(NULL); + } + /* FIXME need some way to fail here */; +} + + +static void +pmu_stop_all(void) +{ + smp_call_function(pmu_stop, NULL, 0, 1); + pmu_stop(NULL); + restore_handler(); +} + + +static int +pmu_check_params(void) +{ + int i; + int enabled = 0; + + for (i = 0; i < op_nr_counters ; i++) { + if (!sysctl.ctr[i].enabled) + continue; + + enabled = 1; + + if (!sysctl.ctr[i].user && !sysctl.ctr[i].kernel) { + printk(KERN_ERR "oprofile: neither kernel nor user " + "set for counter %d\n", i); + return -EINVAL; + } + + if (check_range(sysctl.ctr[i].count, 1, OP_MAX_PERF_COUNT, + "ctr count value %d not in range (%d %ld)\n")) + return -EINVAL; + } + + if (!enabled) { + printk(KERN_ERR "oprofile: no counters have been enabled.\n"); + return -EINVAL; + } + + return 0; +} + + +static struct op_msrs cpu_msrs[NR_CPUS]; + + +static void free_msr_group(struct op_msr_group * group) +{ + if (group->addrs) + kfree(group->addrs); + if (group->saved) + kfree(group->saved); + group->addrs = NULL; + group->saved = NULL; +} + + +static void pmu_save_registers(void * dummy) +{ + uint i; + uint const cpu = op_cpu_id(); + struct op_msr_group * counters = &cpu_msrs[cpu].counters; + struct op_msr_group * controls = &cpu_msrs[cpu].controls; + + counters->addrs = NULL; + counters->saved = NULL; + controls->addrs = NULL; + controls->saved = NULL; + + counters->saved = kmalloc( + op_nr_counters * sizeof(struct op_saved_msr), GFP_KERNEL); + if (!counters->saved) + goto fault; + + controls->saved = kmalloc( + op_nr_counters * sizeof(struct op_saved_msr), GFP_KERNEL); + if (!controls->saved) + goto fault; + + for (i = 0; i < op_nr_counters; ++i) { + controls->saved[i].low = get_pmc(i); + counters->saved[i].low = get_pmd(i); + } + return; + +fault: + free_msr_group(counters); + free_msr_group(controls); +} + + +static void pmu_restore_registers(void * dummy) +{ + uint i; + uint const cpu = op_cpu_id(); + struct op_msr_group * counters = &cpu_msrs[cpu].counters; + struct op_msr_group * controls = &cpu_msrs[cpu].controls; + + for (i = 0; i < op_nr_counters; ++i) { + set_pmc(controls->saved[i].low, i); + set_pmd(counters->saved[i].low, i); + } + + free_msr_group(counters); + free_msr_group(controls); +} + + + +static int +pmu_init(void) +{ + int err = 0; + + /* figure out processor type configure number of bits in pmd + and number of counters */ + switch (get_cpu_type()) { + case CPU_IA64_1: + pmd_mask = IA64_1_PMD_MASK_VAL; break; + case CPU_IA64_2: + case CPU_IA64: + pmd_mask = IA64_2_PMD_MASK_VAL; break; + default: + err = -EIO; break; + } + + op_nr_counters = 4; + + if ((err = smp_call_function(pmu_save_registers, NULL, 0, 1))) { + goto out; + } + pmu_save_registers(NULL); + +out: + return err; +} + + +static void +pmu_deinit(void) +{ + smp_call_function(pmu_restore_registers, NULL, 0, 1); + pmu_restore_registers(NULL); +} + + +static char *names[] = { "0", "1", "2", "3", }; + + +static int +pmu_add_sysctls(ctl_table * next) +{ + ctl_table * start = next; + ctl_table * tab; + int i, j; + + for (i=0; i < op_nr_counters; i++) { + next->ctl_name = 1; + next->procname = names[i]; + next->mode = 0700; + + if (!(tab = kmalloc(sizeof(ctl_table)*7, GFP_KERNEL))) + goto cleanup; + + next->child = tab; + + memset(tab, 0, sizeof(ctl_table)*7); + tab[0] = ((ctl_table) { 1, "enabled", &sysctl_parms.ctr[i].enabled, sizeof(int), 0600, NULL, lproc_dointvec, NULL, }); + tab[1] = ((ctl_table) { 1, "event", &sysctl_parms.ctr[i].event, sizeof(int), 0600, NULL, lproc_dointvec, NULL, }); + tab[2] = ((ctl_table) { 1, "count", &sysctl_parms.ctr[i].count, sizeof(int), 0600, NULL, lproc_dointvec, NULL, }); + tab[3] = ((ctl_table) { 1, "unit_mask", &sysctl_parms.ctr[i].unit_mask, sizeof(int), 0600, NULL, lproc_dointvec, NULL, }); + tab[4] = ((ctl_table) { 1, "kernel", &sysctl_parms.ctr[i].kernel, sizeof(int), 0600, NULL, lproc_dointvec, NULL, }); + tab[5] = ((ctl_table) { 1, "user", &sysctl_parms.ctr[i].user, sizeof(int), 0600, NULL, lproc_dointvec, NULL, }); + next++; + } + + return 0; + +cleanup: + next = start; + for (j = 0; j < i; j++) { + kfree(next->child); + next++; + } + return -EFAULT; +} + + +static void pmu_remove_sysctls(ctl_table * next) +{ + int ii; + + for (ii=0; ii < op_nr_counters; ii++) { + kfree(next->child); + next++; + } +} + + +struct op_int_operations op_nmi_ops = { + init: pmu_init, + deinit: pmu_deinit, + add_sysctls: pmu_add_sysctls, + remove_sysctls: pmu_remove_sysctls, + check_params: pmu_check_params, + setup: pmu_setup_all, + start: pmu_start_all, + stop: pmu_stop_all, + start_cpu: pmu_select_start, + stop_cpu: pmu_select_stop, +}; + + +struct op_int_operations const * op_int_interface() +{ + return &op_nmi_ops; +} + +/* Need this dummy so module/oprofile.c links */ +struct op_int_operations op_rtc_ops = { + init: NULL, + deinit: NULL, + add_sysctls: NULL, + remove_sysctls: NULL, + check_params: NULL, + setup: NULL, + start: NULL, + stop: NULL, + start_cpu: NULL, + stop_cpu: NULL, +}; diff --git a/module/ia64/op_syscalls.c b/module/ia64/op_syscalls.c new file mode 100644 index 0000000..882b5ee --- /dev/null +++ b/module/ia64/op_syscalls.c @@ -0,0 +1,383 @@ +/** + * @file op_syscalls.c + * Tracing of system calls + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Bob Montgomery + * @author Will Cohen + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include +#include + +#include "oprofile.h" +#include "op_dcache.h" +#include "op_util.h" + +uint dname_top; +struct qstr **dname_stack; +char * pool_pos; +char * pool_start; +char * pool_end; + +void oprof_put_note(struct op_note *samp); + +/* ------------ system calls --------------- */ + +struct mmap_arg_struct { + unsigned long addr; + unsigned long len; + unsigned long prot; + unsigned long flags; + unsigned long fd; + unsigned long offset; +}; + +/* --------- IA64 versions of system calls ------ */ +asmlinkage static int (*old_sys_clone)(long, long); +asmlinkage static int (*old_sys_clone2)(long, long, long); +asmlinkage static int (*old_sys_execve)(char *, char **, char **); +asmlinkage static unsigned long (*old_sys_mmap)(unsigned long, + unsigned long, int, int, int, long); +asmlinkage static unsigned long (*old_sys_mmap2)(unsigned long, + unsigned long, int, int, int, long); +asmlinkage static long (*old_sys_init_module)(char const *, struct module *); +asmlinkage static long (*old_sys_exit)(int); + +/* --------- declarations of interception stubs for IA64 ------ */ +asmlinkage long post_stub_clone(long, long); +asmlinkage long post_stub_clone2(long, long, long); +asmlinkage long my_ia64_execve(char *, char **, char **); +asmlinkage unsigned long post_stub_mmap(unsigned long, + unsigned long, int, int, int, long); +asmlinkage unsigned long post_stub_mmap2(unsigned long, + unsigned long, int, int, int, long); +asmlinkage long post_stub_init_module(char const *, struct module *); +asmlinkage long pre_stub_exit(int); + +/* IA64 system call table doesn't use function pointers, it uses + * pointers to code (not the same thing). Basically it can violate the + * procedure calling rules because these "procedure calls" are made by + * the assembly language BREAK handler in ivt.S. + */ + +struct fdesc { + void *ip; + void *gp; +}; + +struct fdesc fdesc_clone; +struct fdesc fdesc_clone2; +struct fdesc fdesc_execve; +struct fdesc fdesc_mmap; +struct fdesc fdesc_mmap2; +struct fdesc fdesc_init_module; +struct fdesc fdesc_exit; +/* ----------- End of IA64 weirdness for now -------------- */ + +spinlock_t map_lock = SPIN_LOCK_UNLOCKED; + +/* called with map_lock held */ +static void oprof_output_map(ulong addr, ulong len, + ulong offset, struct file *file, int is_execve) +{ + struct op_note note; + + /* don't bother with /dev/zero mappings etc. */ + if (!len) + return; + + note.pid = current->pid; + note.tgid = op_get_tgid(); + note.addr = addr; + note.len = len; + note.offset = offset; + note.type = is_execve ? OP_EXEC : OP_MAP; + note.hash = hash_path(file); + if (note.hash == -1) + return; + oprof_put_note(¬e); +} + +static int oprof_output_maps(struct task_struct *task) +{ + int size=0; + struct mm_struct *mm; + struct vm_area_struct *map; + + /* we don't need to worry about mm_users here, since there is at + least one user (current), and if there's other code using this + mm, then mm_users must be at least 2; we should never have to + mmput() here. */ + + if (!(mm = task->mm)) + goto out; + + lock_mmap(mm); + spin_lock(&map_lock); + + /* We need two pass, daemon assume than the first mmap notification + * is for the executable but some process doesn't follow this model. + */ + for (map = mm->mmap; map; map = map->vm_next) { + if (!(map->vm_flags & VM_EXEC) || !map->vm_file) + continue; + if (!(map->vm_flags & VM_EXECUTABLE)) + continue; + + oprof_output_map(map->vm_start, map->vm_end-map->vm_start, + GET_VM_OFFSET(map), map->vm_file, 1); + } + for (map = mm->mmap; map; map = map->vm_next) { + if (!(map->vm_flags & VM_EXEC) || !map->vm_file) + continue; + if (map->vm_flags & VM_EXECUTABLE) + continue; + + oprof_output_map(map->vm_start, map->vm_end-map->vm_start, + GET_VM_OFFSET(map), map->vm_file, 0); + } + spin_unlock(&map_lock); + unlock_mmap(mm); + +out: + return size; +} + + +/* execve is a special case on IA64. The others get the result and + * arguments after the system call has been made from the ASM stub. */ + +asmlinkage long +my_sys_execve (char *filename, char **argv, char **envp, struct pt_regs *regs) +{ + int error; + + MOD_INC_USE_COUNT; + + filename = getname(filename); + error = PTR_ERR(filename); + if (IS_ERR(filename)) + goto out; + error = do_execve(filename, argv, envp, regs); + + if (!error) { + PTRACE_OFF(current); + oprof_output_maps(current); + } + putname(filename); +out: + unlock_execve(); + MOD_DEC_USE_COUNT; + return error; +} + + +static void out_mmap(ulong addr, ulong len, ulong prot, ulong flags, + ulong fd, ulong offset) +{ + struct file *file; + + lock_out_mmap(); + + file = fget(fd); + if (!file) + goto out; + + spin_lock(&map_lock); + oprof_output_map(addr, len, offset, file, 0); + spin_unlock(&map_lock); + + fput(file); + +out: + unlock_out_mmap(); +} + + +/* + * IA64 mmap routines: + * The post_sys_* routines are called after the syscall has been made. + * The first argument is the return value from the system call. + */ +asmlinkage void post_sys_mmap2(ulong ret, ulong addr, ulong len, + ulong prot, ulong flags, ulong fd, ulong pgoff) +{ + /* FIXME: This should be done in the ASM stub. */ + MOD_INC_USE_COUNT; + + if ((prot & PROT_EXEC) && ret >= 0) + out_mmap(ret, len, prot, flags, fd, pgoff << PAGE_SHIFT); + goto out; +out: + MOD_DEC_USE_COUNT; +} + +asmlinkage void post_sys_mmap(ulong ret, ulong addr, ulong len, + ulong prot, ulong flags, ulong fd, ulong off) +{ + /* FIXME: This should be done in the ASM stub. */ + MOD_INC_USE_COUNT; + + if ((prot & PROT_EXEC) && ret >= 0) + out_mmap(ret, len, prot, flags, fd, off); + goto out; +out: + MOD_DEC_USE_COUNT; +} + + +inline static void oprof_report_fork(u32 old_pid, u32 new_pid, u32 old_tgid, u32 new_tgid) +{ + struct op_note note; + + note.type = OP_FORK; + note.pid = old_pid; + note.tgid = old_tgid; + note.addr = new_pid; + note.len = new_tgid; + oprof_put_note(¬e); +} + + +asmlinkage void post_sys_clone(long ret, long arg0, long arg1) +{ + u32 pid = current->pid; + u32 tgid = op_get_tgid(); + + /* FIXME: This should be done in the ASM stub. */ + MOD_INC_USE_COUNT; + + if (ret) + /* FIXME: my libc show clone() is not implemented in ia64 + * but used only by fork() with a SIGCHILD first parameter + * so we assume it's a fork */ + oprof_report_fork(pid, ret, pid, tgid); + MOD_DEC_USE_COUNT; +} + +asmlinkage void post_sys_clone2(long ret, long arg0, long arg1, long arg2) +{ + u32 pid = current->pid; + u32 tgid = op_get_tgid(); + long clone_flags = arg0; + + /* FIXME: This should be done in the ASM stub. */ + MOD_INC_USE_COUNT; + + if (ret) { + if (clone_flags & CLONE_THREAD) + oprof_report_fork(pid, ret, tgid, tgid); + else + oprof_report_fork(pid, ret, tgid, ret); + } + MOD_DEC_USE_COUNT; +} + +asmlinkage void +post_sys_init_module(long ret, char const * name_user, + struct module * mod_user) +{ + /* FIXME: This should be done in the ASM stub. */ + MOD_INC_USE_COUNT; + + if (ret >= 0) { + struct op_note note; + + note.type = OP_DROP_MODULES; + oprof_put_note(¬e); + } + MOD_DEC_USE_COUNT; +} + +/* Exit must use a pre-call intercept stub. There is no post exit. */ +asmlinkage void pre_sys_exit(int error_code) +{ + struct op_note note; + + MOD_INC_USE_COUNT; + + note.addr = current->times.tms_utime; + note.len = current->times.tms_stime; + note.offset = current->start_time; + note.type = OP_EXIT; + note.pid = current->pid; + note.tgid = op_get_tgid(); + oprof_put_note(¬e); + + /* this looks UP-dangerous, as the exit sleeps and we don't + * have a use count, but in fact its ok as sys_exit is noreturn, + * so we can never come back to this non-existent exec page + */ + MOD_DEC_USE_COUNT; +} + +extern void *sys_call_table[]; + +/* FIXME: Now that I'm never trying to do a C-level call through these + * pointers, I should just save, intercept, and restore with void * + * instead of the void * part of the function descriptor, I think. + */ + +void op_save_syscalls(void) +{ + fdesc_clone.ip = sys_call_table[__NR_clone - __NR_ni_syscall]; + old_sys_clone = (void *)&fdesc_clone; + fdesc_clone2.ip = sys_call_table[__NR_clone2 - __NR_ni_syscall]; + old_sys_clone2 = (void *)&fdesc_clone2; + fdesc_execve.ip = sys_call_table[__NR_execve - __NR_ni_syscall]; + old_sys_execve = (void *)&fdesc_execve; + fdesc_mmap.ip = sys_call_table[__NR_mmap - __NR_ni_syscall]; + old_sys_mmap = (void *)&fdesc_mmap; + fdesc_mmap2.ip = sys_call_table[__NR_mmap2 - __NR_ni_syscall]; + old_sys_mmap2 = (void *)&fdesc_mmap2; + fdesc_init_module.ip = sys_call_table[__NR_init_module - __NR_ni_syscall]; + old_sys_init_module = (void *)&fdesc_init_module; + fdesc_exit.ip = sys_call_table[__NR_exit - __NR_ni_syscall]; + old_sys_exit = (void *)&fdesc_exit; +} + +void op_intercept_syscalls(void) +{ + /* Must extract the function address from the stub function + * descriptors. + */ + sys_call_table[__NR_clone - __NR_ni_syscall] = + ((struct fdesc *)post_stub_clone)->ip; + sys_call_table[__NR_clone2 - __NR_ni_syscall] = + ((struct fdesc *)post_stub_clone2)->ip; + sys_call_table[__NR_execve - __NR_ni_syscall] = + ((struct fdesc *)my_ia64_execve)->ip; + sys_call_table[__NR_mmap - __NR_ni_syscall] = + ((struct fdesc *)post_stub_mmap)->ip; + sys_call_table[__NR_mmap2 - __NR_ni_syscall] = + ((struct fdesc *)post_stub_mmap2)->ip; + sys_call_table[__NR_init_module - __NR_ni_syscall] = + ((struct fdesc *)post_stub_init_module)->ip; + sys_call_table[__NR_exit - __NR_ni_syscall] = + ((struct fdesc *)pre_stub_exit)->ip; +} + +void op_restore_syscalls(void) +{ + sys_call_table[__NR_clone - __NR_ni_syscall] = + ((struct fdesc *)old_sys_clone)->ip; + sys_call_table[__NR_clone2 - __NR_ni_syscall] = + ((struct fdesc *)old_sys_clone2)->ip; + sys_call_table[__NR_execve - __NR_ni_syscall] = + ((struct fdesc *)old_sys_execve)->ip; + sys_call_table[__NR_mmap - __NR_ni_syscall] = + ((struct fdesc *)old_sys_mmap)->ip; + sys_call_table[__NR_mmap2 - __NR_ni_syscall] = + ((struct fdesc *)old_sys_mmap2)->ip; + sys_call_table[__NR_init_module - __NR_ni_syscall] = + ((struct fdesc *)old_sys_init_module)->ip; + sys_call_table[__NR_exit - __NR_ni_syscall] = + ((struct fdesc *)old_sys_exit)->ip; +} diff --git a/module/ia64/oprofile_stubs.S b/module/ia64/oprofile_stubs.S new file mode 100644 index 0000000..3695f50 --- /dev/null +++ b/module/ia64/oprofile_stubs.S @@ -0,0 +1,140 @@ +/** + * @file oprofile_stubs.S + * Assembly language system call interceptor stubs + * + * @remark Copyright 2001-2002 Hewlett-Packard Company + * @remark Read the file COPYING + * + * @author Bob Montgomery + */ + +/* + * This interceptor for execve was stolen from ia64/kernel/entry.S + * + * Kernel entry points. + * + * Copyright (C) 1998-2001 Hewlett-Packard Co + * David Mosberger-Tang + * Copyright (C) 1999 VA Linux Systems + * Copyright (C) 1999 Walt Drummond + * Copyright (C) 1999 Asit Mallick + * Copyright (C) 1999 Don Dugger + */ +/* + * ia64_switch_to now places correct virtual mapping in in TR2 for + * kernel stack. This allows us to handle interrupts without changing + * to physical mode. + * + * Jonathan Nicklin + * Patrick O'Rourke + * 11/07/2000 + */ +/* + * Global (preserved) predicate usage on syscall entry/exit path: + * + * pKern: See entry.h. + * pUser: See entry.h. + * pSys: See entry.h. + * pNonSys: !pSys + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "IA64minstate.h" + + /* + * execve() is special because in case of success, we need to + * setup a null register window frame. + */ +GLOBAL_ENTRY(my_ia64_execve) + .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(3) + alloc loc1=ar.pfs,3,3,4,0 + mov loc0=rp + mov loc2=gp + .body + mov out0=in0 // filename + ;; // stop bit between alloc and call + mov out1=in1 // argv + mov out2=in2 // envp + add out3=16,sp // regs + /* + * We are here with the kernel's gp register value but we need + * to find the module's gp value before we can call our own + * routine. That's why we can't just use: + * br.call.sptk.many rp=my_sys_execve + * Use ip-relative addressing to get to the fptr since I can't + * use gp-relative anything without the module's gp. + */ +.L1_execve: + mov r3 = ip + ;; + addl r14 = .fptr_execve - .L1_execve, r3 + ;; + ld8 r14=[r14] + ;; + ld8 r15=[r14],8 + ;; + ld8 gp=[r14] + ;; + mov b6=r15 + br.call.sptk.many b0=b6 + ;; +.ret0: cmp4.ge p6,p7=r8,r0 + mov ar.pfs=loc1 // restore ar.pfs + sxt4 r8=r8 // return 64-bit result + ;; + stf.spill [sp]=f0 +(p6) cmp.ne pKern,pUser=r0,r0 // a successful execve() lands us in user-mode... + mov gp=loc2 + mov rp=loc0 +(p6) mov ar.pfs=r0 // clear ar.pfs on success +(p7) br.ret.sptk.many rp + + /* + * In theory, we'd have to zap this state only to prevent leaking of + * security sensitive state (e.g., if current->mm->dumpable is zero). However, + * this executes in less than 20 cycles even on Itanium, so it's not worth + * optimizing for...). + */ + mov r4=0; mov f2=f0; mov b1=r0 + mov r5=0; mov f3=f0; mov b2=r0 + mov r6=0; mov f4=f0; mov b3=r0 + mov r7=0; mov f5=f0; mov b4=r0 + mov ar.unat=0; mov f10=f0; mov b5=r0 + ldf.fill f11=[sp]; ldf.fill f12=[sp]; mov f13=f0 + ldf.fill f14=[sp]; ldf.fill f15=[sp]; mov f16=f0 + ldf.fill f17=[sp]; ldf.fill f18=[sp]; mov f19=f0 + ldf.fill f20=[sp]; ldf.fill f21=[sp]; mov f22=f0 + ldf.fill f23=[sp]; ldf.fill f24=[sp]; mov f25=f0 + ldf.fill f26=[sp]; ldf.fill f27=[sp]; mov f28=f0 + ldf.fill f29=[sp]; ldf.fill f30=[sp]; mov f31=f0 + mov ar.lc=0 + br.ret.sptk.many rp + .align 16 +.fptr_execve: + data8 @fptr(my_sys_execve) +END(my_ia64_execve) + +/* These interceptors are from IA64syscallstub.h macros */ +#include "IA64syscallstub.h" + +SYSCALLSTUB_POST(clone) + +SYSCALLSTUB_POST(clone2) + +SYSCALLSTUB_POST(mmap) + +SYSCALLSTUB_POST(mmap2) + +SYSCALLSTUB_POST(init_module) + +SYSCALLSTUB_PRE(exit) diff --git a/module/op_cache.h b/module/op_cache.h new file mode 100644 index 0000000..4fd772a --- /dev/null +++ b/module/op_cache.h @@ -0,0 +1,57 @@ +/** + * @file op_cache.h + * Cache definitions for compatibility + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef OP_CACHE_H +#define OP_CACHE_H + +#include + +#ifndef L1_CACHE_ALIGN +#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1)) +#endif + +#ifndef SMP_CACHE_BYTES +#define SMP_CACHE_BYTES L1_CACHE_BYTES +#endif + +/* 2.4.0 introduced __cacheline_aligned */ +#ifndef ____cacheline_aligned +#define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES))) +#endif + +#ifndef __cacheline_aligned +#ifdef MODULE +#define __cacheline_aligned ____cacheline_aligned +#else +#define __cacheline_aligned \ + __attribute__((__aligned__(SMP_CACHE_BYTES), \ + __section__(".data.cacheline_aligned"))) +#endif +#endif /* __cacheline_aligned */ + +/* 2.4.10 introduced ___cacheline_aligned_in_smp */ +#ifndef ____cacheline_aligned_in_smp +#ifdef CONFIG_SMP +#define ____cacheline_aligned_in_smp ____cacheline_aligned +#else +#define ____cacheline_aligned_in_smp +#endif /* CONFIG_SMP */ +#endif + +#ifndef __cacheline_aligned_in_smp +#ifdef CONFIG_SMP +#define __cacheline_aligned_in_smp __cacheline_aligned +#else +#define __cacheline_aligned_in_smp +#endif /* CONFIG_SMP */ +#endif + +#endif /* !OP_CACHE_H */ diff --git a/module/op_dcache.h b/module/op_dcache.h new file mode 100644 index 0000000..ffa0a1a --- /dev/null +++ b/module/op_dcache.h @@ -0,0 +1,87 @@ +/** + * @file op_dcache.h + * Compatibility functions for dcache lookups + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef OP_DCACHE_H +#define OP_DCACHE_H + +#include +#include +#include +#include + +#include "oprofile.h" + +extern uint op_dname_top; +extern struct qstr **op_dname_stack; +extern char * op_pool_pos; +extern char * op_pool_start; +extern char * op_pool_end; + +uint do_hash(struct dentry *dentry, struct vfsmount *vfsmnt, struct dentry *root, struct vfsmount *rootmnt); + +inline static uint alloc_in_pool(char const * str, uint len); +inline static int add_hash_entry(struct op_hash_index * entry, uint parent, char const * name, uint len); +inline static uint name_hash(char const * name, uint len, uint parent); + +inline static uint name_hash(char const * name, uint len, uint parent) +{ + uint hash=0; + + while (len--) + hash = (hash + (name[len] << 4) + (name[len] >> 4)) * 11; + + return (hash ^ parent) % OP_HASH_MAP_NR; +} + +/* empty ascending dname stack */ +inline static void push_dname(struct qstr *dname) +{ + op_dname_stack[op_dname_top] = dname; + if (op_dname_top != DNAME_STACK_MAX) + op_dname_top++; + else + printk(KERN_ERR "oprofile: overflowed dname stack !\n"); +} + +inline static struct qstr *pop_dname(void) +{ + if (op_dname_top == 0) + return NULL; + + return op_dname_stack[--op_dname_top]; +} + +inline static uint alloc_in_pool(char const * str, uint len) +{ + char * place = op_pool_pos; + if (op_pool_pos + len + 1 >= op_pool_end) + return 0; + + strcpy(place, str); + op_pool_pos += len + 1; + return place - op_pool_start; +} + +inline static char * get_from_pool(uint index) +{ + return op_pool_start + index; +} + +inline static int add_hash_entry(struct op_hash_index * entry, uint parent, char const * name, uint len) +{ + entry->name = alloc_in_pool(name, len); + if (!entry->name) + return -1; + entry->parent = parent; + return 0; +} + +#endif /* OP_DCACHE_H */ diff --git a/module/op_dname.c b/module/op_dname.c new file mode 100644 index 0000000..390d7b7 --- /dev/null +++ b/module/op_dname.c @@ -0,0 +1,227 @@ +/** + * @file op_dname.c + * dentry stack walking + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include +#include + +#include "oprofile.h" +#include "op_dcache.h" +#include "op_util.h" + +/* --------- device routines ------------- */ + +uint op_dname_top; +struct qstr ** op_dname_stack; +char * op_pool_pos; +char * op_pool_start; +char * op_pool_end; + +static ulong hash_map_open; +static struct op_hash_index * hash_map; + +unsigned long is_map_ready(void) +{ + return hash_map_open; +} + +int oprof_init_hashmap(void) +{ + uint i; + + op_dname_stack = kmalloc(DNAME_STACK_MAX * sizeof(struct qstr *), GFP_KERNEL); + if (!op_dname_stack) + return -EFAULT; + op_dname_top = 0; + memset(op_dname_stack, 0, DNAME_STACK_MAX * sizeof(struct qstr *)); + + hash_map = rvmalloc(PAGE_ALIGN(OP_HASH_MAP_SIZE)); + if (!hash_map) + return -EFAULT; + + for (i = 0; i < OP_HASH_MAP_NR; ++i) { + hash_map[i].name = 0; + hash_map[i].parent = -1; + } + + op_pool_start = (char *)(hash_map + OP_HASH_MAP_NR); + op_pool_end = op_pool_start + POOL_SIZE; + op_pool_pos = op_pool_start; + + /* Ensure that the zero hash map entry is never used, we use this + * value as end of path terminator */ + hash_map[0].name = alloc_in_pool("/", 1); + hash_map[0].parent = 0; + + return 0; +} + +void oprof_free_hashmap(void) +{ + kfree(op_dname_stack); + rvfree(hash_map, PAGE_ALIGN(OP_HASH_MAP_SIZE)); +} + +int oprof_hash_map_open(void) +{ + if (test_and_set_bit(0, &hash_map_open)) + return -EBUSY; + + return 0; +} + +int oprof_hash_map_release(void) +{ + if (!hash_map_open) + return -EFAULT; + + clear_bit(0,&hash_map_open); + return 0; +} + +int oprof_hash_map_mmap(struct file * file, struct vm_area_struct * vma) +{ + ulong start = (ulong)vma->vm_start; + ulong page, pos; + ulong size = (ulong)(vma->vm_end-vma->vm_start); + + if (size > PAGE_ALIGN(OP_HASH_MAP_SIZE) || (vma->vm_flags & VM_WRITE) || GET_VM_OFFSET(vma)) + return -EINVAL; + + pos = (ulong)hash_map; + while (size > 0) { + page = kvirt_to_pa(pos); + if (remap_page_range(start, page, PAGE_SIZE, PAGE_SHARED)) + return -EAGAIN; + start += PAGE_SIZE; + pos += PAGE_SIZE; + size -= PAGE_SIZE; + } + return 0; +} + + +#ifndef NEED_2_2_DENTRIES +int wind_dentries_2_4(struct dentry * dentry, struct vfsmount * vfsmnt, struct dentry * root, struct vfsmount * rootmnt) +{ + struct dentry * d = dentry; + struct vfsmount * v = vfsmnt; + + /* wind the dentries onto the stack pages */ + for (;;) { + /* deleted ? */ + if (!IS_ROOT(d) && list_empty(&d->d_hash)) + return 0; + + /* the root */ + if (d == root && v == rootmnt) + break; + + if (d == v->mnt_root || IS_ROOT(d)) { + if (v->mnt_parent == v) + break; + /* cross the mount point */ + d = v->mnt_mountpoint; + v = v->mnt_parent; + } + + push_dname(&d->d_name); + + d = d->d_parent; + } + + return 1; +} + +/* called with note_lock held */ +uint do_path_hash_2_4(struct dentry *dentry, struct vfsmount *vfsmnt) +{ + uint value; + struct vfsmount * rootmnt; + struct dentry * root; + + read_lock(¤t->fs->lock); + rootmnt = mntget(current->fs->rootmnt); + root = dget(current->fs->root); + read_unlock(¤t->fs->lock); + + spin_lock(&dcache_lock); + + value = do_hash(dentry, vfsmnt, root, rootmnt); + + spin_unlock(&dcache_lock); + dput(root); + mntput(rootmnt); + return value; +} +#endif /* NEED_2_2_DENTRIES */ + +/* called with note_lock held */ +uint do_hash(struct dentry * dentry, struct vfsmount * vfsmnt, struct dentry * root, struct vfsmount * rootmnt) +{ + struct qstr * dname; + uint value = -1; + uint firsthash; + uint incr; + uint parent = 0; + struct op_hash_index *entry; + + if (!wind_dentries(dentry, vfsmnt, root, rootmnt)) + goto out; + + /* unwind and hash */ + + while ((dname = pop_dname())) { + /* if N is prime, value in [0-N[ and incr = max(1, value) then + * iteration: value = (value + incr) % N covers the range [0-N[ + * in N iterations */ + incr = firsthash = value = name_hash(dname->name, dname->len, parent); + if (incr == 0) + incr = 1; + + retry: + entry = &hash_map[value]; + /* existing entry ? */ + if (streq(get_from_pool(entry->name), dname->name) + && entry->parent == parent) + goto next; + + /* new entry ? */ + if (entry->parent == -1) { + if (add_hash_entry(entry, parent, dname->name, dname->len)) + goto fullpool; + goto next; + } + + /* nope, find another place in the table */ + value = (value + incr) % OP_HASH_MAP_NR; + + if (value == firsthash) + goto fulltable; + + goto retry; + next: + parent = value; + } + +out: + op_dname_top = 0; + return value; +fullpool: + printk(KERN_ERR "oprofile: string pool exhausted.\n"); + value = -1; + goto out; +fulltable: + printk(KERN_ERR "oprofile: component hash table full :(\n"); + value = -1; + goto out; +} diff --git a/module/op_init.c b/module/op_init.c new file mode 100644 index 0000000..61394fc --- /dev/null +++ b/module/op_init.c @@ -0,0 +1,33 @@ +/** + * @file op_init.c + * Initialisation stubs + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +// FIXME: any point in this file now we don't fiddle +// with -march options ?? + +#undef __NO_VERSION__ + +#include "oprofile.h" + +EXPORT_NO_SYMBOLS; + +int __init stub_init(void) +{ + sysctl.cpu_type = get_cpu_type(); + return oprof_init(); +} + +void __exit stub_exit(void) +{ + oprof_exit(); +} + +module_init(stub_init); +module_exit(stub_exit); diff --git a/module/op_util.c b/module/op_util.c new file mode 100644 index 0000000..8425d75 --- /dev/null +++ b/module/op_util.c @@ -0,0 +1,103 @@ +/** + * @file op_util.c + * Various utility functions + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include + +#include "compat.h" + +#include "op_util.h" + +/* Given PGD from the address space's page table, return the kernel + * virtual mapping of the physical memory mapped at ADR. + */ +static inline unsigned long uvirt_to_kva(pgd_t * pgd, unsigned long adr) +{ + unsigned long ret = 0UL; + pmd_t *pmd; + pte_t *ptep, pte; + + if (!pgd_none(*pgd)) { + pmd = pmd_offset(pgd, adr); + if (!pmd_none(*pmd)) { + ptep = pte_offset(pmd, adr); + pte = *ptep; + if (pte_present(pte)) { + ret = (unsigned long) pte_page_address(pte); + ret |= adr & (PAGE_SIZE - 1); + } + } + } + return ret; +} + +/* Here we want the physical address of the memory. + * This is used when initializing the contents of the + * area and marking the pages as reserved. + */ +unsigned long kvirt_to_pa(unsigned long adr) +{ + unsigned long va, kva, ret; + + va = VMALLOC_VMADDR(adr); + kva = uvirt_to_kva(pgd_offset_k(va), va); + ret = __pa(kva); + return ret; +} + +void * rvmalloc(signed long size) +{ + void * mem; + unsigned long adr, page; + + mem = VMALLOC_32(size); + if (!mem) + return NULL; + + memset(mem, 0, size); + + adr=(unsigned long) mem; + while (size > 0) { + page = kvirt_to_pa(adr); + mem_map_reserve(virt_to_page((unsigned long)__va(page))); + adr += PAGE_SIZE; + size -= PAGE_SIZE; + } + return mem; +} + +void rvfree(void * mem, signed long size) +{ + unsigned long adr, page; + + if (!mem) + return; + + adr=(unsigned long) mem; + while (size > 0) { + page = kvirt_to_pa(adr); + mem_map_unreserve(virt_to_page((unsigned long)__va(page))); + + adr += PAGE_SIZE; + size -= PAGE_SIZE; + } + vfree(mem); +} + +int check_range(int val, int l, int h, char const * msg) +{ + if (val < l || val > h) { + printk(msg, val, l, h); + return -EINVAL; + } + return 0; +} diff --git a/module/op_util.h b/module/op_util.h new file mode 100644 index 0000000..baea40e --- /dev/null +++ b/module/op_util.h @@ -0,0 +1,21 @@ +/** + * @file op_util.h + * Various utility functions + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_UTIL_H +#define OP_UTIL_H + +unsigned long kvirt_to_pa(unsigned long adr); +void * rvmalloc(signed long size); +void rvfree(void * mem, signed long size); +// returns non-zero on failure, inclusive +int check_range(int val, int l, int h, char const * msg); + +#endif /* OP_UTIL_H */ diff --git a/module/oprofile.c b/module/oprofile.c new file mode 100644 index 0000000..20dbb72 --- /dev/null +++ b/module/oprofile.c @@ -0,0 +1,883 @@ +/** + * @file oprofile.c + * Main driver code + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "oprofile.h" +#include "op_util.h" +#include "config.h" + +EXPORT_NO_SYMBOLS; + +MODULE_AUTHOR("John Levon (levon@movementarian.org)"); +MODULE_DESCRIPTION("Continuous Profiling Module"); +MODULE_LICENSE("GPL"); + +MODULE_PARM(allow_unload, "i"); +MODULE_PARM_DESC(allow_unload, "Allow module to be unloaded."); +#ifdef CONFIG_SMP +static int allow_unload; +#else +static int allow_unload = 1; +#endif + +/* sysctl settables */ +struct oprof_sysctl sysctl_parms; +/* some of the sys ctl settable variable needs to be copied to protect + * against user that try to change through /proc/sys/dev/oprofile/ * running + * parameters during profiling */ +struct oprof_sysctl sysctl; + +static enum oprof_state state __cacheline_aligned_in_smp = STOPPED; + +static int op_major; + +static volatile ulong oprof_opened __cacheline_aligned_in_smp; +static volatile ulong oprof_note_opened __cacheline_aligned_in_smp; +static DECLARE_WAIT_QUEUE_HEAD(oprof_wait); + +static u32 oprof_ready[NR_CPUS] __cacheline_aligned_in_smp; +struct _oprof_data oprof_data[NR_CPUS] __cacheline_aligned; + +struct op_note * note_buffer __cacheline_aligned_in_smp; +u32 note_pos __cacheline_aligned_in_smp; + +// the interrupt handler ops structure to use +static struct op_int_operations const * int_ops; + +static char const * op_version = PACKAGE " " VERSION; + +/* ---------------- interrupt entry routines ------------------ */ + +inline static int need_wakeup(uint cpu, struct _oprof_data * data) +{ + return data->nextbuf >= (data->buf_size - data->buf_watermark) && !oprof_ready[cpu]; +} + +inline static void next_sample(struct _oprof_data * data) +{ + if (unlikely(++data->nextbuf == data->buf_size)) + data->nextbuf = 0; +} + +inline static void evict_op_entry(uint cpu, struct _oprof_data * data, long irq_enabled) +{ + next_sample(data); + if (likely(!need_wakeup(cpu, data))) + return; + + /* locking rationale : + * + * other CPUs are not a race concern since we synch on oprof_wait->lock. + * + * for the current CPU, we might have interrupted another user of e.g. + * runqueue_lock, deadlocking on SMP and racing on UP. So we check that IRQs + * were not disabled (corresponding to the irqsave/restores in __wake_up(). + * + * Note that this requires all spinlocks taken by the full wake_up path + * to have saved IRQs - otherwise we can interrupt whilst holding a spinlock + * taken from some non-wake_up() path and deadlock. Currently this means only + * oprof_wait->lock and runqueue_lock: all instances disable IRQs before + * taking the lock. + * + * This will mean that approaching the end of the buffer, a number of the + * evictions may fail to wake up the daemon. We simply hope this doesn't + * take long; a pathological case could cause buffer overflow. + * + * Note that we use oprof_ready as our flag for whether we have initiated a + * wake-up. Once the wake-up is received, the flag is reset as well as + * data->nextbuf, preventing multiple wakeups. + * + * On 2.2, a global waitqueue_lock is used, so we must check it's not held + * by the current CPU. We make sure that any users of the wait queue (i.e. + * us and the code for wait_event_interruptible()) disable interrupts so it's + * still safe to check IF_MASK. + */ + if (likely(irq_enabled)) { + oprof_ready[cpu] = 1; + wake_up(&oprof_wait); + } +} + +inline static void +fill_op_entry(struct op_sample * ops, long eip, pid_t pid, pid_t tgid, int ctr) +{ + ops->eip = eip; + ops->pid = pid; + ops->tgid = tgid; + ops->counter = ctr; +} + +void fastcall op_do_profile(uint cpu, long eip, long irq_enabled, int ctr) +{ + struct _oprof_data * data = &oprof_data[cpu]; + pid_t const pid = current->pid; + pid_t const tgid = op_get_tgid(); + struct op_sample * samples = &data->buffer[data->nextbuf]; + + data->nr_irq++; + + fill_op_entry(samples, eip, pid, tgid, ctr); + evict_op_entry(cpu, data, irq_enabled); +} + +/* ---------------- driver routines ------------------ */ + +/* only stop and start profiling interrupt when we are + * fully running ! + */ +static void stop_cpu_perfctr(int cpu) +{ + if (state == RUNNING) + int_ops->stop_cpu(cpu); +} + +static void start_cpu_perfctr(int cpu) +{ + if (state == RUNNING) + int_ops->start_cpu(cpu); +} + +spinlock_t note_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; +/* which buffer nr. is waiting to be read ? */ +int cpu_buffer_waiting; + +static int is_ready(void) +{ + uint cpu_nr; + for (cpu_nr = 0 ; cpu_nr < smp_num_cpus; cpu_nr++) { + if (oprof_ready[cpu_nr]) { + cpu_buffer_waiting = cpu_nr; + return 1; + } + } + return 0; +} + +inline static void up_and_check_note(void) +{ + note_pos++; + if (likely(note_pos < (sysctl.note_size - OP_PRE_NOTE_WATERMARK(sysctl.note_size)) && !is_ready())) + return; + + /* if we reach the end of the buffer, just pin + * to the last entry until it is read. This loses + * notes, but we have no choice. */ + if (unlikely(note_pos == sysctl.note_size)) { + static int warned; + if (!warned) { + printk(KERN_WARNING "note buffer overflow: restart " + "oprofile with a larger note buffer.\n"); + warned = 1; + } + sysctl.nr_note_buffer_overflow++; + note_pos = sysctl.note_size - 1; + } + + /* we just use cpu 0 as a convenient one to wake up */ + oprof_ready[0] = 2; + oprof_wake_up(&oprof_wait); +} + +/* if holding note_lock */ +void __oprof_put_note(struct op_note * onote) +{ + /* ignore note if we're not up and running fully */ + if (state != RUNNING) + return; + + memcpy(¬e_buffer[note_pos], onote, sizeof(struct op_note)); + up_and_check_note(); +} + +void oprof_put_note(struct op_note * onote) +{ + spin_lock(¬e_lock); + __oprof_put_note(onote); + spin_unlock(¬e_lock); +} + +static ssize_t oprof_note_read(char * buf, size_t count, loff_t * ppos) +{ + struct op_note * mybuf; + uint num; + ssize_t max; + + max = sizeof(struct op_note) * sysctl.note_size; + + if (*ppos || count != max) + return -EINVAL; + + mybuf = vmalloc(max); + if (!mybuf) + return -EFAULT; + + spin_lock(¬e_lock); + + num = note_pos; + + count = note_pos * sizeof(struct op_note); + + if (count) + memcpy(mybuf, note_buffer, count); + + note_pos = 0; + + spin_unlock(¬e_lock); + + if (count && copy_to_user(buf, mybuf, count)) + count = -EFAULT; + + vfree(mybuf); + return count; +} + +static int oprof_note_open(void) +{ + if (test_and_set_bit(0, &oprof_note_opened)) + return -EBUSY; + INC_USE_COUNT_MAYBE; + return 0; +} + +static int oprof_note_release(void) +{ + BUG_ON(!oprof_note_opened); + clear_bit(0, &oprof_note_opened); + DEC_USE_COUNT_MAYBE; + return 0; +} + +static int check_buffer_amount(int cpu_nr) +{ + struct _oprof_data * data = &oprof_data[cpu_nr]; + int size = data->buf_size; + int num = data->nextbuf; + if (num < size - data->buf_watermark && oprof_ready[cpu_nr] != 2) { + printk(KERN_WARNING "oprofile: Detected overflow of size %d. " + "You must increase the module buffer size with\n" + "opcontrol --setup --bufer-size= or reduce the " + "interrupt frequency\n", num); + data->nr_buffer_overflow += num; + num = size; + } else + data->nextbuf = 0; + return num; +} + +static int copy_buffer(char * buf, int cpu_nr) +{ + struct op_buffer_head head; + int ret = -EFAULT; + + stop_cpu_perfctr(cpu_nr); + + head.cpu_nr = cpu_nr; + head.count = check_buffer_amount(cpu_nr); + head.state = state; + + oprof_ready[cpu_nr] = 0; + + if (copy_to_user(buf, &head, sizeof(struct op_buffer_head))) + goto out; + + if (head.count) { + size_t const size = head.count * sizeof(struct op_sample); + if (copy_to_user(buf + sizeof(struct op_buffer_head), + oprof_data[cpu_nr].buffer, size)) + goto out; + ret = size + sizeof(struct op_buffer_head); + } else { + ret = sizeof(struct op_buffer_head); + } + +out: + start_cpu_perfctr(cpu_nr); + return ret; +} + +static ssize_t oprof_read(struct file * file, char * buf, size_t count, loff_t * ppos) +{ + ssize_t max; + + if (!capable(CAP_SYS_PTRACE)) + return -EPERM; + + switch (MINOR(file->f_dentry->d_inode->i_rdev)) { + case 2: return oprof_note_read(buf, count, ppos); + case 0: break; + default: return -EINVAL; + } + + max = sizeof(struct op_buffer_head) + sizeof(struct op_sample) * sysctl.buf_size; + + if (*ppos || count != max) + return -EINVAL; + + switch (state) { + case RUNNING: + wait_event_interruptible(oprof_wait, is_ready()); + if (signal_pending(current)) + return -EINTR; + break; + + /* Non-obvious. If O_NONBLOCK is set, that means + * the daemon knows it has to quit and is asking + * for final buffer data. If it's not set, then we + * have just transitioned to STOPPING, and we must + * inform the daemon (which we can do just by a normal + * operation). + */ + case STOPPING: { + int cpu; + + if (!(file->f_flags & O_NONBLOCK)) + break; + + for (cpu = 0; cpu < smp_num_cpus; ++cpu) { + if (oprof_data[cpu].nextbuf) { + cpu_buffer_waiting = cpu; + oprof_ready[cpu] = 2; + break; + } + } + + if (cpu == smp_num_cpus) + return -EAGAIN; + + } + break; + + case STOPPED: BUG(); + } + + return copy_buffer(buf, cpu_buffer_waiting); +} + + +static int oprof_start(void); +static int oprof_stop(void); + +static int oprof_open(struct inode * ino, struct file * file) +{ + int err; + + if (!capable(CAP_SYS_PTRACE)) + return -EPERM; + + switch (MINOR(file->f_dentry->d_inode->i_rdev)) { + case 1: return oprof_hash_map_open(); + case 2: return oprof_note_open(); + case 0: + /* make sure the other devices are open */ + if (is_map_ready()) + break; + default: + return -EINVAL; + } + + if (test_and_set_bit(0, &oprof_opened)) + return -EBUSY; + + err = oprof_start(); + if (err) + clear_bit(0, &oprof_opened); + return err; +} + +static int oprof_release(struct inode * ino, struct file * file) +{ + switch (MINOR(file->f_dentry->d_inode->i_rdev)) { + case 1: return oprof_hash_map_release(); + case 2: return oprof_note_release(); + case 0: break; + default: return -EINVAL; + } + + BUG_ON(!oprof_opened); + + clear_bit(0, &oprof_opened); + + // FIXME: is this safe when I kill -9 the daemon ? + return oprof_stop(); +} + +static int oprof_mmap(struct file * file, struct vm_area_struct * vma) +{ + if (MINOR(file->f_dentry->d_inode->i_rdev) == 1) + return oprof_hash_map_mmap(file, vma); + return -EINVAL; +} + +/* called under spinlock, cannot sleep */ +static void oprof_free_mem(uint num) +{ + uint i; + for (i=0; i < num; i++) { + if (oprof_data[i].buffer) + vfree(oprof_data[i].buffer); + oprof_data[i].buffer = NULL; + } + vfree(note_buffer); + note_buffer = NULL; +} + +static int oprof_init_data(void) +{ + uint i, notebufsize; + ulong buf_size; + struct _oprof_data * data; + + sysctl.nr_note_buffer_overflow = 0; + notebufsize = sizeof(struct op_note) * sysctl.note_size; + note_buffer = vmalloc(notebufsize); + if (!note_buffer) { + printk(KERN_ERR "oprofile: failed to allocate note buffer of %u bytes\n", + notebufsize); + return -EFAULT; + } + note_pos = 0; + + // safe init + for (i = 0; i < smp_num_cpus; ++i) { + data = &oprof_data[i]; + data->buf_size = 0; + data->buffer = 0; + data->buf_watermark = 0; + data->nr_buffer_overflow = 0; + } + + buf_size = (sizeof(struct op_sample) * sysctl.buf_size); + + for (i = 0 ; i < smp_num_cpus ; ++i) { + data = &oprof_data[i]; + + data->buffer = vmalloc(buf_size); + if (!data->buffer) { + printk(KERN_ERR "oprofile: failed to allocate eviction buffer of %lu bytes\n",buf_size); + oprof_free_mem(i); + return -EFAULT; + } + + memset(data->buffer, 0, buf_size); + + data->buf_size = sysctl.buf_size; + data->buf_watermark = OP_PRE_WATERMARK(data->buf_size); + data->nextbuf = 0; + } + + return 0; +} + +static int parms_check(void) +{ + int err; + + if ((err = check_range(sysctl.buf_size, OP_MIN_BUF_SIZE, OP_MAX_BUF_SIZE, + "sysctl.buf_size value %d not in range (%d %d)\n"))) + return err; + if ((err = check_range(sysctl.note_size, OP_MIN_NOTE_TABLE_SIZE, OP_MAX_NOTE_TABLE_SIZE, + "sysctl.note_size value %d not in range (%d %d)\n"))) + return err; + + if ((err = int_ops->check_params())) + return err; + + return 0; +} + + +static DECLARE_MUTEX(sysctlsem); + + +static int oprof_start(void) +{ + int err = 0; + + down(&sysctlsem); + + /* save the sysctl settable things to protect against change through + * systcl the profiler params */ + sysctl_parms.cpu_type = sysctl.cpu_type; + sysctl = sysctl_parms; + + if ((err = oprof_init_data())) + goto out; + + if ((err = parms_check())) { + oprof_free_mem(smp_num_cpus); + goto out; + } + + if ((err = int_ops->setup())) { + oprof_free_mem(smp_num_cpus); + goto out; + } + + op_intercept_syscalls(); + + int_ops->start(); + + state = RUNNING; + +out: + up(&sysctlsem); + return err; +} + +/* + * stop interrupts being generated and notes arriving. + * This is idempotent. + */ +static void oprof_partial_stop(void) +{ + BUG_ON(state == STOPPED); + + if (state == RUNNING) { + op_restore_syscalls(); + int_ops->stop(); + } + + state = STOPPING; +} + +static int oprof_stop(void) +{ + uint i; + // FIXME: err not needed + int err = -EINVAL; + + down(&sysctlsem); + + BUG_ON(state == STOPPED); + + /* here we need to : + * bring back the old system calls + * stop the perf counter + * bring back the old NMI handler + * reset the map buffer stuff and ready values + * + * Nothing will be able to write into the map buffer because + * we synchronise via the spinlocks + */ + + oprof_partial_stop(); + + spin_lock(¬e_lock); + + for (i = 0 ; i < smp_num_cpus; i++) { + struct _oprof_data * data = &oprof_data[i]; + oprof_ready[i] = 0; + data->nextbuf = 0; + } + + oprof_free_mem(smp_num_cpus); + + spin_unlock(¬e_lock); + err = 0; + + /* FIXME: can we really say this ? */ + state = STOPPED; + up(&sysctlsem); + return err; +} + +static struct file_operations oprof_fops = { +#ifdef HAVE_FILE_OPERATIONS_OWNER + owner: THIS_MODULE, +#endif + open: oprof_open, + release: oprof_release, + read: oprof_read, + mmap: oprof_mmap, +}; + +/* + * /proc/sys/dev/oprofile/ + * bufsize + * notesize + * dump + * dump_stop + * nr_interrupts + * #ctr/ + * event + * enabled + * count + * unit_mask + * kernel + * user + * + * #ctr is in [0-1] for PPro core, [0-3] for Athlon core + * + */ + +/* These access routines are basically not safe on SMP for module unload. + * And there is nothing we can do about it - the API is broken. We'll just + * make a best-efforts thing. Note the sem is needed to prevent parms_check + * bypassing during oprof_start(). + */ + +static void lock_sysctl(void) +{ + MOD_INC_USE_COUNT; + down(&sysctlsem); +} + +static void unlock_sysctl(void) +{ + up(&sysctlsem); + MOD_DEC_USE_COUNT; +} + +static int get_nr_interrupts(ctl_table * table, int write, struct file * filp, void * buffer, size_t * lenp) +{ + uint cpu; + int ret = -EINVAL; + + lock_sysctl(); + + if (write) + goto out; + + sysctl.nr_interrupts = 0; + + for (cpu = 0 ; cpu < smp_num_cpus; cpu++) { + sysctl.nr_interrupts += oprof_data[cpu].nr_irq; + oprof_data[cpu].nr_irq = 0; + } + + ret = proc_dointvec(table, write, filp, buffer, lenp); +out: + unlock_sysctl(); + return ret; +} + +static int get_nr_buffer_overflow(ctl_table * table, int write, struct file * filp, void * buffer, size_t * lenp) +{ + uint cpu; + int ret = -EINVAL; + + lock_sysctl(); + + if (write) + goto out; + + for (cpu = 0 ; cpu < smp_num_cpus; cpu++) { + sysctl.nr_buffer_overflow += oprof_data[cpu].nr_buffer_overflow; + oprof_data[cpu].nr_buffer_overflow = 0; + } + + ret = proc_dointvec(table, write, filp, buffer, lenp); +out: + unlock_sysctl(); + return ret; +} + +int lproc_dointvec(ctl_table * table, int write, struct file * filp, void * buffer, size_t * lenp) +{ + int err; + + lock_sysctl(); + err = proc_dointvec(table, write, filp, buffer, lenp); + unlock_sysctl(); + + return err; +} + +static void do_actual_dump(void) +{ + uint cpu; + + for (cpu = 0 ; cpu < smp_num_cpus; cpu++) { + oprof_ready[cpu] = 2; + } + oprof_wake_up(&oprof_wait); +} + +static int sysctl_do_dump(ctl_table * table, int write, struct file * filp, void * buffer, size_t * lenp) +{ + int err = -EINVAL; + + lock_sysctl(); + + if (state != RUNNING) + goto out; + + if (!write) { + err = proc_dointvec(table, write, filp, buffer, lenp); + goto out; + } + + do_actual_dump(); + + err = 0; +out: + unlock_sysctl(); + return err; +} + +static int sysctl_do_dump_stop(ctl_table * table, int write, struct file * filp, void * buffer, size_t * lenp) +{ + int err = -EINVAL; + + lock_sysctl(); + + if (state != RUNNING) + goto out; + + if (!write) { + err = proc_dointvec(table, write, filp, buffer, lenp); + goto out; + } + + oprof_partial_stop(); + + /* also wakes up daemon */ + do_actual_dump(); + + err = 0; +out: + unlock_sysctl(); + return err; +} + +static int const nr_oprof_static = 8; + +static ctl_table oprof_table[] = { + { 1, "bufsize", &sysctl_parms.buf_size, sizeof(int), 0644, NULL, &lproc_dointvec, NULL, }, + { 1, "dump", &sysctl_parms.dump, sizeof(int), 0666, NULL, &sysctl_do_dump, NULL, }, + { 1, "dump_stop", &sysctl_parms.dump_stop, sizeof(int), 0644, NULL, &sysctl_do_dump_stop, NULL, }, + { 1, "nr_interrupts", &sysctl.nr_interrupts, sizeof(int), 0444, NULL, &get_nr_interrupts, NULL, }, + { 1, "notesize", &sysctl_parms.note_size, sizeof(int), 0644, NULL, &lproc_dointvec, NULL, }, + { 1, "cpu_type", &sysctl.cpu_type, sizeof(int), 0444, NULL, &lproc_dointvec, NULL, }, + { 1, "note_buffer_overflow", &sysctl.nr_note_buffer_overflow, sizeof(int), 0444, NULL, &lproc_dointvec, NULL, }, + { 1, "buffer_overflow", &sysctl.nr_buffer_overflow, sizeof(int), 0444, NULL, &get_nr_buffer_overflow, NULL, }, + { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, { 0, }, + { 0, }, +}; + +static ctl_table oprof_root[] = { + {1, "oprofile", NULL, 0, 0755, oprof_table}, + {0,}, +}; + +static ctl_table dev_root[] = { + {CTL_DEV, "dev", NULL, 0, 0555, oprof_root}, + {0,}, +}; + +static struct ctl_table_header * sysctl_header; + +/* NOTE: we do *not* support sysctl() syscall */ + +static int __init init_sysctl(void) +{ + int err = 0; + ctl_table * next = &oprof_table[nr_oprof_static]; + + /* these sysctl parms need sensible value */ + sysctl_parms.buf_size = OP_DEFAULT_BUF_SIZE; + sysctl_parms.note_size = OP_DEFAULT_NOTE_SIZE; + + if ((err = int_ops->add_sysctls(next))) { + return err; + } + + sysctl_header = register_sysctl_table(dev_root, 0); + return err; +} + +/* not safe to mark as __exit since used from __init code */ +static void cleanup_sysctl(void) +{ + ctl_table * next = &oprof_table[nr_oprof_static]; + unregister_sysctl_table(sysctl_header); + + int_ops->remove_sysctls(next); + + return; +} + +static int can_unload(void) +{ + int can = -EBUSY; + down(&sysctlsem); + + if (allow_unload && state == STOPPED && !GET_USE_COUNT(THIS_MODULE)) + can = 0; + up(&sysctlsem); + return can; +} + +int __init oprof_init(void) +{ + int err = 0; + + if (sysctl.cpu_type != CPU_RTC) { + int_ops = op_int_interface(); + + // try to init, fall back to rtc if not + if ((err = int_ops->init())) { + int_ops = &op_rtc_ops; + if ((err = int_ops->init())) { + return err; + } + sysctl.cpu_type = CPU_RTC; + } + } else { + int_ops = &op_rtc_ops; + if ((err = int_ops->init())) + return err; + } + + if ((err = init_sysctl())) + goto out_err; + + err = op_major = register_chrdev(0, "oprof", &oprof_fops); + if (err < 0) + goto out_err2; + + err = oprof_init_hashmap(); + if (err < 0) { + printk(KERN_ERR "oprofile: couldn't allocate hash map !\n"); + unregister_chrdev(op_major, "oprof"); + goto out_err2; + } + + /* module might not be unloadable */ + THIS_MODULE->can_unload = can_unload; + + /* do this now so we don't have to track save/restores later */ + op_save_syscalls(); + + printk(KERN_INFO "%s loaded, major %u\n", op_version, op_major); + return 0; + +out_err2: + cleanup_sysctl(); +out_err: + int_ops->deinit(); + return err; +} + +void __exit oprof_exit(void) +{ + oprof_free_hashmap(); + + unregister_chrdev(op_major, "oprof"); + + cleanup_sysctl(); + + int_ops->deinit(); +} + +/* + * "The most valuable commodity I know of is information." + * - Gordon Gekko + */ diff --git a/module/oprofile.h b/module/oprofile.h new file mode 100644 index 0000000..cd74424 --- /dev/null +++ b/module/oprofile.h @@ -0,0 +1,161 @@ +/** + * @file oprofile.h + * Main driver code + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPROFILE_H +#define OPROFILE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "compat.h" + +#include "op_config_24.h" +#include "op_hw_config.h" +#include "op_interface.h" +#include "op_cpu_type.h" + +#undef min +#undef max + +#define streq(a, b) (!strcmp((a), (b))) + +/* per-cpu dynamic data */ +struct _oprof_data { + /* eviction buffer */ + struct op_sample * buffer; + /* nr. in buffer */ + uint buf_size; + /* we try to wakeup when nextbuf >= buf_watermark */ + uint buf_watermark; + /* next in buffer (atomic) */ + uint nextbuf; + /* number of IRQs for this CPU */ + uint nr_irq; + /* buffer overflow cumulated size */ + uint nr_buffer_overflow; + /* reset counter values */ + uint ctr_count[OP_MAX_COUNTERS]; +}; + +/* reflect /proc/sys/dev/oprofile/#counter files */ +struct oprof_counter { + int count; + int enabled; + int event; + int kernel; + int user; + int unit_mask; +}; + +/* reflect /proc/sys/dev/oprofile files */ +struct oprof_sysctl { + /* nr. in eviction buffser */ + int buf_size; + /* sysctl dump */ + int dump; + /* dump and stop */ + int dump_stop; + /* nr. in note buffer */ + int note_size; + /* nr. interrupts occured */ + int nr_interrupts; + /* the cpu core type: CPU_PPRO, CPU_PII ... */ + int cpu_type; + /* nr note buffer overflow */ + int nr_note_buffer_overflow; + /* nr buffer overflow */ + int nr_buffer_overflow; + /* counter setup */ + struct oprof_counter ctr[OP_MAX_COUNTERS]; +}; + +/** + * A interrupt handler must implement these routines. + * When an interrupt arrives, it must eventually call + * op_do_profile(). + */ +struct op_int_operations { + /* initialise the interrupt handler on module load. + * On failure deinit handler is not called so all resources + * allocated by init() must be freed before returning an error code + * (or 0 on success) + */ + int (*init)(void); + /* deinitialise on module unload */ + void (*deinit)(void); + /* add any handler-specific sysctls at the position given by @next. Return 0 on success */ + int (*add_sysctls)(ctl_table *next); + /* remove handler-specific sysctls */ + void (*remove_sysctls)(ctl_table *next); + /* check given profiling parameters are correct. Return 0 on success */ + int (*check_params)(void); + /* setup the handler from profiling parameters. Return 0 on success */ + int (*setup)(void); + /* start profiling on all CPUs */ + void (*start)(void); + /* stop profiling on all CPUs */ + void (*stop)(void); + /* start profiling on the given CPU */ + void (*start_cpu)(uint); + /* stop profiling on the given CPU */ + void (*stop_cpu)(uint); +}; + +/* maximum depth of dname trees - this is just a page */ +#define DNAME_STACK_MAX 1024 + +/* oprof_start() copy here the sysctl settable parameters */ +extern struct oprof_sysctl sysctl; + +int oprof_init(void); +void oprof_exit(void); +unsigned long is_map_ready(void); +int oprof_hash_map_open(void); +int oprof_hash_map_release(void); +int oprof_hash_map_mmap(struct file *file, struct vm_area_struct *vma); +int oprof_map_open(void); +int oprof_map_release(void); +int oprof_init_hashmap(void); +void oprof_free_hashmap(void); + +/* used by interrupt handlers if the underlined harware doesn't support + * performance counter */ +extern struct op_int_operations op_rtc_ops; + +void FASTCALL(op_do_profile(uint cpu, long eip, long irq_enabled, int ctr)); +extern struct _oprof_data oprof_data[NR_CPUS]; +extern struct oprof_sysctl sysctl_parms; +extern int lproc_dointvec(ctl_table *table, int write, struct file *filp, void *buffer, size_t *lenp); + +/* functionality provided by the architecture dependent file */ +/* must return OP_RTC if the hardware doesn't support something like + * perf counter */ +op_cpu get_cpu_type(void); +/* return an interface pointer, this function is called only if get_cpu_type + * doesn't return OP_RTC */ +struct op_int_operations const * op_int_interface(void); +/* intercept the needed syscall */ +void op_intercept_syscalls(void); +void op_restore_syscalls(void); +void op_save_syscalls(void); + +#endif /* OPROFILE_H */ diff --git a/module/x86/Makefile.in b/module/x86/Makefile.in new file mode 100644 index 0000000..c5f1833 --- /dev/null +++ b/module/x86/Makefile.in @@ -0,0 +1,28 @@ +OPROFILE_DIR=@OPROFILE_DIR@ +VERSION=@VERSION@ +KVERS=@KVERS@ +KSRC=@KSRC@ + +EXTRA_CFLAGS=@EXTRA_CFLAGS_MODULE@ -D__NO_VERSION__ \ + -I$(OPROFILE_DIR)/ -I$(OPROFILE_DIR)/libutil -I$(OPROFILE_DIR)/libop -I$(OPROFILE_DIR)/module + +USE_STANDARD_AS_RULE=1 + +# NB: do not add a file here without adding it to EXTRA_DIST in ../Makefile.am + +O_TARGET := arch.o + +obj-y := cpu_type.o op_apic.o op_fixmap.o op_rtc.o op_nmi.o \ + op_model_ppro.o op_model_athlon.o op_model_p4.o + +obj-y += oprofile_nmi.o op_syscalls.o + +obj-m := $(O_TARGET) +O_OBJS := $(obj-y) +M_OBJS := $(O_TARGET) + +TOPDIR := $(KSRC) +CONFIG_SHELL := TOPDIR=$(KSRC) /bin/bash +include $(KSRC)/Rules.make + +# FIXME: dependencies diff --git a/module/x86/apic_compat.h b/module/x86/apic_compat.h new file mode 100644 index 0000000..b4b38f3 --- /dev/null +++ b/module/x86/apic_compat.h @@ -0,0 +1,80 @@ +/** + * @file apic_compat.h + * Definitions and functions for APIC interaction + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + * @author John Levon + */ + +#ifndef APIC_COMPAT_H +#define APIC_COMPAT_H + +#if V_BEFORE(2,4,0) +/* even on SMP, some defines are missing in 2.2 */ +#define APIC_LVR 0x30 +#define APIC_LVTPC 0x340 +#define APIC_LVTERR 0x370 +#define GET_APIC_VERSION(x) ((x)&0xFF) +#define GET_APIC_MAXLVT(x) (((x)>>16)&0xFF) +#define APIC_INTEGRATED(x) ((x)&0xF0) +#else +#include +#include +#include +#endif + +#ifndef MSR_IA32_APICBASE +#define MSR_IA32_APICBASE 0x1B +#endif + +#ifndef APIC_SPIV_APIC_ENABLED +#define APIC_SPIV_APIC_ENABLED (1<<8) +#endif + +#ifndef APIC_DEFAULT_PHYS_BASE +#define APIC_DEFAULT_PHYS_BASE 0xfee00000 +#endif + +#if !defined(CONFIG_X86_LOCAL_APIC) + +#define APIC_DEFAULT_PHYS_BASE 0xfee00000 +#define APIC_SPIV 0xF0 +#define APIC_ESR 0x280 +#define APIC_LVTT 0x320 +#define APIC_LVT0 0x350 +#define APIC_LVT_MASKED (1<<16) +#define APIC_LVT_LEVEL_TRIGGER (1<<15) +#define APIC_MODE_NMI 0x4 +#define APIC_MODE_EXINT 0x7 +#define GET_APIC_DELIVERY_MODE(x) (((x)>>8)&0x7) +#define SET_APIC_DELIVERY_MODE(x,y) (((x)&~0x700)|((y)<<8)) +#define APIC_LVT1 0x360 +#define APIC_SEND_PENDING (1<<12) +#define APIC_TDCR 0x3E0 +#define APIC_TDR_DIV_1 0xB + +/* when !CONFIG_X86_LOCAL_APIC we need to provide a valid va to map the + * the pa of APIC onto. This va must be un-cachable/un-swapable*/ +/*#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))*/ +extern unsigned long virt_apic_base; +/* the other define above can be redefined until the ref is identical, this + * allow a compile time checking but this need to be redefined differently */ +#undef APIC_BASE +#define APIC_BASE virt_apic_base + +static __inline void apic_write(unsigned long reg, unsigned long v) +{ + *((volatile u32 *)(APIC_BASE+reg)) = v; +} + +static __inline unsigned long apic_read(unsigned long reg) +{ + return *((volatile u32 *)(APIC_BASE+reg)); +} + +#endif /* !defined(CONFIG_X86_LOCAL_APIC) */ + +#endif /* APIC_COMPAT_H */ diff --git a/module/x86/cpu_type.c b/module/x86/cpu_type.c new file mode 100644 index 0000000..90b2e98 --- /dev/null +++ b/module/x86/cpu_type.c @@ -0,0 +1,188 @@ +/** + * @file cpu_type.c + * CPU determination + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "oprofile.h" +#include "op_msr.h" + +#include + +EXPORT_NO_SYMBOLS; + +MODULE_PARM(force_rtc, "i"); +MODULE_PARM_DESC(force_rtc, "force RTC mode."); +static int force_rtc; + +#ifndef HT_SUPPORT +/** + * p4_threads - determines the number of logical processor threads in a die + * + * returns number of threads in p4 die (1 for non-HT processors) + */ +static int p4_threads(void) +{ + int processor_threads = 1; + +#ifdef CONFIG_SMP + if (test_bit(X86_FEATURE_HT, ¤t_cpu_data.x86_capability)) { + /* This it a Pentium 4 with HT, find number of threads */ + int eax, ebx, ecx, edx; + + cpuid (1, &eax, &ebx, &ecx, &edx); + processor_threads = (ebx >> 16) & 0xff; + } +#endif /* CONFIG_SMP */ + + return processor_threads; +} + +#ifdef CONFIG_SMP +/** + * do_cpu_id - Call the cpuid instruction and fill in data at passed address + * + * We expect that data is pointing to an array of unsigned chars as big as there + * are cpus in an smp system. + */ +static void do_cpu_id(void *data) +{ + int eax, ebx, ecx, edx; + unsigned char * ptr = (unsigned char *) data; + + cpuid(1, &eax, &ebx, &ecx, &edx); + + /* bits EBX[31:24] define APIC ID */ + ptr[smp_processor_id()] = (unsigned char) ((ebx & 0xff000000) >> 24); +} +#endif + +/** + * p4_ht_enabled - Determines if Hyper Threading is enabled or not. + * + * A P4 can be capable of HT, but not enabled via BIOS. The check for + * this is unfortunately not simple and involves running cpuid on all + * logical processors and checking for bits in the APIC_ID fields. + * As per Intel docs. Returns 1 if enabled, 0 otherwise. + * + */ +static int p4_ht_enabled(void) +{ +#ifndef CONFIG_SMP + return 0; +#else + int enabled, threads, i; + unsigned char mask; + unsigned char apic_id[smp_num_cpus]; + unsigned int cpu; + + /* First check for capability */ + threads = p4_threads(); + if (threads == 1) return 0; + /* Create mask for low order bits */ + mask = 0xff; + i = 1; + while (i < threads) { + i *= 2; + mask <<= 1; + } + /* Get APIC_ID from all logial procs and self */ + smp_call_function(do_cpu_id, apic_id, 1, 1); + do_cpu_id(apic_id); + /* If the low order bits are on, then HT is enabled */ + enabled = 0; + cpu = 0; + do { + if (apic_id[cpu] & ~mask) { + enabled = 1; + break; + } + cpu++; + } while (cpu < smp_num_cpus); + + return enabled; +#endif /* CONFIG_SMP */ +} +#endif /* !HT_SUPPORT */ + + +op_cpu p4_cpu_type(void) +{ + __u8 model = current_cpu_data.x86_model; + if (model <= 3) { +#ifdef HT_SUPPORT + if (smp_num_siblings == 1) { + return CPU_P4; + } else if (smp_num_siblings == 2) { + return CPU_P4_HT2; + } else { + printk(KERN_INFO + "oprofile: P4 HT unsupported number of siblings" + "processor, reverting to RTC\n"); + return CPU_RTC; + } +#else + /* Cannot handle enabled HT P4 hardware */ + if ((p4_threads() > 1) && p4_ht_enabled()) { + printk(KERN_INFO + "oprofile: P4 HT enabled, reverting to RTC\n"); + return CPU_RTC; + } + else + return CPU_P4; +#endif + } else + /* Do not know what it is */ + return CPU_RTC; +} + + +__init op_cpu get_cpu_type(void) +{ + __u8 vendor = current_cpu_data.x86_vendor; + __u8 family = current_cpu_data.x86; + __u8 model = current_cpu_data.x86_model; + __u16 val; + + if (force_rtc) + return CPU_RTC; + + switch (vendor) { + case X86_VENDOR_AMD: + if (family == 6) { + /* certain models of K7 does not have apic. + * Check if apic is really present before enabling it. + * IA32 V3, 7.4.1 */ + val = cpuid_edx(1); + if (!(val & (1 << 9))) + return CPU_RTC; + return CPU_ATHLON; + } + if (family == 15) + return CPU_HAMMER; + return CPU_RTC; + + case X86_VENDOR_INTEL: + switch (family) { + default: + return CPU_RTC; + case 6: + /* A P6-class processor */ + if (model > 5) + return CPU_PIII; + else if (model > 2) + return CPU_PII; + return CPU_PPRO; + case 0xf: + return p4_cpu_type(); + } + + default: + return CPU_RTC; + } +} diff --git a/module/x86/op_apic.c b/module/x86/op_apic.c new file mode 100644 index 0000000..7b4ef57 --- /dev/null +++ b/module/x86/op_apic.c @@ -0,0 +1,239 @@ +/** + * @file op_apic.c + * + * APIC setup etc. routines + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + * @author Dave Jones + * @author Graydon Hoare + */ + +#include +#include +#include +#include + +#include "oprofile.h" +#include "op_msr.h" +#include "op_apic.h" + +/* used to save/restore original kernel nmi */ +static struct gate_struct kernel_nmi; +static ulong lvtpc_masked; + +/* this masking code is unsafe and nasty but might deal with the small + * race when installing the NMI entry into the IDT. + */ +static void mask_lvtpc(void * e) +{ + u32 v = apic_read(APIC_LVTPC); + lvtpc_masked = v & APIC_LVT_MASKED; + apic_write(APIC_LVTPC, v | APIC_LVT_MASKED); +} + +static void unmask_lvtpc(void * e) +{ + if (!lvtpc_masked) + apic_write(APIC_LVTPC, apic_read(APIC_LVTPC) & ~APIC_LVT_MASKED); +} + + +void install_nmi(void) +{ + struct _descr descr; + + /* NMI handler is at idt_table[IDT_VECTOR_NUMBER] */ + /* see Intel Vol.3 Figure 5-2, interrupt gate */ + + smp_call_function(mask_lvtpc, NULL, 0, 1); + mask_lvtpc(NULL); + + store_idt(descr); + kernel_nmi = descr.base[NMI_VECTOR_NUM]; + SET_NMI_GATE; + + smp_call_function(unmask_lvtpc, NULL, 0, 1); + unmask_lvtpc(NULL); +} + +void restore_nmi(void) +{ + struct _descr descr; + + smp_call_function(mask_lvtpc, NULL, 0, 1); + mask_lvtpc(NULL); + + store_idt(descr); + descr.base[NMI_VECTOR_NUM] = kernel_nmi; + + smp_call_function(unmask_lvtpc, NULL, 0, 1); + unmask_lvtpc(NULL); +} + + +/* ---------------- APIC setup ------------------ */ +static uint saved_lvtpc[NR_CPUS]; + +void __init lvtpc_apic_setup(void * dummy) +{ + uint val; + + /* set up LVTPC as we need it */ + /* IA32 V3, Figure 7.8 */ + val = apic_read(APIC_LVTPC); + saved_lvtpc[op_cpu_id()] = val; + /* allow PC overflow interrupts */ + val &= ~APIC_LVT_MASKED; + /* set delivery to NMI */ + val = SET_APIC_DELIVERY_MODE(val, APIC_MODE_NMI); + apic_write(APIC_LVTPC, val); +} + +/* not safe to mark as __exit since used from __init code */ +void lvtpc_apic_restore(void * dummy) +{ + /* restoring APIC_LVTPC can trigger an apic error because the delivery + * mode and vector nr combination can be illegal. That's by design: on + * power on apic lvt contain a zero vector nr which are legal only for + * NMI delivrey mode. So inhibit apic err before restoring lvtpc + */ + uint v = apic_read(APIC_LVTERR); + apic_write(APIC_LVTERR, v | APIC_LVT_MASKED); + apic_write(APIC_LVTPC, saved_lvtpc[op_cpu_id()]); + apic_write(APIC_LVTERR, v); +} + +static int __init enable_apic(void) +{ + uint msr_low, msr_high; + uint val; + + /* enable local APIC via MSR. Forgetting this is a fun way to + * lock the box. But we have to hope this is allowed if the APIC + * has already been enabled. + * + * IA32 V3, 7.4.2 */ + rdmsr(MSR_IA32_APICBASE, msr_low, msr_high); + if ((msr_low & (1 << 11)) == 0) + wrmsr(MSR_IA32_APICBASE, msr_low | (1<<11), msr_high); + + /* even if the apic is up we must check for a good APIC */ + + /* IA32 V3, 7.4.15 */ + val = apic_read(APIC_LVR); + if (!APIC_INTEGRATED(GET_APIC_VERSION(val))) + goto not_local_apic; + + /* LVT0,LVT1,LVTT,LVTPC */ + if (GET_APIC_MAXLVT(apic_read(APIC_LVR)) < 4) + goto not_local_apic; + + /* IA32 V3, 7.4.14.1 */ + val = apic_read(APIC_SPIV); + if (!(val & APIC_SPIV_APIC_ENABLED)) + apic_write(APIC_SPIV, val | APIC_SPIV_APIC_ENABLED); + + return !!(val & APIC_SPIV_APIC_ENABLED); + +not_local_apic: + /* disable the apic only if it was disabled */ + if ((msr_low & (1 << 11)) == 0) + wrmsr(MSR_IA32_APICBASE, msr_low & ~(1<<11), msr_high); + + printk(KERN_ERR "oprofile: no suitable local APIC. Falling back to RTC mode.\n"); + return -ENODEV; +} + +static void __init do_apic_setup(void) +{ + uint val; + + local_irq_disable(); + + val = APIC_LVT_LEVEL_TRIGGER; + val = SET_APIC_DELIVERY_MODE(val, APIC_MODE_EXINT); + apic_write(APIC_LVT0, val); + + /* edge triggered, IA 7.4.11 */ + val = SET_APIC_DELIVERY_MODE(0, APIC_MODE_NMI); + apic_write(APIC_LVT1, val); + + /* clear error register */ + /* IA32 V3, 7.4.17 */ + /* PHE must be cleared after unmasking by a back-to-back write, + * but it is probably ok because we mask only, the ESR is not + * updated is this a real problem ? */ + apic_write(APIC_ESR, 0); + + /* mask error interrupt */ + /* IA32 V3, Figure 7.8 */ + val = apic_read(APIC_LVTERR); + val |= APIC_LVT_MASKED; + apic_write(APIC_LVTERR, val); + + /* setup timer vector */ + /* IA32 V3, 7.4.8 */ + apic_write(APIC_LVTT, APIC_SEND_PENDING | 0x31); + + /* Divide configuration register */ + /* PHE the apic clock is based on the FSB. This should only + * changed with a calibration method. */ + val = APIC_TDR_DIV_1; + apic_write(APIC_TDCR, val); + + local_irq_enable(); +} + +/* does the CPU have a local APIC ? */ +static int __init check_cpu_ok(void) +{ + if (sysctl.cpu_type != CPU_PPRO && + sysctl.cpu_type != CPU_PII && + sysctl.cpu_type != CPU_PIII && + sysctl.cpu_type != CPU_ATHLON && + sysctl.cpu_type != CPU_HAMMER && + sysctl.cpu_type != CPU_P4 && + sysctl.cpu_type != CPU_P4_HT2) + return 0; + + return 1; +} + +int __init apic_setup(void) +{ + u32 val; + + if (!check_cpu_ok()) + goto nodev; + + fixmap_setup(); + + switch (enable_apic()) { + case 0: + do_apic_setup(); + val = apic_read(APIC_ESR); + printk(KERN_INFO "oprofile: enabled local APIC. Err code %.08x\n", val); + break; + case 1: + printk(KERN_INFO "oprofile: APIC was already enabled\n"); + break; + default: + goto nodev; + } + + lvtpc_apic_setup(NULL); + return 0; +nodev: + printk(KERN_WARNING "Your CPU does not have a local APIC, e.g. " + "mobile P6. Falling back to RTC mode.\n"); + return -ENODEV; +} + +void apic_restore(void) +{ + fixmap_restore(); +} diff --git a/module/x86/op_apic.h b/module/x86/op_apic.h new file mode 100644 index 0000000..3d3b30a --- /dev/null +++ b/module/x86/op_apic.h @@ -0,0 +1,71 @@ +/** + * @file op_apic.h + * x86 apic, nmi, perf counter declaration + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + * @author Dave Jones + * @author Graydon Hoare + */ + +#ifndef OP_APIC_H +#define OP_APIC_H + +#include "apic_compat.h" + +#define NMI_GATE_TYPE 14 +#define NMI_VECTOR_NUM 2 +#define NMI_DPL_LEVEL 0 + + +/* copied from kernel 2.4.19 : arch/i386/traps.c */ + +struct gate_struct { + u32 a; + u32 b; +} __attribute__((packed)); + +#define _set_gate(gate_addr, type, dpl, addr) \ +do { \ + int __d0, __d1; \ + __asm__ __volatile__ ("movw %%dx, %%ax\n\t" \ + "movw %4, %%dx\n\t" \ + "movl %%eax, %0\n\t" \ + "movl %%edx, %1" \ + :"=m" (*((long *) (gate_addr))), \ + "=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \ + :"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \ + "3" ((char *) (addr)), "2" (__KERNEL_CS << 16)); \ +} while (0) + +#define SET_NMI_GATE \ + _set_gate(&descr.base[NMI_VECTOR_NUM], NMI_GATE_TYPE, NMI_DPL_LEVEL, &op_nmi); + +#define store_idt(addr) \ + do { \ + __asm__ __volatile__ ("sidt %0" \ + : "=m" (addr) \ + : : "memory"); \ + } while (0) + +struct _descr { + u16 limit; + struct gate_struct * base; +} __attribute__((__packed__)); + +void lvtpc_apic_setup(void *dummy); +void lvtpc_apic_restore(void *dummy); +int apic_setup(void); +void apic_restore(void); +void install_nmi(void); +void restore_nmi(void); + +void fixmap_setup(void); +void fixmap_restore(void); + +asmlinkage void op_nmi(void); + +#endif /* OP_APIC_H */ diff --git a/module/x86/op_arch.h b/module/x86/op_arch.h new file mode 100644 index 0000000..9bf41e9 --- /dev/null +++ b/module/x86/op_arch.h @@ -0,0 +1,24 @@ +/** + * @file op_arch.h + * defines registers for x86 + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Will Cohen + */ + +#ifndef OP_ARCH_H +#define OP_ARCH_H + +#include + +/* How to access the processor's instruction pointer */ +#ifndef instruction_pointer +#define instruction_pointer(regs) ((regs)->eip) +#endif + +/* Bit in processor's status register for interrupt masking */ +#define IRQ_ENABLED(regs) ((regs)->eflags & IF_MASK) + +#endif /* OP_ARCH_H */ diff --git a/module/x86/op_fixmap.c b/module/x86/op_fixmap.c new file mode 100644 index 0000000..7bfd572 --- /dev/null +++ b/module/x86/op_fixmap.c @@ -0,0 +1,201 @@ +/** + * @file op_fixmap.c + * Horrible hacks for compatibility's sake. + * Based in part on arch/i386/kernel/mpparse.c + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include +#include +#include + +#include "oprofile.h" +#include "apic_compat.h" + +#ifndef cpu_has_pge +#if V_BEFORE(2, 4, 0) +#define cpu_has_pge (test_bit(X86_FEATURE_PGE, &boot_cpu_data.x86_capability)) +#else +#define cpu_has_pge (test_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability)) +#endif +#endif + +unsigned long virt_apic_base; + +/* some static commented out to avoid warning, trying to figure out + * in exactly which circumstances we need this function is too prone + * error to be made w/o a full rebuild of supported kernel version */ +/* how about __attribute__(__unused__) then ? */ + +/* FIXME is this comment right ? */ +/* We don't take care about locking mm->page_table_lock because this is + * only needed on SMP and on SMP we have already a sensible setup */ + +/*static*/ void set_pte_phys(ulong vaddr, ulong phys) +{ + pgprot_t prot; + pgd_t *pgd; + pmd_t *pmd; + pte_t *pte; + + pgd = pgd_offset_k(vaddr); + pmd = pmd_offset(pgd, vaddr); + pte = pte_offset(pmd, vaddr); + prot = PAGE_KERNEL; + /* when !CONFIG_X86_LOCAL_APIC we can't rely on no cache flag set */ + pgprot_val(prot) |= _PAGE_PCD; + if (cpu_has_pge) + pgprot_val(prot) |= _PAGE_GLOBAL; + set_pte(pte, mk_pte_phys(phys, prot)); + __flush_tlb_one(vaddr); +} + +/*static*/ void alloc_fixmap(void) +{ + /* dirty hack :/ */ + virt_apic_base = (ulong)vmalloc(4096); + set_pte_phys(virt_apic_base, APIC_DEFAULT_PHYS_BASE); +} + +/*static*/ void free_fixmap(void) +{ + ulong vaddr; + pgd_t *pgd; + pmd_t *pmd; + pte_t *pte; + + vaddr = virt_apic_base; + if (!vaddr) + return; + + pgd = pgd_offset_k(vaddr); + if (!pgd) + return; + + pmd = pmd_offset(pgd, vaddr); + if (!pmd) + return; + + pte = pte_offset(pmd, vaddr); + if (!pte) + return; + + /* FIXME: is this the right way */ + pte_clear(pte); + __flush_tlb_one(vaddr); + + vfree((void*)virt_apic_base); +} + +/* + * Make sure we can access the APIC. Some kernel versions create + * a meaningless zero-page mapping for the local APIC: we must + * detect this case and reset it. + * + * Some kernel versions/configs won't map the APIC at all, in + * which case we need to hack it ourselves. + */ +void fixmap_setup(void) +{ +#if V_BEFORE(2,4,10) +#if defined(CONFIG_X86_LOCAL_APIC) + static int find_intel_smp(void); + + if (!find_intel_smp()) { + set_pte_phys(__fix_to_virt(FIX_APIC_BASE), + APIC_DEFAULT_PHYS_BASE); + printk(KERN_INFO "oprofile: remapping local APIC.\n"); + } +#else + alloc_fixmap(); + printk(KERN_INFO "oprofile: mapping APIC.\n"); +#endif /* CONFIG_X86_LOCAL_APIC */ +#else +#if !defined(CONFIG_X86_LOCAL_APIC) + alloc_fixmap(); + printk(KERN_INFO "oprofile: mapping APIC.\n"); +#endif +#endif +} + +void fixmap_restore(void) +{ +#if V_BEFORE(2,4,10) +#if defined(CONFIG_X86_LOCAL_APIC) + /* Nothing to do */ +#else + free_fixmap(); + printk(KERN_INFO "oprofile: freeing APIC mapping.\n"); +#endif /* CONFIG_X86_LOCAL_APIC */ +#else +#if !defined(CONFIG_X86_LOCAL_APIC) + free_fixmap(); + printk(KERN_INFO "oprofile: freeing APIC mapping.\n"); +#endif +#endif +} + +/* ---------------- MP table code ------------------ */ + +#if V_BEFORE(2,4,10) && defined(CONFIG_X86_LOCAL_APIC) + +static int __init mpf_checksum(unsigned char *mp, int len) +{ + int sum = 0; + + while (len--) + sum += *mp++; + + return sum & 0xFF; +} + +static int __init mpf_table_ok(struct intel_mp_floating * mpf, unsigned long *bp) +{ + if (*bp != SMP_MAGIC_IDENT) + return 0; + if (mpf->mpf_length != 1) + return 0; + if (mpf_checksum((unsigned char *)bp, 16)) + return 0; + + return (mpf->mpf_specification == 1 || mpf->mpf_specification == 4); +} + +static int __init smp_scan_config (unsigned long base, unsigned long length) +{ + unsigned long *bp = phys_to_virt(base); + struct intel_mp_floating *mpf; + + while (length > 0) { + mpf = (struct intel_mp_floating *)bp; + if (mpf_table_ok(mpf, bp)) + return 1; + bp += 4; + length -= 16; + } + return 0; +} + +static int __init find_intel_smp(void) +{ + unsigned int address; + + if (smp_scan_config(0x0,0x400) || + smp_scan_config(639*0x400,0x400) || + smp_scan_config(0xF0000,0x10000)) { + return 1; + } + + address = *(unsigned short *)phys_to_virt(0x40E); + address <<= 4; + return smp_scan_config(address, 0x1000); +} + +#endif /* V_BEFORE(2,4,10) && defined(CONFIG_X86_LOCAL_APIC) */ diff --git a/module/x86/op_model_athlon.c b/module/x86/op_model_athlon.c new file mode 100644 index 0000000..a8a1be1 --- /dev/null +++ b/module/x86/op_model_athlon.c @@ -0,0 +1,140 @@ +/** + * @file op_model_athlon.h + * athlon / K7 model-specific MSR operations + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + * @author Graydon Hoare + */ + +#include "op_x86_model.h" +#include "op_arch.h" +#include "op_msr.h" + +#define NUM_COUNTERS 4 +#define NUM_CONTROLS 4 + +#define CTR_READ(l, h, msrs, c) do {rdmsr(msrs->counters.addrs[(c)], (l), (h));} while (0) +#define CTR_WRITE(l, msrs, c) do {wrmsr(msrs->counters.addrs[(c)], -(u32)(l), 0xffff);} while (0) +#define CTR_OVERFLOWED(n) (!((n) & (1U<<31))) + +#define CTRL_READ(l, h, msrs, c) do {rdmsr(msrs->controls.addrs[(c)], (l), (h));} while (0) +#define CTRL_WRITE(l, h, msrs, c) do {wrmsr(msrs->controls.addrs[(c)], (l), (h));} while (0) +#define CTRL_SET_ACTIVE(n) (n |= (1<<22)) +#define CTRL_SET_INACTIVE(n) (n &= ~(1<<22)) +#define CTRL_CLEAR(x) (x &= (1<<21)) +#define CTRL_SET_ENABLE(val) (val |= 1<<20) +#define CTRL_SET_USR(val, u) (val |= ((u & 1) << 16)) +#define CTRL_SET_KERN(val, k) (val |= ((k & 1) << 17)) +#define CTRL_SET_UM(val, m) (val |= (m << 8)) +#define CTRL_SET_EVENT(val, e) (val |= e) + + +static void athlon_fill_in_addresses(struct op_msrs * const msrs) +{ + msrs->counters.addrs[0] = MSR_K7_PERFCTR0; + msrs->counters.addrs[1] = MSR_K7_PERFCTR1; + msrs->counters.addrs[2] = MSR_K7_PERFCTR2; + msrs->counters.addrs[3] = MSR_K7_PERFCTR3; + + msrs->controls.addrs[0] = MSR_K7_EVNTSEL0; + msrs->controls.addrs[1] = MSR_K7_EVNTSEL1; + msrs->controls.addrs[2] = MSR_K7_EVNTSEL2; + msrs->controls.addrs[3] = MSR_K7_EVNTSEL3; +} + + +static void athlon_setup_ctrs(struct op_msrs const * const msrs) +{ + uint low, high; + int i; + + /* clear all counters */ + for (i = 0 ; i < NUM_CONTROLS; ++i) { + CTRL_READ(low, high, msrs, i); + CTRL_CLEAR(low); + CTRL_WRITE(low, high, msrs, i); + } + + /* avoid a false detection of ctr overflows in NMI handler */ + for (i = 0; i < NUM_COUNTERS; ++i) { + CTR_WRITE(1, msrs, i); + } + + /* enable active counters */ + for (i = 0; i < NUM_COUNTERS; ++i) { + if (sysctl.ctr[i].enabled) { + + CTR_WRITE(sysctl.ctr[i].count, msrs, i); + + CTRL_READ(low, high, msrs, i); + CTRL_CLEAR(low); + CTRL_SET_ENABLE(low); + CTRL_SET_USR(low, sysctl.ctr[i].user); + CTRL_SET_KERN(low, sysctl.ctr[i].kernel); + CTRL_SET_UM(low, sysctl.ctr[i].unit_mask); + CTRL_SET_EVENT(low, sysctl.ctr[i].event); + CTRL_WRITE(low, high, msrs, i); + } + } +} + + +static void athlon_check_ctrs(uint const cpu, + struct op_msrs const * const msrs, + struct pt_regs * const regs) +{ + uint low, high; + int i; + for (i = 0 ; i < NUM_COUNTERS; ++i) { + if (sysctl.ctr[i].enabled) { + CTR_READ(low, high, msrs, i); + if (CTR_OVERFLOWED(low)) { + op_do_profile(cpu, instruction_pointer(regs), IRQ_ENABLED(regs), i); + CTR_WRITE(oprof_data[cpu].ctr_count[i], msrs, i); + } + } + } +} + + +static void athlon_start(struct op_msrs const * const msrs) +{ + uint low, high; + int i; + for (i = 0 ; i < NUM_COUNTERS ; ++i) { + if (sysctl.ctr[i].enabled) { + CTRL_READ(low, high, msrs, i); + CTRL_SET_ACTIVE(low); + CTRL_WRITE(low, high, msrs, i); + } + } +} + + +static void athlon_stop(struct op_msrs const * const msrs) +{ + uint low, high; + int i; + for (i = 0 ; i < NUM_COUNTERS ; ++i) { + if (sysctl.ctr[i].enabled) { + CTRL_READ(low, high, msrs, i); + CTRL_SET_INACTIVE(low); + CTRL_WRITE(low, high, msrs, i); + } + } +} + + +struct op_x86_model_spec const op_athlon_spec = { + .num_counters = NUM_COUNTERS, + .num_controls = NUM_CONTROLS, + .fill_in_addresses = &athlon_fill_in_addresses, + .setup_ctrs = &athlon_setup_ctrs, + .check_ctrs = &athlon_check_ctrs, + .start = &athlon_start, + .stop = &athlon_stop +}; diff --git a/module/x86/op_model_p4.c b/module/x86/op_model_p4.c new file mode 100644 index 0000000..9f84019 --- /dev/null +++ b/module/x86/op_model_p4.c @@ -0,0 +1,693 @@ +/** + * @file op_model_p4.c + * P4 model-specific MSR operations + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Graydon Hoare + */ + +#include "op_x86_model.h" +#include "op_msr.h" +#include "op_apic.h" +#include "op_arch.h" + +#define NUM_EVENTS 39 + +#define NUM_COUNTERS_NON_HT 8 +#define NUM_ESCRS_NON_HT 45 +#define NUM_CCCRS_NON_HT 18 +#define NUM_CONTROLS_NON_HT (NUM_ESCRS_NON_HT + NUM_CCCRS_NON_HT) + +#define NUM_COUNTERS_HT2 4 +#define NUM_ESCRS_HT2 23 +#define NUM_CCCRS_HT2 9 +#define NUM_CONTROLS_HT2 (NUM_ESCRS_HT2 + NUM_CCCRS_HT2) + +static unsigned int num_counters = NUM_COUNTERS_NON_HT; + + +/* this has to be checked dynamically since the + hyper-threadedness of a chip is discovered at + kernel boot-time. */ +static inline void setup_num_counters(void) +{ +#ifdef HT_SUPPORT + if (smp_num_siblings == 2) + num_counters = NUM_COUNTERS_HT2; +#endif +} + +static int inline addr_increment(void) +{ +#ifdef HT_SUPPORT + return smp_num_siblings == 2 ? 2 : 1; +#else + return 1; +#endif +} + + +/* tables to simulate simplified hardware view of p4 registers */ +struct p4_counter_binding { + int virt_counter; + int counter_address; + int cccr_address; +}; + +struct p4_event_binding { + int escr_select; /* value to put in CCCR */ + int event_select; /* value to put in ESCR */ + struct { + int virt_counter; /* for this counter... */ + int escr_address; /* use this ESCR */ + } bindings[2]; +}; + +/* nb: these CTR_* defines are a duplicate of defines in + event/i386.p4*events. */ + + +#define CTR_BPU_0 (1 << 0) +#define CTR_MS_0 (1 << 1) +#define CTR_FLAME_0 (1 << 2) +#define CTR_IQ_4 (1 << 3) +#define CTR_BPU_2 (1 << 4) +#define CTR_MS_2 (1 << 5) +#define CTR_FLAME_2 (1 << 6) +#define CTR_IQ_5 (1 << 7) + +static struct p4_counter_binding p4_counters [NUM_COUNTERS_NON_HT] = { + { CTR_BPU_0, MSR_P4_BPU_PERFCTR0, MSR_P4_BPU_CCCR0 }, + { CTR_MS_0, MSR_P4_MS_PERFCTR0, MSR_P4_MS_CCCR0 }, + { CTR_FLAME_0, MSR_P4_FLAME_PERFCTR0, MSR_P4_FLAME_CCCR0 }, + { CTR_IQ_4, MSR_P4_IQ_PERFCTR4, MSR_P4_IQ_CCCR4 }, + { CTR_BPU_2, MSR_P4_BPU_PERFCTR2, MSR_P4_BPU_CCCR2 }, + { CTR_MS_2, MSR_P4_MS_PERFCTR2, MSR_P4_MS_CCCR2 }, + { CTR_FLAME_2, MSR_P4_FLAME_PERFCTR2, MSR_P4_FLAME_CCCR2 }, + { CTR_IQ_5, MSR_P4_IQ_PERFCTR5, MSR_P4_IQ_CCCR5 } +}; + +#define NUM_UNUSED_CCCRS NUM_CCCRS_NON_HT - NUM_COUNTERS_NON_HT + +/* All cccr we don't use. */ +static int p4_unused_cccr[NUM_UNUSED_CCCRS] = { + MSR_P4_BPU_CCCR1, MSR_P4_BPU_CCCR3, + MSR_P4_MS_CCCR1, MSR_P4_MS_CCCR3, + MSR_P4_FLAME_CCCR1, MSR_P4_FLAME_CCCR3, + MSR_P4_IQ_CCCR0, MSR_P4_IQ_CCCR1, + MSR_P4_IQ_CCCR2, MSR_P4_IQ_CCCR3 +}; + +/* p4 event codes in libop/op_event.h are indices into this table. */ + +static struct p4_event_binding p4_events[NUM_EVENTS] = { + + { /* BRANCH_RETIRED */ + 0x05, 0x06, + { {CTR_IQ_4, MSR_P4_CRU_ESCR2}, + {CTR_IQ_5, MSR_P4_CRU_ESCR3} } + }, + + { /* MISPRED_BRANCH_RETIRED */ + 0x04, 0x03, + { { CTR_IQ_4, MSR_P4_CRU_ESCR0}, + { CTR_IQ_5, MSR_P4_CRU_ESCR1} } + }, + + { /* TC_DELIVER_MODE */ + 0x01, 0x01, + { { CTR_MS_0, MSR_P4_TC_ESCR0}, + { CTR_MS_2, MSR_P4_TC_ESCR1} } + }, + + { /* BPU_FETCH_REQUEST */ + 0x00, 0x03, + { { CTR_BPU_0, MSR_P4_BPU_ESCR0}, + { CTR_BPU_2, MSR_P4_BPU_ESCR1} } + }, + + { /* ITLB_REFERENCE */ + 0x03, 0x18, + { { CTR_BPU_0, MSR_P4_ITLB_ESCR0}, + { CTR_BPU_2, MSR_P4_ITLB_ESCR1} } + }, + + { /* MEMORY_CANCEL */ + 0x05, 0x02, + { { CTR_FLAME_0, MSR_P4_DAC_ESCR0}, + { CTR_FLAME_2, MSR_P4_DAC_ESCR1} } + }, + + { /* MEMORY_COMPLETE */ + 0x02, 0x08, + { { CTR_FLAME_0, MSR_P4_SAAT_ESCR0}, + { CTR_FLAME_2, MSR_P4_SAAT_ESCR1} } + }, + + { /* LOAD_PORT_REPLAY */ + 0x02, 0x04, + { { CTR_FLAME_0, MSR_P4_SAAT_ESCR0}, + { CTR_FLAME_2, MSR_P4_SAAT_ESCR1} } + }, + + { /* STORE_PORT_REPLAY */ + 0x02, 0x05, + { { CTR_FLAME_0, MSR_P4_SAAT_ESCR0}, + { CTR_FLAME_2, MSR_P4_SAAT_ESCR1} } + }, + + { /* MOB_LOAD_REPLAY */ + 0x02, 0x03, + { { CTR_BPU_0, MSR_P4_MOB_ESCR0}, + { CTR_BPU_2, MSR_P4_MOB_ESCR1} } + }, + + { /* PAGE_WALK_TYPE */ + 0x04, 0x01, + { { CTR_BPU_0, MSR_P4_PMH_ESCR0}, + { CTR_BPU_2, MSR_P4_PMH_ESCR1} } + }, + + { /* BSQ_CACHE_REFERENCE */ + 0x07, 0x0c, + { { CTR_BPU_0, MSR_P4_BSU_ESCR0}, + { CTR_BPU_2, MSR_P4_BSU_ESCR1} } + }, + + /* intel doc vol 3 table A-1: P4 and xeon with cpuid signature < 0xf27 + * doen't allow MSR_FSB_ESCR1 so only counter 0 is available */ + { /* IOQ_ALLOCATION */ + 0x06, 0x03, + { { CTR_BPU_0, MSR_P4_FSB_ESCR0}, + { 0, 0 } } + }, + + { /* IOQ_ACTIVE_ENTRIES */ + 0x06, 0x1a, + { { CTR_BPU_2, MSR_P4_FSB_ESCR1}, + { 0, 0 } } + }, + + { /* FSB_DATA_ACTIVITY */ + 0x06, 0x17, + { { CTR_BPU_0, MSR_P4_FSB_ESCR0}, + { CTR_BPU_2, MSR_P4_FSB_ESCR1} } + }, + + { /* BSQ_ALLOCATION */ + 0x07, 0x05, + { { CTR_BPU_0, MSR_P4_BSU_ESCR0}, + { 0, 0 } } + }, + + { /* BSQ_ACTIVE_ENTRIES */ + 0x07, 0x06, + /* FIXME intel doc don't say which ESCR1 to use, using + BSU_ESCR1 is a sensible guess but will need validation */ + { { CTR_BPU_2, MSR_P4_BSU_ESCR1 }, + { 0, 0 } } + }, + + { /* X87_ASSIST */ + 0x05, 0x03, + { { CTR_IQ_4, MSR_P4_CRU_ESCR2}, + { CTR_IQ_5, MSR_P4_CRU_ESCR3} } + }, + + { /* SSE_INPUT_ASSIST */ + 0x01, 0x34, + { { CTR_FLAME_0, MSR_P4_FIRM_ESCR0}, + { CTR_FLAME_2, MSR_P4_FIRM_ESCR1} } + }, + + { /* PACKED_SP_UOP */ + 0x01, 0x08, + { { CTR_FLAME_0, MSR_P4_FIRM_ESCR0}, + { CTR_FLAME_2, MSR_P4_FIRM_ESCR1} } + }, + + { /* PACKED_DP_UOP */ + 0x01, 0x0c, + { { CTR_FLAME_0, MSR_P4_FIRM_ESCR0}, + { CTR_FLAME_2, MSR_P4_FIRM_ESCR1} } + }, + + { /* SCALAR_SP_UOP */ + 0x01, 0x0a, + { { CTR_FLAME_0, MSR_P4_FIRM_ESCR0}, + { CTR_FLAME_2, MSR_P4_FIRM_ESCR1} } + }, + + { /* SCALAR_DP_UOP */ + 0x01, 0x0e, + { { CTR_FLAME_0, MSR_P4_FIRM_ESCR0}, + { CTR_FLAME_2, MSR_P4_FIRM_ESCR1} } + }, + + { /* 64BIT_MMX_UOP */ + 0x01, 0x02, + { { CTR_FLAME_0, MSR_P4_FIRM_ESCR0}, + { CTR_FLAME_2, MSR_P4_FIRM_ESCR1} } + }, + + { /* 128BIT_MMX_UOP */ + 0x01, 0x1a, + { { CTR_FLAME_0, MSR_P4_FIRM_ESCR0}, + { CTR_FLAME_2, MSR_P4_FIRM_ESCR1} } + }, + + { /* X87_FP_UOP */ + 0x01, 0x04, + { { CTR_FLAME_0, MSR_P4_FIRM_ESCR0}, + { CTR_FLAME_2, MSR_P4_FIRM_ESCR1} } + }, + + { /* X87_SIMD_MOVES_UOP */ + 0x01, 0x2e, + { { CTR_FLAME_0, MSR_P4_FIRM_ESCR0}, + { CTR_FLAME_2, MSR_P4_FIRM_ESCR1} } + }, + + { /* MACHINE_CLEAR */ + 0x05, 0x02, + { { CTR_IQ_4, MSR_P4_CRU_ESCR2}, + { CTR_IQ_5, MSR_P4_CRU_ESCR3} } + }, + + { /* GLOBAL_POWER_EVENTS */ + 0x06, 0x13 /* older manual says 0x05, newer 0x13 */, + { { CTR_BPU_0, MSR_P4_FSB_ESCR0}, + { CTR_BPU_2, MSR_P4_FSB_ESCR1} } + }, + + { /* TC_MS_XFER */ + 0x00, 0x05, + { { CTR_MS_0, MSR_P4_MS_ESCR0}, + { CTR_MS_2, MSR_P4_MS_ESCR1} } + }, + + { /* UOP_QUEUE_WRITES */ + 0x00, 0x09, + { { CTR_MS_0, MSR_P4_MS_ESCR0}, + { CTR_MS_2, MSR_P4_MS_ESCR1} } + }, + + { /* FRONT_END_EVENT */ + 0x05, 0x08, + { { CTR_IQ_4, MSR_P4_CRU_ESCR2}, + { CTR_IQ_5, MSR_P4_CRU_ESCR3} } + }, + + { /* EXECUTION_EVENT */ + 0x05, 0x0c, + { { CTR_IQ_4, MSR_P4_CRU_ESCR2}, + { CTR_IQ_5, MSR_P4_CRU_ESCR3} } + }, + + { /* REPLAY_EVENT */ + 0x05, 0x09, + { { CTR_IQ_4, MSR_P4_CRU_ESCR2}, + { CTR_IQ_5, MSR_P4_CRU_ESCR3} } + }, + + { /* INSTR_RETIRED */ + 0x04, 0x02, + { { CTR_IQ_4, MSR_P4_CRU_ESCR0}, + { CTR_IQ_5, MSR_P4_CRU_ESCR1} } + }, + + { /* UOPS_RETIRED */ + 0x04, 0x01, + { { CTR_IQ_4, MSR_P4_CRU_ESCR0}, + { CTR_IQ_5, MSR_P4_CRU_ESCR1} } + }, + + { /* UOP_TYPE */ + 0x02, 0x02, + { { CTR_IQ_4, MSR_P4_RAT_ESCR0}, + { CTR_IQ_5, MSR_P4_RAT_ESCR1} } + }, + + { /* RETIRED_MISPRED_BRANCH_TYPE */ + 0x02, 0x05, + { { CTR_MS_0, MSR_P4_TBPU_ESCR0}, + { CTR_MS_2, MSR_P4_TBPU_ESCR1} } + }, + + { /* RETIRED_BRANCH_TYPE */ + 0x02, 0x04, + { { CTR_MS_0, MSR_P4_TBPU_ESCR0}, + { CTR_MS_2, MSR_P4_TBPU_ESCR1} } + } +}; + + +#define MISC_PMC_ENABLED_P(x) ((x) & 1 << 7) + +#define ESCR_RESERVED_BITS 0x80000003 +#define ESCR_CLEAR(escr) ((escr) &= ESCR_RESERVED_BITS) +#define ESCR_SET_USR_0(escr, usr) ((escr) |= (((usr) & 1) << 2)) +#define ESCR_SET_OS_0(escr, os) ((escr) |= (((os) & 1) << 3)) +#define ESCR_SET_USR_1(escr, usr) ((escr) |= (((usr) & 1))) +#define ESCR_SET_OS_1(escr, os) ((escr) |= (((os) & 1) << 1)) +#define ESCR_SET_EVENT_SELECT(escr, sel) ((escr) |= (((sel) & 0x3f) << 25)) +#define ESCR_SET_EVENT_MASK(escr, mask) ((escr) |= (((mask) & 0xffff) << 9)) +#define ESCR_READ(escr,high,ev,i) do {rdmsr(ev->bindings[(i)].escr_address, (escr), (high));} while (0) +#define ESCR_WRITE(escr,high,ev,i) do {wrmsr(ev->bindings[(i)].escr_address, (escr), (high));} while (0) + +#define CCCR_RESERVED_BITS 0x38030FFF +#define CCCR_CLEAR(cccr) ((cccr) &= CCCR_RESERVED_BITS) +#define CCCR_SET_REQUIRED_BITS(cccr) ((cccr) |= 0x00030000) +#define CCCR_SET_ESCR_SELECT(cccr, sel) ((cccr) |= (((sel) & 0x07) << 13)) +#define CCCR_SET_PMI_OVF_0(cccr) ((cccr) |= (1<<26)) +#define CCCR_SET_PMI_OVF_1(cccr) ((cccr) |= (1<<27)) +#define CCCR_SET_ENABLE(cccr) ((cccr) |= (1<<12)) +#define CCCR_SET_DISABLE(cccr) ((cccr) &= ~(1<<12)) +#define CCCR_READ(low, high, i) do {rdmsr(p4_counters[(i)].cccr_address, (low), (high));} while (0) +#define CCCR_WRITE(low, high, i) do {wrmsr(p4_counters[(i)].cccr_address, (low), (high));} while (0) +#define CCCR_OVF_P(cccr) ((cccr) & (1U<<31)) +#define CCCR_CLEAR_OVF(cccr) ((cccr) &= (~(1U<<31))) + +#define CTR_READ(l,h,i) do {rdmsr(p4_counters[(i)].counter_address, (l), (h));} while (0) +#define CTR_WRITE(l,i) do {wrmsr(p4_counters[(i)].counter_address, -(u32)(l), -1);} while (0) +#define CTR_OVERFLOW_P(ctr) (!((ctr) & 0x80000000)) + + +/* this assigns a "stagger" to the current CPU, which is used throughout + the code in this module as an extra array offset, to select the "even" + or "odd" part of all the divided resources. */ +static unsigned int get_stagger(void) +{ +#ifdef HT_SUPPORT + int cpu; + if (smp_num_siblings > 1) { + cpu = smp_processor_id(); + return (cpu_sibling_map[cpu] > cpu) ? 0 : 1; + } +#endif + return 0; +} + + +/* finally, mediate access to a real hardware counter + by passing a "virtual" counter numer to this macro, + along with your stagger setting. */ +#define VIRT_CTR(stagger, i) ((i) + ((num_counters) * (stagger))) + + +static void p4_fill_in_addresses(struct op_msrs * const msrs) +{ + unsigned int i; + unsigned int addr, stag; + + setup_num_counters(); + stag = get_stagger(); + + /* the counter registers we pay attention to */ + for (i = 0; i < num_counters; ++i) { + msrs->counters.addrs[i] = + p4_counters[VIRT_CTR(stag, i)].counter_address; + } + + /* FIXME: bad feeling, we don't save the 10 counters we don't use. */ + + /* 18 CCCR registers */ + for (i = 0, addr = MSR_P4_BPU_CCCR0 + stag; + addr <= MSR_P4_IQ_CCCR5; ++i, addr += addr_increment()) { + msrs->controls.addrs[i] = addr; + } + + /* 43 ESCR registers in three discontiguous group */ + for (addr = MSR_P4_BSU_ESCR0 + stag; + addr <= MSR_P4_SSU_ESCR0; ++i, addr += addr_increment()) { + msrs->controls.addrs[i] = addr; + } + + for (addr = MSR_P4_MS_ESCR0 + stag; + addr <= MSR_P4_TC_ESCR1; ++i, addr += addr_increment()) { + msrs->controls.addrs[i] = addr; + } + + for (addr = MSR_P4_IX_ESCR0 + stag; + addr <= MSR_P4_CRU_ESCR3; ++i, addr += addr_increment()) { + msrs->controls.addrs[i] = addr; + } + + /* there are 2 remaining non-contiguously located ESCRs */ + + if (num_counters == NUM_COUNTERS_NON_HT) { + /* standard non-HT CPUs handle both remaining ESCRs*/ + msrs->controls.addrs[i++] = MSR_P4_CRU_ESCR5; + msrs->controls.addrs[i++] = MSR_P4_CRU_ESCR4; + + } else if (stag == 0) { + /* HT CPUs give the first remainder to the even thread, as + the 32nd control register */ + msrs->controls.addrs[i++] = MSR_P4_CRU_ESCR4; + + } else { + /* and two copies of the second to the odd thread, + for the 22st and 23nd control registers */ + msrs->controls.addrs[i++] = MSR_P4_CRU_ESCR5; + msrs->controls.addrs[i++] = MSR_P4_CRU_ESCR5; + } +} + + +static void pmc_setup_one_p4_counter(unsigned int ctr) +{ + int i; + int const maxbind = 2; + unsigned int cccr = 0; + unsigned int escr = 0; + unsigned int high = 0; + unsigned int counter_bit; + struct p4_event_binding * ev = 0; + unsigned int stag; + + stag = get_stagger(); + + /* convert from counter *number* to counter *bit* */ + counter_bit = 1 << VIRT_CTR(stag, ctr); + + /* find our event binding structure. */ + if (sysctl.ctr[ctr].event <= 0 || sysctl.ctr[ctr].event > NUM_EVENTS) { + printk(KERN_ERR + "oprofile: P4 event code 0x%x out of range\n", + sysctl.ctr[ctr].event); + return; + } + + ev = &(p4_events[sysctl.ctr[ctr].event - 1]); + + for (i = 0; i < maxbind; i++) { + if (ev->bindings[i].virt_counter & counter_bit) { + + /* modify ESCR */ + ESCR_READ(escr, high, ev, i); + ESCR_CLEAR(escr); + if (stag == 0) { + ESCR_SET_USR_0(escr, sysctl.ctr[ctr].user); + ESCR_SET_OS_0(escr, sysctl.ctr[ctr].kernel); + } else { + ESCR_SET_USR_1(escr, sysctl.ctr[ctr].user); + ESCR_SET_OS_1(escr, sysctl.ctr[ctr].kernel); + } + ESCR_SET_EVENT_SELECT(escr, ev->event_select); + ESCR_SET_EVENT_MASK(escr, sysctl.ctr[ctr].unit_mask); + ESCR_WRITE(escr, high, ev, i); + + /* modify CCCR */ + CCCR_READ(cccr, high, VIRT_CTR(stag, ctr)); + CCCR_CLEAR(cccr); + CCCR_SET_REQUIRED_BITS(cccr); + CCCR_SET_ESCR_SELECT(cccr, ev->escr_select); + if (stag == 0) { + CCCR_SET_PMI_OVF_0(cccr); + } else { + CCCR_SET_PMI_OVF_1(cccr); + } + CCCR_WRITE(cccr, high, VIRT_CTR(stag, ctr)); + return; + } + } + + printk(KERN_ERR + "oprofile: P4 event code 0x%x no binding, ctr %d\n", + sysctl.ctr[ctr].event, ctr); +} + + +static void p4_setup_ctrs(struct op_msrs const * const msrs) +{ + unsigned int i; + unsigned int low, high; + unsigned int addr; + unsigned int stag; + + stag = get_stagger(); + + rdmsr(MSR_IA32_MISC_ENABLE, low, high); + if (! MISC_PMC_ENABLED_P(low)) { + printk(KERN_ERR "oprofile: P4 PMC not available\n"); + return; + } + + /* clear the cccrs we will use */ + for (i = 0 ; i < num_counters ; i++) { + rdmsr(p4_counters[VIRT_CTR(stag, i)].cccr_address, low, high); + CCCR_CLEAR(low); + CCCR_SET_REQUIRED_BITS(low); + wrmsr(p4_counters[VIRT_CTR(stag, i)].cccr_address, low, high); + } + + /* clear cccrs outside our concern */ + for (i = stag ; i < NUM_UNUSED_CCCRS ; i += addr_increment()) { + rdmsr(p4_unused_cccr[i], low, high); + CCCR_CLEAR(low); + CCCR_SET_REQUIRED_BITS(low); + wrmsr(p4_unused_cccr[i], low, high); + } + + /* clear all escrs (including those outside our concern) */ + for (addr = MSR_P4_BSU_ESCR0 + stag; + addr <= MSR_P4_SSU_ESCR0; addr += addr_increment()) { + wrmsr(addr, 0, 0); + } + + for (addr = MSR_P4_MS_ESCR0 + stag; + addr <= MSR_P4_TC_ESCR1; addr += addr_increment()){ + wrmsr(addr, 0, 0); + } + + for (addr = MSR_P4_IX_ESCR0 + stag; + addr <= MSR_P4_CRU_ESCR3; addr += addr_increment()){ + wrmsr(addr, 0, 0); + } + + if (num_counters == NUM_COUNTERS_NON_HT) { + wrmsr(MSR_P4_CRU_ESCR4, 0, 0); + wrmsr(MSR_P4_CRU_ESCR5, 0, 0); + } else if (stag == 0) { + wrmsr(MSR_P4_CRU_ESCR4, 0, 0); + } else { + wrmsr(MSR_P4_CRU_ESCR5, 0, 0); + } + + /* setup all counters */ + for (i = 0 ; i < num_counters ; ++i) { + if (sysctl.ctr[i].event) { + pmc_setup_one_p4_counter(i); + CTR_WRITE(sysctl.ctr[i].count, VIRT_CTR(stag, i)); + } + } +} + + +static void p4_check_ctrs(unsigned int const cpu, + struct op_msrs const * const msrs, + struct pt_regs * const regs) +{ + unsigned long ctr, low, high, stag, real; + int i; + + stag = get_stagger(); + + for (i = 0; i < num_counters; ++i) { + + if (!sysctl.ctr[i].enabled) + continue; + + /* + * there is some eccentricity in the hardware which + * requires that we perform 2 extra corrections: + * + * - check both the CCCR:OVF flag for overflow and the + * counter high bit for un-flagged overflows. + * + * - write the counter back twice to ensure it gets + * updated properly. + * + * the former seems to be related to extra NMIs happening + * during the current NMI; the latter is reported as errata + * N15 in intel doc 249199-029, pentium 4 specification + * update, though their suggested work-around does not + * appear to solve the problem. + */ + + real = VIRT_CTR(stag, i); + + CCCR_READ(low, high, real); + CTR_READ(ctr, high, real); + if (CCCR_OVF_P(low) || CTR_OVERFLOW_P(ctr)) { + op_do_profile(cpu, instruction_pointer(regs), IRQ_ENABLED(regs), i); + CTR_WRITE(oprof_data[cpu].ctr_count[i], real); + CCCR_CLEAR_OVF(low); + CCCR_WRITE(low, high, real); + CTR_WRITE(oprof_data[cpu].ctr_count[i], real); + } + } + + /* P4 quirk: you have to re-unmask the apic vector */ + apic_write(APIC_LVTPC, apic_read(APIC_LVTPC) & ~APIC_LVT_MASKED); +} + + +static void p4_start(struct op_msrs const * const msrs) +{ + unsigned int low, high, stag; + int i; + + stag = get_stagger(); + + for (i = 0; i < num_counters; ++i) { + if (!sysctl.ctr[i].enabled) + continue; + CCCR_READ(low, high, VIRT_CTR(stag, i)); + CCCR_SET_ENABLE(low); + CCCR_WRITE(low, high, VIRT_CTR(stag, i)); + } +} + + +static void p4_stop(struct op_msrs const * const msrs) +{ + unsigned int low, high, stag; + int i; + + stag = get_stagger(); + + for (i = 0; i < num_counters; ++i) { + /* FIXME: 2.6 driver doesn't do that ? */ + if (!sysctl.ctr[i].enabled) + continue; + CCCR_READ(low, high, VIRT_CTR(stag, i)); + CCCR_SET_DISABLE(low); + CCCR_WRITE(low, high, VIRT_CTR(stag, i)); + } +} + +#ifdef HT_SUPPORT + +struct op_x86_model_spec const op_p4_ht2_spec = { + .num_counters = NUM_COUNTERS_HT2, + .num_controls = NUM_CONTROLS_HT2, + .fill_in_addresses = &p4_fill_in_addresses, + .setup_ctrs = &p4_setup_ctrs, + .check_ctrs = &p4_check_ctrs, + .start = &p4_start, + .stop = &p4_stop +}; +#endif + +struct op_x86_model_spec const op_p4_spec = { + .num_counters = NUM_COUNTERS_NON_HT, + .num_controls = NUM_CONTROLS_NON_HT, + .fill_in_addresses = &p4_fill_in_addresses, + .setup_ctrs = &p4_setup_ctrs, + .check_ctrs = &p4_check_ctrs, + .start = &p4_start, + .stop = &p4_stop +}; diff --git a/module/x86/op_model_ppro.c b/module/x86/op_model_ppro.c new file mode 100644 index 0000000..5f97039 --- /dev/null +++ b/module/x86/op_model_ppro.c @@ -0,0 +1,124 @@ +/** + * @file op_model_ppro.h + * pentium pro / P6 model-specific MSR operations + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + * @author Graydon Hoare + */ + +#include "op_x86_model.h" +#include "op_arch.h" +#include "op_msr.h" + +#define NUM_COUNTERS 2 +#define NUM_CONTROLS 2 + +#define CTR_READ(l, h, msrs, c) do {rdmsr(msrs->counters.addrs[(c)], (l), (h));} while (0) +#define CTR_WRITE(l, msrs, c) do {wrmsr(msrs->counters.addrs[(c)], -(u32)(l), -1);} while (0) +#define CTR_OVERFLOWED(n) (!((n) & (1U<<31))) + +#define CTRL_READ(l, h, msrs, c) do {rdmsr((msrs->controls.addrs[(c)]), (l), (h));} while (0) +#define CTRL_WRITE(l, h, msrs, c) do {wrmsr((msrs->controls.addrs[(c)]), (l), (h));} while (0) +#define CTRL_SET_ACTIVE(n) (n |= (1<<22)) +#define CTRL_SET_INACTIVE(n) (n &= ~(1<<22)) +#define CTRL_CLEAR(x) (x &= (1<<21)) +#define CTRL_SET_ENABLE(val) (val |= 1<<20) +#define CTRL_SET_USR(val, u) (val |= ((u & 1) << 16)) +#define CTRL_SET_KERN(val, k) (val |= ((k & 1) << 17)) +#define CTRL_SET_UM(val, m) (val |= (m << 8)) +#define CTRL_SET_EVENT(val, e) (val |= e) + + +static void ppro_fill_in_addresses(struct op_msrs * const msrs) +{ + msrs->counters.addrs[0] = MSR_P6_PERFCTR0; + msrs->counters.addrs[1] = MSR_P6_PERFCTR1; + + msrs->controls.addrs[0] = MSR_P6_EVNTSEL0; + msrs->controls.addrs[1] = MSR_P6_EVNTSEL1; +} + + +static void ppro_setup_ctrs(struct op_msrs const * const msrs) +{ + uint low, high; + int i; + + /* clear all counters */ + for (i = 0 ; i < NUM_CONTROLS; ++i) { + CTRL_READ(low, high, msrs, i); + CTRL_CLEAR(low); + CTRL_WRITE(low, high, msrs, i); + } + + /* avoid a false detection of ctr overflows in NMI handler */ + for (i = 0; i < NUM_COUNTERS; ++i) { + CTR_WRITE(1, msrs, i); + } + + /* enable active counters */ + for (i = 0; i < NUM_COUNTERS; ++i) { + if (sysctl.ctr[i].enabled) { + + CTR_WRITE(sysctl.ctr[i].count, msrs, i); + + CTRL_READ(low, high, msrs, i); + CTRL_CLEAR(low); + CTRL_SET_ENABLE(low); + CTRL_SET_USR(low, sysctl.ctr[i].user); + CTRL_SET_KERN(low, sysctl.ctr[i].kernel); + CTRL_SET_UM(low, sysctl.ctr[i].unit_mask); + CTRL_SET_EVENT(low, sysctl.ctr[i].event); + CTRL_WRITE(low, high, msrs, i); + } + } +} + + +static void ppro_check_ctrs(uint const cpu, + struct op_msrs const * const msrs, + struct pt_regs * const regs) +{ + ulong low, high; + int i; + for (i = 0 ; i < NUM_COUNTERS; ++i) { + CTR_READ(low, high, msrs, i); + if (CTR_OVERFLOWED(low)) { + op_do_profile(cpu, instruction_pointer(regs), IRQ_ENABLED(regs), i); + CTR_WRITE(oprof_data[cpu].ctr_count[i], msrs, i); + } + } +} + + +static void ppro_start(struct op_msrs const * const msrs) +{ + uint low, high; + CTRL_READ(low, high, msrs, 0); + CTRL_SET_ACTIVE(low); + CTRL_WRITE(low, high, msrs, 0); +} + + +static void ppro_stop(struct op_msrs const * const msrs) +{ + uint low, high; + CTRL_READ(low, high, msrs, 0); + CTRL_SET_INACTIVE(low); + CTRL_WRITE(low, high, msrs, 0); +} + + +struct op_x86_model_spec const op_ppro_spec = { + .num_counters = NUM_COUNTERS, + .num_controls = NUM_CONTROLS, + .fill_in_addresses = &ppro_fill_in_addresses, + .setup_ctrs = &ppro_setup_ctrs, + .check_ctrs = &ppro_check_ctrs, + .start = &ppro_start, + .stop = &ppro_stop +}; diff --git a/module/x86/op_msr.h b/module/x86/op_msr.h new file mode 100644 index 0000000..06b7329 --- /dev/null +++ b/module/x86/op_msr.h @@ -0,0 +1,337 @@ +/** + * @file op_msr.h + * x86-specific MSR stuff + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OP_MSR_H +#define OP_MSR_H + +/* work-around compiler bug in gcc 2.91.66, just mark all input register as + * magically cloberred by wrmsr */ +#if __GNUC__ == 2 && __GNUC_MINOR__ == 91 + #undef wrmsr + #define wrmsr(msr, val1, val2) \ + __asm__ __volatile__("wrmsr" \ + /* no outputs */ \ + : \ + : "c" (msr), "a" (val1), "d" (val2) \ + : "ecx", "eax", "edx") +#endif + +#ifndef MSR_IA32_MISC_ENABLE +#define MSR_IA32_MISC_ENABLE 0x1a0 +#endif + +/* MSRs */ +#ifndef MSR_P6_PERFCTR0 +#define MSR_P6_PERFCTR0 0xc1 +#endif +#ifndef MSR_P6_PERFCTR1 +#define MSR_P6_PERFCTR1 0xc2 +#endif +#ifndef MSR_P6_EVNTSEL0 +#define MSR_P6_EVNTSEL0 0x186 +#endif +#ifndef MSR_P6_EVNTSEL1 +#define MSR_P6_EVNTSEL1 0x187 +#endif +#ifndef MSR_K7_EVNTSEL0 +#define MSR_K7_EVNTSEL0 0xc0010000 +#endif +#ifndef MSR_K7_EVNTSEL1 +#define MSR_K7_EVNTSEL1 0xc0010001 +#endif +#ifndef MSR_K7_EVNTSEL2 +#define MSR_K7_EVNTSEL2 0xc0010002 +#endif +#ifndef MSR_K7_EVNTSEL3 +#define MSR_K7_EVNTSEL3 0xc0010003 +#endif +#ifndef MSR_K7_PERFCTR0 +#define MSR_K7_PERFCTR0 0xc0010004 +#endif +#ifndef MSR_K7_PERFCTR1 +#define MSR_K7_PERFCTR1 0xc0010005 +#endif +#ifndef MSR_K7_PERFCTR2 +#define MSR_K7_PERFCTR2 0xc0010006 +#endif +#ifndef MSR_K7_PERFCTR3 +#define MSR_K7_PERFCTR3 0xc0010007 +#endif + +/* There are *82* pentium 4 MSRs: + + - 1 misc register + + - 18 counters (PERFCTRs) + + - 18 counter configuration control registers (CCCRs) + + - 45 event selection control registers (ESCRs). */ + + +#ifndef MSR_P4_BPU_PERFCTR0 +#define MSR_P4_BPU_PERFCTR0 0x300 +#endif +#ifndef MSR_P4_BPU_PERFCTR1 +#define MSR_P4_BPU_PERFCTR1 0x301 +#endif +#ifndef MSR_P4_BPU_PERFCTR2 +#define MSR_P4_BPU_PERFCTR2 0x302 +#endif +#ifndef MSR_P4_BPU_PERFCTR3 +#define MSR_P4_BPU_PERFCTR3 0x303 +#endif +#ifndef MSR_P4_MS_PERFCTR0 +#define MSR_P4_MS_PERFCTR0 0x304 +#endif +#ifndef MSR_P4_MS_PERFCTR1 +#define MSR_P4_MS_PERFCTR1 0x305 +#endif +#ifndef MSR_P4_MS_PERFCTR2 +#define MSR_P4_MS_PERFCTR2 0x306 +#endif +#ifndef MSR_P4_MS_PERFCTR3 +#define MSR_P4_MS_PERFCTR3 0x307 +#endif +#ifndef MSR_P4_FLAME_PERFCTR0 +#define MSR_P4_FLAME_PERFCTR0 0x308 +#endif +#ifndef MSR_P4_FLAME_PERFCTR1 +#define MSR_P4_FLAME_PERFCTR1 0x309 +#endif +#ifndef MSR_P4_FLAME_PERFCTR2 +#define MSR_P4_FLAME_PERFCTR2 0x30a +#endif +#ifndef MSR_P4_FLAME_PERFCTR3 +#define MSR_P4_FLAME_PERFCTR3 0x30b +#endif +#ifndef MSR_P4_IQ_PERFCTR0 +#define MSR_P4_IQ_PERFCTR0 0x30c +#endif +#ifndef MSR_P4_IQ_PERFCTR1 +#define MSR_P4_IQ_PERFCTR1 0x30d +#endif +#ifndef MSR_P4_IQ_PERFCTR2 +#define MSR_P4_IQ_PERFCTR2 0x30e +#endif +#ifndef MSR_P4_IQ_PERFCTR3 +#define MSR_P4_IQ_PERFCTR3 0x30f +#endif +#ifndef MSR_P4_IQ_PERFCTR4 +#define MSR_P4_IQ_PERFCTR4 0x310 +#endif +#ifndef MSR_P4_IQ_PERFCTR5 +#define MSR_P4_IQ_PERFCTR5 0x311 +#endif + + +#ifndef MSR_P4_BPU_CCCR0 +#define MSR_P4_BPU_CCCR0 0x360 +#endif +#ifndef MSR_P4_BPU_CCCR1 +#define MSR_P4_BPU_CCCR1 0x361 +#endif +#ifndef MSR_P4_BPU_CCCR2 +#define MSR_P4_BPU_CCCR2 0x362 +#endif +#ifndef MSR_P4_BPU_CCCR3 +#define MSR_P4_BPU_CCCR3 0x363 +#endif +#ifndef MSR_P4_MS_CCCR0 +#define MSR_P4_MS_CCCR0 0x364 +#endif +#ifndef MSR_P4_MS_CCCR1 +#define MSR_P4_MS_CCCR1 0x365 +#endif +#ifndef MSR_P4_MS_CCCR2 +#define MSR_P4_MS_CCCR2 0x366 +#endif +#ifndef MSR_P4_MS_CCCR3 +#define MSR_P4_MS_CCCR3 0x367 +#endif +#ifndef MSR_P4_FLAME_CCCR0 +#define MSR_P4_FLAME_CCCR0 0x368 +#endif +#ifndef MSR_P4_FLAME_CCCR1 +#define MSR_P4_FLAME_CCCR1 0x369 +#endif +#ifndef MSR_P4_FLAME_CCCR2 +#define MSR_P4_FLAME_CCCR2 0x36a +#endif +#ifndef MSR_P4_FLAME_CCCR3 +#define MSR_P4_FLAME_CCCR3 0x36b +#endif +#ifndef MSR_P4_IQ_CCCR0 +#define MSR_P4_IQ_CCCR0 0x36c +#endif +#ifndef MSR_P4_IQ_CCCR1 +#define MSR_P4_IQ_CCCR1 0x36d +#endif +#ifndef MSR_P4_IQ_CCCR2 +#define MSR_P4_IQ_CCCR2 0x36e +#endif +#ifndef MSR_P4_IQ_CCCR3 +#define MSR_P4_IQ_CCCR3 0x36f +#endif +#ifndef MSR_P4_IQ_CCCR4 +#define MSR_P4_IQ_CCCR4 0x370 +#endif +#ifndef MSR_P4_IQ_CCCR5 +#define MSR_P4_IQ_CCCR5 0x371 +#endif + + +#ifndef MSR_P4_ALF_ESCR0 +#define MSR_P4_ALF_ESCR0 0x3ca +#endif +#ifndef MSR_P4_ALF_ESCR1 +#define MSR_P4_ALF_ESCR1 0x3cb +#endif +#ifndef MSR_P4_BPU_ESCR0 +#define MSR_P4_BPU_ESCR0 0x3b2 +#endif +#ifndef MSR_P4_BPU_ESCR1 +#define MSR_P4_BPU_ESCR1 0x3b3 +#endif +#ifndef MSR_P4_BSU_ESCR0 +#define MSR_P4_BSU_ESCR0 0x3a0 +#endif +#ifndef MSR_P4_BSU_ESCR1 +#define MSR_P4_BSU_ESCR1 0x3a1 +#endif +#ifndef MSR_P4_CRU_ESCR0 +#define MSR_P4_CRU_ESCR0 0x3b8 +#endif +#ifndef MSR_P4_CRU_ESCR1 +#define MSR_P4_CRU_ESCR1 0x3b9 +#endif +#ifndef MSR_P4_CRU_ESCR2 +#define MSR_P4_CRU_ESCR2 0x3cc +#endif +#ifndef MSR_P4_CRU_ESCR3 +#define MSR_P4_CRU_ESCR3 0x3cd +#endif +#ifndef MSR_P4_CRU_ESCR4 +#define MSR_P4_CRU_ESCR4 0x3e0 +#endif +#ifndef MSR_P4_CRU_ESCR5 +#define MSR_P4_CRU_ESCR5 0x3e1 +#endif +#ifndef MSR_P4_DAC_ESCR0 +#define MSR_P4_DAC_ESCR0 0x3a8 +#endif +#ifndef MSR_P4_DAC_ESCR1 +#define MSR_P4_DAC_ESCR1 0x3a9 +#endif +#ifndef MSR_P4_FIRM_ESCR0 +#define MSR_P4_FIRM_ESCR0 0x3a4 +#endif +#ifndef MSR_P4_FIRM_ESCR1 +#define MSR_P4_FIRM_ESCR1 0x3a5 +#endif +#ifndef MSR_P4_FLAME_ESCR0 +#define MSR_P4_FLAME_ESCR0 0x3a6 +#endif +#ifndef MSR_P4_FLAME_ESCR1 +#define MSR_P4_FLAME_ESCR1 0x3a7 +#endif +#ifndef MSR_P4_FSB_ESCR0 +#define MSR_P4_FSB_ESCR0 0x3a2 +#endif +#ifndef MSR_P4_FSB_ESCR1 +#define MSR_P4_FSB_ESCR1 0x3a3 +#endif +#ifndef MSR_P4_IQ_ESCR0 +#define MSR_P4_IQ_ESCR0 0x3ba +#endif +#ifndef MSR_P4_IQ_ESCR1 +#define MSR_P4_IQ_ESCR1 0x3bb +#endif +#ifndef MSR_P4_IS_ESCR0 +#define MSR_P4_IS_ESCR0 0x3b4 +#endif +#ifndef MSR_P4_IS_ESCR1 +#define MSR_P4_IS_ESCR1 0x3b5 +#endif +#ifndef MSR_P4_ITLB_ESCR0 +#define MSR_P4_ITLB_ESCR0 0x3b6 +#endif +#ifndef MSR_P4_ITLB_ESCR1 +#define MSR_P4_ITLB_ESCR1 0x3b7 +#endif +#ifndef MSR_P4_IX_ESCR0 +#define MSR_P4_IX_ESCR0 0x3c8 +#endif +#ifndef MSR_P4_IX_ESCR1 +#define MSR_P4_IX_ESCR1 0x3c9 +#endif +#ifndef MSR_P4_MOB_ESCR0 +#define MSR_P4_MOB_ESCR0 0x3aa +#endif +#ifndef MSR_P4_MOB_ESCR1 +#define MSR_P4_MOB_ESCR1 0x3ab +#endif +#ifndef MSR_P4_MS_ESCR0 +#define MSR_P4_MS_ESCR0 0x3c0 +#endif +#ifndef MSR_P4_MS_ESCR1 +#define MSR_P4_MS_ESCR1 0x3c1 +#endif +#ifndef MSR_P4_PMH_ESCR0 +#define MSR_P4_PMH_ESCR0 0x3ac +#endif +#ifndef MSR_P4_PMH_ESCR1 +#define MSR_P4_PMH_ESCR1 0x3ad +#endif +#ifndef MSR_P4_RAT_ESCR0 +#define MSR_P4_RAT_ESCR0 0x3bc +#endif +#ifndef MSR_P4_RAT_ESCR1 +#define MSR_P4_RAT_ESCR1 0x3bd +#endif +#ifndef MSR_P4_SAAT_ESCR0 +#define MSR_P4_SAAT_ESCR0 0x3ae +#endif +#ifndef MSR_P4_SAAT_ESCR1 +#define MSR_P4_SAAT_ESCR1 0x3af +#endif +#ifndef MSR_P4_SSU_ESCR0 +#define MSR_P4_SSU_ESCR0 0x3be +#endif +/* guess: not defined in manual */ +#ifndef MSR_P4_SSU_ESCR1 +#define MSR_P4_SSU_ESCR1 0x3bf +#endif +#ifndef MSR_P4_TBPU_ESCR0 +#define MSR_P4_TBPU_ESCR0 0x3c2 +#endif +#ifndef MSR_P4_TBPU_ESCR1 +#define MSR_P4_TBPU_ESCR1 0x3c3 +#endif +#ifndef MSR_P4_TC_ESCR0 +#define MSR_P4_TC_ESCR0 0x3c4 +#endif +#ifndef MSR_P4_TC_ESCR1 +#define MSR_P4_TC_ESCR1 0x3c5 +#endif +#ifndef MSR_P4_U2L_ESCR0 +#define MSR_P4_U2L_ESCR0 0x3b0 +#endif +#ifndef MSR_P4_U2L_ESCR1 +#define MSR_P4_U2L_ESCR1 0x3b1 +#endif + +/* Hyper-Threading */ +#ifndef X86_FEATURE_HT +#define X86_FEATURE_HT (0*32+28) +#endif + +#endif /* OP_MSR_H */ diff --git a/module/x86/op_nmi.c b/module/x86/op_nmi.c new file mode 100644 index 0000000..1cfc395 --- /dev/null +++ b/module/x86/op_nmi.c @@ -0,0 +1,376 @@ +/** + * @file op_nmi.c + * Setup and handling of NMI PMC interrupts + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include "oprofile.h" +#include "op_msr.h" +#include "op_apic.h" +#include "op_util.h" +#include "op_x86_model.h" + +static struct op_msrs cpu_msrs[NR_CPUS]; +static struct op_x86_model_spec const * model = NULL; + +static struct op_x86_model_spec const * get_model(void) +{ + if (!model) { + /* pick out our per-model function table */ + switch (sysctl.cpu_type) { + case CPU_ATHLON: + case CPU_HAMMER: + model = &op_athlon_spec; + break; + case CPU_P4: + model = &op_p4_spec; + break; +#ifdef HT_SUPPORT + case CPU_P4_HT2: + model = &op_p4_ht2_spec; + break; +#endif + default: + model = &op_ppro_spec; + break; + } + } + return model; +} + +asmlinkage void op_do_nmi(struct pt_regs * regs) +{ + uint const cpu = op_cpu_id(); + struct op_msrs const * const msrs = &cpu_msrs[cpu]; + + model->check_ctrs(cpu, msrs, regs); +} + +/* ---------------- PMC setup ------------------ */ + +static void pmc_setup_ctr(void * dummy) +{ + uint const cpu = op_cpu_id(); + struct op_msrs const * const msrs = &cpu_msrs[cpu]; + get_model()->setup_ctrs(msrs); +} + + +static int pmc_setup_all(void) +{ + if (smp_call_function(pmc_setup_ctr, NULL, 0, 1)) + return -EFAULT; + pmc_setup_ctr(NULL); + return 0; +} + + +static void pmc_start(void * info) +{ + uint const cpu = op_cpu_id(); + struct op_msrs const * const msrs = &cpu_msrs[cpu]; + + if (info && (*((uint *)info) != cpu)) + return; + + get_model()->start(msrs); +} + + +static void pmc_stop(void *info) +{ + uint const cpu = op_cpu_id(); + struct op_msrs const * const msrs = &cpu_msrs[cpu]; + + if (info && (*((uint *)info) != cpu)) + return; + + get_model()->stop(msrs); +} + + +static void pmc_select_start(uint cpu) +{ + if (cpu == op_cpu_id()) + pmc_start(NULL); + else + smp_call_function(pmc_start, &cpu, 0, 1); +} + + +static void pmc_select_stop(uint cpu) +{ + if (cpu == op_cpu_id()) + pmc_stop(NULL); + else + smp_call_function(pmc_stop, &cpu, 0, 1); +} + + +static void pmc_start_all(void) +{ + int cpu, i; + + for (cpu = 0 ; cpu < smp_num_cpus; cpu++) { + struct _oprof_data * data = &oprof_data[cpu]; + + for (i = 0 ; i < get_model()->num_counters ; ++i) { + if (sysctl.ctr[i].enabled) + data->ctr_count[i] = sysctl.ctr[i].count; + else + data->ctr_count[i] = 0; + } + } + + install_nmi(); + smp_call_function(pmc_start, NULL, 0, 1); + pmc_start(NULL); +} + + +static void pmc_stop_all(void) +{ + smp_call_function(pmc_stop, NULL, 0, 1); + pmc_stop(NULL); + restore_nmi(); +} + + +static int pmc_check_params(void) +{ + int i; + int enabled = 0; + + for (i = 0; i < get_model()->num_counters; i++) { + if (!sysctl.ctr[i].enabled) + continue; + + enabled = 1; + + if (!sysctl.ctr[i].user && !sysctl.ctr[i].kernel) { + printk(KERN_ERR "oprofile: neither kernel nor user " + "set for counter %d\n", i); + return -EINVAL; + } + + if (check_range(sysctl.ctr[i].count, 1, OP_MAX_PERF_COUNT, + "ctr count value %d not in range (%d %ld)\n")) + return -EINVAL; + + } + + if (!enabled) { + printk(KERN_ERR "oprofile: no counters have been enabled.\n"); + return -EINVAL; + } + + return 0; +} + + +static void free_msr_group(struct op_msr_group * group) +{ + if (group->addrs) + kfree(group->addrs); + if (group->saved) + kfree(group->saved); + group->addrs = NULL; + group->saved = NULL; +} + + +static void pmc_save_registers(void * dummy) +{ + uint i; + uint const cpu = op_cpu_id(); + uint const nr_ctrs = get_model()->num_counters; + uint const nr_ctrls = get_model()->num_controls; + struct op_msr_group * counters = &cpu_msrs[cpu].counters; + struct op_msr_group * controls = &cpu_msrs[cpu].controls; + + counters->addrs = NULL; + counters->saved = NULL; + controls->addrs = NULL; + controls->saved = NULL; + + counters->addrs = kmalloc(nr_ctrs * sizeof(uint), GFP_KERNEL); + if (!counters->addrs) + goto fault; + + counters->saved = kmalloc( + nr_ctrs * sizeof(struct op_saved_msr), GFP_KERNEL); + if (!counters->saved) + goto fault; + + controls->addrs = kmalloc(nr_ctrls * sizeof(uint), GFP_KERNEL); + if (!controls->addrs) + goto fault; + + controls->saved = kmalloc( + nr_ctrls * sizeof(struct op_saved_msr), GFP_KERNEL); + if (!controls->saved) + goto fault; + + model->fill_in_addresses(&cpu_msrs[cpu]); + + for (i = 0; i < nr_ctrs; ++i) { + rdmsr(counters->addrs[i], + counters->saved[i].low, + counters->saved[i].high); + } + + for (i = 0; i < nr_ctrls; ++i) { + rdmsr(controls->addrs[i], + controls->saved[i].low, + controls->saved[i].high); + } + return; + +fault: + free_msr_group(counters); + free_msr_group(controls); +} + + +static void pmc_restore_registers(void * dummy) +{ + uint i; + uint const cpu = op_cpu_id(); + uint const nr_ctrs = get_model()->num_counters; + uint const nr_ctrls = get_model()->num_controls; + struct op_msr_group * counters = &cpu_msrs[cpu].counters; + struct op_msr_group * controls = &cpu_msrs[cpu].controls; + + if (controls->addrs) { + for (i = 0; i < nr_ctrls; ++i) { + wrmsr(controls->addrs[i], + controls->saved[i].low, + controls->saved[i].high); + } + } + + if (counters->addrs) { + for (i = 0; i < nr_ctrs; ++i) { + wrmsr(counters->addrs[i], + counters->saved[i].low, + counters->saved[i].high); + } + } + + free_msr_group(counters); + free_msr_group(controls); +} + + +static int pmc_init(void) +{ + int err = 0; + + if ((err = smp_call_function(pmc_save_registers, NULL, 0, 1))) { + goto out; + } + pmc_save_registers(NULL); + + if ((err = apic_setup())) + goto out_restore; + + if ((err = smp_call_function(lvtpc_apic_setup, NULL, 0, 1))) { + lvtpc_apic_restore(NULL); + goto out_restore; + } + +out: + return err; +out_restore: + smp_call_function(pmc_restore_registers, NULL, 0, 1); + pmc_restore_registers(NULL); + goto out; +} + + +static void pmc_deinit(void) +{ + smp_call_function(lvtpc_apic_restore, NULL, 0, 1); + lvtpc_apic_restore(NULL); + + apic_restore(); + + smp_call_function(pmc_restore_registers, NULL, 0, 1); + pmc_restore_registers(NULL); +} + + +static char *names[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8" }; + +static int pmc_add_sysctls(ctl_table * next) +{ + ctl_table * start = next; + ctl_table * tab; + int i, j; + + /* now init the sysctls */ + for (i=0; i < get_model()->num_counters; i++) { + next->ctl_name = 1; + next->procname = names[i]; + next->mode = 0755; + + if (!(tab = kmalloc(sizeof(ctl_table)*7, GFP_KERNEL))) + goto cleanup; + + next->child = tab; + + memset(tab, 0, sizeof(ctl_table)*7); + tab[0] = ((ctl_table) { 1, "enabled", &sysctl_parms.ctr[i].enabled, sizeof(int), 0644, NULL, lproc_dointvec, NULL, }); + tab[1] = ((ctl_table) { 1, "event", &sysctl_parms.ctr[i].event, sizeof(int), 0644, NULL, lproc_dointvec, NULL, }); + tab[2] = ((ctl_table) { 1, "count", &sysctl_parms.ctr[i].count, sizeof(int), 0644, NULL, lproc_dointvec, NULL, }); + tab[3] = ((ctl_table) { 1, "unit_mask", &sysctl_parms.ctr[i].unit_mask, sizeof(int), 0644, NULL, lproc_dointvec, NULL, }); + tab[4] = ((ctl_table) { 1, "kernel", &sysctl_parms.ctr[i].kernel, sizeof(int), 0644, NULL, lproc_dointvec, NULL, }); + tab[5] = ((ctl_table) { 1, "user", &sysctl_parms.ctr[i].user, sizeof(int), 0644, NULL, lproc_dointvec, NULL, }); + next++; + } + + return 0; + +cleanup: + next = start; + for (j = 0; j < i; j++) { + kfree(next->child); + next++; + } + return -EFAULT; +} + + +static void pmc_remove_sysctls(ctl_table * next) +{ + int i; + for (i=0; i < get_model()->num_counters; i++) { + kfree(next->child); + next++; + } +} + + +static struct op_int_operations op_nmi_ops = { + init: pmc_init, + deinit: pmc_deinit, + add_sysctls: pmc_add_sysctls, + remove_sysctls: pmc_remove_sysctls, + check_params: pmc_check_params, + setup: pmc_setup_all, + start: pmc_start_all, + stop: pmc_stop_all, + start_cpu: pmc_select_start, + stop_cpu: pmc_select_stop, +}; + + +struct op_int_operations const * op_int_interface() +{ + return &op_nmi_ops; +} diff --git a/module/x86/op_rtc.c b/module/x86/op_rtc.c new file mode 100644 index 0000000..8a26fd6 --- /dev/null +++ b/module/x86/op_rtc.c @@ -0,0 +1,194 @@ +/** + * @file op_rtc.c + * Setup and handling of RTC interrupts + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Bob Montgomery + * @author Philippe Elie + * @author John Levon + */ + +#include +#include +#include + +#include "oprofile.h" +#include "op_arch.h" +#include "op_util.h" + +#define RTC_IO_PORTS 2 + +/* not in 2.2 */ +#ifndef RTC_IRQ +#define RTC_IRQ 8 +#endif + +/* ---------------- RTC handler ------------------ */ + +static void do_rtc_interrupt(int irq, void * dev_id, struct pt_regs * regs) +{ + uint cpu = op_cpu_id(); + unsigned char intr_flags; + unsigned long flags; + + int usermode = user_mode(regs); + if ((sysctl.ctr[0].kernel && usermode) + || (sysctl.ctr[0].user && !usermode)) + return; + + lock_rtc(flags); + + /* read and ack the interrupt */ + intr_flags = CMOS_READ(RTC_INTR_FLAGS); + /* Is this my type of interrupt? */ + if (intr_flags & RTC_PF) { + op_do_profile(cpu, instruction_pointer(regs), IRQ_ENABLED(regs), 0); + } + + unlock_rtc(flags); + + return; +} + +static int rtc_setup(void) +{ + unsigned char tmp_control; + unsigned long flags; + unsigned char tmp_freq_select; + unsigned long target; + unsigned int exp, freq; + + lock_rtc(flags); + + /* disable periodic interrupts */ + tmp_control = CMOS_READ(RTC_CONTROL); + tmp_control &= ~RTC_PIE; + CMOS_WRITE(tmp_control, RTC_CONTROL); + CMOS_READ(RTC_INTR_FLAGS); + + /* Set the frequency for periodic interrupts by finding the + * closest power of two within the allowed range. + */ + + target = sysctl.ctr[0].count; + + exp = 0; + while (target > (1 << exp) + ((1 << exp) >> 1)) + exp++; + freq = 16 - exp; + + tmp_freq_select = CMOS_READ(RTC_FREQ_SELECT); + tmp_freq_select = (tmp_freq_select & 0xf0) | freq; + CMOS_WRITE(tmp_freq_select, RTC_FREQ_SELECT); + + /* Update /proc with the actual frequency. */ + sysctl_parms.ctr[0].count = sysctl.ctr[0].count = 1< +#include +#include +#include + +#include "oprofile.h" + +void oprof_put_note(struct op_note *samp); +void __oprof_put_note(struct op_note *samp); + +extern spinlock_t note_lock; + +/* ------------ system calls --------------- */ + +struct mmap_arg_struct { + unsigned long addr; + unsigned long len; + unsigned long prot; + unsigned long flags; + unsigned long fd; + unsigned long offset; +}; + +asmlinkage static int (*old_sys_fork)(struct pt_regs); +asmlinkage static int (*old_sys_vfork)(struct pt_regs); +asmlinkage static int (*old_sys_clone)(struct pt_regs); +asmlinkage static int (*old_sys_execve)(struct pt_regs); +asmlinkage static int (*old_old_mmap)(struct mmap_arg_struct *); +#ifdef HAVE_MMAP2 +asmlinkage static long (*old_sys_mmap2)(ulong, ulong, ulong, ulong, ulong, ulong); +#endif +asmlinkage static long (*old_sys_init_module)(char const *, struct module *); +asmlinkage static long (*old_sys_exit)(int); + +/* called with note_lock held */ +static void oprof_output_map(ulong addr, ulong len, + ulong offset, struct file *file, int is_execve) +{ + struct op_note note; + + /* don't bother with /dev/zero mappings etc. */ + if (!len) + return; + + note.pid = current->pid; + note.tgid = op_get_tgid(); + note.addr = addr; + note.len = len; + note.offset = offset; + note.type = is_execve ? OP_EXEC : OP_MAP; + note.hash = hash_path(file); + if (note.hash == -1) + return; + /* holding note lock */ + __oprof_put_note(¬e); +} + +static int oprof_output_maps(struct task_struct *task) +{ + int size=0; + struct mm_struct *mm; + struct vm_area_struct *map; + + /* we don't need to worry about mm_users here, since there is at + least one user (current), and if there's other code using this + mm, then mm_users must be at least 2; we should never have to + mmput() here. */ + + if (!(mm = task->mm)) + goto out; + + lock_mmap(mm); + spin_lock(¬e_lock); + + /* We need two pass, daemon assume than the first mmap notification + * is for the executable but some process doesn't follow this model. + */ + for (map = mm->mmap; map; map = map->vm_next) { + if (!(map->vm_flags & VM_EXEC) || !map->vm_file) + continue; + if (!(map->vm_flags & VM_EXECUTABLE)) + continue; + + oprof_output_map(map->vm_start, map->vm_end-map->vm_start, + GET_VM_OFFSET(map), map->vm_file, 1); + } + for (map = mm->mmap; map; map = map->vm_next) { + if (!(map->vm_flags & VM_EXEC) || !map->vm_file) + continue; + if (map->vm_flags & VM_EXECUTABLE) + continue; + + oprof_output_map(map->vm_start, map->vm_end-map->vm_start, + GET_VM_OFFSET(map), map->vm_file, 0); + } + + spin_unlock(¬e_lock); + unlock_mmap(mm); + +out: + return size; +} + +asmlinkage static int my_sys_execve(struct pt_regs regs) +{ + char *filename; + int ret; + + MOD_INC_USE_COUNT; + + lock_execve(); + + filename = getname((char *)regs.ebx); + if (IS_ERR(filename)) { + ret = PTR_ERR(filename); + goto out; + } + ret = do_execve(filename, (char **)regs.ecx, (char **)regs.edx, ®s); + + if (!ret) { + PTRACE_OFF(current); + oprof_output_maps(current); + } + + putname(filename); + +out: + unlock_execve(); + MOD_DEC_USE_COUNT; + return ret; +} + +static void out_mmap(ulong addr, ulong len, ulong prot, ulong flags, + ulong fd, ulong offset) +{ + struct file *file; + + lock_out_mmap(); + + file = fget(fd); + if (!file) + goto out; + + spin_lock(¬e_lock); + oprof_output_map(addr, len, offset, file, 0); + spin_unlock(¬e_lock); + + fput(file); + +out: + unlock_out_mmap(); +} + +#ifdef HAVE_MMAP2 +asmlinkage static int my_sys_mmap2(ulong addr, ulong len, + ulong prot, ulong flags, ulong fd, ulong pgoff) +{ + int ret; + + MOD_INC_USE_COUNT; + + ret = old_sys_mmap2(addr, len, prot, flags, fd, pgoff); + + if ((prot & PROT_EXEC) && ret >= 0) + out_mmap(ret, len, prot, flags, fd, pgoff << PAGE_SHIFT); + + MOD_DEC_USE_COUNT; + return ret; +} +#endif + +asmlinkage static int my_old_mmap(struct mmap_arg_struct *arg) +{ + int ret; + + MOD_INC_USE_COUNT; + + ret = old_old_mmap(arg); + + if (ret >= 0) { + struct mmap_arg_struct a; + + if (copy_from_user(&a, arg, sizeof(a))) { + ret = -EFAULT; + goto out; + } + + if (a.prot&PROT_EXEC) + out_mmap(ret, a.len, a.prot, a.flags, a.fd, a.offset); + } + +out: + MOD_DEC_USE_COUNT; + return ret; +} + +inline static void oprof_report_fork(u32 old_pid, u32 new_pid, u32 old_tgid, u32 new_tgid) +{ + struct op_note note; + + note.type = OP_FORK; + note.pid = old_pid; + note.tgid = old_tgid; + note.addr = new_pid; + note.len = new_tgid; + oprof_put_note(¬e); +} + +asmlinkage static int my_sys_fork(struct pt_regs regs) +{ + u32 pid = current->pid; + u32 tgid = op_get_tgid(); + int ret; + + MOD_INC_USE_COUNT; + + ret = old_sys_fork(regs); + if (ret) + oprof_report_fork(pid, ret, tgid, ret); + MOD_DEC_USE_COUNT; + return ret; +} + +asmlinkage static int my_sys_vfork(struct pt_regs regs) +{ + u32 pid = current->pid; + u32 tgid = op_get_tgid(); + int ret; + + MOD_INC_USE_COUNT; + ret = old_sys_vfork(regs); + if (ret) + oprof_report_fork(pid, ret, tgid, ret); + MOD_DEC_USE_COUNT; + return ret; +} + +asmlinkage static int my_sys_clone(struct pt_regs regs) +{ + u32 pid = current->pid; + u32 tgid = op_get_tgid(); +#if V_AT_LEAST(2, 4, 0) + u32 clone_flags = regs.ebx; +#endif + int ret; + + MOD_INC_USE_COUNT; + ret = old_sys_clone(regs); + if (ret) { +#if V_AT_LEAST(2, 4, 0) + if (clone_flags & CLONE_THREAD) + oprof_report_fork(pid, ret, tgid, tgid); + else +#endif + oprof_report_fork(pid, ret, tgid, ret); + } + MOD_DEC_USE_COUNT; + return ret; +} + +asmlinkage static long my_sys_init_module(char const * name_user, struct module * mod_user) +{ + long ret; + + MOD_INC_USE_COUNT; + + ret = old_sys_init_module(name_user, mod_user); + + if (ret >= 0) { + struct op_note note; + + note.type = OP_DROP_MODULES; + oprof_put_note(¬e); + } + MOD_DEC_USE_COUNT; + return ret; +} + +/* used from do_nmi */ +asmlinkage long my_sys_exit(int error_code) +{ + struct op_note note; + + MOD_INC_USE_COUNT; + + note.type = OP_EXIT; + note.pid = current->pid; + note.tgid = op_get_tgid(); + oprof_put_note(¬e); + + /* this looks UP-dangerous, as the exit sleeps and we don't + * have a use count, but in fact its ok as sys_exit is noreturn, + * so we can never come back to this non-existent exec page + */ + MOD_DEC_USE_COUNT; + return old_sys_exit(error_code); +} + +extern void *sys_call_table[]; + +void op_save_syscalls(void) +{ + old_sys_fork = sys_call_table[__NR_fork]; + old_sys_vfork = sys_call_table[__NR_vfork]; + old_sys_clone = sys_call_table[__NR_clone]; + old_sys_execve = sys_call_table[__NR_execve]; + old_old_mmap = sys_call_table[__NR_mmap]; +#ifdef HAVE_MMAP2 + old_sys_mmap2 = sys_call_table[__NR_mmap2]; +#endif + old_sys_init_module = sys_call_table[__NR_init_module]; + old_sys_exit = sys_call_table[__NR_exit]; +} + +void op_intercept_syscalls(void) +{ + sys_call_table[__NR_fork] = my_sys_fork; + sys_call_table[__NR_vfork] = my_sys_vfork; + sys_call_table[__NR_clone] = my_sys_clone; + sys_call_table[__NR_execve] = my_sys_execve; + sys_call_table[__NR_mmap] = my_old_mmap; +#ifdef HAVE_MMAP2 + sys_call_table[__NR_mmap2] = my_sys_mmap2; +#endif + sys_call_table[__NR_init_module] = my_sys_init_module; + sys_call_table[__NR_exit] = my_sys_exit; +} + +void op_restore_syscalls(void) +{ + sys_call_table[__NR_fork] = old_sys_fork; + sys_call_table[__NR_vfork] = old_sys_vfork; + sys_call_table[__NR_clone] = old_sys_clone; + sys_call_table[__NR_execve] = old_sys_execve; + sys_call_table[__NR_mmap] = old_old_mmap; +#ifdef HAVE_MMAP2 + sys_call_table[__NR_mmap2] = old_sys_mmap2; +#endif + sys_call_table[__NR_init_module] = old_sys_init_module; + sys_call_table[__NR_exit] = old_sys_exit; +} diff --git a/module/x86/op_x86_model.h b/module/x86/op_x86_model.h new file mode 100644 index 0000000..09a1546 --- /dev/null +++ b/module/x86/op_x86_model.h @@ -0,0 +1,52 @@ +/** + * @file op_x86_model.h + * interface to x86 model-specific MSR operations + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author Graydon Hoare + */ + +#ifndef OP_X86_MODEL_H +#define OP_X86_MODEL_H + +#include "oprofile.h" + +struct op_saved_msr { + uint high; + uint low; +}; + +struct op_msr_group { + uint * addrs; + struct op_saved_msr * saved; +}; + +struct op_msrs { + struct op_msr_group counters; + struct op_msr_group controls; +}; + +struct pt_regs; + +struct op_x86_model_spec { + uint const num_counters; + uint const num_controls; + void (*fill_in_addresses)(struct op_msrs * const msrs); + void (*setup_ctrs)(struct op_msrs const * const msrs); + void (*check_ctrs)(uint const cpu, + struct op_msrs const * const msrs, + struct pt_regs * const regs); + void (*start)(struct op_msrs const * const msrs); + void (*stop)(struct op_msrs const * const msrs); +}; + +extern struct op_x86_model_spec const op_ppro_spec; +extern struct op_x86_model_spec const op_athlon_spec; +extern struct op_x86_model_spec const op_p4_spec; +#ifdef HT_SUPPORT +extern struct op_x86_model_spec const op_p4_ht2_spec; +#endif + +#endif /* OP_X86_MODEL_H */ diff --git a/module/x86/oprofile_nmi.S b/module/x86/oprofile_nmi.S new file mode 100644 index 0000000..2cec15c --- /dev/null +++ b/module/x86/oprofile_nmi.S @@ -0,0 +1,63 @@ +#ifndef __ASSEMBLY__ +#define __ASSEMBLY__ /* for some 2.2 kernel */ +#endif +#include +#include +#include +#define ASSEMBLY +#include + +#define SAVE_ALL \ + cld; \ + pushl %es; \ + pushl %ds; \ + pushl %eax; \ + pushl %ebp; \ + pushl %edi; \ + pushl %esi; \ + pushl %edx; \ + pushl %ecx; \ + pushl %ebx; \ + movl $(__KERNEL_DS),%edx; \ + movl %edx,%ds; \ + movl %edx,%es; + +#define RESTORE_ALL \ + popl %ebx; \ + popl %ecx; \ + popl %edx; \ + popl %esi; \ + popl %edi; \ + popl %ebp; \ + popl %eax; \ +1: popl %ds; \ +2: popl %es; \ + addl $4,%esp; \ +3: iret; \ +.section .fixup,"ax"; \ +4: movl $0,(%esp); \ + jmp 1b; \ +5: movl $0,(%esp); \ + jmp 2b; \ +6: pushl %ss; \ + popl %ds; \ + pushl %ss; \ + popl %es; \ + pushl $11; \ + call my_sys_exit;\ +.previous; \ +.section __ex_table,"a";\ + .align 4; \ + .long 1b,4b; \ + .long 2b,5b; \ + .long 3b,6b; \ +.previous + +ENTRY(op_nmi) + pushl %eax + SAVE_ALL + movl %esp,%edx + pushl %edx + call op_do_nmi + addl $4,%esp + RESTORE_ALL diff --git a/pp/Makefile.am b/pp/Makefile.am new file mode 100644 index 0000000..1436473 --- /dev/null +++ b/pp/Makefile.am @@ -0,0 +1,45 @@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libdb \ + -I ${top_srcdir}/libopt++ \ + -I ${top_srcdir}/libutil++ \ + -I ${top_srcdir}/libregex \ + -I ${top_srcdir}/libpp + +AM_CXXFLAGS = @OP_CXXFLAGS@ + +bin_PROGRAMS = opreport opannotate opgprof oparchive + +LIBS=@POPT_LIBS@ @BFD_LIBS@ + +pp_common = common_option.cpp common_option.h + +common_libs = \ + ../libpp/libpp.a \ + ../libopt++/libopt++.a \ + ../libregex/libop_regex.a \ + ../libutil++/libutil++.a \ + ../libop/libop.a \ + ../libutil/libutil.a \ + ../libdb/libodb.a + +opreport_SOURCES = opreport.cpp \ + opreport_options.h opreport_options.cpp \ + $(pp_common) +opreport_LDADD = $(common_libs) + +opannotate_SOURCES = opannotate.cpp \ + opannotate_options.h opannotate_options.cpp \ + $(pp_common) +opannotate_LDADD = $(common_libs) + +opgprof_SOURCES = opgprof.cpp \ + opgprof_options.h opgprof_options.cpp \ + $(pp_common) +opgprof_LDADD = $(common_libs) + +oparchive_SOURCES = oparchive.cpp \ + oparchive_options.h oparchive_options.cpp \ + $(pp_common) +oparchive_LDADD = $(common_libs) diff --git a/pp/Makefile.in b/pp/Makefile.in new file mode 100644 index 0000000..ac91d0a --- /dev/null +++ b/pp/Makefile.in @@ -0,0 +1,534 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SOURCES = $(opannotate_SOURCES) $(oparchive_SOURCES) $(opgprof_SOURCES) $(opreport_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +bin_PROGRAMS = opreport$(EXEEXT) opannotate$(EXEEXT) opgprof$(EXEEXT) \ + oparchive$(EXEEXT) +subdir = pp +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am__objects_1 = common_option.$(OBJEXT) +am_opannotate_OBJECTS = opannotate.$(OBJEXT) \ + opannotate_options.$(OBJEXT) $(am__objects_1) +opannotate_OBJECTS = $(am_opannotate_OBJECTS) +am__DEPENDENCIES_1 = ../libpp/libpp.a ../libopt++/libopt++.a \ + ../libregex/libop_regex.a ../libutil++/libutil++.a \ + ../libop/libop.a ../libutil/libutil.a ../libdb/libodb.a +opannotate_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_oparchive_OBJECTS = oparchive.$(OBJEXT) oparchive_options.$(OBJEXT) \ + $(am__objects_1) +oparchive_OBJECTS = $(am_oparchive_OBJECTS) +oparchive_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_opgprof_OBJECTS = opgprof.$(OBJEXT) opgprof_options.$(OBJEXT) \ + $(am__objects_1) +opgprof_OBJECTS = $(am_opgprof_OBJECTS) +opgprof_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_opreport_OBJECTS = opreport.$(OBJEXT) opreport_options.$(OBJEXT) \ + $(am__objects_1) +opreport_OBJECTS = $(am_opreport_OBJECTS) +opreport_DEPENDENCIES = $(am__DEPENDENCIES_1) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(opannotate_SOURCES) $(oparchive_SOURCES) \ + $(opgprof_SOURCES) $(opreport_SOURCES) +DIST_SOURCES = $(opannotate_SOURCES) $(oparchive_SOURCES) \ + $(opgprof_SOURCES) $(opreport_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @POPT_LIBS@ @BFD_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +AM_CPPFLAGS = \ + -I ${top_srcdir}/libop \ + -I ${top_srcdir}/libutil \ + -I ${top_srcdir}/libdb \ + -I ${top_srcdir}/libopt++ \ + -I ${top_srcdir}/libutil++ \ + -I ${top_srcdir}/libregex \ + -I ${top_srcdir}/libpp + +AM_CXXFLAGS = @OP_CXXFLAGS@ +pp_common = common_option.cpp common_option.h +common_libs = \ + ../libpp/libpp.a \ + ../libopt++/libopt++.a \ + ../libregex/libop_regex.a \ + ../libutil++/libutil++.a \ + ../libop/libop.a \ + ../libutil/libutil.a \ + ../libdb/libodb.a + +opreport_SOURCES = opreport.cpp \ + opreport_options.h opreport_options.cpp \ + $(pp_common) + +opreport_LDADD = $(common_libs) +opannotate_SOURCES = opannotate.cpp \ + opannotate_options.h opannotate_options.cpp \ + $(pp_common) + +opannotate_LDADD = $(common_libs) +opgprof_SOURCES = opgprof.cpp \ + opgprof_options.h opgprof_options.cpp \ + $(pp_common) + +opgprof_LDADD = $(common_libs) +oparchive_SOURCES = oparchive.cpp \ + oparchive_options.h oparchive_options.cpp \ + $(pp_common) + +oparchive_LDADD = $(common_libs) +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign pp/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign pp/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +opannotate$(EXEEXT): $(opannotate_OBJECTS) $(opannotate_DEPENDENCIES) + @rm -f opannotate$(EXEEXT) + $(CXXLINK) $(opannotate_LDFLAGS) $(opannotate_OBJECTS) $(opannotate_LDADD) $(LIBS) +oparchive$(EXEEXT): $(oparchive_OBJECTS) $(oparchive_DEPENDENCIES) + @rm -f oparchive$(EXEEXT) + $(CXXLINK) $(oparchive_LDFLAGS) $(oparchive_OBJECTS) $(oparchive_LDADD) $(LIBS) +opgprof$(EXEEXT): $(opgprof_OBJECTS) $(opgprof_DEPENDENCIES) + @rm -f opgprof$(EXEEXT) + $(CXXLINK) $(opgprof_LDFLAGS) $(opgprof_OBJECTS) $(opgprof_LDADD) $(LIBS) +opreport$(EXEEXT): $(opreport_OBJECTS) $(opreport_DEPENDENCIES) + @rm -f opreport$(EXEEXT) + $(CXXLINK) $(opreport_LDFLAGS) $(opreport_OBJECTS) $(opreport_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common_option.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opannotate.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opannotate_options.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oparchive.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oparchive_options.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opgprof.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opgprof_options.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opreport.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opreport_options.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-binPROGRAMS + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/pp/common_option.cpp b/pp/common_option.cpp new file mode 100644 index 0000000..34a971d --- /dev/null +++ b/pp/common_option.cpp @@ -0,0 +1,287 @@ +/** + * @file common_option.cpp + * Contains common options and implementation of entry point of pp tools + * and some miscelleaneous functions + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Philippe Elie + */ + +#include +#include +#include + +#include "locate_images.h" +#include "op_exception.h" +#include "popt_options.h" +#include "cverb.h" +#include "common_option.h" +#include "file_manip.h" + +using namespace std; + +namespace options { + extra_images extra_found_images; + double threshold = 0.0; + string threshold_opt; +} + +namespace { + +vector image_path; +vector verbose_strings; + +popt::option common_options_array[] = { + popt::option(verbose_strings, "verbose", 'V', + // FIXME help string for verbose level + "verbose output", "all,debug,bfd,level1,sfile,stats"), + popt::option(image_path, "image-path", 'p', + "comma-separated path to search missing binaries", "path"), +}; + + +double handle_threshold(string threshold) +{ + double value = 0.0; + + if (threshold.length()) { + istringstream ss(threshold); + if (!(ss >> value)) { + cerr << "illegal threshold value: " << threshold + << " allowed range: [0-100]" << endl; + exit(EXIT_FAILURE); + } + + if (value < 0.0 || value > 100.0) { + cerr << "illegal threshold value: " << threshold + << " allowed range: [0-100]" << endl; + exit(EXIT_FAILURE); + } + } + + cverb << vdebug << "threshold: " << value << endl;; + + return value; +} + + +vector pre_parse_spec(vector const & non_options) +{ + vector result; + + for (size_t i = 0; i < non_options.size(); ++i) { + if (non_options[i] == "{}") { + result.push_back("{"); + result.push_back("}"); + } else { + result.push_back(non_options[i]); + } + } + + return result; +} + + +options::spec const parse_spec(vector non_options) +{ + bool in_first = false; + bool in_second = false; + bool first = false; + bool second = false; + options::spec pspec; + + non_options = pre_parse_spec(non_options); + + vector::const_iterator it = non_options.begin(); + vector::const_iterator end = non_options.end(); + + for (; it != end; ++it) { + if (*it == "{") { + if (in_first || in_second || second) + goto fail; + if (first) { + in_second = true; + second = true; + } else { + in_first = true; + first = true; + } + continue; + } + + if (*it == "}") { + if (in_first) { + in_first = false; + } else if (in_second) { + in_second = false; + } else { + goto fail; + } + continue; + } + + if (in_first) { + pspec.first.push_back(*it); + } else if (in_second) { + pspec.second.push_back(*it); + } else { + pspec.common.push_back(*it); + } + } + + if (in_first || in_second || (first && !second)) + goto fail; + + if (pspec.first.empty() && pspec.second.size()) + goto fail; + + if (first && second) { + pspec.first.insert(pspec.first.begin(), pspec.common.begin(), + pspec.common.end()); + pspec.second.insert(pspec.second.begin(), pspec.common.begin(), + pspec.common.end()); + } + + return pspec; +fail: + cerr << "invalid profile specification "; + copy(non_options.begin(), non_options.end(), + ostream_iterator(cerr, " ")); + cerr << endl; + exit(EXIT_FAILURE); +} + + +options::spec get_options(int argc, char const * argv[]) +{ + vector non_options; + popt::parse_options(argc, argv, non_options); + + if (!options::threshold_opt.empty()) + options::threshold = handle_threshold(options::threshold_opt); + + if (!verbose::setup(verbose_strings)) { + cerr << "unknown --verbose= options\n"; + exit(EXIT_FAILURE); + } + + bool ok = true; + vector::const_iterator it; + for (it = image_path.begin(); it != image_path.end(); ++it) { + if (!is_directory(*it)) { + cerr << *it << " isn't a valid directory\n"; + ok = false; + } + } + + if (!ok) + throw op_runtime_error("invalid --image-path= options"); + + options::extra_found_images.populate(image_path); + + return parse_spec(non_options); +} + +} // anon namespace + + +int run_pp_tool(int argc, char const * argv[], pp_fct_run_t fct) +{ + try { + return fct(get_options(argc, argv)); + } + catch (op_runtime_error const & e) { + cerr << argv[0] << " error: " << e.what() << endl; + } + catch (op_fatal_error const & e) { + cerr << argv[0] << " error: " << e.what() << endl; + } + catch (op_exception const & e) { + cerr << argv[0] << " error: " << e.what() << endl; + } + catch (invalid_argument const & e) { + cerr << argv[0] << " error: " << e.what() << endl; + } + catch (exception const & e) { + cerr << argv[0] << " error: " << e.what() << endl; + } + catch (...) { + cerr << argv[0] << " unknown exception" << endl; + } + + return EXIT_FAILURE; +} + + +demangle_type handle_demangle_option(string const & option) +{ + if (option == "none") + return dmt_none; + if (option == "smart") + return dmt_smart; + if (option == "normal") + return dmt_normal; + + throw op_runtime_error("invalid option --demangle=" + option); +} + + +merge_option handle_merge_option(vector const & mergespec, + bool allow_lib, bool exclude_dependent) +{ + using namespace options; + merge_option merge_by; + + merge_by.cpu = false; + merge_by.lib = false; + merge_by.tid = false; + merge_by.tgid = false; + merge_by.unitmask = false; + + if (!allow_lib) + merge_by.lib = true; + + bool is_all = false; + + vector::const_iterator cit = mergespec.begin(); + vector::const_iterator end = mergespec.end(); + + for (; cit != end; ++cit) { + if (*cit == "cpu") { + merge_by.cpu = true; + } else if (*cit == "tid") { + merge_by.tid = true; + } else if (*cit == "tgid") { + // PP:5.21 tgid merge imply tid merging. + merge_by.tgid = true; + merge_by.tid = true; + } else if ((*cit == "lib" || *cit == "library") && allow_lib) { + merge_by.lib = true; + } else if (*cit == "unitmask") { + merge_by.unitmask = true; + } else if (*cit == "all") { + merge_by.cpu = true; + merge_by.lib = true; + merge_by.tid = true; + merge_by.tgid = true; + merge_by.unitmask = true; + is_all = true; + } else { + cerr << "unknown merge option: " << *cit << endl; + exit(EXIT_FAILURE); + } + } + + // if --merge all, don't warn about lib merging, + // it's not user friendly. Behaviour should still + // be correct. + if (exclude_dependent && merge_by.lib && allow_lib && !is_all) { + cerr << "--merge=lib is meaningless " + << "with --exclude-dependent" << endl; + exit(EXIT_FAILURE); + } + + return merge_by; +} diff --git a/pp/common_option.h b/pp/common_option.h new file mode 100644 index 0000000..3a82fe4 --- /dev/null +++ b/pp/common_option.h @@ -0,0 +1,70 @@ +/** + * @file common_option.h + * Declaration of entry point of pp tools, implementation file add common + * options of pp tools and some miscelleaneous functions + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef COMMON_OPTION_H +#define COMMON_OPTION_H + +#include +#include + +#include "arrange_profiles.h" +#include "demangle_symbol.h" + +namespace options { + extern bool verbose; + extern extra_images extra_found_images; + extern double threshold; + extern std::string threshold_opt; + + struct spec { + std::list common; + std::list first; + std::list second; + }; +}; + +/** + * prototype of a pp tool entry point. This entry point is called + * by run_pp_tool + */ +typedef int (*pp_fct_run_t)(options::spec const & spec); + +/** + * @param argc command line number of argument + * @param argv command line argument pointer array + * @param fct function to run to start this pp tool + * + * Provide a common entry to all pp tools, parsing all options, handling + * common options and providing the necessary try catch clause + */ +int run_pp_tool(int argc, char const * argv[], pp_fct_run_t fct); + +/** + * @param option one of [smart,none,normal] + * + * return the demangle_type of option or throw an exception if option + * is not valid. + */ +demangle_type handle_demangle_option(std::string const & option); + +/** + * @param mergespec merge option + * @param allow_lib is merge)lib allowed in mergespec + * @param exclude_dependent user specified --exclude-dependent + * + * parse merge option and return a merge_option filled from it. + * + */ +merge_option handle_merge_option(std::vector const & mergespec, + bool allow_lib, bool exclude_dependent); + +#endif /* !COMMON_OPTION_H */ diff --git a/pp/opannotate.cpp b/pp/opannotate.cpp new file mode 100644 index 0000000..741a1f1 --- /dev/null +++ b/pp/opannotate.cpp @@ -0,0 +1,715 @@ +/** + * @file opannotate.cpp + * Implement opannotate utility + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include +#include +#include +#include + +#include "op_exception.h" +#include "op_header.h" +#include "profile.h" +#include "populate.h" +#include "op_sample_file.h" +#include "cverb.h" +#include "string_manip.h" +#include "demangle_symbol.h" +#include "child_reader.h" +#include "op_file.h" +#include "file_manip.h" +#include "arrange_profiles.h" +#include "opannotate_options.h" +#include "profile_container.h" +#include "symbol_sort.h" +#include "image_errors.h" + +using namespace std; +using namespace options; + +namespace { + +size_t nr_events; + +scoped_ptr samples; + +/// how opannotate was invoked +string cmdline; + +/// empty annotation fill string +string annotation_fill; + +/// string used as start / end comment to annotate source +string const begin_comment("/* "); +string const in_comment(" * "); +string const end_comment(" */"); + +/// field width for the sample count +unsigned int const count_width = 6; + +string get_annotation_fill() +{ + string str; + + for (size_t i = 0; i < nr_events; ++i) { + str += string(count_width, ' ') + ' '; + str += string(percent_width, ' '); + } + + for (size_t i = 1; i < nr_events; ++i) { + str += " "; + } + + str += " :"; + return str; +} + + +symbol_entry const * find_symbol(string const & image_name, + string const & str_vma) +{ + // do not use the bfd equivalent: + // - it does not skip space at begin + // - we does not need cross architecture compile so the native + // strtoull must work, assuming unsigned long long can contain a vma + // and on 32/64 bits box bfd_vma is 64 bits + bfd_vma vma = strtoull(str_vma.c_str(), NULL, 16); + + return samples->find_symbol(image_name, vma); +} + + +void output_info(ostream & out) +{ + out << begin_comment << '\n'; + + out << in_comment << "Command line: " << cmdline << '\n' + << in_comment << '\n'; + + out << in_comment << "Interpretation of command line:" << '\n'; + + if (!assembly) { + out << in_comment + << "Output annotated source file with samples" << '\n'; + + if (options::threshold != 0) { + out << in_comment + << "Output files where samples count reach " + << options::threshold << "% of the samples\n"; + } else { + out << in_comment << "Output all files" << '\n'; + } + } else { + out << in_comment + << "Output annotated assembly listing with samples" + << '\n'; + + if (!objdump_params.empty()) { + out << in_comment << "Passing the following " + "additional arguments to objdump ; \""; + for (size_t i = 0 ; i < objdump_params.size() ; ++i) + out << objdump_params[i] << " "; + out << "\"" << '\n'; + } + } + + out << in_comment << '\n'; + + out << in_comment << classes.cpuinfo << endl; + if (!classes.event.empty()) + out << in_comment << classes.event << endl; + + for (size_t i = 0; i < classes.v.size(); ++i) + out << in_comment << classes.v[i].longname << endl; + + out << end_comment << '\n'; +} + + +string count_str(count_array_t const & count, + count_array_t const & total) +{ + ostringstream os; + for (size_t i = 0; i < nr_events; ++i) { + os << setw(count_width) << count[i] << ' '; + + os << format_percent(op_ratio(count[i], total[i]) * 100.0, + percent_int_width, percent_fract_width); + } + return os.str(); +} + + +string asm_line_annotation(symbol_entry const * last_symbol, + string const & value) +{ + // do not use the bfd equivalent: + // - it does not skip space at begin + // - we does not need cross architecture compile so the native + // strtoull must work, assuming unsigned long long can contain a vma + // and on 32/64 bits box bfd_vma is 64 bits + // gcc 2.91.66 workaround + bfd_vma vma = 0; + vma = strtoull(value.c_str(), NULL, 16); + + string str; + + sample_entry const * sample = samples->find_sample(last_symbol, vma); + if (sample) { + str += count_str(sample->counts, samples->samples_count()); + for (size_t i = 1; i < nr_events; ++i) + str += " "; + str += " :"; + } else { + str = annotation_fill; + } + + return str; +} + + +string symbol_annotation(symbol_entry const * symbol) +{ + if (!symbol) + return string(); + + string annot = count_str(symbol->sample.counts, + samples->samples_count()); + if (annot.empty()) + return string(); + + string const & symname = symbol_names.demangle(symbol->name); + + string str = " "; + str += begin_comment + symname + " total: "; + str += count_str(symbol->sample.counts, samples->samples_count()); + str += end_comment; + return str; +} + + +/// return true if this line contains a symbol name in objdump formatting +/// symbol are on the form 08030434 : we need to be strict +/// here to avoid any interpretation of a source line as a symbol line +bool is_symbol_line(string const & str, string::size_type pos) +{ + if (str[pos] != ' ' || str[pos + 1] != '<') + return false; + + return str[str.length() - 1] == ':'; +} + + +symbol_entry const * output_objdump_asm_line(symbol_entry const * last_symbol, + string const & app_name, string const & str, + symbol_collection const & symbols, + bool & do_output) +{ + // output of objdump is a human readable form and can contain some + // ambiguity so this code is dirty. It is also optimized a little bit + // so it is difficult to simplify it without breaking something ... + + // line of interest are: "[:space:]*[:xdigit:]?[ :]", the last char of + // this regexp dis-ambiguate between a symbol line and an asm line. If + // source contain line of this form an ambiguity occur and we rely on + // the robustness of this code. + + size_t pos = 0; + while (pos < str.length() && isspace(str[pos])) + ++pos; + + if (pos == str.length() || !isxdigit(str[pos])) { + if (do_output) { + cout << annotation_fill << str << '\n'; + return last_symbol; + } + } + + while (pos < str.length() && isxdigit(str[pos])) + ++pos; + + if (pos == str.length() || (!isspace(str[pos]) && str[pos] != ':')) { + if (do_output) { + cout << annotation_fill << str << '\n'; + return last_symbol; + } + } + + if (is_symbol_line(str, pos)) { + last_symbol = find_symbol(app_name, str); + + // ! complexity: linear in number of symbol must use sorted + // by address vector and lower_bound ? + // Note this use a pointer comparison. It work because symbols + // pointer are unique + if (find(symbols.begin(), symbols.end(), last_symbol) + != symbols.end()) { + do_output = true; + } else { + do_output = false; + } + + if (do_output) + cout << str << symbol_annotation(last_symbol) << '\n'; + + } else { + // not a symbol, probably an asm line. + if (do_output) + cout << asm_line_annotation(last_symbol, str) + << str << '\n'; + } + + return last_symbol; +} + + +void do_one_output_objdump(symbol_collection const & symbols, + string const & app_name, bfd_vma start, bfd_vma end) +{ + vector args; + + args.push_back("-d"); + args.push_back("--no-show-raw-insn"); + if (source) + args.push_back("-S"); + + if (start || end != ~(bfd_vma)0) { + ostringstream arg1, arg2; + arg1 << "--start-address=" << start; + arg2 << "--stop-address=" << end; + args.push_back(arg1.str()); + args.push_back(arg2.str()); + } + + if (!objdump_params.empty()) { + for (size_t i = 0 ; i < objdump_params.size() ; ++i) + args.push_back(objdump_params[i]); + } + + args.push_back(app_name); + child_reader reader("objdump", args); + if (reader.error()) { + cerr << "An error occur during the execution of objdump:\n\n"; + cerr << reader.error_str() << endl; + return; + } + + // to filter output of symbols (filter based on command line options) + bool do_output = true; + + symbol_entry const * last_symbol = 0; + string str; + while (reader.getline(str)) { + last_symbol = output_objdump_asm_line(last_symbol, app_name, + str, symbols, do_output); + } + + // objdump always returns SUCCESS so we must rely on the stderr state + // of objdump. If objdump error message is cryptic our own error + // message will be probably also cryptic + ostringstream std_err; + ostringstream std_out; + reader.get_data(std_out, std_err); + if (std_err.str().length()) { + cerr << "An error occur during the execution of objdump:\n\n"; + cerr << std_err.str() << endl; + return ; + } + + // force error code to be acquired + reader.terminate_process(); + + // required because if objdump stop by signal all above things suceeed + // (signal error message are not output through stdout/stderr) + if (reader.error()) { + cerr << "An error occur during the execution of objdump:\n\n"; + cerr << reader.error_str() << endl; + return; + } +} + + +void output_objdump_asm(symbol_collection const & symbols, + string const & app_name) +{ + // this is only an optimisation, we can either filter output by + // directly calling objdump and rely on the symbol filtering or + // we can call objdump with the right parameter to just disassemble + // the needed part. This is a real win only when calling objdump + // a medium number of times, I dunno if the used threshold is optimal + // but it is a conservative value. + size_t const max_objdump_exec = 50; + if (symbols.size() <= max_objdump_exec) { + symbol_collection::const_iterator cit = symbols.begin(); + symbol_collection::const_iterator end = symbols.end(); + for (; cit != end; ++cit) { + bfd_vma start = (*cit)->sample.vma; + bfd_vma end = start + (*cit)->size; + do_one_output_objdump(symbols, app_name, start, end); + } + } else { + do_one_output_objdump(symbols, app_name, 0, ~bfd_vma(0)); + } +} + + +bool output_asm(string const & app_name) +{ + profile_container::symbol_choice choice; + choice.threshold = options::threshold; + choice.image_name = app_name; + choice.match_image = true; + symbol_collection symbols = samples->select_symbols(choice); + + if (!symbols.empty()) { + sort_options options; + options.add_sort_option(sort_options::sample); + options.sort(symbols, false, false); + + output_info(cout); + + output_objdump_asm(symbols, app_name); + + return true; + } + + return false; +} + + +string const source_line_annotation(debug_name_id filename, size_t linenr) +{ + string str; + + count_array_t counts = samples->samples_count(filename, linenr); + if (!counts.zero()) { + str += count_str(counts, samples->samples_count()); + for (size_t i = 1; i < nr_events; ++i) + str += " "; + str += " :"; + } else { + str = annotation_fill; + } + + return str; +} + + +string source_symbol_annotation(debug_name_id filename, size_t linenr) +{ + symbol_entry const * symbol = samples->find_symbol(filename, linenr); + + return symbol_annotation(symbol); +} + + +void output_per_file_info(ostream & out, debug_name_id filename, + count_array_t const & total_file_count) +{ + out << begin_comment << '\n' + << in_comment << "Total samples for file : " + << '"' << debug_names.name(filename) << '"' + << '\n'; + out << in_comment << '\n' << in_comment + << count_str(total_file_count, samples->samples_count()) + << '\n'; + out << end_comment << '\n' << '\n'; +} + + +string const line0_info(debug_name_id filename) +{ + string annotation = source_line_annotation(filename, 0); + if (trim(annotation, " \t:").empty()) + return string(); + + string str = " "; + str += annotation; + return str; +} + + +void do_output_one_file(ostream & out, istream & in, debug_name_id filename, + bool header) +{ + count_array_t count = samples->samples_count(filename); + + if (header) { + output_per_file_info(out, filename, count); + out << line0_info(filename) << '\n'; + } + + + if (in) { + string str; + + for (size_t linenr = 1 ; getline(in, str) ; ++linenr) { + out << source_line_annotation(filename, linenr) << str + << source_symbol_annotation(filename, linenr) + << '\n'; + } + + } else { + // FIXME : we have no input file : we just outputfooter + // so on user can known total nr of samples for this source + // later we must add code that iterate through symbol in this + // file to output one annotation for each symbol. To do this we + // need a select_symbol(filename); in profile_container which + // fall back to the implementation in symbol_container + // using a lazilly build symbol_map sorted by filename + // (necessary functors already exist in symbol_functors.h) + } + + if (!header) { + output_per_file_info(out, filename, count); + out << line0_info(filename) << '\n'; + } +} + + +void output_one_file(istream & in, debug_name_id filename, + string const & source) +{ + if (output_dir.empty()) { + do_output_one_file(cout, in, filename, true); + return; + } + + string const out_file = op_realpath(output_dir + source); + + /* Just because you're paranoid doesn't mean they're not out to + * get you ... + * + * This is just a lame final safety check. If we found the + * source, then "source" should be canonical already, and + * can't escape from the output dir. We can't use op_realpath() + * alone as that needs the file to exist already. + * + * Let's not complain again if we couldn't find the file anyway. + */ + if (out_file.find("/../") != string::npos) { + if (in) { + cerr << "refusing to create non-canonical filename " + << out_file << endl; + } + return; + } else if (!is_prefix(out_file, output_dir)) { + if (in) { + cerr << "refusing to create file " << out_file + << " outside of output directory " << output_dir + << endl; + } + return; + } + + if (is_files_identical(out_file, source)) { + cerr << "input and output files are identical: " + << out_file << endl; + return; + } + + if (create_path(out_file.c_str())) { + cerr << "unable to create file: " + << '"' << op_dirname(out_file) << '"' << endl; + return; + } + + ofstream out(out_file.c_str()); + if (!out) { + cerr << "unable to open output file " + << '"' << out_file << '"' << endl; + } else { + do_output_one_file(out, in, filename, false); + output_info(out); + } +} + + +/* Locate a source file from debug info, which may be relative */ +string const locate_source_file(debug_name_id filename_id) +{ + string const origfile = debug_names.name(filename_id); + string file = origfile; + + if (file.empty()) + return file; + + /* Allow absolute paths to be relocated to a different directory */ + if (file[0] == '/') { + vector::const_iterator cit = base_dirs.begin(); + vector::const_iterator end = base_dirs.end(); + for (; cit != end; ++cit) { + string path = op_realpath(*cit); + + if (is_prefix(file, path)) { + file = file.substr(path.length()); + break; + } + } + } + + vector::const_iterator cit = search_dirs.begin(); + vector::const_iterator end = search_dirs.end(); + + for (; cit != end; ++cit) { + string const absfile = op_realpath(*cit + "/" + file); + + if (op_file_readable(absfile)) { + return absfile; + } + } + + /* We didn't find a relocated absolute file, or a relative file, + * assume the original is correct, accounting for the + * possibility it's relative the cwd + */ + return op_realpath(origfile); +} + + +void output_source(path_filter const & filter) +{ + bool const separate_file = !output_dir.empty(); + + if (!separate_file) + output_info(cout); + + vector filenames = + samples->select_filename(options::threshold); + + for (size_t i = 0 ; i < filenames.size() ; ++i) { + string const & source = locate_source_file(filenames[i]); + + if (!filter.match(source)) + continue; + + ifstream in(source.c_str()); + + // it is common to have empty filename due to the lack + // of debug info (eg _init function) so warn only + // if the filename is non empty. The case: no debug + // info at all has already been checked. + if ((!in) && source.length()) { + cerr << "opannotate (warning): unable to open for " + "reading: " << source << endl; + } + + if (source.length()) { + output_one_file(in, filenames[i], source); + } + } +} + + +bool annotate_source(list const & images) +{ + annotation_fill = get_annotation_fill(); + + if (!output_dir.empty()) { + + if (create_path(output_dir.c_str())) { + cerr << "unable to create " << output_dir + << " directory: " << endl; + return false; + } + + // Make sure we have an absolute path. + output_dir = op_realpath(output_dir); + if (output_dir.length() && + output_dir[output_dir.length() - 1] != '/') + output_dir += '/'; + + /* Don't let the user stomp on their sources */ + if (output_dir == "/") { + cerr << "Output path of / would over-write the " + "source files" << endl; + return false; + } + } + + if (assembly) { + bool some_output = false; + + list::const_iterator it = images.begin(); + list::const_iterator const end = images.end(); + + for (; it != end; ++it) { + if (output_asm(*it)) { + some_output = true; + } + } + + if (!some_output) { + // It's the only case we must care since we know the + // selected image set is not empty + cerr << "selected image set doesn't contain any of " + << "the selected symbol\n"; + } + } else { + output_source(file_filter); + } + + return true; +} + + +int opannotate(options::spec const & spec) +{ + handle_options(spec); + + nr_events = classes.v.size(); + + samples.reset(new profile_container(true, true)); + + list images; + + list iprofiles + = invert_profiles(options::archive_path, classes, + options::extra_found_images); + + report_image_errors(iprofiles); + + list::iterator it = iprofiles.begin(); + list::iterator const end = iprofiles.end(); + + bool debug_info = false; + for (; it != end; ++it) { + bool tmp = false; + populate_for_image(options::archive_path, *samples, *it, + options::symbol_filter, &tmp); + images.push_back(it->image); + if (tmp) + debug_info = true; + } + + if (!debug_info && !options::assembly) { + cerr << "no debug information available for any binary " + << "selected and --assembly not requested\n"; + exit(EXIT_FAILURE); + } + + annotate_source(images); + + return 0; +} + +} // anonymous namespace + + +int main(int argc, char const * argv[]) +{ + // set the invocation, for the file headers later + for (int i = 0 ; i < argc ; ++i) + cmdline += string(argv[i]) + " "; + + return run_pp_tool(argc, argv, opannotate); +} diff --git a/pp/opannotate_options.cpp b/pp/opannotate_options.cpp new file mode 100644 index 0000000..4bcb694 --- /dev/null +++ b/pp/opannotate_options.cpp @@ -0,0 +1,150 @@ +/** + * @file opannotate_options.cpp + * Options for opannotate tool + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include +#include + +#include "profile_spec.h" +#include "arrange_profiles.h" +#include "op_exception.h" +#include "opannotate_options.h" +#include "popt_options.h" +#include "cverb.h" + +using namespace std; + +profile_classes classes; + +namespace options { + string archive_path; + demangle_type demangle = dmt_normal; + string output_dir; + vector search_dirs; + vector base_dirs; + merge_option merge_by; + path_filter file_filter; + string_filter symbol_filter; + bool source; + bool assembly; + vector objdump_params; + bool exclude_dependent; +} + + +namespace { + +string include_symbols; +string exclude_symbols; +string include_file; +string exclude_file; +string demangle_option = "normal"; +vector mergespec; + +popt::option options_array[] = { + popt::option(demangle_option, "demangle", 'D', + "demangle GNU C++ symbol names (default normal)", + "none|normal|smart"), + popt::option(options::output_dir, "output-dir", 'o', + "output directory", "directory name"), + popt::option(options::search_dirs, "search-dirs", 'd', + "directories to look for source files", "comma-separated paths"), + popt::option(options::base_dirs, "base-dirs", 'b', + "source file prefixes to strip", "comma-separated paths"), + popt::option(include_file, "include-file", '\0', + "include these comma separated filename", "filenames"), + popt::option(exclude_file, "exclude-file", '\0', + "exclude these comma separated filename", "filenames"), + popt::option(include_symbols, "include-symbols", 'i', + "include these comma separated symbols", "symbols"), + popt::option(exclude_symbols, "exclude-symbols", 'e', + "exclude these comma separated symbols", "symbols"), + popt::option(options::objdump_params, "objdump-params", '\0', + "additional params to pass to objdump", "parameters"), + popt::option(options::exclude_dependent, "exclude-dependent", 'x', + "exclude libs, kernel, and module samples for applications"), + popt::option(mergespec, "merge", 'm', + "comma separated list", "cpu,tid,tgid,unitmask,all"), + popt::option(options::source, "source", 's', "output source"), + popt::option(options::assembly, "assembly", 'a', "output assembly"), + popt::option(options::threshold_opt, "threshold", 't', + "minimum percentage needed to produce output", + "percent"), +}; + +} // anonymous namespace + + +void handle_options(options::spec const & spec) +{ + using namespace options; + + if (spec.first.size()) { + cerr << "differential profiles not allowed" << endl; + exit(EXIT_FAILURE); + } + + if (!assembly && !source) { + cerr << "you must specify at least --source or --assembly\n"; + exit(EXIT_FAILURE); + } + + if (!objdump_params.empty() && !assembly) { + cerr << "--objdump-params is meaningless without --assembly\n"; + exit(EXIT_FAILURE); + } + + if (search_dirs.empty() && !base_dirs.empty()) { + cerr << "--base-dirs is useless unless you specify an " + "alternative source location with --search-dirs" + << endl; + exit(EXIT_FAILURE); + } + + if (assembly && !output_dir.empty()) { + cerr << "--output-dir is meaningless with --assembly" << endl; + exit(EXIT_FAILURE); + } + + options::symbol_filter = string_filter(include_symbols, exclude_symbols); + + options::file_filter = path_filter(include_file, exclude_file); + + profile_spec const pspec = + profile_spec::create(spec.common, options::extra_found_images); + + list sample_files = pspec.generate_file_list(exclude_dependent, true); + + archive_path = pspec.get_archive_path(); + cverb << vsfile << "Archive: " << archive_path << endl; + + cverb << vsfile << "Matched sample files: " << sample_files.size() + << endl; + copy(sample_files.begin(), sample_files.end(), + ostream_iterator(cverb << vsfile, "\n")); + + demangle = handle_demangle_option(demangle_option); + + // we always merge but this have no effect on output since at source + // or assembly point of view the result will be merged anyway + merge_by = handle_merge_option(mergespec, false, exclude_dependent); + + classes = arrange_profiles(sample_files, merge_by); + + cverb << vsfile << "profile_classes:\n" << classes << endl; + + if (classes.v.empty()) { + cerr << "error: no sample files found: profile specification " + "too strict ?" << endl; + exit(EXIT_FAILURE); + } +} diff --git a/pp/opannotate_options.h b/pp/opannotate_options.h new file mode 100644 index 0000000..fce95cb --- /dev/null +++ b/pp/opannotate_options.h @@ -0,0 +1,48 @@ +/** + * @file opannotate_options.h + * Options for opannotate tool + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPANNOTATE_OPTIONS_H +#define OPANNOTATE_OPTIONS_H + +#include +#include + +#include "common_option.h" +#include "path_filter.h" + +class profile_classes; + +namespace options { + extern std::string archive_path; + extern demangle_type demangle; + extern bool source; + extern bool assembly; + extern string_filter symbol_filter; + extern path_filter file_filter; + extern std::string output_dir; + extern std::vector search_dirs; + extern std::vector base_dirs; + extern std::vector objdump_params; + extern double threshold; +} + +/// classes of sample filenames to handle +extern profile_classes classes; + +/** + * handle_options - process command line + * @param spec profile specification + * + * Process the spec, fatally complaining on error. + */ +void handle_options(options::spec const & spec); + +#endif // OPANNOTATE_OPTIONS_H diff --git a/pp/oparchive.cpp b/pp/oparchive.cpp new file mode 100644 index 0000000..308ea45 --- /dev/null +++ b/pp/oparchive.cpp @@ -0,0 +1,140 @@ +/** + * @file oparchive.cpp + * Implement oparchive utility + * + * @remark Copyright 2003, 2004 OProfile authors + * @remark Read the file COPYING + * + * @author Will Cohen + * @author John Levon + * @author Philippe Elie + */ + +#include +#include + +#include +#include +#include +#include "op_file.h" +#include "op_bfd.h" +#include "op_config.h" +#include "oparchive_options.h" +#include "file_manip.h" +#include "cverb.h" +#include "image_errors.h" + +using namespace std; + +namespace { + +int oparchive(options::spec const & spec) +{ + handle_options(spec); + + /* Check to see if directory can be created */ + if (create_path(options::outdirectory.c_str())) { + cerr << "Unable to create directory for " + << options::outdirectory << "." << endl; + exit (EXIT_FAILURE); + } + + /* copy over each of the executables and the debuginfo files */ + list iprofiles + = invert_profiles(options::archive_path, classes, + options::extra_found_images); + + report_image_errors(iprofiles); + + list::iterator it = iprofiles.begin(); + list::iterator const end = iprofiles.end(); + + cverb << vdebug << "(exe_names)" << endl << endl; + for (; it != end; ++it) { + string exe_name = it->image; + string exe_archive_file = options::outdirectory + exe_name; + + cverb << vdebug << exe_name << endl; + /* Create directory for executable file. */ + if (create_path(exe_archive_file.c_str())) { + cerr << "Unable to create directory for " + << exe_archive_file << "." << endl; + exit (EXIT_FAILURE); + } + + /* Copy actual executable files */ + copy_file(options::archive_path + exe_name, exe_archive_file); + + /* If there are any debuginfo files, copy them over. + * Need to copy the debug info file in the same + * directory as the executable. The /usr/lib/debug + * search path is not going to work. + */ + bfd * ibfd = open_bfd(exe_name); + if (ibfd) { + string global(options::archive_path + DEBUGDIR); + string dirname = op_dirname(options::archive_path + + exe_name); + string debug_filename; + if (find_separate_debug_file(ibfd, dirname, global, + debug_filename)) { + /* found something copy it over */ + string dest_debug = options::outdirectory + + dirname + "/" + + op_basename(debug_filename); + copy_file(debug_filename, dest_debug); + } + bfd_close(ibfd); + } + } + + /* copy over each of the sample files */ + list::iterator sit = sample_files.begin(); + list::iterator const send = sample_files.end(); + + cverb << vdebug << "(sample_names)" << endl << endl; + + /* Copy over each of the sample files. The sample files are + * copied after the executables to avoid the situation where + * executable is newer than the sample file. + */ + for (; sit != send; ++sit) { + string sample_name = *sit; + string sample_base = sample_name; + /* Get rid of the the archive_path from the name */ + sample_base.replace(sample_base.find(options::archive_path), + options::archive_path.size(), ""); + string sample_archive_file = options::outdirectory + sample_base; + + cverb << vdebug << (sample_name) << endl; + cverb << vdebug << " destp " << sample_archive_file << endl; + if (create_path(sample_archive_file.c_str())) { + cerr << "Unable to create directory for " + << sample_archive_file << "." << endl; + exit (EXIT_FAILURE); + } + + /* Copy over actual sample file. */ + copy_file(sample_name, sample_archive_file); + } + + /* copy over the /var/lib/oprofile/abi file if it exists */ + string abi_name = "/var/lib/oprofile/abi"; + copy_file(options::archive_path + abi_name, + options::outdirectory + abi_name); + + /* copy over the /var/lib/oprofile/oprofiled.log file */ + string log_name = "/var/lib/oprofile/oprofiled.log"; + copy_file(options::archive_path + log_name, + options::outdirectory + log_name); + + return 0; +} + +} // anonymous namespace + + +int main(int argc, char const * argv[]) +{ + run_pp_tool(argc, argv, oparchive); +} diff --git a/pp/oparchive_options.cpp b/pp/oparchive_options.cpp new file mode 100644 index 0000000..8c0988f --- /dev/null +++ b/pp/oparchive_options.cpp @@ -0,0 +1,105 @@ +/** + * @file oparchive_options.cpp + * Options for oparchive tool + * + * @remark Copyright 2002, 2003, 2004 OProfile authors + * @remark Read the file COPYING + * + * @author William Cohen + * @author Philippe Elie + */ + +#include +#include +#include +#include +#include +#include + +#include "profile_spec.h" +#include "arrange_profiles.h" +#include "oparchive_options.h" +#include "popt_options.h" +#include "string_filter.h" +#include "file_manip.h" +#include "cverb.h" + + +using namespace std; + +profile_classes classes; +list sample_files; + +namespace options { + string archive_path; + bool exclude_dependent; + merge_option merge_by; + string outdirectory; +} + + +namespace { + +vector mergespec; + +popt::option options_array[] = { + popt::option(options::outdirectory, "output-directory", 'o', + "output to the given directory", "directory"), + popt::option(options::exclude_dependent, "exclude-dependent", 'x', + "exclude libs, kernel, and module samples for applications") +}; + + +/** + * check incompatible or meaningless options + * + */ +void check_options() +{ + using namespace options; + + /* output directory is required */ + if (outdirectory.size() == 0) { + cerr << "Requires --output-directory option." << endl; + exit(EXIT_FAILURE); + } +} + +} // anonymous namespace + + +void handle_options(options::spec const & spec) +{ + using namespace options; + + if (spec.first.size()) { + cerr << "differential profiles not allowed" << endl; + exit(EXIT_FAILURE); + } + + merge_by = handle_merge_option(mergespec, true, exclude_dependent); + check_options(); + + profile_spec const pspec = + profile_spec::create(spec.common, extra_found_images); + + sample_files = pspec.generate_file_list(exclude_dependent, false); + + archive_path = pspec.get_archive_path(); + cverb << vsfile << "Archive: " << archive_path << endl; + + cverb << vsfile << "Matched sample files: " << sample_files.size() + << endl; + copy(sample_files.begin(), sample_files.end(), + ostream_iterator(cverb << vsfile, "\n")); + + classes = arrange_profiles(sample_files, merge_by); + + cverb << vsfile << "profile_classes:\n" << classes << endl; + + if (classes.v.empty()) { + cerr << "error: no sample files found: profile specification " + "too strict ?" << endl; + exit(EXIT_FAILURE); + } +} diff --git a/pp/oparchive_options.h b/pp/oparchive_options.h new file mode 100644 index 0000000..fbf7872 --- /dev/null +++ b/pp/oparchive_options.h @@ -0,0 +1,39 @@ +/** + * @file oparchive_options.h + * Options for oparchive tool + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author Will Cohen + * @author Philippe Elie + */ + +#ifndef OPARCHIVE_OPTIONS_H +#define OPARCHIVE_OPTIONS_H + +#include "common_option.h" + +class profile_classes; +class merge_option; + +namespace options { + extern std::string archive_path; + extern bool exclude_dependent; + extern merge_option merge_by; + extern std::string outdirectory; +} + +/// All the chosen sample files. +extern profile_classes classes; +extern std::list sample_files; + +/** + * handle_options - process command line + * @param spec profile specification + * + * Process the spec, fatally complaining on error. + */ +void handle_options(options::spec const & spec); + +#endif // OPARCHIVE_OPTIONS_H diff --git a/pp/opgprof.cpp b/pp/opgprof.cpp new file mode 100644 index 0000000..f56deac --- /dev/null +++ b/pp/opgprof.cpp @@ -0,0 +1,311 @@ +/** + * @file opgprof.cpp + * Implement opgprof utility + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include + +#include "op_header.h" +#include "profile.h" +#include "op_libiberty.h" +#include "op_fileio.h" +#include "string_filter.h" +#include "profile_container.h" +#include "arrange_profiles.h" +#include "image_errors.h" +#include "opgprof_options.h" +#include "cverb.h" +#include "op_file.h" + +using namespace std; + +namespace { + +#define GMON_VERSION 1 +#define GMON_TAG_TIME_HIST 0 +#define GMON_TAG_CG_ARC 1 + +struct gmon_hdr { + char cookie[4]; + u32 version; + u32 spare[3]; +}; + + +void op_write_vma(FILE * fp, op_bfd const & abfd, bfd_vma vma) +{ + // bfd vma write size is a per binary property not a bfd + // configuration property + switch (abfd.bfd_arch_bits_per_address()) { + case 32: + op_write_u32(fp, vma); + break; + case 64: + op_write_u64(fp, vma); + break; + default: + cerr << "oprofile: unknown vma size for this binary\n"; + exit(EXIT_FAILURE); + } +} + + +void get_vma_range(bfd_vma & min, bfd_vma & max, + profile_container const & samples) +{ + min = bfd_vma(-1); + max = 0; + + sample_container::samples_iterator it = samples.begin(); + sample_container::samples_iterator end = samples.end(); + for (; it != end ; ++it) { + if (it->second.vma < min) + min = it->second.vma; + if (it->second.vma > max) + max = it->second.vma; + } + + if (min == bfd_vma(-1)) + min = 0; + // we must return a range [min, max) not a range [min, max] + if (max != 0) + max += 1; +} + + +/** + * @param abfd bfd object + * @param samples_files profile container to act on + * @param gap a power of 2 + * + * return true if all sample in samples_files are at least aligned on gap. This + * function is used to get at runtime the right size of gprof bin size + * reducing gmon.out on arch with fixed size instruction length + * + */ +bool aligned_samples(profile_container const & samples, int gap) +{ + sample_container::samples_iterator it = samples.begin(); + sample_container::samples_iterator end = samples.end(); + for (; it != end ; ++it) { + if (it->second.vma % gap) + return false; + } + + return true; +} + + +void output_cg(FILE * fp, op_bfd const & abfd, profile_t const & cg_db) +{ + opd_header const & header = cg_db.get_header(); + bfd_vma offset = 0; + if (header.is_kernel || header.anon_start) + offset = abfd.get_start_offset(header.anon_start); + + profile_t::iterator_pair p_it = cg_db.samples_range(); + for (; p_it.first != p_it.second; ++p_it.first) { + bfd_vma from = p_it.first.vma() >> 32; + bfd_vma to = p_it.first.vma() & 0xffffffff; + + op_write_u8(fp, GMON_TAG_CG_ARC); + op_write_vma(fp, abfd, abfd.offset_to_pc(from + offset)); + op_write_vma(fp, abfd, abfd.offset_to_pc(to + offset)); + op_write_u32(fp, p_it.first.count()); + } +} + + +void output_gprof(op_bfd const & abfd, profile_container const & samples, + profile_t const & cg_db, string const & gmon_filename) +{ + static gmon_hdr hdr = { { 'g', 'm', 'o', 'n' }, GMON_VERSION, {0, 0, 0 } }; + + bfd_vma low_pc; + bfd_vma high_pc; + + /* FIXME worth to try more multiplier ? */ + int multiplier = 2; + if (aligned_samples(samples, 4)) + multiplier = 8; + + cverb << vdebug << "opgrof multiplier: " << multiplier << endl; + + get_vma_range(low_pc, high_pc, samples); + + cverb << vdebug << "low_pc: " << hex << low_pc << " " << "high_pc: " + << high_pc << dec << endl; + + // round-down low_pc to ensure bin number is correct in the inner loop + low_pc = (low_pc / multiplier) * multiplier; + // round-up high_pc to ensure a correct histsize calculus + high_pc = ((high_pc + multiplier - 1) / multiplier) * multiplier; + + cverb << vdebug << "low_pc: " << hex << low_pc << " " << "high_pc: " + << high_pc << dec << endl; + + size_t histsize = (high_pc - low_pc) / multiplier; + + // FIXME: must we skip the flat profile write if histsize == 0 ? + // (this can occur with callgraph w/o samples to the binary) but in + // this case user must gprof --no-flat-profile whiwh is a bit boring + // and result *seems* weirds. + + FILE * fp = op_open_file(gmon_filename.c_str(), "w"); + + op_write_file(fp, &hdr, sizeof(gmon_hdr)); + op_write_u8(fp, GMON_TAG_TIME_HIST); + + op_write_vma(fp, abfd, low_pc); + op_write_vma(fp, abfd, high_pc); + /* size of histogram */ + op_write_u32(fp, histsize); + /* profiling rate */ + op_write_u32(fp, 1); + op_write_file(fp, "samples\0\0\0\0\0\0\0\0", 15); + /* abbreviation */ + op_write_u8(fp, '1'); + + u16 * hist = (u16*)xcalloc(histsize, sizeof(u16)); + + profile_container::symbol_choice choice; + choice.threshold = options::threshold; + symbol_collection symbols = samples.select_symbols(choice); + + symbol_collection::const_iterator sit = symbols.begin(); + symbol_collection::const_iterator send = symbols.end(); + + for (; sit != send; ++sit) { + sample_container::samples_iterator it = samples.begin(*sit); + sample_container::samples_iterator end = samples.end(*sit); + for (; it != end ; ++it) { + u32 pos = (it->second.vma - low_pc) / multiplier; + u32 count = it->second.counts[0]; + + if (pos >= histsize) { + cerr << "Bogus histogram bin " << pos + << ", larger than " << pos << " !\n"; + continue; + } + + if (hist[pos] + count > (u16)-1) { + hist[pos] = (u16)-1; + cerr << "Warning: capping sample count by " + << hist[pos] + count - ((u16)-1) << endl; + } else { + hist[pos] += (u16)count; + } + } + } + + op_write_file(fp, hist, histsize * sizeof(u16)); + + if (!cg_db.empty()) + output_cg(fp, abfd, cg_db); + + op_close_file(fp); + + free(hist); +} + + +void +load_samples(op_bfd const & abfd, list const & files, + string const & image, profile_container & samples) +{ + list::const_iterator it = files.begin(); + list::const_iterator const end = files.end(); + + for (; it != end; ++it) { + // we can get call graph w/o any samples to the binary + if (it->sample_filename.empty()) + continue; + + cverb << vsfile << "loading flat samples files : " + << it->sample_filename << endl; + + profile_t profile; + + profile.add_sample_file(it->sample_filename); + profile.set_offset(abfd); + + check_mtime(abfd.get_filename(), profile.get_header()); + + samples.add(profile, abfd, image, 0); + } +} + + +void load_cg(profile_t & cg_db, list const & files) +{ + list::const_iterator it = files.begin(); + list::const_iterator const end = files.end(); + + /* the list of non cg files is a super set of the list of cg file + * (module always log a samples to non-cg files before logging + * call stack) so by using the list of non-cg file we are sure to get + * all existing cg files. + */ + for (; it != end; ++it) { + list::const_iterator cit; + list::const_iterator const cend = it->cg_files.end(); + for (cit = it->cg_files.begin(); cit != cend; ++cit) { + // FIXME: do we need filtering ? + /* We can't handle start_offset now but after splitting + * data in from/to eip. */ + cverb << vsfile << "loading cg samples file : " + << *cit << endl; + cg_db.add_sample_file(*cit); + } + } +} + + +int opgprof(options::spec const & spec) +{ + handle_options(spec); + + profile_container samples(false, true); + + bool ok = image_profile.error == image_ok; + // FIXME: symbol_filter would be allowed through option + op_bfd abfd(options::archive_path, image_profile.image, + string_filter(), ok); + if (!ok && image_profile.error == image_ok) + image_profile.error = image_format_failure; + + if (image_profile.error != image_ok) { + report_image_error(image_profile, true); + exit(EXIT_FAILURE); + } + + profile_t cg_db; + + image_group_set const & groups = image_profile.groups[0]; + image_group_set::const_iterator it; + for (it = groups.begin(); it != groups.end(); ++it) { + load_samples(abfd, it->files, image_profile.image, samples); + + load_cg(cg_db, it->files); + } + + output_gprof(abfd, samples, cg_db, options::gmon_filename); + + return 0; +} + + +} // anonymous namespace + + +int main(int argc, char const * argv[]) +{ + return run_pp_tool(argc, argv, opgprof); +} diff --git a/pp/opgprof_options.cpp b/pp/opgprof_options.cpp new file mode 100644 index 0000000..3c32b02 --- /dev/null +++ b/pp/opgprof_options.cpp @@ -0,0 +1,126 @@ +/** + * @file opgprof_options.cpp + * Options for opgprof tool + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include +#include + +#include "opgprof_options.h" +#include "popt_options.h" +#include "cverb.h" +#include "profile_spec.h" +#include "arrange_profiles.h" + +using namespace std; + +inverted_profile image_profile; + +namespace options { + string archive_path; + string gmon_filename = "gmon.out"; + + // Ugly, for build only + demangle_type demangle; +} + + +namespace { + +popt::option options_array[] = { + popt::option(options::gmon_filename, "output-filename", 'o', + "output filename, defaults to gmon.out if not specified", + "filename"), + popt::option(options::threshold_opt, "threshold", 't', + "minimum percentage needed to produce output", + "percent"), +}; + + +bool try_merge_profiles(profile_spec const & spec, bool exclude_dependent) +{ + list sample_files = spec.generate_file_list(exclude_dependent, false); + + cverb << vsfile + << "Matched sample files: " << sample_files.size() << endl; + copy(sample_files.begin(), sample_files.end(), + ostream_iterator(cverb << vsfile, "\n")); + + // opgprof merge all by default + merge_option merge_by; + merge_by.cpu = true; + merge_by.lib = true; + merge_by.tid = true; + merge_by.tgid = true; + merge_by.unitmask = true; + + profile_classes classes + = arrange_profiles(sample_files, merge_by); + + cverb << vsfile << "profile_classes:\n" << classes << endl; + + size_t nr_classes = classes.v.size(); + + list iprofiles + = invert_profiles(options::archive_path, classes, + options::extra_found_images); + + if (nr_classes == 1 && iprofiles.size() == 1) { + image_profile = *(iprofiles.begin()); + return true; + } + + // come round for another try + if (exclude_dependent) + return false; + + if (iprofiles.empty()) { + cerr << "error: no sample files found: profile specification " + "too strict ?" << endl; + exit(EXIT_FAILURE); + } + + if (nr_classes > 1 || iprofiles.size() > 1) { + cerr << "error: specify exactly one binary to process " + "and give an event: or count: specification if necessary" + << endl; + exit(EXIT_FAILURE); + } + + return false; +} + +} // anonymous namespace + + +void handle_options(options::spec const & spec) +{ + if (spec.first.size()) { + cerr << "differential profiles not allowed" << endl; + exit(EXIT_FAILURE); + } + + profile_spec const pspec = + profile_spec::create(spec.common, options::extra_found_images); + + options::archive_path = pspec.get_archive_path(); + cverb << vsfile << "Archive: " << options::archive_path << endl; + + cverb << vsfile << "output filename: " << options::gmon_filename + << endl; + + // we do a first try with exclude-dependent if it fails we include + // dependent. First try should catch "opgrof /usr/bin/make" whilst + // the second catch "opgprof /lib/libc-2.2.5.so" + if (!try_merge_profiles(pspec, true)) { + try_merge_profiles(pspec, false); + } +} diff --git a/pp/opgprof_options.h b/pp/opgprof_options.h new file mode 100644 index 0000000..7fbc580 --- /dev/null +++ b/pp/opgprof_options.h @@ -0,0 +1,37 @@ +/** + * @file opgprof_options.h + * Options for opgprof tool + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPGPROF_OPTIONS_H +#define OPGPROF_OPTIONS_H + +#include + +#include "common_option.h" + +namespace options { + extern std::string archive_path; + extern std::string gmon_filename; +} + +class inverted_profile; + +/// a set of sample filenames to handle. +extern inverted_profile image_profile; + +/** + * handle_options - process command line + * @param spec profile specification + * + * Process the spec, fatally complaining on error. + */ +void handle_options(options::spec const & spec); + +#endif // OPGPROF_OPTIONS_H diff --git a/pp/opreport.cpp b/pp/opreport.cpp new file mode 100644 index 0000000..c0ca91c --- /dev/null +++ b/pp/opreport.cpp @@ -0,0 +1,545 @@ +/** + * @file opreport.cpp + * Implement opreport utility + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include +#include +#include +#include + +#include "op_exception.h" +#include "stream_util.h" +#include "string_manip.h" +#include "file_manip.h" +#include "opreport_options.h" +#include "op_header.h" +#include "profile.h" +#include "populate.h" +#include "arrange_profiles.h" +#include "profile_container.h" +#include "callgraph_container.h" +#include "diff_container.h" +#include "symbol_sort.h" +#include "format_output.h" +#include "image_errors.h" + +using namespace std; + +namespace { + +static size_t nr_classes; + +/// storage for a merged file summary +struct summary { + count_array_t counts; + string lib_image; + + bool operator<(summary const & rhs) const { + return options::reverse_sort + ? counts[0] < rhs.counts[0] : rhs.counts[0] < counts[0]; + } + + /// add a set of files to a summary + size_t add_files(list const & files, + size_t pclass); +}; + + +size_t summary:: +add_files(list const & files, size_t pclass) +{ + size_t subtotal = 0; + + list::const_iterator it = files.begin(); + list::const_iterator const end = files.end(); + + for (; it != end; ++it) { + size_t count = profile_t::sample_count(it->sample_filename); + counts[pclass] += count; + subtotal += count; + + // FIXME: is it worth (for now yes I expect bugs ...) + if (!it->cg_files.empty()) { + throw "opreport.cpp::add_files(): unxpected non empty " + "cg file set\n"; + } + } + + return subtotal; +} + + +/** + * Summary of an application: a set of image summaries + * for one application, i.e. an application image and all + * dependent images such as libraries. + */ +struct app_summary { + /// total count of us and all dependents + count_array_t counts; + /// the main image + string image; + /// our dependent images + vector deps; + + /// construct and fill in the data + size_t add_profile(profile_set const & profile, size_t pclass); + + bool operator<(app_summary const & rhs) const { + return options::reverse_sort + ? counts[0] < rhs.counts[0] : rhs.counts[0] < counts[0]; + } + +private: + /// find a matching summary (including main app summary) + summary & find_summary(string const & image); +}; + + +summary & app_summary::find_summary(string const & image) +{ + vector::iterator sit = deps.begin(); + vector::iterator const send = deps.end(); + for (; sit != send; ++sit) { + if (sit->lib_image == image) + return *sit; + } + + summary summ; + summ.lib_image = image; + deps.push_back(summ); + return deps.back(); +} + + +size_t app_summary::add_profile(profile_set const & profile, + size_t pclass) +{ + size_t group_total = 0; + + // first the main image + summary & summ = find_summary(profile.image); + size_t app_count = summ.add_files(profile.files, pclass); + counts[pclass] += app_count; + group_total += app_count; + + // now all dependent images if any + list::const_iterator it = profile.deps.begin(); + list::const_iterator const end = profile.deps.end(); + + for (; it != end; ++it) { + summary & summ = find_summary(it->lib_image); + size_t lib_count = summ.add_files(it->files, pclass); + counts[pclass] += lib_count; + group_total += lib_count; + } + + return group_total; +} + + +/// all the summaries +struct summary_container { + summary_container(vector const & pclasses); + + /// all map summaries + vector apps; + /// total count of samples for all summaries + count_array_t total_counts; +}; + + +summary_container:: +summary_container(vector const & pclasses) +{ + typedef map app_map_t; + app_map_t app_map; + + for (size_t i = 0; i < pclasses.size(); ++i) { + list::const_iterator it + = pclasses[i].profiles.begin(); + list::const_iterator const end + = pclasses[i].profiles.end(); + + for (; it != end; ++it) { + app_map_t::iterator ait = app_map.find(it->image); + if (ait == app_map.end()) { + app_summary app; + app.image = it->image; + total_counts[i] += app.add_profile(*it, i); + app_map[app.image] = app; + } else { + total_counts[i] + += ait->second.add_profile(*it, i); + } + } + } + + app_map_t::const_iterator it = app_map.begin(); + app_map_t::const_iterator const end = app_map.end(); + + for (; it != end; ++it) { + apps.push_back(it->second); + } + + // sort by count + stable_sort(apps.begin(), apps.end()); + vector::iterator ait = apps.begin(); + vector::iterator const aend = apps.end(); + for (; ait != aend; ++ait) { + stable_sort(ait->deps.begin(), ait->deps.end()); + } +} + + +void output_header() +{ + if (!options::show_header) + return; + + cout << classes.cpuinfo << endl; + if (!classes.event.empty()) + cout << classes.event << endl; + + for (vector::size_type i = 0; + i < classes.v.size(); ++i) { + cout << classes.v[i].longname << endl; + } +} + + +string get_filename(string const & filename) +{ + return options::long_filenames ? filename : op_basename(filename); +} + + +/// Output a count and a percentage +void output_count(double total_count, size_t count) +{ + cout << setw(9) << count << ' '; + double ratio = op_ratio(count, total_count); + cout << format_percent(ratio * 100, percent_int_width, + percent_fract_width) << ' '; +} + + +void output_col_headers(bool indent) +{ + if (!options::show_header) + return; + + if (indent) + cout << '\t'; + + size_t colwidth = 9 + 1 + percent_width; + + for (size_t i = 0; i < classes.v.size(); ++i) { + string name = classes.v[i].name; + if (name.length() > colwidth) + name = name.substr(0, colwidth - 3) + + "..."; + io_state state(cout); + // gcc 2.95 doesn't know right io manipulator + cout.setf(ios::right, ios::adjustfield); + // gcc 2.95 doesn't honor setw() for std::string + cout << setw(colwidth) << name.c_str(); + cout << '|'; + } + cout << '\n'; + + if (indent) + cout << '\t'; + + for (size_t i = 0; i < classes.v.size(); ++i) { + cout << " samples| "; + io_state state(cout); + // gcc 2.95 doesn't know right io manipulator + cout.setf(ios::right, ios::adjustfield); + cout << setw(percent_width) << "%|"; + } + + cout << '\n'; + + if (indent) + cout << '\t'; + + for (size_t i = 0; i < classes.v.size(); ++i) { + cout << "-----------"; + string str(percent_width, '-'); + cout << str; + } + + cout << '\n'; +} + + +void +output_deps(summary_container const & summaries, + app_summary const & app) +{ + // the app summary itself is *always* present + // (perhaps with zero counts) so this test + // is correct + if (app.deps.size() == 1) + return; + + output_col_headers(true); + + for (size_t j = 0 ; j < app.deps.size(); ++j) { + summary const & summ = app.deps[j]; + + if (summ.counts.zero()) + continue; + + cout << '\t'; + + for (size_t i = 0; i < nr_classes; ++i) { + double tot_count = options::global_percent + ? summaries.total_counts[i] : app.counts[i]; + + output_count(tot_count, summ.counts[i]); + } + + cout << get_filename(summ.lib_image); + cout << '\n'; + } +} + + +/** + * Display all the given summary information + */ +void output_summaries(summary_container const & summaries) +{ + output_col_headers(false); + + for (size_t i = 0; i < summaries.apps.size(); ++i) { + app_summary const & app = summaries.apps[i]; + + if ((app.counts[0] * 100.0) / summaries.total_counts[0] + < options::threshold) { + continue; + } + + for (size_t j = 0; j < nr_classes; ++j) { + output_count(summaries.total_counts[j], + app.counts[j]); + } + + cout << get_filename(app.image) << '\n'; + + output_deps(summaries, app); + } +} + + +format_flags const get_format_flags(column_flags const & cf) +{ + format_flags flags(ff_none); + flags = format_flags(flags | ff_nr_samples); + flags = format_flags(flags | ff_percent | ff_symb_name); + + if (options::show_address) + flags = format_flags(flags | ff_vma); + + if (options::debug_info) + flags = format_flags(flags | ff_linenr_info); + + if (options::accumulated) { + flags = format_flags(flags | ff_nr_samples_cumulated); + flags = format_flags(flags | ff_percent_cumulated); + } + + if (classes2.v.size()) + flags = format_flags(flags | ff_diff); + + if (cf & cf_image_name) + flags = format_flags(flags | ff_image_name); + + return flags; +} + + +void output_symbols(profile_container const & pc, bool multiple_apps) +{ + profile_container::symbol_choice choice; + choice.threshold = options::threshold; + symbol_collection symbols = pc.select_symbols(choice); + options::sort_by.sort(symbols, options::reverse_sort, + options::long_filenames); + + format_output::opreport_formatter out(pc); + + out.set_nr_classes(nr_classes); + out.show_details(options::details); + out.show_long_filenames(options::long_filenames); + out.show_header(options::show_header); + out.vma_format_64bit(choice.hints & cf_64bit_vma); + out.show_global_percent(options::global_percent); + + format_flags flags = get_format_flags(choice.hints); + if (multiple_apps) + flags = format_flags(flags | ff_app_name); + + out.add_format(flags); + out.output(cout, symbols); +} + + +void output_diff_symbols(profile_container const & pc1, + profile_container const & pc2, bool multiple_apps) +{ + diff_container dc(pc1, pc2); + + profile_container::symbol_choice choice; + choice.threshold = options::threshold; + + diff_collection symbols = dc.get_symbols(choice); + + format_flags flags = get_format_flags(choice.hints); + if (multiple_apps) + flags = format_flags(flags | ff_app_name); + + format_output::diff_formatter out(dc); + + out.set_nr_classes(nr_classes); + out.show_long_filenames(options::long_filenames); + out.show_header(options::show_header); + out.show_global_percent(options::global_percent); + out.vma_format_64bit(choice.hints & cf_64bit_vma); + out.add_format(flags); + + options::sort_by.sort(symbols, options::reverse_sort, + options::long_filenames); + + out.output(cout, symbols); +} + + +void output_cg_symbols(callgraph_container const & cg, bool multiple_apps) +{ + column_flags output_hints = cg.output_hint(); + + cg_collection symbols = cg.get_symbols(); + options::sort_by.sort(symbols, options::reverse_sort, + options::long_filenames); + + format_output::cg_formatter out(cg); + + out.set_nr_classes(nr_classes); + out.show_long_filenames(options::long_filenames); + out.show_header(options::show_header); + out.vma_format_64bit(output_hints & cf_64bit_vma); + out.show_global_percent(options::global_percent); + + format_flags flags = get_format_flags(output_hints); + if (multiple_apps) + flags = format_flags(flags | ff_app_name); + + out.add_format(flags); + + out.output(cout, symbols); +} + + +int opreport(options::spec const & spec) +{ + handle_options(spec); + + nr_classes = classes.v.size(); + + if (!options::symbols) { + summary_container summaries(classes.v); + output_header(); + output_summaries(summaries); + return 0; + } + + bool multiple_apps = false; + + for (size_t i = 0; i < classes.v.size(); ++i) { + if (classes.v[i].profiles.size() > 1) + multiple_apps = true; + } + + list iprofiles + = invert_profiles(options::archive_path, classes, + options::extra_found_images); + + report_image_errors(iprofiles); + + output_header(); + + if (classes2.v.size()) { + for (size_t i = 0; i < classes2.v.size(); ++i) { + if (classes2.v[i].profiles.size() > 1) + multiple_apps |= true; + } + + profile_container pc1(options::debug_info, options::details); + + list::iterator it = iprofiles.begin(); + list::iterator const end = iprofiles.end(); + + for (; it != end; ++it) + populate_for_image(options::archive_path, pc1, + *it, options::symbol_filter, 0); + + list iprofiles2 + = invert_profiles(options::archive_path2, classes2, + options::extra_found_images); + + report_image_errors(iprofiles2); + + profile_container pc2(options::debug_info, options::details); + + list::iterator it2 = iprofiles2.begin(); + list::iterator const end2 = iprofiles2.end(); + + for (; it2 != end2; ++it2) + populate_for_image(options::archive_path2, pc2, + *it2, options::symbol_filter, 0); + + output_diff_symbols(pc1, pc2, multiple_apps); + } else if (options::callgraph) { + callgraph_container cg_container; + cg_container.populate(options::archive_path, iprofiles, + options::extra_found_images, + options::debug_info, options::threshold, + options::merge_by.lib, options::symbol_filter); + + output_cg_symbols(cg_container, multiple_apps); + } else { + profile_container samples(options::debug_info, options::details); + + list::iterator it = iprofiles.begin(); + list::iterator const end = iprofiles.end(); + + for (; it != end; ++it) + populate_for_image(options::archive_path, samples, + *it, options::symbol_filter, 0); + + output_symbols(samples, multiple_apps); + } + + return 0; +} + +} // anonymous namespace + + +int main(int argc, char const * argv[]) +{ + cout.tie(0); + return run_pp_tool(argc, argv, opreport); +} diff --git a/pp/opreport_options.cpp b/pp/opreport_options.cpp new file mode 100644 index 0000000..1e1d872 --- /dev/null +++ b/pp/opreport_options.cpp @@ -0,0 +1,279 @@ +/** + * @file opreport_options.cpp + * Options for opreport tool + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#include +#include +#include +#include +#include +#include + +#include "profile_spec.h" +#include "arrange_profiles.h" +#include "opreport_options.h" +#include "popt_options.h" +#include "string_filter.h" +#include "file_manip.h" +#include "cverb.h" + +using namespace std; + +profile_classes classes; +profile_classes classes2; + +namespace options { + string archive_path; + string archive_path2; + demangle_type demangle = dmt_normal; + bool symbols; + bool callgraph; + bool debug_info; + bool details; + bool exclude_dependent; + string_filter symbol_filter; + sort_options sort_by; + merge_option merge_by; + bool show_header = true; + bool long_filenames; + bool show_address; + bool accumulated; + bool reverse_sort; + bool global_percent; +} + + +namespace { + +string outfile; +vector mergespec; +vector sort; +vector exclude_symbols; +vector include_symbols; +string demangle_option = "normal"; + +popt::option options_array[] = { + popt::option(options::callgraph, "callgraph", 'c', + "show call graph"), + popt::option(options::details, "details", 'd', + "output detailed samples for each symbol"), + popt::option(options::symbols, "symbols", 'l', + "list all symbols"), + + popt::option(outfile, "output-file", 'o', + "output to the given filename", "file"), + + popt::option(sort, "sort", 's', + "sort by", "sample,image,app-name,symbol,debug,vma"), + popt::option(options::reverse_sort, "reverse-sort", 'r', + "use reverse sort"), + popt::option(mergespec, "merge", 'm', + "comma separated list", "cpu,lib,tid,tgid,unitmask,all"), + popt::option(options::exclude_dependent, "exclude-dependent", 'x', + "exclude libs, kernel, and module samples for applications"), + popt::option(exclude_symbols, "exclude-symbols", 'e', + "exclude these comma separated symbols", "symbols"), + popt::option(include_symbols, "include-symbols", 'i', + "include these comma separated symbols", "symbols"), + popt::option(options::threshold_opt, "threshold", 't', + "minimum percentage needed to produce output", + "percent"), + + popt::option(demangle_option, "demangle", 'D', + "demangle GNU C++ symbol names (default normal)", + "none|normal|smart"), + // PP:5 + popt::option(options::debug_info, "debug-info", 'g', + "add source file and line number to output"), + popt::option(options::show_header, "no-header", 'n', + "remove all headers from output"), + popt::option(options::show_address, "show-address", 'w', + "show VMA address of each symbol"), + popt::option(options::long_filenames, "long-filenames", 'f', + "show the full path of filenames"), + popt::option(options::accumulated, "accumulated", 'a', + "percentage field show accumulated count"), + popt::option(options::global_percent, "global-percent", '%', + "percentage are not relative to symbol count or image " + "count but total sample count"), +}; + + +void handle_sort_option() +{ + if (sort.empty()) { + // PP:5.14 sort default to sample + sort.push_back("sample"); + } + + vector::const_iterator cit = sort.begin(); + vector::const_iterator end = sort.end(); + + for (; cit != end; ++cit) { + options::sort_by.add_sort_option(*cit); + } +} + + +void handle_output_file() +{ + if (outfile.empty()) + return; + + static ofstream os(outfile.c_str()); + if (!os) { + cerr << "Couldn't open \"" << outfile + << "\" for writing." << endl; + exit(EXIT_FAILURE); + } + + cout.rdbuf(os.rdbuf()); +} + + +/// Check incompatible or meaningless options. +void check_options(bool diff) +{ + using namespace options; + + bool do_exit = false; + + if (callgraph) { + symbols = true; + if (details) { + cerr << "--callgraph is incompatible with --details" << endl; + do_exit = true; + } + + if (diff) { + cerr << "differential profiles are incompatible with --callgraph" << endl; + do_exit = true; + } + } + + if (details && diff) { + cerr << "differential profiles are incompatible with --details" << endl; + do_exit = true; + } + + if (!symbols) { + if (diff) { + cerr << "different profiles are meaningless " + "without --symbols" << endl; + do_exit = true; + } + + if (show_address) { + cerr << "--show-address is meaningless " + "without --symbols" << endl; + do_exit = true; + } + + if (debug_info || accumulated) { + cerr << "--debug-info and --accumulated are " + << "meaningless without --symbols" << endl; + do_exit = true; + } + + if (!exclude_symbols.empty() || !include_symbols.empty()) { + cerr << "--exclude-symbols and --include-symbols are " + << "meaningless without --symbols" << endl; + do_exit = true; + } + + if (find(sort_by.options.begin(), sort_by.options.end(), + sort_options::vma) != sort_by.options.end()) { + cerr << "--sort=vma is " + << "meaningless without --symbols" << endl; + do_exit = true; + } + } + + if (global_percent && symbols && !(details || callgraph)) { + cerr << "--global-percent is meaningless with --symbols " + "and without --details or --callgraph" << endl; + do_exit = true; + } + + if (do_exit) + exit(EXIT_FAILURE); +} + + +/// process a spec into classes +string process_spec(profile_classes & classes, list const & spec) +{ + using namespace options; + + copy(spec.begin(), spec.end(), + ostream_iterator(cverb << vsfile, " ")); + cverb << vsfile << "\n\n"; + + profile_spec const pspec = + profile_spec::create(spec, extra_found_images); + + list sample_files = pspec.generate_file_list(exclude_dependent, + !options::callgraph); + + cverb << vsfile << "Archive: " << pspec.get_archive_path() << endl; + + cverb << vsfile << "Matched sample files: " << sample_files.size() + << endl; + copy(sample_files.begin(), sample_files.end(), + ostream_iterator(cverb << vsfile, "\n")); + + classes = arrange_profiles(sample_files, merge_by); + + cverb << vsfile << "profile_classes:\n" << classes << endl; + + if (classes.v.empty()) { + cerr << "error: no sample files found: profile specification " + "too strict ?" << endl; + exit(EXIT_FAILURE); + } + + return pspec.get_archive_path(); +} + + +} // namespace anon + + +void handle_options(options::spec const & spec) +{ + using namespace options; + + if (details) { + symbols = true; + show_address = true; + } + + handle_sort_option(); + merge_by = handle_merge_option(mergespec, true, exclude_dependent); + handle_output_file(); + demangle = handle_demangle_option(demangle_option); + check_options(spec.first.size()); + + symbol_filter = string_filter(include_symbols, exclude_symbols); + + if (!spec.first.size()) { + archive_path = process_spec(classes, spec.common); + } else { + cverb << vsfile << "profile spec 1:" << endl; + archive_path = process_spec(classes, spec.first); + cverb << vsfile << "profile spec 2:" << endl; + archive_path2 = process_spec(classes2, spec.second); + + if (!classes.matches(classes2)) { + cerr << "profile classes are incompatible" << endl; + exit(EXIT_FAILURE); + } + } +} diff --git a/pp/opreport_options.h b/pp/opreport_options.h new file mode 100644 index 0000000..438c101 --- /dev/null +++ b/pp/opreport_options.h @@ -0,0 +1,58 @@ +/** + * @file opreport_options.h + * Options for opreport tool + * + * @remark Copyright 2003 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#ifndef OPREPORT_OPTIONS_H +#define OPREPORT_OPTIONS_H + +#include +#include +#include + +#include "common_option.h" +#include "string_filter.h" +#include "symbol_sort.h" + +class profile_classes; +class merge_option; + +namespace options { + extern std::string archive_path; + extern std::string archive_path2; + extern demangle_type demangle; + extern bool symbols; + extern bool callgraph; + extern bool debug_info; + extern bool details; + extern bool reverse_sort; + extern bool exclude_dependent; + extern sort_options sort_by; + extern merge_option merge_by; + extern bool global_percent; + extern bool long_filenames; + extern bool show_address; + extern string_filter symbol_filter; + extern bool show_header; + extern bool accumulated; +} + +/// All the chosen sample files. +extern profile_classes classes; +extern profile_classes classes2; + +/** + * handle_options - process command line + * @param spec profile specification + * + * Process the spec, fatally complaining on error. + */ +void handle_options(options::spec const & spec); + +#endif // OPREPORT_OPTIONS_H diff --git a/utils/Makefile.am b/utils/Makefile.am new file mode 100644 index 0000000..45136e0 --- /dev/null +++ b/utils/Makefile.am @@ -0,0 +1,10 @@ +AM_CPPFLAGS=-I ${top_srcdir}/libop -I ${top_srcdir}/libutil +AM_CFLAGS = @OP_CFLAGS@ + +LIBS=@POPT_LIBS@ @LIBERTY_LIBS@ + +bin_PROGRAMS = ophelp +dist_bin_SCRIPTS = opcontrol + +ophelp_SOURCES = ophelp.c +ophelp_LDADD = ../libop/libop.a ../libutil/libutil.a diff --git a/utils/Makefile.in b/utils/Makefile.in new file mode 100644 index 0000000..09093f0 --- /dev/null +++ b/utils/Makefile.in @@ -0,0 +1,482 @@ +# Makefile.in generated by automake 1.9.5 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +SOURCES = $(ophelp_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +bin_PROGRAMS = ophelp$(EXEEXT) +subdir = utils +DIST_COMMON = $(dist_bin_SCRIPTS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \ + $(top_srcdir)/m4/builtinexpect.m4 \ + $(top_srcdir)/m4/compileroption.m4 \ + $(top_srcdir)/m4/configmodule.m4 \ + $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \ + $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \ + $(top_srcdir)/m4/kerneloption.m4 \ + $(top_srcdir)/m4/kernelversion.m4 \ + $(top_srcdir)/m4/mallocattribute.m4 \ + $(top_srcdir)/m4/poptconst.m4 \ + $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \ + $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_ophelp_OBJECTS = ophelp.$(OBJEXT) +ophelp_OBJECTS = $(am_ophelp_OBJECTS) +ophelp_DEPENDENCIES = ../libop/libop.a ../libutil/libutil.a +dist_binSCRIPT_INSTALL = $(INSTALL_SCRIPT) +SCRIPTS = $(dist_bin_SCRIPTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(ophelp_SOURCES) +DIST_SOURCES = $(ophelp_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BFD_LIBS = @BFD_LIBS@ +CAT_ENTRY_END = @CAT_ENTRY_END@ +CAT_ENTRY_START = @CAT_ENTRY_START@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATE = @DATE@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DOCBOOK_ROOT = @DOCBOOK_ROOT@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KINC = @KINC@ +KSRC = @KSRC@ +KVERS = @KVERS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBERTY_LIBS = @LIBERTY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @POPT_LIBS@ @LIBERTY_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MOC = @MOC@ +MODINSTALLDIR = @MODINSTALLDIR@ +OBJEXT = @OBJEXT@ +OPROFILE_DIR = @OPROFILE_DIR@ +OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@ +OP_CFLAGS = @OP_CFLAGS@ +OP_CXXFLAGS = @OP_CXXFLAGS@ +OP_DOCDIR = @OP_DOCDIR@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POPT_LIBS = @POPT_LIBS@ +PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +QT_LIB = @QT_LIB@ +QT_VERSION = @QT_VERSION@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SIZE_T_TYPE = @SIZE_T_TYPE@ +STRIP = @STRIP@ +UIC = @UIC@ +VERSION = @VERSION@ +XML_CATALOG = @XML_CATALOG@ +XSLTPROC = @XSLTPROC@ +XSLTPROC_FLAGS = @XSLTPROC_FLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build_alias = @build_alias@ +datadir = @datadir@ +enable_abi_FALSE = @enable_abi_FALSE@ +enable_abi_TRUE = @enable_abi_TRUE@ +exec_prefix = @exec_prefix@ +have_qt_FALSE = @have_qt_FALSE@ +have_qt_TRUE = @have_qt_TRUE@ +have_xsltproc_FALSE = @have_xsltproc_FALSE@ +have_xsltproc_TRUE = @have_xsltproc_TRUE@ +host_alias = @host_alias@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kernel_support_FALSE = @kernel_support_FALSE@ +kernel_support_TRUE = @kernel_support_TRUE@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +topdir = @topdir@ +AM_CPPFLAGS = -I ${top_srcdir}/libop -I ${top_srcdir}/libutil +AM_CFLAGS = @OP_CFLAGS@ +dist_bin_SCRIPTS = opcontrol +ophelp_SOURCES = ophelp.c +ophelp_LDADD = ../libop/libop.a ../libutil/libutil.a +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign utils/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign utils/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +ophelp$(EXEEXT): $(ophelp_OBJECTS) $(ophelp_DEPENDENCIES) + @rm -f ophelp$(EXEEXT) + $(LINK) $(ophelp_LDFLAGS) $(ophelp_OBJECTS) $(ophelp_LDADD) $(LIBS) +install-dist_binSCRIPTS: $(dist_bin_SCRIPTS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(dist_bin_SCRIPTS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f $$d$$p; then \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " $(dist_binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(dist_binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \ + else :; fi; \ + done + +uninstall-dist_binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(dist_bin_SCRIPTS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ophelp.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(SCRIPTS) +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: install-binPROGRAMS install-dist_binSCRIPTS + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-dist_binSCRIPTS \ + uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-dist_binSCRIPTS \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ + ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-dist_binSCRIPTS uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/utils/opcontrol b/utils/opcontrol new file mode 100644 index 0000000..cbb4226 --- /dev/null +++ b/utils/opcontrol @@ -0,0 +1,1446 @@ +#!/bin/bash +# +# opcontrol is a script to control OProfile +# opcontrol --help and opcontrol --list-events have info +# +# Copyright 2002 +# Read the file COPYING +# +# Authors: John Levon, Philippe Elie, Will Cohen + +# ensure bash2 +if test "`echo $BASH_VERSION | cut -b1`" -lt 2; then + exec /bin/bash2 $0 $@ +fi + + +SYSCTL=do_sysctl + +# A replacement function for the sysctl (procps package) utility which is +# missing on some distribution (e.g. slack 7.0). +# Handles only the -w option of sysctl. +do_sysctl() +{ + if test "$1" != "-w"; then + echo "$0 unknown sysctl option" >&2 + exit 1 + fi + + shift + + arg=`echo $1 | awk -F= '{print $1}'` + val=`echo $1 | awk -F= '{print $2}'` + + dev_name=`echo $arg | tr . /` + + if test ! -f /proc/sys/$dev_name; then + echo "/proc/sys/$dev_name does not exist or is not a regular file" >&2 + exit 1 + fi + echo $val > /proc/sys/$dev_name +} + + +# check value is set +error_if_empty() +{ + if test -z "$2"; then + echo "No value given for option $1" >&2 + do_help + exit 1 + fi +} + + +# rm_device arguments $1=file_name +function rm_device +{ + if test -c "$1"; then + vecho "Removing $1" + rm "$1" + fi +} + + +# create_device arguments $1=file_name $2=MAJOR_NR $3=MINOR_NR +function create_device { + vecho "Doing mknod $1" + mknod "$1" c $2 $3 + if test "$?" != "0"; then + echo "Couldn't mknod $1" >&2 + exit 1 + fi + chmod 700 "$1" +} + + +move_and_remove() +{ + if test -e $1; then + mv $1 $SAMPLES_DIR/.tmp_reset.$$ + rm -rf $SAMPLES_DIR/.tmp_reset.$$ + fi +} + + +# verbose echo +vecho() +{ + if test -n "$VERBOSE"; then + echo $@ + fi +} + + +# print help message +do_help() +{ + echo "opcontrol: usage: + -l/--list-events list event types and unit masks + -?/--help this message + -v/--version show version + --init loads the oprofile module and oprofilefs + --setup give setup arguments (may be omitted) + --status show configuration + --start-daemon start daemon without starting profiling + -s/--start start data collection + -d/--dump flush the collected profiling data + -t/--stop stop data collection + -h/--shutdown stop data collection and kill daemon + -V/--verbose[=all,sfile,arcs,samples,module,misc] be verbose in the daemon log + --reset clears out data from current session + --save=name save data from current session to session_name + --deinit unload the oprofile module and oprofilefs + + -e/--event=eventspec + + Choose an event. May be specified multiple times. Of the form + "default" or "name:count:unitmask:kernel:user", where : + + name: event name, e.g. CPU_CLK_UNHALTED or RTC_INTERRUPTS + count: reset counter value e.g. 100000 + unitmask: hardware unit mask e.g. 0x0f + kernel: whether to profile kernel: 0 or 1 + user: whether to profile userspace: 0 or 1 + + -p/--separate=type,[types] + + Separate profiles as follows : + + none: no profile separation + library: separate shared library profiles per-application + kernel: same as library, plus kernel profiles + thread: per-thread/process profiles + cpu: per CPU profiles + all: all of the above + + -c/--callgraph=#depth enable callgraph sample collection with a maximum depth. + Use 0 to disable callgraph profiling. + + -i/--image=name[,names] list of binaries to profile (default is "all") + --vmlinux=file vmlinux kernel image + --no-vmlinux no kernel image (vmlinux) available + --kernel-range=start,end kernel range vma address in hexadecimal + --buffer-size=num kernel buffer size in sample units + --cpu-buffer-size=num per-cpu buffer size in units (2.6 only) + --note-table-size kernel notes buffer size in notes units (2.4 only) +" >&2 +} + + +# load the module and mount oprofilefs +load_module_26() +{ + grep oprofilefs /proc/filesystems >/dev/null + if test "$?" -ne 0; then + modprobe oprofile + if test "$?" != "0"; then + # couldn't load a module + return + fi + grep oprofile /proc/modules >/dev/null + if test "$?" != "0"; then + # didn't find module + return + fi + fi + grep oprofilefs /proc/filesystems >/dev/null + if test "$?" -ne 0; then + # filesystem still not around + return + fi + mkdir /dev/oprofile >/dev/null 2>&1 + grep oprofilefs /etc/mtab >/dev/null + if test "$?" -ne 0; then + mount -t oprofilefs nodev /dev/oprofile >/dev/null + fi + KERNEL_SUPPORT=yes + OPROFILE_AVAILABLE=yes +} + + +load_module_24() +{ + grep oprof /proc/devices >/dev/null + if test "$?" -ne 0; then + modprobe oprofile + if test "$?" != "0"; then + # couldn't load a module + return + fi + grep oprofile /proc/modules >/dev/null + if test "$?" != "0"; then + # didn't find module + return + fi + fi + KERNEL_SUPPORT=no + OPROFILE_AVAILABLE=yes +} + + +load_module() +{ + OPROFILE_AVAILABLE=no + load_module_26 + if test "$OPROFILE_AVAILABLE" != "yes"; then + load_module_24 + fi + if test "$OPROFILE_AVAILABLE" != "yes"; then + echo "Kernel doesn't support oprofile" >&2 + exit 1 + fi +} + +# setup variables related to daemon +do_init_daemon_vars() +{ + # as in op_user.h + DIR="/var/lib/oprofile" + LOCK_FILE="/var/lib/oprofile/lock" + LOG_FILE="$DIR/oprofiled.log" + SAMPLES_DIR="$DIR/samples" + CURRENT_SAMPLES_DIR=${SAMPLES_DIR}/current +} + +# pick the appropriate locations device for oprofile based on kernel +decide_oprofile_device() +{ + if test "$KERNEL_SUPPORT" = "yes"; then + MOUNT="/dev/oprofile" + DEVICE_FILE="$MOUNT/buffer" + else + MOUNT="/proc/sys/dev/oprofile" + DEVICE_FILE="$DIR/opdev" + NOTE_DEVICE_FILE="$DIR/opnotedev" + HASH_MAP_DEVICE_FILE="$DIR/ophashmapdev" + fi +} + +# initialise parameters +do_init() +{ + # for these three buffer size == 0 means use the default value + # hard-coded in op_user.h + BUF_SIZE=0 + CPU_BUF_SIZE=0 + NOTE_SIZE=0 + VMLINUX= + VERBOSE="" + SEPARATE_LIB=0 + SEPARATE_KERNEL=0 + SEPARATE_THREAD=0 + SEPARATE_CPU=0 + CALLGRAPH=0 + + OPROFILED="$OPDIR/oprofiled" + + # location for daemon setup information + SETUP_DIR="/root/.oprofile" + SETUP_FILE="$SETUP_DIR/daemonrc" + + CPUTYPE=`cat $MOUNT/cpu_type` + OP_COUNTERS=`ls $MOUNT/ | grep "^[0-9]\+\$" | tr "\n" " "` + NR_CHOSEN=0 + + DEFAULT_EVENT=`$OPHELP --get-default-event` + + IS_TIMER=0 + IS_PERFMON=0 + if test "$CPUTYPE" = "timer"; then + IS_TIMER=1 + else + case "$CPUTYPE" in + ia64/*) + IS_PERFMON=$KERNEL_SUPPORT + ;; + esac + fi +} + + +create_dir() +{ + if test ! -d "$1"; then + mkdir -p "$1" + if test "$?" != "0"; then + echo "Couldn't mkdir -p $1" >&2 + exit 1 + fi + chmod 755 "$1" + fi +} + + +# save all the setup related information +do_save_setup() +{ + create_dir "$SETUP_DIR" + + touch $SETUP_FILE + chmod 644 $SETUP_FILE + >$SETUP_FILE + + if test "$NR_CHOSEN" != "0"; then + for f in `seq 0 $((NR_CHOSEN - 1))`; do + echo "CHOSEN_EVENTS[${f}]=${CHOSEN_EVENTS[$f]}" >>$SETUP_FILE + done + fi + + echo "NR_CHOSEN=$NR_CHOSEN" >>$SETUP_FILE + + echo "SEPARATE_LIB=$SEPARATE_LIB" >> $SETUP_FILE + echo "SEPARATE_KERNEL=$SEPARATE_KERNEL" >> $SETUP_FILE + echo "SEPARATE_THREAD=$SEPARATE_THREAD" >> $SETUP_FILE + echo "SEPARATE_CPU=$SEPARATE_CPU" >> $SETUP_FILE + echo "VMLINUX=$VMLINUX" >> $SETUP_FILE + echo "IMAGE_FILTER=$IMAGE_FILTER" >> $SETUP_FILE + # write the actual information to file + if test "$BUF_SIZE" != "0"; then + echo "BUF_SIZE=$BUF_SIZE" >> $SETUP_FILE + fi; + if test "$KERNEL_SUPPORT" = "yes"; then + echo "CPU_BUF_SIZE=$CPU_BUF_SIZE" >> $SETUP_FILE + fi + if test "$KERNEL_SUPPORT" != "yes"; then + echo "NOTE_SIZE=$NOTE_SIZE" >> $SETUP_FILE + fi + echo "CALLGRAPH=$CALLGRAPH" >> $SETUP_FILE +} + + +# reload all the setup-related information +do_load_setup() +{ + if test -f "$SETUP_FILE"; then + # load the actual information from file + # FIXME this is insecure, arbitrary commands could be added to + # $SETUP_FILE and be executed as root + source $SETUP_FILE + fi + + vecho "Parameters used:" + vecho "CPUTYPE $CPUTYPE" + if test "$BUF_SIZE" != "0"; then + vecho "BUF_SIZE $BUF_SIZE" + else + vecho "BUF_SIZE default value" + fi; + if test "$KERNEL_SUPPORT" = "yes"; then + if test "$CPU_BUF_SIZE" != "0"; then + vecho "CPU_BUF_SIZE $CPU_BUF_SIZE" + else + vecho "CPU_BUF_SIZE default value" + fi; + fi + + vecho "SEPARATE_LIB $SEPARATE_LIB" + vecho "SEPARATE_KERNEL $SEPARATE_KERNEL" + vecho "SEPARATE_THREAD $SEPARATE_THREAD" + vecho "SEPARATE_CPU $SEPARATE_CPU" + vecho "CALLGRAPH $CALLGRAPH" + vecho "VMLINUX $VMLINUX" +} + + +check_valid_args() +{ + if test -z "$VMLINUX"; then + echo "No vmlinux file specified. You must specify the correct vmlinux file, e.g." >&2 + echo "opcontrol --vmlinux=/path/to/vmlinux" >&2 + echo "If you do not have a vmlinux file, use " >&2 + echo "opcontrol --no-vmlinux" >&2 + echo "Enter opcontrol --help for full options" >&2 + exit 1 + fi + + if test -f "$VMLINUX"; then + return + fi + + if test "$VMLINUX" = "none"; then + return + fi + + echo "The specified vmlinux file \"$VMLINUX\" doesn't exist." >&2 + exit 1 +} + + +# get start and end points of the kernel +get_kernel_range() +{ + if test ! -z "$KERNEL_RANGE"; then + return; + fi + + if test "$VMLINUX" = "none"; then + return; + fi + + # start at the start of .text and then continue to the end + range_info=`objdump -h $VMLINUX 2>/dev/null | grep " .text "` + tmp1=`echo $range_info | awk '{print $4}'` + tmp_length=`echo $range_info | awk '{print $3}'` + tmp2=`objdump -h $VMLINUX --adjust-vma=0x$tmp_length 2>/dev/null | grep " .text " | awk '{print $4}'` + + if test -z "$tmp1" -o -z "$tmp2"; then + echo "The specified file $VMLINUX does not seem to be valid" >&2 + echo "Make sure you are using vmlinux not vmlinuz" >&2 + vecho "found start as \"$tmp1\", end as \"$tmp2\"" >&2 + exit 1 + fi + + KERNEL_RANGE="`echo $tmp1`,`echo $tmp2`" + vecho "KERNEL_RANGE $KERNEL_RANGE" +} + + +# validate --separate= parameters. This function is called with IFS=, +# so on each argument is splitted +validate_separate_args() +{ + error_if_empty $1 $2 # we need at least one argument + local i=1 + SEPARATE_LIB=0 + SEPARATE_KERNEL=0 + SEPARATE_THREAD=0 + SEPARATE_CPU=0 + while (($i < $#)); do + shift + case "$1" in + lib|library) + SEPARATE_LIB=1 + ;; + kernel) + # first implied by second + SEPARATE_LIB=1 + SEPARATE_KERNEL=1 + ;; + thread) + SEPARATE_THREAD=1 + ;; + cpu) + SEPARATE_CPU=1 + ;; + all) + SEPARATE_LIB=1 + SEPARATE_KERNEL=1 + SEPARATE_THREAD=1 + SEPARATE_CPU=1 + ;; + none) + SEPARATE_LIB=0 + SEPARATE_KERNEL=0 + SEPARATE_THREAD=0 + SEPARATE_CPU=0 + ;; + *) + echo "invalid --separate= argument: $1" + exit 1 + esac + done +} + + +# check the counters make sense, and resolve the hardware allocation +verify_counters() +{ + if test "$IS_TIMER" = 1; then + if test "$NR_CHOSEN" != 0; then + echo "You cannot specify any performance counter events" >&2 + echo "because OProfile is in timer mode." >&2 + exit 1 + fi + return + fi + + OPHELP_ARGS= + + if test "$NR_CHOSEN" != 0; then + for f in `seq 0 $((NR_CHOSEN - 1))`; do + if test "${CHOSEN_EVENTS[$f]}" != ""; then + OPHELP_ARGS="$OPHELP_ARGS ${CHOSEN_EVENTS[$f]}" + fi + done + + HW_CTRS=`$OPHELP --check-events $OPHELP_ARGS --callgraph=$CALLGRAPH` + if test "$?" != 0; then + exit 1 + fi + fi +} + + +# setup any needed default value in chosen events +normalise_events() +{ + if test "$NR_CHOSEN" -le 0; then + return + fi + + for f in `seq 0 $((NR_CHOSEN - 1))`; do + if test "${CHOSEN_EVENTS[$f]}" != ""; then + EVENT=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $1}'` + EVENT_VAL=`$OPHELP $EVENT` + if test "$?" != 0; then + exit 1 + fi + COUNT=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $2}'` + UNIT_MASK=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $3}'` + KERNEL=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $4}'` + USER=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $5}'` + if test -z "$UNIT_MASK"; then + TMPEVENT="$EVENT:$COUNT" + UNIT_MASK=`$OPHELP --unit-mask $TMPEVENT` + if test "$?" != 0; then + exit 1 + fi + fi + if test -z "$KERNEL"; then + KERNEL=1 + fi + if test -z "$USER"; then + USER=1 + fi + + CHOSEN_EVENTS[$f]=$EVENT:$COUNT:$UNIT_MASK:$KERNEL:$USER + fi + done +} + + +# get and check specified options +do_options() +{ + EXCLUSIVE_ARGC=0 + SETUP=no + NEED_SETUP=no + SEEN_EVENT=0 + + # load any default settings + do_load_setup + + while [ "$#" -ne 0 ] + do + arg=`printf %s $1 | awk -F= '{print $1}'` + val=`printf %s $1 | awk -F= '{print $2}'` + shift + if test -z "$val"; then + local possibleval=$1 + printf %s $1 "$possibleval" | grep ^- >/dev/null 2>&1 + if test "$?" != "0"; then + val=$possibleval + shift + fi + fi + + case "$arg" in + + --init) + # this is already done in load_module + # because need to know the processor type + # and number of registers + INIT=yes; + EXCLUSIVE_ARGC=`expr $EXCLUSIVE_ARGC + 1` + EXCLUSIVE_ARGV="$arg" + ;; + + --setup) + SETUP=yes + ;; + + --start-daemon) + if test "$KERNEL_SUPPORT" != "yes"; then + echo "$arg unsupported. use \"--start\"" >&2 + exit 1 + fi + START_DAEMON=yes + EXCLUSIVE_ARGC=`expr $EXCLUSIVE_ARGC + 1` + EXCLUSIVE_ARGV="$arg" + ;; + + -s|--start) + START=yes + EXCLUSIVE_ARGC=`expr $EXCLUSIVE_ARGC + 1` + EXCLUSIVE_ARGV="$arg" + ;; + + -d|--dump) + DUMP=yes + ONLY_DUMP=yes + EXCLUSIVE_ARGC=`expr $EXCLUSIVE_ARGC + 1` + EXCLUSIVE_ARGV="$arg" + ;; + + -t|--stop) + if test "$KERNEL_SUPPORT" != "yes"; then + echo "$arg unsupported. use \"--shutdown\"" >&2 + exit 1 + fi + DUMP=yes + STOP=yes + EXCLUSIVE_ARGC=`expr $EXCLUSIVE_ARGC + 1` + EXCLUSIVE_ARGV="$arg" + ;; + + -h|--shutdown) + DUMP=yes + STOP=yes + KILL_DAEMON=yes + EXCLUSIVE_ARGC=`expr $EXCLUSIVE_ARGC + 1` + EXCLUSIVE_ARGV="$arg" + ;; + + --status) + STATUS=yes + ;; + + --reset) + DUMP=yes + RESET=yes + EXCLUSIVE_ARGC=`expr $EXCLUSIVE_ARGC + 1` + EXCLUSIVE_ARGV="$arg" + ;; + + --save) + error_if_empty $arg $val + DUMP=yes + SAVE_SESSION=yes + SAVE_NAME=$val + EXCLUSIVE_ARGC=`expr $EXCLUSIVE_ARGC + 1` + EXCLUSIVE_ARGV="$arg" + ;; + + --deinit) + DUMP=yes + STOP=yes + KILL_DAEMON=yes + DEINIT=yes + EXCLUSIVE_ARGC=`expr $EXCLUSIVE_ARGC + 1` + EXCLUSIVE_ARGV="$arg" + ;; + + # --setup options + + --buffer-size) + error_if_empty $arg $val + BUF_SIZE=$val + DO_SETUP=yes + ;; + --cpu-buffer-size) + if test "$KERNEL_SUPPORT" != "yes"; then + echo "$arg unsupported for this kernel version" + exit 1 + fi + error_if_empty $arg $val + CPU_BUF_SIZE=$val + DO_SETUP=yes + ;; + -e|--event) + error_if_empty $arg $val + # reset any read-in defaults from daemonrc + if test "$SEEN_EVENT" = "0"; then + NR_CHOSEN=0 + SEEN_EVENT=1 + fi + if test "$val" = "default"; then + val=$DEFAULT_EVENT + fi + CHOSEN_EVENTS[$NR_CHOSEN]=$val + NR_CHOSEN=`expr $NR_CHOSEN + 1` + DO_SETUP=yes + ;; + -p|--separate) + OLD_IFS=$IFS + IFS=, + validate_separate_args $arg $val + IFS=$OLD_IFS + DO_SETUP=yes + ;; + -c|--callgraph) + error_if_empty $arg $val + if test ! -f $MOUNT/backtrace_depth; then + echo "Call-graph profiling unsupported on this kernel/hardware" >&2 + exit 1 + fi + CALLGRAPH=$val + DO_SETUP=yes + ;; + --vmlinux) + error_if_empty $arg $val + VMLINUX=$val + DO_SETUP=yes + # check validity + get_kernel_range + ;; + --no-vmlinux) + VMLINUX=none + DO_SETUP=yes + ;; + --kernel-range) + error_if_empty $arg $val + KERNEL_RANGE=$val + DO_SETUP=yes + ;; + --note-table-size) + error_if_empty $arg $val + if test $"KERNEL_SUPPORT" = "yes"; then + echo "\"$arg\" meaningless on this kernel" >&2 + exit 1 + else + NOTE_SIZE=$val + fi + DO_SETUP=yes + ;; + -i|--image) + error_if_empty $arg $val + if test "$val" = "all"; then + IMAGE_FILTER= + else + IMAGE_FILTER=$val + fi + DO_SETUP=yes + ;; + + -V|--verbose) + if test -z "$val"; then + VERBOSE="all" + else + VERBOSE=$val + fi + ;; + + -l|--list-events) + EXCLUSIVE_ARGC=`expr $EXCLUSIVE_ARGC + 1` + EXCLUSIVE_ARGV="$arg" + exec $OPHELP + ;; + + *) + echo "Unknown option \"$arg\". See opcontrol --help" >&2 + exit 1 + ;; + esac + done + + normalise_events + verify_counters + + # error checking to make sure options make sense + if test "$EXCLUSIVE_ARGC" -gt 1; then + echo "Option \"$EXCLUSIVE_ARGV\" not valid with other options." >&2 + exit 1 + fi + + if test "$SETUP" = "yes" -a "$DO_SETUP" != "yes"; then + echo "No options specified for --setup." >&2 + exit 1 + fi + + if test -n "$VERBOSE"; then + if test "$START" != "yes" -a "$START_DAEMON" != "yes"; then + echo "Option --verbose may only be used with --start or --start-daemon" >&2 + exit 1 + fi + fi + + if test "$DO_SETUP" = "yes"; then + SETUP="$DO_SETUP" + fi + + if test "$EXCLUSIVE_ARGC" -eq 1 -a "$SETUP" = "yes"; then + if test "$EXCLUSIVE_ARGV" != "--start-daemon" -a "$EXCLUSIVE_ARGV" != "--start"; then + echo "Option \"--setup\" not valid with \"$EXCLUSIVE_ARGV\"." >&2 + exit 1 + fi + fi +} + + +# stop any existing daemon +do_stop() +{ + if test ! -f "$LOCK_FILE"; then + echo "Daemon not running" >&2 + return + fi + + kill -s 0 `cat $LOCK_FILE` 2>/dev/null + if test "$?" -ne 0; then + echo "Detected stale lock file. Removing." >&2 + rm -f "$LOCK_FILE" + return + fi + + if test $KERNEL_SUPPORT = "yes"; then + echo "Stopping profiling." + echo 0 >/dev/oprofile/enable + fi + kill -s USR2 `cat $LOCK_FILE` 2>/dev/null +} + + +# kill the daemon process(es) +do_kill_daemon() +{ + if test ! -f "$LOCK_FILE"; then + # no error message, do_kill_deamon imply stop and stop already + # output "Daemon not running" + return + fi + + kill -s 0 `cat $LOCK_FILE` 2>/dev/null + if test "$?" -ne 0; then + echo "Detected stale lock file. Removing." >&2 + rm -f "$LOCK_FILE" + return + fi + + echo "Killing daemon." + + if test $KERNEL_SUPPORT = "yes"; then + kill -TERM `cat $LOCK_FILE` + else + echo 1 >/proc/sys/dev/oprofile/dump_stop + fi + + COUNT=0 + while test -n "`pidof oprofiled`" + do + sleep 1 + + # because oprofiled only sets a variable inside the + # signal handler itself, it's possible to miss a + # signal just before it goes to sleep waiting for + # data from the kernel that never arrives. So we + # remind it it needs to die - this works because + # the signal will bring oprofiled out of the kernel + # back into userspace + if test $KERNEL_SUPPORT = "yes"; then + pid=`cat $LOCK_FILE 2>/dev/null` + kill -TERM "$pid" 2>/dev/null + fi + + COUNT=`expr $COUNT + 1` + if test "$COUNT" -eq 15; then + echo "Daemon stuck shutting down; killing !" + kill -9 `cat $LOCK_FILE` + fi + done + + # already removed unless we forced the kill + rm -f /var/lib/oprofile/lock +} + + +rm_devices_24() +{ + rm_device "$DEVICE_FILE" + rm_device "$NOTE_DEVICE_FILE" + rm_device "$HASH_MAP_DEVICE_FILE" +} + + +create_devices_24() +{ + MAJOR_NR=`grep oprof /proc/devices | awk '{print $1}'` + + create_device $DEVICE_FILE $MAJOR_NR 0 + create_device $NOTE_DEVICE_FILE $MAJOR_NR 2 + create_device $HASH_MAP_DEVICE_FILE $MAJOR_NR 1 +} + + +# setup and start module +do_setup() +{ + create_dir "$DIR" + + >$LOG_FILE + + if test "$KERNEL_SUPPORT" != "yes"; then + rm_devices_24 + create_devices_24 + fi + + create_dir "$CURRENT_SAMPLES_DIR" +} + + +# set a sysctl/oprofilefs parameter +set_param() +{ + if test "$KERNEL_SUPPORT" = "yes"; then + echo $2 >$MOUNT/$1 + else + $SYSCTL -w dev.oprofile.$1=$2 + fi +} + + +# set a sysctl/oprofilefs counter parameter +set_ctr_param() +{ + # no such thing for perfmon + if test "$IS_PERFMON" = "yes"; then + return + fi + + if test "$KERNEL_SUPPORT" = "yes"; then + echo $3 >$MOUNT/$1/$2 + else + $SYSCTL -w dev.oprofile.$1.$2=$3 + fi +} + + +# If EVENT_STR has more than one token in it (i.e., the event ID), +# this implies some additional information is present that is associated +# with the event. For example, for PPC64 architectures, the values +# required to program the MMCRs for the given event are returned along +# with the event. This function will perform any needed validation +# of such event mapping data. +check_event_mapping_data() +{ + + if [ "$CPUTYPE" = "ppc64/power4" -o "$CPUTYPE" = "ppc64/power5" -o "$CPUTYPE" = "ppc64/970" ]; then + MMCR0=`echo $EVENT_STR | awk '{print $2}'` + MMCR1=`echo $EVENT_STR | awk '{print $3}'` + MMCRA=`echo $EVENT_STR | awk '{print $4}'` + MMCR0_VAL=`echo $MMCR0 | awk -F: '{print $2}'` + MMCR1_VAL=`echo $MMCR1 | awk -F: '{print $2}'` + MMCRA_VAL=`echo $MMCRA | awk -F: '{print $2}'` + + ## mmcr0, mmcr1, mmcra are for all ppc64 counters + # Save first event mmcr settings to compare with additional + # events. All events must have the same mmcrx values i.e. be in + # the same group. Only one event is assigned per counter, + # hence there will not be a conflict on the counters + if [ "$MMCR0_CK_VAL" = "" ] ; then + MMCR0_CK_VAL=$MMCR0_VAL + MMCR1_CK_VAL=$MMCR1_VAL + MMCRA_CK_VAL=$MMCRA_VAL + else + # make sure all events are from the same group + if test $MMCR0_CK_VAL != $MMCR0_VAL \ + -o $MMCR1_CK_VAL != $MMCR1_VAL \ + -o $MMCRA_CK_VAL != $MMCRA_VAL ; then + echo "ERROR: The specified events are not from the same group." + echo " Use 'opcontrol --list-events' to see event groupings." + exit 1 + fi + fi + fi +} + + +do_param_setup() +{ + # different names + if test $BUF_SIZE != 0; then + if test "$KERNEL_SUPPORT" = "yes"; then + echo $BUF_SIZE >$MOUNT/buffer_size + else + $SYSCTL -w dev.oprofile.bufsize=$BUF_SIZE + fi + fi + + if test $CPU_BUF_SIZE != 0; then + if test "$KERNEL_SUPPORT" = "yes"; then + echo $CPU_BUF_SIZE >$MOUNT/cpu_buffer_size + else + echo "cpu-buffer-size not supported - ignored" >&2 + fi + fi + + if test $NOTE_SIZE != 0; then + set_param notesize $NOTE_SIZE + fi + + if test "$KERNEL_SUPPORT" = "yes" -a -f $MOUNT/backtrace_depth; then + set_param backtrace_depth $CALLGRAPH + elif test "$CALLGRAPH" != "0"; then + echo "Call-graph profiling not supported - ignored" >&2 + fi + + if test "$IS_TIMER" = 1; then + return + fi + + # use the default setup if none set + if test "$NR_CHOSEN" = 0; then + CHOSEN_EVENTS[0]=$DEFAULT_EVENT + NR_CHOSEN=1 + HW_CTRS=`$OPHELP --check-events $DEFAULT_EVENT --callgraph=$CALLGRAPH` + echo "Using default event: ${CHOSEN_EVENTS[0]}" + fi + + # Necessary in this case : + # opcontrol ctr0-on ctr1-on then opcontrol ctr0-on + for f in $OP_COUNTERS ; do + set_ctr_param $f enabled 0 + set_ctr_param $f event 0 + set_ctr_param $f count 0 + done + + verify_counters + + OPROFILED_EVENTS= + for f in `seq 0 $((NR_CHOSEN - 1))`; do + if test "${CHOSEN_EVENTS[$f]}" != ""; then + EVENT=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $1}'` + EVENT_STR=`$OPHELP $EVENT` + # For some architectures, additional information associated with given + # event is returned in EVENT_STR, so we validate this information if necessary + check_event_mapping_data + EVENT_VAL=`echo $EVENT_STR | awk '{print $1}'` + COUNT=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $2}'` + UNIT_MASK=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $3}'` + KERNEL=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $4}'` + USER=`echo ${CHOSEN_EVENTS[$f]} | awk -F: '{print $5}'` + CTR=`echo $HW_CTRS | awk "{print \\$$((f + 1))}"` + + if test "$EVENT" = "RTC_INTERRUPTS"; then + set_param rtc_value $COUNT + $SYSCTL -w dev.oprofile.rtc_value=$COUNT + else + set_ctr_param $CTR enabled 1 + set_ctr_param $CTR event $EVENT_VAL + let loop_count=1 + for i in ${EVENT_STR}; do + #Skip first argument of EVENT_STR (event val) since we've already + #processed that value. + if test "$loop_count" -gt 1; then + KEY=`echo $i | awk -F: '{print $1}'` + VAL=`echo $i | awk -F: '{print $2}'` + set_ctr_param "" $KEY $VAL + fi + let loop_count="$loop_count"+1 + done + set_ctr_param $CTR count $COUNT + set_ctr_param $CTR kernel $KERNEL + set_ctr_param $CTR user $USER + set_ctr_param $CTR unit_mask $UNIT_MASK + fi + OPROFILED_EVENTS=${OPROFILED_EVENTS}$EVENT:$EVENT_VAL: + OPROFILED_EVENTS=${OPROFILED_EVENTS}$CTR:$COUNT:$UNIT_MASK: + OPROFILED_EVENTS=${OPROFILED_EVENTS}$KERNEL:$USER, + fi + done +} + + +do_start_daemon() +{ + + if test -f "$LOCK_FILE"; then + kill -s 0 `cat $LOCK_FILE` 2>/dev/null + if test "$?" -eq 0; then + return; + else + echo "Detected stale lock file. Removing." >&2 + rm -f "$LOCK_FILE" + fi + fi + + do_setup + do_load_setup + check_valid_args + get_kernel_range + do_param_setup + + OPD_ARGS=" \ + --separate-lib=$SEPARATE_LIB \ + --separate-kernel=$SEPARATE_KERNEL \ + --separate-thread=$SEPARATE_THREAD \ + --separate-cpu=$SEPARATE_CPU" + + OPD_ARGS="$OPD_ARGS --events=$OPROFILED_EVENTS" + + if test "$VMLINUX" = "none"; then + OPD_ARGS="$OPD_ARGS --no-vmlinux" + else + OPD_ARGS="$OPD_ARGS --vmlinux=$VMLINUX --kernel-range=$KERNEL_RANGE" + fi + + if ! test -z "$IMAGE_FILTER"; then + OPD_ARGS="$OPD_ARGS --image=$IMAGE_FILTER" + fi + + if test -n "$VERBOSE"; then + OPD_ARGS="$OPD_ARGS --verbose=$VERBOSE" + fi + + vecho "executing oprofiled $OPD_ARGS" + + $OPROFILED $OPD_ARGS + + COUNT=0 + while ! test -f "$DIR/lock" + do + sleep 1 + COUNT=`expr $COUNT + 1` + if test "$COUNT" -eq 10; then + echo "Couldn't start oprofiled." >&2 + echo "Check the log file \"$LOG_FILE\" and kernel syslog" >&2 + exit 1 + fi + done + + echo "Daemon started." +} + + +do_start() +{ + if test "$KERNEL_SUPPORT" = "yes"; then + echo 1 >$MOUNT/enable + fi + kill -s USR1 `cat $LOCK_FILE` 2>/dev/null + echo "Profiler running." +} + + +# print status +do_status() +{ + OPROFILED_PID=`cat $DIR/lock 2>/dev/null` + if test -n "$OPROFILED_PID" -a -d "/proc/$OPROFILED_PID"; then + echo "Daemon running: pid $OPROFILED_PID" + else + echo "Daemon not running" + fi + + if test "$NR_CHOSEN" != "0"; then + for f in `seq 0 $((NR_CHOSEN - 1))`; do + echo "Event 0: ${CHOSEN_EVENTS[$f]}" + done + fi + + SEPARATE="" + if test "$SEPARATE_LIB" = "1"; then + SEPARATE="library"; + fi + if test "$SEPARATE_KERNEL" = "1"; then + SEPARATE="$SEPARATE kernel"; + fi + if test "$SEPARATE_THREAD" = "1"; then + SEPARATE="$SEPARATE thread"; + fi + if test "$SEPARATE_CPU" = "1"; then + SEPARATE="$SEPARATE cpu"; + fi + + if test -z "$SEPARATE"; then + SEPARATE=none + fi + + echo "Separate options: $SEPARATE" + echo "vmlinux file: $VMLINUX" + + if test -z "$IMAGE_FILTER"; then + echo "Image filter: none" + else + echo "Image filter: $IMAGE_FILTER" + fi + + echo "Call-graph depth: $CALLGRAPH" + if test "$BUF_SIZE" != "0"; then + echo "Buffer size: $BUF_SIZE" + fi; + if test "$KERNEL_SUPPORT" != "yes"; then + if test "$NOTE_SIZE" != "0"; then + echo "Note buffer size: $NOTE_SIZE" + fi + else + if test "$CPU_BUF_SIZE" != "0"; then + echo "CPU buffer size: $CPU_BUF_SIZE" + fi + fi + + exit 0 +} + + +# do_dump_data +# returns 0 if successful +# returns 1 if the daemon is unable to dump data +# exit 1 if we need to be root to dump +do_dump_data() +{ + # make sure that the daemon is not dead and gone + if test -e "$DIR/lock"; then + OPROFILED_PID=`cat $DIR/lock` + if test ! -d "/proc/$OPROFILED_PID"; then + echo "dump fail: daemon died during last run ?" >&2 + return 1; + fi + else + return 1; + fi + + if test "$KERNEL_SUPPORT" = "yes"; then + # find current time + TMPFILE=`mktemp /tmp/oprofile.XXXXXX` || exit 1 + if ! test -w $MOUNT/dump; then + if test "$UID" != "0"; then + echo "You must be root to dump with this kernel version" + exit 1 + fi + fi + echo 1 > $MOUNT/dump + # loop until there is a file to check and + # the modification data of $MOUNT/dump after TMPFILE + while [ \( ! -e "$DIR/complete_dump" \) -o \( "$TMPFILE" -nt "$DIR/complete_dump" \) ] + do + if test ! -d "/proc/$OPROFILED_PID"; then + rm $TMPFILE + echo "dump fail: either daemon died during last run or dies during dump" >&2 + return 1 + fi + sleep 1; + done + rm $TMPFILE + else + echo 1 > $MOUNT/dump + # HACK ! + sleep 2 + fi + return 0; +} + +# do_dump +# returns 0 if successful +# exits if unsuccessful +do_dump() +{ + do_dump_data + if test $? -ne 0 -a "$ONLY_DUMP" = "yes"; then + echo "Unable to complete dump of oprofile data: is the oprofile daemon running?" >& 2 + exit 1; + fi + return 0; +} + +# tell daemon to re-open the sample files +hup_daemon() +{ + if test -f "$LOCK_FILE"; then + echo -n "Signalling daemon... " + kill -HUP `cat $LOCK_FILE` + echo "done" + fi +} + + +# move all the sample files to a sample directory +do_save_session() +{ + SAVE_DIR="${SAMPLES_DIR}/${SAVE_NAME}" + + if test -e "$SAVE_DIR"; then + echo "session $SAVE_DIR already exists" >&2 + exit 1 + fi + + if ! test -e $CURRENT_SAMPLES_DIR; then + echo "$CURRENT_SAMPLES_DIR doesn't exist: nothing to save" >&2 + exit 0 + fi + + # FIXME: I don't think it's worth checking for empty current directory + + mv $CURRENT_SAMPLES_DIR $SAVE_DIR + if test "$?" != "0"; then + echo "Couldn't move $CURRENT_SAMPLES_DIR to $SAVE_DIR" >&2 + exit 1 + fi + + hup_daemon +} + + +# remove all the sample files +do_reset() +{ + if test -z "$SAMPLES_DIR"; then + echo "opcontrol:do_reset() SAMPLES_DIR is empty!" + exit 1; + fi + + # daemon use {kern} and {root} subdir, it's not a typo to not use ${} + move_and_remove $SAMPLES_DIR/current/{kern} + move_and_remove $SAMPLES_DIR/current/{root} + + hup_daemon +} + + +do_deinit() +{ + # unmount /dev/oprofile if it is mounted + OPROF_FS=`grep /dev/oprofile /etc/mtab` + if test -n "$OPROF_FS"; then + umount /dev/oprofile + fi + # unload the oprofile module if it is around + OPROF_MOD=`lsmod | grep oprofile` + if test -n "$OPROF_MOD"; then + echo "Unloading oprofile module" >& 2 + rmmod oprofile + fi +} + + +# The function that calls the appropriate operations +do_operations() +{ + # INIT always done by load_module to get access to cputype + # thus INIT is a noop + + if test "$STATUS" = "yes"; then + do_status + fi + + if test "$SETUP" = "yes"; then + check_valid_args + do_save_setup + fi + + if test "$START_DAEMON" = "yes"; then + do_start_daemon + fi + + if test "$START" = "yes"; then + do_start_daemon + do_start + fi + + if test "$DUMP" = "yes"; then + do_dump + fi + + if test "$SAVE_SESSION" = "yes"; then + do_save_session + fi + + if test "$STOP" = "yes"; then + do_stop + fi + + if test "$KILL_DAEMON" = "yes"; then + do_kill_daemon + fi + + if test "$RESET" = "yes"; then + do_reset + fi + + if test "$DEINIT" = "yes"; then + do_deinit + fi +} + +# early check for --version, --help +check_version_help() +{ + + OPHELP="$OPDIR/ophelp" + + for i in $@; do + case "$i" in + -\?|--help) + do_help + exit 0 + ;; + + -v|--version) + echo -n "`basename $0`: " + $OPHELP --version | cut -d' ' -f2- + exit 0 + ;; + + esac + done +} + + +#determine which module is loaded +check_version() +{ + OPROFILE_AVAILABLE=no + grep oprofilefs /etc/mtab >/dev/null + if test "$?" -eq 0; then + # need to have oprofilefs mounted for this to work on 2.6 + KERNEL_SUPPORT=yes + OPROFILE_AVAILABLE=yes + return + fi + # need to have /proc/oprof available for this to work on 2.4 + grep oprof /proc/devices >/dev/null + if test "$?" -eq 0; then + KERNEL_SUPPORT=no + OPROFILE_AVAILABLE=yes + return + fi +} + + +# main + +# determine the location of opcontrol and related programs +OPCONTROL=`which $0` +OPDIR=`dirname $OPCONTROL` + +PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin + +check_version_help $@ + +if test -z "$1"; then + do_help + exit 0 +fi + +if test "$UID" = "0"; then + load_module +fi +check_version +do_init_daemon_vars +decide_oprofile_device +if test "$UID" != "0"; then + if test "$1" = "--dump" -a -z "$2"; then + ONLY_DUMP=yes + do_dump + exit 0; + elif test "$1" = "--list-events" -a -z "$2"; then + exec $OPHELP + else + echo "Normal users are limited to either '--dump' or '--list-events'." >&2 + exit 1 + fi +fi + +do_init +do_options $@ +do_operations diff --git a/utils/ophelp.c b/utils/ophelp.c new file mode 100644 index 0000000..b297ed3 --- /dev/null +++ b/utils/ophelp.c @@ -0,0 +1,472 @@ +/** + * @file ophelp.c + * Print out PMC event information + * + * @remark Copyright 2002 OProfile authors + * @remark Read the file COPYING + * + * @author John Levon + * @author Philippe Elie + */ + +#define _GNU_SOURCE +#include +#include +#include +#include + +#include "op_version.h" +#include "op_events.h" +#include "op_popt.h" +#include "op_cpufreq.h" +#include "op_hw_config.h" +#include "op_string.h" +#include "op_alloc_counter.h" +#include "op_parse_event.h" +#include "op_libiberty.h" + +static char const ** chosen_events; +struct parsed_event * parsed_events; +static op_cpu cpu_type = CPU_NO_GOOD; +static char * cpu_string; +static int callgraph_depth; + +static poptContext optcon; + + +/// return the Hamming weight (number of set bits) +static size_t hweight(size_t mask) +{ + size_t count = 0; + + while (mask) { + mask &= mask - 1; + count++; + } + + return count; +} + + +/** + * help_for_event - output event name and description + * @param i event number + * + * output an help string for the event @i + */ +static void help_for_event(struct op_event * event) +{ + uint i, j; + uint mask; + + size_t nr_counters = op_get_nr_counters(cpu_type); + + printf("%s", event->name); + + printf(": (counter: "); + + mask = event->counter_mask; + if (hweight(mask) == nr_counters) { + printf("all"); + } else { + for (i = 0; i < CHAR_BIT * sizeof(event->counter_mask); ++i) { + if (mask & (1 << i)) { + printf("%d", i); + mask &= ~(1 << i); + if (mask) + printf(", "); + } + } + } + + printf(")\n\t%s (min count: %d)\n", event->desc, event->min_count); + + if (strcmp(event->unit->name, "zero")) { + + printf("\tUnit masks (default 0x%x)\n", + event->unit->default_mask); + printf("\t----------\n"); + + for (j = 0; j < event->unit->num; j++) { + printf("\t0x%.2x: %s\n", + event->unit->um[j].value, + event->unit->um[j].desc); + } + } +} + + +static void check_event(struct parsed_event * pev, + struct op_event const * event) +{ + int ret; + int min_count; + int const callgraph_min_count_scale = 15; + + if (!event) { + fprintf(stderr, "No event named %s is available.\n", + pev->name); + exit(EXIT_FAILURE); + } + + ret = op_check_events(0, event->val, pev->unit_mask, cpu_type); + + if (ret & OP_INVALID_UM) { + fprintf(stderr, "Invalid unit mask 0x%x for event %s\n", + pev->unit_mask, pev->name); + exit(EXIT_FAILURE); + } + + min_count = event->min_count; + if (callgraph_depth) + min_count *= callgraph_min_count_scale; + if (pev->count < min_count) { + fprintf(stderr, "Count %d for event %s is below the " + "minimum %d\n", pev->count, pev->name, min_count); + exit(EXIT_FAILURE); + } +} + + +static void resolve_events(void) +{ + size_t count; + size_t i, j; + size_t * counter_map; + size_t nr_counters = op_get_nr_counters(cpu_type); + struct op_event const * selected_events[nr_counters]; + + count = parse_events(parsed_events, nr_counters, chosen_events); + if (count > nr_counters) { + fprintf(stderr, "Not enough hardware counters.\n"); + exit(EXIT_FAILURE); + } + + for (i = 0; i < count; ++i) { + for (j = i + 1; j < count; ++j) { + struct parsed_event * pev1 = &parsed_events[i]; + struct parsed_event * pev2 = &parsed_events[j]; + + if (!strcmp(pev1->name, pev2->name) && + pev1->count == pev2->count && + pev1->unit_mask == pev2->unit_mask && + pev1->kernel == pev2->kernel && + pev1->user == pev2->user) { + fprintf(stderr, "All events must be distinct.\n"); + exit(EXIT_FAILURE); + } + } + } + + for (i = 0; i < count; ++i) { + struct parsed_event * pev = &parsed_events[i]; + + selected_events[i] = find_event_by_name(pev->name); + + check_event(pev, selected_events[i]); + } + + counter_map = map_event_to_counter(selected_events, count, cpu_type); + + if (!counter_map) { + fprintf(stderr, "Couldn't allocate hardware counters for the selected events.\n"); + exit(EXIT_FAILURE); + } + + for (i = 0; i < count; ++i) { + printf("%d ", (unsigned int) counter_map[i]); + } + printf("\n"); + + free(counter_map); +} + + +static void show_unit_mask(void) +{ + struct op_event * event; + size_t count; + size_t nr_counter = op_get_nr_counters(cpu_type); + + count = parse_events(parsed_events, nr_counter, chosen_events); + if (count > 1) { + fprintf(stderr, "More than one event specified.\n"); + exit(EXIT_FAILURE); + } + + event = find_event_by_name(parsed_events[0].name); + + if (!event) { + fprintf(stderr, "No such event found.\n"); + exit(EXIT_FAILURE); + } + + printf("%d\n", event->unit->default_mask); +} + + +static void show_default_event(void) +{ + struct op_default_event_descr descr; + + op_default_event(cpu_type, &descr); + + if (descr.name[0] == '\0') + return; + + printf("%s:%lu:%lu:1:1\n", descr.name, descr.count, descr.um); +} + + +static int show_vers; +static int get_cpu_type; +static int check_events; +static int unit_mask; +static int get_default_event; + +static struct poptOption options[] = { + { "cpu-type", 'c', POPT_ARG_STRING, &cpu_string, 0, + "use the given CPU type", "cpu type", }, + { "check-events", 'e', POPT_ARG_NONE, &check_events, 0, + "check the given event descriptions for validity", NULL, }, + { "unit-mask", 'u', POPT_ARG_NONE, &unit_mask, 0, + "default unit mask for the given event", NULL, }, + { "get-cpu-type", 'r', POPT_ARG_NONE, &get_cpu_type, 0, + "show the auto-detected CPU type", NULL, }, + { "get-default-event", 'd', POPT_ARG_NONE, &get_default_event, 0, + "get the default event", NULL, }, + { "callgraph", '\0', POPT_ARG_INT, &callgraph_depth, 0, + "use this callgraph depth", "callgraph depth", }, + { "version", 'v', POPT_ARG_NONE, &show_vers, 0, + "show version", NULL, }, + POPT_AUTOHELP + { NULL, 0, 0, NULL, 0, NULL, NULL, }, +}; + +/** + * get_options - process command line + * @param argc program arg count + * @param argv program arg array + * + * Process the arguments, fatally complaining on error. + */ +static void get_options(int argc, char const * argv[]) +{ + optcon = op_poptGetContext(NULL, argc, argv, options, 0); + + if (show_vers) { + show_version(argv[0]); + } + + /* non-option, must be a valid event name or event specs */ + chosen_events = poptGetArgs(optcon); + + /* don't free the context now, we need chosen_events */ +} + + +/** make valgrind happy */ +static void cleanup(void) +{ + int i; + for (i = 0; i < op_get_nr_counters(cpu_type); ++i) { + if (parsed_events[i].name) + free(parsed_events[i].name); + } + op_free_events(); + if (optcon) + poptFreeContext(optcon); + if (parsed_events) + free(parsed_events); +} + + +int main(int argc, char const * argv[]) +{ + struct list_head * events; + struct list_head * pos; + char const * pretty; + size_t nr_counter; + + atexit(cleanup); + + get_options(argc, argv); + + /* usefull for testing purpose to allow to force the cpu type + * with --cpu-type */ + if (cpu_string) { + cpu_type = op_get_cpu_number(cpu_string); + } else { + cpu_type = op_get_cpu_type(); + } + + if (cpu_type == CPU_NO_GOOD) { + fprintf(stderr, "cpu_type '%s' is not valid\n", + cpu_string ? cpu_string : "unset"); + exit(EXIT_FAILURE); + } + + nr_counter = op_get_nr_counters(cpu_type); + parsed_events = xcalloc(nr_counter, sizeof(struct parsed_event)); + + pretty = op_get_cpu_type_str(cpu_type); + + if (get_cpu_type) { + printf("%s\n", pretty); + exit(EXIT_SUCCESS); + } + + if (get_default_event) { + show_default_event(); + exit(EXIT_SUCCESS); + } + + if (cpu_type == CPU_TIMER_INT) { + if (!check_events) + printf("Using timer interrupt.\n"); + exit(EXIT_SUCCESS); + } + + events = op_events(cpu_type); + + if (!chosen_events && (unit_mask || check_events)) { + fprintf(stderr, "No events given.\n"); + exit(EXIT_FAILURE); + } + + if (unit_mask) { + show_unit_mask(); + exit(EXIT_SUCCESS); + } + + if (check_events) { + resolve_events(); + exit(EXIT_SUCCESS); + } + + /* without --check-events, the only argument must be an event name */ + if (chosen_events && chosen_events[0]) { + if (chosen_events[1]) { + fprintf(stderr, "Too many arguments.\n"); + exit(EXIT_FAILURE); + } + + list_for_each(pos, events) { + struct op_event * event = list_entry(pos, struct op_event, event_next); + + if (strcmp(event->name, chosen_events[0]) == 0) { + char const * map = find_mapping_for_event(event->val, cpu_type); + if (map) { + printf("%d %s\n", event->val, map); + } else { + printf("%d\n", event->val); + } + exit(EXIT_SUCCESS); + } + } + fprintf(stderr, "No such event \"%s\"\n", chosen_events[0]); + exit(EXIT_FAILURE); + } + + /* default: list all events */ + + printf("oprofile: available events for CPU type \"%s\"\n\n", pretty); + switch (cpu_type) { + case CPU_HAMMER: + break; + case CPU_ATHLON: + printf ("See AMD document x86 optimisation guide (22007.pdf), Appendix D\n\n"); + break; + case CPU_PPRO: + case CPU_PII: + case CPU_PIII: + case CPU_P6_MOBILE: + case CPU_P4: + case CPU_P4_HT2: + printf("See Intel Architecture Developer's Manual Volume 3, Appendix A and\n" + "Intel Architecture Optimization Reference Manual (730795-001)\n\n"); + break; + case CPU_IA64: + case CPU_IA64_1: + case CPU_IA64_2: + printf("See Intel Itanium Processor Reference Manual\n" + "for Software Development (Document 245320-003),\n" + "Intel Itanium Processor Reference Manual\n" + "for Software Optimization (Document 245473-003),\n" + "Intel Itanium 2 Processor Reference Manual\n" + "for Software Development and Optimization (Document 251110-001)\n\n"); + break; + case CPU_AXP_EV4: + case CPU_AXP_EV5: + case CPU_AXP_PCA56: + case CPU_AXP_EV6: + case CPU_AXP_EV67: + printf("See Alpha Architecture Reference Manual\n" + "ftp://ftp.compaq.com/pub/products/alphaCPUdocs/alpha_arch_ref.pdf\n"); + break; + case CPU_ARM_XSCALE1: + case CPU_ARM_XSCALE2: + printf("See Intel XScale Core Developer's Manual\n" + "Chapter 8 Performance Monitoring\n"); + break; + break; + + case CPU_PPC64_POWER4: + case CPU_PPC64_POWER5: + case CPU_PPC64_970: + printf("Obtain PowerPC64 processor documentation at:\n" + "http://www-306.ibm.com/chips/techlib/techlib.nsf/productfamilies/PowerPC\n"); + break; + + case CPU_MIPS_24K: + printf("See Programming the MIPS32 24K Core " + "available from www.mips.com\n"); + break; + case CPU_MIPS_R10000: + case CPU_MIPS_R12000: + printf("See NEC R10000 / R12000 User's Manual\n" + "http://www.necelam.com/docs/files/U10278EJ3V0UM00.pdf\n"); + break; + case CPU_MIPS_RM7000: + printf("See RM7000 Family User Manual " + "available from www.pmc-sierra.com\n"); + break; + case CPU_MIPS_RM9000: + printf("See RM9000x2 Family User Manual " + "available from www.pmc-sierra.com\n"); + break; + case CPU_MIPS_SB1: + case CPU_MIPS_VR5432: + printf("See NEC VR5443 User's Manual, Volume 1\n" + "http://www.necelam.com/docs/files/1375_V1.pdf\n"); + break; + case CPU_MIPS_VR5500: + printf("See NEC R10000 / R12000 User's Manual\n" + "http://www.necel.com/nesdis/image/U16677EJ3V0UM00.pdf\n"); + break; + + case CPU_PPC_E500: + printf("See PowerPC e500 Core Complex Reference Manual\n" + "Chapter 7: Performance Monitor\n" + "Downloadable from http://www.freescale.com\n"); + break; + + case CPU_RTC: + break; + + // don't use default, if someone add a cpu he wants a compiler warning + // if he forgets to handle it here. + case CPU_TIMER_INT: + case CPU_NO_GOOD: + case MAX_CPU_TYPE: + printf("%d is not a valid processor type.\n", cpu_type); + break; + } + + list_for_each(pos, events) { + struct op_event * event = list_entry(pos, struct op_event, event_next); + help_for_event(event); + } + + return EXIT_SUCCESS; +}