MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / startSession

Method startSession

src/utilities/fbtracemgr/traceMgrMain.cpp:117–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117void TraceSvcUtil::startSession(TraceSession& session, bool /*interactive*/)
118{
119 HalfStaticArray<UCHAR, 1024> buff(*getDefaultMemoryPool());
120 UCHAR* p = NULL;
121 long len = 0;
122
123 FILE* file = NULL;
124
125 try
126 {
127 const char* fileName = session.ses_config.c_str();
128 file = os_utils::fopen(fileName, "rb");
129 if (!file)
130 {
131 (Arg::Gds(isc_io_error) << Arg::Str("fopen") << Arg::Str(fileName) <<
132 Arg::Gds(isc_io_open_err) << Arg::OsError()).raise();
133 }
134
135 fseek(file, 0, SEEK_END);
136 len = ftell(file);
137 if (len == 0)
138 {
139 (Arg::Gds(isc_io_error) << Arg::Str("fread") << Arg::Str(fileName) <<
140 Arg::Gds(isc_io_read_err) << Arg::OsError()).raise();
141 }
142
143 fseek(file, 0, SEEK_SET);
144 p = buff.getBuffer(len);
145
146 if (fread(p, 1, len, file) != size_t(len))
147 {
148 (Arg::Gds(isc_io_error) << Arg::Str("fread") << Arg::Str(fileName) <<
149 Arg::Gds(isc_io_read_err) << Arg::OsError()).raise();
150 }
151 fclose(file);
152 }
153 catch (const Exception&)
154 {
155 if (file)
156 fclose(file);
157
158 throw;
159 }
160
161 ClumpletWriter spb(ClumpletWriter::SpbStart, MAXBUF);
162
163 spb.insertTag(isc_action_svc_trace_start);
164 spb.insertBytes(isc_spb_trc_cfg, p, len);
165
166 if (session.ses_name.hasData())
167 {
168 spb.insertBytes(isc_spb_trc_name,
169 reinterpret_cast<const UCHAR*> (session.ses_name.c_str()),
170 session.ses_name.length());
171 }
172
173 runService(spb.getBufferLength(), spb.getBuffer());
174}

Callers

nothing calls this directly

Calls 15

getDefaultMemoryPoolFunction · 0.85
GdsClass · 0.85
StrClass · 0.85
OsErrorClass · 0.85
fseekFunction · 0.85
ftellFunction · 0.85
fcloseFunction · 0.85
fopenFunction · 0.50
c_strMethod · 0.45
raiseMethod · 0.45
getBufferMethod · 0.45
insertTagMethod · 0.45

Tested by

no test coverage detected