From 506615ff94c7784e974f13034f04db87427b367e Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sat, 14 May 2011 00:07:41 +0000 Subject: 29267: add -enable-zsh-debug and use for debugging completion matcher groups --- Src/Zle/compcore.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Src/Zle/compcore.c') diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index fa8b8c11f..9c6f0673a 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -405,6 +405,11 @@ do_completion(UNUSED(Hookdef dummy), Compldat dat) } else if (nmatches == 1 || (nmatches > 1 && !diffmatches)) { /* Only one match. */ Cmgroup m = amatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(m->heap_id)) { + HEAP_ERROR(m->heap_id); + } +#endif while (!m->mcount) m = m->next; @@ -509,6 +514,11 @@ after_complete(UNUSED(Hookdef dummy), int *dat) int ret; cdat.matches = amatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(cdat.matches->heap_id)) { + HEAP_ERROR(cdat.matches->heap_id); + } +#endif cdat.num = nmatches; cdat.nmesg = nmessages; cdat.cur = NULL; @@ -987,6 +997,11 @@ makecomplist(char *s, int incmd, int lst) diffmatches = odm; validlist = 1; amatches = lastmatches; +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(amatches->heap_id)) { + HEAP_ERROR(amatches->heap_id); + } +#endif lmatches = lastlmatches; if (pmatches) { freematches(pmatches, 1); @@ -2959,6 +2974,11 @@ begcmgroup(char *n, int flags) Cmgroup p = amatches; while (p) { +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(p->heap_id)) { + HEAP_ERROR(p->heap_id); + } +#endif if (p->name && flags == (p->flags & (CGF_NOSORT|CGF_UNIQALL|CGF_UNIQCON)) && !strcmp(n, p->name)) { @@ -2975,6 +2995,9 @@ begcmgroup(char *n, int flags) } } mgroup = (Cmgroup) zhalloc(sizeof(struct cmgroup)); +#ifdef ZSH_HEAP_DEBUG + mgroup->heap_id = last_heap_id; +#endif mgroup->name = dupstring(n); mgroup->lcount = mgroup->llcount = mgroup->mcount = mgroup->ecount = mgroup->ccount = 0; @@ -3295,6 +3318,11 @@ permmatches(int last) fi = 1; } while (g) { +#ifdef ZSH_HEAP_DEBUG + if (memory_validate(g->heap_id)) { + HEAP_ERROR(g->heap_id); + } +#endif if (fi != ofi || !g->perm || g->new) { if (fi) /* We have no matches, try ignoring fignore. */ @@ -3323,6 +3351,9 @@ permmatches(int last) diffmatches = 1; n = (Cmgroup) zshcalloc(sizeof(struct cmgroup)); +#ifdef ZSH_HEAP_DEBUG + n->heap_id = HEAPID_PERMANENT; +#endif if (g->perm) { g->perm->next = NULL; -- cgit 1.4.1