From 86471f8b72d2a6ac8f6078b92f701da1eeab2525 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 Jan 2008 14:53:44 +0000 Subject: [PATCH] Split guardedalloc print into 2 funcs, 1 that prints on errors, another then prints the memory blocks as a python dict, minor changes to help text --- intern/guardedalloc/MEM_guardedalloc.h | 6 +++++- intern/guardedalloc/intern/mallocn.c | 29 +++++++++++++++++++------- source/blender/src/editscreen.c | 2 +- source/creator/creator.c | 23 ++++++++++++++------ 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index 26a9258d03b..94276c0454a 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -99,10 +99,14 @@ extern "C" { * */ void *MEM_mapallocN(unsigned int len, const char * str); + /** Print a list of the names and sizes of all allocated memory + * blocks. as a python dict for easy investigation */ + void MEM_printmemlist_pydict(void); + /** Print a list of the names and sizes of all allocated memory * blocks. */ void MEM_printmemlist(void); - + /** Set the callback function for error output. */ void MEM_set_error_callback(void (*func)(char *)); diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c index 44909bbea54..413f4d80514 100644 --- a/intern/guardedalloc/intern/mallocn.c +++ b/intern/guardedalloc/intern/mallocn.c @@ -334,7 +334,7 @@ void *MEM_mapallocN(unsigned int len, const char *str) /* Prints in python syntax for easy */ -void MEM_printmemlist() +static void MEM_printmemlist_internal( int pydict ) { MemHead *membl; @@ -343,16 +343,23 @@ void MEM_printmemlist() membl = membase->first; if (membl) membl = MEMNEXT(membl); - print_error("# membase_debug.py\n"); - print_error("membase = [\\\n"); + if (pydict) { + print_error("# membase_debug.py\n"); + print_error("membase = [\\\n"); + } while(membl) { - fprintf(stderr, "{'len':%i, 'name':'''%s''', 'pointer':'%p'},\\\n", membl->len, membl->name, membl+1); + if (pydict) { + fprintf(stderr, "{'len':%i, 'name':'''%s''', 'pointer':'%p'},\\\n", membl->len, membl->name, membl+1); + } else { + print_error("%s len: %d %p\n",membl->name,membl->len, membl+1); + } if(membl->next) membl= MEMNEXT(membl->next); else break; } - fprintf(stderr, "]\n\n"); - fprintf(stderr, + if (pydict) { + fprintf(stderr, "]\n\n"); + fprintf(stderr, "mb_userinfo = {}\n" "totmem = 0\n" "for mb_item in membase:\n" @@ -367,11 +374,19 @@ void MEM_printmemlist() "\tmb_userinfo_sort.sort(key = sort_func)\n" "\tfor item in mb_userinfo_sort:\n" "\t\tprint 'name:%%s, users:%%i, len:%%i' %% (item[0], item[1][0], item[1][1])\n" - ); + ); + } mem_unlock_thread(); } +void MEM_printmemlist( void ) { + MEM_printmemlist_internal(0); +} +void MEM_printmemlist_pydict( void ) { + MEM_printmemlist_internal(1); +} + short MEM_freeN(void *vmemh) /* anders compileertie niet meer */ { short error = 0; diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c index 43d163bff09..2d6cc99b1ce 100644 --- a/source/blender/src/editscreen.c +++ b/source/blender/src/editscreen.c @@ -1399,7 +1399,7 @@ void screenmain(void) else if (event==QKEY) { /* Temp place to print mem debugging info ctrl+alt+shift + qkey */ if ( G.qual == (LR_SHIFTKEY | LR_ALTKEY | LR_CTRLKEY) ) { - MEM_printmemlist(); + MEM_printmemlist_pydict(); } else if((G.obedit && G.obedit->type==OB_FONT && g_activearea->spacetype==SPACE_VIEW3D)||g_activearea->spacetype==SPACE_TEXT||g_activearea->spacetype==SPACE_SCRIPT); diff --git a/source/creator/creator.c b/source/creator/creator.c index 879bbbd386f..9b5a151b56b 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -176,8 +176,10 @@ static void print_help(void) printf (" ...may not render to /tmp because '-f 1' renders before the output path is set\n"); printf (" blender -b -o /tmp test.blend -f 1\n"); printf (" ...may not render to /tmp because loading the blend file overwrites the output path that was set\n"); + printf (" \"blender -b test.blend -o /tmp -f 1\" works as expected.\n"); printf ("\nRender options:\n"); printf (" -b \tRender in background\n"); + printf (" -a render frames from start to end (inclusive), only works when used after -b\n"); printf (" -S \tSet scene \n"); printf (" -f \tRender frame and save it\n"); printf (" -s \tSet start to frame (use with -a)\n"); @@ -186,16 +188,25 @@ static void print_help(void) printf (" Use // at the start of the path to\n"); printf (" render relative to the blend file.\n"); printf (" The frame number will be added at the end of the filename.\n"); - printf (" eg: blender -b foobar.blend -o //render_ -F PNG -x 1\n"); - printf (" -F \tSet the render format, Valid options are..\n"); + printf (" eg: blender -b foobar.blend -o //render_ -F PNG -x 1 -a\n"); + printf ("\nFormat options:\n"); + printf (" -F \tSet the render format, Valid options are...\n"); printf (" \tTGA IRIS HAMX JPEG MOVIE IRIZ RAWTGA\n"); printf (" \tAVIRAW AVIJPEG PNG BMP FRAMESERVER\n"); printf (" (formats that can be compiled into blender, not available on all systems)\n"); printf (" \tHDR TIFF EXR MPEG AVICODEC QUICKTIME CINEON DPX DDS\n"); printf (" -x \tSet option to add the file extension to the end of the file.\n"); printf (" -t \tUse amount of for rendering\n"); - printf ("\nAnimation options:\n"); - printf (" -a \tPlayback \n"); + /*Add these later - Campbell*/ + /* + printf (" -colorchannel \tColors to save, valid types are: BW RGB RGBA \n"); + printf (" -compression \t Use with EXR format, valid types are..\n"); + printf (" \tZIP Pxr24 PIZ RLE\n"); + printf (" -zbuf \tUse with EXR format, set the zbuf save option\n"); + printf (" -halffloat \tUse with EXR format, set the half float option\n"); + printf (" -preview \tUse with EXR format, save a jpeg for viewing as well as the EXR\n");*/ + printf ("\nAnimation playback options:\n"); + printf (" -a \tPlayback , only operates this way when -b is not used.\n"); printf (" -p \tOpen with lower left corner at , \n"); printf (" -m\t\tRead from disk (Don't buffer)\n"); printf (" -f \t\tSpecify FPS to start with\n"); @@ -337,7 +348,7 @@ int main(int argc, char **argv) /* Handle -* switches */ else if(argv[a][0] == '-') { switch(argv[a][1]) { - case 'a': + case 'a': /* -b was not given, play an animation */ playanim(argc-1, argv+1); exit(0); break; @@ -662,7 +673,7 @@ int main(int argc, char **argv) else if (!strcmp(argv[a],"FRAMESERVER")) G.scene->r.imtype = R_FRAMESERVER; else if (!strcmp(argv[a],"CINEON")) G.scene->r.imtype = R_CINEON; else if (!strcmp(argv[a],"DPX")) G.scene->r.imtype = R_DPX; - else printf("\nError: Format from '-F ' not known or not compiled in this release.\n"); + else printf("\nError: Format from '-F' not known or not compiled in this release.\n"); } } else { printf("\nError: no blend loaded. cannot use '-x'.\n");