Skip to content

Commit

Permalink
Add helper functions to use gdb reverse-next.
Browse files Browse the repository at this point in the history
On my machine, gdb reverse-next does not work with memcpy and memset.
Add naive implementation of those functions to override.
  • Loading branch information
matz committed Jun 15, 2017
1 parent b979226 commit bb1bfaa
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions include/mruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,33 @@ MRB_API void mrb_show_copyright(mrb_state *mrb);

MRB_API mrb_value mrb_format(mrb_state *mrb, const char *format, ...);

#if 0
/* memcpy and memset does not work with gdb reverse-next on my box */
/* use naive memcpy and memset instead */
#undef memcpy
#undef memset
static inline void*
mrbmemcpy(void *dst, const void *src, size_t n)
{
char *d = dst;
const char *s = src;
while (n--)
*d++ = *s++;
return d;
}
#define memcpy(a,b,c) mrbmemcpy(a,b,c)

static inline void*
mrbmemset(void *s, int c, size_t n)
{
char *t = s;
while (n--)
*t++ = c;
return s;
}
#define memset(a,b,c) mrbmemset(a,b,c)
#endif

MRB_END_DECL

#endif /* MRUBY_H */

0 comments on commit bb1bfaa

Please sign in to comment.