Exemplo n.º 1
0
static int print_meta_offset(RCore *core, ut64 offset) {
	int ret, line, line_old, i;
	char file[1024];

	ret = r_bin_addr2line (core->bin, offset, file, sizeof (file)-1, &line);

	if (ret) {
		r_cons_printf ("file %s\nline %d\n", file, line);
		line_old = line;
		if (line >= 2)
			line -= 2;
		if (r_file_exists (file)) {
			for (i = 0; i<5; i++) {
				char *row = r_file_slurp_line (file, line+i, 0);
				if (row) {
					r_cons_printf ("%c %.3x  %s\n", line+i == line_old ? '>' : ' ', line+i, row);
					free (row);
				}
			}
		} else {
			eprintf ("Cannot open '%s'\n", file);
		}
	} else {
		eprintf ("Cannot find meta information at 0x%08"
			PFMT64x"\n", offset);
	}

	return 0;
}
Exemplo n.º 2
0
R_API char *r_bin_addr2fileline(RBin *bin, ut64 addr) {
	char file[1024];
	int line;
	char *out = NULL;
	char *file_nopath;

	if (r_bin_addr2line (bin, addr, file, sizeof (file)-1, &line)) {
		int sz = strlen (file)+10;
		file_nopath = strrchr (file, '/');
		out = malloc (sz);
		snprintf (out, sizeof (sz), "%s:%d",
				file_nopath ? file_nopath + 1 : file , line);
	}
	return out;
}
Exemplo n.º 3
0
R_API char *r_bin_addr2text(RBin *bin, ut64 addr) {
	char file[1024];
	int line;
	char *out = NULL, *out2;
	char *file_nopath;

	if (r_bin_addr2line (bin, addr, file, sizeof (file), &line)) {
		out = r_file_slurp_line (file, line, 0);
		if (!out)
			return 0;

		out2 = malloc((strlen(file) + 64 + strlen(out))*sizeof(char));
		file_nopath = strrchr (file, '/');
		snprintf(out2, strlen(file) + 63 + strlen(out), "%s:%d %s",
				file_nopath ? file_nopath + 1 : file, line, out);

		free (out);
		return out2;
	}
	return 0;
}