Skip to content

Commit

Permalink
Adds a print operator to our code ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
legendre committed Oct 21, 2005
1 parent 6de1f05 commit fa76232
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 3 deletions.
80 changes: 79 additions & 1 deletion dyninstAPI/src/codeRange.C
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* incur to third parties resulting from your use of Paradyn.
*/

// $Id: codeRange.C,v 1.12 2005/09/15 19:20:38 tlmiller Exp $
// $Id: codeRange.C,v 1.13 2005/10/21 21:48:14 legendre Exp $

#include <stdio.h>
#include "codeRange.h"
Expand Down Expand Up @@ -505,3 +505,81 @@ void codeRangeTree::clear() {
setData = nil;
setSize = 0;
}

#define PRINT_COMMA if (print_comma) fprintf(stderr, ", "); print_comma = true
void codeRange::print_range(Address addr) {
bool print_comma = false;
image *img_ptr = is_image();
mapped_object *mapped_ptr = is_mapped_object();
int_function *func_ptr = is_function();
functionReplacement *reloc_ptr = is_function_replacement();
multiTramp *multi_ptr = is_multitramp();
baseTrampInstance *base_ptr = NULL;
miniTrampInstance *mini_ptr = is_minitramp();
inferiorRPCinProgress *rpc_ptr = is_inferior_rpc();

/**
* The is_* functions above won't give us mulitple layers of objects
* (i.e the fact we have a function pointer, doesn't mean we have a
* mapped_object pointer). Build up more information from what we have
**/
if (mini_ptr && !base_ptr)
base_ptr = mini_ptr->baseTI;
if (base_ptr && !multi_ptr)
multi_ptr = base_ptr->multiT;
if (multi_ptr && !func_ptr)
func_ptr = multi_ptr->func();
if (multi_ptr && !base_ptr && addr)
base_ptr = multi_ptr->getBaseTrampInstanceByAddr(addr);
if (reloc_ptr && !func_ptr)
func_ptr = reloc_ptr->source()->func();
if (func_ptr && !mapped_ptr)
mapped_ptr = func_ptr->obj();
if (mapped_ptr && !img_ptr)
img_ptr = mapped_ptr->parse_img();

fprintf(stderr, "[");

if (img_ptr) {
PRINT_COMMA;
fprintf(stderr, "img:%s", img_ptr->name().c_str());
}
if (mapped_ptr) {
PRINT_COMMA;
fprintf(stderr, "map_obj:%s", mapped_ptr->fullName().c_str());
}
if (func_ptr) {
PRINT_COMMA;
fprintf(stderr, "func:%s", func_ptr->prettyName().c_str());
}
if (reloc_ptr) {
PRINT_COMMA;
fprintf(stderr, "reloc:%lx",
reloc_ptr->targetVersion());
}
if (multi_ptr) {
PRINT_COMMA;
fprintf(stderr, "multi:%lx->%lx+%u", multi_ptr->instAddr(),
multi_ptr->get_address_cr(), multi_ptr->get_size_cr());
}
if (base_ptr) {
PRINT_COMMA;
fprintf(stderr, "base:%lx+%lx", multi_ptr->get_address_cr(),
multi_ptr->get_size_cr());
}
if (mini_ptr) {
PRINT_COMMA;
fprintf(stderr, "mini:%lx+%lx", multi_ptr->get_address_cr(),
multi_ptr->get_size_cr());
}
if (rpc_ptr) {
PRINT_COMMA;
fprintf(stderr, "rpc:%lx", rpc_ptr->get_address_cr());
}
if (!print_comma)
{
fprintf(stderr, "Nothing");
}
fprintf(stderr, "]\n");
}

8 changes: 7 additions & 1 deletion dyninstAPI/src/codeRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* incur to third parties resulting from your use of Paradyn.
*/

// $Id: codeRange.h,v 1.12 2005/09/15 19:20:39 tlmiller Exp $
// $Id: codeRange.h,v 1.13 2005/10/21 21:48:15 legendre Exp $


#ifndef _codeRangeTree_h_
Expand All @@ -53,6 +53,7 @@
#include <stdlib.h>
#include "common/h/Types.h"
#include "common/h/Vector.h"
#include "common/h/std_namesp.h"

/** template class for codeRangeTree. The implementation is based on red black
* tree implementation for efficiency concerns and for getting sorted
Expand Down Expand Up @@ -118,6 +119,11 @@ class codeRange {
functionReplacement *is_function_replacement();
signal_handler_location *is_signal_handler_location();
inferiorRPCinProgress *is_inferior_rpc();

//Prints codeRange info to stderr.
void print_range(Address addr = 0);

friend ostream &operator<<(ostream &s, const codeRange &c);
};

class codeRangeTree {
Expand Down
16 changes: 16 additions & 0 deletions dyninstAPI/src/function.C
Original file line number Diff line number Diff line change
Expand Up @@ -851,3 +851,19 @@ bblInstance::reloc_info_t::~reloc_info_t() {
};

#endif

int_basicBlock *functionReplacement::source() {
return sourceBlock_;
}

int_basicBlock *functionReplacement::target() {
return targetBlock_;
}

unsigned functionReplacement::sourceVersion() {
return sourceVersion_;
}

unsigned functionReplacement::targetVersion() {
return targetVersion_;
}
7 changes: 6 additions & 1 deletion dyninstAPI/src/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* incur to third parties resulting from your use of Paradyn.
*/

// $Id: function.h,v 1.18 2005/10/17 19:24:19 bernat Exp $
// $Id: function.h,v 1.19 2005/10/21 21:48:17 legendre Exp $

#ifndef FUNCTION_H
#define FUNCTION_H
Expand Down Expand Up @@ -523,6 +523,11 @@ class functionReplacement : public codeRange {

bool overwritesMultipleBlocks();

int_basicBlock *source();
int_basicBlock *target();
unsigned sourceVersion();
unsigned targetVersion();

Address get_address_cr() const;
unsigned get_size_cr() const;

Expand Down

0 comments on commit fa76232

Please sign in to comment.