65
65
Process* p = process_tab[i];
67
67
if (p->status != P_GARBING) {
68
dump_process_info(p, to);
68
dump_process_info(to, to_arg, p);
74
dump_binaries(all_binaries, to);
74
dump_binaries(to, to_arg, all_binaries);
78
dump_process_info(Process *p, CIO to)
78
dump_process_info(int to, void *to_arg, Process *p)
85
ERTS_SMP_MSGQ_MV_INQ2PRIVQ(p);
84
87
if (p->msg.first) {
85
erl_printf(to, "=proc_messages:");
88
erts_print(to, to_arg, "=proc_messages:%T\n", p->id);
88
89
for (mp = p->msg.first; mp != NULL; mp = mp->next) {
89
90
Eterm mesg = ERL_MESSAGE_TERM(mp);
90
dump_element(mesg, to);
91
dump_element(to, to_arg, mesg);
91
92
mesg = ERL_MESSAGE_TOKEN(mp);
93
dump_element(mesg, to);
93
erts_print(to, to_arg, ":");
94
dump_element(to, to_arg, mesg);
95
erts_print(to, to_arg, "\n");
98
99
if (p->dictionary) {
99
erl_printf(to, "=proc_dictionary:");
101
erl_printf(to, "\n");
102
erts_deep_dictionary_dump(p->dictionary, dump_element_nl, to);
100
erts_print(to, to_arg, "=proc_dictionary:%T\n", p->id);
101
erts_deep_dictionary_dump(to, to_arg,
102
p->dictionary, dump_element_nl);
105
105
if (p->debug_dictionary) {
106
erl_printf(to, "=debug_proc_dictionary:");
108
erl_printf(to, "\n");
109
erts_deep_dictionary_dump(p->debug_dictionary, dump_element_nl, to);
106
erts_print(to, to_arg, "=debug_proc_dictionary:%T\n", p->id);
107
erts_deep_dictionary_dump(to, to_arg,
108
p->debug_dictionary, dump_element_nl);
112
erl_printf(to, "=proc_stack:");
114
erl_printf(to, "\n");
111
erts_print(to, to_arg, "=proc_stack:%T\n", p->id);
116
113
for (sp = p->stop; sp < STACK_START(p); sp++) {
117
yreg = stack_element_dump(p, sp, yreg, to);
120
erl_printf(to, "=proc_heap:");
122
erl_printf(to, "\n");
114
yreg = stack_element_dump(to, to_arg, p, sp, yreg);
117
erts_print(to, to_arg, "=proc_heap:%T\n", p->id);
119
#ifndef HYBRID /* FIND ME! */
121
* We dump funs in the external format. Therefore, we must be sure
122
* sure that any part of the heap referenced by the funs's environments
123
* have not been destroyed. Dump the funs now.
125
for (fptr = MSO(p).funs; fptr != 0; fptr = fptr->next) {
126
erts_print(to, to_arg, ADDR_FMT ":", fptr);
127
dump_externally(to, to_arg, make_fun((Eterm)fptr));
128
erts_putc(to, to_arg, '\n');
129
* (Eterm *) fptr = OUR_NIL;
124
133
for (sp = p->stop; sp < STACK_START(p); sp++) {
125
134
Eterm term = *sp;
127
136
if (!is_catch(term) && !is_CP(term)) {
137
heap_dump(to, to_arg, term);
132
141
for (mp = p->msg.first; mp != NULL; mp = mp->next) {
133
142
Eterm mesg = ERL_MESSAGE_TERM(mp);
143
heap_dump(to, to_arg, mesg);
135
144
mesg = ERL_MESSAGE_TOKEN(mp);
145
heap_dump(to, to_arg, mesg);
139
148
if (p->dictionary) {
140
erts_deep_dictionary_dump(p->dictionary, heap_dump, to);
149
erts_deep_dictionary_dump(to, to_arg, p->dictionary, heap_dump);
143
152
if (p->debug_dictionary) {
144
erts_deep_dictionary_dump(p->debug_dictionary, heap_dump, to);
153
erts_deep_dictionary_dump(to, to_arg, p->debug_dictionary, heap_dump);
149
dump_element(Eterm x, CIO fd)
158
dump_element(int to, void *to_arg, Eterm x)
151
160
if (is_list(x)) {
152
sys_printf(fd, "H" WORD_FMT, list_val(x));
161
erts_print(to, to_arg, "H" WORD_FMT, list_val(x));
153
162
} else if (is_boxed(x)) {
154
sys_printf(fd, "H" WORD_FMT, boxed_val(x));
163
erts_print(to, to_arg, "H" WORD_FMT, boxed_val(x));
155
164
} else if (is_immed(x)) {
156
165
if (is_atom(x)) {
157
char* s = atom_tab(atom_val(x))->name;
166
unsigned char* s = atom_tab(atom_val(x))->name;
158
167
int len = atom_tab(atom_val(x))->len;
161
sys_printf(fd, "A%X:", atom_tab(atom_val(x))->len);
170
erts_print(to, to_arg, "A%X:", atom_tab(atom_val(x))->len);
162
171
for (i = 0; i < len; i++) {
172
erts_putc(to, to_arg, *s++);
165
174
} else if (is_small(x)) {
175
erts_print(to, to_arg, "I%T", x);
168
176
} else if (is_pid(x)) {
177
erts_print(to, to_arg, "P%T", x);
171
178
} else if (is_port(x)) {
172
erl_printf(fd, "p<%lu.%lu>",
173
(unsigned long) port_channel_no(x),
174
(unsigned long) port_number(x));
179
erts_print(to, to_arg, "p<%bpu.%bpu>",
180
port_channel_no(x), port_number(x));
175
181
} else if (is_nil(x)) {
182
erts_putc(to, to_arg, 'N');
182
dump_element_nl(Eterm x, CIO fd)
188
dump_element_nl(int to, void *to_arg, Eterm x)
190
dump_element(to, to_arg, x);
191
erts_putc(to, to_arg, '\n');
190
stack_element_dump(Process* p, Eterm* sp, int yreg, CIO fd)
196
stack_element_dump(int to, void *to_arg, Process* p, Eterm* sp, int yreg)
194
200
if (yreg < 0 || is_CP(x)) {
195
erl_printf(fd, "%p:", sp);
201
erts_print(to, to_arg, "%p:", sp);
197
sys_printf(fd, "y%d:", yreg);
203
erts_print(to, to_arg, "y%d:", yreg);
202
sys_printf(fd, "SReturn addr 0x%X (", (Eterm *) x);
203
print_function_from_pc(cp_val(x), fd);
204
sys_printf(fd, ")\n");
208
erts_print(to, to_arg, "SReturn addr 0x%X (", (Eterm *) x);
209
print_function_from_pc(to, to_arg, cp_val(x));
210
erts_print(to, to_arg, ")\n");
206
212
} else if is_catch(x) {
207
sys_printf(fd, "SCatch 0x%X (", catch_pc(x));
208
print_function_from_pc(catch_pc(x), fd);
209
sys_printf(fd, ")\n");
213
erts_print(to, to_arg, "SCatch 0x%X (", catch_pc(x));
214
print_function_from_pc(to, to_arg, catch_pc(x));
215
erts_print(to, to_arg, ")\n");
217
dump_element(to, to_arg, x);
218
erts_putc(to, to_arg, '\n');
218
print_function_from_pc(Eterm* x, CIO fd)
224
print_function_from_pc(int to, void *to_arg, Eterm* x)
220
226
Eterm* addr = find_function_from_pc(x);
221
227
if (addr == NULL) {
222
228
if (x == beam_exit) {
223
sys_printf(fd, "<terminate process>");
229
erts_print(to, to_arg, "<terminate process>");
224
230
} else if (x == beam_apply+1) {
225
sys_printf(fd, "<terminate process normally>");
231
erts_print(to, to_arg, "<terminate process normally>");
227
sys_printf(fd, "unknown function");
233
erts_print(to, to_arg, "unknown function");
230
display(addr[0], fd);
232
display(addr[1], fd);
233
sys_printf(fd, "/%d", addr[2]);
234
sys_printf(fd, " + %d", ((x-addr)-2) * sizeof(Eterm));
236
erts_print(to, to_arg, "%T:%T/%bpu + %bpu",
237
addr[0], addr[1], addr[2], ((x-addr)-2) * sizeof(Eterm));
239
heap_dump(Eterm x, CIO fd)
242
heap_dump(int to, void *to_arg, Eterm x)
242
245
Eterm last = OUR_NIL;
383
dump_binaries(Binary* current, CIO fd)
380
dump_binaries(int to, void *to_arg, Binary* current)
385
382
while (current) {
387
384
long size = current->orig_size;
388
byte* bytes = current->orig_bytes;
385
byte* bytes = (byte*) current->orig_bytes;
390
sys_printf(fd, "=binary:%X\n", current);
391
sys_printf(fd, "%X:", size);
387
erts_print(to, to_arg, "=binary:%X\n", current);
388
erts_print(to, to_arg, "%X:", size);
392
389
for (i = 0; i < size; i++) {
393
sys_printf(fd, "%02X", bytes[i]);
390
erts_print(to, to_arg, "%02X", bytes[i]);
392
erts_putc(to, to_arg, '\n');
396
393
current = (Binary *) current->flags;
401
dump_externally(Eterm term, CIO fd)
398
dump_externally(int to, void *to_arg, Eterm term)
400
byte sbuf[1024]; /* encode and hope for the best ... */
408
erts_to_external_format(0, term, &p);
409
sys_printf(fd, "E%X:", p-s);
405
erts_to_external_format(NULL, term, &p, NULL, NULL);
406
erts_print(to, to_arg, "E%X:", p-s);
411
sys_printf(fd, "%02X", *s++);
408
erts_print(to, to_arg, "%02X", *s++);