lldbrun 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f500af3654fffeeaa63954ba1a77909173738f8a0335d4c0d8af48c973eb57af
4
+ data.tar.gz: 8e4900a1a669ab1be5d2a5af022092e152f3b7cbb047e199837774feb54b81fc
5
+ SHA512:
6
+ metadata.gz: 0414e3ec9c65dd92c11806c9a3e9fc19c2918f7b5a5293b57dd0e4c9c609ea5c23a7ce7f007274c2b93cd6c01bd13b19adca31f16759c203d8b85645c207956d
7
+ data.tar.gz: cc8d1a44b4c778ddb8af89fe40a851d47abdeda1aa9b9a220251a6bd421ad703f9275cd43e31e23557a446ecee9d6efaeeb309df3834dd59093c9f2e56708818
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lldbrun"
5
+
6
+ argv_params = Lldbrun::ParserARGV.new(ARGV)
7
+ Lldbrun::ParserPoint.new(argv_params).run
@@ -0,0 +1,7 @@
1
+ require "lldbrun/version"
2
+ require "lldbrun/BreakPoint"
3
+ require "lldbrun/ParserARGV"
4
+ require "lldbrun/ParserPoint"
5
+
6
+ module Lldbrun
7
+ end
@@ -0,0 +1,15 @@
1
+ module Lldbrun
2
+ class BreakPoint
3
+
4
+ attr_reader :file, :line
5
+
6
+ def initialize(file, line)
7
+ @file = file
8
+ @line = line
9
+ end
10
+
11
+ def lldb_set_breakpoint_command
12
+ "breakpoint set --file #{file} --line #{line}"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,75 @@
1
+ module Lldbrun
2
+ class ParserARGV
3
+
4
+ DEFAULT_LLDB = ''
5
+ DEFAULT_START_DIR = `pwd`.strip
6
+
7
+ PARAMETER_FILE_PATH = '-f'
8
+ PARAMETER_SCAN_DIR = '-s'
9
+ PARAMETER_HELP = '-h'
10
+ PARAMETER_RUN = '-r'
11
+ PARAMETER_LLDB = '-l'
12
+
13
+ attr_reader :argv, :params
14
+
15
+ def initialize(argv)
16
+ @argv = argv
17
+ @params = {}
18
+
19
+ check_info
20
+ get_params
21
+ end
22
+
23
+ def param_file_path
24
+ params[PARAMETER_FILE_PATH] or DEFAULT_START_DIR
25
+ end
26
+
27
+ def param_lldb
28
+ params[PARAMETER_LLDB] or DEFAULT_LLDB
29
+ end
30
+
31
+ def param_scan_dir
32
+ params[PARAMETER_SCAN_DIR] or DEFAULT_START_DIR
33
+ end
34
+
35
+ def param_auto_run?
36
+ params[PARAMETER_RUN] ? params[PARAMETER_RUN] == 'true' : true
37
+ end
38
+
39
+ private
40
+
41
+ def check_info
42
+ if argv[0].strip == PARAMETER_HELP || argv.count == 0
43
+ info
44
+ end
45
+ end
46
+
47
+ def help
48
+ descriptions = []
49
+ descriptions << ["#{PARAMETER_FILE_PATH} <path> executable file of your program"]
50
+ descriptions << ["#{PARAMETER_SCAN_DIR} <path> root directory for scan breakpoints. Default - current terminal directory"]
51
+ descriptions << ["#{PARAMETER_LLDB} <' ... '>standard parameters LLDB in quotes -l '...' "]
52
+ descriptions << ["#{PARAMETER_RUN} <true/false> auto run LLDB after initialize breakpoints"]
53
+ descriptions << ["#{PARAMETER_HELP} <> this help"]
54
+ end
55
+
56
+ def get_params
57
+ argv.each_slice(2).to_a.each do |pair|
58
+ error_params if pair.size != 2
59
+ params[pair[0].strip] = pair[1].strip
60
+ end
61
+
62
+ self
63
+ end
64
+
65
+ def info
66
+ help.each { |descr| p descr}
67
+ exit 0
68
+ end
69
+
70
+ def error_params
71
+ p 'LLDBRUN: BAD PARAMETERS'
72
+ info
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,84 @@
1
+ module Lldbrun
2
+ class ParserPoint
3
+
4
+ LLDBPOINT = /^[\s\S]+lldbpoint[\s\S]+$/i
5
+ PREV_DIR = /^\.\./
6
+ CURRENT_DIR = /^\.$/
7
+ RELATIVE_PATH = /^[\.~]/
8
+
9
+ attr_reader :argv_parser, :break_points
10
+
11
+ def initialize(argv_parser)
12
+ @argv_parser = argv_parser
13
+ @break_points = []
14
+ end
15
+
16
+ def run
17
+ scan_dir(argv_parser.param_scan_dir)
18
+ system(generate_start_command)
19
+ end
20
+
21
+ private
22
+
23
+ def lldb_run_command
24
+ "lldb #{argv_parser.param_file_path}"
25
+ end
26
+
27
+ def generate_start_command
28
+ lldb_command = lldb_run_command
29
+ lldb_command << lldb_standard_params
30
+ break_points.each do |break_point|
31
+ lldb_command << " -o \"#{break_point.lldb_set_breakpoint_command}\""
32
+ end
33
+ lldb_command << lldb_run
34
+
35
+ lldb_command
36
+ end
37
+
38
+ def lldb_standard_params
39
+ ' ' << argv_parser.param_lldb
40
+ end
41
+
42
+ def lldb_run
43
+ argv_parser.param_auto_run? ? ' -o run' : ''
44
+ end
45
+
46
+ def full_path(dir, name)
47
+ "#{dir}/#{name}"
48
+ end
49
+
50
+ def absolute_file_path(path)
51
+ absolute_path = ''
52
+ if relative_path?(path)
53
+ absolute_path << "#{`pwd`.strip}/#{path}"
54
+ end
55
+
56
+ absolute_path
57
+ end
58
+
59
+ def relative_path?(path)
60
+ path[RELATIVE_PATH].to_i
61
+ end
62
+
63
+ def scan_file(path)
64
+ File.open(path, File::RDONLY) do |file|
65
+ file.each_with_index do |line, index|
66
+ @break_points << BreakPoint.new(absolute_file_path(path), index + 1) if line.encode("UTF-8", :invalid=>:replace, :replace=>"?")[LLDBPOINT]
67
+ end
68
+ file.close
69
+ end
70
+ end
71
+
72
+ def scan_dir(dir)
73
+ Dir.foreach(dir) do |name|
74
+ path = full_path(dir, name)
75
+ next if name[PREV_DIR] || name[CURRENT_DIR]
76
+ if File.directory?(path)
77
+ scan_dir(path)
78
+ next
79
+ end
80
+ scan_file(path)
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,3 @@
1
+ module Lldbrun
2
+ VERSION = "0.2.1"
3
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lldbrun
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Oleh Hudeichuk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ description: SCANNER BREAKPOINTS BASED ON LLDB
28
+ email:
29
+ - emptystamp@gmail.com
30
+ executables:
31
+ - lldbrun
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - bin/lldbrun
36
+ - lib/lldbrun.rb
37
+ - lib/lldbrun/BreakPoint.rb
38
+ - lib/lldbrun/ParserARGV.rb
39
+ - lib/lldbrun/ParserPoint.rb
40
+ - lib/lldbrun/version.rb
41
+ homepage: https://github.com/woodcrust/lldb-run
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.7.3
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: This is gem for scan breakpoints in your code and running lldb
65
+ test_files: []