4 * (C) 2005 Michael Beck beck@ipd.info.uni-karlsruhe.de
6 #define WIN32_LEAN_AND_MEAN
14 /* ugly, but I must include array.h WITHOUT NDEBUG */
24 #include "irgraph_t.h"
29 #include "irextbb_t.h"
31 #include "compound_path_t.h"
41 #include "firmEvaluator.h"
43 /** get the address of a pointer */
44 #define ADD_ADR(p, off) ((void *)((char *)(p) + (off)))
47 static void debug(char *fmt, ...) {
52 vsprintf(buf, fmt, ap);
54 OutputDebugString(buf);
59 * return the size of a firm object
61 int get_firm_object_size(firm_kind kind) {
63 case k_entity: /* an entity */
64 return sizeof(ir_entity);
65 case k_type: /* a type */
66 return sizeof(ir_type);
67 case k_ir_graph: /* an ir graph */
68 return sizeof(ir_graph);
69 case k_ir_node: /* an ir node */
70 return sizeof(ir_node);
71 case k_ir_mode: /* an ir mode */
72 return sizeof(ir_mode);
73 case k_ir_op: /* an ir opcode */
75 case k_tarval: /* a tarval */
76 return sizeof(tarval);
77 case k_ir_loop: /* a loop */
78 return sizeof(ir_loop);
79 case k_ir_compound_graph_path: /* a compound graph path, see entity.h */
80 return sizeof(compound_graph_path);
81 case k_ir_extblk: /* an extended block */
82 return sizeof(ir_extblk);
83 case k_ir_prog: /* a program representation (irp) */
84 return sizeof(ir_prog);
88 } /* get_firm_object_size */
91 * returns the string length of a string in debuggee space
93 * @return string length or negative value on error
95 static int strlen_debuggee(DEBUGHELPER *pHelper, const void *address, size_t max)
99 const char *p = address;
101 for (i = 0; i < max; ++i) {
102 if (copy_from_debuggee(p + i, pHelper, &v, sizeof(v)) != S_OK)
109 } /* strlen_debuggee */
114 HRESULT format_ident(DEBUGHELPER *pHelper, const void *address, char *pResult, size_t max) {
115 set_entry *data = NULL;
119 if (copy_from_debuggee(address, pHelper, &id, sizeof(id)) != S_OK)
123 if (id.size < 1 || id.size > 256)
127 len = offsetof(set_entry, dptr) + slen;
131 if (copy_from_debuggee(address, pHelper, data, len) != S_OK)
134 _tcsncpy(pResult, (const char *)data->dptr, max);
141 static HRESULT format_tp_op(DEBUGHELPER *pHelper, const void *addr, char *pResult, size_t max)
145 #define X(a) case tpo_##a: _tcsncpy(pResult, #a, max); return S_OK
146 #define Y(a, b) case tpo_##a: _tcsncpy(pResult, b, max); return S_OK
148 if (copy_from_debuggee(addr, pHelper, &op, sizeof(op)) != S_OK)
158 Y(enumeration, "enum");
160 Y(primitive, "prim");
172 * Checks whether a type is the global type
174 * @param type the address of the type in debuggee's space
176 static HRESULT is_global_type(DEBUGHELPER *pHelper, const void *type, int *flag) {
180 if (copy_from_debuggee(type, pHelper, &tp, sizeof(tp)) != S_OK)
183 *flag = tp.flags & tf_global_type;
185 } /* is_global_type */
190 static HRESULT format_entity(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top) {
196 if (copy_from_debuggee(addr, pHelper, &ent, sizeof(ent)) != S_OK) {
199 if (is_global_type(pHelper, ent.owner, &is_global) != S_OK)
204 _tcsncpy(pResult, "ENT: ", max);
207 if (copy_from_debuggee(ent.owner, pHelper, &owner, sizeof(owner)) != S_OK)
209 if (format_ident(pHelper, (void *)owner.name, name, sizeof(name)) != S_OK)
211 _tcsncat(pResult, name, max);
212 _tcsncat(pResult, "::", max);
215 if (format_ident(pHelper, (void *)ent.name, name, sizeof(name)) != S_OK)
217 _tcsncat(pResult, name, max);
221 _snprintf(name, sizeof(name), " [0x%lx]", ent.nr);
224 _snprintf(name, sizeof(name), " [0%lo]", ent.nr);
227 _snprintf(name, sizeof(name), " [%ld]", ent.nr);
229 _tcsncat(pResult, name, max);
232 } /* format_entity */
237 static HRESULT format_type(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top) {
241 if (copy_from_debuggee(addr, pHelper, &tp, sizeof(tp)) != S_OK)
246 if (format_tp_op(pHelper, tp.type_op, pResult, max) != S_OK)
249 _tcsncat(pResult, " ", max);
252 if (format_ident(pHelper, tp.name, name, sizeof(name)) != S_OK)
255 _tcsncat(pResult, name, max);
258 _snprintf(name, sizeof(name), " [0x%lx]", tp.nr);
261 _snprintf(name, sizeof(name), " [0%lo]", tp.nr);
264 _snprintf(name, sizeof(name), " [%ld]", tp.nr);
266 _tcsncat(pResult, name, max);
274 static HRESULT format_irg(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top) {
278 if (copy_from_debuggee(addr, pHelper, &irg, sizeof(irg)) != S_OK)
283 _tcsncpy(pResult, "IRG: ", max);
290 if (copy_from_debuggee(irg.ent, pHelper, &ent, sizeof(ent)) != S_OK)
292 if (is_global_type(pHelper, ent.owner, &is_global) != S_OK)
295 if (copy_from_debuggee(ent.owner, pHelper, &owner, sizeof(owner)) != S_OK)
297 if (format_ident(pHelper, (void *)owner.name, name, sizeof(name)) != S_OK)
299 _tcsncat(pResult, name, max);
300 _tcsncat(pResult, "::", max);
302 if (format_ident(pHelper, ent.name, name, sizeof(name)) != S_OK)
304 _tcsncat(pResult, name, max);
307 _tcsncat(pResult, "NULL", max);
311 _snprintf(name, sizeof(name), " [0x%lx, 0x%u nodes]", irg.graph_nr, irg.last_node_idx);
314 _snprintf(name, sizeof(name), " [0%lo, 0%o nodes]", irg.graph_nr, irg.last_node_idx);
317 _snprintf(name, sizeof(name), " [%ld, %u nodes]", irg.graph_nr, irg.last_node_idx);
319 _tcsncat(pResult, name, max);
326 HRESULT format_op(DEBUGHELPER *pHelper, const void *addr, char *pResult, size_t max) {
329 if (copy_from_debuggee(addr, pHelper, &op, sizeof(op)) != S_OK)
331 if (format_ident(pHelper, op.name, pResult, max) != S_OK)
339 static HRESULT format_mode(DEBUGHELPER *pHelper, const void *addr, char *pResult, size_t max) {
342 if (copy_from_debuggee(addr, pHelper, &mode, sizeof(mode)) != S_OK)
344 if (format_ident(pHelper, mode.name, pResult, max) != S_OK)
349 /** get a temporary string */
350 #define get_string(str) \
355 len = strlen_debuggee(pHelper, str, 256); \
358 s = alloca(len + 1); \
359 if (copy_from_debuggee(str, pHelper, s, (DWORD)len) != S_OK) \
369 static HRESULT format_tarval(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max)
375 tarval_mode_info modinfo;
378 static int initialized = 0;
381 /* from init_tarval_1() */
389 if (copy_from_debuggee(addr, pHelper, &tv, sizeof(tv)) != S_OK)
396 if (copy_from_debuggee(tv.mode, pHelper, &mode, sizeof(mode)) != S_OK)
401 if (mode_is_int(&mode)) {
404 modinfo.mode_output = TVO_HEX;
405 modinfo.mode_prefix = "0x";
406 modinfo.mode_suffix = "";
409 modinfo.mode_output = TVO_OCTAL;
410 modinfo.mode_prefix = "0";
411 modinfo.mode_suffix = "";
414 modinfo.mode_output = TVO_DECIMAL;
415 modinfo.mode_prefix = "";
416 modinfo.mode_suffix = "";
421 if (copy_from_debuggee(mode.tv_priv, pHelper, &modinfo, sizeof(modinfo)) != S_OK)
424 get_string(modinfo.mode_prefix);
425 get_string(modinfo.mode_suffix);
428 mode.tv_priv = &modinfo;
437 if (copy_from_debuggee(tv.value, pHelper, value, len) != S_OK)
442 tarval_snprintf(pResult, max, &tv);
445 /* might be a reserved tarval */
446 int resid = PTR_TO_INT(tv.value);
449 case resid_tarval_bad:
450 _tcsncat(pResult, "BAD", max);
452 case resid_tarval_undefined:
453 _tcsncat(pResult, "UNDEF", max);
455 case resid_tarval_b_false:
456 _tcsncat(pResult, "FALSE", max);
458 case resid_tarval_b_true:
459 _tcsncat(pResult, "TRUE", max);
463 tarval_snprintf(pResult, max, &tv);
467 } /* format_tarval */
472 static HRESULT format_node(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max, int top) {
477 if (copy_from_debuggee(addr, pHelper, &n, sizeof(n)) != S_OK)
481 if (format_op(pHelper, n.op, pResult, max) != S_OK)
485 if (format_mode(pHelper, n.mode, name, sizeof(name)) != S_OK)
487 _tcsncat(pResult, name, max);
489 if (copy_from_debuggee(n.op, pHelper, &op, sizeof(op)) != S_OK)
492 /* show show node attributes */
495 if (format_tarval(pHelper, nBase, n.attr.con.tv, name, sizeof(name)) != S_OK) {
496 _tcsncat(pResult, "<???>", max);
499 _tcsncat(pResult, "<", max);
500 _tcsncat(pResult, name, max);
501 _tcsncat(pResult, ">", max);
505 _tcsncat(pResult, "<", max);
506 switch (n.attr.symc.kind) {
507 case symconst_type_tag:
508 _tcsncat(pResult, "TAG:", max);
509 if (format_type(pHelper, nBase, n.attr.symc.sym.type_p, name, sizeof(name), 0) != S_OK)
511 _tcsncat(pResult, name, max);
513 case symconst_type_size:
514 _tcsncat(pResult, "SIZE:", max);
515 if (format_type(pHelper, nBase, n.attr.symc.sym.type_p, name, sizeof(name), 0) != S_OK)
517 _tcsncat(pResult, name, max);
519 case symconst_type_align:
520 _tcsncat(pResult, "ALGN:", max);
521 if (format_type(pHelper, nBase, n.attr.symc.sym.type_p, name, sizeof(name), 0) != S_OK)
523 _tcsncat(pResult, name, max);
525 case symconst_addr_name:
526 _tcsncat(pResult, "NAME:", max);
527 if (format_ident(pHelper, n.attr.symc.sym.ident_p, name, sizeof(name)) != S_OK)
529 _tcsncat(pResult, name, max);
531 case symconst_addr_ent:
532 _tcsncat(pResult, "ENT:", max);
533 if (format_entity(pHelper, nBase, n.attr.symc.sym.entity_p, name, sizeof(name), 0) != S_OK)
535 _tcsncat(pResult, name, max);
538 _tcsncat(pResult, ">", max);
541 _tcsncat(pResult, "<", max);
542 if (format_entity(pHelper, nBase, n.attr.sel.entity, name, sizeof(name), 0) != S_OK)
544 _tcsncat(pResult, name, max);
545 _tcsncat(pResult, ">", max);
548 _tcsncat(pResult, "<", max);
549 if (format_type(pHelper, nBase, n.attr.cast.type, name, sizeof(name), 0) != S_OK)
551 _tcsncat(pResult, name, max);
552 _tcsncat(pResult, ">", max);
555 _tcsncat(pResult, "<", max);
556 if (format_type(pHelper, nBase, n.attr.alloc.type, name, sizeof(name), 0) != S_OK)
558 _tcsncat(pResult, name, max);
559 _snprintf(name, sizeof(name), ", %s", n.attr.alloc.where == stack_alloc ? "stack" : "heap");
560 _tcsncat(pResult, name, max);
561 _tcsncat(pResult, ">", max);
564 _tcsncat(pResult, "<", max);
565 if (format_type(pHelper, nBase, n.attr.free.type, name, sizeof(name), 0) != S_OK)
567 _tcsncat(pResult, name, max);
568 _snprintf(name, sizeof(name), ", %s", n.attr.free.where == stack_alloc ? "stack" : "heap");
569 _tcsncat(pResult, name, max);
570 _tcsncat(pResult, ">", max);
573 _tcsncat(pResult, "<", max);
574 if (format_type(pHelper, nBase, n.attr.copyb.type, name, sizeof(name), 0) != S_OK)
576 _tcsncat(pResult, name, max);
577 _tcsncat(pResult, ">", max);
583 _snprintf(name, sizeof(name), " [0x%lx:0x%x]", n.node_nr, n.node_idx);
586 _snprintf(name, sizeof(name), " [0%lo:0%o]", n.node_nr, n.node_idx);
589 _snprintf(name, sizeof(name), " [%ld:%u]", n.node_nr, n.node_idx);
591 _tcsncat(pResult, name, max);
599 static HRESULT format_loop(DEBUGHELPER *pHelper, const void *addr, char *pResult, size_t max)
603 if (copy_from_debuggee(addr, pHelper, &loop, sizeof(loop)) != S_OK)
609 * Get an array descriptor
611 static HRESULT get_array_desc(DEBUGHELPER *pHelper, const void *address, ir_arr_descr *desc)
613 address = ARR_DESCR(address);
614 if (copy_from_debuggee(address, pHelper, desc, sizeof(*desc)) != S_OK)
618 } /* get_array_desc */
621 * format an extended block
623 static HRESULT format_extblk(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max){
626 ir_node *blks = NULL;
630 if (copy_from_debuggee(addr, pHelper, &extbb, sizeof(extbb)) != S_OK)
632 if (extbb.blks == NULL)
635 if (get_array_desc(pHelper, extbb.blks, &blocks) != S_OK)
638 len = ARR_LEN(&blocks.v.elts);
641 if (copy_from_debuggee(extbb.blks, pHelper, &blks, sizeof(blks)) != S_OK)
648 _snprintf(name, sizeof(name), "0x%x 0x%x blocks", blks->node_nr, len);
651 _snprintf(name, sizeof(name), "0%o 0%o blocks", blks->node_nr, len);
654 _snprintf(name, sizeof(name), "%d %d blocks", blks->node_nr, len);
656 _tcsncpy(pResult, name, max);
659 _tcsncpy(pResult, "<EMPTY>", max);
661 } /* format_extblk */
667 static HRESULT format_prog(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max)
670 ir_arr_descr graphs, types;
673 if (copy_from_debuggee(addr, pHelper, &irp, sizeof(irp)) != S_OK)
676 if (get_array_desc(pHelper, irp.graphs, &graphs) != S_OK)
679 irp.graphs = (ir_graph**)&graphs.v.elts;
683 if (get_array_desc(pHelper, irp.types, &types) != S_OK)
686 irp.types = (ir_type**)&types.v.elts;
691 _snprintf(name, sizeof(name), "0x%x graphs 0x%x types", ARR_LEN(irp.graphs), ARR_LEN(irp.types));
694 _snprintf(name, sizeof(name), "0%o graphs 0%o types", ARR_LEN(irp.graphs), ARR_LEN(irp.types));
697 _snprintf(name, sizeof(name), "%d graphs %d types", ARR_LEN(irp.graphs), ARR_LEN(irp.types));
699 _tcsncpy(pResult, name, max);
705 * Format an array descriptor
707 HRESULT format_arr_descr(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max)
712 if (copy_from_debuggee(addr, pHelper, &desc, sizeof(desc)) != S_OK)
715 switch (desc.magic) {
717 _tcsncpy(pResult, "DynArr ", max); break;
719 _tcsncpy(pResult, "AutoArr ", max); break;
721 _tcsncpy(pResult, "FlexArr ", max); break;
723 _tcsncpy(pResult, "UNKN ", max);
728 _snprintf(name, sizeof(name), "nelts 0x%x", desc.nelts);
731 _snprintf(name, sizeof(name), "nelts 0%o", desc.nelts);
734 _snprintf(name, sizeof(name), "nelts %d", desc.nelts);
736 _tcsncat(pResult, name, max);
739 } /* format_arr_descr */
742 * format a firm object
744 HRESULT FormatFirmObject(DEBUGHELPER *pHelper, int nBase, firm_kind kind, const void *addr, char *pResult, size_t max)
747 case k_entity: /* an entity */
748 return format_entity(pHelper, nBase, addr, pResult, max, 1);
749 case k_type: /* a type */
750 return format_type(pHelper, nBase, addr, pResult, max, 1);
751 case k_ir_graph: /* an ir graph */
752 return format_irg(pHelper, nBase, addr, pResult, max, 1);
753 case k_ir_node: /* an ir node */
754 return format_node(pHelper, nBase, addr, pResult, max, 1);
755 case k_ir_mode: /* an ir mode */
756 return format_mode(pHelper, addr, pResult, max);
757 case k_ir_op: /* an ir opcode */
758 return format_op(pHelper, addr, pResult, max);
759 case k_tarval: /* a tarval */
760 return format_tarval(pHelper, nBase, addr, pResult, max);
761 case k_ir_loop: /* a loop */
762 return format_loop(pHelper, addr, pResult, max);
763 case k_ir_compound_graph_path: /* a compound graph path, see entity.h */
765 case k_ir_extblk: /* an extended block */
766 return format_extblk(pHelper, nBase, addr, pResult, max);
767 case k_ir_prog: /* a program representation (irp) */
768 return format_prog(pHelper, nBase, addr, pResult, max);
772 } /* FormatFirmObject */
774 #define SEGMENT_SIZE_SHIFT 8
775 #define SEGMENT_SIZE (1 << SEGMENT_SIZE_SHIFT)
776 #define DIRECTORY_SIZE_SHIFT 8
777 #define DIRECTORY_SIZE (1 << DIRECTORY_SIZE_SHIFT)
778 #define MAX_LOAD_FACTOR 4
780 typedef struct pset_element {
781 struct pset_element *chain; /**< for chaining Elements */
783 } pset_Element, *pset_Segment;
785 /* not visible from outside */
787 unsigned p; /**< Next bucket to be split */
788 unsigned maxp; /**< upper bound on p during expansion */
789 unsigned nkey; /**< current # keys */
790 unsigned nseg; /**< current # segments */
791 pset_Segment *dir[DIRECTORY_SIZE];
792 int (*cmp)(); /**< function comparing entries */
793 unsigned iter_i, iter_j;
794 pset_Element *iter_tail; /**< non-NULL while iterating over elts */
795 pset_Element *free_list; /**< list of free Elements */
796 struct obstack obst; /**< obstack for allocation all data */
798 int naccess, ncollision, ndups;
802 const char *tag; /**< an optionally tag for distinguishing sets */
806 typedef struct set_element {
807 struct set_element *chain; /**< for chaining Elements */
809 } set_Element, *set_Segment;
811 /* not visible from outside */
813 unsigned p; /**< Next bucket to be split */
814 unsigned maxp; /**< upper bound on p during expansion */
815 unsigned nkey; /**< current # keys */
816 unsigned nseg; /**< current # segments */
817 set_Segment *dir[DIRECTORY_SIZE];
818 int (*cmp)(); /**< function comparing entries */
819 unsigned iter_i, iter_j;
820 set_Element *iter_tail; /**< non-NULL while iterating over elts */
821 struct obstack obst; /**< obstack for allocation all data */
823 int naccess, ncollision, ndups;
827 const char *tag; /**< an optionally tag for distinguishing sets */
832 * Find the longest chain of a pset
834 static HRESULT find_longest_pset_chain(DEBUGHELPER *pHelper, pset *set,
835 int *chains, int *lenght, size_t *size) {
837 pset_Segment *seg, *curr;
840 int len, nchains = 0, max_len = 0;
843 for (i = 0; i < set->nseg; ++i) {
846 dyns += sizeof(seg[j]) * SEGMENT_SIZE;
847 for (j = 0; j < SEGMENT_SIZE; ++j) {
848 if (copy_from_debuggee(&seg[j], pHelper, &curr, sizeof(curr)) != S_OK)
854 for (len = 0; address != NULL; address = elem.chain) {
855 if (copy_from_debuggee(address, pHelper, &elem, sizeof(elem)) != S_OK)
857 dyns += sizeof(pset_Element);
869 } /* find_longest_pset_chain */
872 * Find the longest chain of a set
874 static HRESULT find_longest_set_chain(DEBUGHELPER *pHelper, set *set,
875 int *chains, int *lenght, size_t *size) {
877 set_Segment *seg, *curr;
880 int len, nchains = 0, max_len = 0;
883 for (i = 0; i < set->nseg; ++i) {
886 dyns += sizeof(seg[j]) * SEGMENT_SIZE;
887 for (j = 0; j < SEGMENT_SIZE; ++j) {
888 if (copy_from_debuggee(&seg[j], pHelper, &curr, sizeof(curr)) != S_OK)
894 for (len = 0; address != NULL; address = elem.chain) {
895 if (copy_from_debuggee(address, pHelper, &elem, sizeof(elem)) != S_OK)
897 dyns += offsetof(set_Element, entry.dptr) + elem.entry.size;
909 } /* find_longest_set_chain */
914 HRESULT format_pset(DEBUGHELPER *pHelper, int nBase, const void *address, char *pResult, size_t max)
918 int nchains, chain_len;
921 if (copy_from_debuggee(address, pHelper, &set, sizeof(set)) != S_OK)
924 if (find_longest_pset_chain(pHelper, &set, &nchains, &chain_len, &size) != S_OK)
929 _snprintf(name, sizeof(name), "nkey 0x%x nseg 0x%x nchain 0x%x maxlen 0x%x size %u kB", set.nkey, set.nseg, nchains, chain_len, (size + 1023) >> 10);
932 _snprintf(name, sizeof(name), "nkey 0%o nseg 0%o nchain 0%o maxlen 0%o size %u kB", set.nkey, set.nseg, nchains, chain_len, (size + 1023) >> 10);
935 _snprintf(name, sizeof(name), "nkey %u nseg %d nchain %d maxlen %d size %u kB", set.nkey, set.nseg, nchains, chain_len, (size + 1023) >> 10);
937 _tcsncpy(pResult, name, max);
945 HRESULT format_set(DEBUGHELPER *pHelper, int nBase, const void *address, char *pResult, size_t max)
949 int nchains, chain_len;
952 if (copy_from_debuggee(address, pHelper, &set, sizeof(set)) != S_OK)
955 if (find_longest_set_chain(pHelper, &set, &nchains, &chain_len, &size) != S_OK)
960 _snprintf(name, sizeof(name), "nkey 0x%x nseg 0x%x nchain 0x%x maxlen 0x%x size %u kB", set.nkey, set.nseg, nchains, chain_len, (size + 1023) >> 10);
963 _snprintf(name, sizeof(name), "nkey 0%o nseg 0%o nchain 0%o maxlen 0%o size %u kB", set.nkey, set.nseg, nchains, chain_len, (size + 1023) >> 10);
966 _snprintf(name, sizeof(name), "nkey %u nseg %d nchain %d maxlen %d size %u kB", set.nkey, set.nseg, nchains, chain_len, (size + 1023) >> 10);
968 _tcsncpy(pResult, name, max);
974 unsigned magic; /**< debug magic, only available in DEBUG builds */
975 pdeq *l_end, *r_end; /**< left and right ends of the queue */
976 pdeq *l, *r; /**< left and right neighbor */
977 int n; /**< number of elements in the current chunk */
978 int p; /**< the read/write pointer */
979 const void *data[1]; /**< storage for elements */
982 /** Returns the length of a double ended pointer list. */
983 static int get_pdeq_len(DEBUGHELPER *pHelper, pdeq *dq)
992 if (copy_from_debuggee(q, pHelper, &pdeq, sizeof(pdeq)) != S_OK)
1002 if (copy_from_debuggee(q, pHelper, &pdeq, sizeof(pdeq)) != S_OK)
1008 } /* get_pdeq_len */
1013 HRESULT format_pdeq(DEBUGHELPER *pHelper, int nBase, const void *address, char *pResult, size_t max)
1019 if (copy_from_debuggee(address, pHelper, &pdeq, sizeof(pdeq)) != S_OK)
1022 len = get_pdeq_len(pHelper, &pdeq);
1028 _snprintf(name, sizeof(name), "pdeq 0x%x elem", len);
1031 _snprintf(name, sizeof(name), "pdeq 0%o elem", len);
1034 _snprintf(name, sizeof(name), "pdeq %d elem", len);
1036 _tcsncpy(pResult, name, max);
1041 /** show the first 2 units */
1042 static HRESULT fill_bits(DEBUGHELPER *pHelper, bitset_t *bs, char *pResult) {
1043 bitset_pos_t i, units = bs->units;
1044 int l = 0, o = 0, breaked = 0;
1047 for (i = 0; i < units; ++i) {
1050 if (copy_from_debuggee((void *)(BS_DATA(bs)[i]), pHelper, &data, sizeof(data)) != S_OK)
1053 for (j = 0; j < 32; ++j) {
1054 if (data & (1 << j)) {
1055 sprintf(pResult + l, "%d,", i * sizeof(data) * 8 + j);
1056 l += strlen(pResult + l);
1067 sprintf(pResult + l, "...");
1070 sprintf(pResult + l, "}");
1077 HRESULT format_bitset(DEBUGHELPER *pHelper, int nBase, const void *address, char *pResult, size_t max)
1083 if (copy_from_debuggee(address, pHelper, &bs, sizeof(bs)) != S_OK)
1088 _snprintf(name, sizeof(name), "bitset{0x%x:", bs.size);
1091 _snprintf(name, sizeof(name), "bitset{0%o:", bs.size);
1094 _snprintf(name, sizeof(name), "bitset{%u:", bs.size);
1098 if (fill_bits(pHelper, &bs, &name[l]) != S_OK)
1102 _tcsncpy(pResult, name, max);
1105 } /* format_bitset */