Commit 25da687d authored by Mark Andrews's avatar Mark Andrews

4560. [bug] mdig: add -m option to enable memory debugging rather

                        than have in on all the time. [RT #44509]

4559.   [bug]           Openssl_link.c didn't compile if ISC_MEM_TRACKLINES
                        was turned off.  [RT #44509]
parent 9f4bf43b
4560. [bug] mdig: add -m option to enable memory debugging rather
than have in on all the time. [RT #44509]
4559. [bug] Openssl_link.c didn't compile if ISC_MEM_TRACKLINES
was turned off. [RT #44509]
4558. [bug] Synthesised CNAME before matching DNAME was still
being cached when it should have been. [RT #44318]
......
......@@ -742,6 +742,7 @@ help(void) {
" -6 (use IPv6 query transport only)\n"
" -b address[#port] (bind to source address/port)\n"
" -p port (specify port number)\n"
" -m (enable memory usage debugging)\n"
" +[no]dscp[=###] (Set the DSCP value to ### [0..63])\n"
" +[no]vc (TCP mode)\n"
" +[no]tcp (TCP mode, alternate syntax)\n"
......@@ -1520,7 +1521,7 @@ plus_option(char *option, struct query *query, isc_boolean_t global)
/*%
* #ISC_TRUE returned if value was used
*/
static const char *single_dash_opts = "46hiv";
static const char *single_dash_opts = "46himv";
/*static const char *dash_opts = "46bcfhiptvx";*/
static isc_boolean_t
dash_option(const char *option, char *next, struct query *query,
......@@ -1577,6 +1578,11 @@ dash_option(const char *option, char *next, struct query *query,
case 'i':
query->ip6_int = ISC_TRUE;
break;
case 'm':
/*
* handled by preparse_args()
*/
break;
case 'v':
fputs("mDiG " VERSION "\n", stderr);
exit(0);
......@@ -1694,6 +1700,39 @@ clone_default_query() {
return query;
}
/*%
* Because we may be trying to do memory allocation recording, we're going
* to need to parse the arguments for the -m *before* we start the main
* argument parsing routine.
*
* I'd prefer not to have to do this, but I am not quite sure how else to
* fix the problem. Argument parsing in mdig involves memory allocation
* by its nature, so it can't be done in the main argument parser.
*/
static void
preparse_args(int argc, char **argv) {
int rc;
char **rv;
char *option;
rc = argc;
rv = argv;
for (rc--, rv++; rc > 0; rc--, rv++) {
if (rv[0][0] != '-')
continue;
option = &rv[0][1];
while (strpbrk(option, single_dash_opts) == &option[0]) {
switch (option[0]) {
case 'm':
isc_mem_debugging = ISC_MEM_DEBUGTRACE |
ISC_MEM_DEBUGRECORD;
break;
}
option = &option[1];
}
}
}
static void
parse_args(isc_boolean_t is_batchfile, int argc, char **argv)
{
......@@ -1870,8 +1909,9 @@ main(int argc, char *argv[]) {
if (!have_ipv4 && !have_ipv6)
fatal("could not find either IPv4 or IPv6");
preparse_args(argc, argv);
mctx = NULL;
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
RUNCHECK(isc_mem_create(0, 0, &mctx));
lctx = NULL;
......
......@@ -44,6 +44,7 @@
<arg choice="opt" rep="norepeat"><option>-v</option></arg>
<arg choice="opt" rep="norepeat"><option>-4</option></arg>
<arg choice="opt" rep="norepeat"><option>-6</option></arg>
<arg choice="opt" rep="norepeat"><option>-m</option></arg>
<arg choice="opt" rep="norepeat"><option>-b <replaceable class="parameter">address</replaceable></option></arg>
<arg choice="opt" rep="norepeat"><option>-p <replaceable class="parameter">port#</replaceable></option></arg>
<arg choice="opt" rep="norepeat"><option>-c <replaceable class="parameter">class</replaceable></option></arg>
......@@ -162,6 +163,10 @@
"#&lt;port&gt;"
</para>
<para>
The <option>-m</option> option enables memory usage debugging.
</para>
<para>
The <option>-p</option> option is used when a non-standard port
number is to be queried.
......
......@@ -122,10 +122,17 @@ id_callback(void) {
#endif
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
#define FLARG_PASS , __FILE__, __LINE__
#define FLARG
#define FILELINE
#if ISC_MEM_TRACKLINES
#define FLARG_PASS , __FILE__, __LINE__
#else
#define FLARG_PASS
#endif
#else
#define FLARG , const char *file, int line
#define FILELINE , __FILE__, __LINE__
#if ISC_MEM_TRACKLINES
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment