{"id":130,"date":"2025-06-03T10:58:15","date_gmt":"2025-06-03T10:58:15","guid":{"rendered":"https:\/\/haco.club\/?p=130"},"modified":"2025-06-03T10:58:15","modified_gmt":"2025-06-03T10:58:15","slug":"how-to-run-a-program-with-commandline-arguments-using-gdb-within-a-bash-script","status":"publish","type":"post","link":"https:\/\/haco.club\/?p=130","title":{"rendered":"How to run a program with commandline arguments using GDB within a Bash script?"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/6121094\/how-do-i-run-a-program-with-commandline-arguments-using-gdb-within-a-bash-script\">https:\/\/stackoverflow.com\/questions\/6121094\/how-do-i-run-a-program-with-commandline-arguments-using-gdb-within-a-bash-script<\/a><\/p>\n<\/blockquote>\n\n\n\n<p>Run gdb with\u00a0<code>--args<\/code>\u00a0parameter:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gdb --args executablename arg1 arg2 arg3<\/code><\/pre>\n\n\n\n<p>If you are doing this often (e.g. when running GDB from a script), you might want to consider the following arguments to automate things further. First, you can place your GDB commands (such as &#8216;run&#8217;) in a text file and provide the filename to the\u00a0<code>-x<\/code>\u00a0argument. Second, you can have GDB exit after running your commands by providing the\u00a0<code>--batch<\/code>\u00a0argument. A full example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gdb -x commands.txt --batch --args executablename arg1 arg2 arg3<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/stackoverflow.com\/questions\/6121094\/how-do-i-run-a-program-with-commandline-arguments-using-gdb-within-a-bash-script Run gdb with\u00a0&#8211;args\u00a0parameter: If you are doing this often [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[10],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-tutotial","tag-toolchain"],"_links":{"self":[{"href":"https:\/\/haco.club\/index.php?rest_route=\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haco.club\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haco.club\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haco.club\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haco.club\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130"}],"version-history":[{"count":1,"href":"https:\/\/haco.club\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":131,"href":"https:\/\/haco.club\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions\/131"}],"wp:attachment":[{"href":"https:\/\/haco.club\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haco.club\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haco.club\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}