[DynInst_API:] Reg. symtabAPI - findLocalVariable method


Date: Wed, 02 Jul 2008 20:43:14 -0500
From: Praveen Venkatachari <vpraveen84@xxxxxxxxx>
Subject: [DynInst_API:] Reg. symtabAPI - findLocalVariable method
Hi,

I'm facing some trouble getting the "findLocalVariable" method of the symtabAPI to work. I would appreciate any help in this regard.

I'm using the Linux(x86) binaries for symtabAPI 2.1.

The following is the code for the object file: a.out

 #include<stdio.h>

 int main(){

 int v1;
 int v2;

 char name;

 return (0);

 }


The following is the code for the symtab file: sym.c

 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
 #include <iomanip>

 #include "../include/Symtab.h"
 #include "../include/Archive.h"

 using namespace Dyninst;
 using namespace Dyninst::SymtabAPI;

 int main(){

 cout<<boolalpha;
 bool yes;

 //Name the object file to be parsed:
 std::string file = "a.out";

 //Declare a pointer to an object of type Symtab; this represents the
 file.
 Symtab *obj;

 // Parse the object file
 bool err = Symtab::openFile(obj, file);
 cout<<"Parsed file successfully:"<<err<<endl;

 // Get the Symbol object representing function
 vector<Symbol *> syms;
 yes = obj->findSymbolByType(syms, "main", Symbol::ST_FUNCTION);
 cout<<"Found function:"<<yes<<"\n";

 // Find the local var
  std::vector<localVar *> vars_local;    yes = obj->findLocalVariable(vars
_local,"name");
  cout<<"Found local variable:"<<yes<<"\n";

  // cout<<vars_local[0]->getName()<<endl;

  return (0);
 }


The output I get:

 Parsed file successfully:true
 Found function:true
 Found local variable:false

I'm using Ubuntu 8.04LTS with 2.6.24-19-generic kernel.

Thank You,
Praveen Venkatachari
[← Prev in Thread] Current Thread [Next in Thread→]
  • [DynInst_API:] Reg. symtabAPI - findLocalVariable method, Praveen Venkatachari <=