* Show comments at right of disasm if they fit in screen

- Added r_cons_get_column () api
* Fix ';' in visual (0 prefix)
* Update pkg-config files
* Fix sys/vala.sh
  - Use ccache if possible
* Add r_magic.vapi
This commit is contained in:
pancake 2011-09-12 03:01:07 +02:00
parent 37fecf7c0c
commit 4a3d7bc1db
11 changed files with 90 additions and 20 deletions

7
TODO
View File

@ -6,6 +6,7 @@
====[[ 0.9 ]]====
* Optimize /m
- search only using given file, not loading default library
- do not read each block byte per byte
- do not show repeated consecutive hits
* Handle ^C in searches (at least)
@ -82,21 +83,19 @@ TODO
* REFACTORING of disasm loop XDDDDD -1 (r2-0.9 plzz)
- arch dependent anal code must be removed from disasm loop +1
To wipe:
========
- Move manpages from man/ to binr/*/? (harder to maintain?)
- Move the content of libr/*/TODO here
- linestyle?? for disassembly lines
- remove libr/vm and libr/db
- imho we should not implement this:
- Implement BLOCK in r_core_sysenv_begin|end ()
pancake
-------
* check search multiple keywords and signatures
* if console width > X place comments there (ash)
* Implement BLOCK in r_core_sysenv_begin|end ()
* Fix iterators for r_macro (test only?)
- search for antidebug/disasm tricks opcodes
- allows to find interesting points to analyze

View File

@ -322,6 +322,13 @@ R_API void r_cons_printf(const char *format, ...) {
} else r_cons_strcat (format);
}
R_API int r_cons_get_column() {
char *line = strrchr (I.buffer, '\n');
if (!line) line = I.buffer;
I.buffer[I.buffer_len] = 0;
return r_str_ansi_len (line);
}
/* final entrypoint for adding stuff in the buffer screen */
R_API void r_cons_memcat(const char *str, int len) {
if (len>0) {

View File

@ -66,7 +66,17 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l
int linesopts = 0;
int lastfail = 0;
const char *pre = " ";
int show_comment_right = 0;
int ocols = 0;
if (show_lines) ocols += 10;
if (show_offset) ocols += 14;
if (show_bytes) ocols += 20;
if (show_trace) ocols += 8;
if (show_stackptr) ocols += 4;
/* disasm */ ocols += 20;
nb = (nbytes*2);
core->inc = 0;
@ -134,12 +144,27 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l
}
f = show_functions? r_anal_fcn_find (core->anal, at, R_ANAL_FCN_TYPE_NULL): NULL;
if (show_comments)
if ((comment = r_meta_get_string (core->anal->meta, R_META_TYPE_COMMENT, at))) {
if (show_color) r_cons_strcat (Color_TURQOISE);
r_cons_strcat_justify (comment, strlen (refline) + 5, ';');
if (show_color) r_cons_strcat (Color_RESET);
free (comment);
/* show comment at right? */
show_comment_right = 0;
if (show_comments) {
comment = r_meta_get_string (core->anal->meta, R_META_TYPE_COMMENT, at);
if (comment) {
int maxclen = strlen (comment)+10;
if (ocols+maxclen < core->cons->columns) {
if (comment && *comment && strlen (comment)<maxclen) {
char *p = strchr (comment, '\n');
if (p && !strchr (p+1, '\n')) // more than one line?
show_comment_right = 1;
}
}
if (!show_comment_right) {
if (show_color) r_cons_strcat (Color_TURQOISE);
r_cons_strcat_justify (comment, strlen (refline) + 5, ';');
if (show_color) r_cons_strcat (Color_RESET);
free (comment);
comment = NULL;
}
}
}
// TODO : line analysis must respect data types! shouldnt be interpreted as code
ret = r_asm_disassemble (core->assembler, &asmop, buf+idx, len-idx);
@ -267,8 +292,9 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l
else r_cons_printf ("%s:\n", flag->name);
}
}
if (show_lines && line)
if (show_lines && line) {
r_cons_strcat (line);
}
if (show_offset) {
if (show_color && (at == dest))
r_cons_invert (R_TRUE, R_TRUE);
@ -467,7 +493,6 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l
ret -= middle;
r_cons_printf (" ; *middle* %d", ret);
}
#
if (core->assembler->syntax != R_ASM_SYNTAX_INTEL) {
RAsmOp ao; /* disassemble for the vm .. */
int os = core->assembler->syntax;
@ -523,7 +548,19 @@ R_API int r_core_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int l
}
} else r_cons_printf ("; err [0x%"PFMT64x"]", analop.ref);
}
r_cons_newline ();
if (show_comment_right) {
if (show_comments && comment) {
int c = r_cons_get_column ();
if (c<ocols)
r_cons_memset(' ',ocols-c);
r_cons_strcat (" ; ");
if (show_color) r_cons_strcat (Color_TURQOISE);
// r_cons_strcat_justify (comment, strlen (refline) + 5, ';');
r_cons_strcat (comment);
if (show_color) r_cons_strcat (Color_RESET);
free (comment);
} else r_cons_newline ();
} else r_cons_newline ();
if (line) {
if (show_lines && analop.type == R_ANAL_OP_TYPE_RET) {
if (strchr (line, '>'))

View File

@ -449,7 +449,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
r_cons_printf ("Enter a comment: ('-' to remove, '!' to use $EDITOR)\n");
r_cons_flush ();
r_cons_set_raw (R_FALSE);
strcpy (buf, "CC 0 ");
strcpy (buf, "CC ");
r_line_set_prompt ("comment: ");
i = strlen (buf);
if (r_cons_fgets (buf+i, sizeof (buf)-i-1, 0, NULL) >1) {

View File

@ -218,6 +218,7 @@ R_API void r_cons_invert(int set, int color);
R_API int r_cons_yesno(int def, const char *fmt, ...);
R_API void r_cons_set_cup(int enable);
R_API void r_cons_column(int c);
R_API int r_cons_get_column();
#endif
#endif

View File

@ -7,5 +7,5 @@ Name: r_core
Description: radare foundation libraries
Version: @VERSION@
Requires:
Libs: -L${libdir} -lr_core -lr_config -lr_cons -lr_line -lr_io -lr_cmd -lr_util -lr_print -lr_flags -lr_asm -lr_lib -lr_debug -lr_hash -lr_bin -lr_lang -lr_io -lr_anal -lr_parse -lr_print -lr_bp -lr_reg -lr_search -lr_syscall -lr_sign -lr_diff -lr_socket -lr_fs
Libs: -L${libdir} -lr_core -lr_config -lr_cons -lr_line -lr_io -lr_cmd -lr_util -lr_print -lr_flags -lr_asm -lr_lib -lr_debug -lr_hash -lr_bin -lr_lang -lr_io -lr_anal -lr_parse -lr_print -lr_bp -lr_reg -lr_search -lr_syscall -lr_sign -lr_diff -lr_socket -lr_fs -lr_magic
Cflags: -I${includedir}/libr

View File

@ -1,11 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
libdir=@LIBDIR@
includedir=${prefix}/include
Name: r_db
Description: radare foundation libraries
Version:
Version: @VERSION@
Requires:
Libs: -L${libdir} -lr_db -lr_util
Cflags: -I${includedir}/libr

View File

@ -7,5 +7,5 @@ Name: r_syscall
Description: radare foundation libraries
Version: @VERSION@
Requires:
Libs: -L${libdir} -lr_syscall
Libs: -L${libdir} -lr_syscall -lr_util -lr_db
Cflags: -I${includedir}/libr

View File

@ -2,4 +2,4 @@ LIBS=r_util.${SOEXT} r_bp.${SOEXT} r_asm.${SOEXT} r_diff.${SOEXT}
LIBS+=r_bin.${SOEXT} r_cons.${SOEXT} r_anal.${SOEXT} r_cmd.${SOEXT}
LIBS+=r_debug.${SOEXT} r_config.${SOEXT} r_io.${SOEXT} r_syscall.${SOEXT}
LIBS+=r_search.${SOEXT} r_lib.${SOEXT} r_flags.${SOEXT} r_fs.${SOEXT}
LIBS+=r_parse.${SOEXT} r_lang.${SOEXT} r_core.${SOEXT}
LIBS+=r_parse.${SOEXT} r_lang.${SOEXT} r_core.${SOEXT} r_magic.${SOEXT}

View File

@ -0,0 +1,18 @@
/* radare - LGPL - Copyright 2011 pancake<@nopcode.org> */
[Compact]
[CCode (cheader_filename="r_magic.h", cname="RMagic", free_function="r_magic_free", cprefix="r_magic_")]
public class Radare.RMagic {
/* lifecycle */
public RMagic(int flags=0);
public weak string file(string f);
public weak string descriptor(int d);
public weak string buffer(void *buffer, size_t n);
public int load(string file);
public int check(string file);
public int compile(string file);
public void setflags(int flags);
}

View File

@ -6,6 +6,13 @@ cd `dirname $PWD/$0`
mkdir -p _work
cd _work
ccache --help 2>&1 > /dev/null
if [ $? = 0 ]; then
[ -z "${CC}" ] && CC=gcc
CC="ccache ${CC}"
export CC
fi
valac --help 2>&1 >/dev/null
if [ ! $? = 0 ]; then
# must install from tarball
@ -24,10 +31,11 @@ fi
if [ -d vala ]; then
cd vala
sudo make uninstall
#sudo make uninstall
git pull
else
git clone git://git.gnome.org/vala
cd vala
fi
sh autogen.sh --prefix=/usr && \
make -j 4 && \