GCC Middle and Back End API Reference
tree-browser.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "hash-table.h"
#include "tree.h"
#include "tree-pretty-print.h"
#include "tree-browser.def"
#include "all-tree.def"
Include dependency graph for tree-browser.c:

Data Structures

struct  tb_command
struct  tb_tree_code
struct  tree_upper_hasher

Macros

#define TB_OUT_FILE   stdout
#define TB_IN_FILE   stdin
#define TB_NIY   fprintf (TB_OUT_FILE, "Sorry this command is not yet implemented.\n")
#define TB_WF   fprintf (TB_OUT_FILE, "Warning, this command failed.\n")
#define DEFTBCODE(COMMAND, STRING, HELP)   COMMAND,
#define DEFTBCODE(code, str, help)   { help, str, sizeof (str) - 1, code },
#define TB_COMMAND_LEN(N)   (tb_commands[N].comm_len)
#define TB_COMMAND_TEXT(N)   (tb_commands[N].comm_text)
#define TB_COMMAND_CODE(N)   (tb_commands[N].comm_code)
#define TB_COMMAND_HELP(N)   (tb_commands[N].help_msg)
#define DEFTREECODE(SYM, STRING, TYPE, NARGS)   { SYM, STRING, sizeof (STRING) - 1 },
#define END_OF_BASE_TREE_CODES   { LAST_AND_UNUSED_TREE_CODE, "@dummy", sizeof ("@dummy") - 1 },
#define TB_TREE_CODE(N)   (tb_tree_codes[N].code)
#define TB_TREE_CODE_TEXT(N)   (tb_tree_codes[N].code_string)
#define TB_TREE_CODE_LEN(N)   (tb_tree_codes[N].code_string_len)
#define TB_SET_HEAD(N)
#define TB_MOVE_HEAD(FCT)
#define MAX_CANON   256

Typedefs

typedef enum TB_Comm_code TB_CODE

Enumerations

enum  TB_Comm_code { TB_UNUSED_COMMAND }

Functions

static long TB_getline (char **, long *, FILE *)
static TB_CODE TB_get_command (char *)
static enum tree_code TB_get_tree_code (char *)
static tree find_node_with_code (tree *, int *, void *)
static tree store_child_info (tree *, int *, void *)
static void TB_update_up (tree)
static tree TB_current_chain_node (tree)
static tree TB_prev_expr (tree)
static tree TB_next_expr (tree)
static tree TB_up_expr (tree)
static tree TB_first_in_bind (tree)
static tree TB_last_in_bind (tree)
static tree TB_history_prev (void)
void browse_tree (tree)
void browse_tree ()
static tree TB_first_in_bind ()
static tree TB_last_in_bind ()
static tree TB_up_expr ()
static tree TB_prev_expr ()
static tree TB_next_expr ()
static tree TB_current_chain_node ()
static void TB_update_up ()
static TB_CODE TB_get_command ()
static enum tree_code TB_get_tree_code ()
static long TB_getline ()

Variables

static struct tb_command tb_commands []
static struct tb_tree_code tb_tree_codes []
static hash_table
< tree_upper_hasher
TB_up_ht
static vec< tree, va_gc > * TB_history_stack
static int TB_verbose = 1

Macro Definition Documentation

#define DEFTBCODE (   COMMAND,
  STRING,
  HELP 
)    COMMAND,

Structures for handling Tree Browser's commands.

#define DEFTBCODE (   code,
  str,
  help 
)    { help, str, sizeof (str) - 1, code },

Structures for handling Tree Browser's commands.

#define DEFTREECODE (   SYM,
  STRING,
  TYPE,
  NARGS 
)    { SYM, STRING, sizeof (STRING) - 1 },
#define END_OF_BASE_TREE_CODES   { LAST_AND_UNUSED_TREE_CODE, "@dummy", sizeof ("@dummy") - 1 },
#define MAX_CANON   256

Referenced by TB_history_prev().

#define TB_COMMAND_CODE (   N)    (tb_commands[N].comm_code)
#define TB_COMMAND_HELP (   N)    (tb_commands[N].help_msg)
#define TB_COMMAND_LEN (   N)    (tb_commands[N].comm_len)
#define TB_COMMAND_TEXT (   N)    (tb_commands[N].comm_text)
#define TB_IN_FILE   stdin
#define TB_MOVE_HEAD (   FCT)
Value:
do { \
if (head) \
{ \
tree t; \
t = FCT (head); \
if (t) \
TB_SET_HEAD (t); \
} \
} while (0)
#define TB_NIY   fprintf (TB_OUT_FILE, "Sorry this command is not yet implemented.\n")
#define TB_OUT_FILE   stdout

Tree browser. Copyright (C) 2002-2013 Free Software Foundation, Inc. Contributed by Sebastian Pop s.pop.nosp@m.@lap.nosp@m.oste..nosp@m.net

This file is part of GCC.

GCC 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 3, or (at your option) any later version.

GCC 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 GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.

Referenced by store_child_info(), and TB_get_command().

#define TB_SET_HEAD (   N)
Value:
do { \
vec_safe_push (TB_history_stack, N); \
head = N; \
if (TB_verbose) \
if (head) \
{ \
print_generic_expr (TB_OUT_FILE, head, 0); \
fprintf (TB_OUT_FILE, "\n"); \
} \
} while (0)

Referenced by browse_tree().

#define TB_TREE_CODE (   N)    (tb_tree_codes[N].code)

Referenced by TB_get_command().

#define TB_TREE_CODE_LEN (   N)    (tb_tree_codes[N].code_string_len)

Referenced by TB_get_command().

#define TB_TREE_CODE_TEXT (   N)    (tb_tree_codes[N].code_string)

Referenced by TB_get_command().

#define TB_WF   fprintf (TB_OUT_FILE, "Warning, this command failed.\n")

Typedef Documentation

typedef enum TB_Comm_code TB_CODE

Enumeration Type Documentation

Enumerator:
TB_UNUSED_COMMAND 

Definitions and documentation for the codes used by the Tree Browser. Copyright (C) 2002-2013 Free Software Foundation, Inc. Contributed by Sebastian Pop s.pop.nosp@m.@lap.nosp@m.oste..nosp@m.net

This file is part of GCC.

GCC 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 3, or (at your option) any later version.

GCC 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 GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. First field in the following declarations is the code of the command used by the tree browser. Second field is what is parsed in order to recognize a command. Third field is used for printing the help message. Misc. commands. Walking commands. Fields accessors. Searching commands. Printing commands.


Function Documentation

void browse_tree ( tree  )

FIXME: To be declared in a .h file.

void browse_tree ( )

Entry point in the Tree Browser.

 Store in a hashtable information about previous and upper statements.   
       EOF.   
       Get a new command.  Otherwise the user just pressed enter, and thus
       she expects the last command to be reexecuted.   
             This command takes another argument: the element number:
             for example "elt 1".   
             This command takes another argument: the element number:
             for example "elt 1".   
           Search in the subtree a node with the given code.   
         This command is a little bit special, since it deals with history
         stack.  For this reason it should keep the "head = ..." statement
         and not use TB_MOVE_HEAD.   
         Don't go further if it's the last node in this chain.   
         Go up to the current function declaration.   
         Display a help message.   
         Just exit from this function.   

References TB_SET_HEAD.

static tree find_node_with_code ( tree tp,
int *  walk_subtrees,
void *  data 
)
static

Find a node with a given code. This function is used as an argument to walk_tree.

References errno.

static tree store_child_info ( tree tp,
int *  walk_subtrees,
void *  data 
)
static

For each node store in its children nodes that the current node is their parent. This function is used by walk_tree.

'node' is the parent of 'TREE_OPERAND (node, *)'.

 Never stop walk_tree.   

References DECL_SAVED_TREE, NULL, TB_OUT_FILE, TREE_CHAIN, TREE_CODE, and walk_tree.

static tree TB_current_chain_node ( tree  )
static
static tree TB_current_chain_node ( )
static
static tree TB_first_in_bind ( tree  )
static
static tree TB_first_in_bind ( )
static

Search the first node in this BIND_EXPR.

static TB_CODE TB_get_command ( char *  )
static
static TB_CODE TB_get_command ( )
static

Parse the input string for determining the command the user asked for.

  Here we just determined the command.  If this command takes
  an argument, then the argument is determined later.   

Not a valid command.

References comp, NULL, TB_OUT_FILE, TB_TREE_CODE, TB_TREE_CODE_LEN, and TB_TREE_CODE_TEXT.

static enum tree_code TB_get_tree_code ( char *  )
static
static enum tree_code TB_get_tree_code ( )
static

Parse the input string for determining the tree code.

This isn't a valid code.

References NULL_TREE, and TREE_CODE.

static long TB_getline ( char **  ,
long *  ,
FILE *   
)
static

Function declarations.

static long TB_getline ( )
static

Read up to (and including) a '
' from STREAM into *LINEPTR (and null-terminate it). *LINEPTR is a pointer returned from malloc (or NULL), pointing to *N characters of space. It is realloc'd as necessary. Returns the number of characters read (not including the null terminator), or -1 on error or EOF. This function comes from sed (and is supposed to be a portable version of getline).

 Make sure we have a line buffer to start with.   
     Need to enlarge the line buffer.   
 Return a partial line since we got an error in the middle.   
static tree TB_history_prev ( )
static

Returns a pointer to the last visited node.

References MAX_CANON.

static tree TB_last_in_bind ( tree  )
static
static tree TB_last_in_bind ( )
static

Search the last node in this BIND_EXPR.

static tree TB_next_expr ( tree  )
static
static tree TB_next_expr ( )
static

Search the next expression in this BIND_EXPR.

static tree TB_prev_expr ( tree  )
static
static tree TB_prev_expr ( )
static

Search the previous expression in this BIND_EXPR.

static tree TB_up_expr ( tree  )
static
static tree TB_up_expr ( )
static

Search the parent expression for this node.

static void TB_update_up ( tree  )
static
static void TB_update_up ( )
static

Update information about upper expressions in the hash table.

Walk function's body.

     Walk rest of the chain.   

Variable Documentation

struct tb_command tb_commands[]
static
vec<tree, va_gc>* TB_history_stack
static
struct tb_tree_code tb_tree_codes[]
static
Initial value:
{
}
hash_table<tree_upper_hasher> TB_up_ht
static

Static variables.

int TB_verbose = 1
static