0

A global var is defined in my framework var showersInProgress: [ProgressShower] = []

It's global so that I can stop the program and hopefully examine the state like so:

(lldb) po showersInProgress

error: <user expression 7>:1:1: use of undeclared identifier 'showersInProgress' showersInProgress

(lldb) p showersInProgress

error: <user expression 8>:1:1: use of undeclared identifier 'showersInProgress' showersInProgress

(lldb) frame variable showersInProgress
(lldb) frame  showersInProgress
invalid command 'frame showersInProgress'.
(lldb) frame -g showersInProgress
invalid command 'frame -g'.
(lldb) frame -g variable showersInProgress
invalid command 'frame -g'.
(lldb) frame variable -g showersInProgress
(lldb) frame variable -g showersInProgress.count
(lldb) 

The log enable -f /tmp/lldb-log.txt lldb expr types in case it's useful to anyone:

 == [UserExpression::Evaluate] Parsing expression showersInProgress ==
 ClangUserExpression::ScanContext()
   [CUE::SC] Null function
 [C++ module config] Language doesn't support C++ modules
 List of imported modules in expression: 
 List of include directories gathered for modules: 
 Parsing the following code:


#line 1 "<lldb wrapper prefix>"
#ifndef offsetof
#define offsetof(t, d) __builtin_offsetof(t, d)
#endif
#ifndef NULL
#define NULL (__null)
#endif
#ifndef Nil
#define Nil (__null)
#endif
#ifndef nil
#define nil (__null)
#endif
#ifndef YES
#define YES ((BOOL)1)
#endif
#ifndef NO
#define NO ((BOOL)0)
#endif
typedef __INT8_TYPE__ int8_t;
typedef __UINT8_TYPE__ uint8_t;
typedef __INT16_TYPE__ int16_t;
typedef __UINT16_TYPE__ uint16_t;
typedef __INT32_TYPE__ int32_t;
typedef __UINT32_TYPE__ uint32_t;
typedef __INT64_TYPE__ int64_t;
typedef __UINT64_TYPE__ uint64_t;
typedef __INTPTR_TYPE__ intptr_t;
typedef __UINTPTR_TYPE__ uintptr_t;
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef unsigned short unichar;
extern "C"
{
    int printf(const char * __restrict, ...);
}

typedef bool BOOL;


void                           
$__lldb_expr(void *$__lldb_arg)          
{                              
    ;                        
#line 1 "<user expression 9>"
showersInProgress
;
#line 1 "<lldb wrapper suffix>"
}                              

 Using x86_64-apple-ios-simulator as the target triple
 Using SIMD alignment: 128
 Target datalayout string: 'e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128'
 Target ABI: ''
 Target vector alignment: 128
 ClangExpressionDeclMap::FindExternalVisibleDecls[469] for '$__lldb_arg' in a 'TranslationUnit'
   CEDM::FEVD[469] Searching the root namespace
 ClangASTSource::FindExternalVisibleDecls[469] on (ASTContext*)0x7fb6b48f1800 for '$__lldb_arg' in a 'TranslationUnit'
   CAS::FEVD[469] Searching the root namespace
 ClangExpressionDeclMap::FindExternalVisibleDecls[470] for '$__lldb_expr' in a 'TranslationUnit'
   CEDM::FEVD[470] Searching the root namespace
 ClangASTSource::FindExternalVisibleDecls[470] on (ASTContext*)0x7fb6b48f1800 for '$__lldb_expr' in a 'TranslationUnit'
   CAS::FEVD[470] Searching the root namespace
 ClangExpressionDeclMap::FindExternalVisibleDecls[471] for 'showersInProgress' in a 'TranslationUnit'
   CEDM::FEVD[471] Searching the root namespace
 Skipped a definition because it has no Clang AST
 ClangASTSource::FindExternalVisibleDecls[471] on (ASTContext*)0x7fb6b48f1800 for 'showersInProgress' in a 'TranslationUnit'
   CAS::FEVD[471] Searching the root namespace
 AppleObjCDeclVendor::FindDecls [434] ('showersInProgress', false, 1, )
 AOCTV::FT [434] Couldn't find showersInProgress in the ASTContext
 AOCTV::FT [434] Couldn't find the isa
     [ClangASTImporter] Forgetting destination (ASTContext*)0x7fb6b48f1800
     [ClangASTImporter] Forgetting source->dest (ASTContext*)0x7fb6b48f1800->(ASTContext*)0x7fb69758cc00
Anton Tropashko
  • 5,486
  • 5
  • 41
  • 66
  • 1
    `frame variable` only shows statics in the CompileUnit of the current frame. If you want to see all the globals you need to use `target variable`. Note, however, `target variable` only searches the shared library of the current frame. You can add the `--shlib` flag to direct the search to a specific shared library. If that doesn't work, then you should probably file a bug with bugs.swift.org with a reproducer for the problem. – Jim Ingham Feb 18 '21 at 18:31
  • target variable worked. But target variable showersInProgress.count naturally didn't (the output of target variable showersInProgress is voluminuous). Anyhow you deserve an answer to upvote and accept for the original question if not the greedy one. – Anton Tropashko Feb 19 '21 at 07:01
  • I put the answer into the answers because it's a useful workaround. But it still makes me sad that the expression evaluator didn't find something that the target variable search did. If you have a example that fails like this that you can make available, please file a bug with the example, and where you were stopped when the po & p failed like this. – Jim Ingham Feb 19 '21 at 18:38

1 Answers1

1

frame variable only shows statics in the CompileUnit of the current frame. If you want to see all the globals you need to use target variable. Note, however, target variable only searches the shared library of the current frame. You can add the --shlib flag to direct the search to a specific shared library.

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63