-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
telescope for debugger #297
base: master
Are you sure you want to change the base?
Conversation
I think the workflow fails because I'm modifying the parser & lexer :? If I do it in the correct order on my machine, everything compiles fine... |
You clearly have to write better doc about what is telescope and how it is configured telescopeset max_rows max_depth data_depth data_hex There max_rows max_depth data_depth are just magic numbers from first sight also I wonder where the name comes from |
Yes, its not the final version, but I want more feedback. About name 'telescope': https://browserpwndbg.readthedocs.io/en/docs/commands/procinfo/telescope/ |
@stlintel Besides improving the documentation, fixing the coding style, enhancing the code... is there anything else that comes to mind? |
fixed coding style & doc @stlintel opinion? (my english s*cks) (github actions fails because parser & lexer changes?) |
@@ -523,7 +523,7 @@ void UpdateStatus() | |||
// Note: laddr + len must not cross a 4K boundary -- otherwise, there are no limits | |||
bool ReadBxLMem(Bit64u laddr, unsigned len, Bit8u *buf) | |||
{ | |||
return bx_dbg_read_linear(CurrentCPU, laddr, len, buf); | |||
return bx_dbg_read_linear(CurrentCPU, laddr, len, buf, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make the param 'quiet' as default false and void changing every call to bx_dbg_read_linear
@@ -117,6 +117,8 @@ writemem { bxlval.sval = strdup(bxtext); return(BX_TOKEN_WRITEMEM); } | |||
loadmem { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LOADMEM); } | |||
setpmem { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SETPMEM); } | |||
deref { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DEREF); } | |||
telescope { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TELESCOPE); } | |||
telescopeset { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TELESCOPESET); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be also telescope reset shortcut instead of 'telescope 0 0 0 0' ?
also lexer is not forgiving for these 4 params
if you forget one or miss order of these params -> result is not nice and hard to understand what went wrong
I prefer smth like telescope rows=R depth=D data_depth=DD hex=H
but I didn't conclude it yet ... anyway -> at least when telescope is called -> print what is actually did.
like setting 'rows = R and etc
Are where default params here ?
Like hex=TRUE is omitted ?
Or data_depth = max_depth if omitted ?
@@ -80,7 +80,7 @@ void bx_dbg_set_magic_bp_mask(Bit8u new_mask); | |||
void bx_dbg_clr_magic_bp_mask(Bit8u mask); | |||
Bit8u bx_dbg_get_magic_bp_mask_from_str(const char *str); | |||
void bx_dbg_print_magic_bp_mask_from_str(Bit8u mask); | |||
bool bx_dbg_read_linear(unsigned which_cpu, bx_address laddr, unsigned len, Bit8u *buf); | |||
bool bx_dbg_read_linear(unsigned which_cpu, bx_address laddr, unsigned len, Bit8u *buf, bool quiet); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use = false default parameter
@@ -1245,56 +1251,96 @@ void bx_dbg_info_registers_command(unsigned cpu, int which_regs_mask) | |||
#endif | |||
#if BX_SUPPORT_X86_64 == 0 | |||
reg = BX_CPU(cpu)->get_reg32(BX_32BIT_REG_EAX); | |||
dbg_printf("eax: 0x%08x %d\n", (unsigned) reg, (int) reg); | |||
dbg_printf("eax: 0x%08x %d ", (unsigned) reg, (int) reg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awful code duplication.
should be array of const char* containing "rax", "rbx", ... , "r15" like this one from disasm.cc:
static const char *general_64bit_regname[17] = {
"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "rip"
};
and for walking over all registers
{ | ||
if (len == 4) { | ||
dbg_printf("0x%08x ", (unsigned) addr); | ||
bx_dbg_telescope(addr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid duplicating bx_dbg_telescope(addr) call ?
just do dbg_printf with if's and call bx_dbg_telescope(addr) after them
; | ||
|
||
telescopeset_command: | ||
BX_TOKEN_TELESCOPESET BX_TOKEN_NUMERIC BX_TOKEN_NUMERIC BX_TOKEN_NUMERIC BX_TOKEN_NUMERIC '\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is possible to have default parameters ?
| expression BX_TOKEN_DEREF_CHR expression { $$ = bx_dbg_deref($1, $3, NULL, NULL, 0); } | ||
| expression BX_TOKEN_RSHIFT expression { $$ = $1 >> $3; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably prefer default parameter also here for bx_dbg_deref
Please also include generated lex and yacc files in the PR |
telescope aims to simplify the dereferencing of an address to determine the content it actually points to. At a glance, you can see the entire chain + final data (ascii string / hex). Very handy for reversing & exploiting.
Example: telescopeset 6 5 15 0
Once activated with the telescopeset command, it can be viewed with the regs, print-stack, and used individually with the telescope command:
A wild PE32 appeared!
I would like the first version of this feature to be simple and straightforward, without adding many options for tuning.
Since the current code is tightly coupled with the UI, I've made the minimum necessary changes to make it functional and "non-noisy"
Do you like it? What changes would you like me to make?
I haven't fixed the coding style yet, and it's not completely finished, but I wanted to discuss the idea before continuing!
@stlintel @vruppert :D
Inspired by GDB-GEF, PEDA, PWNDBG...
GDB-GEF:
PWNDBG: