QuTech-Delft / OpenQL

OpenQL: A Portable Quantum Programming Framework for Quantum Accelerators. https://dl.acm.org/doi/10.1145/3474222
https://openql.readthedocs.io
Other
99 stars 44 forks source link

Add stack trace to ql::exception message #366

Closed jvanstraten closed 3 years ago

jvanstraten commented 3 years ago

Given platform support (backward supports a bunch of backends) ql::exception now does a stack trace upon construction and appends it to its exception message. It's probably not great in terms of performance, so if it slows things down it should probably be made optional at some point, but for now it should aid debugging.

Example:

terminate called after throwing an instance of 'ql::exception'
  what():  hello this is a test
Stack trace (most recent call last):
#8    Object "", at 0xffffffffffffffff, in 
#7    Source "../sysdeps/x86_64/start.S", line 120, in _start
#6    Object "/lib64/libc-2.26.so", at 0x2afec7550349, in __libc_start_main
#5    Source "/data/quantum/openql-work/develop/tests/test_mapper.cc", line 1434, in main
#4    Source "/data/quantum/openql-work/develop/tests/test_mapper.cc", line 79, in test_dpt
#3    Source "/data/quantum/openql-work/develop/src/program.cc", line 353, in compile
#2    Source "/data/quantum/openql-work/develop/src/arch/cc_light/cc_light_eqasm_compiler.cc", line 902, in compile
#1    Source "/data/quantum/openql-work/develop/src/arch/cc_light/cc_light_eqasm_compiler.cc", line 748, in map
#0    Source "/data/quantum/openql-work/develop/src/mapper.cc", line 2952, in Init

(location of the test exception was just arbitrarily chosen, of course)

jvansomeren commented 3 years ago

Done

Op 28 okt. 2020, om 16:46 heeft jvanstraten notifications@github.com<mailto:notifications@github.com> het volgende geschreven:

@jvanstratenhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_jvanstraten&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=ocuB3DldwmO5vzyJN6uE5GsV9JTb-QOHhmigPr8k-Uo&s=Uu8XVlFJiIUi3F9kbiar3OAZocy8kmPWHWP34WjVnfg&e= requested your review on: #366https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_QE-2DLab_OpenQL_pull_366&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=ocuB3DldwmO5vzyJN6uE5GsV9JTb-QOHhmigPr8k-Uo&s=kTftgKXOgMf2VeI9uUqgtceA_TFOSro3eGol-ZXzfJI&e= Add stack trace to ql::exception message.

— You are receiving this because your review was requested. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_QE-2DLab_OpenQL_pull_366-23event-2D3932000010&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=ocuB3DldwmO5vzyJN6uE5GsV9JTb-QOHhmigPr8k-Uo&s=DT_5OeulH14xECgTU6IPApowsX_89P9It8E-YUNCb4A&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AEDTBNVYFJSGTZLIMLFUSX3SNA4ENANCNFSM4TCNIYOA&d=DwMCaQ&c=XYzUhXBD2cD-CornpT4QE19xOJBbRy-TBPLK0X9U2o8&r=kNdT9ewT6pQdYFkBLR_5-ZqsrSTk7k5Hdd7MSC_Vnzg&m=ocuB3DldwmO5vzyJN6uE5GsV9JTb-QOHhmigPr8k-Uo&s=pnR-vJxh7gc8pzDhNqzoAHxS9jH2d5BER3IYonG2ipQ&e=.