Ejemplo n.º 1
0
void update_variables()
{
	IIntuition->SetAttrs(MainObj[GAD_VARIABLES_LISTBROWSER], LISTBROWSER_Labels, ~0, TAG_DONE);
	struct Node *n = IExec->GetHead(&variable_list);
	while(n)
	{
		if (n == registers_node)
            break;

		if(n != locals_node && n != globals_node)
		{
			struct variables_userdata *u;
			uint32 flags;
			IListBrowser->GetListBrowserNodeAttrs(n,
												LBNA_UserData, &u,
												LBNA_Flags, &flags,
												TAG_END);
			if(u && u->s /*&& !u->haschildren*/)
			{
				char *str = print_variable_value(u->s);
				IListBrowser->SetListBrowserNodeAttrs(n,
												LBNA_Column, 1,
													LBNCA_Text, str,
												TAG_END);
			}
		}
        n = IExec->GetSucc(n);
	}
	registers_update();
	IIntuition->SetGadgetAttrs((struct Gadget *)MainObj[GAD_VARIABLES_LISTBROWSER], mainwin, NULL, LISTBROWSER_Labels, &variable_list, TAG_END);
}
Ejemplo n.º 2
0
static void
info_common_command (char *comname, int from_tty)
{
  SAVED_F77_COMMON_PTR the_common;
  COMMON_ENTRY_PTR entry;
  struct frame_info *fi;
  char *funname = 0;
  struct symbol *func;

  /* We have been told to display the contents of F77 COMMON 
     block supposedly visible in this function.  Let us 
     first make sure that it is visible and if so, let 
     us display its contents */

  fi = deprecated_selected_frame;

  if (fi == NULL)
    error ("No frame selected");

  /* The following is generally ripped off from stack.c's routine 
     print_frame_info() */

  func = find_pc_function (get_frame_pc (fi));
  if (func)
    {
      /* In certain pathological cases, the symtabs give the wrong
         function (when we are in the first function in a file which
         is compiled without debugging symbols, the previous function
         is compiled with debugging symbols, and the "foo.o" symbol
         that is supposed to tell us where the file with debugging symbols
         ends has been truncated by ar because it is longer than 15
         characters).

         So look in the minimal symbol tables as well, and if it comes
         up with a larger address for the function use that instead.
         I don't think this can ever cause any problems; there shouldn't
         be any minimal symbols in the middle of a function.
         FIXME:  (Not necessarily true.  What about text labels) */

      struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi));

      if (msymbol != NULL
	  && (SYMBOL_VALUE_ADDRESS (msymbol)
	      > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
	funname = DEPRECATED_SYMBOL_NAME (msymbol);
      else
	funname = DEPRECATED_SYMBOL_NAME (func);
    }
  else
    {
      struct minimal_symbol *msymbol =
      lookup_minimal_symbol_by_pc (get_frame_pc (fi));

      if (msymbol != NULL)
	funname = DEPRECATED_SYMBOL_NAME (msymbol);
    }

  /* If comname is NULL, we assume the user wishes to see the 
     which COMMON blocks are visible here and then return */

  if (comname == 0)
    {
      list_all_visible_commons (funname);
      return;
    }

  the_common = find_common_for_function (comname, funname);

  if (the_common)
    {
      if (strcmp (comname, BLANK_COMMON_NAME_LOCAL) == 0)
	printf_filtered ("Contents of blank COMMON block:\n");
      else
	printf_filtered ("Contents of F77 COMMON block '%s':\n", comname);

      printf_filtered ("\n");
      entry = the_common->entries;

      while (entry != NULL)
	{
	  printf_filtered ("%s = ", DEPRECATED_SYMBOL_NAME (entry->symbol));
	  print_variable_value (entry->symbol, fi, gdb_stdout);
	  printf_filtered ("\n");
	  entry = entry->next;
	}
    }
  else
    printf_filtered ("Cannot locate the common block %s in function '%s'\n",
		     comname, funname);
}
Ejemplo n.º 3
0
struct Node *variables_add_children(struct Node *n, struct stab_symbol *s, int32 gen, int hidden)
{
	uint32 hidflag = (hidden ? LBFLG_HIDDEN : 0);
	struct Node *node;

	if(!s->type)
	{
		if (node = IListBrowser->AllocListBrowserNode(2,
		        								LBNA_Generation, gen+1,
		        								LBNA_Flags, hidflag,
                                                LBNA_Column, 0,
                                                LBNA_UserData, NULL,
                                                	LBNCA_CopyText, TRUE,
                                                	LBNCA_Text, s->name,
                                                LBNA_Column, 1,
                                               		LBNCA_Text, "(unknown type)",
                                                TAG_DONE))
                                    {
                                    	if(n)
	                                        IExec->Insert(&variable_list, node, n);
	                                    else
	                                    	IExec->AddTail(&variable_list, node);
                                    }
		return node;
	}
	switch(s->type->type)
	{
      	case T_UNKNOWN:
    	case T_VOID:
    	case T_BOOL:
	    case T_U8:
	    case T_8:
	    case T_U16:
	    case T_16:
	    case T_U32:
	    case T_32:
	    case T_U64:
	    case T_64:
	    case T_FLOAT32:
	    case T_FLOAT64:
	    case T_ENUM:
	   	{
			TEXT buf[1024];
	        IUtility->SNPrintf(buf, sizeof(buf), "%s", s->name);

			char *str = print_variable_value(s);
			
            struct variables_userdata *u = freemem_malloc(variables_freemem_hook, sizeof(struct variables_userdata));
            u->s = s;
            u->haschildren = 0;
            
			if (node = IListBrowser->AllocListBrowserNode(2,
		        								LBNA_Generation, gen+1,
		        								LBNA_Flags, hidflag,
                                                LBNA_Column, 0,
                                                LBNA_UserData, u,
                                                	LBNCA_CopyText, TRUE,
                                                	LBNCA_Text, buf,
                                                LBNA_Column, 1,
                                               		LBNCA_Text, str,
                                                TAG_DONE))
                                    {
                                    	if(n)
	                                        IExec->Insert(&variable_list, node, n);
	                                    else
	                                    	IExec->AddTail(&variable_list, node);
                                    }
		}
		break;
				
		case T_POINTER:
		{
			TEXT buf[1024];
	        IUtility->SNPrintf(buf, sizeof(buf), "%s", s->name);
	        
		    struct variables_userdata *u = freemem_malloc(variables_freemem_hook, sizeof(struct variables_userdata));
            u->s = s;
            u->haschildren = 1;
            u->isopen = 0;
            
			char *str = print_variable_value(s);
	        if (node = IListBrowser->AllocListBrowserNode(2,
		        								LBNA_Generation, gen+1,
		        								LBNA_Flags, LBFLG_HASCHILDREN|hidflag,
		        								LBNA_UserData, u,
                                                LBNA_Column, 0,
                                                	LBNCA_CopyText, TRUE,
                                                	LBNCA_Text, buf,
                                                LBNA_Column, 1,
                                                	LBNCA_Text, str,
                                                TAG_DONE))
                                    {
                                    	if(n)
                                    		IExec->Insert(&variable_list, node, n);
                                    	else
	                                        IExec->AddTail(&variable_list, node);
                                    }

		}
		break;
		
		case T_STRUCT:
		case T_UNION:
		{
			TEXT buf[1024];
	        IUtility->SNPrintf(buf, sizeof(buf), "%s", s->name);

			char *str = " < struct > ";
			
            struct variables_userdata *u = freemem_malloc(variables_freemem_hook, sizeof(struct variables_userdata));
            u->s = s;
            u->haschildren = 1;
            u->isopen = 1;
            
			if (node = IListBrowser->AllocListBrowserNode(2,
		        								LBNA_Generation, gen+1,
		        								LBNA_Flags, LBFLG_HASCHILDREN|hidflag,
                                                LBNA_Column, 0,
                                                LBNA_UserData, u,
                                                	LBNCA_CopyText, TRUE,
                                                	LBNCA_Text, buf,
                                                LBNA_Column, 1,
                                               		LBNCA_Text, str,
                                                TAG_DONE))
            {
               	if(n)
	        	    IExec->Insert(&variable_list, node, n);
	            else
	              	IExec->AddTail(&variable_list, node);
            }
	
			struct stab_structure *stru = s->type->struct_ptr;
			if(s->type->points_to)
				stru = s->type->points_to->struct_ptr;

			struct stab_struct_element *e = (struct stab_struct_element *)IExec->GetHead(&(stru->list));
			if(e)
			while(1)
			{
	    	    struct variables_userdata *u = freemem_malloc(variables_freemem_hook, sizeof(struct variables_userdata));
		    	struct stab_symbol *news = freemem_malloc(variables_freemem_hook, sizeof(struct stab_symbol));
		    	news->name = e->name;
		    	news->type = e->type;
		    	switch(s->location)
		    	{
		    		case L_ABSOLUTE:
		    			news->location = L_ABSOLUTE;
		    			news->address = s->address + (e->bitoffset >> 3);
		    			break;
		    		case L_STACK:
				        news->location = L_STACK;
        				news->offset = s->offset + (e->bitoffset >> 3);
        				break;
        			case L_POINTER:
        				news->location = L_POINTER;
        				news->offset = (e->bitoffset >> 3);
        				news->pointer = s->pointer;
        				break;
        		}

		    	node = variables_add_children(node, news, gen+1, TRUE);
				
				if(e == (struct stab_struct_element *)IExec->GetTail(&(stru->list)))
					break;
				e = (struct stab_struct_element *)IExec->GetSucc((struct Node *)e);
			}

		}
		break;

		default:
			break;
	}
	return node;
}
Ejemplo n.º 4
0
/* Print a list of the locals or the arguments for the currently
   selected frame.  If the argument passed is 0, printonly the names
   of the variables, if an argument of 1 is passed, print the values
   as well. */
static void
list_args_or_locals (int locals, int values, struct frame_info *fi)
{
  struct block *block;
  struct symbol *sym;
  struct dict_iterator iter;
  int nsyms;
  struct cleanup *cleanup_list;
  static struct ui_stream *stb = NULL;
  struct type *type;

  stb = ui_out_stream_new (uiout);

  block = get_frame_block (fi, 0);

  cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, locals ? "locals" : "args");

  while (block != 0)
    {
      ALL_BLOCK_SYMBOLS (block, iter, sym)
	{
          int print_me = 0;

	  switch (SYMBOL_CLASS (sym))
	    {
	    default:
	    case LOC_UNDEF:	/* catches errors        */
	    case LOC_CONST:	/* constant              */
	    case LOC_TYPEDEF:	/* local typedef         */
	    case LOC_LABEL:	/* local label           */
	    case LOC_BLOCK:	/* local function        */
	    case LOC_CONST_BYTES:	/* loc. byte seq.        */
	    case LOC_UNRESOLVED:	/* unresolved static     */
	    case LOC_OPTIMIZED_OUT:	/* optimized out         */
	      print_me = 0;
	      break;

	    case LOC_ARG:	/* argument              */
	    case LOC_REF_ARG:	/* reference arg         */
	    case LOC_REGPARM:	/* register arg          */
	    case LOC_REGPARM_ADDR:	/* indirect register arg */
	    case LOC_LOCAL_ARG:	/* stack arg             */
	    case LOC_BASEREG_ARG:	/* basereg arg           */
	    case LOC_COMPUTED_ARG:	/* arg with computed location */
	      if (!locals)
		print_me = 1;
	      break;

	    case LOC_LOCAL:	/* stack local           */
	    case LOC_BASEREG:	/* basereg local         */
	    case LOC_STATIC:	/* static                */
	    case LOC_REGISTER:	/* register              */
	    case LOC_COMPUTED:	/* computed location     */
	      if (locals)
		print_me = 1;
	      break;
	    }
	  if (print_me)
	    {
	      struct cleanup *cleanup_tuple = NULL;
	      struct symbol *sym2;
	      if (values != PRINT_NO_VALUES)
		cleanup_tuple =
		  make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
	      ui_out_field_string (uiout, "name", SYMBOL_PRINT_NAME (sym));

	      if (!locals)
		sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
				      block, VAR_DOMAIN,
				      (int *) NULL,
				      (struct symtab **) NULL);
	      else
		    sym2 = sym;
	      switch (values)
		{
		case PRINT_SIMPLE_VALUES:
		  type = check_typedef (sym2->type);
		  type_print (sym2->type, "", stb->stream, -1);
		  ui_out_field_stream (uiout, "type", stb);
		  if (TYPE_CODE (type) != TYPE_CODE_ARRAY
		      && TYPE_CODE (type) != TYPE_CODE_STRUCT
		      && TYPE_CODE (type) != TYPE_CODE_UNION)
		    {
		      print_variable_value (sym2, fi, stb->stream);
		      ui_out_field_stream (uiout, "value", stb);
		    }
		  do_cleanups (cleanup_tuple);
		  break;
		case PRINT_ALL_VALUES:
		  print_variable_value (sym2, fi, stb->stream);
		  ui_out_field_stream (uiout, "value", stb);
		  do_cleanups (cleanup_tuple);
		  break;
		}
	    }
	}
      if (BLOCK_FUNCTION (block))
	break;
      else
	block = BLOCK_SUPERBLOCK (block);
    }