예제 #1
0
static void addcan(int tok, Node *n, Miscellaneous *miscell)
{	Node	*m, *prev = ZN;
	Node	**ptr;
	Node	*N;
	Symbol	*s, *t; int cmp;
	static char	dumpbuf[BUFF_LEN];
	static Node	*can = ZN;

	if (!n) return;

	if (n->ntyp == tok)
	{	addcan(tok, n->rgt, miscell);
		addcan(tok, n->lft, miscell);
		return;
	}
#if 0
	if ((tok == AND && n->ntyp == TRUE)
	||  (tok == OR  && n->ntyp == FALSE))
		return;
#endif
	N = dupnode(n);
	if (!can)	
	{	can = N;
		return;
	}

	s = DoDump(N,dumpbuf, miscell);
	if (can->ntyp != tok)	/* only one element in list so far */
	{	ptr = &can;
		goto insert;
	}

	/* there are at least 2 elements in list */
	prev = ZN;
	for (m = can; m->ntyp == tok && m->rgt; prev = m, m = m->rgt)
	{	t = DoDump(m->lft,dumpbuf, miscell);
		cmp = strcmp(s->name, t->name);
		if (cmp == 0)	/* duplicate */
			return;
		if (cmp < 0)
		{	if (!prev)
			{	can = tl_nn(tok, N, can, miscell);
				return;
			} else
			{	ptr = &(prev->rgt);
				goto insert;
	}	}	}

	/* new entry goes at the end of the list */
	ptr = &(prev->rgt);
insert:
	t = DoDump(*ptr,dumpbuf, miscell);
	cmp = strcmp(s->name, t->name);
	if (cmp == 0)	/* duplicate */
		return;
	if (cmp < 0)
		*ptr = tl_nn(tok, N, *ptr, miscell);
	else
		*ptr = tl_nn(tok, *ptr, N, miscell);
}
예제 #2
0
파일: tl_rewrt.c 프로젝트: aahud/harvey
static void
addcan(int tok, Node *n)
{	Node	*m, *prev = ZN;
	Node	**ptr;
	Node	*N;
	Symbol	*s, *t; int cmp;

	if (!n) return;

	if (n->ntyp == tok)
	{	addcan(tok, n->rgt);
		addcan(tok, n->lft);
		return;
	}

	N = dupnode(n);
	if (!can)	
	{	can = N;
		return;
	}

	s = DoDump(N);
	if (can->ntyp != tok)	/* only one element in list so far */
	{	ptr = &can;
		goto insert;
	}

	/* there are at least 2 elements in list */
	prev = ZN;
	for (m = can; m->ntyp == tok && m->rgt; prev = m, m = m->rgt)
	{	t = DoDump(m->lft);
		if (t != ZS)
			cmp = strcmp(s->name, t->name);
		else
			cmp = 0;
		if (cmp == 0)	/* duplicate */
			return;
		if (cmp < 0)
		{	if (!prev)
			{	can = tl_nn(tok, N, can);
				return;
			} else
			{	ptr = &(prev->rgt);
				goto insert;
	}	}	}

	/* new entry goes at the end of the list */
	ptr = &(prev->rgt);
insert:
	t = DoDump(*ptr);
	cmp = strcmp(s->name, t->name);
	if (cmp == 0)	/* duplicate */
		return;
	if (cmp < 0)
		*ptr = tl_nn(tok, N, *ptr);
	else
		*ptr = tl_nn(tok, *ptr, N);
}
예제 #3
0
void
SCProfilingKeywordDump(DetectEngineCtx *de_ctx)
{
    int i;
    FILE *fp;
    struct timeval tval;
    struct tm *tms;
    struct tm local_tm;

    if (profiling_keyword_enabled == 0)
        return;

    gettimeofday(&tval, NULL);
    tms = SCLocalTime(tval.tv_sec, &local_tm);

    if (profiling_keywords_output_to_file == 1) {
        SCLogDebug("file %s mode %s", profiling_file_name, profiling_file_mode);

        fp = fopen(profiling_file_name, profiling_file_mode);

        if (fp == NULL) {
            SCLogError(SC_ERR_FOPEN, "failed to open %s: %s", profiling_file_name,
                    strerror(errno));
            return;
        }
    } else {
       fp = stdout;
    }

    fprintf(fp, "  ----------------------------------------------"
            "------------------------------------------------------"
            "----------------------------\n");
    fprintf(fp, "  Date: %" PRId32 "/%" PRId32 "/%04d -- "
            "%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
            tms->tm_hour,tms->tm_min, tms->tm_sec);

    /* global stats first */
    DoDump(de_ctx->profile_keyword_ctx, fp, "total");
    /* per buffer stats next, but only if there are stats to print */
    for (i = 0; i < DETECT_SM_LIST_MAX; i++) {
        int j;
        uint64_t checks = 0;
        for (j = 0; j < DETECT_TBLSIZE; j++) {
            checks += de_ctx->profile_keyword_ctx_per_list[i]->data[j].checks;
        }

        if (checks)
            DoDump(de_ctx->profile_keyword_ctx_per_list[i], fp,
                    DetectSigmatchListEnumToString(i));
    }

    fprintf(fp,"\n");
    if (fp != stdout)
        fclose(fp);

    SCLogPerf("Done dumping keyword profiling data.");
}
예제 #4
0
void    DumpRegTree( reg_tree *tree )
/***********************************/
{
    if( tree != NULL ) {
        DoDump( tree, 0 );
    }
}
예제 #5
0
extern  void    DumpRegTree( reg_tree *tree ) {
    /*********************************************/

    if( tree != NULL ) {
        DoDump( tree, 0 );
    }
}
예제 #6
0
STATIC
VOID
EFIAPI
DumpVars(
  IN EFI_EVENT Event,
  IN VOID *Context
  )
{
  EFI_STATUS Status;

  if (mFvInstance->Device == NULL) {
    DEBUG((DEBUG_INFO, "Variable store not found?\n"));
    return;
  }

  if (!mFvInstance->Dirty) {
    DEBUG((DEBUG_INFO, "Variables not dirty, not dumping!\n"));
    return;
  }

  Status = DoDump (mFvInstance->Device);
  if (EFI_ERROR (Status)) {
    DEBUG((EFI_D_ERROR, "Couldn't dump '%s'\n",
           mFvInstance->MappedFile));
    ASSERT_EFI_ERROR(Status);
    return;
  }

  DEBUG((DEBUG_INFO, "Variables dumped!\n"));
  mFvInstance->Dirty = FALSE;
}
예제 #7
0
VOID
EFIAPI
OnSimpleFileSystemInstall (
  IN EFI_EVENT Event,
  IN VOID *Context
  )
{
  EFI_STATUS Status;
  UINTN HandleSize;
  EFI_HANDLE Handle;
  EFI_DEVICE_PATH_PROTOCOL *Device;

  if ((mFvInstance->Device != NULL) &&
      !EFI_ERROR (CheckStoreExists (mFvInstance->Device))
      ) {
    //
    // We've already found the variable store before,
    // and that device is not removed from the ssystem.
    //
    return;
  }

  while (TRUE) {
    HandleSize = sizeof (EFI_HANDLE);
    Status = gBS->LocateHandle (
                    ByRegisterNotify,
                    NULL,
                    mSFSRegistration,
                    &HandleSize,
                    &Handle
                    );
    if (Status == EFI_NOT_FOUND) {
      break;
    }

    ASSERT_EFI_ERROR (Status);

    Status = CheckStore (Handle, &Device);
    if (EFI_ERROR (Status)) {
      continue;
    }

    Status = DoDump (Device);
    if (EFI_ERROR (Status)) {
      DEBUG((EFI_D_ERROR, "Couldn't update '%s'\n",
             mFvInstance->MappedFile));
      ASSERT_EFI_ERROR(Status);
      continue;
    }

    if (mFvInstance->Device != NULL) {
      gBS->FreePool (mFvInstance->Device);
    }

    DEBUG((EFI_D_INFO, "Found variable store!\n"));
    mFvInstance->Device = Device;
    break;
  }
}
예제 #8
0
wxDebugContextDumpDelayCounter::~wxDebugContextDumpDelayCounter()
{
    if ( !--sm_count )
    {
        // Notify app if we've been asked to do that
        if( wxDebugContext::sm_shutdownFn )
            wxDebugContext::sm_shutdownFn();
        DoDump();
    }
}
예제 #9
0
static  void    DoDump( reg_tree *tree, int indent ) {
/****************************************************/

    DumpIndent( indent );
    DumpRegs( tree->regs );
    DumpNL();
    DumpIndent( indent );
    DumpLiteral( "offset " );
    DumpInt( tree->offset );
    DumpLiteral( " size " );
    DumpInt( tree->size );
    DumpNL();
    if( tree->temp != NULL ) {
        DumpIndent( indent );
        DumpLiteral( "name " );
        DumpPtr( tree->temp );
        DumpChar( ' ' );
        DumpSym( tree->temp );
        DumpNL();
    }
    if( tree->alt != NULL ) {
        DumpIndent( indent );
        DumpLiteral( "alt  " );
        DumpPtr( tree->alt  );
        DumpChar( ' ' );
        DumpSym( tree->alt );
        DumpNL();
    }
    if( tree->hi != NULL ) {
        DumpIndent( indent );
        DumpLiteral( "high " );
        DumpNL();
        DoDump( tree->hi, indent + 4 );
    }
    if( tree->lo != NULL ) {
        DumpIndent( indent );
        DumpLiteral( "low  " );
        DumpNL();
        DoDump( tree->lo, indent + 4 );
    }
}
예제 #10
0
void
SCProfilingSghDump(DetectEngineCtx *de_ctx)
{
    FILE *fp;
    struct timeval tval;
    struct tm *tms;
    struct tm local_tm;

    if (profiling_sghs_enabled == 0)
        return;

    gettimeofday(&tval, NULL);
    tms = SCLocalTime(tval.tv_sec, &local_tm);

    if (profiling_sghs_output_to_file == 1) {
        SCLogDebug("file %s mode %s", profiling_file_name, profiling_file_mode);

        fp = fopen(profiling_file_name, profiling_file_mode);

        if (fp == NULL) {
            SCLogError(SC_ERR_FOPEN, "failed to open %s: %s", profiling_file_name,
                       strerror(errno));
            return;
        }
    } else {
        fp = stdout;
    }

    fprintf(fp, "  ----------------------------------------------"
            "------------------------------------------------------"
            "----------------------------\n");
    fprintf(fp, "  Date: %" PRId32 "/%" PRId32 "/%04d -- "
            "%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
            tms->tm_hour,tms->tm_min, tms->tm_sec);

    DoDump(de_ctx->profile_sgh_ctx, fp, "rule groups");

    fprintf(fp,"\n");
    if (fp != stdout)
        fclose(fp);

    SCLogInfo("Done dumping rulegroup profiling data.");
}
예제 #11
0
파일: tl_trans.c 프로젝트: APRODEV/SQA
static int
not_new(Graph *g)
{	Graph	*q1; Node *tmp, *n1, *n2;
	Mapping	*map;

	tmp = flatten(g->Old);	/* duplicate, collapse, normalize */
	g->Other = g->Old;	/* non normalized full version */
	g->Old = tmp;

	g->oldstring = DoDump(g->Old);

	tmp = flatten(g->Next);
	g->nxtstring = DoDump(tmp);

	if (tl_verbose) dump_graph(g);

	Debug2("\tformula-old: [%s]\n", g->oldstring?g->oldstring->name:"true");
	Debug2("\tformula-nxt: [%s]\n", g->nxtstring?g->nxtstring->name:"true");
	for (q1 = Nodes_Set; q1; q1 = q1->nxt)
	{	Debug2("	compare old to: %s", q1->name->name);
		Debug2(" [%s]", q1->oldstring?q1->oldstring->name:"true");

		Debug2("	compare nxt to: %s", q1->name->name);
		Debug2(" [%s]", q1->nxtstring?q1->nxtstring->name:"true");

		if (q1->oldstring != g->oldstring
		||  q1->nxtstring != g->nxtstring)
		{	Debug(" => different\n");
			continue;
		}
		Debug(" => match\n");

		if (g->incoming)
			q1->incoming = catSlist(g->incoming, q1->incoming);

		/* check if there's anything in g->Other that needs
		   adding to q1->Other
		*/
		for (n2 = g->Other; n2; n2 = n2->nxt)
		{	for (n1 = q1->Other; n1; n1 = n1->nxt)
				if (isequal(n1, n2))
					break;
			if (!n1)
			{	Node *n3 = dupnode(n2);
				/* don't mess up n2->nxt */
				n3->nxt = q1->Other;
				q1->Other = n3;
		}	}

		map = (Mapping *) tl_emalloc(sizeof(Mapping));
	  	map->from = g->name->name;
	  	map->to   = q1;
	  	map->nxt = Mapped;
	  	Mapped = map;

		for (n1 = g->Other; n1; n1 = n2)
		{	n2 = n1->nxt;
			releasenode(1, n1);
		}
		for (n1 = g->Old; n1; n1 = n2)
		{	n2 = n1->nxt;
			releasenode(1, n1);
		}
		for (n1 = g->Next; n1; n1 = n2)
		{	n2 = n1->nxt;
			releasenode(1, n1);
		}
		return 1;
	}

	if (newstates) tl_verbose=1;
	Debug2("	New Node %s [", g->name->name);
	for (n1 = g->Old; n1; n1 = n1->nxt)
	{ Dump(n1); Debug(", "); }
	Debug2("] nr %d\n", Base);
	if (newstates) tl_verbose=0;

	Base++;
	g->nxt = Nodes_Set;
	Nodes_Set = g;

	return 0;
}
예제 #12
0
int
main(int argc, char* argv[])
{
    llvm::llvm_shutdown_obj llvm_manager(false);

    cl::SetVersionPrinter(&PrintVersion);
    cl::ParseCommandLineOptions(argc, argv);

    if (show_help)
        cl::PrintHelpMessage();

    if (show_license)
    {
        for (std::size_t i=0; i<sizeof(license_msg)/sizeof(license_msg[0]); i++)
            llvm::outs() << license_msg[i] << '\n';
        return EXIT_SUCCESS;
    }

    if (show_info)
    {
        llvm::outs() << full_version << '\n';
        list_module<yasm::ObjectFormatModule>();
        return EXIT_SUCCESS;
    }

    yasm::OffsetDiagnosticPrinter diag_printer(llvm::errs());
    yasm::Diagnostic diags(&diag_printer);
    yasm::SourceManager source_mgr(diags);
    diags.setSourceManager(&source_mgr);
    diag_printer.setPrefix("yobjdump");

    // Load standard modules
    if (!yasm::LoadStandardPlugins())
    {
        diags.Report(yasm::diag::fatal_standard_modules);
        return EXIT_FAILURE;
    }

    if (show_all_headers)
    {
        show_file_headers = true;
        show_section_headers = true;
        show_private_headers = true;
        show_relocs = true;
        show_symbols = true;
    }

    // Determine input filename and open input file.
    if (in_filenames.empty())
    {
        diags.Report(yasm::diag::fatal_no_input_files);
        return EXIT_FAILURE;
    }

    int retval = EXIT_SUCCESS;

    for (std::vector<std::string>::const_iterator i=in_filenames.begin(),
         end=in_filenames.end(); i != end; ++i)
    {
        try
        {
            if (DoDump(*i, source_mgr, diags) != EXIT_SUCCESS)
                retval = EXIT_FAILURE;
        }
        catch (std::out_of_range& err)
        {
            llvm::errs() << *i << ": "
                << "out of range error while reading (corrupt file?)\n";
            retval = EXIT_FAILURE;
        }
    }
    return retval;
}
예제 #13
0
파일: dut.c 프로젝트: PaulJing/Sora
void DutDump(HANDLE hDevice, ULONG* RadioNo, ULONG Count, PCSTR szDumpFileName)
{
    ULONG nWritten;
    PDEV_RET pOutInfo = (PDEV_RET)__MALLOC(sizeof(DEV_RET) + sizeof(HWT_DETAIL_INFO));
    DeviceIoControl ( 
        hDevice,
        DUT_IO_CODE(CMD_INFO),
        NULL, 
        0, 
        pOutInfo,
        sizeof(DEV_RET) + sizeof(HWT_DETAIL_INFO), 
        &nWritten,
        NULL);
    if (nWritten != sizeof(DEV_RET) + sizeof(HWT_DETAIL_INFO))
        printf("Get Radio Mask failed.\n");
    else {
		ULONG nWritten;
		PDEV_RET pOutVer = (PDEV_RET)__MALLOC(sizeof(DEV_RET) + sizeof(HWT_FW_VERSION));
		DeviceIoControl ( 
			hDevice, 
			DUT_IO_CODE(CMD_FW_VERSION),
			NULL, 
			0, 
			pOutVer,
			sizeof(DEV_RET) + sizeof(HWT_FW_VERSION), 
			&nWritten,
			NULL);
		if (nWritten != sizeof(DEV_RET) + sizeof(HWT_FW_VERSION))
			printf("Get Firmware version failed.\n");
		else {
			if (((HWT_FW_VERSION*)pOutVer->data)->m_fw_version >= 0x02000000) {
				PHWT_DETAIL_INFO hwt_detail_info;
				ULONG i;
				HRESULT r = S_OK;
				hwt_detail_info = (PHWT_DETAIL_INFO)pOutInfo->data;
				if (Count) {
					for(i=0; i < Count; i++) {
						if (hwt_detail_info->RadioMask & (1 << RadioNo[i]))
							continue;
						printf("Radio is not ready.\n");
						r = E_FAIL;
						break;
					}
					if (r == S_OK)
						DoDump(hDevice, RadioNo, Count, TRUE, szDumpFileName);
				}
				else {
					ULONG RadioNo[MAX_RADIO_NUMBER] = { 0 };
					ULONG Count = 0;
					for(i=0; i < MAX_RADIO_NUMBER; i++) {
						if (hwt_detail_info->RadioMask & (1 << i)) {
							RadioNo[Count] = i;
							Count++;
						}
					}
					DoDump(hDevice, RadioNo, Count, TRUE, szDumpFileName);
				}
			}
			else {
				ULONG RadioNo = 0;
				ULONG Count = 1;
				DoDump(hDevice, &RadioNo, Count, FALSE, szDumpFileName);
			}
		}
		__FREE(pOutVer);
    }
    __FREE(pOutInfo);
}