Commit graph

65 commits

Author SHA1 Message Date
Tim Wojtulewicz
9cb54f5d44 clang-format: Force zeek-config.h to be earlier in the config ordering 2021-09-25 11:52:55 -07:00
Tim Wojtulewicz
b2f171ec69 Reformat the world 2021-09-16 15:35:39 -07:00
Vern Paxson
efd03d41f8 convert scopes to be managed using IntrusivePtr's 2021-05-30 17:20:29 -07:00
Tim Wojtulewicz
2f2a265415 Fix variable shadowing issues reported by LGTM 2021-03-03 09:57:16 -07:00
Jon Siwek
8a8a983c49 Add missing zeek/ to header includes
Related to https://github.com/zeek/zeek/pull/1377
2021-01-29 19:16:29 -08:00
Tim Wojtulewicz
0618be792f Remove all of the random single-file deprecations
These are the changes that don't require a ton of changes to other files outside
of the original removal.
2021-01-27 10:52:40 -07:00
Jon Siwek
a4986a17cb Update Debug.cc to use setsignal() wrapper
So as to prefer sigaction() over either sigset() or signal(), which are
less favorable due to underspecification issues and some treating them
as obsolete/deprecated.
2020-12-07 18:03:24 -08:00
Tim Wojtulewicz
bd1379e864 Move 'using namespace' declaration after other includes 2020-11-12 12:15:26 -07:00
Tim Wojtulewicz
96d9115360 GH-1079: Use full paths starting with zeek/ when including files 2020-11-12 12:15:26 -07:00
Tim Wojtulewicz
fe0c22c789 Base: Clean up explicit uses of namespaces in places where they're not necessary.
This commit covers all of the common and base classes.
2020-08-24 12:07:00 -07:00
Tim Wojtulewicz
0ac3fafe13 Move zeek::net namespace to zeek::run_state namespace.
This also moves all of the code from Net.{h,cc} to RunState.{h,cc} and marks Net.h as deprecated
2020-08-20 16:11:47 -07:00
Tim Wojtulewicz
db36688bf0 Move a few smaller files to zeek namespaces 2020-08-20 16:11:46 -07:00
Tim Wojtulewicz
8d2d867a65 Move everything in util.h to zeek::util namespace.
This commit includes renaming a number of methods prefixed with bro_ to be prefixed with zeek_.
2020-08-20 16:00:33 -07:00
Tim Wojtulewicz
e7c6d51ae7 Move the functions and variables in Net.h to the zeek::net namespace. This includes moving network_time out of util.h. 2020-08-20 15:55:17 -07:00
Tim Wojtulewicz
bfab224d7c Move Reporter to zeek namespace 2020-07-31 16:22:41 -04:00
Tim Wojtulewicz
35c61697d9 Move all debugger code into the zeek::detail namespace 2020-07-31 16:22:04 -04:00
Tim Wojtulewicz
a2bc42dd93 Move Func up to zeek namespace, rename BroFunc to ScriptFunc 2020-07-02 16:15:01 -07:00
Tim Wojtulewicz
40ecede4ea Move Location to zeek::detail and BroObj to zeek 2020-06-30 21:12:26 -07:00
Tim Wojtulewicz
d6f1ea16ac Move Func and associated classes into zeek::detail namespace 2020-06-30 20:51:58 -07:00
Tim Wojtulewicz
937a462e70 Move Frame and Scope to zeek::detail namespace 2020-06-30 20:51:53 -07:00
Tim Wojtulewicz
64332ca22c Move all Val classes to the zeek namespaces 2020-06-30 20:48:09 -07:00
Tim Wojtulewicz
ec9eff0bd5 Use type aliases for IntrusivePtr definitions 2020-06-30 20:37:30 -07:00
Tim Wojtulewicz
9364e6a5b7 Move IntrusivePtr and utility methods to the zeek namespace 2020-06-30 20:19:12 -07:00
Tim Wojtulewicz
cbdb8ee074 Expr: move all classes into zeek::detail 2020-06-03 15:16:18 -07:00
Tim Wojtulewicz
3fa4acc175 Stmt: move Stmt classes into zeek::detail namespace 2020-06-03 13:37:57 -07:00
Jon Siwek
0af7f8141b Change lookup_ID() to return a const-reference 2020-05-14 17:24:21 -07:00
Jon Siwek
32b895f4ba Deprecate ID::ID_Val(), replace with ID::GetVal() 2020-05-14 17:18:00 -07:00
Jon Siwek
3f07c57523 Deprecate ID::Type(), replace with GetType() 2020-05-14 17:18:00 -07:00
Jon Siwek
15a19414ca GH-895: Remove use of Variable-Length-Arrays 2020-04-15 16:25:21 -07:00
Tim Wojtulewicz
0a47588d0b The remaining nulls 2020-04-07 16:08:34 -07:00
Tim Wojtulewicz
fd5e15b116 The Great Embooleanating
A large number of functions had return values and/or arguments changed
to use ``bool`` types instead of ``int``.
2020-03-31 06:41:54 +00:00
Jon Siwek
b62727a7fa Merge branch 'intrusive_ptr' of https://github.com/MaxKellermann/zeek
* 'intrusive_ptr' of https://github.com/MaxKellermann/zeek: (32 commits)
  Scope: store IntrusivePtr in `local`
  Scope: pass IntrusivePtr to AddInit()
  DNS_Mgr: use class IntrusivePtr
  Scope: use class IntrusivePtr
  Attr: use class IntrusivePtr
  Expr: check_and_promote_expr() returns IntrusivePtr
  Frame: use class IntrusivePtr
  Val: RecordVal::LookupWithDefault() returns IntrusivePtr
  Type: RecordType::FieldDefault() returns IntrusivePtr
  Val: TableVal::Delete() returns IntrusivePtr
  Type: base_type() returns IntrusivePtr
  Type: init_type() returns IntrusivePtr
  Type: merge_types() returns IntrusivePtr
  Type: use class IntrusivePtr in VectorType
  Type: use class IntrusivePtr in EnumType
  Type: use class IntrusivePtr in FileType
  Type: use class IntrusivePtr in TypeDecl
  Type: make TypeDecl `final` and the dtor non-`virtual`
  Type: use class IntrusivePtr in TypeType
  Type: use class IntrusivePtr in FuncType
  ...
2020-03-17 22:51:46 -07:00
Max Kellermann
a0c831a1bd Func: use class IntrusivePtr 2020-03-06 09:06:37 +01:00
Jon Siwek
cf196bb148 Merge branch 'leaks' of https://github.com/MaxKellermann/zeek
Only one instance of base_type() getting a NewRef instead of AdoptRef
fixed in merge.  All other changes are superficial formatting and
factoring.

* 'leaks' of https://github.com/MaxKellermann/zeek: (22 commits)
  Stmt: use class IntrusivePtr
  Stmt: remove unused default constructors and `friend` declarations
  Val: remove unimplemented prototype recover_val()
  Val: cast_value_to_type() returns IntrusivePtr
  Val: use IntrusivePtr in check_and_promote()
  Val: use nullptr instead of 0
  zeekygen: use class IntrusivePtr
  ID: use class IntrusivePtr
  Expr: use class IntrusivePtr
  Var: copy Location to stack, to fix use-after-free crash bug
  Scope: lookup_ID() and install_ID() return IntrusivePtr<ID>
  Scope: delete duplicate locals
  EventRegistry: automatically delete EventHandlers
  main: destroy event_registry after iosource_mgr
  zeekygen/IdentifierInfo: delete duplicate fields
  main: free the global scope in terminate_bro()
  Scope: pop_scope() returns IntrusivePtr<>
  Scope: unref all inits in destructor
  Var: pass IntrusivePtr to add_global(), add_local() etc.
  plugin/ComponentManager: hold a reference to the EnumType
  ...
2020-02-28 00:48:20 -08:00
Max Kellermann
c3ea246237 Expr: use class IntrusivePtr
As a side effect, this fixes lots of memory leaks in
`*Expr::InitVal()` because in most implementations, the `aggr`
parameter leaks.
2020-02-27 12:06:34 +01:00
Max Kellermann
528cf11a5c Scope: lookup_ID() and install_ID() return IntrusivePtr<ID>
This fixes several memory leaks and double free bugs.
2020-02-27 12:02:55 +01:00
Max Kellermann
875bfc09a2 Scope: pop_scope() returns IntrusivePtr<>
Make sure unused scopes are freed to fix memory leaks.

The comment inside pop_scope() is now obsolete and I deleted it,
because this commit implements the real solution.

Note that this requires us to add a reference to the
push_existing_scope() call in dbg_eval_expr(), because it never owned
the reference.
2020-02-27 12:02:55 +01:00
Max Kellermann
0db61f3094 include cleanup
The Zeek code base has very inconsistent #includes.  Many sources
included a few headers, and those headers included other headers, and
in the end, nearly everything is included everywhere, so missing
#includes were never noticed.  Another side effect was a lot of header
bloat which slows down the build.

First step to fix it: in each source file, its own header should be
included first to verify that each header's includes are correct, and
none is missing.

After adding the missing #includes, I replaced lots of #includes
inside headers with class forward declarations.  In most headers,
object pointers are never referenced, so declaring the function
prototypes with forward-declared classes is just fine.

This patch speeds up the build by 19%, because each compilation unit
gets smaller.  Here are the "time" numbers for a fresh build (with a
warm page cache but without ccache):

Before this patch:

 3144.94user 161.63system 3:02.87elapsed 1808%CPU (0avgtext+0avgdata 2168608maxresident)k
 760inputs+12008400outputs (1511major+57747204minor)pagefaults 0swaps

After this patch:

 2565.17user 141.83system 2:25.46elapsed 1860%CPU (0avgtext+0avgdata 1489076maxresident)k
 72576inputs+9130920outputs (1667major+49400430minor)pagefaults 0swaps
2020-02-04 20:51:02 +01:00
Tim Wojtulewicz
67fcc9b5af Mark safe_snprintf and safe_vsnprintf as deprecated, remove uses of them
safe_snprintf and safe_vsnprintf just exist to ensure that the resulting strings are always null-terminated. The documentation for snprintf/vsnprintf states that the output of those methods are always null-terminated, thus making the safe versions obsolete.
2020-01-02 15:36:39 -07:00
Jon Siwek
6255ab6584 Fix misc. Coverity warnings 2019-08-14 16:19:56 -07:00
Tim Wojtulewicz
d0e8af9343 g_dbgfilemaps: Remove uses of PDict 2019-08-13 19:57:42 -07:00
Tim Wojtulewicz
bf70dad395 Remove loop_over_queue (as an example for later removing loop_over_list) 2019-07-15 19:00:15 -07:00
Tim Wojtulewicz
50943a580c Replace uses of the old Dict generation code with new template versions 2019-07-15 18:54:07 -07:00
Daniel Thayer
0ae1bfa29d Rename bro to zeek in error messages
More renaming in error messages and a few other places.
2019-06-16 23:08:45 -05:00
Robin Sommer
789cb376fd GH-239: Rename bro to zeek, bro-config to zeek-config, and bro-path-dev to zeek-path-dev.
This also installs symlinks from "zeek" and "bro-config" to a wrapper
script that prints a deprecation warning.

The btests pass, but this is still WIP. broctl renaming is still
missing.

#239
2019-05-01 21:43:45 +00:00
Daniel Thayer
7366155bad Update script search logic for new file extension
When searching for script files, look for both the new and old file
extensions.  If a file with ".zeek" can't be found, then search for
a file with ".bro" as a fallback.
2019-04-09 01:26:16 -05:00
Johanna Amann
48f505f706 Fix a debugger bug where it would not support statements like print(3).
This is a manual merge of a branch of Vlad Grigorescu.

BIT-1703 #merged
2016-09-26 10:17:12 -07:00
Robin Sommer
3957091e1b Renaming config.h to bro-config.h.
A couple times now I had this conflicting with files of the same name
in other projects.
2015-07-28 11:57:04 -07:00
Jon Siwek
8b7d5a68b2 Fix reference counting for lookup_ID() usages.
That function refs the ID before returning it, but callers were never
assuming responsibility for that reference.
2014-05-01 15:00:03 -05:00
Jon Siwek
90477df973 Refactor search_for_file() util function.
It was getting too bloated and allocated memory in ways that were
difficult to understand how to manage.  Separated out primarily in to
new find_file() and open_file()/open_package() functions.

Also renamed other util functions for path-related things.
2013-10-07 15:01:03 -05:00