rizin/subprojects/rzgdb/include/gdbclient/commands.h
Dean 59b38e6efa
Add /*<type>*/ comments everywhere (#2986)
Adds /*<type>*/ comments and a linter check from rz-bindgen to enforce
their existence and consistency

Also includes the following fixes made when adding the annotations:
* removed unused intern_table arguments in pyc_dis.c, pyc_dis.h, asm_pyc.c
* removed unused classes argument from place_nodes in agraph.c
* removed unused recurse and recurse_bb functions in canalysis.c
* removed unused vars field from RzPrint struct
* removed unused RzAnalysisType* structs from rz_analysis.h
* removed unused list field from RzEgg struct
* fixed bug in bp_plugin.c where duplication-checking logic iterates over the wrong list
* removed unused q_regs field from RzDebug struct
* removed unused backtrace field from RzDebugPlugin struct
* removed unused classes_list field from RzBinNXOObj struct
* removed unused methods_list and classes_list fields from RzBinZimgObj struct
2022-09-11 13:04:53 +08:00

157 lines
5.1 KiB
C

// SPDX-FileCopyrightText: 2014 defragger <rlaemmert@gmail.com>
// SPDX-License-Identifier: LGPL-3.0-only
#ifndef CLIENT_COMMANDS_H
#define CLIENT_COMMANDS_H
#include "../libgdbr.h"
#include "rz_types_base.h"
#include <rz_util.h>
/*!
* \brief Acquires the gdbr lock and sets up breaking
* \returns true on success, false on failure
*/
bool gdbr_lock_enter(libgdbr_t *g);
/*!
* \brief Releases the gdbr lock
*/
void gdbr_lock_leave(libgdbr_t *g);
/*!
* \brief Function connects to a gdbserver instance
* \param server string that represents the host
* \param number that represents the port
* \returns a failure code (currently -1) or 0 if call successfully
*/
int gdbr_connect(libgdbr_t *g, const char *server, int port);
/*!
* \brief disconnects the lib
* \returns a failure code (currently -1) or 0 if call successfully
*/
int gdbr_disconnect(libgdbr_t *g);
/*!
* \brief invalidates the reg cache
*/
void gdbr_invalidate_reg_cache(void);
/*!
* \brief gets reason why remote target stopped
*/
int gdbr_stop_reason(libgdbr_t *g);
/*!
* \brief checks for extended mode availability
* \returns a failure code (currently -1) or 0 if call successfully
*/
int gdbr_check_extended_mode(libgdbr_t *g);
/*!
* \brief checks which subcommands of the vCont packet are supported
*/
int gdbr_check_vcont(libgdbr_t *g);
/*!
* \brief sends a qRcmd packet which basically passes a command to the
* remote target's interpreter.
* \returns 0 on success and -1 on failure
*/
int gdbr_send_qRcmd(libgdbr_t *g, const char *cmd, PrintfCallback cb_printf);
/*!
* \brief attaches to a process
* \param pid of the process to attach to
* \returns a failure code (currently -1) or 0 if call successfully
*/
int gdbr_attach(libgdbr_t *g, int pid);
/*!
* \brief detaches from a process
* \param pid of the process to detach from (only the multiprocess/pid variant)
* \returns a failure code (currently -1) or 0 if call successfully
*/
int gdbr_detach(libgdbr_t *g);
int gdbr_detach_pid(libgdbr_t *g, int pid);
/*!
* \brief kills the process the remote gdbserver is debugging (TODO: handle pid)
* \param pid of the process to detach from (only the multiprocess/pid variant)
* \retuns a failure code (currently -1) or 0 if call successfully
*/
int gdbr_kill(libgdbr_t *g);
int gdbr_kill_pid(libgdbr_t *g, int pid);
// Commands
int gdbr_continue(libgdbr_t *g, int pid, int tid, int sig);
int gdbr_step(libgdbr_t *g, int thread_id);
int gdbr_read_registers(libgdbr_t *g);
/*!
* \brief Function writes general purpose registers
* \param gdbr instance that contains the current context
* \param reg contains the registers that should be written
* reg contains a comma separated string that uses <regname>=value,<regname>=value
* i.e. eax=0x123,ebx=0x234
* \returns a failurre code (currently -1) or 0 if call successfully
*/
int gdbr_write_bin_registers(libgdbr_t *g, const char *regs, int len);
int gdbr_write_reg(libgdbr_t *g, const char *name, char *value, int len);
int gdbr_write_register(libgdbr_t *g, int index, char *value, int len);
int gdbr_write_registers(libgdbr_t *g, char *registers);
int gdbr_read_memory(libgdbr_t *g, ut64 address, ut8 *buf, int len);
int gdbr_write_memory(libgdbr_t *g, ut64 address, const uint8_t *data, ut64 len);
int test_command(libgdbr_t *g, const char *command);
/*!
* \brief Function sets normal breakpoint (0xcc, int3)
* \param gdbr instance that contains the current context
* \param addrress at this position the breakpoint will be added
* \param conditions TODO: examine how this condition string should look like
* \returns a failure code (currently -1) or 0 if call successfully
*/
int gdbr_set_bp(libgdbr_t *g, ut64 address, const char *conditions, int sizebp);
int gdbr_set_hwbp(libgdbr_t *g, ut64 address, const char *conditions, int sizebp);
int gdbr_set_hww(libgdbr_t *g, ut64 address, const char *conditions, int sizebp);
int gdbr_set_hwr(libgdbr_t *g, ut64 address, const char *conditions, int sizebp);
int gdbr_set_hwa(libgdbr_t *g, ut64 address, const char *conditions, int sizebp);
int gdbr_remove_bp(libgdbr_t *g, ut64 address, int sizebp);
int gdbr_remove_hwbp(libgdbr_t *g, ut64 address, int sizebp);
int gdbr_remove_hww(libgdbr_t *g, ut64 address, int sizebp);
int gdbr_remove_hwr(libgdbr_t *g, ut64 address, int sizebp);
int gdbr_remove_hwa(libgdbr_t *g, ut64 address, int sizebp);
/*!
* File read from remote target (only one file open at a time for now)
*/
int gdbr_open_file(libgdbr_t *g, const char *filename, int flags, int mode);
int gdbr_read_file(libgdbr_t *g, ut8 *buf, ut64 max_len);
int gdbr_close_file(libgdbr_t *g);
/*!
* \brief get list of threads for given pid
*/
RzList /*<RzDebugPid *>*/ *gdbr_threads_list(libgdbr_t *g, int pid);
/*!
* \brief get a list of the child processes of the given pid
*/
RzList /*<RzDebugPid *>*/ *gdbr_pids_list(libgdbr_t *g, int pid);
/*!
* Get absolute name of file executed to create a process
*/
char *gdbr_exec_file_read(libgdbr_t *g, int pid);
/*!
* Get offset of lowest segment returned by 'qOffsets'
*/
ut64 gdbr_get_baddr(libgdbr_t *g);
/*!
* Select pid-tid
*/
int gdbr_select(libgdbr_t *g, int pid, int tid);
#endif // CLIENT_COMMANDS_H