diff options
author | Brendan Long <self@brendanlong.com> | 2018-12-27 23:28:10 +0300 |
---|---|---|
committer | Brendan Long <self@brendanlong.com> | 2018-12-28 00:09:05 +0300 |
commit | eebdc6f83f311730cd6b0c210836ac4b134080fc (patch) | |
tree | 7eb33da7995c36a7fd1b38703e402aa53e6930a9 /libraries | |
parent | e7776503fce12e470c879688c0bb675435e2258f (diff) |
Run Vala code though Uncrustify
This uses the changes in these two Uncrustify pull requests:
https://github.com/uncrustify/uncrustify/pull/2142
https://github.com/uncrustify/uncrustify/pull/2137
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/WebExtension/webextension.vala | 268 | ||||
-rw-r--r-- | libraries/libIvy/Extractor.vala | 722 | ||||
-rw-r--r-- | libraries/libIvy/Frame.vala | 146 | ||||
-rw-r--r-- | libraries/libIvy/Printer.vala | 406 | ||||
-rw-r--r-- | libraries/libIvy/Stacktrace.vala | 700 |
5 files changed, 1121 insertions, 1121 deletions
diff --git a/libraries/WebExtension/webextension.vala b/libraries/WebExtension/webextension.vala index 5b64914c..2b5360f0 100644 --- a/libraries/WebExtension/webextension.vala +++ b/libraries/WebExtension/webextension.vala @@ -1,175 +1,175 @@ [DBus (name = "org.gnome.FeedReader.ArticleView")] public class FeedReaderWebExtension : Object { - private WebKit.DOM.Document m_doc; - public signal void onClick(string path, int width, int height, string url); - public signal void message(string message); +private WebKit.DOM.Document m_doc; +public signal void onClick(string path, int width, int height, string url); +public signal void message(string message); - [DBus (visible = false)] - public void on_bus_aquired(DBusConnection connection) +[DBus (visible = false)] +public void on_bus_aquired(DBusConnection connection) +{ + try { - try - { - connection.register_object("/org/gnome/FeedReader/ArticleView", this); - } - catch(GLib.IOError e) - { - warning("Could not register object"); - } + connection.register_object("/org/gnome/FeedReader/ArticleView", this); } - - [DBus (visible = false)] - public void on_page_created(WebKit.WebExtension extension, WebKit.WebPage page) + catch(GLib.IOError e) { - page.document_loaded.connect(() => { + warning("Could not register object"); + } +} + +[DBus (visible = false)] +public void on_page_created(WebKit.WebExtension extension, WebKit.WebPage page) +{ + page.document_loaded.connect(() => { onDocLoaded(page); }); - message("on_page_created"); - } + message("on_page_created"); +} - private void onDocLoaded(WebKit.WebPage page) - { - m_doc = page.get_dom_document(); - message("onDocLoaded"); - } +private void onDocLoaded(WebKit.WebPage page) +{ + m_doc = page.get_dom_document(); + message("onDocLoaded"); +} + +public void recalculate() +{ + message("recalculate"); + var images = m_doc.get_images(); + ulong count = images.get_length(); - public void recalculate() + for(ulong i = 0; i < count; i++) { - message("recalculate"); - var images = m_doc.get_images(); - ulong count = images.get_length(); + var image = (WebKit.DOM.HTMLImageElement)images.item(i); - for(ulong i = 0; i < count; i++) + // don't offer imageviewer if image isn't local + if(image.src.has_prefix("http")) + continue; + + // if image was so huge it had to be replaced with a downscaled version + if(image.has_attribute("FR_huge")) { - var image = (WebKit.DOM.HTMLImageElement)images.item(i); - - // don't offer imageviewer if image isn't local - if(image.src.has_prefix("http")) - continue; - - // if image was so huge it had to be replaced with a downscaled version - if(image.has_attribute("FR_huge")) - { - addListener(image, image.get_attribute("FR_huge")); - continue; - } - else if(image.has_attribute("FR_parent")) - { - addListener(image, image.get_attribute("FR_parent")); - continue; - } - - long nHeight = image.get_natural_height(); - long nWidth = image.get_natural_width(); - long height = image.get_height(); - long width = image.get_width(); - - if(nHeight > 250 || nWidth > 250) - { - double hRatio = (double)height / (double)nHeight; - double wRatio = (double)width / (double)nWidth; - double threshold = 0.8; - - if(hRatio <= threshold - || wRatio <= threshold) - addListener(image, image.src); - else - removeListener(image); - } + addListener(image, image.get_attribute("FR_huge")); + continue; } - } - - [DBus (visible = false)] - private void addListener(WebKit.DOM.HTMLImageElement image, string url) - { - // check if url exists - if(GLib.FileUtils.test(url, GLib.FileTest.EXISTS)) + else if(image.has_attribute("FR_parent")) { - ((WebKit.DOM.EventTarget) image).add_event_listener_with_closure("mouseover", on_enter, false); - ((WebKit.DOM.EventTarget) image).add_event_listener_with_closure("mousemove", on_enter, false); - ((WebKit.DOM.EventTarget) image).add_event_listener_with_closure("mouseout", on_leave, false); - ((WebKit.DOM.EventTarget) image).add_event_listener_with_closure("click", on_click, false); + addListener(image, image.get_attribute("FR_parent")); + continue; } - } - [DBus (visible = false)] - private void removeListener(WebKit.DOM.HTMLImageElement image) - { - ((WebKit.DOM.EventTarget) image).remove_event_listener_with_closure("mouseover", on_enter, false); - ((WebKit.DOM.EventTarget) image).remove_event_listener_with_closure("mousemove", on_enter, false); - ((WebKit.DOM.EventTarget) image).remove_event_listener_with_closure("mouseout", on_leave, false); - ((WebKit.DOM.EventTarget) image).remove_event_listener_with_closure("click", on_click, false); + long nHeight = image.get_natural_height(); + long nWidth = image.get_natural_width(); + long height = image.get_height(); + long width = image.get_width(); - try + if(nHeight > 250 || nWidth > 250) { - image.set_attribute("class", ""); - } - catch(GLib.Error e) - { - stderr.printf("WebExtension.recalculate: %s", e.message); + double hRatio = (double)height / (double)nHeight; + double wRatio = (double)width / (double)nWidth; + double threshold = 0.8; + + if(hRatio <= threshold + || wRatio <= threshold) + addListener(image, image.src); + else + removeListener(image); } } +} - [DBus (visible = false)] - private void on_enter(WebKit.DOM.EventTarget target, WebKit.DOM.Event event) +[DBus (visible = false)] +private void addListener(WebKit.DOM.HTMLImageElement image, string url) +{ + // check if url exists + if(GLib.FileUtils.test(url, GLib.FileTest.EXISTS)) { - try - { - var image = (WebKit.DOM.HTMLImageElement)target; - image.set_attribute("class", "clickable-img-hover"); - } - catch(GLib.Error e) - { + ((WebKit.DOM.EventTarget)image).add_event_listener_with_closure("mouseover", on_enter, false); + ((WebKit.DOM.EventTarget)image).add_event_listener_with_closure("mousemove", on_enter, false); + ((WebKit.DOM.EventTarget)image).add_event_listener_with_closure("mouseout", on_leave, false); + ((WebKit.DOM.EventTarget)image).add_event_listener_with_closure("click", on_click, false); + } +} - } +[DBus (visible = false)] +private void removeListener(WebKit.DOM.HTMLImageElement image) +{ + ((WebKit.DOM.EventTarget)image).remove_event_listener_with_closure("mouseover", on_enter, false); + ((WebKit.DOM.EventTarget)image).remove_event_listener_with_closure("mousemove", on_enter, false); + ((WebKit.DOM.EventTarget)image).remove_event_listener_with_closure("mouseout", on_leave, false); + ((WebKit.DOM.EventTarget)image).remove_event_listener_with_closure("click", on_click, false); + + try + { + image.set_attribute("class", ""); } + catch(GLib.Error e) + { + stderr.printf("WebExtension.recalculate: %s", e.message); + } +} - [DBus (visible = false)] - private void on_leave(WebKit.DOM.EventTarget target, WebKit.DOM.Event event) +[DBus (visible = false)] +private void on_enter(WebKit.DOM.EventTarget target, WebKit.DOM.Event event) +{ + try + { + var image = (WebKit.DOM.HTMLImageElement)target; + image.set_attribute("class", "clickable-img-hover"); + } + catch(GLib.Error e) { - try - { - var image = (WebKit.DOM.HTMLImageElement)target; - image.set_attribute("class", ""); - } - catch(GLib.Error e) - { - } } +} - [DBus (visible = false)] - public void on_click(WebKit.DOM.EventTarget target, WebKit.DOM.Event event) +[DBus (visible = false)] +private void on_leave(WebKit.DOM.EventTarget target, WebKit.DOM.Event event) +{ + try { - event.prevent_default(); var image = (WebKit.DOM.HTMLImageElement)target; + image.set_attribute("class", ""); + } + catch(GLib.Error e) + { - string url = ""; - var parent = image.get_parent_element(); - if(parent.tag_name == "A") - url = parent.get_attribute("href"); + } +} +[DBus (visible = false)] +public void on_click(WebKit.DOM.EventTarget target, WebKit.DOM.Event event) +{ + event.prevent_default(); + var image = (WebKit.DOM.HTMLImageElement)target; - int height = (int)image.natural_height; - int width = (int)image.natural_width; - string src = image.src; - string pref = "file://"; - if(src.has_prefix(pref)) - src = src.substring(pref.length); + string url = ""; + var parent = image.get_parent_element(); + if(parent.tag_name == "A") + url = parent.get_attribute("href"); - if(image.has_attribute("FR_huge")) - { - src = image.get_attribute("FR_huge"); - Gdk.Pixbuf.get_file_info(src, out width, out height); - } - else if(image.has_attribute("FR_parent")) - { - src = image.get_attribute("FR_parent"); - Gdk.Pixbuf.get_file_info(src, out width, out height); - } - onClick(src, width, height, url); + int height = (int)image.natural_height; + int width = (int)image.natural_width; + string src = image.src; + string pref = "file://"; + if(src.has_prefix(pref)) + src = src.substring(pref.length); + + if(image.has_attribute("FR_huge")) + { + src = image.get_attribute("FR_huge"); + Gdk.Pixbuf.get_file_info(src, out width, out height); } + else if(image.has_attribute("FR_parent")) + { + src = image.get_attribute("FR_parent"); + Gdk.Pixbuf.get_file_info(src, out width, out height); + } + + onClick(src, width, height, url); +} } [DBus (name = "org.gnome.FeedReader.ArticleView")] @@ -184,5 +184,5 @@ public void webkit_web_extension_initialize(WebKit.WebExtension extension) var server = new FeedReaderWebExtension(); extension.page_created.connect(server.on_page_created); Bus.own_name(BusType.SESSION, "org.gnome.FeedReader.ArticleView", BusNameOwnerFlags.NONE, - server.on_bus_aquired, null, () => { warning("Could not aquire name"); }); + server.on_bus_aquired, null, () => { warning("Could not aquire name"); }); } diff --git a/libraries/libIvy/Extractor.vala b/libraries/libIvy/Extractor.vala index cb939567..b6126963 100644 --- a/libraries/libIvy/Extractor.vala +++ b/libraries/libIvy/Extractor.vala @@ -16,407 +16,407 @@ namespace Ivy { - /** - * Extracts frames and builds a {@link Stacktrace} - * - */ - public class Extractor { - - private bool show_debug_frames = false; - - private string func = ""; - private string file_path = ""; - private string short_file_path = ""; - private string l = ""; - private string file_line = ""; - private string func_line = ""; - private string lib_address =""; - - private static Gee.List<string> libraries_with_no_info = new Gee.ArrayList<string>(); - - private string get_module_name () { - var path = new char[1024]; - Posix.readlink ("/proc/self/exe", path); - string result = (string) path; - return result; - } +/** + * Extracts frames and builds a {@link Stacktrace} + * + */ +public class Extractor { - // TODO CARL convert this piece of code to vala conventions - private static string get_relative_path (string p_fullDestinationPath, string p_startPath) { +private bool show_debug_frames = false; - string[] l_startPathParts = p_startPath.split ("/"); - string[] l_destinationPathParts = p_fullDestinationPath.split ("/"); +private string func = ""; +private string file_path = ""; +private string short_file_path = ""; +private string l = ""; +private string file_line = ""; +private string func_line = ""; +private string lib_address =""; - int l_sameCounter = 0; - while ((l_sameCounter < l_startPathParts.length) && - (l_sameCounter < l_destinationPathParts.length) && - l_startPathParts[l_sameCounter] == l_destinationPathParts[l_sameCounter]) { - l_sameCounter++; - } +private static Gee.List<string> libraries_with_no_info = new Gee.ArrayList<string>(); - if (l_sameCounter == 0) { - return p_fullDestinationPath; // There is no relative link. - } +private string get_module_name () { + var path = new char[1024]; + Posix.readlink ("/proc/self/exe", path); + string result = (string) path; + return result; +} - StringBuilder l_builder = new StringBuilder (); - for (int i = l_sameCounter ; i < l_startPathParts.length ; i++) { - l_builder.append ("../"); - } +// TODO CARL convert this piece of code to vala conventions +private static string get_relative_path (string p_fullDestinationPath, string p_startPath) { - for (int i = l_sameCounter ; i < l_destinationPathParts.length ; i++) { - l_builder.append (l_destinationPathParts[i] + "/"); - } + string[] l_startPathParts = p_startPath.split ("/"); + string[] l_destinationPathParts = p_fullDestinationPath.split ("/"); - // CARL l_builder.Length--; - // Remove the last / - var result = l_builder.str; - result = result.substring (0, result.length - 1); - return result; - } + int l_sameCounter = 0; + while ((l_sameCounter < l_startPathParts.length) && + (l_sameCounter < l_destinationPathParts.length) && + l_startPathParts[l_sameCounter] == l_destinationPathParts[l_sameCounter]) { + l_sameCounter++; + } - private string extract_short_file_path (string file_path) { - var path = Environment.get_current_dir (); - /*var i = file_path.index_of ( path ); - if( i>=0 ) - return file_path.substring ( path.length, file_path.length - path.length ); - return file_path; */ - var result = get_relative_path (file_path, path); - return result; - } + if (l_sameCounter == 0) { + return p_fullDestinationPath; // There is no relative link. + } - // input : '/home/cran/Documents/Projects/elementary/noise/instant-beta/build/core/libnoise-core.so.0(noise_job_repository_create_job+0x309) [0x7ff60a021e69]' - // ouput: 0x309 - private int extract_base_address (string line) { - int result = 0; - var start = line.last_index_of ("+"); - if (start >= 0) { - var end = line.last_index_of (")"); - if( end > start ) { - var text = line.substring (start+3,end-start-3); - text.scanf("%x", &result); - } - } - return result; - } + StringBuilder l_builder = new StringBuilder (); + for (int i = l_sameCounter; i < l_startPathParts.length; i++) { + l_builder.append ("../"); + } - private void process_info_for_file (string full_line, string str ) { - func = ""; - file_path = ""; - short_file_path = ""; - l = ""; - file_line = ""; - func_line = ""; - if (full_line == "") - return; - - var lines = full_line.split ("\n"); - - if (lines.length > 0) - func_line = lines[0]; - - if (lines.length > 1) - file_line = lines[1]; - if (file_line == "??:0" || file_line == "??:?") - file_line = ""; - func = extract_function_name (str); - - file_path = ""; - short_file_path = ""; - l = ""; - if (file_line != "") { - if (func == "") - func = extract_function_name_from_line (func_line); - file_path = extract_file_path (file_line); - short_file_path = extract_short_file_path (file_path); - l = extract_line (file_line); - } + for (int i = l_sameCounter; i < l_destinationPathParts.length; i++) { + l_builder.append (l_destinationPathParts[i] + "/"); + } + + // CARL l_builder.Length--; + // Remove the last / + var result = l_builder.str; + result = result.substring (0, result.length - 1); + return result; +} + +private string extract_short_file_path (string file_path) { + var path = Environment.get_current_dir (); + /*var i = file_path.index_of ( path ); + if( i>=0 ) + return file_path.substring ( path.length, file_path.length - path.length ); + return file_path; */ + var result = get_relative_path (file_path, path); + return result; +} + +// input : '/home/cran/Documents/Projects/elementary/noise/instant-beta/build/core/libnoise-core.so.0(noise_job_repository_create_job+0x309) [0x7ff60a021e69]' +// ouput: 0x309 +private int extract_base_address (string line) { + int result = 0; + var start = line.last_index_of ("+"); + if (start >= 0) { + var end = line.last_index_of (")"); + if( end > start ) { + var text = line.substring (start+3,end-start-3); + text.scanf("%x", &result); } + } + return result; +} + +private void process_info_for_file (string full_line, string str ) { + func = ""; + file_path = ""; + short_file_path = ""; + l = ""; + file_line = ""; + func_line = ""; + if (full_line == "") + return; + + var lines = full_line.split ("\n"); + + if (lines.length > 0) + func_line = lines[0]; + + if (lines.length > 1) + file_line = lines[1]; + if (file_line == "??:0" || file_line == "??:?") + file_line = ""; + func = extract_function_name (str); + + file_path = ""; + short_file_path = ""; + l = ""; + if (file_line != "") { + if (func == "") + func = extract_function_name_from_line (func_line); + file_path = extract_file_path (file_line); + short_file_path = extract_short_file_path (file_path); + l = extract_line (file_line); + } +} + +private void process_info_from_lib (string file_path, string str) { + //stdout.printf( "process_info_from_lib('%s', '%s') func: '%s'\n", file_path, str, func); + var has_info = true; + var addr1_s = ""; + var lib_addr = ""; + var cmd2 = ""; + lib_address =""; + lock( libraries_with_no_info) + { + if( libraries_with_no_info.index_of (file_path) == -1 ) { + // The library is not on the black list + cmd2 = "nm %s".printf(file_path); + + addr1_s = execute_command_sync_get_output (cmd2); + if( addr1_s == null || addr1_s == "" ) + { + // stdout.printf( "ADDED TO NO INFO: '%s'\n", file_path); + libraries_with_no_info.add (file_path); + has_info = false; - private void process_info_from_lib (string file_path, string str) { - //stdout.printf( "process_info_from_lib('%s', '%s') func: '%s'\n", file_path, str, func); - var has_info = true; - var addr1_s = ""; - var lib_addr = ""; - var cmd2 = ""; - lib_address =""; - lock( libraries_with_no_info) - { - if( libraries_with_no_info.index_of (file_path) == -1 ){ - // The library is not on the black list - cmd2 = "nm %s".printf(file_path); - - addr1_s = execute_command_sync_get_output (cmd2); - if( addr1_s == null || addr1_s == "" ) - { - // stdout.printf( "ADDED TO NO INFO: '%s'\n", file_path); - libraries_with_no_info.add (file_path); - has_info = false; - - } - } - else - has_info = false; } - if( has_info && func != "" ) + } + else + has_info = false; + } + if( has_info && func != "" ) + { + MatchInfo info; + var expression = "\\n[^ ]* T "+func; + try { + + Regex regex = new Regex (expression); + int count = 0; + string matches = ""; + if( regex.match (addr1_s, 0, out info) ) { - MatchInfo info; - var expression = "\\n[^ ]* T "+func; - try { - - Regex regex = new Regex (expression); - int count = 0; - string matches = ""; - if( regex.match (addr1_s, 0, out info) ) - { - while( info.matches() ){ - var lll = info.fetch(0); - // stdout.printf ( "lll '%s'\n", lll ); - lib_addr = lll.substring(0, lll.index_of(" ")); - matches += lib_addr + "\n"; - info.next(); - count++; - } - if( count >1 ) - { - stdout.printf (" XX %d matches for '%s'. Command: '%s'. Matches: '%s'\n", count, func, cmd2, matches); - } - // stdout.printf (" YY %d matches for '%s'. Command: '%s'. Matches: '%s'\n", count, func, cmd2, matches); - } - - } catch (RegexError e) - { - critical( "Error while processing regex '%s. Err: '%s", expression, e.message ); + while( info.matches() ) { + var lll = info.fetch(0); + // stdout.printf ( "lll '%s'\n", lll ); + lib_addr = lll.substring(0, lll.index_of(" ")); + matches += lib_addr + "\n"; + info.next(); + count++; } - //stdout.printf ("addr1_s %s\n", addr1_s); - int addr1 = 0; - lib_addr.scanf("%x", &addr1); - if( addr1 != 0 ) { - int addr2 = extract_base_address (str); - string addr3 = "%#08x".printf (addr1+addr2); - lib_address = addr3; - // stdout.printf ("lib_address : %s\n", lib_address); - var new_full_line = process_line (file_path, addr3); - //stdout.printf ("STR : %s\n", str); - // stdout.printf ("AD1 : %s\n", addr1_s); - //stdout.printf ("AD2 : %#08x\n", addr2); - //stdout.printf ("AD3 : %s\n", addr3); - //stdout.printf ("LIB : %s\n", file_path); - //stdout.printf ("RES : %s\n", new_full_line); - - process_info_for_file (new_full_line, str ); + if( count >1 ) + { + stdout.printf (" XX %d matches for '%s'. Command: '%s'. Matches: '%s'\n", count, func, cmd2, matches); } - else - stdout.printf ("NULL\n"); + // stdout.printf (" YY %d matches for '%s'. Command: '%s'. Matches: '%s'\n", count, func, cmd2, matches); } + } catch (RegexError e) + { + critical( "Error while processing regex '%s. Err: '%s", expression, e.message ); } - - private string extract_function_name (string line) { - if (line == "") - return ""; - var start = line.index_of ("("); - if (start >= 0) { - var end = line.index_of ("+", start); - if (end >= 0) { - var result = line.substring (start + 1, end - start - 1); - return result.strip (); - } - } - return ""; + //stdout.printf ("addr1_s %s\n", addr1_s); + int addr1 = 0; + lib_addr.scanf("%x", &addr1); + if( addr1 != 0 ) { + int addr2 = extract_base_address (str); + string addr3 = "%#08x".printf (addr1+addr2); + lib_address = addr3; + // stdout.printf ("lib_address : %s\n", lib_address); + var new_full_line = process_line (file_path, addr3); + //stdout.printf ("STR : %s\n", str); + // stdout.printf ("AD1 : %s\n", addr1_s); + //stdout.printf ("AD2 : %#08x\n", addr2); + //stdout.printf ("AD3 : %s\n", addr3); + //stdout.printf ("LIB : %s\n", file_path); + //stdout.printf ("RES : %s\n", new_full_line); + + process_info_for_file (new_full_line, str ); } + else + stdout.printf ("NULL\n"); + } - private string extract_function_name_from_line (string line) { - return line.strip (); - } +} - private string extract_file_path_from (string str) { - if (str == "") - return ""; - /*if( str.index_of("??") >= 0) - //result = result.substring (4, line.length - 4 ); - stdout.printf ("ERR2?? : %s\n", str ) ; */ - var start = str.index_of ("("); - if (start >= 0) { - return str.substring (0, start).strip (); - } - return str.strip (); +private string extract_function_name (string line) { + if (line == "") + return ""; + var start = line.index_of ("("); + if (start >= 0) { + var end = line.index_of ("+", start); + if (end >= 0) { + var result = line.substring (start + 1, end - start - 1); + return result.strip (); } + } + return ""; +} - private string extract_file_path (string line) { - var result = line; - if (result == "") - return ""; - if (result == "??:0??:0") - return ""; - // For some reason, the file name can starts with ??:0 - if (result.has_prefix ("??:0")) - result = result.substring (4, line.length - 4); - // stdout.printf ("ERR1?? : %s\n", line ); - var start = result.index_of (":"); - if (start >= 0) { - result = result.substring (0, start); - return result.strip (); - } - return ""; - } +private string extract_function_name_from_line (string line) { + return line.strip (); +} - private static string extract_line (string line) { - var result = line; - if (result == "") - return ""; - if (result.has_prefix ("??:0")) - result = result.substring (4, line.length - 4); - var start = result.index_of (":"); - if (start >= 0) { - result = result.substring (start + 1, line.length - start - 1); - var end = result.index_of ("("); - if (end >= 0) { - result = result.substring (0, end); - } - return result.strip (); - } - return ""; +private string extract_file_path_from (string str) { + if (str == "") + return ""; + /*if( str.index_of("??") >= 0) + //result = result.substring (4, line.length - 4 ); + stdout.printf ("ERR2?? : %s\n", str ) ; */ + var start = str.index_of ("("); + if (start >= 0) { + return str.substring (0, start).strip (); + } + return str.strip (); +} + +private string extract_file_path (string line) { + var result = line; + if (result == "") + return ""; + if (result == "??:0??:0") + return ""; + // For some reason, the file name can starts with ??:0 + if (result.has_prefix ("??:0")) + result = result.substring (4, line.length - 4); + // stdout.printf ("ERR1?? : %s\n", line ); + var start = result.index_of (":"); + if (start >= 0) { + result = result.substring (0, start); + return result.strip (); + } + return ""; +} + +private static string extract_line (string line) { + var result = line; + if (result == "") + return ""; + if (result.has_prefix ("??:0")) + result = result.substring (4, line.length - 4); + var start = result.index_of (":"); + if (start >= 0) { + result = result.substring (start + 1, line.length - start - 1); + var end = result.index_of ("("); + if (end >= 0) { + result = result.substring (0, end); } + return result.strip (); + } + return ""; +} - private string extract_address (string line) { - if (line == "") - return ""; - var start = line.index_of ("["); - if (start >= 0) { - var end = line.index_of ("]", start); - if (end >= 0) { - var result = line.substring (start + 1, end - start - 1); - return result.strip (); - } - } - return ""; +private string extract_address (string line) { + if (line == "") + return ""; + var start = line.index_of ("["); + if (start >= 0) { + var end = line.index_of ("]", start); + if (end >= 0) { + var result = line.substring (start + 1, end - start - 1); + return result.strip (); } + } + return ""; +} - private string execute_command_sync_get_output (string cmd) { - try { - int exitCode; - string std_out; - string std_err; - Process.spawn_command_line_sync (cmd, out std_out, out std_err, out exitCode); - if( exitCode == 0) - return std_out; - else - print ("Error while executing '%s'. Exit code '%d'\n".printf(cmd, exitCode)); +private string execute_command_sync_get_output (string cmd) { + try { + int exitCode; + string std_out; + string std_err; + Process.spawn_command_line_sync (cmd, out std_out, out std_err, out exitCode); + if( exitCode == 0) + return std_out; + else + print ("Error while executing '%s'. Exit code '%d'\n".printf(cmd, exitCode)); - } - catch (Error e) { - print ("Error while executing '%s': %s\n".printf(cmd,e.message)); - } - return ""; - } + } + catch (Error e) { + print ("Error while executing '%s': %s\n".printf(cmd,e.message)); + } + return ""; +} - // Poor's man demangler. libunwind is another dep - // TODO : Optimize this - // module : app - // address : 0x007f80 - // output : /home/cran/Projects/noise/noise-perf-instant-search/tests/errors.vala:87 - private string process_line (string module, string address) { - var cmd = "addr2line -f -e %s %s".printf (module, address); - var result = execute_command_sync_get_output (cmd); - //stdout.printf( "CMD %s\n", cmd); - return result; - } +// Poor's man demangler. libunwind is another dep +// TODO : Optimize this +// module : app +// address : 0x007f80 +// output : /home/cran/Projects/noise/noise-perf-instant-search/tests/errors.vala:87 +private string process_line (string module, string address) { + var cmd = "addr2line -f -e %s %s".printf (module, address); + var result = execute_command_sync_get_output (cmd); + //stdout.printf( "CMD %s\n", cmd); + return result; +} - /** - * Populates the stacktrace with frames - * - * The frames are extracted from ``Linux.Backtrace`` and enriched - * via calls to unix tools ``nm`` and ``addr2line``. - * - * ''Warning:'' because this methods calls synchronously other applications (nm and addr2line), it - * can have a significant impact on performance. - * - * @param trace the stacktrace - */ - public void create_stacktrace (Stacktrace trace) { - int frame_count = 100; - int skipped_frames_count = 5; - // Stacktrace not due to a crash - if (trace.is_custom) - skipped_frames_count = 3; - - void *[] array = new void *[frame_count]; - - trace.frames.clear (); - trace.first_vala = null; - trace.max_file_name_length = 0; - trace.is_all_function_name_blank = true; - trace.is_all_file_name_blank = true; - - // TODO fix that > 0.26 +/** + * Populates the stacktrace with frames + * + * The frames are extracted from ``Linux.Backtrace`` and enriched + * via calls to unix tools ``nm`` and ``addr2line``. + * + * ''Warning:'' because this methods calls synchronously other applications (nm and addr2line), it + * can have a significant impact on performance. + * + * @param trace the stacktrace + */ +public void create_stacktrace (Stacktrace trace) { + int frame_count = 100; + int skipped_frames_count = 5; + // Stacktrace not due to a crash + if (trace.is_custom) + skipped_frames_count = 3; + + void *[] array = new void *[frame_count]; + + trace.frames.clear (); + trace.first_vala = null; + trace.max_file_name_length = 0; + trace.is_all_function_name_blank = true; + trace.is_all_file_name_blank = true; + + // TODO fix that > 0.26 #if VALA_0_26 || VALA_0_28 - var size = Linux.Backtrace.@get (array); - var strings = Linux.Backtrace.symbols (array); + var size = Linux.Backtrace.@get (array); + var strings = Linux.Backtrace.symbols (array); #else - int size = Linux.backtrace (array, frame_count); - unowned string[] strings = Linux.backtrace_symbols (array, size); - // Needed because of some weird bug - strings.length = size; + int size = Linux.backtrace (array, frame_count); + unowned string[] strings = Linux.backtrace_symbols (array, size); + // Needed because of some weird bug + strings.length = size; #endif - int[] addresses = (int[])array; - string module = get_module_name (); - // First ones are the handler - for (int i = skipped_frames_count ; i < size ; i++) { - int address = addresses[i]; - string str = strings[i]; - var addr = extract_address (str); - lib_address =""; - //stdout.printf ("9 '%s'. Addr: '%s' \n", func, addr); - var full_line = process_line (module, addr); - //stdout.printf ("10 '%s'\n", func); - if( full_line == "" ) { - // Happens when the process memory is going up and up - // Likely a memory leak - // Like in the test suite for echo - // ** (/home/cran/Documents/Projects/i-hate-farms/ide/echo/build/test:2859): - // CRITICAL **: vala_data_type_copy: assertion 'self != NULL' failed - // Error while executing 'addr2line -f -e /home/cran/Documents/Projects/i- - // hate-farms/ide/echo/build/test 0x2afe3b5beb32': Failed to fork (Cannot allocate memory) - - print ("Something went very wrong. Your stacktrace cannot be displayed\n"); - break; - } - process_info_for_file( full_line, str); - //stdout.printf ("11 '%s'\n", func); - if (file_line == "") { - file_path = extract_file_path_from (str); + int[] addresses = (int[])array; + string module = get_module_name (); + // First ones are the handler + for (int i = skipped_frames_count; i < size; i++) { + int address = addresses[i]; + string str = strings[i]; + var addr = extract_address (str); + lib_address =""; + //stdout.printf ("9 '%s'. Addr: '%s' \n", func, addr); + var full_line = process_line (module, addr); + //stdout.printf ("10 '%s'\n", func); + if( full_line == "" ) { + // Happens when the process memory is going up and up + // Likely a memory leak + // Like in the test suite for echo + // ** (/home/cran/Documents/Projects/i-hate-farms/ide/echo/build/test:2859): + // CRITICAL **: vala_data_type_copy: assertion 'self != NULL' failed + // Error while executing 'addr2line -f -e /home/cran/Documents/Projects/i- + // hate-farms/ide/echo/build/test 0x2afe3b5beb32': Failed to fork (Cannot allocate memory) + + print ("Something went very wrong. Your stacktrace cannot be displayed\n"); + break; + } + process_info_for_file( full_line, str); + //stdout.printf ("11 '%s'\n", func); + if (file_line == "") { + file_path = extract_file_path_from (str); - } - //stdout.printf ("12 '%s'\n", func); - // The file name may ends with .so or .so.0 ... - if( ".so" in file_path ) { - process_info_from_lib (file_path, str); - } - //stdout.printf ("14 '%s'\n", func); - if( show_debug_frames ) - { - stdout.printf ("\nFrame %d \n--------\n . addr: [%s]\n . full_line: '%s'\n . file_line: '%s'\n . func_line: '%s'\n . str : '%s'\n . func: '%s'\n . file: '%s'\n . line: '%s'\n . address: '%#08x'\n . lib_address: '%s'\n", - i, addr, full_line, file_line, func_line, str, func, file_path, l, address, lib_address); - } - if (func != "" && file_path.has_suffix (".vala") && trace.is_all_function_name_blank) - trace.is_all_function_name_blank = false; + } + //stdout.printf ("12 '%s'\n", func); + // The file name may ends with .so or .so.0 ... + if( ".so" in file_path ) { + process_info_from_lib (file_path, str); + } + //stdout.printf ("14 '%s'\n", func); + if( show_debug_frames ) + { + stdout.printf ("\nFrame %d \n--------\n . addr: [%s]\n . full_line: '%s'\n . file_line: '%s'\n . func_line: '%s'\n . str : '%s'\n . func: '%s'\n . file: '%s'\n . line: '%s'\n . address: '%#08x'\n . lib_address: '%s'\n", + i, addr, full_line, file_line, func_line, str, func, file_path, l, address, lib_address); + } + if (func != "" && file_path.has_suffix (".vala") && trace.is_all_function_name_blank) + trace.is_all_function_name_blank = false; - if (short_file_path != "" && trace.is_all_file_name_blank) - trace.is_all_file_name_blank = false; + if (short_file_path != "" && trace.is_all_file_name_blank) + trace.is_all_file_name_blank = false; - var line_number = extract_line (file_line); - var frame = new Frame (addr, file_line, func, file_path, short_file_path, line_number); + var line_number = extract_line (file_line); + var frame = new Frame (addr, file_line, func, file_path, short_file_path, line_number); - if (trace.first_vala == null && file_path.has_suffix (".vala")) - trace.first_vala = frame; + if (trace.first_vala == null && file_path.has_suffix (".vala")) + trace.first_vala = frame; - if (short_file_path.length > trace.max_file_name_length) - trace.max_file_name_length = short_file_path.length; - if (l.length > trace.max_line_number_length) - trace.max_line_number_length = l.length; - trace.frames.add (frame); - } - } + if (short_file_path.length > trace.max_file_name_length) + trace.max_file_name_length = short_file_path.length; + if (l.length > trace.max_line_number_length) + trace.max_line_number_length = l.length; + trace.frames.add (frame); } } +} +} diff --git a/libraries/libIvy/Frame.vala b/libraries/libIvy/Frame.vala index 383576b1..7d1bdc2c 100644 --- a/libraries/libIvy/Frame.vala +++ b/libraries/libIvy/Frame.vala @@ -16,87 +16,87 @@ namespace Ivy { - /** - * A part of a stacktrace - * - * This class represent on instance of a frame, ie a particular location - * in a binary (application or library) on the system called by the application - * - * ''Note:'' frames from system libraries without code information available are - * not displayed by default. See {@link Stacktrace.hide_installed_libraries} for how to - * display them. - **/ - public class Frame { +/** + * A part of a stacktrace + * + * This class represent on instance of a frame, ie a particular location + * in a binary (application or library) on the system called by the application + * + * ''Note:'' frames from system libraries without code information available are + * not displayed by default. See {@link Stacktrace.hide_installed_libraries} for how to + * display them. + **/ +public class Frame { - /** - * Address of the stack in hexadecimal - * - * Ex: ``0x309`` - **/ - public string address { get;private set;default = "";} +/** + * Address of the stack in hexadecimal + * + * Ex: ``0x309`` + **/ +public string address { get; private set; default = "";} - /** - * Line of code of the frame - * - * Can point to C code, Vala code or be blank if - * no symbol is available (or if -rdynamic has not been set during the - * compilation of the binary) - * - * Ex: - **/ - public string line { get;private set;default = "";} +/** + * Line of code of the frame + * + * Can point to C code, Vala code or be blank if + * no symbol is available (or if -rdynamic has not been set during the + * compilation of the binary) + * + * Ex: + **/ +public string line { get; private set; default = "";} - /** - * Line number in the code file. - * - * May be blank if no code information is available - * - * Ex: ``25`` - **/ - public string line_number { get;private set;default = "";} +/** + * Line number in the code file. + * + * May be blank if no code information is available + * + * Ex: ``25`` + **/ +public string line_number { get; private set; default = "";} - /** - * Full path to the code file as it was stored on the building machine - * - * Returns the path to the installed binary if no code information is available - * - * Ex: ``/home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/error_sigsegv.vala`` - * - * Ex: ``/lib/x86_64-linux-gnu/libc.so.6`` if no code information is available - **/ - public string file_path { get;private set;default = "";} +/** + * Full path to the code file as it was stored on the building machine + * + * Returns the path to the installed binary if no code information is available + * + * Ex: ``/home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/error_sigsegv.vala`` + * + * Ex: ``/lib/x86_64-linux-gnu/libc.so.6`` if no code information is available + **/ +public string file_path { get; private set; default = "";} - /** - * Path the code file relative to the current path - * - * Returns the path to the installed binary if no code information is available - * - * Ex: ``/stuff/to/stuff/`` - **/ - public string file_short_path { get;private set;default = "";} +/** + * Path the code file relative to the current path + * + * Returns the path to the installed binary if no code information is available + * + * Ex: ``/stuff/to/stuff/`` + **/ +public string file_short_path { get; private set; default = "";} - /** - * C function name - * - * Because only the C function name is avaialable, - * the name mixes the vala class and vala method name (by default separated by ``_``). - * - * For more information about getting full vala names see [[https://bugzilla.gnome.org/show_bug.cgi?id=738784|vala bug #738784]] - * - * Ex: ``namespace_someclass_method`` - **/ - public string function { get;private set;default = "";} +/** + * C function name + * + * Because only the C function name is avaialable, + * the name mixes the vala class and vala method name (by default separated by ``_``). + * + * For more information about getting full vala names see [[https://bugzilla.gnome.org/show_bug.cgi?id=738784|vala bug #738784]] + * + * Ex: ``namespace_someclass_method`` + **/ +public string function { get; private set; default = "";} - public Frame (string address, string line, string function, string file_path, string file_short_path, string line_number) { - this._address = address; - this._line = line; +public Frame (string address, string line, string function, string file_path, string file_short_path, string line_number) { + this._address = address; + this._line = line; - this._file_path = file_path; - this._file_short_path = file_short_path; - this._function = function; - this.line_number = line_number; - } + this._file_path = file_path; + this._file_short_path = file_short_path; + this._function = function; + this.line_number = line_number; +} - } +} } diff --git a/libraries/libIvy/Printer.vala b/libraries/libIvy/Printer.vala index 84d7812b..1786f899 100644 --- a/libraries/libIvy/Printer.vala +++ b/libraries/libIvy/Printer.vala @@ -16,227 +16,227 @@ namespace Ivy { - /** - * Prints the stacktrace to ``stdout`` in colors - * - */ - public class Printer { +/** + * Prints the stacktrace to ``stdout`` in colors + * + */ +public class Printer { - private Color background_color = Color.BLACK; - private int title_length = 0; +private Color background_color = Color.BLACK; +private int title_length = 0; - private Stacktrace stacktrace; +private Stacktrace stacktrace; - private string get_reset_code () { - // return get_color_code (Style.RESET, Colors.WHITE, Colors.BLACK); - return "\x1b[0m"; - } +private string get_reset_code () { + // return get_color_code (Style.RESET, Colors.WHITE, Colors.BLACK); + return "\x1b[0m"; +} - private string get_reset_style () { - return get_color_code (Style.DIM, stacktrace.highlight_color, background_color); - } +private string get_reset_style () { + return get_color_code (Style.DIM, stacktrace.highlight_color, background_color); +} - private string get_color_code (Style attr, Color fg, Color bg = background_color) { - /* Command is the control command to the terminal */ - if (bg == Color.BLACK) - return "%c[%d;%dm".printf (0x1B, (int) attr, (int) fg + 30); - else - return "%c[%d;%d;%dm".printf (0x1B, (int) attr, (int) fg + 30, (int) bg + 40); - } +private string get_color_code (Style attr, Color fg, Color bg = background_color) { + /* Command is the control command to the terminal */ + if (bg == Color.BLACK) + return "%c[%d;%dm".printf (0x1B, (int) attr, (int) fg + 30); + else + return "%c[%d;%d;%dm".printf (0x1B, (int) attr, (int) fg + 30, (int) bg + 40); +} - private string get_signal_name () { - return stacktrace.sig.to_string (); - } +private string get_signal_name () { + return stacktrace.sig.to_string (); +} - private string get_highlight_code () { - return get_color_code (Style.BRIGHT, stacktrace.highlight_color); - } +private string get_highlight_code () { + return get_color_code (Style.BRIGHT, stacktrace.highlight_color); +} - private string get_printable_function (Frame frame, int padding = 0) { - var result = ""; - var is_unknown = false; - if (frame.function == "") { - result = "<unknown> " + frame.address; - is_unknown = true; - } else { - var s = ""; - int count = padding - get_signal_name ().length; - if (padding != 0 && count > 0) - s = string.nfill (count, ' '); - result = "'" + frame.function + "'" + s; - } - if (is_unknown) - return result + get_reset_code (); - else - return get_highlight_code () + result + get_reset_code (); - } +private string get_printable_function (Frame frame, int padding = 0) { + var result = ""; + var is_unknown = false; + if (frame.function == "") { + result = "<unknown> " + frame.address; + is_unknown = true; + } else { + var s = ""; + int count = padding - get_signal_name ().length; + if (padding != 0 && count > 0) + s = string.nfill (count, ' '); + result = "'" + frame.function + "'" + s; + } + if (is_unknown) + return result + get_reset_code (); + else + return get_highlight_code () + result + get_reset_code (); +} - private string get_printable_line_number (Frame frame, bool pad = true) { - var path = frame.line_number; - var max_line_number_length = stacktrace.max_line_number_length; - var result = ""; - var color = get_highlight_code (); - if (path.length >= max_line_number_length || !pad) - result = color + path + get_reset_style (); - else { - result = color + path + get_reset_style (); - result = string.nfill (max_line_number_length - path.length, ' ') + result; - } - return result; - } +private string get_printable_line_number (Frame frame, bool pad = true) { + var path = frame.line_number; + var max_line_number_length = stacktrace.max_line_number_length; + var result = ""; + var color = get_highlight_code (); + if (path.length >= max_line_number_length || !pad) + result = color + path + get_reset_style (); + else { + result = color + path + get_reset_style (); + result = string.nfill (max_line_number_length - path.length, ' ') + result; + } + return result; +} - private string get_printable_file_short_path (Frame frame, bool pad = true) { - var path = frame.file_short_path; - var max_file_name_length = stacktrace.max_file_name_length; - var result = ""; - var color = get_highlight_code (); - if (path.length >= max_file_name_length || !pad) - result = color + path + get_reset_style (); - else { - result = color + path + get_reset_style (); - result = result + string.nfill (max_file_name_length - path.length, ' '); - } - return result; - } +private string get_printable_file_short_path (Frame frame, bool pad = true) { + var path = frame.file_short_path; + var max_file_name_length = stacktrace.max_file_name_length; + var result = ""; + var color = get_highlight_code (); + if (path.length >= max_file_name_length || !pad) + result = color + path + get_reset_style (); + else { + result = color + path + get_reset_style (); + result = result + string.nfill (max_file_name_length - path.length, ' '); + } + return result; +} - private string get_printable_title () { - var c = get_color_code (Style.DIM, stacktrace.highlight_color, background_color); - var color = get_highlight_code (); - - var result = ""; - - if( stacktrace.is_custom) - result = "%sA function was called in %s".printf ( - c, - get_reset_style ()); - else - result = "%sAn error occured %s(%s)%s".printf ( - c, - color, - get_signal_name (), - get_reset_style ()); - - title_length = get_signal_name ().length; - return result; - } +private string get_printable_title () { + var c = get_color_code (Style.DIM, stacktrace.highlight_color, background_color); + var color = get_highlight_code (); + + var result = ""; + + if( stacktrace.is_custom) + result = "%sA function was called in %s".printf ( + c, + get_reset_style ()); + else + result = "%sAn error occured %s(%s)%s".printf ( + c, + color, + get_signal_name (), + get_reset_style ()); + + title_length = get_signal_name ().length; + return result; +} - private string get_reason () { - // var c = get_reset_code(); - var sig = stacktrace.sig; +private string get_reason () { + // var c = get_reset_code(); + var sig = stacktrace.sig; - var color = get_highlight_code (); - if (sig == ProcessSignal.TRAP) { - return "The reason is likely %san uncaught error%s".printf ( - color, get_reset_code ()); - } - if (sig == ProcessSignal.ABRT) { - return "The reason is likely %sa failed assertion (assert...)%s".printf ( - color, get_reset_code ()); - } - if (sig == ProcessSignal.SEGV) { - return "The reason is likely %sa null reference being used%s".printf ( - color, get_reset_code ()); - } - return "Unknown reason"; - } + var color = get_highlight_code (); + if (sig == ProcessSignal.TRAP) { + return "The reason is likely %san uncaught error%s".printf ( + color, get_reset_code ()); + } + if (sig == ProcessSignal.ABRT) { + return "The reason is likely %sa failed assertion (assert...)%s".printf ( + color, get_reset_code ()); + } + if (sig == ProcessSignal.SEGV) { + return "The reason is likely %sa null reference being used%s".printf ( + color, get_reset_code ()); + } + return "Unknown reason"; +} - /** - * Print the stacktrace to ``stdout`` - * - * @param trace the stacktrace - * - */ - public virtual void print (Stacktrace trace) { - this.stacktrace = trace; - background_color = stacktrace.error_background; - var header = "%s%s\n".printf (get_printable_title (), - get_reset_code ()); - var first_vala = trace.first_vala; - - if (trace.first_vala != null) { - header = "%s in %s, line %s in %s\n".printf ( - get_printable_title (), - get_printable_file_short_path (first_vala, false), - get_printable_line_number (first_vala, false), - get_printable_function (first_vala) + get_reset_code ()); - title_length += first_vala.line_number.length + - first_vala.function.length + - first_vala.file_short_path.length; - } - stdout.printf (header); - background_color = Color.BLACK; - if( !stacktrace.is_custom) { - var reason = get_reason (); - stdout.printf (" %s.\n", reason); - } - var is_all_file_name_blank = stacktrace.is_all_file_name_blank; +/** + * Print the stacktrace to ``stdout`` + * + * @param trace the stacktrace + * + */ +public virtual void print (Stacktrace trace) { + this.stacktrace = trace; + background_color = stacktrace.error_background; + var header = "%s%s\n".printf (get_printable_title (), + get_reset_code ()); + var first_vala = trace.first_vala; + + if (trace.first_vala != null) { + header = "%s in %s, line %s in %s\n".printf ( + get_printable_title (), + get_printable_file_short_path (first_vala, false), + get_printable_line_number (first_vala, false), + get_printable_function (first_vala) + get_reset_code ()); + title_length += first_vala.line_number.length + + first_vala.function.length + + first_vala.file_short_path.length; + } + stdout.printf (header); + background_color = Color.BLACK; + if( !stacktrace.is_custom) { + var reason = get_reason (); + stdout.printf (" %s.\n", reason); + } + var is_all_file_name_blank = stacktrace.is_all_file_name_blank; - // Has the user forgot to compile with -g -X -rdynamic flag ? - if (is_all_file_name_blank) { - var advice = " %sNote%s: no file path and line numbers can be retrieved. Are you sure %syou added -g -X -rdynamic%s to valac command line?\n"; - var color = get_highlight_code (); - stdout.printf (advice, color, get_reset_code (), color, get_reset_code ()); - } + // Has the user forgot to compile with -g -X -rdynamic flag ? + if (is_all_file_name_blank) { + var advice = " %sNote%s: no file path and line numbers can be retrieved. Are you sure %syou added -g -X -rdynamic%s to valac command line?\n"; + var color = get_highlight_code (); + stdout.printf (advice, color, get_reset_code (), color, get_reset_code ()); + } - // Has the user forgot to compile with rdynamic flag ? - if (stacktrace.is_all_function_name_blank && !is_all_file_name_blank) { - var advice = " %sNote%s: no vala function name can be retrieved. Are you sure %syou added -X -rdynamic%s to valac command line?\n"; - var color = get_highlight_code (); - stdout.printf (advice, color, get_reset_code (), color, get_reset_code ()); - } + // Has the user forgot to compile with rdynamic flag ? + if (stacktrace.is_all_function_name_blank && !is_all_file_name_blank) { + var advice = " %sNote%s: no vala function name can be retrieved. Are you sure %syou added -X -rdynamic%s to valac command line?\n"; + var color = get_highlight_code (); + stdout.printf (advice, color, get_reset_code (), color, get_reset_code ()); + } - stdout.printf ("\n"); - int i = 1; - bool has_displayed_first_vala = false; - foreach (var frame in trace.frames) { - var show_frame = frame.function != "" || frame.file_path.has_suffix (".vala") || frame.file_path.has_suffix (".c"); - if (Stacktrace.hide_installed_libraries && has_displayed_first_vala) - show_frame = show_frame && frame.file_short_path != ""; - - // Ignore glib tracing code if displayed before the first vala frame - if ((frame.function == "g_logv" || frame.function == "g_log") && !has_displayed_first_vala) - show_frame = false; - if (show_frame) { - // #2 ./OtherModule.c line 80 in 'other_module_do_it' - // at /home/cran/Projects/noise/noise-perf-instant-search/tests/errors/module/OtherModule.vala:10 - var str = " %s #%d %s line %s in %s\n"; - background_color = Color.BLACK; - var lead = " "; - var function_padding = 0; - if (frame == first_vala) { - has_displayed_first_vala = true; - lead = "*"; - background_color = stacktrace.error_background; - function_padding = 22; - } - var l_number = ""; - if (frame.line_number == "") { - str = " %s #%d <unknown> %s in %s\n"; - var func_name = get_printable_function (frame); - var fill_len = int.max (stacktrace.max_file_name_length + stacktrace.max_line_number_length - 1, 0); - str = str.printf ( - lead, - i, - string.nfill (fill_len, ' '), - func_name); - } else { - str = str.printf ( - lead, - i, - get_printable_file_short_path (frame), - get_printable_line_number (frame), - get_printable_function (frame, function_padding)); - l_number = ":" + frame.line_number; - } - stdout.printf (str); - str = " at %s%s\n".printf ( - frame.file_path, l_number); - stdout.printf (str); - - i++; - } + stdout.printf ("\n"); + int i = 1; + bool has_displayed_first_vala = false; + foreach (var frame in trace.frames) { + var show_frame = frame.function != "" || frame.file_path.has_suffix (".vala") || frame.file_path.has_suffix (".c"); + if (Stacktrace.hide_installed_libraries && has_displayed_first_vala) + show_frame = show_frame && frame.file_short_path != ""; + + // Ignore glib tracing code if displayed before the first vala frame + if ((frame.function == "g_logv" || frame.function == "g_log") && !has_displayed_first_vala) + show_frame = false; + if (show_frame) { + // #2 ./OtherModule.c line 80 in 'other_module_do_it' + // at /home/cran/Projects/noise/noise-perf-instant-search/tests/errors/module/OtherModule.vala:10 + var str = " %s #%d %s line %s in %s\n"; + background_color = Color.BLACK; + var lead = " "; + var function_padding = 0; + if (frame == first_vala) { + has_displayed_first_vala = true; + lead = "*"; + background_color = stacktrace.error_background; + function_padding = 22; } - } + var l_number = ""; + if (frame.line_number == "") { + str = " %s #%d <unknown> %s in %s\n"; + var func_name = get_printable_function (frame); + var fill_len = int.max (stacktrace.max_file_name_length + stacktrace.max_line_number_length - 1, 0); + str = str.printf ( + lead, + i, + string.nfill (fill_len, ' '), + func_name); + } else { + str = str.printf ( + lead, + i, + get_printable_file_short_path (frame), + get_printable_line_number (frame), + get_printable_function (frame, function_padding)); + l_number = ":" + frame.line_number; + } + stdout.printf (str); + str = " at %s%s\n".printf ( + frame.file_path, l_number); + stdout.printf (str); + i++; + } } } + +} +} diff --git a/libraries/libIvy/Stacktrace.vala b/libraries/libIvy/Stacktrace.vala index 1bd78ff1..1c43ffb0 100644 --- a/libraries/libIvy/Stacktrace.vala +++ b/libraries/libIvy/Stacktrace.vala @@ -14,388 +14,388 @@ * limitations under the License. */ - /** - * Provides services to display vala stacktraces - */ +/** + * Provides services to display vala stacktraces + */ namespace Ivy { - internal enum Style { - RESET = 0, - BRIGHT = 1, - DIM = 2, - UNDERLINE = 3, - BLINK = 4, - REVERSE = 7, - HIDDEN = 8 - } +internal enum Style { + RESET = 0, + BRIGHT = 1, + DIM = 2, + UNDERLINE = 3, + BLINK = 4, + REVERSE = 7, + HIDDEN = 8 +} +/** + * Defines how Unix signals are processed + */ +public enum CriticalHandler { /** - * Defines how Unix signals are processed + * Unix signals are ignored */ - public enum CriticalHandler { - /** - * Unix signals are ignored - */ - IGNORE, - /** - * When a signal is intercepted, a stacktrace is displayed - * to ``stdout`` and the execution of the application is - * resumed - */ - PRINT_STACKTRACE, - /** - * When a signal is intercepted, a stacktrace is displayed - * to ``stdout`` and the application is stopped - */ - CRASH - } - + IGNORE, /** - * Colors used for displaying stacktraces + * When a signal is intercepted, a stacktrace is displayed + * to ``stdout`` and the execution of the application is + * resumed */ - public enum Color { - BLACK = 0, - RED = 1, - GREEN = 2, - YELLOW = 3, - BLUE = 4, - MAGENTA = 5, - CYAN = 6, - WHITE = 7 - } - + PRINT_STACKTRACE, /** - * A complete execution stacktrace - * - * Holds a collection of {@link Frame} and the basic methods to intercept Unix signals - * and prints the complete stacktrace to ``stdout`` in colors. - * - * For more information, refer to the [[https://github.com/I-hate-farms/stacktrace|official website]]. - * - * Here's a sample of a printed stacktrace: - * {{{ - * An error occured (SIGSEGV) in samples/vala_file.vala, line 21 in 'this_will_crash_harder' - * The reason is likely a null reference being used. - * - * #1 <unknown> in 'strlen' - * at /lib/x86_64-linux-gnu/libc.so.6 - * * #2 samples/vala_file.vala line 21 in 'this_will_crash_harder' - * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/vala_file.vala:21 - * #3 samples/module/OtherModule.vala line 11 in 'other_module_do_it' - * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/module/OtherModule.vala:11 - * #4 samples/error_sigsegv.vala line 19 in 'namespace_someclass_exec' - * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/error_sigsegv.vala:19 - * #5 samples/error_sigsegv.vala line 29 in 'this_will_crash' - * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/error_sigsegv.vala:29 - * #6 samples/error_sigsegv.vala line 39 in '_vala_main' - * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/error_sigsegv.vala:39 - * #7 error_sigsegv.vala.c line 421 in 'main' - * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/error_sigsegv.vala.c:421 - * #8 <unknown> in '__libc_start_main' - * at /lib/x86_64-linux-gnu/libc.so.6 - * }}} + * When a signal is intercepted, a stacktrace is displayed + * to ``stdout`` and the application is stopped */ - public class Stacktrace { + CRASH +} - internal Frame first_vala = null; +/** + * Colors used for displaying stacktraces + */ +public enum Color { + BLACK = 0, + RED = 1, + GREEN = 2, + YELLOW = 3, + BLUE = 4, + MAGENTA = 5, + CYAN = 6, + WHITE = 7 +} - internal int max_file_name_length = 0; +/** + * A complete execution stacktrace + * + * Holds a collection of {@link Frame} and the basic methods to intercept Unix signals + * and prints the complete stacktrace to ``stdout`` in colors. + * + * For more information, refer to the [[https://github.com/I-hate-farms/stacktrace|official website]]. + * + * Here's a sample of a printed stacktrace: + * {{{ + * An error occured (SIGSEGV) in samples/vala_file.vala, line 21 in 'this_will_crash_harder' + * The reason is likely a null reference being used. + * + * #1 <unknown> in 'strlen' + * at /lib/x86_64-linux-gnu/libc.so.6 + * * #2 samples/vala_file.vala line 21 in 'this_will_crash_harder' + * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/vala_file.vala:21 + * #3 samples/module/OtherModule.vala line 11 in 'other_module_do_it' + * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/module/OtherModule.vala:11 + * #4 samples/error_sigsegv.vala line 19 in 'namespace_someclass_exec' + * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/error_sigsegv.vala:19 + * #5 samples/error_sigsegv.vala line 29 in 'this_will_crash' + * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/error_sigsegv.vala:29 + * #6 samples/error_sigsegv.vala line 39 in '_vala_main' + * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/samples/error_sigsegv.vala:39 + * #7 error_sigsegv.vala.c line 421 in 'main' + * at /home/cran/Documents/Projects/i-hate-farms/stacktrace/error_sigsegv.vala.c:421 + * #8 <unknown> in '__libc_start_main' + * at /lib/x86_64-linux-gnu/libc.so.6 + * }}} + */ +public class Stacktrace { - internal int max_line_number_length = 0; +internal Frame first_vala = null; - internal bool is_all_function_name_blank = true; +internal int max_file_name_length = 0; - internal bool is_all_file_name_blank = true; +internal int max_line_number_length = 0; - private Gee.List<Frame> _frames = new Gee.ArrayList<Frame>(); +internal bool is_all_function_name_blank = true; - /** - * Unix signal being intercepted - * - */ - public ProcessSignal sig; +internal bool is_all_file_name_blank = true; - /** - * Enables the Unix signals interception - * - * Setting it to false and preventing signals interception and the collection - * of the complete stacktrace (that might a significant effect on performance) - * is useful when the application uses a library that emits a ``SIGTRAP`` - * signal for unknown reasons. - * - * Such a case would cripple the application performance and clutter the - * ``stdout`` ouput for no benefit. - * - * Default is ``true`` - */ - public static bool enabled { get;set;default = true;} +private Gee.List<Frame> _frames = new Gee.ArrayList<Frame>(); - /** - * Hides frames located in external system libraries (like ``libgc``) without - * code information - * - * * Default is ``true`` - * - * Before - * {{{ - * An error occured (SIGTRAP) in ../src/Database/Core/QueryResult.vala, line 26 in 'app_center_core_query_result_finalize' - * The reason is likely an uncaught error. - * - * #1 <unknown> in 'g_signal_handlers_disconnect_matched' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * * #2 ../src/Database/Core/QueryResult.vala line 26 in 'app_center_core_query_result_finalize' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/Core/QueryResult.vala:26 - * #3 <unknown> in 'g_object_unref' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #4 ../src/Database/Core/Dao.vala line 88 in 'app_center_core_dao_insert' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/Core/Dao.vala:88 - * #5 ../src/Database/PackageKitSource.vala line 18 in 'app_center_core_package_kit_source_fetch' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/PackageKitSource.vala:18 - * #6 ../src/MainPanel.vala line 68 in '__lambda19_' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/MainPanel.vala:68 - * #7 src/MainPanel.c line 297 in '___lambda19__app_center_views_browse_view_show_app_info' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/MainPanel.c:297 - * #8 <unknown> in 'g_cclosure_marshal_VOID__STRINGv' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #9 <unknown> in 'g_signal_emit_valist' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #10 <unknown> in 'g_signal_emit_by_name' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #11 src/BrowseView.c line 871 in '__lambda16_' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/BrowseView.c:871 - * #12 src/BrowseView.c line 878 in '___lambda16__gtk_button_clicked' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/BrowseView.c:878 - * #13 <unknown> in 'g_signal_emit_valist' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #14 <unknown> in 'g_signal_emit' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #15 <unknown> in 'g_closure_invoke' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #16 <unknown> in 'g_signal_emit_valist' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #17 <unknown> in 'g_signal_emit' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #18 <unknown> in 'ffi_call_unix64' - * at /usr/lib/x86_64-linux-gnu/libffi.so.6 - * #19 <unknown> in 'ffi_call' - * at /usr/lib/x86_64-linux-gnu/libffi.so.6 - * #20 <unknown> in 'g_cclosure_marshal_generic_va' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #21 <unknown> in 'g_signal_emit_valist' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #22 <unknown> in 'g_signal_emit' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #23 <unknown> in 'g_cclosure_marshal_VOID__BOXEDv' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #24 <unknown> in 'g_signal_emit_valist' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #25 <unknown> in 'g_signal_emit' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #26 <unknown> in 'gtk_event_controller_handle_event' - * at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 - * #27 <unknown> in 'g_signal_emit_valist' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #28 <unknown> in 'g_signal_emit' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * #29 <unknown> in 'gtk_main_do_event' - * at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 - * #30 <unknown> in 'g_main_context_dispatch' - * at /lib/x86_64-linux-gnu/libglib-2.0.so.0 - * #31 <unknown> in 'g_main_context_iteration' - * at /lib/x86_64-linux-gnu/libglib-2.0.so.0 - * #32 <unknown> in 'g_application_run' - * at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 - * #33 <unknown> in 'granite_application_run' - * at /usr/lib/x86_64-linux-gnu/libgranite.so.2 - * #34 ../src/Application.vala line 54 in 'app_center_main' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Application.vala:54 - * #35 src/Application.c line 296 in 'main' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/Application.c:296 - * #36 <unknown> in '__libc_start_main' - * at /lib/x86_64-linux-gnu/libc.so.6 - * - * }}} - * - * After : - * {{{ - * An error occured (SIGTRAP) in ../src/Database/Core/QueryResult.vala, line 26 in 'app_center_core_query_result_finalize' - * The reason is likely an uncaught error. - * - * #1 <unknown> in 'g_signal_handlers_disconnect_matched' - * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 - * * #2 ../src/Database/Core/QueryResult.vala line 26 in 'app_center_core_query_result_finalize' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/Core/QueryResult.vala:26 - * #3 ../src/Database/Core/Dao.vala line 88 in 'app_center_core_dao_insert' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/Core/Dao.vala:88 - * #4 ../src/Database/PackageKitSource.vala line 18 in 'app_center_core_package_kit_source_fetch' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/PackageKitSource.vala:18 - * #5 ../src/MainPanel.vala line 68 in '__lambda19_' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/MainPanel.vala:68 - * #6 src/MainPanel.c line 297 in '___lambda19__app_center_views_browse_view_show_app_info' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/MainPanel.c:297 - * #7 src/BrowseView.c line 871 in '__lambda16_' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/BrowseView.c:871 - * #8 src/BrowseView.c line 878 in '___lambda16__gtk_button_clicked' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/BrowseView.c:878 - * #9 ../src/Application.vala line 55 in 'app_center_main' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Application.vala:55 - * #10 src/Application.c line 304 in 'main' - * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/Application.c:304 - * }}} - */ - public static bool hide_installed_libraries { get;set;default = true;} +/** + * Unix signal being intercepted + * + */ +public ProcessSignal sig; - /** - * Sets the default higlighted text color for stacktrace that are created - * via Unix signals interception - * - * Default is ``Color.WHITE`` - */ - public static Color default_highlight_color { get;set;default = Color.WHITE;} +/** + * Enables the Unix signals interception + * + * Setting it to false and preventing signals interception and the collection + * of the complete stacktrace (that might a significant effect on performance) + * is useful when the application uses a library that emits a ``SIGTRAP`` + * signal for unknown reasons. + * + * Such a case would cripple the application performance and clutter the + * ``stdout`` ouput for no benefit. + * + * Default is ``true`` + */ +public static bool enabled { get; set; default = true;} - /** - * Sets the default background color for stacktrace that are created - * via Unix signals interception - * - * Default is ``Color.RED`` - */ - public static Color default_error_background { get;set;default = Color.RED;} +/** + * Hides frames located in external system libraries (like ``libgc``) without + * code information + * + * * Default is ``true`` + * + * Before + * {{{ + * An error occured (SIGTRAP) in ../src/Database/Core/QueryResult.vala, line 26 in 'app_center_core_query_result_finalize' + * The reason is likely an uncaught error. + * + * #1 <unknown> in 'g_signal_handlers_disconnect_matched' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * * #2 ../src/Database/Core/QueryResult.vala line 26 in 'app_center_core_query_result_finalize' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/Core/QueryResult.vala:26 + * #3 <unknown> in 'g_object_unref' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #4 ../src/Database/Core/Dao.vala line 88 in 'app_center_core_dao_insert' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/Core/Dao.vala:88 + * #5 ../src/Database/PackageKitSource.vala line 18 in 'app_center_core_package_kit_source_fetch' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/PackageKitSource.vala:18 + * #6 ../src/MainPanel.vala line 68 in '__lambda19_' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/MainPanel.vala:68 + * #7 src/MainPanel.c line 297 in '___lambda19__app_center_views_browse_view_show_app_info' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/MainPanel.c:297 + * #8 <unknown> in 'g_cclosure_marshal_VOID__STRINGv' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #9 <unknown> in 'g_signal_emit_valist' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #10 <unknown> in 'g_signal_emit_by_name' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #11 src/BrowseView.c line 871 in '__lambda16_' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/BrowseView.c:871 + * #12 src/BrowseView.c line 878 in '___lambda16__gtk_button_clicked' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/BrowseView.c:878 + * #13 <unknown> in 'g_signal_emit_valist' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #14 <unknown> in 'g_signal_emit' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #15 <unknown> in 'g_closure_invoke' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #16 <unknown> in 'g_signal_emit_valist' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #17 <unknown> in 'g_signal_emit' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #18 <unknown> in 'ffi_call_unix64' + * at /usr/lib/x86_64-linux-gnu/libffi.so.6 + * #19 <unknown> in 'ffi_call' + * at /usr/lib/x86_64-linux-gnu/libffi.so.6 + * #20 <unknown> in 'g_cclosure_marshal_generic_va' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #21 <unknown> in 'g_signal_emit_valist' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #22 <unknown> in 'g_signal_emit' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #23 <unknown> in 'g_cclosure_marshal_VOID__BOXEDv' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #24 <unknown> in 'g_signal_emit_valist' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #25 <unknown> in 'g_signal_emit' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #26 <unknown> in 'gtk_event_controller_handle_event' + * at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 + * #27 <unknown> in 'g_signal_emit_valist' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #28 <unknown> in 'g_signal_emit' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * #29 <unknown> in 'gtk_main_do_event' + * at /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 + * #30 <unknown> in 'g_main_context_dispatch' + * at /lib/x86_64-linux-gnu/libglib-2.0.so.0 + * #31 <unknown> in 'g_main_context_iteration' + * at /lib/x86_64-linux-gnu/libglib-2.0.so.0 + * #32 <unknown> in 'g_application_run' + * at /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 + * #33 <unknown> in 'granite_application_run' + * at /usr/lib/x86_64-linux-gnu/libgranite.so.2 + * #34 ../src/Application.vala line 54 in 'app_center_main' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Application.vala:54 + * #35 src/Application.c line 296 in 'main' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/Application.c:296 + * #36 <unknown> in '__libc_start_main' + * at /lib/x86_64-linux-gnu/libc.so.6 + * + * }}} + * + * After : + * {{{ + * An error occured (SIGTRAP) in ../src/Database/Core/QueryResult.vala, line 26 in 'app_center_core_query_result_finalize' + * The reason is likely an uncaught error. + * + * #1 <unknown> in 'g_signal_handlers_disconnect_matched' + * at /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * * #2 ../src/Database/Core/QueryResult.vala line 26 in 'app_center_core_query_result_finalize' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/Core/QueryResult.vala:26 + * #3 ../src/Database/Core/Dao.vala line 88 in 'app_center_core_dao_insert' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/Core/Dao.vala:88 + * #4 ../src/Database/PackageKitSource.vala line 18 in 'app_center_core_package_kit_source_fetch' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Database/PackageKitSource.vala:18 + * #5 ../src/MainPanel.vala line 68 in '__lambda19_' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/MainPanel.vala:68 + * #6 src/MainPanel.c line 297 in '___lambda19__app_center_views_browse_view_show_app_info' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/MainPanel.c:297 + * #7 src/BrowseView.c line 871 in '__lambda16_' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/BrowseView.c:871 + * #8 src/BrowseView.c line 878 in '___lambda16__gtk_button_clicked' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/BrowseView.c:878 + * #9 ../src/Application.vala line 55 in 'app_center_main' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/src/Application.vala:55 + * #10 src/Application.c line 304 in 'main' + * at /home/cran/Documents/Projects/i-hate-farms/app/exocron/build/src/Application.c:304 + * }}} + */ +public static bool hide_installed_libraries { get; set; default = true;} - /** - * Sets the stacktrace higlighted text color when printed on ``stdout`` - * - * Default is ``Color.WHITE`` - */ - public Color highlight_color { get;set;default = Color.WHITE;} +/** + * Sets the default higlighted text color for stacktrace that are created + * via Unix signals interception + * + * Default is ``Color.WHITE`` + */ +public static Color default_highlight_color { get; set; default = Color.WHITE;} - /** - * Sets the stacktrace background color when printed on ``stdout`` - * - * Default is ``Color.RED`` - */ - public Color error_background { get;set;default = Color.RED;} +/** + * Sets the default background color for stacktrace that are created + * via Unix signals interception + * + * Default is ``Color.RED`` + */ +public static Color default_error_background { get; set; default = Color.RED;} - /** - * Collection of frames - * - */ - public Gee.List<Frame> frames { - get { - return _frames; - } - } +/** + * Sets the stacktrace higlighted text color when printed on ``stdout`` + * + * Default is ``Color.WHITE`` + */ +public Color highlight_color { get; set; default = Color.WHITE;} - private Printer printer = new Printer (); - private Extractor extractor = new Extractor (); +/** + * Sets the stacktrace background color when printed on ``stdout`` + * + * Default is ``Color.RED`` + */ +public Color error_background { get; set; default = Color.RED;} - public Stacktrace (GLib.ProcessSignal sig = GLib.ProcessSignal.TTOU) { - this.sig = sig; - // The stacktrace is used likely to understand the inner - // working of the app so we displays everything. - if (is_custom) { - hide_installed_libraries = false; - error_background = Color.BLUE; - } else { - error_background = default_error_background; - highlight_color = default_highlight_color; - } - extractor.create_stacktrace (this); - } +/** + * Collection of frames + * + */ +public Gee.List<Frame> frames { + get { + return _frames; + } +} - /** - * Returns true if the stacktrace is "custom" - * - * A custom stacktrace has been created via code as - * opposed to created via Unix signal interception. - * - * Custom stacktrace are displayed with a different color scheme (default ``Color.GREEN``) that - * can be set via {@link highlight_color} and {@link error_background} - * - * Here's how to create a custom stacktrace: - * {{{ - * - * int my_function (string arg) { - * var custom_stracktrace = new Stacktrace (); - * custom_stracktrace.print (); - * return 0; - * } - * }}} - */ - public bool is_custom { - get { - return sig == ProcessSignal.TTOU; - } - } +private Printer printer = new Printer (); +private Extractor extractor = new Extractor (); - /** - * Prints the stacktrace to ``stdout`` with colors - * - */ - public void print () { - printer.print (this); - } +public Stacktrace (GLib.ProcessSignal sig = GLib.ProcessSignal.TTOU) { + this.sig = sig; + // The stacktrace is used likely to understand the inner + // working of the app so we displays everything. + if (is_custom) { + hide_installed_libraries = false; + error_background = Color.BLUE; + } else { + error_background = default_error_background; + highlight_color = default_highlight_color; + } + extractor.create_stacktrace (this); +} - /** - * Registers handlers to intercept Unix signals - * - * Calling ``register_handlers`` is required for the - * library to display a stacktrace when the application encounters an error (ie raises a ``SIGABRT``, - * a ``SIGSEV`` or a ``SIGTRAP`` signal). - * - * ''Note:'' calling ``register_handlers`` is not needed to be able to display custom stacktraces. <<BR>> - * (See {@link is_custom} for more information about custom stacktraces). - * - * How to initialize the library so it can intercept Unix signals: - * {{{ - * - * static int main (string[] arg) { - * Stacktrace.register_handlers (); - * // Start your application - * ... - * return 0; - * } - * }}} - * - */ - public static void register_handlers () { - //Log.set_always_fatal (LogLevelFlags.LEVEL_CRITICAL); - Log.set_always_fatal (LogLevelFlags.LEVEL_ERROR); +/** + * Returns true if the stacktrace is "custom" + * + * A custom stacktrace has been created via code as + * opposed to created via Unix signal interception. + * + * Custom stacktrace are displayed with a different color scheme (default ``Color.GREEN``) that + * can be set via {@link highlight_color} and {@link error_background} + * + * Here's how to create a custom stacktrace: + * {{{ + * + * int my_function (string arg) { + * var custom_stracktrace = new Stacktrace (); + * custom_stracktrace.print (); + * return 0; + * } + * }}} + */ +public bool is_custom { + get { + return sig == ProcessSignal.TTOU; + } +} - Process.@signal (ProcessSignal.SEGV, handler); - Process.@signal (ProcessSignal.TRAP, handler); - if (critical_handling != CriticalHandler.IGNORE) - Process.@signal (ProcessSignal.ABRT, handler); - } +/** + * Prints the stacktrace to ``stdout`` with colors + * + */ +public void print () { + printer.print (this); +} + +/** + * Registers handlers to intercept Unix signals + * + * Calling ``register_handlers`` is required for the + * library to display a stacktrace when the application encounters an error (ie raises a ``SIGABRT``, + * a ``SIGSEV`` or a ``SIGTRAP`` signal). + * + * ''Note:'' calling ``register_handlers`` is not needed to be able to display custom stacktraces. <<BR>> + * (See {@link is_custom} for more information about custom stacktraces). + * + * How to initialize the library so it can intercept Unix signals: + * {{{ + * + * static int main (string[] arg) { + * Stacktrace.register_handlers (); + * // Start your application + * ... + * return 0; + * } + * }}} + * + */ +public static void register_handlers () { + //Log.set_always_fatal (LogLevelFlags.LEVEL_CRITICAL); + Log.set_always_fatal (LogLevelFlags.LEVEL_ERROR); + + Process.@signal (ProcessSignal.SEGV, handler); + Process.@signal (ProcessSignal.TRAP, handler); + if (critical_handling != CriticalHandler.IGNORE) + Process.@signal (ProcessSignal.ABRT, handler); +} - /** - * Defines how Unix signals are processed - * - * Default is ``CriticalHandler.PRINT_STACKTRACE``. - */ - public static CriticalHandler critical_handling { get;set;default = CriticalHandler.PRINT_STACKTRACE;} +/** + * Defines how Unix signals are processed + * + * Default is ``CriticalHandler.PRINT_STACKTRACE``. + */ +public static CriticalHandler critical_handling { get; set; default = CriticalHandler.PRINT_STACKTRACE;} - /*{ - set { - _critical_handling = value; - if( value == CriticalHandler.CRASH ) - //var variables = Environ.get (); - //Environ.set_variable (variables, "G_DEBUG", "fatal-criticals" ); - Log.set_always_fatal (LogLevelFlags.LEVEL_CRITICAL); - } - get { - } +/*{ + set { + _critical_handling = value; + if( value == CriticalHandler.CRASH ) + //var variables = Environ.get (); + //Environ.set_variable (variables, "G_DEBUG", "fatal-criticals" ); + Log.set_always_fatal (LogLevelFlags.LEVEL_CRITICAL); + } + get { + } - }*/ + }*/ - private static void handler (int sig) { - if( !enabled) - return; - Stacktrace stack = new Stacktrace ((ProcessSignal) sig); - stack.print (); - if (sig != ProcessSignal.TRAP || - (sig == ProcessSignal.TRAP && critical_handling == CriticalHandler.CRASH)) - Process.exit (1); - } +private static void handler (int sig) { + if( !enabled) + return; + Stacktrace stack = new Stacktrace ((ProcessSignal) sig); + stack.print (); + if (sig != ProcessSignal.TRAP || + (sig == ProcessSignal.TRAP && critical_handling == CriticalHandler.CRASH)) + Process.exit (1); +} - } +} } |