Exemple #1
0
struct parse_result *  get_one_image (char *data)
{
	char c;
	struct parse_result *one_image;
	
	data = is_string(data,"src");
	
	if (data == NULL)
		return NULL;
	
	data = is_string (data,"="); 

	one_image = malloc (sizeof(struct parse_result));
	if (one_image ==NULL)
	{
		printf ("malloc %d bytes error!\n",sizeof(struct parse_result));
		return NULL;
	}	

	if (data != NULL)
	      one_image->data = get_image_name(data);

	one_image->ret = 1;
	

	return one_image;
}
Exemple #2
0
void xml_formatter::
output_symbol(ostream & out,
	symbol_entry const * symb, size_t lo, size_t hi, bool is_module)
{
	ostringstream str;
	// pointless reference to is_module, remove insane compiler warning
	size_t indx = is_module ? 0 : 1;

	// output symbol's summary data for each profile class
	bool got_samples = false;

	for (size_t p = lo; p <= hi; ++p) {
		got_samples |= xml_support->output_summary_data(str,
		    symb->sample.counts, p);
	}

	if (!got_samples)
		return;

	if (cverb << vxml)
		out << "<!-- symbol_ref=" << symbol_names.name(symb->name) <<
			" -->" << endl;

	out << open_element(SYMBOL, true);

	string const name = symbol_names.name(symb->name);
	assert(name.size() > 0);
	
	string const image = get_image_name(symb->image_name,
		image_name_storage::int_filename, extra_found_images);
	string const qname = image + ":" + name;

	indx = xml_get_symbol_index(qname);

	out << init_attr(ID_REF, indx);

	if (need_details) {
		ostringstream details;
		symbol_details_t & sd = symbol_details[indx];
		size_t const detail_lo = sd.index;

		string detail_str = output_symbol_details(symb, sd.index, lo, hi);

		if (detail_str.size() > 0) {
			if (sd.id < 0)
				sd.id = indx;
			details << detail_str;
		}

		if (sd.index > detail_lo) {
			sd.details = sd.details + details.str();
			out << init_attr(DETAIL_LO, detail_lo);
			out << init_attr(DETAIL_HI, sd.index-1);
		}
	}
	out << close_element(NONE, true);
	// output summary
	out << str.str();
	out << close_element(SYMBOL);
}
Exemple #3
0
string formatter::format_app_name(field_datum const & f)
{
	return get_image_name(f.symbol.app_name,
		long_filenames 
			? image_name_storage::int_real_filename
			: image_name_storage::int_real_basename,
		extra_found_images);
}
Exemple #4
0
void xml_cg_formatter::
output_symbol_core(ostream & out, cg_symbol::children const cg_symb,
       string const selfname, string const qname,
       size_t lo, size_t hi, bool is_module, tag_t tag)
{
	cg_symbol::children::const_iterator cit;
	cg_symbol::children::const_iterator cend = cg_symb.end();

	for (cit = cg_symb.begin(); cit != cend; ++cit) {
		string const & module = get_image_name((cit)->image_name,
			image_name_storage::int_filename, extra_found_images);
		bool self = false;
		ostringstream str;
		size_t indx;

		// output symbol's summary data for each profile class
		for (size_t p = lo; p <= hi; ++p)
			xml_support->output_summary_data(str, cit->sample.counts, p);

		if (cverb << vxml)
			out << "<!-- symbol_ref=" << symbol_names.name(cit->name) <<
				" -->" << endl;

		if (is_module) {
			out << open_element(MODULE, true);
			out << init_attr(NAME, module) << close_element(NONE, true);
		}

		out << open_element(SYMBOL, true);

		string const symname = symbol_names.name(cit->name);
		assert(symname.size() > 0);

		string const symqname = module + ":" + symname;

		// Find any self references and handle
		if ((symname == selfname) && (tag == CALLEES)) {
			self = true;
			indx = xml_get_symbol_index(qname);
		} else {
			indx = xml_get_symbol_index(symqname);
		}

		out << init_attr(ID_REF, indx);

		if (self)
			out << init_attr(SELFREF, "true");

		out << close_element(NONE, true);
		out << str.str();
		out << close_element(SYMBOL);

		if (is_module)
			out << close_element(MODULE);
	}
}
Exemple #5
0
static void
handle_load_dll (void)
{
  LOAD_DLL_DEBUG_INFO *event = &current_event.u.LoadDll;
  char *dll_name;

  dll_name = get_image_name (current_process_handle,
			     event->lpImageName, event->fUnicode);
  if (!dll_name)
    return;

  win32_add_one_solib (dll_name, (CORE_ADDR) (uintptr_t) event->lpBaseOfDll);
}
Exemple #6
0
void
do_file_save_as_dialog (void)
{
  static GtkWidget *dialog;

  if (! dialog)
    {
      gchar *filename;

      dialog =
        gtk_file_chooser_dialog_new (_("Save Image Map"),
                                     NULL,
                                     GTK_FILE_CHOOSER_ACTION_SAVE,

                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     GTK_STOCK_SAVE,   GTK_RESPONSE_OK,

                                     NULL);

      gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                               GTK_RESPONSE_OK,
                                               GTK_RESPONSE_CANCEL,
                                               -1);
      gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);

      gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
                                                      TRUE);

      g_signal_connect (dialog, "destroy",
                        G_CALLBACK (gtk_widget_destroyed),
                        &dialog);
      g_signal_connect (dialog, "response",
                        G_CALLBACK (save_cb),
                        dialog);

      /*  Suggest a filename based on the image name.
       *  The image name is in UTF-8 encoding.
       */
      filename = g_strconcat (get_image_name(), ".map", NULL);

      if (filename)
        {
          gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
                                             filename);
          g_free (filename);
        }
    }

  gtk_window_present (GTK_WINDOW (dialog));
}
Exemple #7
0
void xml_cg_formatter::
output_symbol(ostream & out,
	symbol_entry const * symb, size_t lo, size_t hi, bool is_module)
{
	cg_symbol const * cg_symb = dynamic_cast<cg_symbol const *>(symb);
	ostringstream str;
	size_t indx;

	// output symbol's summary data for each profile class
	for (size_t p = lo; p <= hi; ++p)
		xml_support->output_summary_data(str, symb->sample.counts, p);

	if (cverb << vxml)
		out << "<!-- symbol_ref=" << symbol_names.name(symb->name) <<
			" -->" << endl;

	out << open_element(SYMBOL, true);

	string const name = symbol_names.name(symb->name);
	assert(name.size() > 0);

	string const image = get_image_name(symb->image_name,
		image_name_storage::int_filename, extra_found_images);
	string const qname = image + ":" + name;

	string const selfname = symbol_names.demangle(symb->name) + " [self]";

	indx = xml_get_symbol_index(qname);

	out << init_attr(ID_REF, indx);

	out << close_element(NONE, true);

	out << open_element(CALLERS);
	if (cg_symb)
		output_symbol_core(out, cg_symb->callers, selfname, qname, lo, hi, is_module, CALLERS);
	out << close_element(CALLERS);

	out << open_element(CALLEES);
	if (cg_symb)
		output_symbol_core(out, cg_symb->callees, selfname, qname, lo, hi, is_module, CALLEES);

	out << close_element(CALLEES);

	// output summary
	out << str.str();
	out << close_element(SYMBOL);
}
Exemple #8
0
void xml_formatter::output_cg_children(ostream & out, 
	cg_symbol::children const cg_symb, op_bfd * & abfd)
{
	cg_symbol::children::const_iterator cit;
	cg_symbol::children::const_iterator cend = cg_symb.end();

	for (cit = cg_symb.begin(); cit != cend; ++cit) {
		string const name = symbol_names.name(cit->name);
		string const image = get_image_name(cit->image_name,
			image_name_storage::int_filename, extra_found_images);
		string const qname = image + ":" + name;
		map<string, size_t>::iterator sd_it = symbol_data_table.find(qname);

		if (sd_it != symbol_data_table.end()) {
			symbol_entry const * child = &(*cit);
			output_the_symbol_data(out, child, abfd);
		}
	}
}
Exemple #9
0
void xml_formatter::
output_the_symbol_data(ostream & out, symbol_entry const * symb, op_bfd * & abfd)
{
	string const name = symbol_names.name(symb->name);
	assert(name.size() > 0);

	string const image = get_image_name(symb->image_name,
		image_name_storage::int_filename, extra_found_images);
	string const qname = image + ":" + name;
	map<string, size_t>::iterator sd_it = symbol_data_table.find(qname);

	if (sd_it != symbol_data_table.end()) {
		// first time we've seen this symbol
		out << open_element(SYMBOL_DATA, true);
		out << init_attr(TABLE_ID, sd_it->second);

		field_datum datum(*symb, symb->sample, 0, counts,
				  extra_found_images);

		output_attribute(out, datum, ff_symb_name, NAME);

		if (flags & ff_linenr_info) {
			output_attribute(out, datum, ff_linenr_info, SOURCE_FILE);
			output_attribute(out, datum, ff_linenr_info, SOURCE_LINE);
		}

		if (name.size() > 0 && name[0] != '?') {
			output_attribute(out, datum, ff_vma, STARTING_ADDR);

			if (need_details) {
				get_bfd_object(symb, abfd);
				if (abfd && abfd->symbol_has_contents(symb->sym_index))
					xml_support->output_symbol_bytes(bytes_out, symb, sd_it->second, *abfd);
			}
		}
		out << close_element();

		// seen so remove (otherwise get several "no symbols")
		symbol_data_table.erase(qname);
	}
}
static void
handle_load_dll (void)
{
  LOAD_DLL_DEBUG_INFO *event = &current_event.u.LoadDll;
  char dll_buf[MAX_PATH + 1];
  char *dll_name = NULL;
  CORE_ADDR load_addr;

  dll_buf[0] = dll_buf[sizeof (dll_buf) - 1] = '\0';

  /* Windows does not report the image name of the dlls in the debug
     event on attaches.  We resort to iterating over the list of
     loaded dlls looking for a match by image base.  */
  if (!psapi_get_dll_name (event->lpBaseOfDll, dll_buf))
    {
      if (!server_waiting)
	/* On some versions of Windows and Windows CE, we can't create
	   toolhelp snapshots while the inferior is stopped in a
	   LOAD_DLL_DEBUG_EVENT due to a dll load, but we can while
	   Windows is reporting the already loaded dlls.  */
	toolhelp_get_dll_name (event->lpBaseOfDll, dll_buf);
    }

  dll_name = dll_buf;

  if (*dll_name == '\0')
    dll_name = get_image_name (current_process_handle,
			       event->lpImageName, event->fUnicode);
  if (!dll_name)
    return;

  /* The symbols in a dll are offset by 0x1000, which is the
     the offset from 0 of the first byte in an image - because
     of the file header and the section alignment. */

  load_addr = (CORE_ADDR) (uintptr_t) event->lpBaseOfDll + 0x1000;
  win32_add_one_solib (dll_name, load_addr);
}
Exemple #11
0
bool
xml_formatter::get_bfd_object(symbol_entry const * symb, op_bfd * & abfd) const
{
	bool ok = true;

	string const & image_name = get_image_name(symb->image_name,
	                                           image_name_storage::int_filename, extra_found_images);
	if (abfd && abfd->get_filename() == image_name)
		return true;
	delete abfd;
	abfd = new op_bfd(image_name, symbol_filter,
	                  extra_found_images, ok);

	if (!ok) {
		report_image_error(image_name, image_format_failure,
				   false, extra_found_images);
		delete abfd;
		abfd = 0;
		return false;
	}

	return true;
}
Exemple #12
0
main()
{
   char  channels[80],
         color_transform[80],
         file_name[80],
         response[80];

   int   a,
         b,
         c,
	 channel,
	 double_display,
	 horizontal,
         ie,
         il,
         key,
         le,
         ll,
         not_finished,
	 r,
	 vertical,
	 x_offset,
	 y_offset;


   unsigned int block,
                color,
                i,
                j,
                x,
                y;

   unsigned long histogram[256];


   _setvideomode(_TEXTC80);         /* MSC 6.0 statements */
   _setbkcolor(1);
   _settextcolor(7);
   _clearscreen(_GCLEARSCREEN);

   strcpy(file_name, "d:/images/nbrite.dat");
   strcpy(channels, "Single channel");
   strcpy(color_transform, "Modified transform");
   channel = 1;
   il      = 1;
   ll      = 100;
   ie      = 1;
   le	   = 100;
   horizontal = 5;
   vertical   = 4;
   double_display = 0;

   printf("\nThis is the display program.");
   printf("\nThis program can either display a 300x500 section of");
   printf("\nan image or three channels of a 100x500 section of an");
   printf("\nimage. The parameters entered describe the upper left");
   printf("\n100x100 corner of the display.");

   not_finished = 1;
   while(not_finished){

      display_menu(channels, color_transform);
      get_image_name(file_name);
      get_parameters(&channel, &il, &ie, &ll, &le,
		     &horizontal, &vertical, &double_display);


	/*******************************************
	*
	*   we want to set an offset so the image is
	*   centered on the CRT
	*
	********************************************/

	   x_offset = 0;
	   y_offset = 0;
	   x_offset = (6-horizontal)*100;
	   x_offset = 20 + x_offset/2;
	   y_offset = (4-vertical)*100;
	   y_offset = 40 + y_offset/2;



           /*********************************************
           *
           *   If the color_transform requires histogram
           *   equalization, then calculate the histogram
           *   from the four corners of the image.  You
           *   will use this in the display loop below
           *   to equalize the image.
           *
           **********************************************/

      if(color_transform[0] == 'H'){
         printf("\nCalculating histograms");
         zero_long_histogram(histogram);
         printf("\n\t1");
         read_image(image, file_name, channel, il, ie, ll, le);
         calculate_long_histogram(image, histogram);
         printf("\n\t2");
	 read_image(image, file_name, channel, il+400, ie,
		    ll+400, le);
         calculate_long_histogram(image, histogram);
         printf("\n\t3");
	 read_image(image, file_name, channel, il,
		    ie+400, ll, le+400);
         calculate_long_histogram(image, histogram);
         printf("\n\t4");
         read_image(image, file_name, channel, il+400, ie+400,
		    ll+400, le+400);
         calculate_long_histogram(image, histogram);
for(a=0; a<256; a++)
printf("\nh[%4d] = %8d", a, histogram[a]);
      }  /* ends if color_transform == H */


           /*********************************************
           *
           *   Find out what the key should be. This
           *   requires looking at the name of the image
           *   that is being displayed. Use a different
           *   key for the three different channels of
           *   the image.
           *
           **********************************************/

      key = 0;
      if(file_name[16] == '1')
         key = 1;
      if(file_name[16] == '2')
         key = 2;
      if(file_name[16] == '3')
         key = 3;
      if( (file_name[16] == '.') &&
          (channel == 1))
         key = 1;
      if( (file_name[16] == '.') &&
          (channel == 2))
         key = 2;
      if( (file_name[16] == '.') &&
          (channel == 3))
         key = 3;

  /* set graphics mode */
/*******
     map_16_shades_of_gray(_VRES16COLOR);
     blank_out_display();
********/

my_set_colors();




	  /***************************************************
          *
          *   If a single channel is desired then display a 300x500
	  *   section of one channel. If multiple channels
	  *   are desired then display one 100x500 section
	  *   of the image three times.
          *
	  *****************************************************/

      if( (channels[0] == 'S')  ||
	  (channels[0] == 's')){

	 for(a=0; a<horizontal; a++){
	    for(b=0; b<vertical; b++){
               x = a*100;
               y = b*100;
               read_image(image, file_name, channel, il+y, ie+x,
			   ll+y, le+x);

               if(color_transform[0] == 'H')
                  perform_histogram_equalization(image, histogram,
					      16, 40000);

	       if(double_display == 1){

		  if( (a==0) && (b==0)){
		    x_offset = 120;
		    y_offset = 40;
		  }

		  if( (a==0) && (b==1)){
		    x_offset = 120;
		    y_offset = 140;
		  }

		  if( (a==1) && (b==0)){
		    x_offset = 220;
		    y_offset = 40;
		  }

		  if( (a==1) && (b==1)){
		    x_offset = 220;
		    y_offset = 140;
		  }
	       }

               display_image_portion(image, key, color_transform,
				x, y, x_offset, y_offset,
				double_display);
            }  /* ends loop over b                   */
	 }     /* ends loop over a		     */

      }        /* ends if channels == Single channel */



      else{    /* else display three channels        */
         for(a=0; a<5; a++){    /*  Channel 1  */
            x = a*100;
            y =     0;
            read_image(image, file_name, 1, il+y, ie+x, ll+y,
			le+x);
            display_image_portion(image, key, color_transform, x,
				  y, x_offset, y_offset,
				  double_display);
         }  /* ends loop over a  */

         for(a=0; a<5; a++){    /*  Channel 2  */
            x = a*100;
            y =     0;
            color_transform[0] = 'S';
            read_image(image, file_name, 2, il+y, ie+x, ll+y,
		       le+x);
            display_image_portion(image, key, color_transform, x,
				  y+100, x_offset, y_offset,
				  double_display);
         }  /* ends loop over a  */

         for(a=0; a<5; a++){    /*  Channel 3  */
            x = a*100;
            y =     0;
            color_transform[0] = 'S';
            read_image(image, file_name, 3, il+y, ie+x, ll+y,
			le+x);
            display_image_portion(image, key, color_transform, x,
				  y+200, x_offset, y_offset,
				  double_display);
         }  /* ends loop over a  */
      }     /* ends else display multiple channels  */


/******************
      setlinestyle(SOLID_LINE, 0, THICK_WIDTH);
      for(i=0; i<5; i++){
         line(0, i*100, 500, i*100);
      }

      for(i=0; i<6; i++){
         line(i*100, 0, i*100, 300);
      }


      setlinestyle(SOLID_LINE, 0, NORM_WIDTH);
      for(i=0; i<13; i++){
         line(0, i*25, 500, i*25);
      }

      for(i=0; i<21; i++){
         line(i*25, 0, i*25, 300);
      }
******************/


/***********
setusercharsize(1, 2, 1, 2);
settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 0);
outtextxy(10, 320, "done");
***********/


/******************
    The following label the objects in the lower portion of the
image
outtextxy(400, 200, "041 house");
outtextxy(100, 25, "041 house");
outtextxy(100, 200, "040 apartments/hotel");
outtextxy(350, 50, "040 apartments/hotel");
outtextxy(10, 100, "200 decidous");
outtextxy(175, 150, "200 decidous");
*******************/


      read_string(response);
      printf("\nEnter 0 to quit 1 to do again");
      get_integer(&not_finished);

          /* set display back to text mode */
   _setvideomode(_TEXTC80);         /* MSC 6.0 statements */
   _setbkcolor(1);
   _settextcolor(7);
   _clearscreen(_GCLEARSCREEN);


   }  /* ends while not_finished  */

}  /* ends main  */
Exemple #13
0
string formatter::format_app_name(field_datum const & f)
{
	return get_image_name(f.symbol.app_name, long_filenames);
}