xdebug

next generation of mdebug (work in progress)
git clone http://frotz.net/git/xdebug.git
Log | Files | Refs | README

xdebug.h (1490B)


      1 // Copyright 2023, Brian Swetland <swetland@frotz.net>
      2 // Licensed under the Apache License, Version 2.0.
      3 
      4 #pragma once
      5 
      6 #include <stdint.h>
      7 #include <stdarg.h>
      8 #include <stddef.h>
      9 
     10 void MSG(uint32_t flags, const char* fmt, ...)
     11 	__attribute__ ((format (printf, 2, 3)));
     12 
     13 #define mINFO 1
     14 #define mDEBUG 2
     15 #define mTRACE 3
     16 #define mERROR 4
     17 #define mPANIC 5 
     18 
     19 #define DEBUG(fmt...) MSG(mDEBUG, fmt)
     20 #define INFO(fmt...) MSG(mINFO, fmt)
     21 #define TRACE(fmt...) MSG(mTRACE, fmt)
     22 #define ERROR(fmt...) MSG(mERROR, fmt)
     23 #define PANIC(fmt...) MSG(mPANIC, fmt)
     24 
     25 #define DBG_OK 0
     26 #define DBG_ERR -1
     27 
     28 typedef struct command_context CC;
     29 const char* cmd_name(CC* cc);
     30 int cmd_arg_u32(CC* cc, unsigned nth, uint32_t* out);
     31 int cmd_arg_u32_opt(CC* cc, unsigned nth, uint32_t* out, uint32_t val);
     32 int cmd_arg_str(CC* cc, unsigned nth, const char** out);
     33 int cmd_arg_str_opt(CC* cc, unsigned nth, const char** out, const char* str);
     34 int cmd_argc(CC* cc);
     35 
     36 typedef struct debug_context DC;
     37 void debugger_command(DC* dc, CC* cc);
     38 void debugger_exit(void);
     39 
     40 // commands.c
     41 int do_help(DC* dc, CC* cc);
     42 int do_attach(DC* dc, CC* cc);
     43 int do_reset_stop(DC* dc, CC* cc);
     44 
     45 // commands-file.c
     46 int do_upload(DC* dc, CC* cc);
     47 int do_download(DC* dc, CC* cc);
     48 
     49 // commands-agent.c
     50 int do_setarch(DC* dc, CC* cc);
     51 int do_flash(DC* dc, CC* cc);
     52 int do_erase(DC* dc, CC* cc);
     53 
     54 void *load_file(const char* fn, size_t *sz);
     55 void *get_builtin_file(const char *name, size_t *sz);
     56 const char *get_builtin_filename(unsigned n);
     57