Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
value.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, 2012, 2013, 2014, 2015 The University of Utah
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #include <glib.h>
20 
21 #include "glib_wrapper.h"
22 #include "target_api.h"
23 #include "target.h"
24 #include "memcache.h"
25 #include "dwdebug.h"
26 #include "dwdebug_priv.h"
27 
28 int value_set_addr(struct value *value,ADDR addr) {
29  value->res.addr = addr;
30  value->res_ip = target_read_creg(value->thread->target,value->thread->tid,
31  CREG_IP);
32  return 0;
33 }
34 
35 int value_set_mmap(struct value *value,ADDR addr,struct memcache_mmap_entry *mme,
36  char *offset_ptr) {
37  value->ismmap = 1;
38  value->buf = offset_ptr;
39  value->res.addr = addr;
40  value->res_ip = target_read_creg(value->thread->target,value->thread->tid,
41  CREG_IP);
42  return 0;
43 }
44 
45 int value_set_reg(struct value *value,REG reg) {
46  value->isreg = 1;
47  value->res.reg = reg;
48  value->res_ip = target_read_creg(value->thread->target,value->thread->tid,
49  CREG_IP);
50  return 0;
51 }
52 
53 int value_set_child(struct value *value,struct value *parent_value,ADDR addr) {
54  if (addr < parent_value->res.addr
55  || addr >= (parent_value->res.addr + parent_value->bufsiz))
56  return -1;
57 
58  value->parent_value = parent_value;
59  value->buf = parent_value->buf + (addr - parent_value->res.addr);
60  value->res.addr = addr;
61  value->range = parent_value->range;
62  value->res_ip = target_read_creg(value->thread->target,value->thread->tid,
63  CREG_IP);
64 
65  return 0;
66 }
67 
68 void value_set_strlen(struct value *value,int len) {
69  value->bufsiz = len;
70  value->isstring = 1;
71 }
72 
73 void value_set_const(struct value *value) {
74  value->isconst = 1;
75 }
76 
78  struct target_thread *tthread,
79  struct memrange *range,int len) {
80  struct value *value;
81 
82  if (!(value = malloc(sizeof(struct value))))
83  return NULL;
84  memset(value,0,sizeof(struct value));
85 
86  if (tthread)
87  value->thread = tthread;
88  else
89  value->thread = target->global_thread;
90  value->range = range;
91 
92  value->buf = malloc(len);
93  if (!value->buf) {
94  free(value);
95  return NULL;
96  }
97  value->bufsiz = len;
98 
99  return value;
100 }
101 
103  struct memrange *range,struct symbol *type) {
104  struct value *value;
105  int len = symbol_type_full_bytesize(type);
106 
107  if (len < 1) {
108  verror("type %s (ref 0x%"PRIxSMOFFSET") had 0-byte size!\n",
109  type->name,type->ref);
110  return NULL;
111  }
112 
113  if (!(value = malloc(sizeof(struct value))))
114  return NULL;
115  memset(value,0,sizeof(struct value));
116 
117  if (thread)
118  value->thread = thread;
119  else if (range)
120  value->thread = range->region->space->target->global_thread;
121  else
122  vwarn("value without thread being created; BUG!\n");
123  value->range = range;
124 
125  RHOLD(type,value);
126  value->type = type;
127 
128  value->buf = malloc(len);
129  if (!value->buf) {
130  free(value);
131  return NULL;
132  }
133  value->bufsiz = len;
134 
135  return value;
136 }
137 
139  struct lsymbol *lsymbol,struct symbol *type) {
140  struct value *value = value_create_type(thread,range,type);
141 
142  if (!value)
143  return NULL;
144 
145  if (lsymbol) {
146  RHOLD(lsymbol,value);
147  value->lsymbol = lsymbol;
148  }
149 
150  return value;
151 }
152 
154  struct memrange *range,
155  struct lsymbol *lsymbol,struct symbol *type) {
156  struct value *value;
157  int len = symbol_type_full_bytesize(type);
158 
159  /*
160  * NB: don't check this because we want to create NULL values sometimes!
161  */
162 #if 0
163  if (len < 1) {
164  verror("type %s (ref 0x%"PRIxSMOFFSET") had 0-byte size!\n",
165  type->name,type->ref);
166  return NULL;
167  }
168 #endif
169 
170  if (!(value = malloc(sizeof(struct value))))
171  return NULL;
172  memset(value,0,sizeof(struct value));
173 
174  if (thread)
175  value->thread = thread;
176  else
177  value->thread = thread->target->global_thread;
178  value->range = range;
179 
180  if (type) {
181  RHOLD(type,value);
182  value->type = type;
183  }
184 
185  if (lsymbol) {
186  RHOLD(lsymbol,value);
187  value->lsymbol = lsymbol;
188  }
189 
190  value->bufsiz = len;
191 
192  return value;
193 }
194 
195 struct value *value_clone(struct value *in) {
196  struct value *out = (struct value *)calloc(1,sizeof(*out));
197  if (!out)
198  return NULL;
199 
200  if (in->type) {
201  out->type = in->type;
202  RHOLD(out->type,out);
203  }
204  if (in->lsymbol) {
205  out->lsymbol = in->lsymbol;
206  RHOLD(out->lsymbol,out);
207  }
208  out->thread = in->thread;
209  out->range = in->range;
210  out->ismmap = in->ismmap;
211  out->isreg = in->isreg;
212  out->isstring = in->isstring;
213  out->res.addr = in->res.addr;
214  out->res.reg = in->res.reg;
215  out->res_ip = in->res_ip;
216 
217  out->buf = malloc(in->bufsiz);
218  memcpy(out->buf,in->buf,in->bufsiz);
219  out->bufsiz = in->bufsiz;
220 
221  return out;
222 }
223 
224 struct value *value_reload_as_type(struct value *in,struct symbol *type,
225  int force) {
226  struct value *out;
227  int bytesize;
228 
229  bytesize = symbol_get_bytesize(type);
230 
231  if (!force) {
232  if (bytesize < 1) {
233  errno = EINVAL;
234  return NULL;
235  }
236  else if (in->isreg
237  && bytesize > (int)in->thread->target->arch->wordsize) {
238  errno = ERANGE;
239  return NULL;
240  }
241  else if (in->isconst && bytesize > in->bufsiz) {
242  errno = ERANGE;
243  return NULL;
244  }
245  }
246 
247  out = (struct value *)calloc(1,sizeof(*out));
248  if (!out)
249  return NULL;
250 
251  out->type = type;
252  RHOLD(out->type,out);
253  if (in->lsymbol) {
254  out->lsymbol = in->lsymbol;
255  RHOLD(out->lsymbol,out);
256  }
257  out->thread = in->thread;
258  out->range = in->range;
259  out->ismmap = in->ismmap;
260  out->isreg = in->isreg;
261  out->isstring = in->isstring;
262  out->res.addr = in->res.addr;
263  out->res.reg = in->res.reg;
264  out->res_ip = in->res_ip;
265 
266  if (!in->isreg && !in->isconst) {
267  /* Reload with new type's size. */
268  out->buf = malloc(bytesize);
269  target_read_addr(in->thread->target,in->res.addr,bytesize,
270  (unsigned char *)out->buf);
271  out->bufsiz = bytesize;
272  }
273  else {
274  out->buf = malloc(in->bufsiz);
275  memcpy(out->buf,in->buf,in->bufsiz);
276  out->bufsiz = in->bufsiz;
277  }
278 
279  return out;
280 }
281 
282 void value_free(struct value *value) {
283  REFCNT trefcnt;
284 
285  if (value->ismmap) {
286  /*
287  * XXX: if we ever link mmaps and values, handle refcnt stuff here.
288  */
289  }
290  else if (!value->parent_value)
291  free(value->buf);
292 
293  if (value->type)
294  RPUT(value->type,symbol,value,trefcnt);
295 
296  if (value->lsymbol)
297  RPUT(value->lsymbol,lsymbol,value,trefcnt);
298 
299  free(value);
300 }
301 
303  if (value->isreg) {
304  errno = EINVAL;
305  return 0;
306  }
307 
308  return value->res.addr;
309 }
310 
311 /*
312  * Do our best to see if the value needs to be reloaded; if so, reload
313  * it.
314  *
315  * There are several ways we can do this. If we have page tracking, and
316  * we know if a page has been updated since we last saw it, we can check
317  * that. If the value is mmap'd, we can just check content if
318  * necessary. Otherwise, we have to load the value again.
319  *
320  * If the value has a parent, we can only reload the parent if
321  * @recursive is set. Ugh, don't want that, but there is no other way.
322  *
323  * Wow, there are tons of complications involved with tracking values --
324  * the thread could be gone; the value (symbol) could be out of scope;
325  * it could have been a raw address on the stack; the value (symbol)
326  * could be in scope but unavailable for load; ...
327  */
328 
329 int value_refresh(struct value *value,int recursive) {
330  struct target *target;
331  REGVAL regval;
332 
333  if (!value->thread) {
334  vwarn("value no longer associated with a thread!\n");
335  errno = EADDRNOTAVAIL;
336  return -1;
337  }
338  if (!value->thread->target) {
339  vwarn("value thread no longer associated with a target!\n");
340  errno = EADDRNOTAVAIL;
341  return -1;
342  }
343  if (value->parent_value && !recursive) {
344  vwarn("value has a parent and you did not force recursive!\n");
345  errno = EBUSY;
346  return -1;
347  }
348 
349  target = value->thread->target;
350 
351  /*
352  * For now, just do it!
353  */
354  if (value->isreg) {
355  errno = 0;
356  regval = target_read_reg(target,value->thread->tid,value->res.reg);
357  if (errno) {
358  verror("could not read reg %d in target %s!\n",
359  value->res.reg,target->name);
360  return -1;
361  }
362  memcpy(value->buf,&regval,value->bufsiz);
363  }
364  else {
365  if (!target_read_addr(target,value->res.addr,value->bufsiz,
366  (unsigned char *)value->buf)) {
367  verror("could not read 0x%"PRIxADDR" in target %s!\n",
368  value->res.addr,target->name);
369  if (!errno)
370  errno = EFAULT;
371  return -1;
372  }
373  }
374 
375  return 0;
376 }
377 
378 int value_refresh_diff(struct value *value,int recurse,value_diff_t *vdiff,
379  char **old_buf,int *old_bufsiz,value_hash_t *old_vhash) {
380  verror("not supported yet!\n");
381  errno = ENOTSUP;
382  return -1;
383 }
384 
385 signed char v_c(struct value *v) { return *((signed char *)v->buf); }
386 unsigned char v_uc(struct value *v) { return *((unsigned char *)v->buf); }
387 wchar_t v_wc(struct value *v) { return *((wchar_t *)v->buf); }
388 uint8_t v_u8(struct value *v) { return *((uint8_t *)v->buf); }
389 uint16_t v_u16(struct value *v) { return *((uint16_t *)v->buf); }
390 uint32_t v_u32(struct value *v) { return *((uint32_t *)v->buf); }
391 uint64_t v_u64(struct value *v) { return *((uint64_t *)v->buf); }
392 int8_t v_i8(struct value *v) { return *((int8_t *)v->buf); }
393 int16_t v_i16(struct value *v) { return *((int16_t *)v->buf); }
394 int32_t v_i32(struct value *v) { return *((int32_t *)v->buf); }
395 int64_t v_i64(struct value *v) { return *((int64_t *)v->buf); }
396 num_t v_num(struct value *v) {
397  if (v->bufsiz == (signed)sizeof(int64_t))
398  return v_i64(v);
399  else if (v->bufsiz == (signed)sizeof(int32_t))
400  return v_i32(v);
401  else if (v->bufsiz == (signed)sizeof(int16_t))
402  return v_i16(v);
403  else if (v->bufsiz == (signed)sizeof(int8_t))
404  return v_i8(v);
405  else {
406  errno = EINVAL;
407  return -1;
408  }
409  return 0;
410 }
411 unum_t v_unum(struct value *v){
412  if (v->bufsiz == (signed)sizeof(uint64_t))
413  return v_u64(v);
414  else if (v->bufsiz == (signed)sizeof(uint32_t))
415  return v_u32(v);
416  else if (v->bufsiz == (signed)sizeof(uint16_t))
417  return v_u16(v);
418  else if (v->bufsiz == (signed)sizeof(uint8_t))
419  return v_u8(v);
420  else {
421  errno = EINVAL;
422  return -1;
423  }
424  return 0;
425 }
426 float v_f(struct value *v) { return *((float *)v->buf); }
427 double v_d(struct value *v) { return *((double *)v->buf); }
428 long double v_dd(struct value *v) { return *((long double *)v->buf); }
429 ADDR v_addr(struct value *v){ return *((ADDR *)v->buf); }
430 char * v_string(struct value *v){ return v->buf; }
431 
432 int value_update(struct value *value,const char *buf,int bufsiz) {
433  if (bufsiz < 0) {
434  errno = EINVAL;
435  return -1;
436  }
437  else if (bufsiz > value->bufsiz) {
438  errno = EOVERFLOW;
439  return -1;
440  }
441  else if (bufsiz > 0)
442  memcpy(value->buf,buf,bufsiz);
443 
444  return 0;
445 }
446 
447 int value_update_zero(struct value *value,const char *buf,int bufsiz) {
448  if (bufsiz < 0) {
449  errno = EINVAL;
450  return -1;
451  }
452  else if (bufsiz > value->bufsiz) {
453  errno = EOVERFLOW;
454  return -1;
455  }
456  else if (bufsiz > 0)
457  memcpy(value->buf,buf,bufsiz);
458 
459  if (bufsiz < value->bufsiz)
460  memset(value->buf + bufsiz,0,value->bufsiz - bufsiz);
461 
462  return 0;
463 }
464 
465 int value_update_c(struct value *value,signed char v) {
466  if ((signed)sizeof(signed char) > value->bufsiz) {
467  errno = EOVERFLOW;
468  return -1;
469  }
470  memcpy(value->buf,&v,sizeof(signed char));
471  return 0;
472 }
473 int value_update_uc(struct value *value,unsigned char v) {
474  if ((signed)sizeof(signed char) > value->bufsiz) {
475  errno = EOVERFLOW;
476  return -1;
477  }
478  memcpy(value->buf,&v,sizeof(signed char));
479  return 0;
480 }
481 int value_update_wc(struct value *value,wchar_t v) {
482  if ((signed)sizeof(signed char) > value->bufsiz) {
483  errno = EOVERFLOW;
484  return -1;
485  }
486  memcpy(value->buf,&v,sizeof(signed char));
487  return 0;
488 }
489 int value_update_u8(struct value *value,uint8_t v) {
490  if ((signed)sizeof(uint8_t) > value->bufsiz) {
491  errno = EOVERFLOW;
492  return -1;
493  }
494  memcpy(value->buf,&v,sizeof(uint8_t));
495  return 0;
496 }
497 int value_update_u16(struct value *value,uint16_t v) {
498  if ((signed)sizeof(uint16_t) > value->bufsiz) {
499  errno = EOVERFLOW;
500  return -1;
501  }
502  memcpy(value->buf,&v,sizeof(uint16_t));
503  return 0;
504 }
505 int value_update_u32(struct value *value,uint32_t v) {
506  if ((signed)sizeof(uint32_t) > value->bufsiz) {
507  errno = EOVERFLOW;
508  return -1;
509  }
510  memcpy(value->buf,&v,sizeof(uint32_t));
511  return 0;
512 }
513 int value_update_u64(struct value *value,uint64_t v) {
514  if ((signed)sizeof(uint64_t) > value->bufsiz) {
515  errno = EOVERFLOW;
516  return -1;
517  }
518  memcpy(value->buf,&v,sizeof(uint64_t));
519  return 0;
520 }
521 int value_update_i8(struct value *value,int8_t v) {
522  if ((signed)sizeof(int8_t) > value->bufsiz) {
523  errno = EOVERFLOW;
524  return -1;
525  }
526  memcpy(value->buf,&v,sizeof(int8_t));
527  return 0;
528 }
529 int value_update_i16(struct value *value,int16_t v) {
530  if ((signed)sizeof(int16_t) > value->bufsiz) {
531  errno = EOVERFLOW;
532  return -1;
533  }
534  memcpy(value->buf,&v,sizeof(int16_t));
535  return 0;
536 }
537 int value_update_i32(struct value *value,int32_t v) {
538  if ((signed)sizeof(int32_t) > value->bufsiz) {
539  errno = EOVERFLOW;
540  return -1;
541  }
542  memcpy(value->buf,&v,sizeof(int32_t));
543  return 0;
544 }
545 int value_update_i64(struct value *value,int64_t v) {
546  if ((signed)sizeof(int64_t) > value->bufsiz) {
547  errno = EOVERFLOW;
548  return -1;
549  }
550  memcpy(value->buf,&v,sizeof(int64_t));
551  return 0;
552 }
553 int value_update_f(struct value *value,float v) {
554  if ((signed)sizeof(float) > value->bufsiz) {
555  errno = EOVERFLOW;
556  return -1;
557  }
558  memcpy(value->buf,&v,sizeof(float));
559  return 0;
560 }
561 int value_update_d(struct value *value,double v) {
562  if ((signed)sizeof(double) > value->bufsiz) {
563  errno = EOVERFLOW;
564  return -1;
565  }
566  memcpy(value->buf,&v,sizeof(double));
567  return 0;
568 }
569 int value_update_dd(struct value *value,long double v) {
570  if ((signed)sizeof(long double) > value->bufsiz) {
571  errno = EOVERFLOW;
572  return -1;
573  }
574  memcpy(value->buf,&v,sizeof(long double));
575  return 0;
576 }
578  if (value->bufsiz <= (signed)sizeof(ADDR)) {
579  memcpy(value->buf,&v,value->bufsiz);
580  }
581  else /* if (value->bufsiz > sizeof(ADDR)) */ {
582  memcpy(value->buf,&v,sizeof(ADDR));
583  }
584  return 0;
585 }
587  if (value->bufsiz == (signed)sizeof(int64_t))
588  return value_update_i64(value,v);
589  else if (value->bufsiz == (signed)sizeof(int32_t))
590  return value_update_i32(value,(int32_t)v);
591  else if (value->bufsiz == (signed)sizeof(int16_t))
592  return value_update_i16(value,(int16_t)v);
593  else if (value->bufsiz == (signed)sizeof(int8_t))
594  return value_update_i8(value,(int8_t)v);
595  else {
596  errno = EINVAL;
597  return -1;
598  }
599  return 0;
600 }
602  if (value->bufsiz == (signed)sizeof(uint64_t))
603  return value_update_u64(value,v);
604  else if (value->bufsiz == (signed)sizeof(uint32_t))
605  return value_update_u32(value,(uint32_t)v);
606  else if (value->bufsiz == (signed)sizeof(uint16_t))
607  return value_update_u16(value,(uint16_t)v);
608  else if (value->bufsiz == (signed)sizeof(uint8_t))
609  return value_update_u8(value,(uint8_t)v);
610  else {
611  errno = EINVAL;
612  return -1;
613  }
614  return 0;
615 }
616 
617 static inline int __d2hs(char *buf,unsigned int len,char *str) {
618  unsigned int i;
619  uint8_t hi,lo;
620 
621  i = 0;
622  while (i < len) {
623  lo = buf[i] & 0xf;
624  hi = (buf[i] >> 4) & 0xf;
625 
626  if (lo <= 9) str[i*2+1] = '0' + lo;
627  else str[i*2+1] = 'a' + (lo - 10);
628 
629  if (hi <= 9) str[i*2] = '0' + hi;
630  else str[i*2] = 'a' + (hi - 10);
631 
632  ++i;
633  }
634 
635  return 0;
636 }
637 
638 
639 int value_snprintf(struct value *value,char *buf,int buflen) {
640  int nrc;
641  struct symbol *tmpsym;
642  struct value fake_value;
643  OFFSET offset;
644  int *indicies;
645  int i;
646  int j;
647  int found;
648  uint32_t tbytesize;
649  struct symbol *datatype = value->type;
650  struct symbol *datatype2;
651  GSList *gsltmp;
652  loctype_t ltrc;
653  struct location tloc;
654  int unprintable;
655  target_decoder_t decoder;
656  void *decoder_data = NULL;
657  struct target *target = NULL;
658 
659  nrc = 0;
660 
661  if ((buf == NULL && buflen != 0) || (buf != NULL && buflen == 0)) {
662  verror("programming bug: buf/buflen must both be NULL, or non-NULL!\n");
663  errno = EINVAL;
664  return -1;
665  }
666 
667  memset(&fake_value,0,sizeof(fake_value));
668 
669  /*
670  * NB: little macro to make sure we can support value_snprintf with
671  * NULL buf and 0 buflen just for sizing purposes. All calls to
672  * snprintf must go through this.
673  */
674 #define Lsnprintf(...) \
675  snprintf((buf != NULL) ? buf + nrc : NULL,(buflen != 0) ? buflen - nrc : 0, \
676  ## __VA_ARGS__)
677 
678 #define VSBP(msg) \
679  do { \
680  int _trc = 0; \
681  _trc = snprintf((buf != NULL) ? buf + nrc : NULL, \
682  (buflen != 0) ? buflen - nrc : 0, \
683  "<"msg"::"); \
684  if (_trc < 0) \
685  return -1; \
686  nrc += _trc; \
687  _trc = ((value->bufsiz * 2) > (buflen - nrc - 1)) \
688  ? (buflen - nrc - 1) / 2 : value->bufsiz; \
689  __d2hs(value->buf,_trc,buf + nrc); \
690  nrc += _trc * 2; \
691  if (nrc < (buflen - 1)) { \
692  buf[nrc++] = '>'; \
693  buf[nrc++] = '\0'; \
694  } \
695  else if (nrc < buflen) \
696  buf[nrc++] = '\0'; \
697  else \
698  buf[buflen - 1] = '\0'; \
699  } \
700  while (0)
701 #define VSBPA(msg,...) \
702  do { \
703  int _trc = 0; \
704  _trc = snprintf((buf != NULL) ? buf + nrc : NULL, \
705  (buflen != 0) ? buflen - nrc : 0, \
706  "<"msg"::", ## __VA_ARGS__); \
707  if (_trc < 0) \
708  return -1; \
709  nrc += _trc; \
710  _trc = ((value->bufsiz * 2) > (buflen - nrc - 1)) \
711  ? (buflen - nrc - 1) / 2 : value->bufsiz; \
712  __d2hs(value->buf,_trc,buf + nrc); \
713  nrc += _trc * 2; \
714  if (nrc < (buflen - 1)) { \
715  buf[nrc++] = '>'; \
716  buf[nrc++] = '\0'; \
717  } \
718  else if (nrc < buflen) \
719  buf[nrc++] = '\0'; \
720  else \
721  buf[buflen - 1] = '\0'; \
722  } \
723  while (0)
724 
725  /* Handle AUTO_STRING specially. */
726  if (value->isstring) {
727  unprintable = 0;
728  for (j = 0; j < value->bufsiz && value->buf[j] != '\0'; ++j) {
729  if (!isgraph(value->buf[j]) && !isspace(value->buf[j])) {
730  unprintable = 1;
731  break;
732  }
733  }
734  if (unprintable) {
735  VSBP("BINARY_STRING");
736  }
737  else
738  nrc = Lsnprintf("\"%s\"",value->buf);
739  goto out;
740  }
741 
742  if (!datatype)
743  return -1;
744 
745  datatype = symbol_type_skip_qualifiers(datatype);
746  tbytesize = symbol_get_bytesize(datatype);
747 
748  /* Check with type decoders. */
749  if (value->thread)
750  target = value->thread->target;
751  if (target
752  && target_decoder_lookup(target,value,&decoder,&decoder_data) == 0) {
753  int _trc = decoder(target,decoder_data,value,buf + nrc,buflen - nrc);
754  if (_trc > -1) {
755  /* It worked, just return. */
756  nrc = _trc;
757  goto out;
758  }
759  }
760 
761  switch (datatype->datatype_code) {
762  case DATATYPE_BASE:;
763  encoding_t enc = SYMBOLX_ENCODING_V(datatype);
764  if (enc == ENCODING_ADDRESS) {
765  if (tbytesize == 1)
766  nrc = Lsnprintf("%"PRIx8,v_u8(value));
767  else if (tbytesize == 2)
768  nrc = Lsnprintf("%"PRIx16,v_u16(value));
769  else if (tbytesize == 4)
770  nrc = Lsnprintf("%"PRIx32,v_u32(value));
771  else if (tbytesize == 8)
772  nrc = Lsnprintf("%"PRIx64,v_u64(value));
773  else
774  VSBPA("UNSUP_ENC_%d",enc);
775  }
776  else if (enc == ENCODING_BOOLEAN
777  || enc == ENCODING_UNSIGNED) {
778  if (tbytesize == 1)
779  nrc = Lsnprintf("%"PRIu8,v_u8(value));
780  else if (tbytesize == 2)
781  nrc = Lsnprintf("%"PRIu16,v_u16(value));
782  else if (tbytesize == 4)
783  nrc = Lsnprintf("%"PRIu32,v_u32(value));
784  else if (tbytesize == 8)
785  nrc = Lsnprintf("%"PRIu64,v_u64(value));
786  else
787  VSBPA("UNSUP_ENC_%d",enc);
788  }
789  else if (enc == ENCODING_SIGNED) {
790  if (tbytesize == 1)
791  nrc = Lsnprintf("%"PRIi8,v_i8(value));
792  else if (tbytesize == 2)
793  nrc = Lsnprintf("%"PRIi16,v_i16(value));
794  else if (tbytesize == 4)
795  nrc = Lsnprintf("%"PRIi32,v_i32(value));
796  else if (tbytesize == 8)
797  nrc = Lsnprintf("%"PRIi64,v_i64(value));
798  else
799  VSBPA("UNSUP_ENC_%d",enc);
800  }
801  else if (enc == ENCODING_FLOAT) {
802  if (tbytesize == 4)
803  nrc = Lsnprintf("%f",(double)v_f(value));
804  else if (tbytesize == 8)
805  nrc = Lsnprintf("%f",v_d(value));
806  else if (tbytesize == 16)
807  nrc = Lsnprintf("%Lf",v_dd(value));
808  else
809  VSBPA("UNSUP_ENC_%d",enc);
810  }
811  else if (enc == ENCODING_SIGNED_CHAR
812  || enc == ENCODING_UNSIGNED_CHAR) {
813  if (tbytesize == 1)
814  nrc = Lsnprintf("%c",(int)v_c(value));
815  else if (tbytesize == 2)
816  nrc = Lsnprintf("%lc",(wint_t)v_wc(value));
817  else
818  VSBPA("UNSUP_ENC_%d",enc);
819  }
820  else if (enc == ENCODING_COMPLEX_FLOAT) {
821  VSBPA("UNSUP_ENC_%d",enc);
822  }
823  else if (enc == ENCODING_IMAGINARY_FLOAT) {
824  VSBPA("UNSUP_ENC_%d",enc);
825  }
826  else if (enc == ENCODING_PACKED_DECIMAL) {
827  VSBPA("UNSUP_ENC_%d",enc);
828  }
829  else if (enc == ENCODING_NUMERIC_STRING) {
830  VSBPA("UNSUP_ENC_%d",enc);
831  }
832  else if (enc == ENCODING_EDITED) {
833  VSBPA("UNSUP_ENC_%d",enc);
834  }
835  else if (enc == ENCODING_SIGNED_FIXED) {
836  VSBPA("UNSUP_ENC_%d",enc);
837  }
838  else if (enc == ENCODING_UNSIGNED_FIXED) {
839  VSBPA("UNSUP_ENC_%d",enc);
840  }
841  else {
842  VSBPA("UNSUP_ENC_%d",enc);
843  }
844  break;
845  case DATATYPE_PTR:
846  if (tbytesize == 4)
847  nrc = Lsnprintf("0x%"PRIx32,v_u32(value));
848  else if (tbytesize == 8)
849  nrc = Lsnprintf("0x%"PRIx64,v_u64(value));
850  else
851  VSBP("UNSUP_PTR");
852  break;
853  case DATATYPE_ARRAY:;
854  GSList *subranges = SYMBOLX_SUBRANGES(datatype);
855  int subrange_first;
856  int subrange;
857  int llen;
858 
859  if (!subranges) {
860  nrc = Lsnprintf("[ ]");
861  break;
862  }
863 
864  llen = g_slist_length(subranges);
865  subrange_first = (int)(uintptr_t)g_slist_nth_data(subranges,0);
866 
867  datatype2 = symbol_get_datatype(datatype);
868 
869  /* First, if it's a single-index char array, print as a string
870  * if AUTO_STRING.
871  */
872  if (llen == 1 && symbol_type_is_char(datatype2)) {
873  nrc = Lsnprintf("\"%.*s\"",subrange_first,value->buf);
874  break;
875  }
876 
877  nrc = 0;
878  /* Otherwise, just dump the members of the array. */
879  indicies = malloc(sizeof(int)*llen);
880  for (i = 0; i < llen; ++i) {
881  indicies[i] = 0;
882  nrc += Lsnprintf("[ ");
883  }
884  fake_value.bufsiz = symbol_get_bytesize(datatype2);
885  fake_value.buf = value->buf;
886  fake_value.type = datatype2;
887  again:
888  while (1) { /* fake_value.buf < (value->buf + value->bufsiz)) {
889  */
890  nrc += value_snprintf(&fake_value,(buf != NULL) ? buf + nrc : NULL,(buflen != 0) ? buflen - nrc : 0);
891  nrc += Lsnprintf(", ");
892 
893  /* calc current offset */
894  fake_value.buf += symbol_get_bytesize(datatype2);
895 
896  /* close brackets */
897  for (j = llen - 1; j > -1; --j) {
898  ++indicies[j];
899  subrange = (int)(uintptr_t)g_slist_nth_data(subranges,j);
900 
901  if (indicies[j] >= subrange) {
902  nrc += Lsnprintf(" ],");
903  if (j == 0)
904  /* Break to outer loop and the main termination */
905  break;
906  indicies[j] = 0;
907  }
908  else
909  goto again;
910  }
911 
912  /* terminate if we're done */
913  if (indicies[0] >= subrange_first)
914  break;
915 
916  for ( ; j < llen; ++j)
917  nrc += Lsnprintf(" [ ");
918  }
919  free(indicies);
920 
921  break;
922  case DATATYPE_STRUCT:
923  case DATATYPE_UNION:
924  case DATATYPE_CLASS:
925  nrc = Lsnprintf("{");
926  gsltmp = NULL;
927  v_g_slist_foreach(SYMBOLX_MEMBERS(datatype),gsltmp,tmpsym) {
928  if (symbol_get_name(tmpsym))
929  nrc += Lsnprintf(" .%s = ",symbol_get_name(tmpsym));
930  else
931  nrc += Lsnprintf(" ");
932  memset(&tloc,0,sizeof(tloc));
933  ltrc = symbol_resolve_location(tmpsym,NULL,&tloc);
934  if (ltrc != LOCTYPE_MEMBER_OFFSET) {
935  nrc += Lsnprintf("?,");
936  }
937  else {
938  offset = LOCATION_OFFSET(&tloc);
939  fake_value.buf = value->buf + offset;
940  fake_value.type = symbol_get_datatype(tmpsym);
941  fake_value.bufsiz = symbol_get_bytesize(fake_value.type);
942  nrc += value_snprintf(&fake_value,(buf != NULL) ? buf + nrc : NULL,(buflen != 0) ? buflen - nrc : 0);
943  nrc += Lsnprintf(",");
944  }
945  location_internal_free(&tloc);
946  }
947  nrc += Lsnprintf(" }");
948  break;
949  case DATATYPE_ENUM:
950  found = 0;
951  nrc = 0;
952  gsltmp = NULL;
953  v_g_slist_foreach(SYMBOLX_MEMBERS(datatype),gsltmp,tmpsym) {
954  char *constval = SYMBOLX_VAR_CONSTVAL(tmpsym);
955  if (!constval)
956  continue;
957  if (strncmp((char *)constval,value->buf,
958  symbol_type_full_bytesize(datatype)) == 0) {
959  nrc += Lsnprintf("%s",symbol_get_name(tmpsym));
960  found = 1;
961  break;
962  }
963  }
964  if (!found)
965  nrc += Lsnprintf("%"PRIuNUM" (0x%"PRIxNUM")",
966  v_unum(value),v_unum(value));
967  break;
968  case DATATYPE_CONST:
969  VSBPA("UNSUP_CONST_%s",symbol_get_name(datatype));
970  break;
971  case DATATYPE_VOL:
972  VSBPA("UNSUP_VOL_%s",symbol_get_name(datatype));
973  break;
974  case DATATYPE_TYPEDEF:
975  VSBPA("UNSUP_TYPEDEF_%s",symbol_get_name(datatype));
976  break;
977  case DATATYPE_FUNC:
978  VSBPA("UNSUP_FUNCTION_%s",symbol_get_name(datatype));
979  break;
980  case DATATYPE_VOID:
981  nrc = Lsnprintf("NULL");
982  break;
983  default:
984  nrc = 0;
985  break;
986  }
987 
988  out:
989  return nrc;
990 }
991 
992 void __value_dump(struct value *value,struct dump_info *ud) {
993  struct symbol *tmpsym;
994  struct value fake_value;
995  OFFSET offset;
996  int *indicies;
997  int i;
998  int j;
999  int found;
1000  uint32_t tbytesize;
1001  struct symbol *datatype = value->type;
1002  struct symbol *datatype2;
1003  GSList *gsltmp;
1004  loctype_t ltrc;
1005  struct location tloc;
1006  target_decoder_t decoder;
1007  void *decoder_data = NULL;
1008  struct target *target = NULL;
1009  char *decstrbuf = NULL;
1010  int decstrbuflen = 0;
1011 
1012  /* Handle AUTO_STRING specially. */
1013  if (value->isstring) {
1014  fprintf(ud->stream,"\"%s\"",value->buf);
1015  goto out;
1016  }
1017 
1018  memset(&fake_value,0,sizeof(fake_value));
1019 
1020  if (datatype)
1021  datatype = symbol_type_skip_qualifiers(datatype);
1022  tbytesize = symbol_get_bytesize(datatype);
1023 
1024  /* Check with type decoders. */
1025  if (value->thread)
1026  target = value->thread->target;
1027  if (target
1028  && target_decoder_lookup(target,value,&decoder,&decoder_data) == 0) {
1029  decstrbuflen = 4096;
1030  decstrbuf = (char *)malloc(decstrbuflen);
1031  int _trc = decoder(target,decoder_data,value,decstrbuf,decstrbuflen);
1032  if (_trc > -1) {
1033  if (_trc < decstrbuflen) {
1034  /* It worked, just dump the string. */
1035  fputs(decstrbuf,ud->stream);
1036  free(decstrbuf);
1037  goto out;
1038  }
1039  else {
1040  free(decstrbuf);
1041  decstrbuflen = _trc + 1;
1042  decstrbuf = (char *)malloc(decstrbuflen);
1043  decoder(target,decoder_data,value,decstrbuf,decstrbuflen);
1044  /* Assume it worked the second time on bigger buf; dump */
1045  fputs(decstrbuf,ud->stream);
1046  free(decstrbuf);
1047  goto out;
1048  }
1049  }
1050  else {
1051  /* Just do the normal thing. */
1052  free(decstrbuf);
1053  decstrbuflen = 0;
1054  }
1055  }
1056 
1057  switch (datatype->datatype_code) {
1058  case DATATYPE_BASE:;
1059  encoding_t enc = SYMBOLX_ENCODING_V(datatype);
1060  if (enc == ENCODING_ADDRESS) {
1061  if (tbytesize == 1)
1062  fprintf(ud->stream,"%"PRIx8,v_u8(value));
1063  else if (tbytesize == 2)
1064  fprintf(ud->stream,"%"PRIx16,v_u16(value));
1065  else if (tbytesize == 4)
1066  fprintf(ud->stream,"%"PRIx32,v_u32(value));
1067  else if (tbytesize == 8)
1068  fprintf(ud->stream,"%"PRIx64,v_u64(value));
1069  else
1070  fprintf(ud->stream,"<UNSUPPORTED_BYTESIZE_%d>",tbytesize);
1071  }
1072  else if (enc == ENCODING_BOOLEAN
1073  || enc == ENCODING_UNSIGNED) {
1074  if (tbytesize == 1)
1075  fprintf(ud->stream,"%"PRIu8,v_u8(value));
1076  else if (tbytesize == 2)
1077  fprintf(ud->stream,"%"PRIu16,v_u16(value));
1078  else if (tbytesize == 4)
1079  fprintf(ud->stream,"%"PRIu32,v_u32(value));
1080  else if (tbytesize == 8)
1081  fprintf(ud->stream,"%"PRIu64,v_u64(value));
1082  else
1083  fprintf(ud->stream,"<UNSUPPORTED_BYTESIZE_%d>",tbytesize);
1084  }
1085  else if (enc == ENCODING_SIGNED) {
1086  if (tbytesize == 1)
1087  fprintf(ud->stream,"%"PRIi8,v_i8(value));
1088  else if (tbytesize == 2)
1089  fprintf(ud->stream,"%"PRIi16,v_i16(value));
1090  else if (tbytesize == 4)
1091  fprintf(ud->stream,"%"PRIi32,v_i32(value));
1092  else if (tbytesize == 8)
1093  fprintf(ud->stream,"%"PRIi64,v_i64(value));
1094  else
1095  fprintf(ud->stream,"<UNSUPPORTED_BYTESIZE_%d>",tbytesize);
1096  }
1097  else if (enc == ENCODING_FLOAT) {
1098  if (tbytesize == 4)
1099  fprintf(ud->stream,"%f",(double)v_f(value));
1100  else if (tbytesize == 8)
1101  fprintf(ud->stream,"%f",v_d(value));
1102  else if (tbytesize == 16)
1103  fprintf(ud->stream,"%Lf",v_dd(value));
1104  else
1105  fprintf(ud->stream,"<UNSUPPORTED_BYTESIZE_%d>",tbytesize);
1106  }
1107  else if (enc == ENCODING_SIGNED_CHAR
1108  || enc == ENCODING_UNSIGNED_CHAR) {
1109  if (tbytesize == 1)
1110  fprintf(ud->stream,"%c",(int)v_c(value));
1111  else if (tbytesize == 2)
1112  fprintf(ud->stream,"%lc",(wint_t)v_wc(value));
1113  else
1114  fprintf(ud->stream,"<UNSUPPORTED_BYTESIZE_%d>",tbytesize);
1115  }
1116  else if (enc == ENCODING_COMPLEX_FLOAT) {
1117  fprintf(ud->stream,"<UNSUPPORTED_COMPLEX_FLOAT_%d>",
1118  tbytesize);
1119  }
1120  else if (enc == ENCODING_IMAGINARY_FLOAT) {
1121  fprintf(ud->stream,"<UNSUPPORTED_IMAGINARY_FLOAT_%d>",
1122  tbytesize);
1123  }
1124  else if (enc == ENCODING_PACKED_DECIMAL) {
1125  fprintf(ud->stream,"<UNSUPPORTED_PACKED_DECIMAL_%d>",
1126  tbytesize);
1127  }
1128  else if (enc == ENCODING_NUMERIC_STRING) {
1129  fprintf(ud->stream,"<UNSUPPORTED_NUMERIC_STRING_%d>",
1130  tbytesize);
1131  }
1132  else if (enc == ENCODING_EDITED) {
1133  fprintf(ud->stream,"<UNSUPPORTED_EDITED_%d>",
1134  tbytesize);
1135  }
1136  else if (enc == ENCODING_SIGNED_FIXED) {
1137  fprintf(ud->stream,"<UNSUPPORTED_SIGNED_FIXED_%d>",
1138  tbytesize);
1139  }
1140  else if (enc == ENCODING_UNSIGNED_FIXED) {
1141  fprintf(ud->stream,"<UNSUPPORTED_UNSIGNED_FIXED_%d>",
1142  tbytesize);
1143  }
1144  break;
1145  case DATATYPE_PTR:
1146  if (tbytesize == 4)
1147  fprintf(ud->stream,"0x%"PRIx32,v_u32(value));
1148  else if (tbytesize == 8)
1149  fprintf(ud->stream,"0x%"PRIx64,v_u64(value));
1150  else
1151  fprintf(ud->stream,"<UNSUPPORTED_PTR_%d>",tbytesize);
1152  break;
1153  case DATATYPE_ARRAY:;
1154  GSList *subranges = SYMBOLX_SUBRANGES(datatype);
1155  int subrange_first;
1156  int subrange;
1157  int llen;
1158 
1159  if (!subranges) {
1160  fprintf(ud->stream,"[ ]");
1161  break;
1162  }
1163 
1164  subrange_first = (int)(uintptr_t)g_slist_nth_data(subranges,0);
1165  llen = g_slist_length(subranges);
1166  datatype2 = symbol_get_datatype(datatype);
1167 
1168  /* First, if it's a single-index char array, print as a string
1169  * if AUTO_STRING.
1170  */
1171  if (llen == 1
1172  && symbol_type_is_char(datatype2)) {
1173  fprintf(ud->stream,"\"%.*s\"",subrange_first,value->buf);
1174  break;
1175  }
1176 
1177  /* Otherwise, just dump the members of the array. */
1178  indicies = malloc(sizeof(int)*llen);
1179  for (i = 0; i < llen; ++i) {
1180  indicies[i] = 0;
1181  fprintf(ud->stream,"[ ");
1182  }
1183  fake_value.bufsiz = symbol_get_bytesize(datatype2);
1184  fake_value.buf = value->buf;
1185  fake_value.type = datatype2;
1186  again:
1187  while (1) { /* fake_value.buf < (value->buf + value->bufsiz)) { */
1188  __value_dump(&fake_value,ud);
1189  fprintf(ud->stream,", ");
1190 
1191  /* calc current offset */
1192  fake_value.buf += symbol_get_bytesize(datatype2);
1193 
1194  /* close brackets */
1195  for (j = llen - 1; j > -1; --j) {
1196  ++indicies[j];
1197 
1198  subrange = (int)(uintptr_t)g_slist_nth_data(subranges,j);
1199  if (indicies[j] >= subrange) {
1200  fprintf(ud->stream," ],");
1201  if (j == 0)
1202  /* Break to outer loop and the main termination */
1203  break;
1204  indicies[j] = 0;
1205  }
1206  else
1207  goto again;
1208  }
1209 
1210  /* terminate if we're done */
1211  if (indicies[0] >= subrange_first)
1212  break;
1213 
1214  for ( ; j < llen; ++j)
1215  fprintf(ud->stream," [ ");
1216  }
1217  free(indicies);
1218 
1219  break;
1220  case DATATYPE_STRUCT:
1221  case DATATYPE_UNION:
1222  fprintf(ud->stream,"{");
1223  gsltmp = NULL;
1224  v_g_slist_foreach(SYMBOLX_MEMBERS(datatype),gsltmp,tmpsym) {
1225  if (symbol_get_name(tmpsym))
1226  fprintf(ud->stream," .%s = ",symbol_get_name(tmpsym));
1227  else
1228  fprintf(ud->stream," ");
1229  memset(&tloc,0,sizeof(tloc));
1230  ltrc = symbol_resolve_location(tmpsym,NULL,&tloc);
1231  if (ltrc != LOCTYPE_MEMBER_OFFSET) {
1232  fputs("?,",ud->stream);
1233  }
1234  else {
1235  offset = LOCATION_OFFSET(&tloc);
1236  fake_value.buf = value->buf + offset;
1237  fake_value.type = symbol_get_datatype(tmpsym);
1238  fake_value.bufsiz = symbol_get_bytesize(fake_value.type);
1239  __value_dump(&fake_value,ud);
1240  fputs(",",ud->stream);
1241  }
1242  location_internal_free(&tloc);
1243  }
1244  fprintf(ud->stream," }");
1245  break;
1246  case DATATYPE_ENUM:
1247  found = 0;
1248  gsltmp = NULL;
1249  v_g_slist_foreach(SYMBOLX_MEMBERS(datatype),gsltmp,tmpsym) {
1250  char *constval = SYMBOLX_VAR_CONSTVAL(tmpsym);
1251  if (!constval)
1252  continue;
1253  if (strncmp((char *)constval,value->buf,
1254  symbol_type_full_bytesize(datatype)) == 0) {
1255  fprintf(ud->stream,"%s",symbol_get_name(tmpsym));
1256  found = 1;
1257  break;
1258  }
1259  }
1260  if (!found)
1261  fprintf(ud->stream,"%"PRIuNUM" (0x%"PRIxNUM")",
1262  v_unum(value),v_unum(value));
1263  break;
1264  case DATATYPE_CONST:
1265  fprintf(ud->stream,"<UNSUPPORTED_CONST_%s>",symbol_get_name(datatype));
1266  break;
1267  case DATATYPE_VOL:
1268  fprintf(ud->stream,"<UNSUPPORTED_VOL_%s>",symbol_get_name(datatype));
1269  break;
1270  case DATATYPE_TYPEDEF:
1271  fprintf(ud->stream,"<UNSUPPORTED_TYPEDEF_%s>",
1272  symbol_get_name(datatype));
1273  break;
1274  case DATATYPE_FUNC:
1275  fprintf(ud->stream,"<UNSUPPORTED_FUNCTION_%s>",
1276  symbol_get_name(datatype));
1277  break;
1278  case DATATYPE_VOID:
1279  fprintf(ud->stream,"NULL");
1280  break;
1281  default:
1282  break;
1283  }
1284 
1285  out:
1286  return;
1287 }
1288 
1289 void value_dump_simple(struct value *value,struct dump_info *ud) {
1290  __value_dump(value,ud);
1291  return;
1292 }
1293 
1294 void value_dump(struct value *value,struct dump_info *ud) {
1295  char *p = "";
1296  char *np;
1297  struct dump_info udn;
1298  int i;
1299  int alen;
1300  struct symbol *s;
1301 
1302  if (ud->prefix) {
1303  p = ud->prefix;
1304  np = malloc(strlen(p) + 1 + 2);
1305  sprintf(np,"%s%s",p," ");
1306  }
1307  else {
1308  np = " ";
1309  }
1310  udn.prefix = np;
1311  udn.stream = ud->stream;
1312  udn.meta = ud->meta;
1313  udn.detail = ud->detail;
1314 
1315  if (value->lsymbol) {
1316  alen = array_list_len(value->lsymbol->chain);
1317  for (i = 0; i < alen; ++i) {
1318  s = (struct symbol *)array_list_item(value->lsymbol->chain,i);
1319  if (symbol_get_name(s)) {
1320  fprintf(udn.stream,"%s",symbol_get_name(s));
1321  if ((i + 1) < alen)
1322  fputs(".",udn.stream);
1323  }
1324  }
1325 
1326  fputs(" = ",udn.stream);
1327  }
1328 
1329  __value_dump(value,&udn);
1330 
1331  if (ud->prefix)
1332  free(np);
1333  return;
1334 }
1335 
1336 signed char rv_c(void *buf) { return *((signed char *)buf); }
1337 unsigned char rv_uc(void *buf) { return *((unsigned char *)buf); }
1338 wchar_t rv_wc(void *buf) { return *((wchar_t *)buf); }
1339 uint8_t rv_u8(void *buf) { return *((uint8_t *)buf); }
1340 uint16_t rv_u16(void *buf) { return *((uint16_t *)buf); }
1341 uint32_t rv_u32(void *buf) { return *((uint32_t *)buf); }
1342 uint64_t rv_u64(void *buf) { return *((uint64_t *)buf); }
1343 int8_t rv_i8(void *buf) { return *((int8_t *)buf); }
1344 int16_t rv_i16(void *buf) { return *((int16_t *)buf); }
1345 int32_t rv_i32(void *buf) { return *((int32_t *)buf); }
1346 int64_t rv_i64(void *buf) { return *((int64_t *)buf); }
1347 float rv_f(void *buf) { return *((float *)buf); }
1348 double rv_d(void *buf) { return *((double *)buf); }
1349 long double rv_dd(void *buf) { return *((long double *)buf); }
1350 ADDR rv_addr(void *buf){ return *((ADDR *)buf); }
unum_t v_unum(struct value *v)
Definition: value.c:411
int8_t rv_i8(void *buf)
Definition: value.c:1343
void value_dump_simple(struct value *value, struct dump_info *ud)
Definition: value.c:1289
int32_t rv_i32(void *buf)
Definition: value.c:1345
uint8_t v_u8(struct value *v)
Definition: value.c:388
int value_update_wc(struct value *value, wchar_t v)
Definition: value.c:481
struct value * value_clone(struct value *in)
Definition: value.c:195
int16_t rv_i16(void *buf)
Definition: value.c:1344
num_t v_num(struct value *v)
Definition: value.c:396
encoding_t
Definition: dwdebug.h:266
#define SYMBOLX_SUBRANGES(sym)
struct value * value_create_raw(struct target *target, struct target_thread *tthread, struct memrange *range, int len)
Definition: value.c:77
void value_set_const(struct value *value)
Definition: value.c:73
signed char rv_c(void *buf)
Definition: value.c:1336
uint8_t isreg
Definition: target_api.h:3300
void * p
uint64_t rv_u64(void *buf)
Definition: value.c:1342
static uint64_t unsigned int i
void value_dump(struct value *value, struct dump_info *ud)
Definition: value.c:1294
#define SYMBOLX_MEMBERS(sym)
int value_update_f(struct value *value, float v)
Definition: value.c:553
Definition: arch.h:74
#define v_g_slist_foreach(gslhead, gslcur, elm)
Definition: glib_wrapper.h:60
SMOFFSET ref
Definition: dwdebug_priv.h:868
void location_internal_free(struct location *location)
Definition: location.c:347
int value_update_zero(struct value *value, const char *buf, int bufsiz)
Definition: value.c:447
void __value_dump(struct value *value, struct dump_info *ud)
Definition: value.c:992
struct value * value_create_noalloc(struct target_thread *thread, struct memrange *range, struct lsymbol *lsymbol, struct symbol *type)
Definition: value.c:153
long double rv_dd(void *buf)
Definition: value.c:1349
void value_free(struct value *value)
Definition: value.c:282
int value_set_reg(struct value *value, REG reg)
Definition: value.c:45
uint32_t v_u32(struct value *v)
Definition: value.c:390
union value::@27 res
int64_t num_t
Definition: common.h:87
struct target_thread * global_thread
Definition: target_api.h:2685
ADDR rv_addr(void *buf)
Definition: value.c:1350
ADDR addr
Definition: target_api.h:3309
double v_d(struct value *v)
Definition: value.c:427
int8_t v_i8(struct value *v)
Definition: value.c:392
uint32_t symbol_get_bytesize(struct symbol *symbol)
Definition: debug.c:3065
struct target * target
Definition: target.h:895
int32_t OFFSET
Definition: common.h:65
struct target_thread * thread
Definition: target_api.h:3277
#define verror(format,...)
Definition: log.h:30
uint16_t rv_u16(void *buf)
Definition: value.c:1340
int target_decoder_lookup(struct target *target, struct value *value, target_decoder_t *decoder, void **decoder_data)
Definition: target.c:6350
unsigned char * target_read_addr(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
Definition: target_api.c:1053
int bufsiz
Definition: target_api.h:3297
struct symbol * symbol_get_datatype(struct symbol *symbol)
Definition: debug.c:2989
signed char v_c(struct value *v)
Definition: value.c:385
int value_snprintf(struct value *value, char *buf, int buflen)
Definition: value.c:639
#define Lsnprintf(...)
double rv_d(void *buf)
Definition: value.c:1348
int32_t v_i32(struct value *v)
Definition: value.c:394
loctype_t symbol_resolve_location(struct symbol *symbol, struct location_ctxt *lctxt, struct location *o_loc)
Definition: location.c:546
int value_update_addr(struct value *value, ADDR v)
Definition: value.c:577
#define vwarn(format,...)
Definition: log.h:33
struct value * value_create(struct target_thread *thread, struct memrange *range, struct lsymbol *lsymbol, struct symbol *type)
Definition: value.c:138
int value_update_i16(struct value *value, int16_t v)
Definition: value.c:529
int symbol_type_is_char(struct symbol *type)
Definition: debug.c:4224
void free(void *ptr)
Definition: debugserver.c:207
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
Definition: target_api.c:1132
uint8_t isconst
Definition: target_api.h:3300
#define LOCATION_OFFSET(loc)
Definition: dwdebug_priv.h:624
int64_t rv_i64(void *buf)
Definition: value.c:1346
int value_refresh_diff(struct value *value, int recurse, value_diff_t *vdiff, char **old_buf, int *old_bufsiz, value_hash_t *old_vhash)
Definition: value.c:378
char * prefix
Definition: output.h:25
int value_refresh(struct value *value, int recursive)
Definition: value.c:329
uintptr_t value_hash_t
Definition: target_api.h:1641
uint8_t isstring
Definition: target_api.h:3300
ADDR res_ip
Definition: target_api.h:3316
int value_update_u64(struct value *value, uint64_t v)
Definition: value.c:513
char * v_string(struct value *v)
Definition: value.c:430
datatype_code_t datatype_code
Definition: dwdebug_priv.h:827
uint16_t v_u16(struct value *v)
Definition: value.c:389
uint8_t rv_u8(void *buf)
Definition: value.c:1339
struct addrspace * space
Definition: target.h:937
char * buf
Definition: target_api.h:3298
unsigned char v_uc(struct value *v)
Definition: value.c:386
#define PRIxNUM
Definition: common.h:91
#define SYMBOLX_ENCODING_V(sym)
unsigned char rv_uc(void *buf)
Definition: value.c:1337
struct value * parent_value
Definition: target_api.h:3318
int value_set_mmap(struct value *value, ADDR addr, struct memcache_mmap_entry *mme, char *offset_ptr)
Definition: value.c:35
struct memrange * range
Definition: target_api.h:3295
char * name
Definition: dwdebug_priv.h:788
int(* target_decoder_t)(struct target *target, void *data, struct value *value, char *buf, int buflen)
Definition: target_api.h:1977
#define PRIxSMOFFSET
Definition: common.h:102
int value_update_d(struct value *value, double v)
Definition: value.c:561
int len
Definition: dumptarget.c:52
#define RHOLD(x, hx)
Definition: common.h:622
wchar_t v_wc(struct value *v)
Definition: value.c:387
REGVAL target_read_creg(struct target *target, tid_t tid, common_reg_t reg)
Definition: target_api.c:1178
struct value * value_reload_as_type(struct value *in, struct symbol *type, int force)
Definition: value.c:224
int value_update_i32(struct value *value, int32_t v)
Definition: value.c:537
struct value * value_create_type(struct target_thread *thread, struct memrange *range, struct symbol *type)
Definition: value.c:102
FILE * stream
Definition: output.h:26
struct symbol * symbol_type_skip_qualifiers(struct symbol *type)
Definition: debug.c:4191
uint32_t rv_u32(void *buf)
Definition: value.c:1341
int value_update_u16(struct value *value, uint16_t v)
Definition: value.c:497
int value_update_num(struct value *value, num_t v)
Definition: value.c:586
struct memregion * region
Definition: target.h:992
ADDR value_addr(struct value *value)
Definition: value.c:302
struct arch * arch
Definition: target_api.h:2603
unsigned int wordsize
Definition: arch.h:121
#define VSBPA(msg,...)
void * calloc(size_t nmemb, size_t size)
Definition: debugserver.c:200
int value_update_u32(struct value *value, uint32_t v)
Definition: value.c:505
struct target * target
Definition: target_api.h:2078
int value_set_addr(struct value *value, ADDR addr)
Definition: value.c:28
int value_update_u8(struct value *value, uint8_t v)
Definition: value.c:489
uint32_t REGVAL
Definition: common.h:66
int16_t v_i16(struct value *v)
Definition: value.c:393
unsigned int symbol_type_full_bytesize(struct symbol *type)
Definition: debug.c:4267
int value_set_child(struct value *value, struct value *parent_value, ADDR addr)
Definition: value.c:53
int8_t REG
Definition: common.h:93
struct lsymbol * lsymbol
Definition: target_api.h:3292
uint32_t ADDR
Definition: common.h:64
#define VSBP(msg)
char * name
Definition: target_api.h:2521
struct symbol * type
Definition: target_api.h:3287
#define SYMBOLX_VAR_CONSTVAL(sym)
int value_update_c(struct value *value, signed char v)
Definition: value.c:465
Definition: memcache.h:110
uint32_t REFCNT
Definition: common.h:124
#define PRIxADDR
Definition: common.h:67
int detail
Definition: output.h:28
value_diff_t
Definition: target_api.h:1634
char * symbol_get_name(struct symbol *symbol)
Definition: debug.c:2587
float rv_f(void *buf)
Definition: value.c:1347
#define RPUT(x, objtype, hx, rc)
Definition: common.h:624
int64_t v_i64(struct value *v)
Definition: value.c:395
void * malloc(size_t size)
Definition: debugserver.c:214
uint8_t ismmap
Definition: target_api.h:3300
int value_update_i64(struct value *value, int64_t v)
Definition: value.c:545
struct array_list * chain
Definition: dwdebug.h:1016
int value_update_uc(struct value *value, unsigned char v)
Definition: value.c:473
uint64_t unum_t
Definition: common.h:88
wchar_t rv_wc(void *buf)
Definition: value.c:1338
int meta
Definition: output.h:27
REG reg
Definition: target_api.h:3310
int value_update_dd(struct value *value, long double v)
Definition: value.c:569
int value_update_unum(struct value *value, unum_t v)
Definition: value.c:601
ADDR v_addr(struct value *v)
Definition: value.c:429
long double v_dd(struct value *v)
Definition: value.c:428
int value_update(struct value *value, const char *buf, int bufsiz)
Definition: value.c:432
float v_f(struct value *v)
Definition: value.c:426
void value_set_strlen(struct value *value, int len)
Definition: value.c:68
#define PRIuNUM
Definition: common.h:89
uint64_t v_u64(struct value *v)
Definition: value.c:391
loctype_t
Definition: dwdebug.h:234
struct symbol * datatype
Definition: dwdebug_priv.h:925
int value_update_i8(struct value *value, int8_t v)
Definition: value.c:521