Пример #1
0
	void assign(DWORD _dwMetaData,const LPVOID _pdata,DWORD _size)
	{
		m_dwMetaData = (PipeDataMetaEn)_dwMetaData;

		VERIFY_EXIT(NOT_NULL(_pdata) && _size>=0);

		m_size = _size;
		m_pdata = (m_size>0)?trace_alloc(new BYTE[m_size]):NULL;
		memcpy(m_pdata,_pdata,m_size);
	}
Пример #2
0
	bool read_pipe(LPVOID& _pdata,DWORD& _size,DWORD& _dwMetaData,bool _ballocate = false)
	{
		if(m_datas.empty()) return false;
		const CPipeDataBlock& front = m_datas.front();
		_size = front.get_size();
		if(_ballocate)
		{
			_pdata = trace_alloc(new BYTE[_size]);
		}
		memcpy(_pdata,front.get_data(),_size);
		_dwMetaData = front.get_metadata();
		m_datas.erase(m_datas.begin());
		return true;
	}
Пример #3
0
void test_ServerThread(IUnitTest* _ts)
{
	TEST_SUITE(_ts,_T("Pipe"),_T("Pipe Server thread"));
	
	//TRACE(_T("Test server thread ------------------------------------\n"));
	CServer1* pserver = trace_alloc(new CServer1(_T("test_pipe")));
	pserver->start();
	Sleep(100);
	CTime t1 = CTime::GetCurrentTime();
	delete trace_free(pserver);
	CTime t2 = CTime::GetCurrentTime();
	CTimeSpan dif = t2 - t1;
	ok(dif.GetSeconds()<5,_T("closing pipe server to long"));
}
Пример #4
0
cell_t *parse_word(seg_t w, cell_t *module, unsigned int n, cell_t *entry) {
  cell_t *c;
  cell_t *data = NULL;
  csize_t in = 0, out = 1;
  if(w.s[0] == '?' && w.n == 1) {
    c = param(T_ANY, entry);
  } else if(in = 1, out = 1, match_param_word("ap", w, &in, &out)) {
    c = func(OP_ap, ++in, ++out);
  } else if(in = 1, out = 1, match_param_word("comp", w, &in, &out)) {
    in += 2;
    c = func(OP_compose, in, ++out);
  } else if(in = 1, out = 1, match_param_word("external", w, &in, &out)) {
    c = func(OP_external, ++in, out);
  } else {
    cell_t *e = lookup_word(w);
    if(!e) e = module_lookup_compiled(w, &module);
    if(e) {
      in = e->entry.in;
      out = e->entry.out;
      if(FLAG(*e, entry, PRIMITIVE)) {
        if(e->op == OP_placeholder) {
          c = func(OP_placeholder, n + 1, 1);
          int x = trace_alloc(entry, n + 2);
          in = n;
          out = 1;
          data = var_create(T_LIST, tc_get(entry, x), 0, 0);
        } else {
          c = func(e->op, e->entry.in, e->entry.out);
        }
      } else {
        c = func(OP_exec, e->entry.in + 1, e->entry.out);
        data = e;
      }
    } else {
      return NULL;
    }
  }
  if(in) c->expr.arg[0] = (cell_t *)(intptr_t)(in - 1);
  TRAVERSE(c, out) {
    *p = dep(c);
  }
Пример #5
0
void test_CPipeReadBuffer(IUnitTest* _ts)
{
	TEST_SUITE(_ts,_T("Pipe"),_T("buffer operations"));

	CPipeReadedBuffer buffer;
	CPipeReadedBuffer::PipeBufferErrorsEn bufferr = CPipeReadedBuffer::PBE_Success;

	ok(buffer.is_empty(),_T("created buffer is not empty"));

	const DWORD allocate_size = 100;
	const DWORD blksz_1 = 122;
	const DWORD blksz_1_aligned = align(blksz_1,QWORD());
	const DWORD blksz_2 = 10;
	const DWORD blksz_2_aligned = align(blksz_2,QWORD());
	const DWORD blksz_3 = 15;
	const DWORD blksz_3_aligned = align(blksz_3,QWORD());

	LPVOID pbuf = NULL;
	pbuf = buffer.alloc_chunk(allocate_size);

	ok(is_all(pbuf,allocate_size,(BYTE)0),_T("alloc_chunk() not zeros memory"));
	ok(buffer.get_firstBlockRealSize()==0,_T("allocated chunk is not counted"));

	LPDWORD pdwbuf = (LPDWORD)pbuf;
	pdwbuf[0] = PDM_Data;
	pdwbuf[1] = blksz_1;

	ok(buffer.get_firstBlockRealSize()==allocate_size-sizeof(DWORD)*2,_T("bad real size"));
	ok(buffer.get_firstBlockSendedSize()==blksz_1,_T("allocated chunk is not counted"));
	ok(buffer.get_firstBlockMetaData()==PDM_Data,_T("no metadata DWORD in data chunk"));

	pbuf = buffer.alloc_chunk(allocate_size);

	fill_fortest((LPVOID)(pdwbuf+2),allocate_size-sizeof(DWORD)*2);
	DWORD cnt = blksz_1 - (allocate_size-sizeof(DWORD)*2);
	fill_fortest(pbuf,cnt,(byte)(blksz_1-cnt));

	ok(buffer.get_firstBlockRealSize()==blksz_1,_T("not processed block after it was already readed"));
	ok(buffer.get_firstBlockSendedSize()==blksz_1,_T("bad real size"));

	pdwbuf = (LPDWORD) ((LPBYTE)pbuf + blksz_1_aligned - (allocate_size-sizeof(DWORD)*2));
	pdwbuf[0] = PDM_Data;
	pdwbuf[1] = blksz_2;
	fill_fortest((LPVOID)(pdwbuf+2),blksz_2);
	pdwbuf = (LPDWORD)(
		(LPBYTE)pbuf 
			+ blksz_1_aligned - (allocate_size - sizeof(DWORD)*2)
			+ sizeof(DWORD)*2
			+ blksz_2_aligned
		);
	pdwbuf[0] = PDM_Data;
	pdwbuf[1] = blksz_3;
	fill_fortest((LPVOID)(pdwbuf+2),blksz_3);

	LPVOID preadbuf = NULL;
	DWORD dwsize = 0;

	DWORD dwMetaData = PDM_Null;
	ok(EQL(CPipeReadedBuffer::PBE_Success,buffer.read(preadbuf,dwsize,dwMetaData,true))
			&& EQL(dwMetaData,PDM_Data)
		,_T("read error")
		);
	ok(EQL(dwsize,blksz_1),_T("read error"));
	ok(test_filling(preadbuf,dwsize),_T("inccorrect data was readed"));
	ok(buffer.get_firstBlockRealSize()==blksz_2,_T("incorrect buffer size"));
	ok(buffer.get_firstBlockSendedSize()==blksz_2,_T("incorrect sended buffer size"));

	delete[] trace_free(preadbuf);
	dwsize = blksz_2+2;//set incorrect size
	preadbuf = trace_alloc(new BYTE[dwsize]);

	//test errors
	dwMetaData = PDM_Null;
	ok(EQL(CPipeReadedBuffer::PBE_WrongBufferSize,buffer.read(preadbuf,dwsize,dwMetaData,false))
		,_T("read return not PBE_WrongBufferSize")
		);
	ok(buffer.get_firstBlockRealSize()==blksz_2,_T("incorrect buffer size"));
	ok(buffer.get_firstBlockSendedSize()==blksz_2,_T("incorrect sended buffer size"));
	
	dwMetaData = PDM_Null;
	ok(EQL(CPipeReadedBuffer::PBE_InvalidArg,buffer.read(preadbuf,dwsize,dwMetaData,true))
		,_T("read return not PBE_InvalidArg")
		);
	ok(buffer.get_firstBlockRealSize()==blksz_2,_T("incorrect buffer size"));
	ok(buffer.get_firstBlockSendedSize()==blksz_2,_T("incorrect sended buffer size"));

	delete[] trace_free(preadbuf);
	dwsize = blksz_2;
	preadbuf = trace_alloc(new BYTE[dwsize]);

	ok(EQL(CPipeReadedBuffer::PBE_Success,buffer.read(preadbuf,dwsize,dwMetaData,false))
			&& EQL(dwMetaData,PDM_Data)
		,_T("read return not PBE_Success")
		);
	ok(test_filling(preadbuf,dwsize),_T("incorrect data was readed"));

	ok(EQL(buffer.get_firstBlockRealSize(),blksz_3),_T("incorrect real size"));
	ok(EQL(buffer.get_firstBlockSendedSize(),blksz_3),_T("incorrect sended size"));
	ok(EQL(buffer.free_firstBlock(),CPipeReadedBuffer::PBE_Success),_T("error while free first block"));

	ok(EQL(buffer.free_firstBlock(),CPipeReadedBuffer::PBE_DataNotReady),_T("free_firstBlock return not PBE_DataNotReady"));

	delete[] trace_free(preadbuf);
}
static void *
frame_obstack_alloc (unsigned long size)
{
  return (void *) trace_alloc (size);
}
static void
frame_saved_regs_zalloc (struct frame_info *fi)
{
  fi->saved_regs = (CORE_ADDR *) trace_alloc (SIZEOF_FRAME_SAVED_REGS);
  memset (fi->saved_regs, 0, SIZEOF_FRAME_SAVED_REGS);
}