38 value->
buf = offset_ptr;
54 if (addr < parent_value->res.addr
59 value->
buf = parent_value->
buf + (addr - parent_value->
res.
addr);
82 if (!(value = malloc(
sizeof(
struct value))))
84 memset(value,0,
sizeof(
struct value));
92 value->
buf = malloc(len);
113 if (!(value = malloc(
sizeof(
struct value))))
115 memset(value,0,
sizeof(
struct value));
122 vwarn(
"value without thread being created; BUG!\n");
128 value->
buf = malloc(len);
146 RHOLD(lsymbol,value);
170 if (!(value = malloc(
sizeof(
struct value))))
172 memset(value,0,
sizeof(
struct value));
186 RHOLD(lsymbol,value);
196 struct value *out = (
struct value *)calloc(1,
sizeof(*out));
276 vwarn(
"value no longer associated with a thread!\n");
277 errno = EADDRNOTAVAIL;
281 vwarn(
"value thread no longer associated with a target!\n");
282 errno = EADDRNOTAVAIL;
286 vwarn(
"value has a parent and you did not force recursive!\n");
300 verror(
"could not read reg %d in target %s!\n",
304 memcpy(value->
buf,®val,value->
bufsiz);
308 (
unsigned char *)value->
buf)) {
321 char **old_buf,
int *old_bufsiz,
value_hash_t *old_vhash) {
322 verror(
"not supported yet!\n");
327 signed char v_c(
struct value *v) {
return *((
signed char *)v->
buf); }
328 unsigned char v_uc(
struct value *v) {
return *((
unsigned char *)v->
buf); }
339 if (v->
bufsiz == (
signed)
sizeof(int64_t))
341 else if (v->
bufsiz == (
signed)
sizeof(int32_t))
343 else if (v->
bufsiz == (
signed)
sizeof(int16_t))
345 else if (v->
bufsiz == (
signed)
sizeof(int8_t))
354 if (v->
bufsiz == (
signed)
sizeof(uint64_t))
356 else if (v->
bufsiz == (
signed)
sizeof(uint32_t))
358 else if (v->
bufsiz == (
signed)
sizeof(uint16_t))
360 else if (v->
bufsiz == (
signed)
sizeof(uint8_t))
379 else if (bufsiz > value->
bufsiz) {
384 memcpy(value->
buf,buf,bufsiz);
394 else if (bufsiz > value->
bufsiz) {
399 memcpy(value->
buf,buf,bufsiz);
401 if (bufsiz < value->bufsiz)
402 memset(value->
buf + bufsiz,0,value->
bufsiz - bufsiz);
408 if ((
signed)
sizeof(
signed char) > value->
bufsiz) {
412 memcpy(value->
buf,&v,
sizeof(
signed char));
416 if ((
signed)
sizeof(
signed char) > value->
bufsiz) {
420 memcpy(value->
buf,&v,
sizeof(
signed char));
424 if ((
signed)
sizeof(
signed char) > value->
bufsiz) {
428 memcpy(value->
buf,&v,
sizeof(
signed char));
432 if ((
signed)
sizeof(uint8_t) > value->
bufsiz) {
436 memcpy(value->
buf,&v,
sizeof(uint8_t));
440 if ((
signed)
sizeof(uint16_t) > value->
bufsiz) {
444 memcpy(value->
buf,&v,
sizeof(uint16_t));
448 if ((
signed)
sizeof(uint32_t) > value->
bufsiz) {
452 memcpy(value->
buf,&v,
sizeof(uint32_t));
456 if ((
signed)
sizeof(uint64_t) > value->
bufsiz) {
460 memcpy(value->
buf,&v,
sizeof(uint64_t));
464 if ((
signed)
sizeof(int8_t) > value->
bufsiz) {
468 memcpy(value->
buf,&v,
sizeof(int8_t));
472 if ((
signed)
sizeof(int16_t) > value->
bufsiz) {
476 memcpy(value->
buf,&v,
sizeof(int16_t));
480 if ((
signed)
sizeof(int32_t) > value->
bufsiz) {
484 memcpy(value->
buf,&v,
sizeof(int32_t));
488 if ((
signed)
sizeof(int64_t) > value->
bufsiz) {
492 memcpy(value->
buf,&v,
sizeof(int64_t));
496 if ((
signed)
sizeof(
float) > value->
bufsiz) {
500 memcpy(value->
buf,&v,
sizeof(
float));
504 if ((
signed)
sizeof(
double) > value->
bufsiz) {
508 memcpy(value->
buf,&v,
sizeof(
double));
512 if ((
signed)
sizeof(
long double) > value->
bufsiz) {
516 memcpy(value->
buf,&v,
sizeof(
long double));
524 memcpy(value->
buf,&v,
sizeof(
ADDR));
529 if (value->
bufsiz == (
signed)
sizeof(int64_t))
531 else if (value->
bufsiz == (
signed)
sizeof(int32_t))
533 else if (value->
bufsiz == (
signed)
sizeof(int16_t))
535 else if (value->
bufsiz == (
signed)
sizeof(int8_t))
544 if (value->
bufsiz == (
signed)
sizeof(uint64_t))
546 else if (value->
bufsiz == (
signed)
sizeof(uint32_t))
548 else if (value->
bufsiz == (
signed)
sizeof(uint16_t))
550 else if (value->
bufsiz == (
signed)
sizeof(uint8_t))
559 static inline int __d2hs(
char *buf,
unsigned int len,
char *str) {
566 hi = (buf[i] >> 4) & 0xf;
568 if (lo <= 9) str[i*2+1] =
'0' + lo;
569 else str[i*2+1] =
'a' + (lo - 10);
571 if (hi <= 9) str[i*2] =
'0' + hi;
572 else str[i*2] =
'a' + (hi - 10);
584 struct value fake_value;
603 _trc = snprintf(buf,buflen - nrc,"<"msg"::"); \
607 _trc = ((value->bufsiz * 2) > (buflen - nrc - 1)) \
608 ? (buflen - nrc - 1) / 2 : value->bufsiz; \
609 __d2hs(value->buf,_trc,buf + nrc); \
611 if (nrc < (buflen - 1)) { \
615 else if (nrc < buflen) \
618 buf[buflen - 1] = '\0'; \
621 #define VSBPA(msg,...) \
624 _trc = snprintf(buf,buflen - nrc,"<"msg"::", ## __VA_ARGS__); \
628 _trc = ((value->bufsiz * 2) > (buflen - nrc - 1)) \
629 ? (buflen - nrc - 1) / 2 : value->bufsiz; \
630 __d2hs(value->buf,_trc,buf + nrc); \
632 if (nrc < (buflen - 1)) { \
636 else if (nrc < buflen) \
639 buf[buflen - 1] = '\0'; \
646 for (j = 0; j < value->
bufsiz && value->
buf[j] !=
'\0'; ++j) {
647 if (!isgraph(value->
buf[j]) && !isspace(value->
buf[j])) {
653 VSBP(
"BINARY_STRING");
656 nrc = snprintf(buf,buflen,
"\"%s\"",value->
buf);
671 nrc = snprintf(buf,buflen,
"%"PRIx8,
v_u8(value));
672 else if (tbytesize == 2)
673 nrc = snprintf(buf,buflen,
"%"PRIx16,
v_u16(value));
674 else if (tbytesize == 4)
675 nrc = snprintf(buf,buflen,
"%"PRIx32,
v_u32(value));
676 else if (tbytesize == 8)
677 nrc = snprintf(buf,buflen,
"%"PRIx64,
v_u64(value));
679 VSBPA(
"UNSUP_ENC_%d",enc);
684 nrc = snprintf(buf,buflen,
"%"PRIu8,
v_u8(value));
685 else if (tbytesize == 2)
686 nrc = snprintf(buf,buflen,
"%"PRIu16,
v_u16(value));
687 else if (tbytesize == 4)
688 nrc = snprintf(buf,buflen,
"%"PRIu32,
v_u32(value));
689 else if (tbytesize == 8)
690 nrc = snprintf(buf,buflen,
"%"PRIu64,
v_u64(value));
692 VSBPA(
"UNSUP_ENC_%d",enc);
696 nrc = snprintf(buf,buflen,
"%"PRIi8,
v_i8(value));
697 else if (tbytesize == 2)
698 nrc = snprintf(buf,buflen,
"%"PRIi16,
v_i16(value));
699 else if (tbytesize == 4)
700 nrc = snprintf(buf,buflen,
"%"PRIi32,
v_i32(value));
701 else if (tbytesize == 8)
702 nrc = snprintf(buf,buflen,
"%"PRIi64,
v_i64(value));
704 VSBPA(
"UNSUP_ENC_%d",enc);
708 nrc = snprintf(buf,buflen,
"%f",(
double)
v_f(value));
709 else if (tbytesize == 8)
710 nrc = snprintf(buf,buflen,
"%f",
v_d(value));
711 else if (tbytesize == 16)
712 nrc = snprintf(buf,buflen,
"%Lf",
v_dd(value));
714 VSBPA(
"UNSUP_ENC_%d",enc);
719 nrc = snprintf(buf,buflen,
"%c",(
int)
v_c(value));
720 else if (tbytesize == 2)
721 nrc = snprintf(buf,buflen,
"%lc",(wint_t)
v_wc(value));
723 VSBPA(
"UNSUP_ENC_%d",enc);
726 VSBPA(
"UNSUP_ENC_%d",enc);
729 VSBPA(
"UNSUP_ENC_%d",enc);
732 VSBPA(
"UNSUP_ENC_%d",enc);
735 VSBPA(
"UNSUP_ENC_%d",enc);
738 VSBPA(
"UNSUP_ENC_%d",enc);
741 VSBPA(
"UNSUP_ENC_%d",enc);
744 VSBPA(
"UNSUP_ENC_%d",enc);
747 VSBPA(
"UNSUP_ENC_%d",enc);
752 nrc = snprintf(buf,buflen,
"0x%"PRIx32,
v_u32(value));
753 else if (tbytesize == 8)
754 nrc = snprintf(buf,buflen,
"0x%"PRIx64,
v_u64(value));
765 nrc = snprintf(buf,buflen,
"[ ]");
769 llen = g_slist_length(subranges);
770 subrange_first = (int)(uintptr_t)g_slist_nth_data(subranges,0);
778 nrc = snprintf(buf,buflen,
"\"%.*s\"",subrange_first,value->
buf);
784 indicies = malloc(
sizeof(
int)*llen);
785 for (i = 0; i < llen; ++i) {
787 nrc += snprintf(buf + nrc,buflen - nrc,
"[ ");
790 fake_value.
buf = value->
buf;
791 fake_value.
type = datatype2;
796 nrc += snprintf(buf + nrc,buflen - nrc,
", ");
802 for (j = llen - 1; j > -1; --j) {
804 subrange = (int)(uintptr_t)g_slist_nth_data(subranges,j);
806 if (indicies[j] >= subrange) {
807 nrc += snprintf(buf + nrc,buflen - nrc,
" ],");
818 if (indicies[0] >= subrange_first)
821 for ( ; j < llen; ++j)
822 nrc += snprintf(buf + nrc,buflen - nrc,
" [ ");
830 nrc = snprintf(buf,buflen,
"{");
834 nrc += snprintf(buf + nrc,buflen - nrc,
837 nrc += snprintf(buf + nrc,buflen - nrc,
" ");
838 memset(&tloc,0,
sizeof(tloc));
841 nrc += snprintf(buf + nrc,buflen - nrc,
"?,");
850 nrc += snprintf(buf + nrc,buflen - nrc,
",");
854 nrc += snprintf(buf + nrc,buflen - nrc,
" }");
864 if (strncmp((
char *)constval,value->
buf,
866 nrc += snprintf(buf + nrc,buflen - nrc,
873 nrc += snprintf(buf + nrc,buflen - nrc,
"%"PRIuNUM" (0x%"PRIxNUM")",
889 nrc = snprintf(buf,buflen,
"NULL");
902 struct value fake_value;
931 else if (tbytesize == 2)
933 else if (tbytesize == 4)
935 else if (tbytesize == 8)
938 fprintf(ud->
stream,
"<UNSUPPORTED_BYTESIZE_%d>",tbytesize);
944 else if (tbytesize == 2)
946 else if (tbytesize == 4)
948 else if (tbytesize == 8)
951 fprintf(ud->
stream,
"<UNSUPPORTED_BYTESIZE_%d>",tbytesize);
956 else if (tbytesize == 2)
958 else if (tbytesize == 4)
960 else if (tbytesize == 8)
963 fprintf(ud->
stream,
"<UNSUPPORTED_BYTESIZE_%d>",tbytesize);
967 fprintf(ud->
stream,
"%f",(
double)
v_f(value));
968 else if (tbytesize == 8)
970 else if (tbytesize == 16)
973 fprintf(ud->
stream,
"<UNSUPPORTED_BYTESIZE_%d>",tbytesize);
978 fprintf(ud->
stream,
"%c",(
int)
v_c(value));
979 else if (tbytesize == 2)
980 fprintf(ud->
stream,
"%lc",(wint_t)
v_wc(value));
982 fprintf(ud->
stream,
"<UNSUPPORTED_BYTESIZE_%d>",tbytesize);
985 fprintf(ud->
stream,
"<UNSUPPORTED_COMPLEX_FLOAT_%d>",
989 fprintf(ud->
stream,
"<UNSUPPORTED_IMAGINARY_FLOAT_%d>",
993 fprintf(ud->
stream,
"<UNSUPPORTED_PACKED_DECIMAL_%d>",
997 fprintf(ud->
stream,
"<UNSUPPORTED_NUMERIC_STRING_%d>",
1001 fprintf(ud->
stream,
"<UNSUPPORTED_EDITED_%d>",
1005 fprintf(ud->
stream,
"<UNSUPPORTED_SIGNED_FIXED_%d>",
1009 fprintf(ud->
stream,
"<UNSUPPORTED_UNSIGNED_FIXED_%d>",
1016 else if (tbytesize == 8)
1019 fprintf(ud->
stream,
"<UNSUPPORTED_PTR_%d>",tbytesize);
1028 fprintf(ud->
stream,
"[ ]");
1032 subrange_first = (int)(uintptr_t)g_slist_nth_data(subranges,0);
1033 llen = g_slist_length(subranges);
1041 fprintf(ud->
stream,
"\"%.*s\"",subrange_first,value->
buf);
1046 indicies = malloc(
sizeof(
int)*llen);
1047 for (i = 0; i < llen; ++i) {
1049 fprintf(ud->
stream,
"[ ");
1052 fake_value.
buf = value->
buf;
1053 fake_value.
type = datatype2;
1057 fprintf(ud->
stream,
", ");
1063 for (j = llen - 1; j > -1; --j) {
1066 subrange = (int)(uintptr_t)g_slist_nth_data(subranges,j);
1067 if (indicies[j] >= subrange) {
1068 fprintf(ud->
stream,
" ],");
1079 if (indicies[0] >= subrange_first)
1082 for ( ; j < llen; ++j)
1083 fprintf(ud->
stream,
" [ ");
1097 memset(&tloc,0,
sizeof(tloc));
1113 fprintf(ud->
stream,
" }");
1122 if (strncmp((
char *)constval,value->
buf,
1140 fprintf(ud->
stream,
"<UNSUPPORTED_TYPEDEF_%s>",
1144 fprintf(ud->
stream,
"<UNSUPPORTED_FUNCTION_%s>",
1148 fprintf(ud->
stream,
"NULL");
1173 np = malloc(strlen(p) + 1 + 2);
1174 sprintf(np,
"%s%s",p,
" ");
1186 for (i = 0; i < alen; ++i) {
1205 signed char rv_c(
void *buf) {
return *((
signed char *)buf); }
1206 unsigned char rv_uc(
void *buf) {
return *((
unsigned char *)buf); }
1207 wchar_t rv_wc(
void *buf) {
return *((
wchar_t *)buf); }
1208 uint8_t
rv_u8(
void *buf) {
return *((uint8_t *)buf); }
1209 uint16_t
rv_u16(
void *buf) {
return *((uint16_t *)buf); }
1210 uint32_t
rv_u32(
void *buf) {
return *((uint32_t *)buf); }
1211 uint64_t
rv_u64(
void *buf) {
return *((uint64_t *)buf); }
1212 int8_t
rv_i8(
void *buf) {
return *((int8_t *)buf); }
1213 int16_t
rv_i16(
void *buf) {
return *((int16_t *)buf); }
1214 int32_t
rv_i32(
void *buf) {
return *((int32_t *)buf); }
1215 int64_t
rv_i64(
void *buf) {
return *((int64_t *)buf); }
1216 float rv_f(
void *buf) {
return *((
float *)buf); }
1217 double rv_d(
void *buf) {
return *((
double *)buf); }
1218 long double rv_dd(
void *buf) {
return *((
long double *)buf); }
uint16_t rv_u16(void *buf)
struct value * value_create_noalloc(struct target_thread *thread, struct memrange *range, struct lsymbol *lsymbol, struct symbol *type)
int16_t v_i16(struct value *v)
int value_update_i16(struct value *value, int16_t v)
#define SYMBOLX_SUBRANGES(sym)
int value_snprintf(struct value *value, char *buf, int buflen)
int value_update_i32(struct value *value, int32_t v)
void value_set_strlen(struct value *value, int len)
int value_update_f(struct value *value, float v)
void value_dump_simple(struct value *value, struct dump_info *ud)
int8_t v_i8(struct value *v)
#define SYMBOLX_MEMBERS(sym)
#define v_g_slist_foreach(gslhead, gslcur, elm)
void location_internal_free(struct location *location)
long double v_dd(struct value *v)
void __value_dump(struct value *value, struct dump_info *ud)
void value_dump(struct value *value, struct dump_info *ud)
int64_t v_i64(struct value *v)
struct target_thread * global_thread
uint32_t symbol_get_bytesize(struct symbol *symbol)
int value_update_addr(struct value *value, ADDR v)
int value_update_num(struct value *value, num_t v)
int value_update(struct value *value, const char *buf, int bufsiz)
signed char rv_c(void *buf)
struct target_thread * thread
#define verror(format,...)
unsigned char * target_read_addr(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
struct symbol * symbol_get_datatype(struct symbol *symbol)
wchar_t v_wc(struct value *v)
loctype_t symbol_resolve_location(struct symbol *symbol, struct location_ctxt *lctxt, struct location *o_loc)
#define vwarn(format,...)
int value_set_mmap(struct value *value, ADDR addr, struct memcache_mmap_entry *mme, char *offset_ptr)
int symbol_type_is_char(struct symbol *type)
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
int value_refresh_diff(struct value *value, int recurse, value_diff_t *vdiff, char **old_buf, int *old_bufsiz, value_hash_t *old_vhash)
unsigned char v_uc(struct value *v)
#define LOCATION_OFFSET(loc)
int value_update_c(struct value *value, signed char v)
long double rv_dd(void *buf)
int value_update_u8(struct value *value, uint8_t v)
datatype_code_t datatype_code
struct value * value_create_raw(struct target *target, struct target_thread *thread, struct memrange *range, int len)
int value_update_i64(struct value *value, int64_t v)
int value_refresh(struct value *value, int recursive)
int value_update_dd(struct value *value, long double v)
int value_set_child(struct value *value, struct value *parent_value, ADDR addr)
#define SYMBOLX_ENCODING_V(sym)
int value_update_wc(struct value *value, wchar_t v)
struct value * parent_value
int value_update_uc(struct value *value, unsigned char v)
int value_update_i8(struct value *value, int8_t v)
struct value * value_create_type(struct target_thread *thread, struct memrange *range, struct symbol *type)
void value_free(struct value *value)
unsigned char rv_uc(void *buf)
struct value * value_clone(struct value *in)
int value_update_u16(struct value *value, uint16_t v)
REGVAL target_read_creg(struct target *target, tid_t tid, common_reg_t reg)
int value_set_addr(struct value *value, ADDR addr)
ADDR v_addr(struct value *v)
struct symbol * symbol_type_skip_qualifiers(struct symbol *type)
struct memregion * region
num_t v_num(struct value *v)
struct value * value_create(struct target_thread *thread, struct memrange *range, struct lsymbol *lsymbol, struct symbol *type)
int value_set_reg(struct value *value, REG reg)
int value_update_unum(struct value *value, unum_t v)
double v_d(struct value *v)
int16_t rv_i16(void *buf)
uint32_t rv_u32(void *buf)
int64_t rv_i64(void *buf)
unsigned int symbol_type_full_bytesize(struct symbol *type)
char * v_string(struct value *v)
uint16_t v_u16(struct value *v)
uint64_t v_u64(struct value *v)
#define SYMBOLX_VAR_CONSTVAL(sym)
uint64_t rv_u64(void *buf)
int value_update_u64(struct value *value, uint64_t v)
int32_t rv_i32(void *buf)
int32_t v_i32(struct value *v)
uint8_t v_u8(struct value *v)
signed char v_c(struct value *v)
int value_update_u32(struct value *value, uint32_t v)
char * symbol_get_name(struct symbol *symbol)
#define RPUT(x, objtype, hx, rc)
int value_update_zero(struct value *value, const char *buf, int bufsiz)
struct array_list * chain
uint32_t v_u32(struct value *v)
void value_set_const(struct value *value)
float v_f(struct value *v)
unum_t v_unum(struct value *v)
ADDR value_addr(struct value *value)
int value_update_d(struct value *value, double v)