Browse Source

Adds a .step command

Yann Weber 1 year ago
parent
commit
77beccae4f
3 changed files with 22 additions and 3 deletions
  1. 0
    1
      asmsh.h
  2. 14
    0
      shell_cmds.c
  3. 8
    2
      shell_cmds.h

+ 0
- 1
asmsh.h View File

108
 
108
 
109
 @section TODO TODOLIST
109
 @section TODO TODOLIST
110
 
110
 
111
-@todo Implement a .step instruction allowing to step without compiling any instruction
112
 @todo Implement breakpoints
111
 @todo Implement breakpoints
113
 @todo Implement symbols for jumps
112
 @todo Implement symbols for jumps
114
 @todo Implement write without exec
113
 @todo Implement write without exec

+ 14
- 0
shell_cmds.c View File

280
 	return 0;
280
 	return 0;
281
 }
281
 }
282
 
282
 
283
+
284
+int asmsh_cmd_step(asmsh_t *sh, asmsh_cmd_args_t *args)
285
+{
286
+	int ret, status;
287
+	ret = asmsh_env_step(sh->env, &status);
288
+
289
+	if(ret > 1)
290
+	{
291
+		return status;
292
+	}
293
+	return ret;
294
+}
295
+
296
+
283
 int asmsh_cmd_syscalls(asmsh_t *sh, asmsh_cmd_args_t *args)
297
 int asmsh_cmd_syscalls(asmsh_t *sh, asmsh_cmd_args_t *args)
284
 {
298
 {
285
 	const int sz = sizeof(syscall_infos)/sizeof(*syscall_infos);
299
 	const int sz = sizeof(syscall_infos)/sizeof(*syscall_infos);

+ 8
- 2
shell_cmds.h View File

31
 typedef struct asmsh_cmd_s asmsh_cmd_t;
31
 typedef struct asmsh_cmd_s asmsh_cmd_t;
32
 typedef struct asmsh_cmd_args_s asmsh_cmd_args_t;
32
 typedef struct asmsh_cmd_args_s asmsh_cmd_args_t;
33
 #include "shell.h"
33
 #include "shell.h"
34
+#include "asm_env.h"
34
 
35
 
35
 /** @return <0 on recoverable error 0 on ok, 1+status on exit */
36
 /** @return <0 on recoverable error 0 on ok, 1+status on exit */
36
 typedef int (asmsh_cmd_f)(asmsh_t*, asmsh_cmd_args_t*);
37
 typedef int (asmsh_cmd_f)(asmsh_t*, asmsh_cmd_args_t*);
98
 
99
 
99
 int asmsh_cmd_print_regs(asmsh_t *sh, asmsh_cmd_args_t *args);
100
 int asmsh_cmd_print_regs(asmsh_t *sh, asmsh_cmd_args_t *args);
100
 
101
 
102
+int asmsh_cmd_step(asmsh_t *sh, asmsh_cmd_args_t *args);
103
+
101
 int asmsh_cmd_syscalls(asmsh_t *sh, asmsh_cmd_args_t *args);
104
 int asmsh_cmd_syscalls(asmsh_t *sh, asmsh_cmd_args_t *args);
102
 
105
 
103
 // Reset the shell (restart the child etc)a
106
 // Reset the shell (restart the child etc)a
131
 	{".regs", asmsh_cmd_print_regs, 1,
134
 	{".regs", asmsh_cmd_print_regs, 1,
132
 	".(regs)", "",
135
 	".(regs)", "",
133
 	"display registers value"},
136
 	"display registers value"},
134
-	{".syscalls", asmsh_cmd_syscalls, 2,
135
-	 ".s(yscalls)", "",
137
+	{".step", asmsh_cmd_step, 2,
138
+	 ".s(tep)", "",
139
+	 "Run the instruction pointed by RIP"},
140
+	{".syscalls", asmsh_cmd_syscalls, 4,
141
+	 ".sys(calls)", "",
136
 	 "print syscalls name & numbers"},
142
 	 "print syscalls name & numbers"},
137
 	{".reset", asmsh_cmd_reset, 0,
143
 	{".reset", asmsh_cmd_reset, 0,
138
 	 ".reset", "",
144
 	 ".reset", "",

Loading…
Cancel
Save