summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-02-08 09:58:26 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-02-08 10:10:15 (GMT)
commitc29506a51108d3093b323b05a4f356847c60b607 (patch) (side-by-side diff)
treead174cecf194d6073e7e62c27d7976e5dd3f26c1
parent9cc96ff20dac0d7d2c9091937395f85dc4fc8259 (diff)
downloadcflow-c29506a51108d3093b323b05a4f356847c60b607.tar.gz
cflow-c29506a51108d3093b323b05a4f356847c60b607.tar.bz2
New options: --all and --no-main
* NEWS: Document --all and --no-main * configure.ac: Version 1.5.90 * doc/cflow.texi: Document --all and --no-main * src/cflow.h (all_functions): New extern. * src/main.c: New options: -A (--all) and --no-main * src/output.c (tree_output): Output all graphs if all_functions is set or no main function is defined.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--NEWS25
-rw-r--r--configure.ac5
-rw-r--r--doc/cflow.texi28
-rw-r--r--src/cflow.h4
-rw-r--r--src/main.c18
-rw-r--r--src/output.c10
6 files changed, 72 insertions, 18 deletions
diff --git a/NEWS b/NEWS
index 11d811d..d469db2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,27 @@
-GNU cflow NEWS -- history of user-visible changes. 2016-05-17
-Copyright (C) 2005-2007, 2009-2011, 2014-2017 Sergey Poznyakoff
+GNU cflow NEWS -- history of user-visible changes. 2019-02-08
See the end of file for copying conditions.
Please send cflow bug reports to <bug-cflow@gnu.org>.
+
+Version 1.5.90 (Git)
+
+* New option --all (-A)
+
+Produce graphs for all global functions in the program. Use this
+option if your program contains functions which are not directly
+reachable from main().
+
+The output consist of separate flow graphs for each global function
+defined in the program. These graphs will be placed after the graph
+for main() (if it exists), and will be ordered lexicographically by
+the function name.
+
+* New option --no-main
+
+This option has the same effect as '--all', except that the graph for
+main() function (if it exists) is treated same way as all the other
+graphs, i.e. it will not be placed at the top of output, but in its
+place as per the lexicographic ordering of function names.
Version 1.5, 2016-05-17
@@ -99,7 +118,7 @@ Initial version restored from 1997 snapshots.
----------------------------------------------------------------------
* Copyright information:
-Copyright (C) 2005-2007, 2009, 2010, 2011, 2016 Sergey Poznyakoff
+Copyright (C) 2005-2019 Sergey Poznyakoff
Permission is granted to anyone to make or distribute verbatim copies
of this document as received, in any medium, provided that the
diff --git a/configure.ac b/configure.ac
index 35f55f8..4aa58aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,5 @@
# This file is part of GNU cflow
-# Copyright (C) 2005, 2007, 2009, 2011, 2014-2016 Free Software
-# Foundation, Inc.
+# Copyright (C) 2005-2019 Free Software Foundation, Inc.
#
# Written by Sergey Poznyakoff
#
@@ -18,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ(2.61)
-AC_INIT([GNU cflow], [1.5], [bug-cflow@gnu.org])
+AC_INIT([GNU cflow], [1.5.90], [bug-cflow@gnu.org])
AC_CONFIG_SRCDIR([src/cflow.h])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([1.11 gnits tar-ustar dist-bzip2 dist-xz std-options
diff --git a/doc/cflow.texi b/doc/cflow.texi
index 643a792..4d613ea 100644
--- a/doc/cflow.texi
+++ b/doc/cflow.texi
@@ -30,7 +30,7 @@ Published by the Free Software Foundation,
51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA
-Copyright @copyright{} 2005, 2010, 2014-2017 Sergey Poznyakoff
+Copyright @copyright{} 2005-2019 Sergey Poznyakoff
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
@@ -209,8 +209,8 @@ main() <int () at whoami.c:25>:
the function called @code{main}. It is convenient when analyzing a set
of input files comprising an entire @code{C} program. However, there
are circumstances where a user would want to see only a part of
-the graph starting on particular function. @command{Cflow}
-allows to select such function using @option{--main} (@option{-m})
+the graph starting on particular function. One can instruct @command{cflow}
+to start output from the desiredfunction using @option{--main} (@option{-m})
command line option. Thus, running
@example
@@ -231,6 +231,14 @@ who_am_i() <int who_am_i (void) at whoami.c:8>:
@end group
@end example
+Many programs (such as libraries or interpreters) define functions
+that are not directly reachable from the main function. To produce
+flow graph for all functions in the program, use the @option{--all}
+(@option{-A}) option. The output will then include separate flow
+graphs for each global function defined in the program. These graphs
+will be placed after the graph for @code{main} (if it exists), and
+will be ordered lexicographically by the function name.
+
@node Direct and Reverse
@chapter Two Types of Flow Graphs.
@cindex @option{--reverse}
@@ -1200,6 +1208,14 @@ configuration file.
with a bullet (@bullet{}).
@table @option
+@cindex @option{-A}
+@cindex @option{--all}
+@item -A
+@itemx --all
+ Produce graphs for all global functions in the program. Use this
+option if your program contains functions, which are not directly
+reachable from @code{main} (@pxref{start symbol}).
+
@cindex @option{-a}
@cindex @option{--ansi}
@cindex @option{--no-ansi}
@@ -1313,6 +1329,12 @@ For more information, @xref{Symbols}.
@itemx --main=@var{name}
Assume main function to be called @var{name}. @xref{start symbol}.
+@cindex @option{--no-main}
+@item --no-main
+ There's no main function in the program. This option has the
+same effect as @option{--all}, except that, if the program defines
+the @code{main} function, it will be treated as any other functions.
+
@cindex @option{-n}
@cindex @option{--number}
@cindex @option{--no-number}
diff --git a/src/cflow.h b/src/cflow.h
index 1a5ec76..8779a68 100644
--- a/src/cflow.h
+++ b/src/cflow.h
@@ -1,6 +1,5 @@
/* This file is part of GNU cflow
- Copyright (C) 1997, 2005, 2007, 2009-2010, 2014-2017 Sergey
- Poznyakoff
+ Copyright (C) 1997-2019 Sergey Poznyakoff
GNU cflow is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -162,6 +161,7 @@ extern int brief_listing;
extern int reverse_tree;
extern int out_line;
extern char *start_name;
+extern int all_functions;
extern int max_depth;
extern int emacs_option;
extern int debug;
diff --git a/src/main.c b/src/main.c
index e67b3e0..a5535c7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,5 @@
/* This file is part of GNU cflow
- Copyright (C) 1997, 2005, 2007, 2009-2011, 2014-2017 Sergey
- Poznyakoff
+ Copyright (C) 1997-2019 Sergey Poznyakoff
GNU cflow is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -44,6 +43,7 @@ enum option_code {
OPT_NO_TREE,
OPT_NO_BRIEF,
OPT_NO_EMACS,
+ OPT_NO_MAIN,
OPT_NO_VERBOSE,
OPT_NO_NUMBER,
OPT_NO_PRINT_LEVEL,
@@ -105,6 +105,8 @@ static struct argp_option options[] = {
N_("Register SYMBOL with given TYPE, or define an alias (if := is used). Valid types are: keyword (or kw), modifier, qualifier, identifier, type, wrapper. Any unambiguous abbreviation of the above is also accepted"), GROUP_ID+1 },
{ "main", 'm', N_("NAME"), 0,
N_("Assume main function to be called NAME"), GROUP_ID+1 },
+ { "no-main", OPT_NO_MAIN, NULL, 0,
+ N_("There's no main function; print graphs for all functions in the program") },
{ "define", 'D', N_("NAME[=DEFN]"), 0,
N_("Predefine NAME as a macro"), GROUP_ID+1 },
{ "undefine", 'U', N_("NAME"), 0,
@@ -121,6 +123,9 @@ static struct argp_option options[] = {
#define GROUP_ID 20
{ NULL, 0, NULL, 0,
N_("Output control:"), GROUP_ID },
+ { "all", 'A', NULL, 0,
+ N_("Show all functions, not only those reachable from main"),
+ GROUP_ID+1 },
{ "number", 'n', NULL, 0,
N_("* Print line numbers"), GROUP_ID+1 },
{ "no-number", OPT_NO_NUMBER, NULL, OPTION_HIDDEN,
@@ -216,7 +221,7 @@ char *level_begin = "";
int preprocess_option = 0; /* Do they want to preprocess sources? */
char *start_name = "main"; /* Name of start symbol */
-
+int all_functions;
struct linked_list *arglist; /* List of command line arguments */
/* Given the option_type array and (possibly abbreviated) option argument
@@ -512,6 +517,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
int num;
switch (key) {
+ case 'A':
+ all_functions = 1;
+ break;
case 'a':
strict_ansi = 1;
break;
@@ -616,6 +624,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'm':
start_name = strdup(arg);
break;
+ case OPT_NO_MAIN:
+ start_name = NULL;
+ break;
case 'n':
print_line_numbers = 1;
break;
@@ -721,6 +732,7 @@ void
xalloc_die(void)
{
error(EX_FATAL, ENOMEM, _("Exiting"));
+ abort();
}
void
diff --git a/src/output.c b/src/output.c
index 764e926..7eaf7ac 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1,6 +1,5 @@
/* This file is part of GNU cflow
- Copyright (C) 1997, 2005, 2007, 2009-2011, 2014-2017 Sergey
- Poznyakoff
+ Copyright (C) 1997-2019 Sergey Poznyakoff
GNU cflow is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -393,11 +392,14 @@ tree_output()
separator();
}
} else {
- main_sym = lookup(start_name);
- if (main_sym) {
+ if ((main_sym = start_name ? lookup(start_name) : NULL) != NULL) {
direct_tree(0, 0, main_sym);
separator();
} else {
+ all_functions = 1;
+ }
+
+ if (all_functions) {
for (i = 0; i < num; i++) {
if (symbols[i]->callee == NULL)
continue;

Return to:

Send suggestions and report system problems to the System administrator.