/*{ ** Name: psf_debug - Standard entry point for debugging PSF. ** ** Description: ** This function is the standard entry point to PSF for setting and ** clearing tracepoints. ** ** Inputs: ** debug_cb Pointer to a DB_DEBUG_CB ** .db_trswitch What operation to perform ** DB_TR_NOCHANGE None ** DB_TR_ON Turn on a tracepoint ** DB_TR_OFF Turn off a tracepoint ** .db_trace_point The number of the tracepoint to be ** effected ** .db_vals[2] Optional values, to be interpreted ** differently for each tracepoint ** .db_value_count The number of values specified in ** the above array ** ** Outputs: ** None ** Returns: ** E_DB_OK Success ** E_DB_WARN Operation completed with warning(s) ** E_DB_ERROR Function failed; non-catastrophic error ** E_DB_FATAL Function failed; catastrophic error ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 17-apr-86 (jeff) ** written ** 13-feb-90 (andre) ** set scf_stype to SCU_EXCLUSIVE before calling scu_swait. ** 14-jul-93 (ed) ** replacing <dbms.h> by <gl.h> <sl.h> <iicommon.h> <dbdbms.h> ** 10-aug-93 (andre) ** removed declaration of scf_call() ** 08-oct-93 (rblumer) ** In order to allow session trace points that take a value, ** changed ult_set_macro call to use firstval and secondval ** instead of hard-coding zeros for the values. ** 09-Oct-1998 (jenjo02) ** Removed SCF semaphore functions, inlining the CS calls instead. ** 04-may-1999 (hanch04) ** Change TRformat's print function to pass a PTR not an i4. ** 21-Feb-2007 (hanal04) Bug 117736 ** Added trace point PS503 to dump PSF's ULM memory usage to the ** DBMS log. */ DB_STATUS psf_debug( DB_DEBUG_CB *debug_cb) { i4 flag; i4 firstval; i4 secondval; PSS_SESBLK *sess_cb; extern PSF_SERVBLK *Psf_srvblk; /* Get the session control block */ sess_cb = psf_sesscb(); /* Flags 0 - PSF_TBITS-1 are for the server; all others are for sessions */ flag = debug_cb->db_trace_point; if (flag >= PSF_TBITS) { flag = flag - PSF_TBITS; if (flag >= PSS_TBITS) return (E_DB_ERROR); } /* There can be UP TO two values, but maybe they weren't given */ if (debug_cb->db_value_count > 0) firstval = debug_cb->db_vals[0]; else firstval = 0L; if (debug_cb->db_value_count > 1) secondval = debug_cb->db_vals[1]; else secondval = 0L; /* ** Three possible actions: Turn on flag, turn it off, or do nothing. */ switch (debug_cb->db_trswitch) { case DB_TR_ON: /* First PSF_TBITS flags belong to server, others to session */ if (debug_cb->db_trace_point < PSF_TBITS) { CSp_semaphore(1, &Psf_srvblk->psf_sem); /* exclusive */ ult_set_macro(&Psf_srvblk->psf_trace, flag, firstval, secondval); CSv_semaphore(&Psf_srvblk->psf_sem); } else { /* Do nothing if couln't get session control block */ if (sess_cb != (PSS_SESBLK *) NULL) { if(flag == PSS_ULM_DUMP_POOL) { ULM_RCB ulm_rcb; char buf[512]; SCF_CB scf_cb; ulm_rcb.ulm_poolid = Psf_srvblk->psf_poolid; ulm_rcb.ulm_facility = DB_PSF_ID; _VOID_ ulm_mappool(&ulm_rcb); ulm_print_pool(&ulm_rcb); STprintf(buf, "ULM Memory Pool Map and ULM Memory Print Pool for PSF has been \nwritten to the DBMS log file."); scf_cb.scf_length = sizeof(scf_cb); scf_cb.scf_type = SCF_CB_TYPE; scf_cb.scf_facility = DB_PSF_ID; scf_cb.scf_session = DB_NOSESSION; scf_cb.scf_nbr_union.scf_local_error = 0; scf_cb.scf_len_union.scf_blength = STlength(buf); scf_cb.scf_ptr_union.scf_buffer = buf; _VOID_ scf_call(SCC_TRACE, &scf_cb); } else { ult_set_macro(&sess_cb->pss_trace, flag, firstval, secondval); /* Yacc debugging requires a special call */ if (flag == PSS_YTRACE) psl_trace((PTR) sess_cb->pss_yacc, TRUE); } } } break; case DB_TR_OFF: /* First PSF_TBITS flags belong to server, others to session */ if (debug_cb->db_trace_point < PSF_TBITS) { CSp_semaphore(1, &Psf_srvblk->psf_sem); /* exclusive */ ult_clear_macro(&Psf_srvblk->psf_trace, flag); CSv_semaphore(&Psf_srvblk->psf_sem); } else { /* Do nothing if couldn't get session control block */ if (sess_cb != (PSS_SESBLK *) NULL) { ult_clear_macro(&sess_cb->pss_trace, flag); /* Yacc debugging requires a special call */ if (flag == PSS_YTRACE) psl_trace((PTR) sess_cb->pss_yacc, FALSE); } } break; case DB_TR_NOCHANGE: /* Do nothing */ break; default: return (E_DB_ERROR); } return (E_DB_OK); }
DB_STATUS opt_call( DB_DEBUG_CB *debug_cb) { i4 flag; /* Trace flag to be affected */ i4 firstval; /* first value of trace control ** block */ i4 secondval; /* second value of trace control ** block */ OPS_CB *ops_cb; /* ptr to session control block */ /* FIXME - need to establish an exception handler here */ ops_cb = ops_getcb(); /* get session control block from ** SCF */ /* Flags 0 - OPT_GMAX-1 are for the server; all others are for sessions */ flag = debug_cb->db_trace_point; if (flag < 0) return (E_DB_ERROR); /* There can be UP TO two values, but maybe they weren't given */ if (debug_cb->db_value_count > 0) firstval = debug_cb->db_vals[0]; else firstval = 0L; if (debug_cb->db_value_count > 1) secondval = debug_cb->db_vals[1]; else secondval = 0L; if (flag < OPT_GMAX) { /* a server trace flag is found */ switch (flag) { /* check that a valid global trace flag is being affected */ case OPT_F038_FAKE_GATEWAY: { /* set some flags to change OPF to gateway */ ops_cb->ops_server->opg_qeftype = OPF_GQEF; /* make this a gateway QEF */ ops_cb->ops_server->opg_smask = OPF_TIDDUPS | OPF_TIDUPDATES | OPF_INDEXSUB; } case OPT_GSTARTUP: case OPT_F004_FLATTEN: case OPT_F005_PARSER: break; default: return( E_DB_ERROR ); /* return if not a valid flag */ } /* ** Three possible actions: Turn on flag, turn it off, or do nothing. */ switch (debug_cb->db_trswitch) { case DB_TR_ON: ult_set_macro(&ops_cb->ops_server->opg_tt, flag, firstval, secondval); ops_cb->ops_server->opg_check = TRUE; /* indicates that at least one ** trace flag has been set ** - this probably could be made ** into a counter */ break; case DB_TR_OFF: ult_clear_macro(&ops_cb->ops_server->opg_tt, flag); break; case DB_TR_NOCHANGE: break; default: return (E_DB_ERROR); } } else { /* a session level trace flag will be set */ flag = flag - OPT_GMAX; /* get proper offset for session ** trace buffer */ switch (flag) { case OPT_F002_SKIPCONSISTENCY: { switch (debug_cb->db_trswitch) { case DB_TR_ON: ops_cb->ops_skipcheck = TRUE; /* indicates non critical consistency ** checks should be skipped */ break; case DB_TR_OFF: ops_cb->ops_skipcheck = FALSE; /* resume consistency checks */ break; case DB_TR_NOCHANGE: break; default: return (E_DB_ERROR); } return(E_DB_OK); } case OPT_F001_DUMP_QTREE: case OPT_T129_NO_LOAD: case OPT_T131_NO_JOINPQUAL: case OPT_F004_FLATTEN: case OPT_F005_PARSER: case OPT_F006_NONOTEX: case OPT_AGSNAME: case OPT_AGSIMPLE: case OPT_AGSUB: case OPT_MAKAVAR: case OPT_AGCANDIDATE: case OPT_AGREPLACE: case OPT_PROJECTION: case OPT_TIMER: case OPT_F016_OPFSTATS: case OPT_FCOTREE: case OPT_F019_AGGCOMPAT: case OPT_F020_NOPRESORT: case OPT_F021_QPTREE: case OPT_F022_FULL_QP: case OPT_F023_NOCOMP: case OPT_F025_RANGETAB: case OPT_F026_FULL_OPKEY: case OPT_F027_FUSED_OPKEY: case OPT_F028_JOINOP: case OPT_F029_HISTMAP: case OPT_F030_SQLNAMES: case OPT_F031_WARNINGS: case OPT_F032_NOEXECUTE: case OPT_F033_OPF_TO_OPC: case OPT_F034_NEWFEATS: case OPT_F035_NO_HISTJOIN: case OPT_F036_OPC_DISTRIBUTED: case OPT_F037_STATISTICS: case OPT_F039_NO_KEYJOINS: #ifdef xDEBUG case OPT_F040_SQL_TEXT: #endif case OPT_F041_MULTI_SITE: case OPT_F042_PTREEDUMP: case OPT_F043_CONSTANTS: case OPT_F044_NO_RTREE: case OPT_F045_QENPROW: case OPT_F046_CONTROLC: case OPT_F048_FLOAT: case OPT_F049_KEYING: case OPT_F050_COMPLETE: case OPT_F051_QPDUMP: case OPT_F052_CARTPROD: case OPT_F053_FASTOPT: case OPT_F054_OLDCNF: case OPT_F055_NOCNF: case OPT_F056_NOSMARTDISK: case OPT_F057_WHYNOSMARTDISK: case OPT_F058_SD_CONJUNCT_TRACE: case OPT_F059_CARTPROD: case OPT_F060_QEP: case OPT_F061_CORRELATION: case OPT_F062_OLDJCARD: case OPT_F063_CORRELATION: case OPT_F064_NOKEY: case OPT_F065_8CHAR: case OPT_F066_GUESS: case OPT_F067_PQ: case OPT_F068_OLDFLATTEN: case OPT_F069_ALLPLANS: case OPT_F070_RIGHT: case OPT_F071_QEP_WITHOUT_COST: case OPT_F073_NODEFAULT: case OPT_F074_UVAGG: case OPT_F075_FLOATQEP: case 76: /* inkdo01 kludge */ case OPT_F077_STATS_NOSTATS_MAX: case OPT_F078_NO_STATS_NOSTATS_MAX: case OPT_F081_DUMPENUM: case OPT_F082_QEPDUMP: case OPT_F083_OLDIDXORDER: case OPT_F084_TBLAUTOSTRUCT: case OPT_F085_MISSINGSTATS: case OPT_F086_DUMP_QTREE2: case OPT_F087_ALLFRAGS: case OPT_F088_BESTPLANS: case OPT_F089_FORCE_HASHJOIN: case OPT_F090_FORCE_EXCHANGE: if (debug_cb->db_value_count > 0) return( E_DB_ERROR ); /* these flags have no values */ break; /* Flag is defined */ case OPT_F119_NEWENUM: if (debug_cb->db_value_count > 1) return( E_DB_ERROR ); /* this flag may have 0 or 1 value */ break; /* Flag is defined */ case OPT_F120_SORTCPU: if (debug_cb->db_value_count > 1) return( E_DB_ERROR ); /* this flag may have 0 or 1 value */ break; /* Flag is defined */ case OPT_F118_GREEDY_FACTOR: case OPT_F123_SCAN: case OPT_F124_BLOCKING: case OPT_F125_TIMEFACTOR: case OPT_F126_SITE_FACTOR: case OPT_F127_TIMEOUT: if ((debug_cb->db_value_count < 1) && (debug_cb->db_trswitch == DB_TR_ON) /* value only required ** if trace flag is to be ** turned on */ ) return (E_DB_ERROR); /* at least one value must be ** specified */ break; case OPT_F024_NOTIMEOUT: if (debug_cb->db_value_count > 0) return( E_DB_ERROR ); ops_cb->ops_alter.ops_timeout = FALSE; /* alternative way of ** changing no timeout flag for ** session */ return (E_DB_OK); case OPT_F072_LVCH_TO_VCH: if (debug_cb->db_value_count > 0) return( E_DB_ERROR ); /* these flags have no values */ /* ** This trace point instructs OPF\OPC to use set the tuple ** descriptor for the query to state that long varchar elements ** are varchar. This is useful for testing the system before there ** is large object support in the frontends. ** ** To be useful, this action must be accompanied by an action which ** tells the adu_redeem() code to format the beasts as varchar. ** This is accomplished by setting adf trace point 11. ** ** Note that this is server wide setting... */ if (debug_cb->db_trswitch != DB_TR_NOCHANGE) { DB_STATUS status; DB_DEBUG_CB adf_dbg; STRUCT_ASSIGN_MACRO(*debug_cb, adf_dbg); /* {@fix_me@} Need a #define for this... */ adf_dbg.db_trace_point = 11; status = adb_trace(&adf_dbg); if (DB_FAILURE_MACRO(status)) return(status); } break; default: return( E_DB_ERROR ); /* unknown session trace flag */ } /* ** Three possible actions: Turn on flag, turn it off, or do nothing. */ switch (debug_cb->db_trswitch) { case DB_TR_ON: ult_set_macro(&ops_cb->ops_tt, flag, firstval, secondval); ops_cb->ops_check = TRUE; /* indicates that at least one ** trace flag has been set ** - this probably could be made ** into a counter */ break; case DB_TR_OFF: ult_clear_macro(&ops_cb->ops_tt, flag); break; case DB_TR_NOCHANGE: break; default: return (E_DB_ERROR); } } return (E_DB_OK); }
/*{ ** Name: rdf_trace - Call RDF trace operation. ** ** External call format: status = rdf_trace(&db_debug_cb) ** ** Description: ** This function is the standard entry point to RDF for setting and ** clearing tracepoints(the "set trace point" command). Because RDF ** is a service facility, trace point for RDF can only be set on ** the server basis. There is no session level trace point. ** Db_debug_cb is the tracing control block that contains the trace ** flag information. ** ** See file <rdftrace.h> for a description of all possible ** RDF trace points. ** ** Inputs: ** debug_cb Pointer to a DB_DEBUG_CB ** .db_trswitch What operation to perform ** DB_TR_NOCHANGE None ** DB_TR_ON Turn on a tracepoint ** DB_TR_OFF Turn off a tracepoint ** .db_trace_point Trace point ID(the flag number) ** .db_value_count The number of values specified in ** the value array ** .db_vals[2] Optional values, to be interpreted ** differently for each tracepoint ** Outputs: ** none ** ** Returns: ** E_DB_OK Function completed normally. ** E_DB_ERROR Function failed due to error by caller; ** E_DB_FATAL Function failed due to some internal ** problem; ** Exceptions: ** none ** ** Side Effects: ** The trace vector in the server control block of RDF will be updated ** to contain the trace information. The trace information will be persist ** throughout the life of the server. ** ** History: ** 15-apr-86 (ac) ** written ** 02-mar-87 (puree) ** replace global server control block with global pointer. ** 14-dec-1989 (teg) ** modify to go get svcb from SCF instead of using a global pointer ** to it. ** 16-jul-92 (teresa) ** prototypes ** 16-sep-92 (teresa) ** implement trace points rd3 and rd4 to clear ldbdesc cache. ** 22-apr-94 (teresa) ** added trace points rd11 and rd12 to dump memory statistics or all ** statistics. This is an action trace point -- the dump occurs when ** the trace point is selected rather than during query execution. ** 20-nov-2007 (thaju02) ** If trace point RD0022/RDU_CHECKSUM specified, invalidate ** relcache. Entries need rdr_checksum to be calc/init'd ** otherwise E_RD010D errors may be reported. (B119499) */ DB_STATUS rdf_trace(DB_DEBUG_CB *debug_cb) { i4 flag; i4 firstval; i4 secondval; DB_STATUS status; i4 trace_scope; /* assure flag is legal */ flag = debug_cb->db_trace_point; if (flag >= RDF_NB) { return (E_DB_ERROR); } /* There can be UP TO two values, but maybe they weren't given */ firstval = (debug_cb->db_value_count > 0) ? debug_cb->db_vals[0] : 0L; secondval = (debug_cb->db_value_count > 1) ? debug_cb->db_vals[1] : 0L; /* see if this is an action trace. Action traces require an immediate ** action rather than turning trace flags on/off/etc. */ if ( (debug_cb->db_trswitch==DB_TR_ON) && (flag <= RD_ACT_MAX) ) { /* see which action is requested. Not all actions are implemented ** yet, so its possible that this call may become a no-opt */ switch (flag) { case RD0001: case RD0002: case RD0003: case RD0004: case RD0005: case RD0010: status=rdt_clear_cache(flag); if (DB_FAILURE_MACRO(status)) { return(E_DB_ERROR); } break; case RD0011: /* dump memory info. This trace is used by tech support when ** debugging out of memory errors. */ TRdisplay("\n...............................................\n"); TRdisplay("RDF Cache Memory Available: %d\n",Rdi_svcb->rdv_memleft); TRdisplay("RDF memory cache size : %d\n", Rdi_svcb->rdv_pool_size); TRdisplay("Max number of objects allowed on Cache:\n"); TRdisplay(" RELcache: %d, QTREE Cache: %d, \n", Rdi_svcb->rdv_cnt0_rdesc, Rdi_svcb->rdv_cnt1_qtree); TRdisplay(" LDBDesc Cache %d, DEFAULTS cache: %d\n", Rdi_svcb->rdv_cnt2_dist, Rdi_svcb->rdv_cnt3_default); TRdisplay("Hashids:\n"); TRdisplay(" RELcache: %d, QTREE Cache: %d, \n", Rdi_svcb->rdv_rdesc_hashid, Rdi_svcb->rdv_qtree_hashid); TRdisplay(" LDBDesc Cache %d, DEFAULTS cache: %d\n", Rdi_svcb->rdv_dist_hashid, Rdi_svcb->rdv_def_hashid); TRdisplay("...............................................\n"); break; case RD0012: /* dump all of the RDF statistics */ rdf_report ( &Rdi_svcb->rdvstat ); break; default: break; } } else { /* ** determine if this is a session wide trace or a server wide trace ** and process accordingly */ trace_scope = trace_type(flag); if (trace_scope == SVR_WIDE_TRACE) { /* turn trace on in svcb ** ** Three possible actions: Turn on flag, turn it off, or do nothing. */ switch (debug_cb->db_trswitch) { case DB_TR_ON: if ((flag == RD0022) && !(ult_check_macro(&Rdi_svcb->rdf_trace, flag, &firstval, &secondval))) { /* setting RDU_CHECKSUM */ RDF_GLOBAL global; RDF_CB rdfcb; RDI_FCB fcb; global.rdfcb = &rdfcb; rdfcb.rdf_rb.rdr_fcb = (PTR)&fcb; rdfcb.rdf_info_blk = NULL; rdfcb.rdf_rb.rdr_db_id = NULL; rdfcb.rdf_rb.rdr_types_mask = 0; rdfcb.rdf_rb.rdr_2types_mask = 0; CSget_sid(&rdfcb.rdf_rb.rdr_session_id); fcb.rdi_fac_id = DB_RDF_ID; status = rdf_invalidate(&global, &rdfcb); if (DB_FAILURE_MACRO(status)) return(E_DB_ERROR); } ult_set_macro(&Rdi_svcb->rdf_trace, flag, firstval, secondval); break; case DB_TR_OFF: ult_clear_macro(&Rdi_svcb->rdf_trace, flag); break; case DB_TR_NOCHANGE: /* Do nothing */ break; default: return (E_DB_ERROR); }; } else { CS_SID sid; RDF_SESS_CB *rdf_sess_cb; /* ** this trace point is session specific, so use the session control ** block for this trace point. */ CSget_sid(&sid); rdf_sess_cb = GET_RDF_SESSCB(sid); /* ** Three possible actions: Turn on flag, turn it off, or do nothing. */ switch (debug_cb->db_trswitch) { case DB_TR_ON: ult_set_macro(&rdf_sess_cb->rds_strace, flag, firstval, secondval); break; case DB_TR_OFF: ult_clear_macro(&rdf_sess_cb->rds_strace, flag); break; case DB_TR_NOCHANGE: /* Do nothing */ break; default: return (E_DB_ERROR); } } } return (E_DB_OK); }
/*{ ** Name: sxf_trace - SXF trace entry point. ** ** Description: ** This routine takes a standard trace control block as input, and ** sets or clears the given trace point. The trace points are either ** specific to a session or server wide. ** ** Inputs: ** debug_cb A standard debug control block. ** ** Outputs: ** Returns: ** E_DB_OK ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 16-jun-93 (robf) ** Created for Secure 2.0 ** 11-oct-93 (robf) ** Rework includes per current integration ** 30-mar-94 (robf) ** Add tracing of shared memory info. ** 09-Sep-2008 (jonj) ** Correct mis-typed ule_format output error_code. */ DB_STATUS sxf_trace( DB_DEBUG_CB *trace_cb ) { i4 bitno = trace_cb->db_trace_point; DB_STATUS status=E_DB_OK; i4 *vector ; i4 err_code; SXF_SCB *scb; i4 error; switch (bitno) { case SXS_TDUMP_SHM: /* ** Dump shared memory */ sxap_shm_dump(); SXF_DISPLAY("SXF shared memory info dumped to trace log"); break; case SXS_TDUMP_STATS: /* ** Dump statistics */ sxc_printstats(); SXF_DISPLAY("SXF server statistics dumped to trace log"); break; case SXS_TDUMP_SESSION: /* ** Dump session info */ status = sxau_get_scb(&scb, &err_code); if (status != E_DB_OK) { _VOID_ ule_format(err_code, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); _VOID_ ule_format(E_SX001E_TRACE_FLAG_ERR, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); break; } SXF_DISPLAY("SXF Session info dumped to trace log"); break; case 0: case SXS_TAUD_LOG: case SXS_TAUD_PHYS: case SXS_TAUD_STATE: case SXS_TAUD_SHM: case SXS_TAUD_PLOCK: status = sxau_get_scb(&scb, &err_code); if (status != E_DB_OK) { _VOID_ ule_format(err_code, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); _VOID_ ule_format(E_SX001E_TRACE_FLAG_ERR, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); break; } if (trace_cb->db_trswitch == DB_TR_ON) { if (ult_set_macro(&scb->sxf_trace, (trace_cb->db_trace_point), trace_cb->db_vals[0], trace_cb->db_vals[1]) != E_DB_OK) { _VOID_ ule_format(E_SX001E_TRACE_FLAG_ERR, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); } } else if (trace_cb->db_trswitch == DB_TR_OFF) { if (ult_clear_macro(&scb->sxf_trace, (trace_cb->db_trace_point)) != E_DB_OK) { _VOID_ ule_format(E_SX001E_TRACE_FLAG_ERR, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); } } break; default: _VOID_ ule_format(E_SX001E_TRACE_FLAG_ERR, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); } sxf_tracing_on=TRUE; return (status); }