Beispiel #1
0
void
gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
		char *file_string,
		int flags,
		int how_many, CORE_ADDR low, CORE_ADDR high)
{
  struct ui_stream *stb = ui_out_stream_new (uiout);
  struct cleanup *cleanups = make_cleanup_ui_out_stream_delete (stb);
  struct disassemble_info di = gdb_disassemble_info (gdbarch, stb->stream);
  /* To collect the instruction outputted from opcodes. */
  struct symtab *symtab = NULL;
  struct linetable_entry *le = NULL;
  int nlines = -1;

  /* Assume symtab is valid for whole PC range */
  symtab = find_pc_symtab (low);

  if (symtab != NULL && symtab->linetable != NULL)
    {
      /* Convert the linetable to a bunch of my_line_entry's.  */
      le = symtab->linetable->item;
      nlines = symtab->linetable->nitems;
    }

  if (!(flags & DISASSEMBLY_SOURCE) || nlines <= 0
      || symtab == NULL || symtab->linetable == NULL)
    do_assembly_only (gdbarch, uiout, &di, low, high, how_many, flags, stb);

  else if (flags & DISASSEMBLY_SOURCE)
    do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low,
				  high, symtab, how_many, flags, stb);

  do_cleanups (cleanups);
  gdb_flush (gdb_stdout);
}
Beispiel #2
0
static int
gdbscm_print_insn_from_port (struct gdbarch *gdbarch,
			     SCM port, ULONGEST offset, CORE_ADDR memaddr,
			     struct ui_file *stream, int *branch_delay_insns)
{
  struct disassemble_info di;
  int length;
  struct gdbscm_disasm_data data;

  di = gdb_disassemble_info (gdbarch, stream);
  data.gdbarch = gdbarch;
  data.port = port;
  data.offset = offset;
  di.application_data = &data;
  di.read_memory_func = gdbscm_disasm_read_memory;
  di.memory_error_func = gdbscm_disasm_memory_error;
  di.print_address_func = gdbscm_disasm_print_address;

  length = gdbarch_print_insn (gdbarch, memaddr, &di);

  if (branch_delay_insns)
    {
      if (di.insn_info_valid)
	*branch_delay_insns = di.branch_delay_insns;
      else
	*branch_delay_insns = 0;
    }

  return length;
}
Beispiel #3
0
void
gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
		 char *file_string, int flags, int how_many,
		 CORE_ADDR low, CORE_ADDR high)
{
  struct ui_file *stb = mem_fileopen ();
  struct cleanup *cleanups = make_cleanup_ui_file_delete (stb);
  struct disassemble_info di = gdb_disassemble_info (gdbarch, stb);
  struct symtab *symtab;
  struct linetable_entry *le = NULL;
  int nlines = -1;

  /* Assume symtab is valid for whole PC range.  */
  symtab = find_pc_line_symtab (low);

  if (symtab != NULL && SYMTAB_LINETABLE (symtab) != NULL)
    {
      /* Convert the linetable to a bunch of my_line_entry's.  */
      le = SYMTAB_LINETABLE (symtab)->item;
      nlines = SYMTAB_LINETABLE (symtab)->nitems;
    }

  if (!(flags & DISASSEMBLY_SOURCE) || nlines <= 0
      || symtab == NULL || SYMTAB_LINETABLE (symtab) == NULL)
    do_assembly_only (gdbarch, uiout, &di, low, high, how_many, flags, stb);

  else if (flags & DISASSEMBLY_SOURCE)
    do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low,
				  high, symtab, how_many, flags, stb);

  do_cleanups (cleanups);
  gdb_flush (gdb_stdout);
}
Beispiel #4
0
uint32_t ti68k_debug_disassemble(uint32_t addr, char **line)
{
	static struct disassemble_info di;
	static char *output = NULL;
	uint32_t offset;
	gchar **split;
	gchar *p;

	if (!output)
	{
		di = gdb_disassemble_info (NULL, NULL);
		output = di.stream;
	}

	*output = 0;
	offset = print_insn_m68k(addr, &di);
	split = g_strsplit(output, " ", 2);

	if(split[1])
		for(p = split[1]; *p == ' '; p++);
	else
		p = "";

	*line = g_strdup_printf("%06x: %s %s", addr, split[0] ? split[0] : "", p);
	g_strfreev(split);

	return offset;
}
Beispiel #5
0
uint32_t Dasm68000(unsigned char *mem_buf, char *output_buf, uint32_t addr)
{
  struct disassemble_info di = gdb_disassemble_info(mem_buf, output_buf);
  uint32_t offset;

  *output_buf = 0;
  di.buffer_vma = addr;
  offset = print_insn_m68k(addr, &di);
  return offset;
}
Beispiel #6
0
int
gdb_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
		struct ui_file *stream, int *branch_delay_insns)
{
  struct disassemble_info di;
  int length;

  di = gdb_disassemble_info (gdbarch, stream);
  length = gdbarch_print_insn (gdbarch, memaddr, &di);
  if (branch_delay_insns)
    {
      if (di.insn_info_valid)
	*branch_delay_insns = di.branch_delay_insns;
      else
	*branch_delay_insns = 0;
    }
  return length;
}
Beispiel #7
0
int
gdb_print_insn (CORE_ADDR memaddr, struct ui_file *stream)
{
	struct ui_stream *stb = ui_out_stream_new (uiout);
	struct cleanup *cleanups = make_cleanup_ui_out_stream_delete (stb);
	struct disassemble_info di = gdb_disassemble_info (current_gdbarch, stb->stream);
	//  struct disassemble_info di = gdb_disassemble_info (current_gdbarch, stream);
	struct disassemble_info * di2 = &di;
	struct cleanup *ui_out_chain;
	
	ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
	int i;
	CORE_ADDR old_pc = memaddr;
	CORE_ADDR oldmemaddr = memaddr;
	bfd_byte data;
	int status;
	ui_file_rewind (stb->stream);
	memaddr = TARGET_PRINT_INSN (memaddr, &di);
	oldmemaddr += memaddr;
	for (; old_pc < oldmemaddr; old_pc ++)
	{
		status = (*di2->read_memory_func) (old_pc, &data, 1, di2);
		if (status != 0)
			(*di2->memory_error_func) (status, old_pc, di2);
		ui_out_message (uiout, 0, " %02x", (unsigned)data);
	}
	i = memaddr;
	for (; i<10; i++) ui_out_text(uiout, "   ");
	ui_out_text (uiout, " ");
	ui_out_field_stream(uiout, "inst", stb);
	ui_file_rewind (stb->stream);
	do_cleanups (ui_out_chain);
	
	return memaddr;
	//  return TARGET_PRINT_INSN (memaddr, &di);
}
Beispiel #8
0
int
gdb_print_insn(CORE_ADDR memaddr, struct ui_file *stream)
{
  struct disassemble_info di = gdb_disassemble_info(current_gdbarch, stream);
  return TARGET_PRINT_INSN(memaddr, &di);
}
Beispiel #9
0
static struct disassemble_info
gdb_disassemble_info_null (struct gdbarch *gdbarch)
{
  struct disassemble_info ret = gdb_disassemble_info (gdbarch, gdb_null);
  return ret;
}