简体   繁体   中英

Debugging in Visual Studio- can I see the Intel Compiler library code?

I am using Visual Studio 2012 with the Intel C/C++ compiler and when stepping in to a line like:

x = new X();

I then see code which looks like:

#ifdef _SYSCRT
#include <cruntime.h>
#include <crtdbg.h>
#include <malloc.h>
#include <new.h>
#include <stdlib.h>
#include <winheap.h>
#include <rtcsup.h>
#include <internal.h>

void * operator new( size_t cb )
{
    void *res;

    for (;;) {

        //  allocate memory block
        res = _heap_alloc(cb);

        //  if successful allocation, return pointer to memory

        if (res)
            break;

        //  call installed new handler
        if (!_callnewh(cb))
            break;

        //  new handler was successful -- try to allocate again
    }

    RTCCALLBACK(_RTC_Allocate_hook, (res, cb, 0));

    return res;
}
#else  /* _SYSCRT */

#include <cstdlib>
#include <new>

_C_LIB_DECL
int __cdecl _callnewh(size_t size) _THROW1(_STD bad_alloc);
_END_C_LIB_DECL

void *__CRTDECL operator new(size_t size) _THROW1(_STD bad_alloc)
        {       // try to allocate size bytes
        void *p;
        while ((p = malloc(size)) == 0)
                if (_callnewh(size) == 0)
                {       // report no memory
                        _THROW_NCEE(_XSTD bad_alloc, );
                }

        return (p);
        }

#endif  /* _SYSCRT */

is this the definition of new() as per the Intel compiler? As in I can see how Intel implement the C++ standard whilst debugging through my app?

How could I see what is in malloc.c (as opposed to malloc.h)?

EDIT: I think this is Microsoft new() because Microsoft appears in the comments. Why am I seeing Microsoft implementation of new() when I am using the Intel compiler?

  • How could I see what is in malloc.c (as opposed to malloc.h)?
  • One reason why you cannot see the malloc.c is if the function you are calling is defined and declared in malloc.h. When you talk of malloc.c and malloc.h, I guess you mean you would like to see the memory allocation function that is the new() or malloc(sizeof(5)/sizeof(int)) among other functions.
  • You might also not see this files because there is no error with your memory allocation function or any other function that indirectly uses the memory allocator function. If the error does not exist, then the compiler won`t point a finger to you that the error you are getting is coming from malloc.c or malloc.h.
  • The compiler will point a finger at a class or file that is generating the error. Until you have a function that violates malloc.c or malloc.h functions, you might not see these files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM