Пример #1
0
// Do a three step traversal: by file, then fn, then line.
// Returns a pointer to the line CC, creates a new one if necessary.
static LineCC* get_lineCC(Addr origAddr)
{
   Char    file[FILE_LEN], fn[FN_LEN];
   Int     line;
   CodeLoc loc;
   LineCC* lineCC;

   get_debug_info(origAddr, file, fn, &line);

   VGP_PUSHCC(VgpGetLineCC);

   loc.file = file;
   loc.fn   = fn;
   loc.line = line;

   lineCC = VG_(OSet_Lookup)(CC_table, &loc);
   if (!lineCC) {
      // Allocate and zero a new node.
      lineCC           = VG_(OSet_AllocNode)(CC_table, sizeof(LineCC));
      lineCC->loc.file = get_perm_string(loc.file);
      lineCC->loc.fn   = get_perm_string(loc.fn);
      lineCC->loc.line = loc.line;
      VG_(OSet_Insert)(CC_table, lineCC);
   }

   VGP_POPCC(VgpGetLineCC);
   return lineCC;
}
Пример #2
0
static int
list_one_view(char *area_name, char *view_name, command_t * cmd)
{
	debug_info_t *db_info;
	debug_view_t *db_view;

	if ((db_info = find_debug_area(area_name)) == NULL) {
		fprintf(cmd->efp, "Debug log '%s' not found!\n", area_name);
		return -1;
	}

	db_info = get_debug_info(db_info->addr,1);

	if ((db_view = find_lcrash_debug_view(view_name)) == NULL) {
		fprintf(cmd->efp, "View '%s' not registered!\n", view_name);
		return -1;
	}
	if(dbf_version == DBF_VERSION_V1){
		debug_format_output_v1(db_info, db_view, cmd->ofp);
		free_debug_info_v1(db_info);
	} else {
		debug_format_output_v2(db_info, db_view, cmd->ofp);
		free_debug_info_v2(db_info);
	}
	return 0;
}
Пример #3
0
/* mon_backtrace prints the current stack backtrace. */
int mon_backtrace(int argc, char **argv)
{
	int *fp = NULL;
	int pc = 0;

	(void) argc;
	(void) argv;
	
	fp = read_fp();
	pc = fp[0];

	while (fp != NULL) {
		int lr = fp[-1];
		struct DebugInfo info = get_debug_info(pc);

		if ((int) fp == lr)
			break;

		kprintf("  fp: %x, lr: %x\n", fp, lr);
		kprintf("    %s:%s:%d\n", info.file, info.function,
			info.source_line_number);

		if (info.arg_count != 0)
			print_arguments(&info, fp);

		pc = lr;
		fp = (int *) fp[-3];
	}

	return 0;
}
Пример #4
0
void print_stacktrace(stacktrace_t const& st, std::ostream& out)
{    

    const int MAX_DEBUG_INFO_FAILS = 10;
    int current_debug_info_fails = 0;
    for( stacktrace_t::const_iterator i = st.begin(); i != st.end(); ++i ) {
        void* address = *i;
        debug_info di;
        bool have_debug_info = false;
	    if( current_debug_info_fails < MAX_DEBUG_INFO_FAILS ) { 
		    have_debug_info =  get_debug_info(address, di);
		    if( !have_debug_info )
	    		    current_debug_info_fails++;
	    }
        out << "\tat ";
        if( have_debug_info ) {
            // func(file:line)
            out << di.function;
            if( di.source_file.size() > 0 ) {
                out << "(" << di.source_file;
                if( di.source_line != 0 )
                    out << ":" << std::dec << di.source_line;
                out << ")";
            }
        } 
        //  0xabcdef123
        out << "[" << std::setfill('0') << std::setw(sizeof(address)) << std::hex << address << "]";
        out << std::endl;
    }
}
Пример #5
0
static int
save_one_view(const char *dbf_dir_name, const char *area_name,
	      const char *view_name, command_t *cmd)
{
	char path_view[PATH_MAX];
	debug_info_t *db_info;
	debug_view_t *db_view;
	FILE *view_fh;

	db_info = find_debug_area(area_name);
	if (db_info == NULL) {
		fprintf(cmd->efp, "Debug log '%s' not found!\n", area_name);
		return -1;
	}
	db_info = get_debug_info(db_info->addr, 1);

	db_view = find_lcrash_debug_view(view_name);
	if (db_view == NULL) {
		fprintf(cmd->efp, "View '%s' not registered!\n", view_name);
		return -1;
	}
	sprintf(path_view, "%s/%s/%s", dbf_dir_name, area_name, view_name);
	view_fh = fopen(path_view, "w");
	if (view_fh == NULL) {
		fprintf(cmd->efp, "Could not create file: %s (%s)\n",
			path_view, strerror(errno));
		return -1;
	}
	debug_write_output(db_info, db_view, view_fh);
	fclose(view_fh);
	return 0;
}
Пример #6
0
void print_debug_info_file(FILE *flux)
{
  char *str = get_debug_info(NULL);

  if (str != NULL)
    {
      fprintf(flux, "%s", str);
      free(str);
    }
}
Пример #7
0
void print_debug_info_fd(int fd)
{
  char *str = get_debug_info(NULL);
  int __attribute__((unused)) rc;

  if (str != NULL)
    {
      rc = write(fd, str, strlen(str));
      free(str);
    }
}
Пример #8
0
// Do a three step traversal: by file, then fn, then line.
// In all cases prepends new nodes to their chain.  Returns a pointer to the
// line node, creates a new one if necessary.
static lineCC* get_lineCC(Addr origAddr)
{
   fileCC *curr_fileCC;
   fnCC   *curr_fnCC;
   lineCC *curr_lineCC;
   Char    file[FILE_LEN], fn[FN_LEN];
   Int     line;
   UInt    file_hash, fn_hash, line_hash;

   get_debug_info(origAddr, file, fn, &line);

   VGP_PUSHCC(VgpGetLineCC);

   // level 1
   file_hash = hash(file, N_FILE_ENTRIES);
   curr_fileCC   = CC_table[file_hash];
   while (NULL != curr_fileCC && !VG_STREQ(file, curr_fileCC->file)) {
      curr_fileCC = curr_fileCC->next;
   }
   if (NULL == curr_fileCC) {
      CC_table[file_hash] = curr_fileCC = 
         new_fileCC(file, CC_table[file_hash]);
      distinct_files++;
   }

   // level 2
   fn_hash = hash(fn, N_FN_ENTRIES);
   curr_fnCC   = curr_fileCC->fns[fn_hash];
   while (NULL != curr_fnCC && !VG_STREQ(fn, curr_fnCC->fn)) {
      curr_fnCC = curr_fnCC->next;
   }
   if (NULL == curr_fnCC) {
      curr_fileCC->fns[fn_hash] = curr_fnCC = 
         new_fnCC(fn, curr_fileCC->fns[fn_hash]);
      distinct_fns++;
   }

   // level 3
   line_hash   = line % N_LINE_ENTRIES;
   curr_lineCC = curr_fnCC->lines[line_hash];
   while (NULL != curr_lineCC && line != curr_lineCC->line) {
      curr_lineCC = curr_lineCC->next;
   }
   if (NULL == curr_lineCC) {
      curr_fnCC->lines[line_hash] = curr_lineCC = 
         new_lineCC(line, curr_fnCC->lines[line_hash]);
      distinct_lines++;
   }

   VGP_POPCC(VgpGetLineCC);
   return curr_lineCC;
}
Пример #9
0
void call3(void)
{
	struct debug_info info;
	struct stab *last = NULL;
	printk("Inside call3\r\n");
	get_debug_info(call3, &info, &last);
	printk("%016x %s:%d %s (%08x)\r\n",
	    call3,
	    info.source_file,
	    info.line_num,
	    info.func_name,
	    info.func_addr_lo
	);
}
Пример #10
0
//-----------------------------------------------------------------
static OA_InstrumentContext contextFor(Addr64 cia, IROp op) {
  Char thisFct[]="contextFor";
  OA_InstrumentContext ic=VG_(malloc)(thisFct, sizeof(OA_InstrumentContext_));
  Int     line;
  Char    filename[COJAC_FILE_LEN];
  Char    fctname[COJAC_FCT_LEN];
  Int     totalLen=COJAC_FILE_LEN+COJAC_FCT_LEN+10;
  get_debug_info((Addr)cia, filename, fctname, &line, &(ic->isLocated));
  ic->string = VG_(malloc)(thisFct, totalLen);
  ic->addr = (Addr)cia;
  ic->op=op;
  //VG_(sprintf)(ic->string, "%s %s(), %s:%d", strFromIROp(op), fctname, filename, line);
  VG_(sprintf)(ic->string, "%s", strFromIROp(op));
  return ic;
}
Пример #11
0
static int
list_one_view(char *area_name, char *view_name, command_t * cmd)
{
	debug_info_t *db_info;
	debug_view_t *db_view;

	if ((db_info = find_debug_area(area_name)) == NULL) {
		fprintf(cmd->efp, "Debug log '%s' not found!\n", area_name);
		return -1;
	}

	db_info = get_debug_info(db_info->addr,1);

	if ((db_view = find_lcrash_debug_view(view_name)) == NULL) {
		fprintf(cmd->efp, "View '%s' not registered!\n", view_name);
		return -1;
	}
	debug_write_output(db_info, db_view, cmd->ofp);
	return 0;
}
Пример #12
0
void print_debug_info_syslog(int level)
{
  int size;
  char *debug_str = get_debug_info(&size);
  char *end_c=debug_str, *first_c=debug_str;

  if (debug_str != NULL) {
    while(*end_c != '\0' && (end_c - debug_str) <= size)
      {
        if (*end_c == '\n' || *end_c == '\0')
          {
            *end_c = '\0';
            if ((end_c - debug_str) != 0)
              syslog(tabLogLevel[level].syslog_level, "%s", first_c);
            first_c = end_c+1;
          }
        end_c++;
      }
    free(debug_str);
  }
}
Пример #13
0
static int
get_debug_areas(void)
{
	kaddr_t act_debug_area;
	syment_t *debug_sym;
	debug_info_t *act_debug_area_cpy;

	if(!(debug_sym = kl_lkup_symname("debug_area_first"))){
		printf("Did not find debug_areas");
		return -1;
	}
	act_debug_area = KL_VREAD_PTR(debug_sym->s_addr);
	while(act_debug_area != 0){
		act_debug_area_cpy = get_debug_info(act_debug_area,0);
		act_debug_area     = act_debug_area_cpy->next_dbi;
	 	if(debug_area_first == NULL){
			debug_area_first = act_debug_area_cpy;
		} else {
			debug_area_last->next = act_debug_area_cpy;
		}
		debug_area_last = act_debug_area_cpy;
	}
	return 0;
}
Пример #14
0
std::string
madara::knowledge::containers::NativeDoubleVector::get_debug_info_ (
  void)
{
  return get_debug_info ();
}
Пример #15
0
std::string madara::knowledge::containers::FlexMap::get_debug_info_(void)
{
  return get_debug_info();
}
Пример #16
0
std::string
madara::knowledge::containers::IntegerVector::get_debug_info_ (void)
{
  return get_debug_info ();
}