Skip to content

Commit 5dcc901

Browse files
committed
MB-32598: Reduce the number of times to invoke gdb
The breakpad tests used to invoke gdb several times to inspect various pieces of the minidump file. Unfortunately the startup cost of gdb seems to be relatively high so we should try to reduce the number of times it is invoked. To work around this we'll invoke gdb a single time, and execute all of the commands in a single batch. To make it easy to figure out the result from each command we invoke 'show print pretty' between each command so that we can easily use the result of that command to split the output. Change-Id: Ie2fd605c589753d695caa8fd883cc0a3db13a4f6 Reviewed-on: http://review.couchbase.org/103586 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 4eb1c71 commit 5dcc901

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

tests/breakpad_test.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,28 @@ def target():
216216
os.remove(minidump)
217217
cleanup_and_exit(7)
218218

219+
# To avoid invoking gdb multiple times, lets collect all of the
220+
# information in a single pass. To make it easy to figure out
221+
# the output from each command, run 'show print pretty' and use
222+
# the expected output from that command to split the data
223+
logging.info('GDB: Collect information from the minidump file')
224+
gdb_output = invoke_gdb(gdb_exe, memcached_exe, core_file,
225+
['set print pretty off',
226+
'show print pretty',
227+
'info shared',
228+
'show print pretty',
229+
'backtrace',
230+
'show print pretty',
231+
'x/x $sp'])
232+
gdb_output = gdb_output.split("Pretty formatting of structures is off.")
233+
219234
# Check for shared library information, and symbols successfully ead
220235
# (needed for any useful backtraces).
221236
# Shared libraries may change over time, but we explicitly asked for
222237
# crash_engine.so in the config so we should have that.
223238
logging.info('GDB: Checking for shared library information')
224-
gdb_output = invoke_gdb(gdb_exe, memcached_exe, core_file,
225-
['info shared'])
226239
m = re.search("^0x[0-9a-f]+\s+0x[0-9a-f]+\s+(\w+)\s+([^\s]+crash_engine\.so$)",
227-
gdb_output, re.MULTILINE)
240+
gdb_output[1], re.MULTILINE)
228241
if not m:
229242
logging.error("FAIL - GDB unable to show information for " +
230243
"crash_engine.so shared library.")
@@ -240,9 +253,7 @@ def target():
240253
# particular trace. Instead we check that all frames but the first have
241254
# a useful-looking symbol (and not just a random address.)
242255
logging.info('GDB: Checking for sensible backtrace')
243-
gdb_output = invoke_gdb(gdb_exe, memcached_exe, core_file,
244-
['backtrace'])
245-
lines = gdb_output.splitlines()
256+
lines = gdb_output[2].splitlines()
246257

247258
# Discard all those lines before the stacktrace
248259
backtrace = [i for i in lines if re.match('#\d+', i)]
@@ -274,9 +285,7 @@ def target():
274285
# Check we can read stack memory. Another tricky one as again we have
275286
# no idea where we crashed. Just ensure that we get *something* back
276287
logging.info('GDB: Checking for readable stack memory')
277-
gdb_output = invoke_gdb(gdb_exe, memcached_exe, core_file,
278-
['x/x $sp'])
279-
m = re.search('(0x[0-9a-f]+):\s(0x[0-9a-f]+)?', gdb_output)
288+
m = re.search('(0x[0-9a-f]+):\s(0x[0-9a-f]+)?', gdb_output[3])
280289
if not m:
281290
logging.error("FAIL - GDB failed to output memory disassembly when " +
282291
"attempting to examine stack.")

0 commit comments

Comments
 (0)