Changeset cba516 in git for omalloc


Ignore:
Timestamp:
Sep 14, 2000, 2:59:54 PM (24 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
cb66fa0d8f3235673bb9477eb737a9069010b278
Parents:
b4e536263bb0aa911b1f252afe51fd37579eaaa1
Message:
* omPrintCurrentBackTraceMax
* omTestBinAddrSize


git-svn-id: file:///usr/local/Singular/svn/trunk@4594 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
omalloc
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • omalloc/omAllocDecl.h

    rb4e536 rcba516  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omAllocDecl.h,v 1.5 2000-08-18 09:05:50 obachman Exp $
     6 *  Version: $Id: omAllocDecl.h,v 1.6 2000-09-14 12:59:51 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_ALLOC_DECL_H
     
    8181#define omDebugBinAddr(addr)                 _omDebugAddr(addr,NULL,OM_FBINADDR,OM_CFL)
    8282#define omDebugAddrBin(addr, bin)            _omDebugAddr(addr,bin,OM_FBIN,OM_CFL)
     83#define omDebugBinAddrSize(addr, size)       _omDebugAddr(addr,(void*)(size),OM_FBINADDR|OM_FSIZE,OM_CFL)
    8384#define omDebugAddrSize(addr,size)           _omDebugAddr(addr,(void*)(size),OM_FSIZE,OM_CFL)
    8485#define omDebugAddr(addr)                    _omDebugAddr(addr,NULL, 0, OM_CFL)
     
    9192#if OM_CHECK > 0
    9293#define omCheckBinAddr      omDebugBinAddr
    93 #define omCheckAddrBin      omDebugAddrBin   
     94#define omCheckAddrBin      omDebugAddrBin 
     95#define omCheckBinAddrSize  omDebugBinAddrSize
    9496#define omCheckAddrSize     omDebugAddrSize 
    9597#define omCheckAddr         omDebugAddr     
     
    297299#define omDebugBinAddr(addr)                     ((void) 0)
    298300#define omDebugAddrBin(addr,bin)                 ((void) 0)
     301#define omDebugBinAddrSize(addr,size)            ((void) 0)                       
    299302#define omDebugAddrSize(addr,size)               ((void) 0)                       
    300303#define omDebugAddr(addr)                        ((void) 0)                               
     
    310313#define omCheckBinAddr(addr)                     ((void) 0)
    311314#define omCheckAddrBin(addr,bin)                 ((void) 0)
     315#define omCheckBinAddrSize(addr,size)            ((void) 0)                       
    312316#define omCheckAddrSize(addr,size)               ((void) 0)                       
    313317#define omCheckAddr(addr)                        ((void) 0)                               
     
    323327omError_t omTestAddrBin(void* addr, omBin bin, int check_level);
    324328omError_t omTestBinAddr(void* addr, int check_level);
     329omError_t omTestBinAddrSize(void* addr, size_t size, int check_level);
    325330omError_t omTestAddrSize(void* addr, size_t size, int check_level);
    326331omError_t omTestAddr(void* addr, int check_level);
     
    341346#define omTestAddrBin(addr,bin,l)                 ((void) 0)
    342347#define omTestBinAddr(addr,l)                     ((void) 0)                               
     348#define omTestBinAddrSize(addr,size,l)            ((void) 0)                       
    343349#define omTestAddrSize(addr,size,l)               ((void) 0)                       
    344350#define omTestAddr(addr,l)                        ((void) 0)                               
  • omalloc/omDebug.c

    rb4e536 rcba516  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 7/00
    6  *  Version: $Id: omDebug.c,v 1.8 2000-09-12 16:02:18 obachman Exp $
     6 *  Version: $Id: omDebug.c,v 1.9 2000-09-14 12:59:52 obachman Exp $
    77 *******************************************************************/
    88#include <limits.h>
     
    3939{
    4040  return _omDebugAddr(addr,bin,OM_FBIN,OM_CLFL);
     41}
     42omError_t omTestBinAddrSize(void* addr, size_t size, int check_level)
     43{
     44  return _omDebugAddr(addr,(void*)(size),OM_FSIZE|OM_FBINADDR,OM_CLFL);
    4145}
    4246omError_t omTestAddrSize(void* addr, size_t size, int check_level)
     
    237241  }
    238242  while (addr[i] != '\0' && i < size) i++;
     243// there seems to be no way to check if it is really a string
     244#if 0
    239245  if (i == size)
    240246  {
     
    242248    i = size-1;
    243249  }
     250#endif
    244251  ret = __omDebugAlloc((void*)i+1, OM_FSIZE, track, OM_FLR_VAL);
    245252  memcpy(ret, addr, i);
  • omalloc/omDebug.h

    rb4e536 rcba516  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 7/00
    6  *  Version: $Id: omDebug.h,v 1.8 2000-09-12 16:02:18 obachman Exp $
     6 *  Version: $Id: omDebug.h,v 1.9 2000-09-14 12:59:52 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_DEBUG_H
     
    179179  if (_status && _status != omError_MaxError)                                 \
    180180  {                                                                           \
    181     omPrintAddrInfo(stderr, _status, addr, bin_size, flags, "  occured for"); \
     181    _omPrintAddrInfo(stderr, _status, addr, bin_size, flags, "  occured for"); \
    182182    return _status;                                                           \
    183183  }                                                                           \
  • omalloc/omDebugCheck.c

    rb4e536 rcba516  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omDebugCheck.c,v 1.4 2000-08-18 09:05:52 obachman Exp $
     6 *  Version: $Id: omDebugCheck.c,v 1.5 2000-09-14 12:59:52 obachman Exp $
    77 *******************************************************************/
    88#include <limits.h>
     
    2626static omError_t omDoCheckBinPage(omBinPage page, int normal_page, int level,
    2727                                  omError_t report, OM_FLR_DECL);
    28 static void omPrintAddrInfo(FILE* fd, omError_t error, void* addr, void* bin_size, omTrackFlags_t flags, char* s);
     28static void _omPrintAddrInfo(FILE* fd, omError_t error, void* addr, void* bin_size, omTrackFlags_t flags, char* s);
    2929
    3030
     
    199199  omAddrCheckReturnCorrupted(! omIsKnownTopBin(bin, ! omIsBinAddrTrackAddr(addr)));
    200200
     201  if (flags & OM_FBINADDR && flags & OM_FSIZE)
     202    omAddrCheckReturnError(bin->sizeW*SIZEOF_LONG != (size_t) bin_size, omError_WrongSize);
     203   
    201204  if (level > 1)
    202205  {
     
    423426  omReportError(error, report_error, OM_FLR_VAL, fmt, ap);
    424427 
    425   omPrintAddrInfo(stderr, error, addr, bin_size, flags, " occured for");
     428  _omPrintAddrInfo(stderr, error, addr, bin_size, flags, " occured for");
    426429  return om_ErrorStatus;
    427430}
    428431
    429 void omPrintAddrInfo(FILE* fd, omError_t error, void* addr, void* bin_size, omTrackFlags_t flags, char* s)
     432void _omPrintAddrInfo(FILE* fd, omError_t error, void* addr, void* bin_size, omTrackFlags_t flags, char* s)
    430433{
    431434  if (! omCheckPtr(addr, omError_MaxError, OM_FLR))
     
    448451    fprintf(fd, "%s (invalid) addr: %p\n", s, addr);
    449452  }
     453}
     454
     455void omPrintAddrInfo(FILE* fd, void *addr, char* s)
     456{
     457  _omPrintAddrInfo(fd, omError_NoError, addr, NULL, 0, s);
    450458}
    451459
     
    537545    om_total_used_blocks++;
    538546    om_total_used_size += omSizeOfAddr(addr);
    539     omPrintAddrInfo(om_print_used_addr_fd, omError_NoError, addr, NULL, 0, "");
     547    _omPrintAddrInfo(om_print_used_addr_fd, omError_NoError, addr, NULL, 0, "");
    540548    fprintf(om_print_used_addr_fd, "\n");
    541549  }
  • omalloc/omDebugTrack.c

    rb4e536 rcba516  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omDebugTrack.c,v 1.6 2000-09-12 16:02:18 obachman Exp $
     6 *  Version: $Id: omDebugTrack.c,v 1.7 2000-09-14 12:59:53 obachman Exp $
    77 *******************************************************************/
    88#include <limits.h>
     
    453453  omAddrCheckReturnError((d_addr->flags & OM_FUSED) ^ (flags & OM_FUSED), omError_FreedAddrOrMemoryCorrupted);
    454454
     455  if (flags & OM_FBINADDR && flags & OM_FSIZE)
     456    omAddrCheckReturnError(omTrackAddr_2_OutSize(d_addr) != (size_t) bin_size, omError_WrongSize);
     457 
    455458  if (d_addr->track > 2)
    456459  {
  • omalloc/omError.h

    rb4e536 rcba516  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omError.h,v 1.4 2000-08-18 09:05:53 obachman Exp $
     6 *  Version: $Id: omError.h,v 1.5 2000-09-14 12:59:53 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_ERROR_H
    99#define OM_ERROR_H
    1010
     11#include <stdio.h>
    1112/*******************************************************************
    1213 * 
     
    5455                               const char* fmt, ...);
    5556
     57#ifndef OM_NDEBUG
     58extern void omPrintAddrInfo(FILE* fd, void* addr, char* s);
     59#else
     60#define omPrintAddrInfo(fd, addr, s) fprintf(fd, "OM_NDEBUG: no addr info available\n")
     61#endif
     62
    5663/*BEGINPRIVATE*/
    5764/*******************************************************************
  • omalloc/omRet2Info.c

    rb4e536 rcba516  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omRet2Info.c,v 1.5 2000-09-12 16:02:19 obachman Exp $
     6 *  Version: $Id: omRet2Info.c,v 1.6 2000-09-14 12:59:53 obachman Exp $
    77 *******************************************************************/
    88#include <stdio.h>
     
    2525#endif
    2626
     27/* define to also print return addresses in (default)
     28   output of omPrintInfo */
     29/* #define OM_PRINT_RETURN_ADDRESS */
    2730static char om_this_prog[MAXPATHLEN] = "";
    2831
     
    139142 
    140143  i = omBackTrace_2_RetInfo(bt, info, max);
    141   return omPrintRetInfo(info, i, fd, "  #%i %L in %F\n");
    142 }
    143 
    144 int omPrintCurrentBackTrace(FILE* fd)
     144#ifdef OM_PRINT_RETURN_ADDRESS
     145  return omPrintRetInfo(info, i, fd, "  #%i at %L in %F ra=%p\n");
     146#else
     147  return omPrintRetInfo(info, i, fd, "  #%i at %L in %F\n");
     148#endif 
     149}
     150
     151int omPrintCurrentBackTraceMax(FILE* fd, int max)
    145152{
    146153  int i;
    147154  void* bt[OM_MAX_BACKTRACE_DEPTH];
    148  
    149   i = omGetBackTrace(bt, 1, OM_MAX_BACKTRACE_DEPTH);
     155  if (max > OM_MAX_BACKTRACE_DEPTH)
     156    max = OM_MAX_BACKTRACE_DEPTH;
     157  if (max <= 0) return 0;
     158  i = omGetBackTrace(bt, 1, max);
    150159  return omPrintBackTrace(bt, i, fd);
    151160}
     
    231240  else
    232241#endif /* ! OM_INTERNAL_DEBUG */
     242#ifdef OM_PRINT_RETURN_ADDRESS
    233243    return omPrintRetInfo(info, i, fd, "\n  #%i at %L in %F ra=%p");
     244#else
     245    return omPrintRetInfo(info, i, fd, "\n  #%i at %L in %F");
     246#endif
    234247}
    235248
  • omalloc/omRet2Info.h

    rb4e536 rcba516  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omRet2Info.h,v 1.4 2000-08-16 12:06:11 obachman Exp $
     6 *  Version: $Id: omRet2Info.h,v 1.5 2000-09-14 12:59:53 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_RET_2_INFO_H
     
    3737
    3838int omPrintBackTrace(void** bt, int max, FILE* fd);
    39 int omPrintCurrentBackTrace(FILE* fd);
     39#define omPrintCurrentBackTrace(fd) omPrintCurrentBackTraceMax(fd, 1000)
     40int omPrintCurrentBackTraceMax(FILE* fd, int max);
    4041
    4142int omFilterRetInfo_i(omRetInfo info, int max, int i);
     
    7273#define omPrintBackTrace(bt,max,fd)     ((void)0)
    7374#define omPrintCurrentBackTrace(fd)     ((void)0)
     75#define omPrintCurrentBackTraceMax(fd,max) ((void)0)
    7476#define omFilterRetInfo_i(info,max,i)   ((void)0)
    7577#define omFilterRetInfo(info, max, cond)((void)0)
  • omalloc/omtTest.c

    rb4e536 rcba516  
    259259void my_exit()
    260260{
    261   printf("\notTest Summary: ");
     261  printf("\nomtTest Summary: ");
    262262  if (errors || missed_errors || used_regions)
    263263  {   
  • omalloc/omtTestError.c

    rb4e536 rcba516  
    118118          {
    119119            omDebugAddrSize(cell->addr, OM_MAX_BLOCK_SIZE + 1);
    120             spec.MaxSize = 0;
    121             spec.MinTrack = 3;
    122             spec.NotIsBin = 1;
    123             cell = omFindCell(spec);
    124             if (cell != NULL)
    125             {   
    126               omDebugAddrSize(cell->addr, GET_SIZE(cell->spec) + SIZEOF_OM_ALIGNMENT);
    127             } else printf("cell not found\n");
     120            if (om_ErrorStatus != omError_NoError)
     121            {
     122              om_ErrorStatus = omError_NoError;
     123              spec.MaxSize = 0;
     124              spec.MinTrack = 3;
     125              spec.NotIsBin = 1;
     126              cell = omFindCell(spec);
     127              if (cell != NULL)
     128              {   
     129                omDebugAddrSize(cell->addr, GET_SIZE(cell->spec) + SIZEOF_OM_ALIGNMENT);
     130                if (om_ErrorStatus != omError_NoError)
     131                {
     132                  om_ErrorStatus = omError_NoError;
     133                  spec.MaxSize = OM_MAX_BLOCK_SIZE;
     134                  spec.MinTrack = 0;
     135                  spec.NotIsBin = 0;
     136                  cell = omFindCell(spec);
     137                  if (cell != NULL)
     138                    omDebugBinAddrSize(cell->addr, GET_SIZE(cell->spec) - 1);
     139                  else printf("cell not found");
     140                }
     141              }
     142              else printf("cell not found\n");
     143            }
    128144          }
    129145          else printf("cell not found\n");
     
    319335        case omError_NotString:
    320336        {
     337/* can only test for NULL string */
     338#if 0
    321339          spec.MaxSize = OM_MAX_BLOCK_SIZE;
    322340          cell = omFindCell(spec);
     
    333351          else printf("cell not found\n");
    334352          break;
     353#endif
     354          omStrDup(NULL);
    335355        }
    336356        default:
Note: See TracChangeset for help on using the changeset viewer.