Esempio n. 1
0
API_TEST_API int __stdcall mangle_simple_struct(simple_struct *x) {
	char *tmp;

	simple_struct mine;

	mine.a = 5;
	mine.b = 2.5;
	mine.c = NULL;

	dump_struct("mine", &mine);
	dump_struct("yours", x);

	x->a /= 2;
	x->b *= 2;

/*	tmp = (char *) malloc(strlen(x->c)); */
	tmp = x->c;
	printf("x.a=%d\n", x->a);
	printf("x.b=%f\n", x->b);
	printf("x.c=0x%08x\n", x->c);
	printf("x.c='%s'\n", x->c);
	// return 1;
	while(tmp[0] != 0) {
		printf("char='%c' toupper='%c'\n", tmp[0], toupper(tmp[0]));
		tmp[0] = toupper(tmp[0]);
		tmp++;
	}
	return 1;
}
Esempio n. 2
0
int main(int argc, char *argv[]) {
	test_struct v1 = { 0, 123 };  /* default is to initialize first alternative */
	test_struct v2 = { 0, { .a = 234 } };
	test_struct v3 = { 1, { .b = 123.456 } };
	test_struct v4 = { 2, { .c = "foo" } };

	dump_struct(&v1);
	dump_struct(&v2);
	dump_struct(&v3);
	dump_struct(&v4);
}
Esempio n. 3
0
void
sigsegv_handler (int sig)
{
  char **messages;
  FILE *fp = stderr;
  int pid = getpid ();
  size_t size, i;
  void *trace_stack[TRACE_SIZE];

  (void) endwin ();
  fprintf (fp, "\n==%d== GoAccess %s crashed by Signal %d\n", pid, GO_VERSION,
           sig);
  fprintf (fp, "==%d==\n", pid);

  dump_struct (fp);

  size = backtrace (trace_stack, TRACE_SIZE);
  messages = backtrace_symbols (trace_stack, size);

  fprintf (fp, "==%d== STACK TRACE:\n", pid);
  fprintf (fp, "==%d==\n", pid);

  for (i = 0; i < size; i++)
    fprintf (fp, "==%d== %zu %s\n", pid, i, messages[i]);

  fprintf (fp, "==%d==\n", pid);
  fprintf (fp, "==%d== Please report it by opening an issue on GitHub:\n", pid);
  fprintf (fp, "==%d== https://github.com/allinurl/goaccess/issues\n\n", pid);
  exit (EXIT_FAILURE);
}
void itdb_sysinfo_properties_dump (SysInfoIpodProperties *props)
{
    dump_struct (sysinfo_ipod_properties_fields_mapping, props);
    g_list_foreach (props->artwork_formats, (GFunc)dump_image_format, NULL);
    g_list_foreach (props->photo_formats, (GFunc)dump_image_format, NULL);
    g_list_foreach (props->chapter_image_formats, (GFunc)dump_image_format, NULL);
}
Esempio n. 5
0
/**
 * dump all static variables
 */
void dumpglbs(void) {
    int dim, i, list_size, line_count, value;
    if (!glbflag)
        return;
    current_symbol_table_idx = rglobal_table_index;
    while (current_symbol_table_idx < global_table_index) {
        SYMBOL *symbol = &symbol_table[current_symbol_table_idx];
        if (symbol->identity != FUNCTION) {
            ppubext(symbol);
            if (symbol->storage != EXTERN) {
                output_string(symbol->name);
                output_label_terminator();
                dim = symbol->offset;
                list_size = 0;
                line_count = 0;
                if (find_symbol_initials(symbol->name)) { // has initials
                    list_size = get_size(symbol->name);
                    if (dim == -1) {
                        dim = list_size;
                    }
                }
                for (i=0; i<dim; i++) {
                    if (symbol->type == STRUCT) {
                        dump_struct(symbol, i);
                    } else {
                        if (line_count % 10 == 0) {
                            newline();
                            if ((symbol->type & CINT) || (symbol->identity == POINTER)) {
                                gen_def_word();
                            } else {
                                gen_def_byte();
                            }
                        }
                        if (i < list_size) {
                            // dump data
                            value = get_item_at(symbol->name, i, &tag_table[symbol->tagidx]);
                            output_number(value);
                        } else {
                            // dump zero, no more data available
                            output_number(0);
                        }
                        line_count++;
                        if (line_count % 10 == 0) {
                            line_count = 0;
                        } else {
                            if (i < dim-1) {
                                output_byte( ',' );
                            }
                        }
                    }
                }
                newline();
            }
        } else {
            fpubext(symbol);
        }
        current_symbol_table_idx++;
    }
}
Esempio n. 6
0
int main(int argc, const char *argv[]) {

  printf("Struct before modifiction:\n");
  memset(&global_foo, 0, sizeof(global_foo));

  dump_struct(&global_foo);

  if(argc % 2 == 0) {
    printf("Not adding to variables\n");
  } else {
    global_foo.u64 += argc;
    global_foo.u32 += argc;
    global_foo.u16 += argc;
    global_foo.u8  += argc;
  }

  printf("Struct after modifiction:\n");
  dump_struct(&global_foo);

  return 0;

}
Esempio n. 7
0
void
dump_struct(Symbol *z, char *prefix, RunList *r)
{	Lextok *fp, *tl;
	char eprefix[256];
	int ix, jx;

	ini_struct(z);

	for (ix = 0; ix < z->nel; ix++)
	{	if (z->nel > 1)
			sprintf(eprefix, "%s[%d]", prefix, ix);
		else
			strcpy(eprefix, prefix);
		
		for (fp = z->Sval[ix]; fp; fp = fp->rgt)
		for (tl = fp->lft; tl; tl = tl->rgt)
		{	if (tl->sym->type == STRUCT)
			{	char pref[256];
				strcpy(pref, eprefix);
				strcat(pref, ".");
				strcat(pref, tl->sym->name);
				dump_struct(tl->sym, pref, r);
			} else
			for (jx = 0; jx < tl->sym->nel; jx++)
			{	if (tl->sym->type == CHAN)
					doq(tl->sym, jx, r);
				else
				{	printf("\t\t");
					if (r)
					printf("%s(%d):", r->n->name, r->pid);
					printf("%s.%s", eprefix, tl->sym->name);
					if (tl->sym->nel > 1)
						printf("[%d]", jx);
					printf(" = ");
					sr_mesg(stdout, tl->sym->val[jx],
						tl->sym->type == MTYPE);
					printf("\n");
		}	}	}
	}
}
Esempio n. 8
0
void split_heap(heap_header_t* heap, size_t size){
	heap_footer_t* foot = (heap_footer_t*) ((uint) heap + HEAP_S + size);
	foot->magic = KHEAP_MAGIC;
	foot->magic2 = KHEAP_MAGIC2;
	foot->size = size;
	
	size_t new_size = heap->size - HEAP_TOTAL - size;
	heap->size = size;

	heap = (heap_header_t*) ((uint) foot + sizeof(heap_footer_t));
	heap->size = new_size;
	heap->free = TRUE;
	heap->magic = KHEAP_MAGIC;
	heap->magic2 = KHEAP_MAGIC2;

	foot = (heap_footer_t*) ((uint) heap + HEAP_S + heap->size);
	if((foot->magic != KHEAP_MAGIC) || (foot->magic2 != KHEAP_MAGIC2)){
		WARN("invalid footer in split");
		dump_struct(foot, sizeof(heap_footer_t));
	}
	
	if(foot->size != KHEAP_END)
		foot->size = new_size;
}
Esempio n. 9
0
/*
 *	dump all static variables
 */
void dumpglbs (void)
{
	long i = 1;
	int dim, list_size, line_count;
	int j;
	FILE *save = output;

	if (!data)
		data = fmemopen(data_buf, DATABUFSIZE, "w");
	if (!rodata)
		rodata = fmemopen(rodata_buf, DATABUFSIZE, "w");

	/* This is done in several passes:
	   Pass 0: Dump initialization data into const bank.
	   Pass 1: Define space for uninitialized data.
	   Pass 2: Define space for initialized data.
	 */
	if (glbflag) {
		int pass = 0;
next:
		i = 1;
		for (cptr = rglbptr; cptr < glbptr; cptr++) {
			if (cptr->ident != FUNCTION) {
//				ppubext(cptr);
				if ((cptr->storage & WRITTEN) == 0 &&	/* Not yet written to file */
				    cptr->storage != EXTERN) {
					dim = cptr->offset;
					if (find_symbol_initials(cptr->name)) {
						// has initials
						/* dump initialization data */
						if (pass == 1)	/* initialized data not handled in pass 1 */
							continue;
						else if (pass == 2) {
							/* define space for initialized data */
							output = data;
							if (cptr->storage != LSTATIC)
								prefix();
							outstr(cptr->name);
							outstr(":\t");
							defstorage();
							outdec(cptr->size);
							nl();
							cptr->storage |= WRITTEN;
							output = save;
							continue;
						}
						/* output initialization data into const bank */
						output = rodata;
						have_init_data = 1;
						list_size = 0;
						line_count = 0;
						list_size = get_size(cptr->name);
						if (cptr->type == CSTRUCT)
							list_size /= tag_table[cptr->tagidx].number_of_members;
						if (dim == -1)
							dim = list_size;
						int item;
						/* dim is an item count for non-compound types and a byte size
						   for compound types; dump_struct() wants an item number, so
						   we have to count both to get the right members out. */
						for (j = item = 0; j < dim; j++, item++) {
							if (cptr->type == CSTRUCT)
								j += dump_struct(cptr, item) - 1;
							else {
								if (line_count % 10 == 0) {
									nl();
									if (cptr->type == CCHAR || cptr->type == CUCHAR)
										defbyte();
									else
										defword();
								}
								if (j < list_size) {
									// dump data
									int value = get_item_at(cptr->name, j, &tag_table[cptr->tagidx]);
									outdec(value);
								}
								else {
									// dump zero, no more data available
									outdec(0);
								}
								line_count++;
								if (line_count % 10 == 0)
									line_count = 0;
								else {
									if (j < dim - 1)
										outbyte(',');
								}
							}
						}
						nl();
						output = save;
					}
					else {
						if (pass == 0)
							continue;
						/* define space in bss */
						if (i) {
							i = 0;
							nl();
							gdata();
						}
						if (cptr->storage != LSTATIC)
							prefix();
						outstr(cptr->name);
						outstr(":\t");
						defstorage();
						outdec(cptr->size);
						nl();
						cptr->storage |= WRITTEN;
					}
				}
			}
			else {
//				fpubext(cptr);
			}
		}
		if (++pass < 3)
			goto next;
	}
	if (i) {
		nl();
		gdata();
	}
	output = save;
}
Esempio n. 10
0
int
main(int argc, char **argv)
{
    XPTArena *arena;
    XPTState *state;
    XPTCursor curs, *cursor = &curs;
    char *header, *data, *whole;
    uint32_t hlen, dlen, i;

    TRY("XPT_NewArena", (arena = XPT_NewArena(1024, sizeof(double), "main")));
    
    TRY("NewState (ENCODE)", (state = XPT_NewXDRState(XPT_ENCODE, NULL, 0)));

    XPT_SetDataOffset(state, sizeof input);

    TRY("MakeCursor", XPT_MakeCursor(state, XPT_HEADER, sizeof input, cursor));

    dump_struct("before", &input);

    if (XDR(arena, cursor, &input))
	return 1;

    fprintf(stderr, "ENCODE successful\n");
    XPT_GetXDRData(state, XPT_HEADER, &header, &hlen);
    fprintf(stderr, "XDR header %d bytes at %p:",
	    hlen, header);
    for (i = 0; i < hlen; i++)
	fprintf(stderr, "%c%02x", i ? ',' : ' ', (uint8_t)header[i]);
    fprintf(stderr, "\n");

    XPT_GetXDRData(state, XPT_DATA, &data, &dlen);

    fprintf(stderr, "XDR data %d bytes at %p:",
	    dlen, data);
    for (i = 0; i < dlen; i++)
	fprintf(stderr, "%c%02x/%c", i ? ',' : ' ', (uint8_t)data[i],
		(uint8_t)data[i]);
    fprintf(stderr, "\n");

    whole = malloc(dlen + hlen);
    if (!whole) {
	fprintf(stderr, "malloc %d failed!\n", dlen + hlen);
	return 1;
    }

    /* TRY_Q("malloc", (data2 = malloc(len))); */
    memcpy(whole, header, hlen);
    memcpy(whole + hlen, data, dlen);
    XPT_DestroyXDRState(state);

    TRY("NewState (DECODE)", (state = XPT_NewXDRState(XPT_DECODE, whole,
						      hlen + dlen)));

    TRY("MakeCursor", XPT_MakeCursor(state, XPT_HEADER, sizeof input, cursor));
    XPT_SetDataOffset(state, sizeof input);

    if (XDR(arena, cursor, &output))
	return 1;
    
    dump_struct("after", &output);
    XPT_DestroyXDRState(state);
    XPT_DestroyArena(arena);
    free(whole);

    return 0;
}
static void dump_image_format (Itdb_ArtworkFormat *format)
{
    dump_struct (sysinfo_image_format_fields_mapping, format);
    g_print ("PixelFormat: %d\n", format->format); 
}