{"id":140,"date":"2014-02-04T17:39:31","date_gmt":"2014-02-04T17:39:31","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=140"},"modified":"2014-02-04T17:39:31","modified_gmt":"2014-02-04T17:39:31","slug":"custom-steps","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/custom\/steps\/","title":{"rendered":"Customizing your projects with custom steps"},"content":{"rendered":"\n<p>This tutorial shows how to extend a simple Linux project with custom actions. For this we make a program that outputs into a file and we download this file on each program run into the Windows machine. Adding custom actions works for all project types since VisualGDB 4.0.<\/p>\n<p>Before we begin, ensure that <a href=\"http:\/\/visualgdb.com\/download\">VisualGDB 4.0<\/a> or later is installed.<\/p>\n<ol>\n<li>Follow the <a href=\"\/tutorials\/linux\/\">Linux tutorial<\/a> to make a simple program. We used the name CustomizedLinuxProject for the project name.<\/li>\n<li>Exchange the contents of the main source file with the following:\n<pre>#include &lt;iostream&gt;\r\n#include &lt;fstream&gt;\r\n\r\nusing namespace std;\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n    ofstream file;\r\n    file.open (\"output.txt\");\r\n\r\n    \/\/ Fibonacci sequence\r\n    unsigned long long fn_1 = 1;\r\n    unsigned long long fn_2 = 0;\r\n    unsigned long long fn = 0;\r\n    for(int i=0;i&lt;80;i++)\r\n    {\r\n        file &lt;&lt; fn &lt;&lt; \"\\r\\n\";\r\n        fn_2=fn_1;\r\n        fn_1=fn;\r\n        fn=fn_1+fn_2;\r\n    }\r\n\r\n    file.close();\r\n    return 0;\r\n}<\/pre>\n<p>This new code generates the first 80 numbers of the Fibonacci sequence and saves it to a file called output.txt.<\/li>\n<li>Build and run the project.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/01-builddebug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/01-builddebug.png\" alt=\"01-builddebug\" width=\"700\" height=\"525\" \/><\/a><\/li>\n<li>As we did not set any breakpoints, the GDB log message appears. You can choose to not be shown this dialog again, you can change this option later on from Tools-&gt;Options. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/12-popup.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/12-popup.png\" alt=\"12-popup\" width=\"510\" height=\"223\" \/><\/a><\/li>\n<li>Go to Tools-&gt;SSH Host Manager. Open the console.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/14-ssh.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/14-ssh.png\" alt=\"14-ssh\" width=\"670\" height=\"440\" \/><\/a><\/li>\n<li>Open the console to the remote machine. Go to the source stored on the remote machine. In our case the source is in the tmp directory under VisualGDB. Locate the output.txt file there and open it for viewing inside the console. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/15-shell.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/15-shell.png\" alt=\"15-shell\" width=\"654\" height=\"449\" \/><\/a><\/li>\n<li>Our next step is to add a custom debug action to bring this output.txt file for local viewing. For this right-click on the project and select VisualGDB Project Properties. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/02-openproperties.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/02-openproperties.png\" alt=\"02-openproperties\" width=\"700\" height=\"525\" \/><\/a><\/li>\n<li>Open the custom debug steps page. Edit the &#8220;Cleanup actions after GDB exits&#8221;. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/03-postdebug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/03-postdebug.png\" alt=\"03-postdebug\" width=\"700\" height=\"566\" \/><\/a><\/li>\n<li>Click on the plus button to add an action. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/04-add.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/04-add.png\" alt=\"04-add\" width=\"500\" height=\"300\" \/><\/a><\/li>\n<li>Choose the transfer action as the type. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/09-transfer.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/09-transfer.png\" alt=\"09-transfer\" width=\"627\" height=\"112\" \/><\/a><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/05-newaction.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/05-newaction.png\" alt=\"05-newaction\" width=\"627\" height=\"256\" \/><\/a><\/li>\n<li>Browse for the output.txt file on the remote machine as the source file. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/06-file.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/06-file.png\" alt=\"06-file\" width=\"500\" height=\"300\" \/><\/a><\/li>\n<li>Save the file locally to the project directory. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/07-save.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/07-save.png\" alt=\"07-save\" width=\"698\" height=\"480\" \/><\/a><\/li>\n<li>The ready command looks as follows. Click on OK. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/08-command.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/08-command.png\" alt=\"08-command\" width=\"627\" height=\"256\" \/><\/a><\/li>\n<li>Click OK in the dialogs and run the project again.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/09-actionsequence.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/09-actionsequence.png\" alt=\"09-actionsequence\" width=\"500\" height=\"300\" \/><\/a><\/li>\n<li>Right click on the project and select <strong> Add-&gt;Existing Item<\/strong>. Browse to the local project directory and add the output.txt file.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/10-addexisting.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/10-addexisting.png\" alt=\"10-addexisting\" width=\"698\" height=\"480\" \/><\/a><\/li>\n<li>Open the output.txt file.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/13-output.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/13-output.png\" alt=\"13-output\" width=\"700\" height=\"525\" \/><\/a><\/li>\n<li>Run the app again. As the file was open, Visual Studio will now prompt to reopen the file which can be handy with quickly changing output files. <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/11-refresh.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/custom\/steps\/11-refresh.png\" alt=\"11-refresh\" width=\"576\" height=\"197\" \/><\/a><\/li>\n<\/ol>\n<p><\/root><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to extend a simple Linux project with custom actions. For this we make a program that<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[38],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/140"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=140"}],"version-history":[{"count":0,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/140\/revisions"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}