how to recast and print variables in lldb





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have a pointer to a string



void *s = "now is the time for all"


and I wish to print it as an integer of 32-bit size:



gdb) p /x *((int *)s)


What is the equivalence in lldb parlance?










share|improve this question





























    0















    I have a pointer to a string



    void *s = "now is the time for all"


    and I wish to print it as an integer of 32-bit size:



    gdb) p /x *((int *)s)


    What is the equivalence in lldb parlance?










    share|improve this question

























      0












      0








      0








      I have a pointer to a string



      void *s = "now is the time for all"


      and I wish to print it as an integer of 32-bit size:



      gdb) p /x *((int *)s)


      What is the equivalence in lldb parlance?










      share|improve this question














      I have a pointer to a string



      void *s = "now is the time for all"


      and I wish to print it as an integer of 32-bit size:



      gdb) p /x *((int *)s)


      What is the equivalence in lldb parlance?







      lldb macos-high-sierra






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 15:41









      Egbert SEgbert S

      5121619




      5121619
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Exactly that, except you can't put a space between the p and the /x.



          lldb's command syntax is not the same as lldb's (for more details see:



          http://lldb.llvm.org/tutorial.html



          ) but p (among others) was added (as an alias to the lldb expr command) for people more familiar with gdb's commands. However, to get the /x part working through lldb's command parser it has to be directly postpended to the actual command name so it isn't confused with arguments and options. So:



          (lldb) p/x *((int *) text_to_use)
          (int) $1 = 0x8f06c8c0


          There's also a cheat sheet for lldb <-> gdb commands here:



          http://lldb.llvm.org/lldb-gdb.html



          which you might find handy.






          share|improve this answer
























          • Why in the world does lldb reinstitue strong typing?

            – Egbert S
            Nov 27 '18 at 10:34











          • Not sure what you mean by that.

            – Jim Ingham
            Nov 27 '18 at 19:00











          • Long typing, long typing, long typing of commands

            – Egbert S
            Nov 27 '18 at 22:02











          • After working on gdb for over 10 years, I was constantly amazed by how small the subset of gdb commands people actually knew existed was. I think part of the reason is the command structure of gdb is flat and fairly ad hoc, which made it hard to explore. So in lldb we ordered the commands in a logical, easy to explore fashion. Then we added several powerful alias facilities so that common commands could be typed quickly. There's a built-in set listed at the end of the 'help' command. And you can add your own if there are commands you use more frequently.

            – Jim Ingham
            Nov 27 '18 at 23:12











          • Note also, lldb does shortest unique matching so you generally have to only type one or two characters of the command name.

            – Jim Ingham
            Nov 27 '18 at 23:12












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53484563%2fhow-to-recast-and-print-variables-in-lldb%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Exactly that, except you can't put a space between the p and the /x.



          lldb's command syntax is not the same as lldb's (for more details see:



          http://lldb.llvm.org/tutorial.html



          ) but p (among others) was added (as an alias to the lldb expr command) for people more familiar with gdb's commands. However, to get the /x part working through lldb's command parser it has to be directly postpended to the actual command name so it isn't confused with arguments and options. So:



          (lldb) p/x *((int *) text_to_use)
          (int) $1 = 0x8f06c8c0


          There's also a cheat sheet for lldb <-> gdb commands here:



          http://lldb.llvm.org/lldb-gdb.html



          which you might find handy.






          share|improve this answer
























          • Why in the world does lldb reinstitue strong typing?

            – Egbert S
            Nov 27 '18 at 10:34











          • Not sure what you mean by that.

            – Jim Ingham
            Nov 27 '18 at 19:00











          • Long typing, long typing, long typing of commands

            – Egbert S
            Nov 27 '18 at 22:02











          • After working on gdb for over 10 years, I was constantly amazed by how small the subset of gdb commands people actually knew existed was. I think part of the reason is the command structure of gdb is flat and fairly ad hoc, which made it hard to explore. So in lldb we ordered the commands in a logical, easy to explore fashion. Then we added several powerful alias facilities so that common commands could be typed quickly. There's a built-in set listed at the end of the 'help' command. And you can add your own if there are commands you use more frequently.

            – Jim Ingham
            Nov 27 '18 at 23:12











          • Note also, lldb does shortest unique matching so you generally have to only type one or two characters of the command name.

            – Jim Ingham
            Nov 27 '18 at 23:12
















          1














          Exactly that, except you can't put a space between the p and the /x.



          lldb's command syntax is not the same as lldb's (for more details see:



          http://lldb.llvm.org/tutorial.html



          ) but p (among others) was added (as an alias to the lldb expr command) for people more familiar with gdb's commands. However, to get the /x part working through lldb's command parser it has to be directly postpended to the actual command name so it isn't confused with arguments and options. So:



          (lldb) p/x *((int *) text_to_use)
          (int) $1 = 0x8f06c8c0


          There's also a cheat sheet for lldb <-> gdb commands here:



          http://lldb.llvm.org/lldb-gdb.html



          which you might find handy.






          share|improve this answer
























          • Why in the world does lldb reinstitue strong typing?

            – Egbert S
            Nov 27 '18 at 10:34











          • Not sure what you mean by that.

            – Jim Ingham
            Nov 27 '18 at 19:00











          • Long typing, long typing, long typing of commands

            – Egbert S
            Nov 27 '18 at 22:02











          • After working on gdb for over 10 years, I was constantly amazed by how small the subset of gdb commands people actually knew existed was. I think part of the reason is the command structure of gdb is flat and fairly ad hoc, which made it hard to explore. So in lldb we ordered the commands in a logical, easy to explore fashion. Then we added several powerful alias facilities so that common commands could be typed quickly. There's a built-in set listed at the end of the 'help' command. And you can add your own if there are commands you use more frequently.

            – Jim Ingham
            Nov 27 '18 at 23:12











          • Note also, lldb does shortest unique matching so you generally have to only type one or two characters of the command name.

            – Jim Ingham
            Nov 27 '18 at 23:12














          1












          1








          1







          Exactly that, except you can't put a space between the p and the /x.



          lldb's command syntax is not the same as lldb's (for more details see:



          http://lldb.llvm.org/tutorial.html



          ) but p (among others) was added (as an alias to the lldb expr command) for people more familiar with gdb's commands. However, to get the /x part working through lldb's command parser it has to be directly postpended to the actual command name so it isn't confused with arguments and options. So:



          (lldb) p/x *((int *) text_to_use)
          (int) $1 = 0x8f06c8c0


          There's also a cheat sheet for lldb <-> gdb commands here:



          http://lldb.llvm.org/lldb-gdb.html



          which you might find handy.






          share|improve this answer













          Exactly that, except you can't put a space between the p and the /x.



          lldb's command syntax is not the same as lldb's (for more details see:



          http://lldb.llvm.org/tutorial.html



          ) but p (among others) was added (as an alias to the lldb expr command) for people more familiar with gdb's commands. However, to get the /x part working through lldb's command parser it has to be directly postpended to the actual command name so it isn't confused with arguments and options. So:



          (lldb) p/x *((int *) text_to_use)
          (int) $1 = 0x8f06c8c0


          There's also a cheat sheet for lldb <-> gdb commands here:



          http://lldb.llvm.org/lldb-gdb.html



          which you might find handy.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 18:25









          Jim InghamJim Ingham

          14.5k13035




          14.5k13035













          • Why in the world does lldb reinstitue strong typing?

            – Egbert S
            Nov 27 '18 at 10:34











          • Not sure what you mean by that.

            – Jim Ingham
            Nov 27 '18 at 19:00











          • Long typing, long typing, long typing of commands

            – Egbert S
            Nov 27 '18 at 22:02











          • After working on gdb for over 10 years, I was constantly amazed by how small the subset of gdb commands people actually knew existed was. I think part of the reason is the command structure of gdb is flat and fairly ad hoc, which made it hard to explore. So in lldb we ordered the commands in a logical, easy to explore fashion. Then we added several powerful alias facilities so that common commands could be typed quickly. There's a built-in set listed at the end of the 'help' command. And you can add your own if there are commands you use more frequently.

            – Jim Ingham
            Nov 27 '18 at 23:12











          • Note also, lldb does shortest unique matching so you generally have to only type one or two characters of the command name.

            – Jim Ingham
            Nov 27 '18 at 23:12



















          • Why in the world does lldb reinstitue strong typing?

            – Egbert S
            Nov 27 '18 at 10:34











          • Not sure what you mean by that.

            – Jim Ingham
            Nov 27 '18 at 19:00











          • Long typing, long typing, long typing of commands

            – Egbert S
            Nov 27 '18 at 22:02











          • After working on gdb for over 10 years, I was constantly amazed by how small the subset of gdb commands people actually knew existed was. I think part of the reason is the command structure of gdb is flat and fairly ad hoc, which made it hard to explore. So in lldb we ordered the commands in a logical, easy to explore fashion. Then we added several powerful alias facilities so that common commands could be typed quickly. There's a built-in set listed at the end of the 'help' command. And you can add your own if there are commands you use more frequently.

            – Jim Ingham
            Nov 27 '18 at 23:12











          • Note also, lldb does shortest unique matching so you generally have to only type one or two characters of the command name.

            – Jim Ingham
            Nov 27 '18 at 23:12

















          Why in the world does lldb reinstitue strong typing?

          – Egbert S
          Nov 27 '18 at 10:34





          Why in the world does lldb reinstitue strong typing?

          – Egbert S
          Nov 27 '18 at 10:34













          Not sure what you mean by that.

          – Jim Ingham
          Nov 27 '18 at 19:00





          Not sure what you mean by that.

          – Jim Ingham
          Nov 27 '18 at 19:00













          Long typing, long typing, long typing of commands

          – Egbert S
          Nov 27 '18 at 22:02





          Long typing, long typing, long typing of commands

          – Egbert S
          Nov 27 '18 at 22:02













          After working on gdb for over 10 years, I was constantly amazed by how small the subset of gdb commands people actually knew existed was. I think part of the reason is the command structure of gdb is flat and fairly ad hoc, which made it hard to explore. So in lldb we ordered the commands in a logical, easy to explore fashion. Then we added several powerful alias facilities so that common commands could be typed quickly. There's a built-in set listed at the end of the 'help' command. And you can add your own if there are commands you use more frequently.

          – Jim Ingham
          Nov 27 '18 at 23:12





          After working on gdb for over 10 years, I was constantly amazed by how small the subset of gdb commands people actually knew existed was. I think part of the reason is the command structure of gdb is flat and fairly ad hoc, which made it hard to explore. So in lldb we ordered the commands in a logical, easy to explore fashion. Then we added several powerful alias facilities so that common commands could be typed quickly. There's a built-in set listed at the end of the 'help' command. And you can add your own if there are commands you use more frequently.

          – Jim Ingham
          Nov 27 '18 at 23:12













          Note also, lldb does shortest unique matching so you generally have to only type one or two characters of the command name.

          – Jim Ingham
          Nov 27 '18 at 23:12





          Note also, lldb does shortest unique matching so you generally have to only type one or two characters of the command name.

          – Jim Ingham
          Nov 27 '18 at 23:12




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53484563%2fhow-to-recast-and-print-variables-in-lldb%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wiesbaden

          Marschland

          Dieringhausen