Bug 162585 - Cannot run dump-class-layout; dies with "global name 'lldb' is not defined"
Summary: Cannot run dump-class-layout; dies with "global name 'lldb' is not defined"
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Local Build
Hardware: Mac macOS 10.12
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-26 17:26 PDT by Daniel Bates
Modified: 2016-09-27 10:21 PDT (History)
4 users (show)

See Also:


Attachments
Patch (2.52 KB, patch)
2016-09-26 17:45 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2016-09-26 17:26:30 PDT
When I ran dump-class-layout today (09/26) to see the object size of ResourceHandle it died with the following traceback:

[[
$ Tools/Scripts/dump-class-layout -c Debug WebCore ResourceHandle
Traceback (most recent call last):
  File "Tools/Scripts/dump-class-layout", line 169, in <module>
    main()
  File "Tools/Scripts/dump-class-layout", line 166, in main
    dump_class(target_path, args.classname)
  File "Tools/Scripts/dump-class-layout", line 120, in dump_class
    debugger = lldb.SBDebugger.Create()
NameError: global name 'lldb' is not defined
]]

I am using Python 2.7.10.
Comment 1 Daniel Bates 2016-09-26 17:33:01 PDT
We import the lldb inside the function import_lldb() in dump-class-layout on line 48, <https://trac.webkit.org/browser/trunk/Tools/Scripts/dump-class-layout?rev=188350#L48>. By (2) of <https://docs.python.org/2/reference/simple_stmts.html#import>, the names from the imported module are defined "in the local namespace (of the scope where the import statement occurs)". And each function creates a local namespace by <https://docs.python.org/2/tutorial/classes.html#python-scopes-and-namespaces>. Therefore, import_lldb() does not import the lldb module into the global namespace.
Comment 2 Daniel Bates 2016-09-26 17:45:51 PDT
Created attachment 289896 [details]
Patch
Comment 3 Daniel Bates 2016-09-27 10:21:16 PDT
Comment on attachment 289896 [details]
Patch

Clearing flags on attachment: 289896

Committed r206441: <http://trac.webkit.org/changeset/206441>
Comment 4 Daniel Bates 2016-09-27 10:21:20 PDT
All reviewed patches have been landed.  Closing bug.