gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-3819-g5c4184


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-3819-g5c41849
Date: Sun, 1 Sep 2019 11:49:21 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, master has been updated
       via  5c41849e0e78e45db0dc4421f1779ef7bec726da (commit)
      from  8cc45af919dc56011dbf4c8965b9c1e4784e56d7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=5c41849e0e78e45db0dc4421f1779ef7bec726da

commit 5c41849e0e78e45db0dc4421f1779ef7bec726da
Author: Andrew J. Schorr <address@hidden>
Date:   Sun Sep 1 11:48:01 2019 -0400

    Hack the typeof function to return memory count info when the 2nd arg is 
PROCINFO.

diff --git a/ChangeLog b/ChangeLog
index a64478c..54bc721 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2019-09-01         Andrew J. Schorr      <address@hidden>
+
+       * awk.h (block_header): Add cnt field even when MEMDEBUG is not
+       defined, and add a name field.
+       * node.c (nextfree): Initialize new name field.
+       (more_blocks): Bump nextfree[id].cnt by BLOCKCHUNK.
+       * builtin.c (do_typeof): When the 1st argument is PROCINFO and the
+       2nd arg is provided, return new "count_<blah>" fields containing
+       the memory allocation accounts of the various block types.
+
 2019-08-30         Andrew J. Schorr      <address@hidden>
 
        * configure.ac (.developing): Add -DMEMDEBUG to CFLAGS.
diff --git a/awk.h b/awk.h
index 345d87b..b55b048 100644
--- a/awk.h
+++ b/awk.h
@@ -1061,9 +1061,8 @@ struct block_item {
 struct block_header {
        struct block_item *freep;
        size_t size;
-#ifdef MEMDEBUG
+       const char *name;
        long cnt;
-#endif
 };
 
 enum block_id {
diff --git a/builtin.c b/builtin.c
index 1c107d3..4694390 100644
--- a/builtin.c
+++ b/builtin.c
@@ -4049,8 +4049,19 @@ do_typeof(int nargs)
                /* Node_var_array is never UPREF'ed */
                res = "array";
                deref = false;
-               if (dbg)
+               if (dbg) {
                        assoc_set(dbg, make_string("array_type", 10), 
make_string(arg->array_funcs->name, strlen(arg->array_funcs->name)));
+                       if (arg == PROCINFO_node) {
+                               int i;
+                               for (i = 0; i < BLOCK_MAX; i++) {
+                                       char *p;
+                                       size_t l = 6 + strlen(nextfree[i].name);
+                                       emalloc(p, char *, l+1, "do_typeof");
+                                       sprintf(p, "count_%s", 
nextfree[i].name);
+                                       assoc_set(dbg, make_str_node(p, l, 
ALREADY_MALLOCED), make_number((AWKNUM) (nextfree[i].cnt)));
+                               }
+                       }
+               }
                break;
        case Node_val:
                switch (fixtype(arg)->flags & (STRING|NUMBER|USER_INPUT|REGEX)) 
{
diff --git a/node.c b/node.c
index eacd17b..5333e84 100644
--- a/node.c
+++ b/node.c
@@ -1026,11 +1026,11 @@ void init_btowc_cache()
 #define BLOCKCHUNK 100
 
 struct block_header nextfree[BLOCK_MAX] = {
-       { NULL, sizeof(NODE) },
-       { NULL, sizeof(BUCKET) },
+       { NULL, sizeof(NODE), "node" },
+       { NULL, sizeof(BUCKET), "bucket" },
 #ifdef HAVE_MPFR
-       { NULL, sizeof(mpfr_t) },
-       { NULL, sizeof(mpz_t) },
+       { NULL, sizeof(mpfr_t), "mpfr" },
+       { NULL, sizeof(mpz_t), "mpz" },
 #endif
 };
 
@@ -1081,6 +1081,7 @@ more_blocks(int id)
                np->freep = next;
        }
        nextfree[id].freep = freep->freep;
+       nextfree[id].cnt += BLOCKCHUNK;
        return freep;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog | 10 ++++++++++
 awk.h     |  3 +--
 builtin.c | 13 ++++++++++++-
 node.c    |  9 +++++----
 4 files changed, 28 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]