From: "Mark E." To: djgpp-workers AT delorie DOT com Date: Sat, 23 Jun 2001 20:42:58 -0400 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: v2loadimage and long cmd lines Message-ID: <3B34FF52.30589.23972E@localhost> X-mailer: Pegasus Mail for Win32 (v3.12c) Reply-To: djgpp-workers AT delorie DOT com I've tired of being unable to pass long command lines to a debugee. So I've written a patch to help fix that. It uses the CMDLINE method because it can be done with few changes unlike the proxy way. Thoughts? Index: v2load.c =================================================================== RCS file: /cvs/djgpp/djgpp/src/debug/common/v2load.c,v retrieving revision 1.6 diff -c -p -r1.6 v2load.c *** v2load.c 2001/06/21 17:13:50 1.6 --- v2load.c 2001/06/24 00:29:33 *************** *** 24,29 **** --- 24,31 ---- #define __tb_size _go32_info_block.size_of_transfer_buffer + #define MAX_CMDLINE_LEN 4096 + AREAS areas[MAX_AREA]; extern char **environ; *************** int v2loadimage(const char *program, con *** 66,71 **** --- 68,75 ---- __dpmi_meminfo memblock; unsigned new_env_selector; char true_name[FILENAME_MAX]; + char use_long_cmdline; + int cmdline_len; _truename(program, true_name); *************** int v2loadimage(const char *program, con *** 137,142 **** --- 141,154 ---- si.initial_size += 0xffff; si.initial_size &= 0xffff0000U; + cmdline_len = strlen(cmdline); + if (cmdline_len > 127 && cmdline_len < MAX_CMDLINE_LEN) + { + /* Dump long command line into CMDLINE environment variable. */ + setenv("CMDLINE", cmdline, 1); + use_long_cmdline = 1; + } + si.env_size = 0; for (i=0; environ[i]; i++) si.env_size += strlen(environ[i])+1; *************** int v2loadimage(const char *program, con *** 257,263 **** _farpokew(si.psp_selector, 0x2c, new_env_selector); /* copy command arguments into debug process */ ! movedata(my_ds, (unsigned)cmdline, si.psp_selector, 128, 128); /* copy si we built into debug process */ movedata(my_ds, (unsigned)&si, si.ds_selector, 0, sizeof(si)); load_state->__ds = client_ds; --- 269,281 ---- _farpokew(si.psp_selector, 0x2c, new_env_selector); /* copy command arguments into debug process */ ! if (!use_long_cmdline) ! movedata(my_ds, (unsigned)cmdline, si.psp_selector, 128, 128); ! else ! /* Don't copy the command line. Instead poke 0x7f to signal ! that CMDLINE has the real command line. */ ! _farpokeb(si.psp_selector, 128, 0x7f); ! /* copy si we built into debug process */ movedata(my_ds, (unsigned)&si, si.ds_selector, 0, sizeof(si)); load_state->__ds = client_ds;