gp-display-html.in 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. #!/usr/bin/perl
  2. # Copyright (C) 2021 Free Software Foundation, Inc.
  3. # Contributed by Oracle.
  4. #
  5. # This file is part of GNU Binutils.
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 3, or (at your option)
  10. # any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, 51 Franklin Street - Fifth Floor, Boston,
  20. # MA 02110-1301, USA.
  21. #------------------------------------------------------------------------------
  22. # gp-display-html, last updated July 2021
  23. #
  24. # NOTE: This is a skeleton version. The real code will follow as an update.
  25. #------------------------------------------------------------------------------
  26. use strict;
  27. use warnings;
  28. #------------------------------------------------------------------------------
  29. # Poor man's version of a boolean.
  30. #------------------------------------------------------------------------------
  31. my $TRUE = 1;
  32. my $FALSE = 0;
  33. #-------------------------------------------------------------------------------
  34. # Define the driver command, tool name and version number.
  35. #-------------------------------------------------------------------------------
  36. my $driver_cmd = "gprofng display html";
  37. my $tool_name = "gp-display-html";
  38. my $binutils_version = "BINUTILS_VERSION";
  39. my $version_info = $tool_name . " GNU binutils version " . $binutils_version;
  40. #------------------------------------------------------------------------------
  41. # This is cosmetic, but helps with the scoping of variables.
  42. #------------------------------------------------------------------------------
  43. main ();
  44. exit (0);
  45. #------------------------------------------------------------------------------
  46. # THE SUBROUTINES
  47. #------------------------------------------------------------------------------
  48. #------------------------------------------------------------------------------
  49. # This is the driver part of the program.
  50. #------------------------------------------------------------------------------
  51. sub
  52. main
  53. {
  54. my $subr_name = "main";
  55. my $ignore_value;
  56. #------------------------------------------------------------------------------
  57. # If no options are given, print the help info and exit.
  58. #------------------------------------------------------------------------------
  59. $ignore_value = early_scan_specific_options();
  60. $ignore_value = be_patient ();
  61. return (0);
  62. } #-- End of subroutine main
  63. sub
  64. be_patient
  65. {
  66. print "Functionality not implemented yet - please stay tuned for updates\n";
  67. } #-- End of subroutine be_patient
  68. #------------------------------------------------------------------------------
  69. # Prints the version number and license information.
  70. #------------------------------------------------------------------------------
  71. sub
  72. print_version_info
  73. {
  74. print "$version_info\n";
  75. print "Copyright (C) 2021 Free Software Foundation, Inc.\n";
  76. print "License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.\n";
  77. print "This is free software: you are free to change and redistribute it.\n";
  78. print "There is NO WARRANTY, to the extent permitted by law.\n";
  79. return (0);
  80. } #-- End of subroutine print_version_info
  81. #-------------------------------------------------------------------------------
  82. # Print the help overview
  83. #-------------------------------------------------------------------------------
  84. sub
  85. print_help_info
  86. {
  87. print
  88. "Usage: $driver_cmd [OPTION(S)] EXPERIMENT(S)\n".
  89. "\n".
  90. "Process one or more experiments to generate a directory containing an index.html\n".
  91. "file that can be used to browse the experiment data\n".
  92. "\n".
  93. "Options:\n".
  94. "\n".
  95. " --help print usage information and exit.\n".
  96. " --version print the version number and exit.\n".
  97. " --verbose {on|off} enable (on) or disable (off) verbose mode; the default is \"off\".\n".
  98. "\n".
  99. "\n".
  100. " -o, --output <dir-name> use <dir-name> to store the results in; the default\n".
  101. " name is ./display.<n>.html with <n> the first number\n".
  102. " not in use; an existing directory is not overwritten.\n".
  103. "\n".
  104. " -O, --overwrite <dir-name> use <dir-name> to store the results in and overwrite\n".
  105. " any existing directory with the same name; make sure\n".
  106. " that umask is set to the correct access permissions.\n".
  107. "\n".
  108. " -fl, --func_limit <limit> impose a limit on the number of functions processed;\n".
  109. " this is an integer number; set to 0 to process all\n".
  110. " functions; the default value is 100.\n".
  111. "\n".
  112. " -ct, --calltree {on|off} enable or disable an html page with a call tree linked\n".
  113. " from the bottom of the first page; default is off.\n".
  114. "\n".
  115. " -tp, --threshold_percentage <percentage> provide a percentage of metric accountability; the\n".
  116. " inclusion of functions for each metric will take\n".
  117. " place in sort order until the percentage has been\n".
  118. " reached.\n".
  119. "\n".
  120. " -dm, --default_metrics {on|off} enable or disable automatic selection of metrics\n".
  121. " and use a default set of metrics; the default is off.\n".
  122. "\n".
  123. " -im, --ignore_metrics <metric-list> ignore the metrics from <metric-list>.\n".
  124. "\n".
  125. " -db, --debug {on|off} enable/disable debug mode; print detailed information to assist with troubleshooting\n".
  126. " or further development of this tool; default is off.\n".
  127. "\n".
  128. " -q, --quiet {on|off} disable/enable the display of warnings; default is off.\n".
  129. "\n".
  130. "Environment:\n".
  131. "\n".
  132. "The options can be set in a configuration file called .gp-display-html.rc. This\n".
  133. "file needs to be either in the current directory, or in the home directory of the user.\n".
  134. "The long name of the option without the leading dashes is supported. For example calltree\n".
  135. "to enable or disable the call tree. Note that some options take a value. In case the same option\n".
  136. "occurs multiple times in this file, only the last setting encountered is preserved.\n".
  137. "\n".
  138. "Documentation:\n".
  139. "\n".
  140. "A getting started guide for gprofng is maintained as a Texinfo manual. If the info and\n".
  141. "gprofng programs are properly installed at your site, the command \"info gprofng\"\n".
  142. "should give you access to this document.\n".
  143. "\n".
  144. "See also:\n".
  145. "\n".
  146. "gprofng(1), gp-archive(1), gp-collect-app(1), gp-display-src(1), gp-display-text(1)\n";
  147. return (0);
  148. } #-- End of subroutine print_help_info
  149. #------------------------------------------------------------------------------
  150. # Scan the command line for specific options.
  151. #------------------------------------------------------------------------------
  152. sub
  153. early_scan_specific_options
  154. {
  155. my $subr_name = "early_scan_specific_options";
  156. my $ignore_value;
  157. my $found_option;
  158. my $option_has_value;
  159. my $option_value;
  160. my $verbose_setting = $FALSE;
  161. my $debug_setting = $FALSE;
  162. my $quiet_setting = $FALSE;
  163. $option_has_value = $FALSE;
  164. ($found_option, $option_value) = find_target_option (\@ARGV, $option_has_value, "--version");
  165. if ($found_option)
  166. {
  167. $ignore_value = print_version_info ();
  168. exit(0);
  169. }
  170. $option_has_value = $FALSE;
  171. ($found_option, $option_value) = find_target_option (\@ARGV, $option_has_value, "--help");
  172. if ($found_option)
  173. {
  174. $ignore_value = print_help_info ();
  175. exit(0);
  176. }
  177. return (0);
  178. } #-- End of subroutine early_scan_specific_options
  179. #------------------------------------------------------------------------------
  180. # Scan the command line to see if the specified option is present.
  181. #
  182. # Two types of options are supported: options without value (e.g. --help) or
  183. # those that are set to "on" or "off".
  184. #------------------------------------------------------------------------------
  185. sub
  186. find_target_option
  187. {
  188. my ($command_line_ref, $has_value, $target_option) = @_;
  189. my @command_line = @{ $command_line_ref };
  190. my ($command_line_string) = join(" ", @command_line);
  191. my $option_value = "not set";
  192. my $found_option = $FALSE;
  193. if ($command_line_string =~ /\s*($target_option)\s*(on|off)*\s*/)
  194. {
  195. if ($has_value)
  196. {
  197. #------------------------------------------------------------------------------
  198. # We are looking for this kind if substring: "--verbose on"
  199. #------------------------------------------------------------------------------
  200. if (defined($1) and defined($2))
  201. {
  202. if ( ($2 eq "on") or ($2 eq "off") )
  203. {
  204. $found_option = $TRUE;
  205. $option_value = $2;
  206. }
  207. }
  208. }
  209. else
  210. {
  211. #------------------------------------------------------------------------------
  212. # We are looking for this kind if substring: "--help"
  213. #------------------------------------------------------------------------------
  214. if (defined($1))
  215. {
  216. $found_option = $TRUE;
  217. }
  218. }
  219. }
  220. return($found_option, $option_value);
  221. } #-- End of subroutine find_target_option