public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Prateek Saxena <prateeksaxena@gmail.com>
To: gcc@gcc.gnu.org
Subject: Problem with instrumenting GIMPLE for adding a global variable
Date: Sat, 20 Aug 2005 23:20:00 -0000	[thread overview]
Message-ID: <4dd65b1505082016201bb2bba8@mail.gmail.com> (raw)

Hi,

I am trying to implement a prototype pass that instruments a function
to check for safe memory accesses. As a starting point I looked at
mudflap1 pass, in tree-mudflap.c and decided that I should write a
dummy pass ( very simple, but similar to mudflap) that instruments the
code to count the number of functions in the source file.

I am unable to add a global variable in the file scope. The global
VAR_DECL building function looks like this:

{
  tree decl = build_decl (VAR_DECL, get_identifier ("my_var"),
integer_type_node);
  TREE_PUBLIC (decl) = 0;
  DECL_EXTERNAL (decl) = 0;
  TREE_STATIC (decl) = 1; 
  gimplify_stmt (my_variable);
  lang_hooks.decls.pushdecl (decl);
  return decl;
}

It is called from within my call-back function "execute_my_pass" ( as
specified by me in the tree_opt_pass structure ).

I increment  "my_var" in every function. But, the instrumented object
file doesnot have a storage allocated for this variable in the .data
section. The problem is that DECL_CONTEXT of this VAR_DECL is always
getting assigned to a function, and not to global file scope. Why is
that?

Any help would be appreciated.

Thanks,
Prateek.

             reply	other threads:[~2005-08-20 23:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-20 23:20 Prateek Saxena [this message]
2005-08-20 23:53 Prateek Saxena

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4dd65b1505082016201bb2bba8@mail.gmail.com \
    --to=prateeksaxena@gmail.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).